chore(core): cleanup create-nx-workspace from obsolete code (#10174)
This commit is contained in:
parent
43ac1f9c43
commit
c9e28a183e
@ -757,7 +757,7 @@ async function createApp(
|
|||||||
|
|
||||||
const pmc = getPackageManagerCommand(packageManager);
|
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, '/')}"`;
|
let nxWorkspaceRoot = `"${process.cwd().replace(/\\/g, '/')}"`;
|
||||||
|
|
||||||
@ -773,11 +773,10 @@ async function createApp(
|
|||||||
nxWorkspaceRoot = `\\"${nxWorkspaceRoot.slice(1, -1)}\\"`;
|
nxWorkspaceRoot = `\\"${nxWorkspaceRoot.slice(1, -1)}\\"`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const fullCommandWithoutWorkspaceRoot = `${pmc.exec} nx ${command}/generators.json --cli=${cli}`;
|
|
||||||
let workspaceSetupSpinner = ora('Creating your workspace').start();
|
let workspaceSetupSpinner = ora('Creating your workspace').start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fullCommand = `${fullCommandWithoutWorkspaceRoot} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
|
const fullCommand = `${pmc.exec} nx ${command} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
|
||||||
await execAndWait(fullCommand, tmpDir);
|
await execAndWait(fullCommand, tmpDir);
|
||||||
|
|
||||||
workspaceSetupSpinner.succeed('Nx has successfully created the workspace.');
|
workspaceSetupSpinner.succeed('Nx has successfully created the workspace.');
|
||||||
@ -868,7 +867,7 @@ function mapErrorToBodyLines(error: {
|
|||||||
code: number;
|
code: number;
|
||||||
logFile: string;
|
logFile: string;
|
||||||
}): 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
|
// print entire log message only if it's only a single message
|
||||||
return [`Error: ${error.logMessage}`];
|
return [`Error: ${error.logMessage}`];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,23 +35,13 @@ export function getPackageManagerCommand(
|
|||||||
packageManager: PackageManager = detectPackageManager()
|
packageManager: PackageManager = detectPackageManager()
|
||||||
): {
|
): {
|
||||||
install: string;
|
install: string;
|
||||||
add: string;
|
|
||||||
addDev: string;
|
|
||||||
rm: string;
|
|
||||||
exec: string;
|
exec: string;
|
||||||
list: string;
|
|
||||||
run: (script: string, args: string) => string;
|
|
||||||
} {
|
} {
|
||||||
switch (packageManager) {
|
switch (packageManager) {
|
||||||
case 'yarn':
|
case 'yarn':
|
||||||
return {
|
return {
|
||||||
install: 'yarn',
|
install: 'yarn',
|
||||||
add: 'yarn add -W',
|
|
||||||
addDev: 'yarn add -D -W',
|
|
||||||
rm: 'yarn remove',
|
|
||||||
exec: 'yarn',
|
exec: 'yarn',
|
||||||
run: (script: string, args: string) => `yarn ${script} ${args}`,
|
|
||||||
list: 'yarn list',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'pnpm':
|
case 'pnpm':
|
||||||
@ -62,12 +52,7 @@ export function getPackageManagerCommand(
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
|
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',
|
exec: useExec ? 'pnpm exec' : 'pnpx',
|
||||||
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
|
|
||||||
list: 'pnpm ls --depth 100',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'npm':
|
case 'npm':
|
||||||
@ -75,12 +60,7 @@ export function getPackageManagerCommand(
|
|||||||
process.env.npm_config_legacy_peer_deps ?? 'true';
|
process.env.npm_config_legacy_peer_deps ?? 'true';
|
||||||
return {
|
return {
|
||||||
install: 'npm install',
|
install: 'npm install',
|
||||||
add: 'npm install',
|
|
||||||
addDev: 'npm install -D',
|
|
||||||
rm: 'npm rm',
|
|
||||||
exec: 'npx',
|
exec: 'npx',
|
||||||
run: (script: string, args: string) => `npm run ${script} -- ${args}`,
|
|
||||||
list: 'npm ls',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user