fix(core): set windowsHide: true wherever possible (#28073)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
8290969cb7
commit
b73f1e0e00
@ -273,6 +273,7 @@ export function runCommandUntil(
|
||||
...opts.env,
|
||||
FORCE_COLOR: 'false',
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
return new Promise((res, rej) => {
|
||||
let output = '';
|
||||
|
||||
@ -62,11 +62,17 @@ export default async function (globalConfig: Config.ConfigGlobals) {
|
||||
function getPublishedVersion(): Promise<string | undefined> {
|
||||
return new Promise((resolve) => {
|
||||
// Resolve the published nx version from verdaccio
|
||||
exec('npm view nx@latest version', (error, stdout, stderr) => {
|
||||
exec(
|
||||
'npm view nx@latest version',
|
||||
{
|
||||
windowsHide: true,
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return resolve(undefined);
|
||||
}
|
||||
return resolve(stdout.trim());
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ export function execAndWait(command: string, cwd: string) {
|
||||
return new Promise<{ code: number; stdout: string }>((res, rej) => {
|
||||
exec(
|
||||
command,
|
||||
{ cwd, env: { ...process.env, NX_DAEMON: 'false' } },
|
||||
{ cwd, env: { ...process.env, NX_DAEMON: 'false' }, windowsHide: true },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
const logFile = join(cwd, 'error.log');
|
||||
|
||||
@ -43,6 +43,7 @@ export async function initializeGitRepo(
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
windowsHide: true,
|
||||
};
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
spawn('git', args, spawnOptions).on('close', (code) => {
|
||||
|
||||
@ -78,12 +78,15 @@ function startWebServer(webServerCommand: string) {
|
||||
// Windows is fine so we leave it attached to this process
|
||||
detached: process.platform !== 'win32',
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
return () => {
|
||||
if (process.platform === 'win32') {
|
||||
try {
|
||||
execSync('taskkill /pid ' + serverProcess.pid + ' /T /F');
|
||||
execSync('taskkill /pid ' + serverProcess.pid + ' /T /F', {
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
||||
console.error(e);
|
||||
|
||||
@ -43,6 +43,7 @@ export function installPackagesTask(
|
||||
const execSyncOptions: ExecSyncOptions = {
|
||||
cwd: join(tree.root, cwd),
|
||||
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
|
||||
windowsHide: true,
|
||||
};
|
||||
// ensure local registry from process is not interfering with the install
|
||||
// when we start the process from temp folder the local registry would override the custom registry
|
||||
|
||||
@ -497,6 +497,7 @@ export function ensurePackage<T extends any = any>(
|
||||
execSync(preInstallCommand, {
|
||||
cwd: tempDir,
|
||||
stdio: isVerbose ? 'inherit' : 'ignore',
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
let addCommand = getPackageManagerCommand(packageManager).addDev;
|
||||
@ -507,6 +508,7 @@ export function ensurePackage<T extends any = any>(
|
||||
execSync(`${addCommand} ${pkg}@${requiredVersion}`, {
|
||||
cwd: tempDir,
|
||||
stdio: isVerbose ? 'inherit' : 'ignore',
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
addToNodePath(join(workspaceRoot, 'node_modules'));
|
||||
|
||||
@ -68,6 +68,7 @@ export function podInstall(
|
||||
execSync('touch .xcode.env', {
|
||||
cwd: iosDirectory,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
execSync(
|
||||
@ -77,6 +78,7 @@ export function podInstall(
|
||||
{
|
||||
cwd: iosDirectory,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
@ -11,13 +11,13 @@ export function resolveEas(workspaceRoot: string): string {
|
||||
|
||||
let npmGlobalPath: string, yarnGlobalPath: string;
|
||||
try {
|
||||
npmGlobalPath = execSync('npm root -g')
|
||||
npmGlobalPath = execSync('npm root -g', { windowsHide: true })
|
||||
?.toString()
|
||||
?.trim()
|
||||
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
||||
} catch {}
|
||||
try {
|
||||
yarnGlobalPath = execSync('yarn global dir')
|
||||
yarnGlobalPath = execSync('yarn global dir', { windowsHide: true })
|
||||
?.toString()
|
||||
?.trim()
|
||||
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
||||
|
||||
@ -18,11 +18,17 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
|
||||
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
exec('taskkill /pid ' + pid + ' /T /F', (error) => {
|
||||
exec(
|
||||
'taskkill /pid ' + pid + ' /T /F',
|
||||
{
|
||||
windowsHide: true,
|
||||
},
|
||||
(error) => {
|
||||
// Ignore Fatal errors (128) because it might be due to the process already being killed.
|
||||
// On Linux/Mac we can check ESRCH (no such process), but on Windows we can't.
|
||||
callback(error?.code !== 128 ? error : null);
|
||||
});
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 'darwin':
|
||||
buildProcessTree(
|
||||
@ -30,7 +36,9 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
|
||||
tree,
|
||||
pidsToProcess,
|
||||
function (parentPid) {
|
||||
return spawn('pgrep', ['-P', parentPid]);
|
||||
return spawn('pgrep', ['-P', parentPid], {
|
||||
windowsHide: true,
|
||||
});
|
||||
},
|
||||
function () {
|
||||
killAll(tree, signal, callback);
|
||||
@ -43,13 +51,13 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
|
||||
tree,
|
||||
pidsToProcess,
|
||||
function (parentPid) {
|
||||
return spawn('ps', [
|
||||
'-o',
|
||||
'pid',
|
||||
'--no-headers',
|
||||
'--ppid',
|
||||
parentPid,
|
||||
]);
|
||||
return spawn(
|
||||
'ps',
|
||||
['-o', 'pid', '--no-headers', '--ppid', parentPid],
|
||||
{
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
},
|
||||
function () {
|
||||
killAll(tree, signal, callback);
|
||||
|
||||
@ -128,6 +128,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
||||
env: processEnv(true),
|
||||
cwd: context.root,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
const resultJson = JSON.parse(result.toString());
|
||||
@ -153,6 +154,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
||||
env: processEnv(true),
|
||||
cwd: context.root,
|
||||
stdio: 'ignore',
|
||||
windowsHide: true,
|
||||
});
|
||||
console.log(
|
||||
`Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n`
|
||||
@ -267,6 +269,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
||||
env: processEnv(true),
|
||||
cwd: context.root,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -136,7 +136,7 @@ function createVerdaccioOptions(
|
||||
|
||||
function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
try {
|
||||
execSync('npm --version', { env });
|
||||
execSync('npm --version', { env, windowsHide: true });
|
||||
} catch (e) {
|
||||
return () => {};
|
||||
}
|
||||
@ -151,7 +151,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
npmRegistryPaths.push(
|
||||
execSync(
|
||||
`npm config get ${registryName} --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
)
|
||||
?.toString()
|
||||
?.trim()
|
||||
@ -159,12 +159,12 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
);
|
||||
execSync(
|
||||
`npm config set ${registryName} http://localhost:${options.port}/ --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
|
||||
execSync(
|
||||
`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
|
||||
logger.info(
|
||||
@ -181,7 +181,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
try {
|
||||
const currentNpmRegistryPath = execSync(
|
||||
`npm config get registry --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
)
|
||||
?.toString()
|
||||
?.trim()
|
||||
@ -194,7 +194,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
) {
|
||||
execSync(
|
||||
`npm config set ${registryName} ${npmRegistryPaths[index]} --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
logger.info(
|
||||
`Reset npm ${registryName} to ${npmRegistryPaths[index]}`
|
||||
@ -204,6 +204,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
`npm config delete ${registryName} --location ${options.location}`,
|
||||
{
|
||||
env,
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
logger.info('Cleared custom npm registry');
|
||||
@ -211,7 +212,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
|
||||
});
|
||||
execSync(
|
||||
`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to reset npm registry: ${e.message}`);
|
||||
@ -230,6 +231,7 @@ function getYarnUnsafeHttpWhitelist(isYarnV1: boolean) {
|
||||
JSON.parse(
|
||||
execSync(`yarn config get unsafeHttpWhitelist --json`, {
|
||||
env,
|
||||
windowsHide: true,
|
||||
}).toString()
|
||||
)
|
||||
)
|
||||
@ -245,13 +247,13 @@ function setYarnUnsafeHttpWhitelist(
|
||||
`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(
|
||||
Array.from(currentWhitelist)
|
||||
)}'` + (options.location === 'user' ? ' --home' : ''),
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
} else {
|
||||
execSync(
|
||||
`yarn config unset unsafeHttpWhitelist` +
|
||||
(options.location === 'user' ? ' --home' : ''),
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -263,7 +265,9 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
|
||||
try {
|
||||
isYarnV1 =
|
||||
major(execSync('yarn --version', { env }).toString().trim()) === 1;
|
||||
major(
|
||||
execSync('yarn --version', { env, windowsHide: true }).toString().trim()
|
||||
) === 1;
|
||||
} catch {
|
||||
// This would fail if yarn is not installed which is okay
|
||||
return () => {};
|
||||
@ -277,6 +281,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
yarnRegistryPaths.push(
|
||||
execSync(`yarn config get ${scopeName}${registryConfigName}`, {
|
||||
env,
|
||||
windowsHide: true,
|
||||
})
|
||||
?.toString()
|
||||
?.trim()
|
||||
@ -286,7 +291,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
execSync(
|
||||
`yarn config set ${scopeName}${registryConfigName} http://localhost:${options.port}/` +
|
||||
(options.location === 'user' ? ' --home' : ''),
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
|
||||
logger.info(
|
||||
@ -313,7 +318,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
try {
|
||||
const currentYarnRegistryPath = execSync(
|
||||
`yarn config get ${registryConfigName}`,
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
)
|
||||
?.toString()
|
||||
?.trim()
|
||||
@ -331,7 +336,11 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
execSync(
|
||||
`yarn config set ${registryName} ${yarnRegistryPaths[index]}` +
|
||||
(options.location === 'user' ? ' --home' : ''),
|
||||
{ env }
|
||||
{
|
||||
env,
|
||||
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
logger.info(
|
||||
`Reset yarn ${registryName} to ${yarnRegistryPaths[index]}`
|
||||
@ -340,7 +349,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
|
||||
execSync(
|
||||
`yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryName}` +
|
||||
(options.location === 'user' ? ' --home' : ''),
|
||||
{ env }
|
||||
{ env, windowsHide: true }
|
||||
);
|
||||
logger.info(`Cleared custom yarn ${registryConfigName}`);
|
||||
}
|
||||
|
||||
@ -211,6 +211,9 @@ To fix this you will either need to add a package.json file at that location, or
|
||||
currentVersion = await new Promise<string>((resolve, reject) => {
|
||||
exec(
|
||||
`npm view ${packageName} version --"${registryConfigKey}=${registry}" --tag=${tag}`,
|
||||
{
|
||||
windowsHide: true,
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
|
||||
@ -133,6 +133,7 @@ function execLockFileUpdate(
|
||||
...process.env,
|
||||
...env,
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
output.error({
|
||||
|
||||
@ -21,8 +21,11 @@ export async function setupVerdaccio(
|
||||
if (!tree.exists('.verdaccio/config.yml')) {
|
||||
generateFiles(tree, path.join(__dirname, 'files'), '.verdaccio', {
|
||||
npmUplinkRegistry:
|
||||
execSync('npm config get registry')?.toString()?.trim() ??
|
||||
'https://registry.npmjs.org',
|
||||
execSync('npm config get registry', {
|
||||
windowsHide: true,
|
||||
})
|
||||
?.toString()
|
||||
?.trim() ?? 'https://registry.npmjs.org',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,10 @@ export function startLocalRegistry({
|
||||
const registry = `http://localhost:${port}`;
|
||||
process.env.npm_config_registry = registry;
|
||||
execSync(
|
||||
`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`
|
||||
`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`,
|
||||
{
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
// yarnv1
|
||||
@ -59,7 +62,9 @@ export function startLocalRegistry({
|
||||
|
||||
resolve(() => {
|
||||
childProcess.kill();
|
||||
execSync(`npm config delete //localhost:${port}/:_authToken`);
|
||||
execSync(`npm config delete //localhost:${port}/:_authToken`, {
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
childProcess?.stdout?.off('data', listener);
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ async function getNpmConfigValue(key: string, cwd: string): Promise<string> {
|
||||
async function execAsync(command: string, cwd: string): Promise<string> {
|
||||
// Must be non-blocking async to allow spinner to render
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
exec(command, { cwd }, (error, stdout, stderr) => {
|
||||
exec(command, { cwd, windowsHide: true }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
@ -85,6 +85,7 @@ export async function compileSwc(
|
||||
const swcCmdLog = execSync(getSwcCmd(normalizedOptions), {
|
||||
encoding: 'utf8',
|
||||
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
||||
windowsHide: true,
|
||||
});
|
||||
logger.log(swcCmdLog.replace(/\n/, ''));
|
||||
const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
|
||||
@ -137,6 +138,7 @@ export async function* compileSwcWatch(
|
||||
|
||||
const swcWatcher = exec(getSwcCmd(normalizedOptions, true), {
|
||||
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
processOnExit = () => {
|
||||
|
||||
@ -153,7 +153,11 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
|
||||
|
||||
tasks.push(() => {
|
||||
try {
|
||||
execSync(`npx -y nuxi prepare`, { cwd: options.appProjectRoot });
|
||||
execSync(`npx -y nuxi prepare`, {
|
||||
cwd: options.appProjectRoot,
|
||||
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Failed to run \`nuxi prepare\` in "${options.appProjectRoot}". Please run the command manually.`
|
||||
|
||||
@ -260,10 +260,18 @@ function getLocalNxVersion(workspace: WorkspaceTypeAndRoot): string | null {
|
||||
|
||||
function _getLatestVersionOfNx(): string {
|
||||
try {
|
||||
return execSync('npm view nx@latest version').toString().trim();
|
||||
return execSync('npm view nx@latest version', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
} catch {
|
||||
try {
|
||||
return execSync('pnpm view nx@latest version').toString().trim();
|
||||
return execSync('pnpm view nx@latest version', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -24,7 +24,10 @@ async function requirePowerpack(): Promise<any> {
|
||||
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
|
||||
try {
|
||||
execSync(
|
||||
`${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`
|
||||
`${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`,
|
||||
{
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
@ -43,7 +43,12 @@ async function installPackage(
|
||||
if (existsSync('package.json')) {
|
||||
const pmc = getPackageManagerCommand();
|
||||
await new Promise<void>((resolve) =>
|
||||
exec(`${pmc.addDev} ${pkgName}@${version}`, (error, stdout) => {
|
||||
exec(
|
||||
`${pmc.addDev} ${pkgName}@${version}`,
|
||||
{
|
||||
windowsHide: true,
|
||||
},
|
||||
(error, stdout) => {
|
||||
if (error) {
|
||||
spinner.fail();
|
||||
output.addNewline();
|
||||
@ -55,7 +60,8 @@ async function installPackage(
|
||||
}
|
||||
|
||||
return resolve();
|
||||
})
|
||||
}
|
||||
)
|
||||
);
|
||||
} else {
|
||||
nxJson.installation.plugins ??= {};
|
||||
|
||||
@ -50,6 +50,7 @@ export async function viewLogs(): Promise<number> {
|
||||
const pmc = getPackageManagerCommand();
|
||||
execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
if (!cloudUsed) {
|
||||
|
||||
@ -54,6 +54,7 @@ export async function nxExecCommand(
|
||||
NX_PROJECT_ROOT_PATH:
|
||||
projectGraph.nodes?.[process.env.NX_TASK_TARGET_PROJECT]?.data?.root,
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
} else {
|
||||
// nx exec is being ran inside of Nx's context
|
||||
@ -104,6 +105,7 @@ async function runScriptAsNxTarget(
|
||||
projectGraph.nodes?.[projectName]?.data?.root
|
||||
)
|
||||
: workspaceRoot,
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -127,7 +129,11 @@ function runTargetOnProject(
|
||||
const command = `${
|
||||
pm.exec
|
||||
} nx run ${projectName}:\\\"${targetName}\\\" ${extraArgs.join(' ')}`;
|
||||
execSync(command, { stdio: 'inherit' });
|
||||
execSync(command, {
|
||||
stdio: 'inherit',
|
||||
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
function readScriptArgV(
|
||||
|
||||
@ -211,6 +211,7 @@ function write(patterns: string[]) {
|
||||
)}`,
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
@ -221,6 +222,7 @@ function write(patterns: string[]) {
|
||||
)} --parser json`,
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -237,7 +239,7 @@ async function check(patterns: string[]): Promise<string[]> {
|
||||
return new Promise((resolve) => {
|
||||
exec(
|
||||
`node "${prettierPath}" --list-different ${patterns.join(' ')}`,
|
||||
{ encoding: 'utf-8' },
|
||||
{ encoding: 'utf-8', windowsHide: true },
|
||||
(error, stdout) => {
|
||||
if (error) {
|
||||
// The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated.
|
||||
|
||||
@ -1263,5 +1263,6 @@ function getHelpTextFromTarget(
|
||||
|
||||
return execSync(command, {
|
||||
cwd: target.options?.cwd ?? workspaceRoot,
|
||||
windowsHide: true,
|
||||
}).toString();
|
||||
}
|
||||
|
||||
@ -3,5 +3,9 @@ import { getPackageManagerCommand } from '../../../../utils/package-manager';
|
||||
|
||||
export function setupIntegratedWorkspace(): void {
|
||||
const pmc = getPackageManagerCommand();
|
||||
execSync(`${pmc.exec} nx g @nx/angular:ng-add`, { stdio: [0, 1, 2] });
|
||||
execSync(`${pmc.exec} nx g @nx/angular:ng-add`, {
|
||||
stdio: [0, 1, 2],
|
||||
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -106,7 +106,10 @@ export async function getLegacyMigrationFunctionIfApplicable(
|
||||
);
|
||||
|
||||
output.log({ title: '📝 Setting up workspace' });
|
||||
execSync(`${pmc.exec} ${legacyMigrationCommand}`, { stdio: [0, 1, 2] });
|
||||
execSync(`${pmc.exec} ${legacyMigrationCommand}`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
if (useNxCloud) {
|
||||
output.log({ title: '🛠️ Setting up Nx Cloud' });
|
||||
@ -146,7 +149,7 @@ async function installDependencies(
|
||||
}
|
||||
writeJsonFile(`package.json`, json);
|
||||
|
||||
execSync(pmc.install, { stdio: [0, 1, 2] });
|
||||
execSync(pmc.install, { stdio: [0, 1, 2], windowsHide: true });
|
||||
}
|
||||
|
||||
async function resolvePackageVersion(
|
||||
|
||||
@ -67,7 +67,9 @@ export function generateDotNxSetup(version?: string) {
|
||||
|
||||
export function normalizeVersionForNxJson(pkg: string, version: string) {
|
||||
if (!valid(version)) {
|
||||
version = execSync(`npm view ${pkg}@${version} version`).toString();
|
||||
version = execSync(`npm view ${pkg}@${version} version`, {
|
||||
windowsHide: true,
|
||||
}).toString();
|
||||
}
|
||||
return version.trimEnd();
|
||||
}
|
||||
|
||||
@ -90,6 +90,7 @@ function performInstallation(
|
||||
cp.execSync('npm i', {
|
||||
cwd: path.dirname(installationPath),
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
// revert possible changes to the current installation
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
export function checkForUncommittedChanges() {
|
||||
const gitResult = execSync('git status --porcelain').toString();
|
||||
const gitResult = execSync('git status --porcelain', {
|
||||
windowsHide: true,
|
||||
}).toString();
|
||||
|
||||
const filteredResults = gitResult
|
||||
.split('\n')
|
||||
|
||||
@ -70,6 +70,7 @@ function installDependencies(options: NormalizedOptions) {
|
||||
|
||||
execSync(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -86,7 +87,9 @@ async function normalizeOptions(options: Options): Promise<NormalizedOptions> {
|
||||
...packageJson.devDependencies,
|
||||
};
|
||||
const isCRA5 = /^[^~]?5/.test(deps['react-scripts']);
|
||||
const npmVersion = execSync('npm -v').toString();
|
||||
const npmVersion = execSync('npm -v', {
|
||||
windowsHide: true,
|
||||
}).toString();
|
||||
// Should remove this check 04/2023 once Node 14 & npm 6 reach EOL
|
||||
const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx
|
||||
const isVite = options.vite;
|
||||
@ -126,8 +129,14 @@ async function reorgnizeWorkspaceStructure(options: NormalizedOptions) {
|
||||
|
||||
output.log({ title: '🧶 Updating .gitignore file' });
|
||||
|
||||
execSync(`echo "node_modules" >> .gitignore`, { stdio: [0, 1, 2] });
|
||||
execSync(`echo "dist" >> .gitignore`, { stdio: [0, 1, 2] });
|
||||
execSync(`echo "node_modules" >> .gitignore`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
execSync(`echo "dist" >> .gitignore`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
process.chdir('..');
|
||||
|
||||
@ -168,7 +177,7 @@ function createTempWorkspace(options: NormalizedOptions) {
|
||||
} ${
|
||||
options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none'
|
||||
}`,
|
||||
{ stdio: [0, 1, 2] }
|
||||
{ stdio: [0, 1, 2], windowsHide: true }
|
||||
);
|
||||
|
||||
output.log({ title: '👋 Welcome to Nx!' });
|
||||
@ -311,7 +320,10 @@ async function addBundler(options: NormalizedOptions) {
|
||||
title: '🛬 Skip CRA preflight check since Nx manages the monorepo',
|
||||
});
|
||||
|
||||
execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, { stdio: [0, 1, 2] });
|
||||
execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -68,24 +68,28 @@ function deduceDefaultBase() {
|
||||
try {
|
||||
execSync(`git rev-parse --verify main`, {
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
return 'main';
|
||||
} catch {
|
||||
try {
|
||||
execSync(`git rev-parse --verify dev`, {
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
return 'dev';
|
||||
} catch {
|
||||
try {
|
||||
execSync(`git rev-parse --verify develop`, {
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
return 'develop';
|
||||
} catch {
|
||||
try {
|
||||
execSync(`git rev-parse --verify next`, {
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
return 'next';
|
||||
} catch {
|
||||
@ -140,7 +144,7 @@ export function runInstall(
|
||||
repoRoot: string,
|
||||
pmc: PackageManagerCommands = getPackageManagerCommand()
|
||||
) {
|
||||
execSync(pmc.install, { stdio: [0, 1, 2], cwd: repoRoot });
|
||||
execSync(pmc.install, { stdio: [0, 1, 2], cwd: repoRoot, windowsHide: true });
|
||||
}
|
||||
|
||||
export async function initCloud(
|
||||
|
||||
@ -95,6 +95,7 @@ export async function initHandler(options: InitArgs) {
|
||||
} else {
|
||||
execSync(`npx --yes create-nx-workspace@${version} ${args}`, {
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ export function installPlugins(
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
cwd: repoRoot,
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -128,6 +128,7 @@ function runMigration() {
|
||||
}
|
||||
execSync(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
|
||||
stdio: ['inherit', 'inherit', 'inherit'],
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -155,12 +156,14 @@ function nxCliPath() {
|
||||
execSync(pmc.preInstall, {
|
||||
cwd: tmpDir,
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
// if it's berry ensure we set the node_linker to node-modules
|
||||
if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
|
||||
execSync('yarn config set nodeLinker node-modules', {
|
||||
cwd: tmpDir,
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -168,6 +171,7 @@ function nxCliPath() {
|
||||
execSync(pmc.install, {
|
||||
cwd: tmpDir,
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
// Set NODE_PATH so that these modules can be used for module resolution
|
||||
|
||||
@ -1387,7 +1387,7 @@ function runInstall() {
|
||||
output.log({
|
||||
title: `Running '${pmCommands.install}' to make sure necessary packages are installed`,
|
||||
});
|
||||
execSync(pmCommands.install, { stdio: [0, 1, 2] });
|
||||
execSync(pmCommands.install, { stdio: [0, 1, 2], windowsHide: true });
|
||||
}
|
||||
|
||||
export async function executeMigrations(
|
||||
|
||||
@ -323,6 +323,9 @@ async function getCommitForVersionPlanFile(
|
||||
return new Promise((resolve) => {
|
||||
exec(
|
||||
`git log --diff-filter=A --pretty=format:"%s|%h|%an|%ae|%b" -n 1 -- ${rawVersionPlan.absolutePath}`,
|
||||
{
|
||||
windowsHide: true,
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
if (isVerbose) {
|
||||
|
||||
@ -10,6 +10,7 @@ export async function execCommand(
|
||||
...options,
|
||||
stdio: ['pipe', 'pipe', 'pipe'], // stdin, stdout, stderr
|
||||
encoding: 'utf-8',
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
let stdout = '';
|
||||
|
||||
@ -367,6 +367,7 @@ async function resolveGithubToken(hostname: string): Promise<string | null> {
|
||||
return execSync(`gh auth token`, {
|
||||
encoding: 'utf8',
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
}).trim();
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ export async function launchEditor(filePath: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const editorProcess = spawn(cmd, [...args, filePath], {
|
||||
stdio: 'inherit', // This will ensure the editor uses the current terminal
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
editorProcess.on('exit', (code) => {
|
||||
@ -28,7 +29,11 @@ export async function launchEditor(filePath: string) {
|
||||
|
||||
function getGitConfig(key): string | null {
|
||||
try {
|
||||
return execSync(`git config --get ${key}`).toString().trim();
|
||||
return execSync(`git config --get ${key}`, {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -753,6 +753,7 @@ function runPreVersionCommand(
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
stdio,
|
||||
env,
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
const title = verbose
|
||||
|
||||
@ -134,6 +134,7 @@ async function printTargetRunHelpInternal(
|
||||
} else {
|
||||
const cp = exec(helpCommand, {
|
||||
env,
|
||||
windowsHide: true,
|
||||
});
|
||||
cp.on('exit', (code) => {
|
||||
process.exit(code);
|
||||
|
||||
@ -132,6 +132,7 @@ class BatchCommandRunner extends BatchFunctionRunner {
|
||||
[this.projectNameEnv]: env[this.projectNameEnv],
|
||||
[this.fileChangesEnv]: env[this.fileChangesEnv],
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
commandExec.on('close', () => {
|
||||
resolve();
|
||||
|
||||
@ -9,6 +9,7 @@ export function generateDaemonHelpOutput(): string {
|
||||
*/
|
||||
const res = spawnSync(process.execPath, ['./exec-is-server-available.js'], {
|
||||
cwd: __dirname,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
const isServerAvailable = res?.stdout?.toString().trim().indexOf('true') > -1;
|
||||
|
||||
@ -572,6 +572,7 @@ describe('Run Commands', () => {
|
||||
...process.env,
|
||||
...env(),
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
@ -579,6 +580,7 @@ describe('Run Commands', () => {
|
||||
...process.env,
|
||||
...env(),
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
@ -601,6 +603,7 @@ describe('Run Commands', () => {
|
||||
...process.env,
|
||||
...env(),
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
@ -608,6 +611,7 @@ describe('Run Commands', () => {
|
||||
...process.env,
|
||||
...env(),
|
||||
},
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
@ -627,10 +631,12 @@ describe('Run Commands', () => {
|
||||
expect(exec).toHaveBeenNthCalledWith(1, `echo 'Hello World'`, {
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
env: { ...process.env, FORCE_COLOR: `true`, ...env() },
|
||||
windowsHide: true,
|
||||
});
|
||||
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
env: { ...process.env, FORCE_COLOR: `true`, ...env() },
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -402,6 +402,7 @@ function nodeProcess(
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
env,
|
||||
cwd,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
childProcesses.add(childProcess);
|
||||
|
||||
@ -54,6 +54,7 @@ function nodeProcess(
|
||||
stdio: ['inherit', 'inherit', 'inherit'],
|
||||
cwd,
|
||||
env,
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ function getNxInitDate(): string | null {
|
||||
try {
|
||||
const nxInitIso = execSync(
|
||||
'git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1',
|
||||
{ stdio: 'pipe' }
|
||||
{ stdio: 'pipe', windowsHide: true }
|
||||
)
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
@ -125,6 +125,7 @@ function defaultReadFileAtRevision(
|
||||
: execSync(`git show ${revision}:${filePathInGitRepository}`, {
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
stdio: ['pipe', 'pipe', 'ignore'],
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
@ -230,6 +230,7 @@ export class Cache {
|
||||
stdio: 'ignore',
|
||||
detached: true,
|
||||
shell: false,
|
||||
windowsHide: true,
|
||||
});
|
||||
p.unref();
|
||||
} catch (e) {
|
||||
|
||||
@ -108,7 +108,10 @@ function shouldRecordStats(): boolean {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const stdout = execSync(pmc.getRegistryUrl, { encoding: 'utf-8' });
|
||||
const stdout = execSync(pmc.getRegistryUrl, {
|
||||
encoding: 'utf-8',
|
||||
windowsHide: true,
|
||||
});
|
||||
const url = new URL(stdout.trim());
|
||||
|
||||
// don't record stats when testing locally
|
||||
|
||||
@ -20,6 +20,7 @@ export function runNxSync(
|
||||
} else {
|
||||
options ??= {};
|
||||
options.cwd ??= process.cwd();
|
||||
options.windowsHide ??= true;
|
||||
const offsetFromRoot = relative(
|
||||
options.cwd,
|
||||
workspaceRootInner(options.cwd, null)
|
||||
@ -43,6 +44,7 @@ export async function runNxAsync(
|
||||
} else {
|
||||
options ??= {};
|
||||
options.cwd ??= process.cwd();
|
||||
options.windowsHide ??= true;
|
||||
const offsetFromRoot = relative(
|
||||
options.cwd,
|
||||
workspaceRootInner(options.cwd, null)
|
||||
|
||||
@ -306,6 +306,7 @@ function getMergeBase(base: string, head: string = 'HEAD') {
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
cwd: workspaceRoot,
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
@ -315,6 +316,7 @@ function getMergeBase(base: string, head: string = 'HEAD') {
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
cwd: workspaceRoot,
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
@ -331,7 +333,11 @@ function getFilesUsingBaseAndHead(base: string, head: string): string[] {
|
||||
}
|
||||
|
||||
function parseGitOutput(command: string): string[] {
|
||||
return execSync(command, { maxBuffer: TEN_MEGABYTES, cwd: workspaceRoot })
|
||||
return execSync(command, {
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
cwd: workspaceRoot,
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString('utf-8')
|
||||
.split('\n')
|
||||
.map((a) => a.trim())
|
||||
|
||||
@ -4,8 +4,11 @@ export function deduceDefaultBase(): string {
|
||||
const nxDefaultBase = 'main';
|
||||
try {
|
||||
return (
|
||||
execSync('git config --get init.defaultBranch').toString().trim() ||
|
||||
nxDefaultBase
|
||||
execSync('git config --get init.defaultBranch', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim() || nxDefaultBase
|
||||
);
|
||||
} catch {
|
||||
return nxDefaultBase;
|
||||
|
||||
@ -9,9 +9,10 @@ try {
|
||||
const { execSync } = require('child_process');
|
||||
// NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
|
||||
const src = process.env.NX_IMPORT_SOURCE;
|
||||
execSync('git read-tree --empty', { stdio: 'inherit' });
|
||||
execSync('git read-tree --empty', { stdio: 'inherit', windowsHide: true });
|
||||
execSync(`git reset ${process.env.GIT_COMMIT} -- "${src}"`, {
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error executing Git commands: ${error}`);
|
||||
|
||||
@ -21,7 +21,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBe('origin-user/repo-name');
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return "github" if there are no remotes', () => {
|
||||
@ -30,7 +33,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBe('github');
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return "github" if execSync throws an error', () => {
|
||||
@ -41,7 +47,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBe('github');
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the first github remote slug if no origin is present', () => {
|
||||
@ -53,7 +62,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBe('upstream-user/repo-name');
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return null if remote is set up but not github', () => {
|
||||
@ -65,7 +77,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the first github remote slug for HTTPS URLs', () => {
|
||||
@ -77,7 +92,10 @@ describe('git utils tests', () => {
|
||||
const result = getGithubSlugOrNull();
|
||||
|
||||
expect(result).toBe('origin-user/repo-name');
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' });
|
||||
expect(execSync).toHaveBeenCalledWith('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -14,7 +14,9 @@ try {
|
||||
// NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
|
||||
const src = process.env.NX_IMPORT_SOURCE;
|
||||
const dest = process.env.NX_IMPORT_DESTINATION;
|
||||
const files = execSync(`git ls-files -z ${src}`)
|
||||
const files = execSync(`git ls-files -z ${src}`, {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
.split('\x00')
|
||||
|
||||
@ -40,6 +40,7 @@ export class GitRepository {
|
||||
getGitRootPath(cwd: string) {
|
||||
return execSync('git rev-parse --show-toplevel', {
|
||||
cwd,
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
@ -237,6 +238,7 @@ export function getGithubSlugOrNull(): string | null {
|
||||
try {
|
||||
const gitRemote = execSync('git remote -v', {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
}).toString();
|
||||
// If there are no remotes, we default to github
|
||||
if (!gitRemote || gitRemote.length === 0) {
|
||||
@ -302,6 +304,7 @@ export function commitChanges(
|
||||
stdio: 'pipe',
|
||||
input: commitMessage,
|
||||
cwd: directory,
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (err) {
|
||||
if (directory) {
|
||||
@ -323,6 +326,7 @@ export function getLatestCommitSha(): string | null {
|
||||
return execSync('git rev-parse HEAD', {
|
||||
encoding: 'utf8',
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
}).trim();
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
@ -80,6 +80,7 @@ export async function playwrightExecutor(
|
||||
execSync(`${pmc.exec} playwright install`, {
|
||||
cwd: workspaceRoot,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,10 @@ function getBrowsersInstallTask() {
|
||||
bodyLines: ['use --skipInstall to skip installation.'],
|
||||
});
|
||||
const pmc = getPackageManagerCommand();
|
||||
execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot });
|
||||
execSync(`${pmc.exec} playwright install`, {
|
||||
cwd: workspaceRoot,
|
||||
windowsHide: true,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ export function runCommandAsync(
|
||||
{
|
||||
cwd: opts.cwd ?? tmpProjPath(),
|
||||
env: { ...process.env, ...opts.env },
|
||||
windowsHide: true,
|
||||
},
|
||||
(err, stdout, stderr) => {
|
||||
if (!opts.silenceError && err) {
|
||||
|
||||
@ -21,6 +21,7 @@ export function runNxCommand(
|
||||
const execSyncOptions: ExecOptions = {
|
||||
cwd,
|
||||
env: { ...process.env, ...opts.env },
|
||||
windowsHide: true,
|
||||
};
|
||||
if (fileExists(tmpProjPath('package.json'))) {
|
||||
const pmc = getPackageManagerCommand(detectPackageManager(cwd));
|
||||
|
||||
@ -21,6 +21,7 @@ function runNxNewCommand(args?: string, silent?: boolean) {
|
||||
{
|
||||
cwd: localTmpDir,
|
||||
...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -55,6 +56,7 @@ export function runPackageManagerInstall(silent: boolean = true) {
|
||||
const install = execSync(pmc.install, {
|
||||
cwd,
|
||||
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
|
||||
windowsHide: true,
|
||||
});
|
||||
return install ? install.toString() : '';
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ export function podInstall(
|
||||
execSync('touch .xcode.env', {
|
||||
cwd: iosDirectory,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
const podCommand = [
|
||||
@ -82,6 +83,7 @@ export function podInstall(
|
||||
execSync(podCommand, {
|
||||
cwd: iosDirectory,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error(podInstallErrorMessage);
|
||||
|
||||
@ -20,6 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer {
|
||||
}`,
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
@ -85,6 +86,7 @@ export function callAutomigrate(
|
||||
`${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer {
|
||||
}`,
|
||||
{
|
||||
stdio: [0, 1, 2],
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
@ -83,6 +84,7 @@ export function callAutomigrate(
|
||||
`${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -18,7 +18,9 @@ export function nxViteBuildCoordinationPlugin(
|
||||
|
||||
async function buildChangedProjects() {
|
||||
await new Promise<void>((res) => {
|
||||
activeBuildProcess = exec(options.buildCommand);
|
||||
activeBuildProcess = exec(options.buildCommand, {
|
||||
windowsHide: true,
|
||||
});
|
||||
activeBuildProcess.stdout.pipe(process.stdout);
|
||||
activeBuildProcess.stderr.pipe(process.stderr);
|
||||
activeBuildProcess.on('exit', () => {
|
||||
|
||||
@ -36,6 +36,7 @@ export async function validateTypes(opts: {
|
||||
{
|
||||
cwd: opts.workspaceRoot,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -52,7 +52,9 @@ export class WebpackNxBuildCoordinationPlugin {
|
||||
this.currentlyRunning = 'nx-build';
|
||||
try {
|
||||
return await new Promise<void>((res) => {
|
||||
this.buildCmdProcess = exec(this.buildCmd);
|
||||
this.buildCmdProcess = exec(this.buildCmd, {
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
this.buildCmdProcess.stdout.pipe(process.stdout);
|
||||
this.buildCmdProcess.stderr.pipe(process.stderr);
|
||||
|
||||
@ -36,6 +36,7 @@ export function generatePreset(host: Tree, opts: NormalizedSchema) {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
cwd: join(host.root, opts.directory),
|
||||
windowsHide: true,
|
||||
};
|
||||
const pmc = getPackageManagerCommand();
|
||||
const executable = `${pmc.exec} nx`;
|
||||
|
||||
@ -63,6 +63,7 @@ export async function newGenerator(tree: Tree, opts: Schema) {
|
||||
cwd: joinPathFragments(tree.root, options.directory),
|
||||
stdio:
|
||||
process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
installPackagesTask(
|
||||
|
||||
@ -7,7 +7,11 @@ export function getNpmPackageVersion(
|
||||
`npm view ${packageName}${
|
||||
packageVersion ? '@' + packageVersion : ''
|
||||
} version --json`,
|
||||
{ stdio: ['pipe', 'pipe', 'ignore'] }
|
||||
{
|
||||
stdio: ['pipe', 'pipe', 'ignore'],
|
||||
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
|
||||
if (version) {
|
||||
|
||||
@ -4,8 +4,11 @@ export function deduceDefaultBase(): string {
|
||||
const nxDefaultBase = 'main';
|
||||
try {
|
||||
return (
|
||||
execSync('git config --get init.defaultBranch').toString().trim() ||
|
||||
nxDefaultBase
|
||||
execSync('git config --get init.defaultBranch', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim() || nxDefaultBase
|
||||
);
|
||||
} catch {
|
||||
return nxDefaultBase;
|
||||
|
||||
@ -42,11 +42,20 @@ async function run() {
|
||||
updateVersionUtils(packageVersionMap);
|
||||
|
||||
console.log('⏳ - Installing packages...');
|
||||
execSync('pnpm install', { stdio: 'inherit', encoding: 'utf8' });
|
||||
execSync('pnpm install', {
|
||||
stdio: 'inherit',
|
||||
encoding: 'utf8',
|
||||
|
||||
windowsHide: true,
|
||||
});
|
||||
console.log('✅ - Finished installing packages!');
|
||||
|
||||
console.log('⏳ - Formatting files...');
|
||||
execSync('pnpm nx format', { stdio: 'inherit', encoding: 'utf8' });
|
||||
execSync('pnpm nx format', {
|
||||
stdio: 'inherit',
|
||||
encoding: 'utf8',
|
||||
windowsHide: true,
|
||||
});
|
||||
console.log('✅ - Finished creating migrations!');
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ export async function generateDevkitDocumentation() {
|
||||
const execSyncOptions: ExecSyncOptions = {
|
||||
stdio: 'true' === 'true' ? 'inherit' : 'ignore',
|
||||
// stdio: process.env.CI === 'true' ? 'inherit' : 'ignore',
|
||||
windowsHide: true,
|
||||
};
|
||||
|
||||
execSync('nx run-many -t build -p devkit,typedoc-theme', execSyncOptions);
|
||||
|
||||
@ -38,7 +38,9 @@ async function generate() {
|
||||
}
|
||||
|
||||
function checkDocumentation() {
|
||||
const output = execSync('git status --porcelain ./docs').toString('utf-8');
|
||||
const output = execSync('git status --porcelain ./docs', {
|
||||
windowsHide: true,
|
||||
}).toString('utf-8');
|
||||
|
||||
if (output) {
|
||||
console.log(
|
||||
@ -50,7 +52,10 @@ function checkDocumentation() {
|
||||
);
|
||||
|
||||
console.log('\nChanged Docs:');
|
||||
execSync('git status --porcelain ./docs', { stdio: 'inherit' });
|
||||
execSync('git status --porcelain ./docs', {
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
process.exit(1);
|
||||
} else {
|
||||
|
||||
@ -62,7 +62,9 @@ function writeFile() {
|
||||
|
||||
// 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');
|
||||
execSync('nx run graph-client:generate-graph --directory ./ --name nx', {
|
||||
windowsHide: true,
|
||||
});
|
||||
writeFile();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ async function generateGraph(directory: string, name: string) {
|
||||
try {
|
||||
execSync(
|
||||
'npx nx graph --file ./node_modules/.cache/nx-graph-gen/graph.html',
|
||||
{ cwd: directory, stdio: 'ignore' }
|
||||
{ cwd: directory, stdio: 'ignore', windowsHide: true }
|
||||
);
|
||||
} catch {
|
||||
console.error(`Could not run graph command in directory ${directory}`);
|
||||
|
||||
@ -35,6 +35,7 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(`pnpm nx copy-native-package-directories nx`, {
|
||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
// Expected to run as part of the Github `publish` workflow
|
||||
@ -44,11 +45,13 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync('find ./build -name "*.node" -delete', {
|
||||
stdio: [0, 1, 2],
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
execSync('pnpm nx run-many --target=artifacts', {
|
||||
stdio: [0, 1, 2],
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -66,6 +69,7 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(versionCommand, {
|
||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
};
|
||||
|
||||
@ -74,7 +78,9 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
// For this important use-case it makes sense to always have full logs
|
||||
isVerboseLogging = true;
|
||||
|
||||
execSync('git status --ahead-behind');
|
||||
execSync('git status --ahead-behind', {
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
if (isRelativeVersionKeyword(options.version)) {
|
||||
throw new Error(
|
||||
@ -87,6 +93,7 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
|
||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`;
|
||||
@ -106,6 +113,7 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(changelogCommand, {
|
||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
console.log(
|
||||
@ -119,6 +127,7 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
|
||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
const distTag = determineDistTag(options.version);
|
||||
@ -174,12 +183,17 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
execSync(publishCommand, {
|
||||
stdio: [0, 1, 2],
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
if (!options.dryRun) {
|
||||
let version;
|
||||
if (['minor', 'major', 'patch'].includes(options.version)) {
|
||||
version = execSync(`npm view nx@${distTag} version`).toString().trim();
|
||||
version = execSync(`npm view nx@${distTag} version`, {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
} else {
|
||||
version = options.version;
|
||||
}
|
||||
@ -256,10 +270,14 @@ function parseArgs() {
|
||||
* Handle the special case of `canary`
|
||||
*/
|
||||
|
||||
const currentLatestVersion = execSync('npm view nx@latest version')
|
||||
const currentLatestVersion = execSync('npm view nx@latest version', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
const currentNextVersion = execSync('npm view nx@next version')
|
||||
const currentNextVersion = execSync('npm view nx@next version', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
@ -290,7 +308,11 @@ function parseArgs() {
|
||||
const YYYYMMDD = `${year}${month}${day}`;
|
||||
|
||||
// Get the current short git sha
|
||||
const gitSha = execSync('git rev-parse --short HEAD').toString().trim();
|
||||
const gitSha = execSync('git rev-parse --short HEAD', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
const canaryVersion = `${canaryBaseVersion}-canary.${YYYYMMDD}-${gitSha}`;
|
||||
|
||||
@ -358,7 +380,13 @@ function parseArgs() {
|
||||
}
|
||||
|
||||
function getRegistry() {
|
||||
return new URL(execSync('npm config get registry').toString().trim());
|
||||
return new URL(
|
||||
execSync('npm config get registry', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
);
|
||||
}
|
||||
|
||||
function determineDistTag(
|
||||
@ -392,7 +420,9 @@ function determineDistTag(
|
||||
);
|
||||
}
|
||||
|
||||
const currentLatestVersion = execSync('npm view nx version')
|
||||
const currentLatestVersion = execSync('npm view nx version', {
|
||||
windowsHide: true,
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
const parsedCurrentLatestVersion = parse(currentLatestVersion);
|
||||
|
||||
@ -8,7 +8,9 @@ console.log(`Comparing ${currentVersion} to npm versions`);
|
||||
|
||||
const majorVersion = major(currentVersion);
|
||||
const releasedVersions: string[] = JSON.parse(
|
||||
execSync(`npm show nx@^${majorVersion} version --json`).toString()
|
||||
execSync(`npm show nx@^${majorVersion} version --json`, {
|
||||
windowsHide: true,
|
||||
}).toString()
|
||||
);
|
||||
|
||||
const latestVersion = maxSatisfying(releasedVersions, `^${majorVersion}`);
|
||||
@ -23,8 +25,12 @@ if (currentVersion && latestVersion && gte(currentVersion, latestVersion)) {
|
||||
`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}`);
|
||||
execSync(`git push -f origin ${branchName}`);
|
||||
execSync(`git branch -f ${branchName}`, {
|
||||
windowsHide: true,
|
||||
});
|
||||
execSync(`git push -f origin ${branchName}`, {
|
||||
windowsHide: true,
|
||||
});
|
||||
} else {
|
||||
console.log(`Not publishing docs to ${branchName}`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user