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

72 lines
2.0 KiB
TypeScript

import * as chalk from 'chalk';
import { execSync } from 'child_process';
import { removeSync } from 'fs-extra';
import { join, resolve } from 'path';
import {
generateExternalPackageSchemas,
generateLocalPackageSchemas,
generatePackageSchemas,
} from '../package-schemas/generatePackageSchemas';
import { generateCliDocumentation } from './generate-cli-data';
import { generateCnwDocumentation } from './generate-cnw-documentation';
import { generateDevkitDocumentation } from './generate-devkit-documentation';
import { generateManifests } from './generate-manifests';
const workspaceRoot = resolve(__dirname, '../../../');
async function generate() {
try {
console.log(`${chalk.blue('i')} Generating Documentation`);
const generatedOutputDirectory = join(workspaceRoot, 'docs', 'generated');
removeSync(generatedOutputDirectory);
const commandsOutputDirectory = join(
workspaceRoot,
'docs',
'generated',
'cli'
);
await generateCnwDocumentation(commandsOutputDirectory);
await generateCliDocumentation(commandsOutputDirectory);
await generateDevkitDocumentation();
await generateLocalPackageSchemas();
await generateExternalPackageSchemas();
await generateManifests(workspaceRoot);
console.log(`\n${chalk.green('✓')} Generated Documentation\n`);
} catch (e) {
console.error(e);
process.exit(1);
}
}
function checkDocumentation() {
const output = execSync('git status --porcelain ./docs', {
windowsHide: false,
}).toString('utf-8');
if (output) {
console.log(
`${chalk.red(
'!'
)} 📄 Documentation has been modified, you need to commit the changes. ${chalk.red(
'!'
)} `
);
console.log('\nChanged Docs:');
execSync('git status --porcelain ./docs', {
stdio: 'inherit',
windowsHide: false,
});
process.exit(1);
} else {
console.log('📄 Documentation not modified');
}
}
generate().then(() => checkDocumentation());