Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): remove unused CLI option from CNW #14865

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/generated/cli/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ Choices: [github, circleci, azure, bitbucket-pipelines, gitlab]

Generate a CI workflow file

### cli

Type: `string`

Choices: [nx, angular]

CLI to power the Nx workspace

### commit.email

Type: `string`
Expand Down
8 changes: 0 additions & 8 deletions docs/generated/packages/nx/documents/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ Choices: [github, circleci, azure, bitbucket-pipelines, gitlab]

Generate a CI workflow file

### cli

Type: `string`

Choices: [nx, angular]

CLI to power the Nx workspace

### commit.email

Type: `string`
Expand Down
6 changes: 0 additions & 6 deletions docs/generated/packages/workspace/generators/new.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
"$default": { "$source": "argv", "index": 0 },
"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": {
"description": "The file extension to be used for style files.",
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion docs/generated/packages/workspace/generators/preset.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"description": "Npm scope for importing libs.",
"type": "string"
},
"cli": { "description": "CLI powering the workspace.", "type": "string" },
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
Expand Down
5 changes: 0 additions & 5 deletions e2e/angular-core/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ describe('Angular Config', () => {
afterAll(() => cleanupProject());

it('should upgrade the config correctly', async () => {
const previousCI = process.env.SELECTED_CLI;
process.env.SELECTED_CLI = 'angular';

const myapp = uniq('myapp');
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);

Expand All @@ -34,8 +31,6 @@ describe('Angular Config', () => {
const myapp2 = uniq('myapp');
runCLI(`generate @nrwl/angular:app ${myapp2} --no-interactive`);
expectTestsPass(await runCLIAsync(`test ${myapp2} --no-watch`));

process.env.SELECTED_CLI = previousCI;
}, 1000000);
});

Expand Down
3 changes: 1 addition & 2 deletions e2e/angular-core/src/ng-add.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
process.env.SELECTED_CLI = 'angular';

import {
checkFilesDoNotExist,
checkFilesExist,
Expand Down Expand Up @@ -56,6 +54,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
runNgAdd('@cypress/schematic', '--e2e-update', '1.7.0');
packageInstall('cypress', null, '^9.0.0');
}

function addCypress10() {
runNgAdd('@cypress/schematic', '--e2e', 'latest');
}
Expand Down
2 changes: 0 additions & 2 deletions e2e/angular-core/src/ng-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
import { PackageManager } from 'nx/src/utils/package-manager';
import { removeSync } from 'fs-extra';

process.env.SELECTED_CLI = 'angular';

describe('using Nx executors and generators with Angular CLI', () => {
let project: string;
let packageManager: PackageManager;
Expand Down
2 changes: 0 additions & 2 deletions e2e/angular-extensions/src/tailwind.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
process.env.SELECTED_CLI = 'angular';

import {
cleanupProject,
listFiles,
Expand Down
8 changes: 3 additions & 5 deletions e2e/storybook-angular/src/storybook-angular.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
process.env.SELECTED_CLI = 'angular';

import {
checkFilesExist,
cleanupProject,
getPackageManagerCommand,
isNotWindows,
killPorts,
newProject,
readFile,
cleanupProject,
runCLI,
runCommand,
runCypressTests,
tmpProjPath,
uniq,
getPackageManagerCommand,
updateJson,
runCommand,
} from '@nrwl/e2e/utils';
import { writeFileSync } from 'fs';

Expand Down
12 changes: 2 additions & 10 deletions e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ interface RunCmdOpts {
silent?: boolean;
}

export function currentCli() {
return process.env.SELECTED_CLI || 'nx';
}

export const e2eRoot = isCI
? dirSync({ prefix: 'nx-e2e-' }).name
: '/tmp/nx-e2e';
Expand All @@ -82,7 +78,7 @@ export function isVerbose() {
);
}

export const e2eCwd = `${e2eRoot}/${currentCli()}`;
export const e2eCwd = `${e2eRoot}/nx`;
ensureDirSync(e2eCwd);

let projName: string;
Expand Down Expand Up @@ -137,7 +133,6 @@ export function runCreateWorkspace(
style,
base,
packageManager,
cli,
extraArgs,
ci,
useDetectedPm = false,
Expand All @@ -149,7 +144,6 @@ export function runCreateWorkspace(
style?: string;
base?: string;
packageManager?: 'npm' | 'yarn' | 'pnpm';
cli?: string;
extraArgs?: string;
ci?: 'azure' | 'github' | 'circleci';
useDetectedPm?: boolean;
Expand All @@ -161,9 +155,7 @@ export function runCreateWorkspace(

const pm = getPackageManagerCommand({ packageManager });

let command = `${pm.createWorkspace} ${name} --cli=${
cli || currentCli()
Coly010 marked this conversation as resolved.
Show resolved Hide resolved
} --preset=${preset} --no-nxCloud --no-interactive`;
let command = `${pm.createWorkspace} ${name} --preset=${preset} --no-nxCloud --no-interactive`;
if (appName) {
command += ` --appName=${appName}`;
}
Expand Down
1 change: 0 additions & 1 deletion e2e/workspace-create/src/create-nx-workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ describe('create-nx-workspace', () => {
appName,
style: 'css',
packageManager: 'npm',
cli: 'angular',
});

checkFilesDoNotExist('yarn.lock');
Expand Down
54 changes: 3 additions & 51 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type Arguments = {
name: string;
preset: string;
appName: string;
cli: string;
style: string;
framework: string;
docker: boolean;
Expand Down Expand Up @@ -140,11 +139,6 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
describe: chalk.dim`Enable interactive mode with presets`,
type: 'boolean',
})
.option('cli', {
describe: chalk.dim`CLI to power the Nx workspace`,
choices: ['nx', 'angular'],
type: 'string',
})
.option('style', {
describe: chalk.dim`Style option to be used when a preset with pregenerated app is selected`,
type: 'string',
Expand Down Expand Up @@ -230,7 +224,6 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
async function main(parsedArgs: yargs.Arguments<Arguments>) {
const {
name,
cli,
preset,
appName,
style,
Expand Down Expand Up @@ -261,7 +254,6 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
packageManager as PackageManager,
{
...parsedArgs,
cli,
preset,
appName,
style,
Expand Down Expand Up @@ -384,7 +376,6 @@ async function getConfiguration(
style = await determineStyle(preset, argv);
}

const cli = await determineCli(preset, argv);
const packageManager = await determinePackageManager(argv);
const defaultBase = await determineDefaultBase(argv);
const nxCloud = await determineNxCloud(argv);
Expand All @@ -396,7 +387,6 @@ async function getConfiguration(
appName,
style,
framework,
cli,
nxCloud,
packageManager,
defaultBase,
Expand Down Expand Up @@ -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(
preset: Preset,
parsedArgs: yargs.Arguments<Arguments>
Expand Down Expand Up @@ -1064,7 +1025,7 @@ async function createApp(
packageManager: PackageManager,
parsedArgs: any
): Promise<string> {
const { _, cli, ...restArgs } = parsedArgs;
const { _, ...restArgs } = parsedArgs;

// Ensure to use packageManager for args
// if it's not already passed in from previous process
Expand Down Expand Up @@ -1122,17 +1083,8 @@ async function createPreset(
packageManager: PackageManager,
directory: string
): Promise<void> {
const {
_,
cli,
skipGit,
ci,
commit,
allPrompts,
nxCloud,
preset,
...restArgs
} = parsedArgs;
const { _, skipGit, ci, commit, allPrompts, nxCloud, preset, ...restArgs } =
parsedArgs;

const args = unparse(restArgs).join(' ');

Expand Down
6 changes: 0 additions & 6 deletions packages/workspace/src/generators/new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
},
"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": {
"description": "The file extension to be used for style files.",
"type": "string",
Expand Down
10 changes: 1 addition & 9 deletions packages/workspace/src/generators/preset/preset.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tree, readJson, readProjectConfiguration } from '@nrwl/devkit';
import { readProjectConfiguration, Tree } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { overrideCollectionResolutionForTesting } from '@nrwl/devkit/ngcli-adapter';
import { presetGenerator } from './preset';
Expand Down Expand Up @@ -45,7 +45,6 @@ describe('preset', () => {
await presetGenerator(tree, {
name: 'proj',
preset: Preset.AngularMonorepo,
cli: 'nx',
style: 'css',
linter: 'eslint',
});
Expand All @@ -58,7 +57,6 @@ describe('preset', () => {
await presetGenerator(tree, {
name: 'proj',
preset: Preset.WebComponents,
cli: 'nx',
});
expect(tree.exists('/apps/proj/src/main.ts')).toBe(true);
});
Expand All @@ -69,7 +67,6 @@ describe('preset', () => {
preset: Preset.ReactMonorepo,
style: 'css',
linter: 'eslint',
cli: 'nx',
});
expect(tree.exists('/apps/proj/src/main.tsx')).toBe(true);
expect(readProjectConfiguration(tree, 'proj').targets.serve).toBeDefined();
Expand All @@ -81,7 +78,6 @@ describe('preset', () => {
preset: Preset.NextJs,
style: 'css',
linter: 'eslint',
cli: 'nx',
});
expect(tree.exists('/apps/proj/pages/index.tsx')).toBe(true);
});
Expand All @@ -91,7 +87,6 @@ describe('preset', () => {
name: 'proj',
preset: Preset.Express,
linter: 'eslint',
cli: 'nx',
});

expect(tree.exists('apps/proj/src/main.ts')).toBe(true);
Expand All @@ -103,7 +98,6 @@ describe('preset', () => {
name: 'proj',
preset: Preset.ReactNative,
linter: 'eslint',
cli: 'nx',
});

expect(tree.exists('/apps/proj/src/app/App.tsx')).toBe(true);
Expand All @@ -115,7 +109,6 @@ describe('preset', () => {
preset: Preset.ReactStandalone,
style: 'css',
linter: 'eslint',
cli: 'nx',
bundler: 'webpack',
});
expect(tree.exists('webpack.config.js')).toBe(true);
Expand All @@ -130,7 +123,6 @@ describe('preset', () => {
preset: Preset.ReactStandalone,
style: 'css',
linter: 'eslint',
cli: 'nx',
bundler: 'vite',
});
expect(tree.exists('vite.config.ts')).toBe(true);
Expand Down
1 change: 0 additions & 1 deletion packages/workspace/src/generators/preset/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface Schema {
name: string;
npmScope?: string;
style?: string;
cli: string;
linter?: string;
preset: Preset;
standaloneConfig?: boolean;
Expand Down
4 changes: 0 additions & 4 deletions packages/workspace/src/generators/preset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
"description": "Npm scope for importing libs.",
"type": "string"
},
"cli": {
"description": "CLI powering the workspace.",
"type": "string"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
Expand Down