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.
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
import { ensureDirSync } from 'fs-extra';
|
|
import { join } from 'path';
|
|
import { readdirSync, writeFileSync } from 'fs';
|
|
import { execSync } from 'child_process';
|
|
|
|
function generateFileContent(
|
|
workspaces: { id: string; label: string; url: string }[]
|
|
) {
|
|
return `
|
|
window.exclude = [];
|
|
window.watch = false;
|
|
window.environment = 'dev';
|
|
window.useXstateInspect = false;
|
|
|
|
window.appConfig = {
|
|
showDebugger: true,
|
|
showExperimentalFeatures: true,
|
|
workspaces: ${JSON.stringify(workspaces)},
|
|
defaultWorkspaceId: '${workspaces[0].id}',
|
|
};
|
|
`;
|
|
}
|
|
|
|
function writeFile() {
|
|
let generatedGraphs;
|
|
try {
|
|
generatedGraphs = readdirSync(
|
|
join(__dirname, '../graph/client/src/assets/generated-project-graphs')
|
|
).map((filename) => {
|
|
const id = filename.substring(0, filename.length - 5);
|
|
return {
|
|
id,
|
|
label: id,
|
|
projectGraphUrl: join('assets/generated-project-graphs/', filename),
|
|
taskGraphUrl: join('assets/generated-task-graphs/', filename),
|
|
taskInputsUrl: join('assets/generated-task-inputs/', filename),
|
|
sourceMapsUrl: join('assets/generated-source-maps/', filename),
|
|
};
|
|
});
|
|
} catch {
|
|
generatedGraphs = [];
|
|
}
|
|
|
|
let pregeneratedGraphs;
|
|
try {
|
|
pregeneratedGraphs = readdirSync(
|
|
join(__dirname, '../graph/client/src/assets/project-graphs')
|
|
).map((filename) => {
|
|
const id = filename.substring(0, filename.length - 5);
|
|
return {
|
|
id,
|
|
label: id,
|
|
projectGraphUrl: join('assets/project-graphs/', filename),
|
|
taskGraphUrl: join('assets/task-graphs/', filename),
|
|
taskInputsUrl: join('assets/task-inputs/', filename),
|
|
sourceMapsUrl: join('assets/source-maps/', filename),
|
|
};
|
|
});
|
|
} catch {
|
|
pregeneratedGraphs = [];
|
|
}
|
|
|
|
// if no generated projects are found, generate one for nx and try this again
|
|
if (generatedGraphs.length === 0) {
|
|
execSync('nx run graph-client:generate-graph --directory ./ --name nx', {
|
|
windowsHide: false,
|
|
});
|
|
writeFile();
|
|
return;
|
|
}
|
|
|
|
const projects = generatedGraphs.concat(pregeneratedGraphs);
|
|
|
|
ensureDirSync(join(__dirname, '../graph/client/src/assets/dev/'));
|
|
|
|
writeFileSync(
|
|
join(__dirname, '../graph/client/src/assets/dev/', `environment.js`),
|
|
generateFileContent(projects)
|
|
);
|
|
}
|
|
|
|
writeFile();
|