using `windowsHide: true` is causing an issue on windows: Ctrl + C handling isn't enabled and no `SIGINT` is sent to the child process when users exit the process. See https://github.com/nodejs/node/issues/29837 and https://github.com/nodejs/node-v0.x-archive/issues/5054 for reference. This will cause leftover processes throughout nx. This PR sets `windowsHide: false` everywhere except for the plugin workers and some short-lived utils. They `spawn` child processes but have explicit handling to make sure they kill themselves when the parent process dies, so the missing Ctrl + C handling doesn't cause issues. We will follow up to make sure any other culprits that still cause windows popups (especially when used through Nx Console) are handled. Leaving no leftover processes running is more important for now, though. Keep in mind the underlying tooling (like vite) might have some windows popups themselves that Nx will inherit.
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { execSync } from 'child_process';
|
|
import { gte, major, maxSatisfying } from 'semver';
|
|
|
|
// The GITHUB_REF_NAME is a full version (i.e. 17.3.2). The branchName will strip the patch version number.
|
|
// We will publish docs to the website branch based on the current tag (i.e. website-17)
|
|
const currentVersion = process.env.GITHUB_REF_NAME || '';
|
|
console.log(`Comparing ${currentVersion} to npm versions`);
|
|
|
|
const majorVersion = major(currentVersion);
|
|
const releasedVersions: string[] = JSON.parse(
|
|
execSync(`npm show nx@^${majorVersion} version --json`, {
|
|
windowsHide: false,
|
|
}).toString()
|
|
);
|
|
|
|
const latestVersion = maxSatisfying(releasedVersions, `^${majorVersion}`);
|
|
|
|
console.log(`Found npm versions:\n${releasedVersions.join('\n')}`);
|
|
|
|
// Publish if the current version is greater than or equal to the latest released version
|
|
|
|
const branchName = `website-${majorVersion}`;
|
|
if (currentVersion && latestVersion && gte(currentVersion, latestVersion)) {
|
|
console.log(
|
|
`Publishing docs site for ${process.env.GITHUB_REF_NAME} to ${branchName}`
|
|
);
|
|
// We force recreate the branch in order to always be up to date and avoid merge conflicts within the automated workflow
|
|
execSync(`git branch -f ${branchName}`, {
|
|
windowsHide: false,
|
|
});
|
|
execSync(`git push -f origin ${branchName}`, {
|
|
windowsHide: false,
|
|
});
|
|
} else {
|
|
console.log(`Not publishing docs to ${branchName}`);
|
|
}
|