fix(misc): nx init should allow overriding the version of nx

This commit is contained in:
Victor Savkin 2022-11-30 12:55:30 -05:00
parent db85c62240
commit ee65e6a100
No known key found for this signature in database
GPG Key ID: 39178FEB7698B817

View File

@ -5,27 +5,28 @@ import { addNxToNpmRepo } from '../nx-init/add-nx-to-npm-repo';
export async function initHandler() { export async function initHandler() {
const args = process.argv.slice(2).join(' '); const args = process.argv.slice(2).join(' ');
const version = process.env.NX_VERSION ?? 'latest';
if (existsSync('package.json')) { if (existsSync('package.json')) {
if (existsSync('angular.json')) { if (existsSync('angular.json')) {
// TODO(leo): remove make-angular-cli-faster // TODO(leo): remove make-angular-cli-faster
execSync(`npx --yes make-angular-cli-faster@latest ${args}`, { execSync(`npx --yes make-angular-cli-faster@${version} ${args}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
}); });
} else if (isCRA()) { } else if (isCRA()) {
// TODO(jack): remove cra-to-nx // TODO(jack): remove cra-to-nx
execSync(`npx --yes cra-to-nx@latest ${args}`, { execSync(`npx --yes cra-to-nx@${version} ${args}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
}); });
} else if (isMonorepo()) { } else if (isMonorepo()) {
// TODO: vsavkin remove add-nx-to-monorepo // TODO: vsavkin remove add-nx-to-monorepo
execSync(`npx --yes add-nx-to-monorepo@latest ${args}`, { execSync(`npx --yes add-nx-to-monorepo@${version} ${args}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
}); });
} else { } else {
await addNxToNpmRepo(); await addNxToNpmRepo();
} }
} else { } else {
execSync(`npx --yes create-nx-workspace@latest ${args}`, { execSync(`npx --yes create-nx-workspace@${version} ${args}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
}); });
} }