MaxKless 499300fd76
fix(core): repair SIGINT signals on windows (#28496)
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.
2024-10-17 15:03:37 -04:00

63 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
/**
* USAGE:
*
* Run the following command from the root of the workspace.
* Replace the versions with the correct target versions
*
* pnpm ts-node scripts/angular-support-upgrades/init-upgrade.ts --angularVersion=next --targetNxVersion=15.5.0 --targetNxMigrationVersion=15.5.0-beta.0
*
*/
import { execSync } from 'child_process';
import { buildMigrations } from './build-migrations';
import { fetchVersionsFromRegistry } from './fetch-versions-from-registry';
import { updatePackageJsonForAngular } from './update-package-jsons';
import { updateVersionUtils } from './update-version-utils';
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const argv = yargs(hideBin(process.argv)).argv;
if (
!argv.angularVersion &&
!argv.targetNxVersion &&
!argv.targetNxMigrationVersion
) {
throw new Error(
'You need to provide --angularVersion=(latest|next) and --targetNxVersion=versionString and --targetNxMigrationVersion=versionString'
);
}
async function run() {
const packageVersionMap = await fetchVersionsFromRegistry(
argv.angularVersion
);
await updatePackageJsonForAngular(packageVersionMap);
await buildMigrations(
packageVersionMap,
argv.targetNxVersion,
argv.targetNxMigrationVersion
);
updateVersionUtils(packageVersionMap);
console.log('⏳ - Installing packages...');
execSync('pnpm install', {
stdio: 'inherit',
encoding: 'utf8',
windowsHide: false,
});
console.log('✅ - Finished installing packages!');
console.log('⏳ - Formatting files...');
execSync('pnpm nx format', {
stdio: 'inherit',
encoding: 'utf8',
windowsHide: false,
});
console.log('✅ - Finished creating migrations!');
}
run();