feat(core): remove unused CLI option from CNW (#14865)
This commit is contained in:
parent
066c3b1e71
commit
762b9f336c
@ -45,14 +45,6 @@ Choices: [github, circleci, azure, bitbucket-pipelines, gitlab]
|
|||||||
|
|
||||||
Generate a CI workflow file
|
Generate a CI workflow file
|
||||||
|
|
||||||
### cli
|
|
||||||
|
|
||||||
Type: `string`
|
|
||||||
|
|
||||||
Choices: [nx, angular]
|
|
||||||
|
|
||||||
CLI to power the Nx workspace
|
|
||||||
|
|
||||||
### commit.email
|
### commit.email
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -45,14 +45,6 @@ Choices: [github, circleci, azure, bitbucket-pipelines, gitlab]
|
|||||||
|
|
||||||
Generate a CI workflow file
|
Generate a CI workflow file
|
||||||
|
|
||||||
### cli
|
|
||||||
|
|
||||||
Type: `string`
|
|
||||||
|
|
||||||
Choices: [nx, angular]
|
|
||||||
|
|
||||||
CLI to power the Nx workspace
|
|
||||||
|
|
||||||
### commit.email
|
### commit.email
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -15,12 +15,6 @@
|
|||||||
"$default": { "$source": "argv", "index": 0 },
|
"$default": { "$source": "argv", "index": 0 },
|
||||||
"x-prompt": "What name would you like to use for the workspace?"
|
"x-prompt": "What name would you like to use for the workspace?"
|
||||||
},
|
},
|
||||||
"cli": {
|
|
||||||
"description": "CLI used for generating code and running tasks.",
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["nx", "angular"],
|
|
||||||
"default": "nx"
|
|
||||||
},
|
|
||||||
"style": {
|
"style": {
|
||||||
"description": "The file extension to be used for style files.",
|
"description": "The file extension to be used for style files.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
"description": "Npm scope for importing libs.",
|
"description": "Npm scope for importing libs.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"cli": { "description": "CLI powering the workspace.", "type": "string" },
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"description": "The tool to use for running lint checks.",
|
"description": "The tool to use for running lint checks.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@ -14,9 +14,6 @@ describe('Angular Config', () => {
|
|||||||
afterAll(() => cleanupProject());
|
afterAll(() => cleanupProject());
|
||||||
|
|
||||||
it('should upgrade the config correctly', async () => {
|
it('should upgrade the config correctly', async () => {
|
||||||
const previousCI = process.env.SELECTED_CLI;
|
|
||||||
process.env.SELECTED_CLI = 'angular';
|
|
||||||
|
|
||||||
const myapp = uniq('myapp');
|
const myapp = uniq('myapp');
|
||||||
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);
|
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);
|
||||||
|
|
||||||
@ -34,8 +31,6 @@ describe('Angular Config', () => {
|
|||||||
const myapp2 = uniq('myapp');
|
const myapp2 = uniq('myapp');
|
||||||
runCLI(`generate @nrwl/angular:app ${myapp2} --no-interactive`);
|
runCLI(`generate @nrwl/angular:app ${myapp2} --no-interactive`);
|
||||||
expectTestsPass(await runCLIAsync(`test ${myapp2} --no-watch`));
|
expectTestsPass(await runCLIAsync(`test ${myapp2} --no-watch`));
|
||||||
|
|
||||||
process.env.SELECTED_CLI = previousCI;
|
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
process.env.SELECTED_CLI = 'angular';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
checkFilesDoNotExist,
|
checkFilesDoNotExist,
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
@ -56,6 +54,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
|
|||||||
runNgAdd('@cypress/schematic', '--e2e-update', '1.7.0');
|
runNgAdd('@cypress/schematic', '--e2e-update', '1.7.0');
|
||||||
packageInstall('cypress', null, '^9.0.0');
|
packageInstall('cypress', null, '^9.0.0');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCypress10() {
|
function addCypress10() {
|
||||||
runNgAdd('@cypress/schematic', '--e2e', 'latest');
|
runNgAdd('@cypress/schematic', '--e2e', 'latest');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,6 @@ import {
|
|||||||
import { PackageManager } from 'nx/src/utils/package-manager';
|
import { PackageManager } from 'nx/src/utils/package-manager';
|
||||||
import { removeSync } from 'fs-extra';
|
import { removeSync } from 'fs-extra';
|
||||||
|
|
||||||
process.env.SELECTED_CLI = 'angular';
|
|
||||||
|
|
||||||
describe('using Nx executors and generators with Angular CLI', () => {
|
describe('using Nx executors and generators with Angular CLI', () => {
|
||||||
let project: string;
|
let project: string;
|
||||||
let packageManager: PackageManager;
|
let packageManager: PackageManager;
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
process.env.SELECTED_CLI = 'angular';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cleanupProject,
|
cleanupProject,
|
||||||
listFiles,
|
listFiles,
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
process.env.SELECTED_CLI = 'angular';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
cleanupProject,
|
||||||
|
getPackageManagerCommand,
|
||||||
isNotWindows,
|
isNotWindows,
|
||||||
killPorts,
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
cleanupProject,
|
|
||||||
runCLI,
|
runCLI,
|
||||||
|
runCommand,
|
||||||
runCypressTests,
|
runCypressTests,
|
||||||
tmpProjPath,
|
tmpProjPath,
|
||||||
uniq,
|
uniq,
|
||||||
getPackageManagerCommand,
|
|
||||||
updateJson,
|
updateJson,
|
||||||
runCommand,
|
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
import { writeFileSync } from 'fs';
|
import { writeFileSync } from 'fs';
|
||||||
|
|
||||||
|
|||||||
@ -67,10 +67,6 @@ interface RunCmdOpts {
|
|||||||
silent?: boolean;
|
silent?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function currentCli() {
|
|
||||||
return process.env.SELECTED_CLI || 'nx';
|
|
||||||
}
|
|
||||||
|
|
||||||
export const e2eRoot = isCI
|
export const e2eRoot = isCI
|
||||||
? dirSync({ prefix: 'nx-e2e-' }).name
|
? dirSync({ prefix: 'nx-e2e-' }).name
|
||||||
: '/tmp/nx-e2e';
|
: '/tmp/nx-e2e';
|
||||||
@ -82,7 +78,7 @@ export function isVerbose() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const e2eCwd = `${e2eRoot}/${currentCli()}`;
|
export const e2eCwd = `${e2eRoot}/nx`;
|
||||||
ensureDirSync(e2eCwd);
|
ensureDirSync(e2eCwd);
|
||||||
|
|
||||||
let projName: string;
|
let projName: string;
|
||||||
@ -137,7 +133,6 @@ export function runCreateWorkspace(
|
|||||||
style,
|
style,
|
||||||
base,
|
base,
|
||||||
packageManager,
|
packageManager,
|
||||||
cli,
|
|
||||||
extraArgs,
|
extraArgs,
|
||||||
ci,
|
ci,
|
||||||
useDetectedPm = false,
|
useDetectedPm = false,
|
||||||
@ -149,7 +144,6 @@ export function runCreateWorkspace(
|
|||||||
style?: string;
|
style?: string;
|
||||||
base?: string;
|
base?: string;
|
||||||
packageManager?: 'npm' | 'yarn' | 'pnpm';
|
packageManager?: 'npm' | 'yarn' | 'pnpm';
|
||||||
cli?: string;
|
|
||||||
extraArgs?: string;
|
extraArgs?: string;
|
||||||
ci?: 'azure' | 'github' | 'circleci';
|
ci?: 'azure' | 'github' | 'circleci';
|
||||||
useDetectedPm?: boolean;
|
useDetectedPm?: boolean;
|
||||||
@ -161,9 +155,7 @@ export function runCreateWorkspace(
|
|||||||
|
|
||||||
const pm = getPackageManagerCommand({ packageManager });
|
const pm = getPackageManagerCommand({ packageManager });
|
||||||
|
|
||||||
let command = `${pm.createWorkspace} ${name} --cli=${
|
let command = `${pm.createWorkspace} ${name} --preset=${preset} --no-nxCloud --no-interactive`;
|
||||||
cli || currentCli()
|
|
||||||
} --preset=${preset} --no-nxCloud --no-interactive`;
|
|
||||||
if (appName) {
|
if (appName) {
|
||||||
command += ` --appName=${appName}`;
|
command += ` --appName=${appName}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -293,7 +293,6 @@ describe('create-nx-workspace', () => {
|
|||||||
appName,
|
appName,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
packageManager: 'npm',
|
packageManager: 'npm',
|
||||||
cli: 'angular',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
checkFilesDoNotExist('yarn.lock');
|
checkFilesDoNotExist('yarn.lock');
|
||||||
|
|||||||
@ -29,7 +29,6 @@ type Arguments = {
|
|||||||
name: string;
|
name: string;
|
||||||
preset: string;
|
preset: string;
|
||||||
appName: string;
|
appName: string;
|
||||||
cli: string;
|
|
||||||
style: string;
|
style: string;
|
||||||
framework: string;
|
framework: string;
|
||||||
docker: boolean;
|
docker: boolean;
|
||||||
@ -140,11 +139,6 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
|
|||||||
describe: chalk.dim`Enable interactive mode with presets`,
|
describe: chalk.dim`Enable interactive mode with presets`,
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
})
|
})
|
||||||
.option('cli', {
|
|
||||||
describe: chalk.dim`CLI to power the Nx workspace`,
|
|
||||||
choices: ['nx', 'angular'],
|
|
||||||
type: 'string',
|
|
||||||
})
|
|
||||||
.option('style', {
|
.option('style', {
|
||||||
describe: chalk.dim`Style option to be used when a preset with pregenerated app is selected`,
|
describe: chalk.dim`Style option to be used when a preset with pregenerated app is selected`,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -230,7 +224,6 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
|
|||||||
async function main(parsedArgs: yargs.Arguments<Arguments>) {
|
async function main(parsedArgs: yargs.Arguments<Arguments>) {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
cli,
|
|
||||||
preset,
|
preset,
|
||||||
appName,
|
appName,
|
||||||
style,
|
style,
|
||||||
@ -261,7 +254,6 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
|
|||||||
packageManager as PackageManager,
|
packageManager as PackageManager,
|
||||||
{
|
{
|
||||||
...parsedArgs,
|
...parsedArgs,
|
||||||
cli,
|
|
||||||
preset,
|
preset,
|
||||||
appName,
|
appName,
|
||||||
style,
|
style,
|
||||||
@ -384,7 +376,6 @@ async function getConfiguration(
|
|||||||
style = await determineStyle(preset, argv);
|
style = await determineStyle(preset, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cli = await determineCli(preset, argv);
|
|
||||||
const packageManager = await determinePackageManager(argv);
|
const packageManager = await determinePackageManager(argv);
|
||||||
const defaultBase = await determineDefaultBase(argv);
|
const defaultBase = await determineDefaultBase(argv);
|
||||||
const nxCloud = await determineNxCloud(argv);
|
const nxCloud = await determineNxCloud(argv);
|
||||||
@ -396,7 +387,6 @@ async function getConfiguration(
|
|||||||
appName,
|
appName,
|
||||||
style,
|
style,
|
||||||
framework,
|
framework,
|
||||||
cli,
|
|
||||||
nxCloud,
|
nxCloud,
|
||||||
packageManager,
|
packageManager,
|
||||||
defaultBase,
|
defaultBase,
|
||||||
@ -768,35 +758,6 @@ async function determineDockerfile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidCli(cli: string): cli is 'angular' | 'nx' {
|
|
||||||
return ['nx', 'angular'].indexOf(cli) !== -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function determineCli(
|
|
||||||
preset: Preset,
|
|
||||||
parsedArgs: yargs.Arguments<Arguments>
|
|
||||||
): Promise<'nx' | 'angular'> {
|
|
||||||
if (parsedArgs.cli) {
|
|
||||||
if (!isValidCli(parsedArgs.cli)) {
|
|
||||||
output.error({
|
|
||||||
title: 'Invalid cli',
|
|
||||||
bodyLines: [`It must be one of the following:`, '', 'nx', 'angular'],
|
|
||||||
});
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
return Promise.resolve(parsedArgs.cli);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (preset) {
|
|
||||||
case Preset.AngularMonorepo: {
|
|
||||||
return Promise.resolve('angular');
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Promise.resolve('nx');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function determineStyle(
|
async function determineStyle(
|
||||||
preset: Preset,
|
preset: Preset,
|
||||||
parsedArgs: yargs.Arguments<Arguments>
|
parsedArgs: yargs.Arguments<Arguments>
|
||||||
@ -1064,7 +1025,7 @@ async function createApp(
|
|||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
||||||
parsedArgs: any
|
parsedArgs: any
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { _, cli, ...restArgs } = parsedArgs;
|
const { _, ...restArgs } = parsedArgs;
|
||||||
|
|
||||||
// Ensure to use packageManager for args
|
// Ensure to use packageManager for args
|
||||||
// if it's not already passed in from previous process
|
// if it's not already passed in from previous process
|
||||||
@ -1122,17 +1083,8 @@ async function createPreset(
|
|||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
||||||
directory: string
|
directory: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const {
|
const { _, skipGit, ci, commit, allPrompts, nxCloud, preset, ...restArgs } =
|
||||||
_,
|
parsedArgs;
|
||||||
cli,
|
|
||||||
skipGit,
|
|
||||||
ci,
|
|
||||||
commit,
|
|
||||||
allPrompts,
|
|
||||||
nxCloud,
|
|
||||||
preset,
|
|
||||||
...restArgs
|
|
||||||
} = parsedArgs;
|
|
||||||
|
|
||||||
const args = unparse(restArgs).join(' ');
|
const args = unparse(restArgs).join(' ');
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,6 @@
|
|||||||
},
|
},
|
||||||
"x-prompt": "What name would you like to use for the workspace?"
|
"x-prompt": "What name would you like to use for the workspace?"
|
||||||
},
|
},
|
||||||
"cli": {
|
|
||||||
"description": "CLI used for generating code and running tasks.",
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["nx", "angular"],
|
|
||||||
"default": "nx"
|
|
||||||
},
|
|
||||||
"style": {
|
"style": {
|
||||||
"description": "The file extension to be used for style files.",
|
"description": "The file extension to be used for style files.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Tree, readJson, readProjectConfiguration } from '@nrwl/devkit';
|
import { readProjectConfiguration, Tree } from '@nrwl/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
import { overrideCollectionResolutionForTesting } from '@nrwl/devkit/ngcli-adapter';
|
import { overrideCollectionResolutionForTesting } from '@nrwl/devkit/ngcli-adapter';
|
||||||
import { presetGenerator } from './preset';
|
import { presetGenerator } from './preset';
|
||||||
@ -45,7 +45,6 @@ describe('preset', () => {
|
|||||||
await presetGenerator(tree, {
|
await presetGenerator(tree, {
|
||||||
name: 'proj',
|
name: 'proj',
|
||||||
preset: Preset.AngularMonorepo,
|
preset: Preset.AngularMonorepo,
|
||||||
cli: 'nx',
|
|
||||||
style: 'css',
|
style: 'css',
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
});
|
});
|
||||||
@ -58,7 +57,6 @@ describe('preset', () => {
|
|||||||
await presetGenerator(tree, {
|
await presetGenerator(tree, {
|
||||||
name: 'proj',
|
name: 'proj',
|
||||||
preset: Preset.WebComponents,
|
preset: Preset.WebComponents,
|
||||||
cli: 'nx',
|
|
||||||
});
|
});
|
||||||
expect(tree.exists('/apps/proj/src/main.ts')).toBe(true);
|
expect(tree.exists('/apps/proj/src/main.ts')).toBe(true);
|
||||||
});
|
});
|
||||||
@ -69,7 +67,6 @@ describe('preset', () => {
|
|||||||
preset: Preset.ReactMonorepo,
|
preset: Preset.ReactMonorepo,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
});
|
});
|
||||||
expect(tree.exists('/apps/proj/src/main.tsx')).toBe(true);
|
expect(tree.exists('/apps/proj/src/main.tsx')).toBe(true);
|
||||||
expect(readProjectConfiguration(tree, 'proj').targets.serve).toBeDefined();
|
expect(readProjectConfiguration(tree, 'proj').targets.serve).toBeDefined();
|
||||||
@ -81,7 +78,6 @@ describe('preset', () => {
|
|||||||
preset: Preset.NextJs,
|
preset: Preset.NextJs,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
});
|
});
|
||||||
expect(tree.exists('/apps/proj/pages/index.tsx')).toBe(true);
|
expect(tree.exists('/apps/proj/pages/index.tsx')).toBe(true);
|
||||||
});
|
});
|
||||||
@ -91,7 +87,6 @@ describe('preset', () => {
|
|||||||
name: 'proj',
|
name: 'proj',
|
||||||
preset: Preset.Express,
|
preset: Preset.Express,
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(tree.exists('apps/proj/src/main.ts')).toBe(true);
|
expect(tree.exists('apps/proj/src/main.ts')).toBe(true);
|
||||||
@ -103,7 +98,6 @@ describe('preset', () => {
|
|||||||
name: 'proj',
|
name: 'proj',
|
||||||
preset: Preset.ReactNative,
|
preset: Preset.ReactNative,
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(tree.exists('/apps/proj/src/app/App.tsx')).toBe(true);
|
expect(tree.exists('/apps/proj/src/app/App.tsx')).toBe(true);
|
||||||
@ -115,7 +109,6 @@ describe('preset', () => {
|
|||||||
preset: Preset.ReactStandalone,
|
preset: Preset.ReactStandalone,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
bundler: 'webpack',
|
bundler: 'webpack',
|
||||||
});
|
});
|
||||||
expect(tree.exists('webpack.config.js')).toBe(true);
|
expect(tree.exists('webpack.config.js')).toBe(true);
|
||||||
@ -130,7 +123,6 @@ describe('preset', () => {
|
|||||||
preset: Preset.ReactStandalone,
|
preset: Preset.ReactStandalone,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
linter: 'eslint',
|
linter: 'eslint',
|
||||||
cli: 'nx',
|
|
||||||
bundler: 'vite',
|
bundler: 'vite',
|
||||||
});
|
});
|
||||||
expect(tree.exists('vite.config.ts')).toBe(true);
|
expect(tree.exists('vite.config.ts')).toBe(true);
|
||||||
|
|||||||
@ -5,7 +5,6 @@ export interface Schema {
|
|||||||
name: string;
|
name: string;
|
||||||
npmScope?: string;
|
npmScope?: string;
|
||||||
style?: string;
|
style?: string;
|
||||||
cli: string;
|
|
||||||
linter?: string;
|
linter?: string;
|
||||||
preset: Preset;
|
preset: Preset;
|
||||||
standaloneConfig?: boolean;
|
standaloneConfig?: boolean;
|
||||||
|
|||||||
@ -18,10 +18,6 @@
|
|||||||
"description": "Npm scope for importing libs.",
|
"description": "Npm scope for importing libs.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"cli": {
|
|
||||||
"description": "CLI powering the workspace.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"description": "The tool to use for running lint checks.",
|
"description": "The tool to use for running lint checks.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user