Skip to content

Commit

Permalink
cleanup(core): clean up workspace creation
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Nov 15, 2022
1 parent 0e3b0ef commit 8d9de7f
Show file tree
Hide file tree
Showing 50 changed files with 359 additions and 2,143 deletions.
2 changes: 1 addition & 1 deletion docs/generated/cli/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Package manager to use

Type: `string`

Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular", "angular-nest", "react", "react-experimental", "react-express", "react-native", "expo", "next", "nest", "express"]. To build your own see https://nx.dev/packages/nx-plugin#preset
Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular", "react", "react-experimental", "react-native", "expo", "next", "nest", "express"]. To build your own see https://nx.dev/packages/nx-plugin#preset

### skipGit

Expand Down
1,219 changes: 0 additions & 1,219 deletions docs/generated/packages/angular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/generated/packages/nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "create-nx-workspace",
"id": "create-nx-workspace",
"file": "generated/cli/create-nx-workspace",
"content": "---\ntitle: 'create-nx-workspace - CLI command'\ndescription: 'Create a new Nx workspace'\n---\n\n# create-nx-workspace\n\nCreate a new Nx workspace\n\n## Usage\n\n```bash\ncreate-nx-workspace [name] [options]\n```\n\nInstall `create-nx-workspace` globally to invoke the command directly, or use `npx create-nx-workspace`, `yarn create nx-workspace`, or `pnpx create-nx-workspace`.\n\n## Options\n\n### allPrompts\n\nType: `boolean`\n\nDefault: `false`\n\nShow all prompts\n\n### appName\n\nType: `string`\n\nThe name of the application when a preset with pregenerated app is selected\n\n### ci\n\nType: `string`\n\nChoices: [github, circleci, azure]\n\nGenerate a CI workflow file\n\n### cli\n\nType: `string`\n\nChoices: [nx, angular]\n\nCLI to power the Nx workspace\n\n### commit.email\n\nType: `string`\n\nE-mail of the committer\n\n### commit.message\n\nType: `string`\n\nDefault: `Initial commit`\n\nCommit message\n\n### commit.name\n\nType: `string`\n\nName of the committer\n\n### defaultBase\n\nType: `string`\n\nDefault: `main`\n\nDefault base to use for new projects\n\n### help\n\nType: `boolean`\n\nShow help\n\n### interactive\n\nType: `boolean`\n\nEnable interactive mode with presets\n\n### name\n\nType: `string`\n\nWorkspace name (e.g. org name)\n\n### nxCloud\n\nType: `boolean`\n\nEnable distributed caching to make your CI faster\n\n### packageManager\n\nType: `string`\n\nChoices: [npm, pnpm, yarn]\n\nDefault: `npm`\n\nPackage manager to use\n\n### preset\n\nType: `string`\n\nCustomizes the initial content of your workspace. Default presets include: [\"apps\", \"empty\", \"core\", \"npm\", \"ts\", \"web-components\", \"angular\", \"angular-nest\", \"react\", \"react-experimental\", \"react-express\", \"react-native\", \"expo\", \"next\", \"nest\", \"express\"]. To build your own see https://nx.dev/packages/nx-plugin#preset\n\n### skipGit\n\nType: `boolean`\n\nDefault: `false`\n\nSkip initializing a git repository.\n\n### style\n\nType: `string`\n\nStyle option to be used when a preset with pregenerated app is selected\n\n### version\n\nType: `boolean`\n\nShow version number\n"
"content": "---\ntitle: 'create-nx-workspace - CLI command'\ndescription: 'Create a new Nx workspace'\n---\n\n# create-nx-workspace\n\nCreate a new Nx workspace\n\n## Usage\n\n```bash\ncreate-nx-workspace [name] [options]\n```\n\nInstall `create-nx-workspace` globally to invoke the command directly, or use `npx create-nx-workspace`, `yarn create nx-workspace`, or `pnpx create-nx-workspace`.\n\n## Options\n\n### allPrompts\n\nType: `boolean`\n\nDefault: `false`\n\nShow all prompts\n\n### appName\n\nType: `string`\n\nThe name of the application when a preset with pregenerated app is selected\n\n### ci\n\nType: `string`\n\nChoices: [github, circleci, azure]\n\nGenerate a CI workflow file\n\n### cli\n\nType: `string`\n\nChoices: [nx, angular]\n\nCLI to power the Nx workspace\n\n### commit.email\n\nType: `string`\n\nE-mail of the committer\n\n### commit.message\n\nType: `string`\n\nDefault: `Initial commit`\n\nCommit message\n\n### commit.name\n\nType: `string`\n\nName of the committer\n\n### defaultBase\n\nType: `string`\n\nDefault: `main`\n\nDefault base to use for new projects\n\n### help\n\nType: `boolean`\n\nShow help\n\n### interactive\n\nType: `boolean`\n\nEnable interactive mode with presets\n\n### name\n\nType: `string`\n\nWorkspace name (e.g. org name)\n\n### nxCloud\n\nType: `boolean`\n\nEnable distributed caching to make your CI faster\n\n### packageManager\n\nType: `string`\n\nChoices: [npm, pnpm, yarn]\n\nDefault: `npm`\n\nPackage manager to use\n\n### preset\n\nType: `string`\n\nCustomizes the initial content of your workspace. Default presets include: [\"apps\", \"empty\", \"core\", \"npm\", \"ts\", \"web-components\", \"angular\", \"react\", \"react-experimental\", \"react-native\", \"expo\", \"next\", \"nest\", \"express\"]. To build your own see https://nx.dev/packages/nx-plugin#preset\n\n### skipGit\n\nType: `boolean`\n\nDefault: `false`\n\nSkip initializing a git repository.\n\n### style\n\nType: `string`\n\nStyle option to be used when a preset with pregenerated app is selected\n\n### version\n\nType: `boolean`\n\nShow version number\n"
},
{
"name": "init",
Expand Down
84 changes: 0 additions & 84 deletions docs/generated/packages/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,90 +21,6 @@
}
],
"generators": [
{
"name": "workspace",
"factory": "./src/generators/workspace/workspace#workspaceGenerator",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsNxNgNew",
"cli": "nx",
"title": "Create an empty workspace",
"description": "Create an empty workspace.",
"type": "object",
"properties": {
"name": {
"description": "The name of the workspace.",
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the workspace?"
},
"style": {
"description": "The file extension to be used for style files.",
"type": "string",
"default": "css",
"x-prompt": {
"message": "Which stylesheet format would you like to use?",
"type": "list",
"items": [
{ "value": "css", "label": "CSS" },
{
"value": "scss",
"label": "SASS(.scss) [ http://sass-lang.com ]"
},
{
"value": "styl",
"label": "Stylus(.styl)[ http://stylus-lang.com ]"
},
{
"value": "less",
"label": "LESS [ http://lesscss.org ]"
}
]
}
},
"directory": {
"type": "string",
"format": "path",
"description": "The directory name to create the workspace in.",
"default": ""
},
"preset": {
"type": "string",
"description": "Preset of the workspace."
},
"npmScope": {
"type": "string",
"description": "Npm scope for importing libs."
},
"defaultBase": {
"type": "string",
"description": "Default base branch for affected."
},
"skipInstall": {
"description": "Skip installing dependency packages.",
"type": "boolean",
"default": false
},
"packageManager": {
"description": "The package manager used to install dependencies.",
"type": "string",
"enum": ["npm", "yarn", "pnpm"]
},
"cli": {
"description": "CLI used for generating code and running tasks",
"type": "string",
"enum": ["nx", "angular"],
"default": "nx"
}
},
"presets": []
},
"description": "Create an empty workspace.",
"hidden": true,
"implementation": "/packages/workspace/src/generators/workspace/workspace#workspaceGenerator.ts",
"aliases": [],
"path": "/packages/workspace/src/generators/workspace/schema.json"
},
{
"name": "preset",
"factory": "./src/generators/preset/preset#presetGenerator",
Expand Down
5 changes: 0 additions & 5 deletions docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"delegate-build",
"ng-packagr-lite",
"package",
"webpack-browser",
"webpack-dev-server",
"webpack-server",
"module-federation-dev-server",
"file-server"
],
"generators": [
Expand Down Expand Up @@ -406,7 +402,6 @@
"schemas": {
"executors": ["run-commands", "counter", "run-script"],
"generators": [
"workspace",
"preset",
"move",
"remove",
Expand Down
1 change: 0 additions & 1 deletion docs/shared/recipes/local-executors.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ This file describes the options being sent to the executor (very similar to the
{
"$schema": "http://json-schema.org/schema",
"type": "object",
"cli": "nx",
"properties": {
"textToEcho": {
"type": "string",
Expand Down
6 changes: 4 additions & 2 deletions e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ProjectConfiguration,
ProjectsConfigurations,
readJsonFile,
workspaceRoot,
} from '@nrwl/devkit';
import { angularCliVersion } from '@nrwl/workspace/src/utils/versions';
import { ChildProcess, exec, execSync, ExecSyncOptions } from 'child_process';
Expand Down Expand Up @@ -35,7 +36,8 @@ export function getPublishedVersion(): string {
process.env.PUBLISHED_VERSION =
process.env.PUBLISHED_VERSION ||
// read version of built nx package
readJsonFile(`./build/packages/nx/package.json`).version ||
readJsonFile(join(workspaceRoot, `./build/packages/nx/package.json`))
.version ||
// fallback to latest if built nx package is missing
'latest';
return process.env.PUBLISHED_VERSION as string;
Expand Down Expand Up @@ -197,7 +199,7 @@ export function runCreateWorkspace(

const create = execSync(command, {
cwd,
stdio: ['pipe', 'pipe', 'pipe'],
stdio: isVerbose() ? 'inherit' : 'pipe',
env: { CI: 'true', ...process.env },
encoding: 'utf-8',
});
Expand Down
27 changes: 0 additions & 27 deletions e2e/workspace-create/src/create-nx-workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,6 @@ describe('create-nx-workspace', () => {
expectNoAngularDevkit();
});

it('should be able to create an angular + nest workspace', () => {
const wsName = uniq('angular-nest');
const appName = uniq('app');
runCreateWorkspace(wsName, {
preset: 'angular-nest',
style: 'css',
appName,
packageManager,
});
});

it('should be able to create an react + express workspace', () => {
const wsName = uniq('react-express');
const appName = uniq('app');
runCreateWorkspace(wsName, {
preset: 'react-express',
style: 'css',
appName,
packageManager,
});

expectNoAngularDevkit();
expectNoTsJestInJestConfig(appName);
});

it('should be able to create an express workspace', () => {
const wsName = uniq('express');
const appName = uniq('app');
Expand Down Expand Up @@ -272,8 +247,6 @@ describe('create-nx-workspace', () => {
cli: 'angular',
});

const nxJson = readJson('nx.json');
expect(nxJson.cli.packageManager).toEqual('npm');
checkFilesDoNotExist('yarn.lock');
checkFilesExist('package-lock.json');
process.env.SELECTED_PM = packageManager;
Expand Down
17 changes: 0 additions & 17 deletions nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ describe('nx-dev: Packages Section', () => {
title: '@nrwl/angular:package',
path: '/packages/angular/executors/package',
},
{
title: '@nrwl/angular:webpack-browser',
path: '/packages/angular/executors/webpack-browser',
},
{
title: '@nrwl/angular:webpack-dev-server',
path: '/packages/angular/executors/webpack-dev-server',
},
{
title: '@nrwl/angular:module-federation-dev-server',
path: '/packages/angular/executors/module-federation-dev-server',
},
{
title: '@nrwl/angular:file-server',
path: '/packages/angular/executors/file-server',
Expand Down Expand Up @@ -468,11 +456,6 @@ describe('nx-dev: Packages Section', () => {
title: '@nrwl/web:file-server',
path: '/packages/web/executors/file-server',
},
{ title: '@nrwl/workspace', path: '/packages/workspace' },
{
title: '@nrwl/workspace:workspace',
path: '/packages/workspace/generators/workspace',
},
{
title: '@nrwl/workspace:preset',
path: '/packages/workspace/generators/preset',
Expand Down
20 changes: 0 additions & 20 deletions packages/angular/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,6 @@
"schema": "./src/executors/package/schema.json",
"description": "Builds and packages an Angular library to be distributed as an NPM package. It supports incremental builds."
},
"webpack-browser": {
"implementation": "./src/builders/webpack-browser/webpack-browser.impl",
"schema": "./src/builders/webpack-browser/schema.json",
"description": "The `webpack-browser` executor is very similar to the standard `browser` builder provided by the Angular Devkit. It allows you to build your Angular application to a build artifact that can be hosted online. There are some key differences: \n- Supports Custom Webpack Configurations \n- Supports Incremental Building"
},
"webpack-dev-server": {
"implementation": "./src/builders/webpack-dev-server/webpack-dev-server.impl",
"schema": "./src/builders/webpack-dev-server/schema.json",
"description": "The `webpack-dev-server` executor is very similar to the standard `dev-server` builder provided by the Angular Devkit. It is usually used in tandem with `@nrwl/angular:webpack-browser` when your Angular application uses a custom webpack configuration."
},
"webpack-server": {
"implementation": "./src/builders/webpack-server/webpack-server.impl",
"schema": "./src/builders/webpack-server/schema.json",
"description": "The `webpack-server` executor is very similar to the standard `server` builder provided by the Angular Devkit. It is usually used in tandem with `@nrwl/angular:webpack-browser` when your Angular application uses a custom webpack configuration and NgUniversal for SSR."
},
"module-federation-dev-server": {
"implementation": "./src/builders/module-federation-dev-server/module-federation-dev-server.impl",
"schema": "./src/builders/module-federation-dev-server/schema.json",
"description": "The module-federation-dev-server executor is reserved exclusively for use with host Module Federation applications. It allows the user to specify which remote applications should be served with the host."
},
"file-server": {
"implementation": "./src/executors/file-server/file-server.impl",
"schema": "./src/executors/file-server/schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
writeJson,
} from '@nrwl/devkit';
import { Linter, lintInitGenerator } from '@nrwl/linter';
import { DEFAULT_NRWL_PRETTIER_CONFIG } from '@nrwl/workspace/src/generators/workspace/workspace';
import { DEFAULT_NRWL_PRETTIER_CONFIG } from '@nrwl/workspace/src/generators/new/generate-workspace-files';
import { deduceDefaultBase } from '@nrwl/workspace/src/utilities/default-base';
import { resolveUserExistingPrettierConfig } from '@nrwl/workspace/src/utilities/prettier';
import { getRootTsConfigPathInTree } from '@nrwl/workspace/src/utilities/typescript';
Expand Down
28 changes: 4 additions & 24 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ enum Preset {
TS = 'ts',
WebComponents = 'web-components',
Angular = 'angular',
AngularWithNest = 'angular-nest',
React = 'react',
ReactExperimental = 'react-experimental',
ReactWithExpress = 'react-express',
ReactNative = 'react-native',
Expo = 'expo',
NextJs = 'next',
Expand Down Expand Up @@ -111,16 +109,6 @@ const presetOptions: { name: Preset; message: string }[] = [
name: Preset.Expo,
message: 'expo [a workspace with a single Expo application]',
},
{
name: Preset.ReactWithExpress,
message:
'react-express [a workspace with a full stack application (React + Express)]',
},
{
name: Preset.AngularWithNest,
message:
'angular-nest [a workspace with a full stack application (Angular + Nest)]',
},
];

const nxVersion = require('../package.json').version;
Expand Down Expand Up @@ -625,8 +613,7 @@ async function determineCli(
}

switch (preset) {
case Preset.Angular:
case Preset.AngularWithNest: {
case Preset.Angular: {
return Promise.resolve('angular');
}
default: {
Expand Down Expand Up @@ -668,20 +655,15 @@ async function determineStyle(
},
];

if (![Preset.Angular, Preset.AngularWithNest].includes(preset)) {
if (![Preset.Angular].includes(preset)) {
choices.push({
name: 'styl',
message: 'Stylus(.styl) [ http://stylus-lang.com ]',
});
}

if (
[
Preset.ReactWithExpress,
Preset.React,
Preset.ReactExperimental,
Preset.NextJs,
].includes(preset)
[Preset.React, Preset.ReactExperimental, Preset.NextJs].includes(preset)
) {
choices.push(
{
Expand Down Expand Up @@ -868,7 +850,7 @@ async function createApp(

const pmc = getPackageManagerCommand(packageManager);

const command = `new ${name} ${args} --collection=@nrwl/workspace/generators.json --cli=${cli}`;
const command = `new ${name} ${args}`;

const workingDir = process.cwd().replace(/\\/g, '/');
let nxWorkspaceRoot = `"${workingDir}"`;
Expand Down Expand Up @@ -1039,7 +1021,6 @@ function pointToTutorialAndCourse(preset: Preset) {

case Preset.React:
case Preset.ReactExperimental:
case Preset.ReactWithExpress:
case Preset.NextJs:
output.addVerticalSeparator();
output.note({
Expand All @@ -1048,7 +1029,6 @@ function pointToTutorialAndCourse(preset: Preset) {
});
break;
case Preset.Angular:
case Preset.AngularWithNest:
output.addVerticalSeparator();
output.note({
title,
Expand Down
Loading

1 comment on commit 8d9de7f

@vercel
Copy link

@vercel vercel bot commented on 8d9de7f Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.