cleanup(misc): use more es6 features

- Single char alternation (e.g. a|b|c|d) in a RegExp can be simplified to use a character class ([abcd]) instead.
  This usually also provides slightly better matching performance.
- Character escapes that are replaceable with the unescaped character without a change in meaning. Inside the square brackets of a character class, many escapes are unnecessary that would be necessary outside of a character class. For example the regex [\.] is identical to [.]
- If several qualified expressions occur after the qualifier having been checked for nullable, they can be replaced with optional chaining
This commit is contained in:
Vivek More 🧐 2021-03-23 17:24:11 -04:00 committed by Victor Savkin
parent 4b669f2d52
commit 212fb00548
64 changed files with 95 additions and 113 deletions

View File

@ -7,7 +7,7 @@ We would love for you to contribute to Nx! Read this document to see how to do i
Watch this 5-minute video: Watch this 5-minute video:
<a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank"> <a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
</a> </a>
## Got a Question? ## Got a Question?

View File

@ -1,6 +1,6 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
<div align="center"> <div style="text-align: center;">
[![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx) [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
[![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]() [![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]()
@ -103,12 +103,12 @@ You are good to go!
<tr> <tr>
<td> <td>
<a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank"> <a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank">
<p align="center">Angular<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p> <p style="text-align: center;">Angular<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
</a> </a>
</td> </td>
<td> <td>
<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank"> <a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center">React<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p> <p style="text-align: center;">React<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a> </a>
</td> </td>
</tr> </tr>
@ -125,17 +125,17 @@ You are good to go!
<tr> <tr>
<td> <td>
<a href="https://egghead.io/playlists/scale-react-development-with-nx-4038" target="_blank"> <a href="https://egghead.io/playlists/scale-react-development-with-nx-4038" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p>
</a> </a>
</td> </td>
<td> <td>
<a href="https://www.youtube.com/watch?v=2mYLe9Kp9VM&list=PLakNactNC1dH38AfqmwabvOszDmKriGco" target="_blank"> <a href="https://www.youtube.com/watch?v=2mYLe9Kp9VM&list=PLakNactNC1dH38AfqmwabvOszDmKriGco" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p>
</a> </a>
</td> </td>
<td> <td>
<a href="https://nxplaybook.com/p/advanced-nx-workspaces" target="_blank"> <a href="https://nxplaybook.com/p/advanced-nx-workspaces" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p>
</a> </a>
</td> </td>
</tr> </tr>
@ -193,7 +193,7 @@ You are good to go!
If you want to file a bug or submit a PR, read up on our [guidelines for contributing](https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md) and watch this video that will help you get started. If you want to file a bug or submit a PR, read up on our [guidelines for contributing](https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md) and watch this video that will help you get started.
<a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank"> <a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
</a> </a>
## Core Team ## Core Team

View File

@ -17,7 +17,7 @@ export class ProjectEdge {
target: this.dep.target, target: this.dep.target,
}, },
}; };
edge.classes = this.dep.type ? this.dep.type : ''; edge.classes = this.dep.type ?? '';
if (this.affected) { if (this.affected) {
edge.classes += ' affected'; edge.classes += ' affected';
} }

View File

@ -37,7 +37,7 @@ export class ProjectNode {
} }
private getClasses(): string { private getClasses(): string {
let classes = this.project.type ? this.project.type : ''; let classes = this.project.type ?? '';
if (this.focused) { if (this.focused) {
classes += ' focused'; classes += ' focused';

View File

@ -102,12 +102,11 @@ h5 {
} }
.sidebar { .sidebar {
min-width: 200px; min-width: 260px;
max-width: calc(50% - 10px); max-width: calc(50% - 10px);
z-index: 1; z-index: 1;
position: relative; position: relative;
height: 100%; height: 100%;
min-width: 260px;
box-shadow: 2px 0 2px rgba(51, 51, 51, 0.1); box-shadow: 2px 0 2px rgba(51, 51, 51, 0.1);
} }
@ -176,13 +175,12 @@ html {
} }
.tag { .tag {
padding: 0.4rem; padding: 0.5rem;
font-size: 0.75em; font-size: 0.75em;
display: inline-block; display: inline-block;
border: 1px solid var(--color-nrwl-light-blue); border: 1px solid var(--color-nrwl-light-blue);
text-transform: uppercase; text-transform: uppercase;
color: var(--color-grey); color: var(--color-grey);
padding: 0.5rem;
line-height: 1; line-height: 1;
letter-spacing: 0.5px; letter-spacing: 0.5px;
margin-right: 0.4em; margin-right: 0.4em;

View File

@ -1,19 +1,19 @@
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager';
import { ChildProcess, exec, execSync } from 'child_process'; import { ChildProcess, exec, execSync } from 'child_process';
import { import {
copySync,
createFileSync,
ensureDirSync,
moveSync,
readdirSync, readdirSync,
readFileSync, readFileSync,
removeSync,
renameSync, renameSync,
statSync, statSync,
writeFileSync, writeFileSync,
ensureDirSync,
createFileSync,
moveSync,
copySync,
removeSync,
} from 'fs-extra'; } from 'fs-extra';
import * as path from 'path';
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager';
import * as isCI from 'is-ci'; import * as isCI from 'is-ci';
import * as path from 'path';
interface RunCmdOpts { interface RunCmdOpts {
silenceError?: boolean; silenceError?: boolean;
@ -23,7 +23,7 @@ interface RunCmdOpts {
} }
export function currentCli() { export function currentCli() {
return process.env.SELECTED_CLI ? process.env.SELECTED_CLI : 'nx'; return process.env.SELECTED_CLI ?? 'nx';
} }
let projName: string; let projName: string;
@ -359,16 +359,14 @@ function setMaxWorkers() {
const workspace = readJson(workspaceFile); const workspace = readJson(workspaceFile);
Object.keys(workspace.projects).forEach((appName) => { Object.keys(workspace.projects).forEach((appName) => {
const targets = workspace.projects[appName].targets const project = workspace.projects[appName];
? workspace.projects[appName].targets const { build } = project.targets ?? project.architect;
: workspace.projects[appName].architect;
const build = targets.build;
if (!build) { if (!build) {
return; return;
} }
const executor = build.builder ? build.builder : build.executor; const executor = build.builder ?? build.executor;
if ( if (
executor.startsWith('@nrwl/node') || executor.startsWith('@nrwl/node') ||
executor.startsWith('@nrwl/web') || executor.startsWith('@nrwl/web') ||

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}
@ -36,7 +36,7 @@ You can always add the Angular plugin to an existing workspace by installing `@n
## Quick Start Videos ## Quick Start Videos
<a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank"> <a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
</a> </a>
- [Nx Dev Tools for Monorepos, In-Depth Explainer](https://youtu.be/h5FIGDn5YM0) - [Nx Dev Tools for Monorepos, In-Depth Explainer](https://youtu.be/h5FIGDn5YM0)

View File

@ -827,7 +827,7 @@ function normalizeOptions(host: Tree, options: Schema): NormalizedSchema {
const defaultPrefix = getNpmScope(host); const defaultPrefix = getNpmScope(host);
return { return {
...options, ...options,
prefix: options.prefix ? options.prefix : defaultPrefix, prefix: options.prefix ?? defaultPrefix,
name: appProjectName, name: appProjectName,
appProjectRoot, appProjectRoot,
e2eProjectRoot, e2eProjectRoot,

View File

@ -12,7 +12,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the application?", "x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"description": "The directory of the new application.", "description": "The directory of the new application.",

View File

@ -88,9 +88,7 @@ function addEntryComponentsToModule(options: Schema): Rule {
} }
export default function (options: Schema): Rule { export default function (options: Schema): Rule {
const angularJsImport = options.angularJsImport const angularJsImport = options.angularJsImport ?? options.name;
? options.angularJsImport
: options.name;
return chain([ return chain([
updateMain(angularJsImport, options), updateMain(angularJsImport, options),

View File

@ -30,7 +30,7 @@ export function normalizeOptions(
return { return {
...options, ...options,
prefix: options.prefix ? options.prefix : defaultPrefix, prefix: options.prefix ?? defaultPrefix,
name: projectName, name: projectName,
projectRoot, projectRoot,
entryFile: 'index', entryFile: 'index',

View File

@ -12,7 +12,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the library?", "x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"type": "string", "type": "string",

View File

@ -123,9 +123,7 @@ function createFiles(angularJsImport: string, options: Schema): Rule {
} }
export default function (options: Schema): Rule { export default function (options: Schema): Rule {
const angularJsImport = options.angularJsImport const angularJsImport = options.angularJsImport ?? options.name;
? options.angularJsImport
: options.name;
return chain([ return chain([
createFiles(angularJsImport, options), createFiles(angularJsImport, options),

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -112,7 +112,7 @@ export function parseRunOneOptions(
workspaceConfigJson.projects && workspaceConfigJson.projects[project]; workspaceConfigJson.projects && workspaceConfigJson.projects[project];
if (!p) return false; if (!p) return false;
const targets = p.architect ? p.architect : p.targets; const targets = p.architect ?? p.targets;
// for backwards compat we require targets to be set when use defaultProjectName // for backwards compat we require targets to be set when use defaultProjectName
if ((!targets || !targets[target]) && projectIsNotSetExplicitly) return false; if ((!targets || !targets[target]) && projectIsNotSetExplicitly) return false;
if (invalidTargetNames.indexOf(target) > -1) return false; if (invalidTargetNames.indexOf(target) > -1) return false;

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -19,7 +19,7 @@ describe('getWebpackConfig', () => {
}, },
}); });
expect(config.module.rules).toContainEqual({ expect(config.module.rules).toContainEqual({
test: /\.(j|t)sx?$/, test: /\.([jt])sx?$/,
loader: require.resolve('ts-loader'), loader: require.resolve('ts-loader'),
exclude: [/node_modules/], exclude: [/node_modules/],
options: { options: {

View File

@ -36,7 +36,7 @@ export function getWebpackConfig(config: any) {
module: { module: {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.([jt])sx?$/,
loader: require.resolve('ts-loader'), loader: require.resolve('ts-loader'),
exclude: [/node_modules/], exclude: [/node_modules/],
options: { options: {

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -15,9 +15,7 @@ export function getWorkspaceLayout(
host: Tree host: Tree
): { appsDir: string; libsDir: string; npmScope: string } { ): { appsDir: string; libsDir: string; npmScope: string } {
const nxJson = readJson<NxJsonConfiguration>(host, 'nx.json'); const nxJson = readJson<NxJsonConfiguration>(host, 'nx.json');
const layout = nxJson.workspaceLayout const layout = nxJson.workspaceLayout ?? { appsDir: 'apps', libsDir: 'libs' };
? nxJson.workspaceLayout
: { appsDir: 'apps', libsDir: 'libs' };
const npmScope = nxJson.npmScope; const npmScope = nxJson.npmScope;
return { ...layout, npmScope }; return { ...layout, npmScope };
} }

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -12,7 +12,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the node application?", "x-prompt": "What name would you like to use for the node application?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"description": "The directory of the new application.", "description": "The directory of the new application.",

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-gatsby.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-gatsby.png" width="600"></p>
{{links}} {{links}}
@ -32,7 +32,7 @@ You are good to go!
## Quick Start Videos ## Quick Start Videos
<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank"> <a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a> </a>
- [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE) - [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE)

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED-CONTENT:START (STARTER) --> <!-- AUTO-GENERATED-CONTENT:START (STARTER) -->
<p align="center"> <p style="text-align: center;">
<a href="https://www.gatsbyjs.org"> <a href="https://www.gatsbyjs.org">
<img alt="Gatsby" src="https://www.gatsbyjs.org/monogram.svg" width="60" /> <img alt="Gatsby" src="https://www.gatsbyjs.org/monogram.svg" width="60" />
</a> </a>

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -29,7 +29,7 @@ function normalizeOptions(
name, name,
path: options.path, path: options.path,
sourceRoot, sourceRoot,
spec: options.spec ? options.spec : options.unitTestRunner === 'jest', spec: options.spec ?? options.unitTestRunner === 'jest',
}; };
} }

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-next.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-next.png" width="600"></p>
{{links}} {{links}}
@ -32,7 +32,7 @@ You are good to go!
## Quick Start Videos ## Quick Start Videos
<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank"> <a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a> </a>
- [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE) - [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE)

View File

@ -19,7 +19,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the application?", "x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"description": "The directory of the new application.", "description": "The directory of the new application.",

View File

@ -53,7 +53,7 @@ export function createWebpackConfig(
config.module.rules.push( config.module.rules.push(
{ {
test: /\.(j|t)sx?$/, test: /\.([jt])sx?$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [defaultLoaders.babel], use: [defaultLoaders.babel],
}, },

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -35,7 +35,7 @@ export function getBaseWebpackPartial(
module: { module: {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.([jt])sx?$/,
loader: require.resolve(`ts-loader`), loader: require.resolve(`ts-loader`),
exclude: /node_modules/, exclude: /node_modules/,
options: { options: {
@ -111,7 +111,7 @@ export function getBaseWebpackPartial(
'.gitkeep', '.gitkeep',
'**/.DS_Store', '**/.DS_Store',
'**/Thumbs.db', '**/Thumbs.db',
...(asset.ignore ? asset.ignore : []), ...(asset.ignore ?? []),
], ],
dot: true, dot: true,
}, },

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -15,7 +15,7 @@ export function updateExecutorJson(
} }
return updateJsonInTree(executorPath, (json) => { return updateJsonInTree(executorPath, (json) => {
let executors = json.executors ? json.executors : json.builders; let executors = json.executors ?? json.builders;
executors = executors || {}; executors = executors || {};
executors[options.name] = { executors[options.name] = {
implementation: `./src/executors/${options.name}/executor`, implementation: `./src/executors/${options.name}/executor`,

View File

@ -15,7 +15,7 @@ export function updateGeneratorJson(
} }
return updateJsonInTree(generatorPath, (json) => { return updateJsonInTree(generatorPath, (json) => {
let generators = json.generators ? json.generators : json.schematics; let generators = json.generators ?? json.schematics;
generators = generators || {}; generators = generators || {};
generators[options.name] = { generators[options.name] = {
factory: `./src/generators/${options.name}/generator`, factory: `./src/generators/${options.name}/generator`,

View File

@ -12,7 +12,7 @@ export function updateMigrationsJson(options: NormalizedSchema): Rule {
delete json.schematics; delete json.schematics;
} }
const generators = json.generators ? json.generators : {}; const generators = json.generators ?? {};
generators[options.name] = { generators[options.name] = {
version: options.version, version: options.version,
description: options.description, description: options.description,
@ -22,9 +22,7 @@ export function updateMigrationsJson(options: NormalizedSchema): Rule {
json.generators = generators; json.generators = generators;
if (options.packageJsonUpdates) { if (options.packageJsonUpdates) {
const packageJsonUpdatesObj = json.packageJsonUpdates const packageJsonUpdatesObj = json.packageJsonUpdates ?? {};
? json.packageJsonUpdates
: {};
if (!packageJsonUpdatesObj[options.version]) { if (!packageJsonUpdatesObj[options.version]) {
packageJsonUpdatesObj[options.version] = { packageJsonUpdatesObj[options.version] = {
version: options.version, version: options.version,

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react.png" width="600"></p>
{{links}} {{links}}
@ -32,7 +32,7 @@ You can always add the React plugin to an existing workspace by installing `@nrw
## Quick Start Videos ## Quick Start Videos
<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank"> <a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a> </a>
- [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE) - [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE)

View File

@ -27,7 +27,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the application?", "x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"description": "The directory of the new application.", "description": "The directory of the new application.",

View File

@ -23,7 +23,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the library?", "x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"type": "string", "type": "string",

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -322,9 +322,7 @@ export class Workspaces {
const packageJson = JSON.parse( const packageJson = JSON.parse(
stripJsonComments(fs.readFileSync(packageJsonPath).toString()) stripJsonComments(fs.readFileSync(packageJsonPath).toString())
); );
const executorsFile = packageJson.executors const executorsFile = packageJson.executors ?? packageJson.builders;
? packageJson.executors
: packageJson.builders;
if (!executorsFile) { if (!executorsFile) {
throw new Error( throw new Error(
@ -364,9 +362,7 @@ export class Workspaces {
const packageJson = JSON.parse( const packageJson = JSON.parse(
stripJsonComments(fs.readFileSync(packageJsonPath).toString()) stripJsonComments(fs.readFileSync(packageJsonPath).toString())
); );
const generatorsFile = packageJson.generators const generatorsFile = packageJson.generators ?? packageJson.schematics;
? packageJson.generators
: packageJson.schematics;
if (!generatorsFile) { if (!generatorsFile) {
throw new Error( throw new Error(
@ -431,7 +427,7 @@ export function reformattedWorkspaceJsonOrNull(w: any) {
export function toNewFormat(w: any): WorkspaceJsonConfiguration { export function toNewFormat(w: any): WorkspaceJsonConfiguration {
const f = toNewFormatOrNull(w); const f = toNewFormatOrNull(w);
return f ? f : w; return f ?? w;
} }
export function toNewFormatOrNull(w: any) { export function toNewFormatOrNull(w: any) {

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -255,7 +255,7 @@ function normalizeOptions(host: Tree, options: Schema): NormalizedSchema {
return { return {
...options, ...options,
prefix: options.prefix ? options.prefix : defaultPrefix, prefix: options.prefix ?? defaultPrefix,
name: names(options.name).fileName, name: names(options.name).fileName,
projectName: appProjectName, projectName: appProjectName,
appProjectRoot, appProjectRoot,

View File

@ -13,7 +13,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the application?", "x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"description": "The directory of the new application.", "description": "The directory of the new application.",

View File

@ -242,7 +242,7 @@ export function createCopyPlugin(assets: AssetGlobPattern[]) {
'.gitkeep', '.gitkeep',
'**/.DS_Store', '**/.DS_Store',
'**/Thumbs.db', '**/Thumbs.db',
...(asset.ignore ? asset.ignore : []), ...(asset.ignore ?? []),
], ],
dot: true, dot: true,
}, },

View File

@ -467,7 +467,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
// Always replace the context for the System.import in angular/core to prevent warnings. // Always replace the context for the System.import in angular/core to prevent warnings.
// https://github.com/angular/angular/issues/11580 // https://github.com/angular/angular/issues/11580
// With VE the correct context is added in @ngtools/webpack, but Ivy doesn't need it at all. // With VE the correct context is added in @ngtools/webpack, but Ivy doesn't need it at all.
new ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)/), new ContextReplacementPlugin(/@angular([\\/])core([\\/])/),
...extraPlugins, ...extraPlugins,
], ],
}; };

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>
{{links}} {{links}}

View File

@ -174,7 +174,7 @@ export function readWorkspaceConfig(opts: { format: 'angularCli' | 'nx' }) {
const json = readWorkspaceJson(); const json = readWorkspaceJson();
if (opts.format === 'angularCli') { if (opts.format === 'angularCli') {
const formatted = toOldFormatOrNull(json); const formatted = toOldFormatOrNull(json);
return formatted ? formatted : json; return formatted ?? json;
} else { } else {
return json; return json;
} }

View File

@ -69,7 +69,7 @@ export function readCache(): false | ProjectGraphCache {
performance.mark('read cache:end'); performance.mark('read cache:end');
performance.measure('read cache', 'read cache:start', 'read cache:end'); performance.measure('read cache', 'read cache:start', 'read cache:end');
return data ? data : false; return data ?? false;
} }
export function writeCache( export function writeCache(

View File

@ -19,7 +19,7 @@
"index": 0 "index": 0
}, },
"x-prompt": "What name would you like to use for the library?", "x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z]{1}.*$" "pattern": "^[a-zA-Z].*$"
}, },
"directory": { "directory": {
"type": "string", "type": "string",

View File

@ -174,7 +174,7 @@ function connectAngularAndNest(host: Tree, options: Schema) {
insertNgModuleImport(host, modulePath, 'HttpClientModule'); insertNgModuleImport(host, modulePath, 'HttpClientModule');
const scope = options.npmScope; const scope = options.npmScope;
const style = options.style ? options.style : 'css'; const style = options.style ?? 'css';
host.write( host.write(
`apps/${options.name}/src/app/app.component.ts`, `apps/${options.name}/src/app/app.component.ts`,
`import { Component } from '@angular/core'; `import { Component } from '@angular/core';

View File

@ -4,7 +4,7 @@
This project was generated using [Nx](https://nx.dev). This project was generated using [Nx](https://nx.dev).
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>
🔎 **Nx is a set of Extensible Dev Tools for Monorepos.** 🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
@ -96,7 +96,7 @@ Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
This project was generated using [Nx](https://nx.dev). This project was generated using [Nx](https://nx.dev).
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>
🔎 **Nx is a set of Extensible Dev Tools for Monorepos.** 🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
@ -177,7 +177,7 @@ Visit the [Nx Documentation](https://nx.dev) to learn more.
### Computation Memoization in the Cloud ### Computation Memoization in the Cloud
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-cloud-card.png"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-cloud-card.png"></p>
Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly. Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.

View File

@ -51,7 +51,7 @@ function createAppsAndLibsFolders(host: Tree, options: Schema) {
} }
function createFiles(host: Tree, options: Schema) { function createFiles(host: Tree, options: Schema) {
const npmScope = options.npmScope ? options.npmScope : options.name; const npmScope = options.npmScope ?? options.name;
const formattedNames = names(options.name); const formattedNames = names(options.name);
generateFiles(host, pathJoin(__dirname, './files'), options.directory, { generateFiles(host, pathJoin(__dirname, './files'), options.directory, {
formattedNames, formattedNames,

View File

@ -121,9 +121,7 @@ export function addLintFiles(
'@typescript-eslint/eslint-plugin': typescriptESLintVersion, '@typescript-eslint/eslint-plugin': typescriptESLintVersion,
eslint: eslintVersion, eslint: eslintVersion,
'eslint-config-prettier': eslintConfigPrettierVersion, 'eslint-config-prettier': eslintConfigPrettierVersion,
...(options.extraPackageDeps ...(options.extraPackageDeps?.devDependencies ?? {}),
? options.extraPackageDeps.devDependencies
: {}),
} }
) )
); );

View File

@ -55,7 +55,7 @@ export function renamePackageImports(packageNameMapping: PackageNameMapping) {
.forEach((projectDir) => { .forEach((projectDir) => {
projectDir.visit((file) => { projectDir.visit((file) => {
// only look at .(j|t)s(x) files // only look at .(j|t)s(x) files
if (!/(j|t)sx?$/.test(file)) { if (!/([jt])sx?$/.test(file)) {
return; return;
} }
// if it doesn't contain at least 1 reference to the packages to be renamed bail out // if it doesn't contain at least 1 reference to the packages to be renamed bail out

View File

@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be * Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
const STRING_DASHERIZE_REGEXP = /[ _\.]/g; const STRING_DASHERIZE_REGEXP = /[ _.]/g;
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g; const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g;
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;

View File

@ -1,4 +1,4 @@
<div align="center"> <div style="text-align: center;">
[![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx) [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
[![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]() [![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]()

View File

@ -14,17 +14,17 @@
<tr> <tr>
<td> <td>
<a href="https://egghead.io/playlists/scale-react-development-with-nx-4038" target="_blank"> <a href="https://egghead.io/playlists/scale-react-development-with-nx-4038" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p>
</a> </a>
</td> </td>
<td> <td>
<a href="https://www.youtube.com/watch?v=2mYLe9Kp9VM&list=PLakNactNC1dH38AfqmwabvOszDmKriGco" target="_blank"> <a href="https://www.youtube.com/watch?v=2mYLe9Kp9VM&list=PLakNactNC1dH38AfqmwabvOszDmKriGco" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p>
</a> </a>
</td> </td>
<td> <td>
<a href="https://nxplaybook.com/p/advanced-nx-workspaces" target="_blank"> <a href="https://nxplaybook.com/p/advanced-nx-workspaces" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p> <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p>
</a> </a>
</td> </td>
</tr> </tr>