chore(core): cleanup create-nx-workspace from obsolete code (#10174)

This commit is contained in:
Miroslav Jonaš 2022-05-05 21:31:19 +02:00 committed by GitHub
parent 43ac1f9c43
commit c9e28a183e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 24 deletions

View File

@ -757,7 +757,7 @@ async function createApp(
const pmc = getPackageManagerCommand(packageManager);
const command = `new ${name} ${args} --collection=@nrwl/workspace`;
const command = `new ${name} ${args} --collection=@nrwl/workspace/generators.json --cli=${cli}`;
let nxWorkspaceRoot = `"${process.cwd().replace(/\\/g, '/')}"`;
@ -773,11 +773,10 @@ async function createApp(
nxWorkspaceRoot = `\\"${nxWorkspaceRoot.slice(1, -1)}\\"`;
}
}
const fullCommandWithoutWorkspaceRoot = `${pmc.exec} nx ${command}/generators.json --cli=${cli}`;
let workspaceSetupSpinner = ora('Creating your workspace').start();
try {
const fullCommand = `${fullCommandWithoutWorkspaceRoot} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
const fullCommand = `${pmc.exec} nx ${command} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
await execAndWait(fullCommand, tmpDir);
workspaceSetupSpinner.succeed('Nx has successfully created the workspace.');
@ -868,7 +867,7 @@ function mapErrorToBodyLines(error: {
code: number;
logFile: string;
}): string[] {
if (error.logMessage.split('\n').filter((line) => !!line).length === 1) {
if (error.logMessage?.split('\n').filter((line) => !!line).length === 1) {
// print entire log message only if it's only a single message
return [`Error: ${error.logMessage}`];
}

View File

@ -35,23 +35,13 @@ export function getPackageManagerCommand(
packageManager: PackageManager = detectPackageManager()
): {
install: string;
add: string;
addDev: string;
rm: string;
exec: string;
list: string;
run: (script: string, args: string) => string;
} {
switch (packageManager) {
case 'yarn':
return {
install: 'yarn',
add: 'yarn add -W',
addDev: 'yarn add -D -W',
rm: 'yarn remove',
exec: 'yarn',
run: (script: string, args: string) => `yarn ${script} ${args}`,
list: 'yarn list',
};
case 'pnpm':
@ -62,12 +52,7 @@ export function getPackageManagerCommand(
}
return {
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
add: 'pnpm add',
addDev: 'pnpm add -D',
rm: 'pnpm rm',
exec: useExec ? 'pnpm exec' : 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
list: 'pnpm ls --depth 100',
};
case 'npm':
@ -75,12 +60,7 @@ export function getPackageManagerCommand(
process.env.npm_config_legacy_peer_deps ?? 'true';
return {
install: 'npm install',
add: 'npm install',
addDev: 'npm install -D',
rm: 'npm rm',
exec: 'npx',
run: (script: string, args: string) => `npm run ${script} -- ${args}`,
list: 'npm ls',
};
}
}