@nx/workspace 17.0.5 → 17.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +4 -9
- package/migrations.json +0 -37
- package/package.json +4 -4
- package/src/generators/ci-workflow/ci-workflow.d.ts +1 -1
- package/src/generators/ci-workflow/ci-workflow.js +18 -30
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +33 -31
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +29 -35
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +53 -17
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +19 -26
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +35 -12
- package/src/generators/ci-workflow/schema.json +1 -1
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +2 -6
- package/src/generators/convert-to-monorepo/schema.json +1 -1
- package/src/generators/convert-to-nx-project/schema.json +1 -1
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +2 -7
- package/src/generators/move/lib/extract-base-configs.d.ts +1 -1
- package/src/generators/move/lib/extract-base-configs.js +10 -4
- package/src/generators/move/lib/move-project-files.js +4 -4
- package/src/generators/move/lib/normalize-schema.d.ts +1 -1
- package/src/generators/move/lib/normalize-schema.js +79 -86
- package/src/generators/move/lib/update-imports.js +1 -1
- package/src/generators/move/lib/update-jest-config.js +3 -5
- package/src/generators/move/lib/update-project-root-files.js +2 -2
- package/src/generators/move/move.js +1 -4
- package/src/generators/move/schema.json +1 -1
- package/src/generators/new/files-readme/README.md.template +23 -49
- package/src/generators/new/files-root-app/package.json__tmpl__ +0 -3
- package/src/generators/new/generate-preset.js +0 -16
- package/src/generators/new/generate-workspace-files.js +23 -36
- package/src/generators/new/new.d.ts +0 -3
- package/src/generators/new/new.js +7 -9
- package/src/generators/new/schema.json +1 -15
- package/src/generators/npm-package/schema.json +1 -1
- package/src/generators/preset/preset.js +0 -84
- package/src/generators/preset/schema.d.ts +0 -3
- package/src/generators/preset/schema.json +3 -17
- package/src/generators/remove/lib/update-jest-config.js +6 -18
- package/src/generators/remove/schema.json +1 -1
- package/src/generators/run-commands/schema.json +1 -1
- package/src/generators/utils/presets.d.ts +0 -4
- package/src/generators/utils/presets.js +1 -5
- package/src/utils/output.js +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/generators/utils/jest-config.d.ts +0 -2
- package/src/generators/utils/jest-config.js +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.maybeExtractEslintConfigIfRootProject = exports.maybeExtractJestConfigBase = exports.maybeExtractTsConfigBase = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function maybeExtractTsConfigBase(tree) {
|
|
6
6
|
let extractTsConfigBase;
|
|
@@ -26,7 +26,11 @@ async function maybeExtractJestConfigBase(tree) {
|
|
|
26
26
|
await jestInitGenerator(tree, {});
|
|
27
27
|
}
|
|
28
28
|
exports.maybeExtractJestConfigBase = maybeExtractJestConfigBase;
|
|
29
|
-
function
|
|
29
|
+
function maybeExtractEslintConfigIfRootProject(tree, rootProject) {
|
|
30
|
+
if (rootProject.root !== '.')
|
|
31
|
+
return;
|
|
32
|
+
if (tree.exists('.eslintrc.base.json'))
|
|
33
|
+
return;
|
|
30
34
|
let migrateConfigToMonorepoStyle;
|
|
31
35
|
try {
|
|
32
36
|
migrateConfigToMonorepoStyle = require('@nx/' +
|
|
@@ -35,9 +39,11 @@ function maybeMigrateEslintConfigIfRootProject(tree, rootProject) {
|
|
|
35
39
|
catch {
|
|
36
40
|
// eslint not installed
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
// Only need to handle migrating the root rootProject.
|
|
43
|
+
// If other libs/apps exist, then this migration is already done by `@nx/eslint:lint-rootProject` generator.
|
|
44
|
+
migrateConfigToMonorepoStyle?.([rootProject], tree, tree.exists((0, devkit_1.joinPathFragments)(rootProject.root, 'jest.config.ts')) ||
|
|
39
45
|
tree.exists((0, devkit_1.joinPathFragments)(rootProject.root, 'jest.config.js'))
|
|
40
46
|
? 'jest'
|
|
41
47
|
: 'none');
|
|
42
48
|
}
|
|
43
|
-
exports.
|
|
49
|
+
exports.maybeExtractEslintConfigIfRootProject = maybeExtractEslintConfigIfRootProject;
|
|
@@ -22,15 +22,15 @@ function moveProjectFiles(tree, schema, project) {
|
|
|
22
22
|
'.babelrc',
|
|
23
23
|
'.eslintrc.json',
|
|
24
24
|
'eslint.config.js',
|
|
25
|
-
/^jest\.config\.(
|
|
25
|
+
/^jest\.config\.(app|lib)\.[jt]s$/,
|
|
26
26
|
'vite.config.ts',
|
|
27
27
|
/^webpack.*\.js$/,
|
|
28
28
|
'index.html', // Vite
|
|
29
29
|
];
|
|
30
30
|
const knownRootProjectFolders = [
|
|
31
|
-
'src',
|
|
32
|
-
'app',
|
|
33
|
-
'pages',
|
|
31
|
+
'src',
|
|
32
|
+
'app',
|
|
33
|
+
'pages',
|
|
34
34
|
'public', // Vite, Remix, Next.js
|
|
35
35
|
];
|
|
36
36
|
const isKnownRootProjectFile = (file) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
import type { NormalizedSchema, Schema } from '../schema';
|
|
3
3
|
export declare function normalizeSchema(tree: Tree, schema: Schema, projectConfiguration: ProjectConfiguration): Promise<NormalizedSchema>;
|
|
@@ -17,16 +17,10 @@ async function normalizeSchema(tree, schema, projectConfiguration) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.normalizeSchema = normalizeSchema;
|
|
19
19
|
async function determineProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
|
20
|
-
if (!options.projectNameAndRootFormat &&
|
|
21
|
-
(process.env.NX_INTERACTIVE !== 'true' || !isTTY())) {
|
|
22
|
-
options.projectNameAndRootFormat = 'derived';
|
|
23
|
-
}
|
|
24
20
|
validateName(options.newProjectName, options.projectNameAndRootFormat, projectConfiguration);
|
|
25
21
|
const formats = getProjectNameAndRootFormats(tree, options, projectConfiguration);
|
|
26
|
-
const format = options.projectNameAndRootFormat ??
|
|
27
|
-
|
|
28
|
-
logDeprecationMessage(formats, options);
|
|
29
|
-
}
|
|
22
|
+
const format = options.projectNameAndRootFormat ??
|
|
23
|
+
(await determineFormat(tree, formats, options));
|
|
30
24
|
return formats[format];
|
|
31
25
|
}
|
|
32
26
|
function validateName(name, projectNameAndRootFormat, projectConfiguration) {
|
|
@@ -61,47 +55,65 @@ function validateName(name, projectNameAndRootFormat, projectConfiguration) {
|
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
|
-
function getProjectNameAndRootFormats(tree,
|
|
65
|
-
let destination = (0, utils_1.normalizePathSlashes)(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const asProvidedOptions = getAsProvidedOptions(tree, { ...options, destination }, projectConfiguration);
|
|
73
|
-
if (options.projectNameAndRootFormat === 'as-provided') {
|
|
58
|
+
function getProjectNameAndRootFormats(tree, schema, projectConfiguration) {
|
|
59
|
+
let destination = (0, utils_1.normalizePathSlashes)(schema.destination);
|
|
60
|
+
const normalizedNewProjectName = schema.newProjectName
|
|
61
|
+
? (0, devkit_1.names)(schema.newProjectName).fileName
|
|
62
|
+
: undefined;
|
|
63
|
+
const asProvidedProjectName = normalizedNewProjectName ?? schema.projectName;
|
|
64
|
+
const asProvidedDestination = destination;
|
|
65
|
+
if (normalizedNewProjectName?.startsWith('@')) {
|
|
74
66
|
return {
|
|
75
|
-
'as-provided':
|
|
76
|
-
|
|
67
|
+
'as-provided': {
|
|
68
|
+
destination: asProvidedDestination,
|
|
69
|
+
importPath: schema.importPath ??
|
|
70
|
+
// keep the existing import path if the name didn't change
|
|
71
|
+
(normalizedNewProjectName &&
|
|
72
|
+
schema.projectName !== normalizedNewProjectName
|
|
73
|
+
? asProvidedProjectName
|
|
74
|
+
: undefined),
|
|
75
|
+
newProjectName: asProvidedProjectName,
|
|
76
|
+
},
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
let npmScope;
|
|
80
|
+
let asProvidedImportPath = schema.importPath;
|
|
81
|
+
if (!asProvidedImportPath &&
|
|
82
|
+
schema.newProjectName &&
|
|
83
|
+
projectConfiguration.projectType === 'library') {
|
|
84
|
+
npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
|
85
|
+
asProvidedImportPath = npmScope
|
|
86
|
+
? `${npmScope === '@' ? '' : '@'}${npmScope}/${asProvidedProjectName}`
|
|
87
|
+
: asProvidedProjectName;
|
|
88
|
+
}
|
|
89
|
+
const derivedProjectName = schema.newProjectName ?? (0, utils_1.getNewProjectName)(destination);
|
|
90
|
+
const derivedDestination = (0, utils_1.getDestination)(tree, schema, projectConfiguration);
|
|
91
|
+
let derivedImportPath;
|
|
92
|
+
if (projectConfiguration.projectType === 'library') {
|
|
93
|
+
derivedImportPath =
|
|
94
|
+
schema.importPath ??
|
|
95
|
+
(0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, destination));
|
|
94
96
|
}
|
|
95
|
-
const derivedOptions = getDerivedOptions(tree, { ...options, destination }, projectConfiguration);
|
|
96
97
|
return {
|
|
97
|
-
'as-provided':
|
|
98
|
-
|
|
98
|
+
'as-provided': {
|
|
99
|
+
destination: asProvidedDestination,
|
|
100
|
+
newProjectName: asProvidedProjectName,
|
|
101
|
+
importPath: asProvidedImportPath,
|
|
102
|
+
},
|
|
103
|
+
derived: {
|
|
104
|
+
destination: derivedDestination,
|
|
105
|
+
newProjectName: derivedProjectName,
|
|
106
|
+
importPath: derivedImportPath,
|
|
107
|
+
},
|
|
99
108
|
};
|
|
100
109
|
}
|
|
101
|
-
async function determineFormat(formats) {
|
|
110
|
+
async function determineFormat(tree, formats, schema) {
|
|
102
111
|
if (!formats.derived) {
|
|
103
112
|
return 'as-provided';
|
|
104
113
|
}
|
|
114
|
+
if (process.env.NX_INTERACTIVE !== 'true' || !isTTY()) {
|
|
115
|
+
return 'derived';
|
|
116
|
+
}
|
|
105
117
|
const asProvidedDescription = `As provided:
|
|
106
118
|
Name: ${formats['as-provided'].newProjectName}
|
|
107
119
|
Destination: ${formats['as-provided'].destination}`;
|
|
@@ -124,59 +136,40 @@ async function determineFormat(formats) {
|
|
|
124
136
|
name: derivedSelectedValue,
|
|
125
137
|
},
|
|
126
138
|
],
|
|
127
|
-
initial:
|
|
139
|
+
initial: 'as-provided',
|
|
128
140
|
}).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
function logDeprecationMessage(formats, options) {
|
|
132
141
|
const callingGenerator = process.env.NX_ANGULAR_MOVE_INVOKED === 'true'
|
|
133
142
|
? '@nx/angular:move'
|
|
134
143
|
: '@nx/workspace:move';
|
|
135
|
-
|
|
136
|
-
In Nx
|
|
137
|
-
Please provide the exact new project name and destination in the future
|
|
138
|
-
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
importPath =
|
|
156
|
-
options.newProjectName && options.projectName !== options.newProjectName
|
|
157
|
-
? newProjectName
|
|
158
|
-
: undefined;
|
|
159
|
-
}
|
|
160
|
-
else if (options.newProjectName) {
|
|
161
|
-
const npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
|
162
|
-
importPath = npmScope
|
|
163
|
-
? `${npmScope === '@' ? '' : '@'}${npmScope}/${newProjectName}`
|
|
164
|
-
: newProjectName;
|
|
144
|
+
const deprecationWarning = (0, devkit_1.stripIndents) `
|
|
145
|
+
In Nx 18, the project name and destination will no longer be derived.
|
|
146
|
+
Please provide the exact new project name and destination in the future.`;
|
|
147
|
+
if (result === 'as-provided') {
|
|
148
|
+
const { saveDefault } = await (0, enquirer_1.prompt)({
|
|
149
|
+
type: 'confirm',
|
|
150
|
+
message: `Would you like to configure Nx to always take the project name and destination as provided for ${callingGenerator}?`,
|
|
151
|
+
name: 'saveDefault',
|
|
152
|
+
initial: true,
|
|
153
|
+
});
|
|
154
|
+
if (saveDefault) {
|
|
155
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
156
|
+
nxJson.generators ??= {};
|
|
157
|
+
nxJson.generators[callingGenerator] ??= {};
|
|
158
|
+
nxJson.generators[callingGenerator].projectNameAndRootFormat = result;
|
|
159
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
devkit_1.logger.warn(deprecationWarning);
|
|
163
|
+
}
|
|
165
164
|
}
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const destination = (0, utils_1.getDestination)(tree, options, projectConfiguration);
|
|
173
|
-
let importPath;
|
|
174
|
-
if (projectConfiguration.projectType === 'library') {
|
|
175
|
-
importPath =
|
|
176
|
-
options.importPath ??
|
|
177
|
-
(0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, options.destination));
|
|
165
|
+
else {
|
|
166
|
+
const example = `Example: nx g ${callingGenerator} --projectName ${schema.projectName} --destination ${formats[result].destination}` +
|
|
167
|
+
(schema.projectName !== formats[result].newProjectName
|
|
168
|
+
? ` --newProjectName ${formats[result].newProjectName}`
|
|
169
|
+
: '');
|
|
170
|
+
devkit_1.logger.warn(deprecationWarning + '\n' + example);
|
|
178
171
|
}
|
|
179
|
-
return
|
|
172
|
+
return result;
|
|
180
173
|
}
|
|
181
174
|
function isTTY() {
|
|
182
175
|
return !!process.stdout.isTTY && process.env['CI'] !== 'true';
|
|
@@ -124,7 +124,7 @@ function updateImportDeclarations(sourceFile, from, to) {
|
|
|
124
124
|
]);
|
|
125
125
|
const changes = [];
|
|
126
126
|
for (const { moduleSpecifier } of importDecls) {
|
|
127
|
-
if (
|
|
127
|
+
if (tsModule.isStringLiteral(moduleSpecifier)) {
|
|
128
128
|
changes.push(...updateModuleSpecifier(moduleSpecifier, from, to));
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateJestConfig = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const jest_config_1 = require("../../utils/jest-config");
|
|
6
5
|
/**
|
|
7
6
|
* Updates the project name and coverage folder in the jest.config.js if it exists
|
|
8
7
|
*
|
|
@@ -35,14 +34,13 @@ function updateJestConfig(tree, schema, project) {
|
|
|
35
34
|
tree.write(jestConfigPath, newContent);
|
|
36
35
|
}
|
|
37
36
|
// update root jest.config.ts
|
|
38
|
-
const rootJestConfigPath =
|
|
39
|
-
if (!
|
|
37
|
+
const rootJestConfigPath = '/jest.config.ts';
|
|
38
|
+
if (!tree.exists(rootJestConfigPath)) {
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
41
|
const findProject = `'<rootDir>/${project.root}'`;
|
|
43
42
|
const oldRootJestConfigContent = tree.read(rootJestConfigPath, 'utf-8');
|
|
44
|
-
const usingJestProjects = oldRootJestConfigContent.includes('getJestProjects()')
|
|
45
|
-
oldRootJestConfigContent.includes('getJestProjectsAsync()');
|
|
43
|
+
const usingJestProjects = oldRootJestConfigContent.includes('getJestProjects()');
|
|
46
44
|
const newRootJestConfigContent = oldRootJestConfigContent.replace(findProject, usingJestProjects ? `` : `'<rootDir>/${schema.relativeToRootDestination}'`);
|
|
47
45
|
tree.write(rootJestConfigPath, newRootJestConfigContent);
|
|
48
46
|
}
|
|
@@ -57,7 +57,7 @@ function updateFilesForNonRootProjects(tree, schema, project) {
|
|
|
57
57
|
const newRelativeRoot = path
|
|
58
58
|
.relative(path.join(devkit_1.workspaceRoot, schema.relativeToRootDestination), devkit_1.workspaceRoot)
|
|
59
59
|
.split(path.sep)
|
|
60
|
-
.join('/')
|
|
60
|
+
.join('/');
|
|
61
61
|
const oldRelativeRoot = path
|
|
62
62
|
.relative(path.join(devkit_1.workspaceRoot, project.root), devkit_1.workspaceRoot)
|
|
63
63
|
.split(path.sep)
|
|
@@ -67,7 +67,7 @@ function updateFilesForNonRootProjects(tree, schema, project) {
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
const dots = /\./g;
|
|
70
|
-
const regex = new RegExp(`(?<!\\.\\.\\/)${oldRelativeRoot.replace(dots, '\\.')}
|
|
70
|
+
const regex = new RegExp(`(?<!\\.\\.\\/)${oldRelativeRoot.replace(dots, '\\.')}(?!\\/\\.\\.)`, 'g');
|
|
71
71
|
for (const file of tree.children(schema.relativeToRootDestination)) {
|
|
72
72
|
const ext = (0, path_1.extname)(file);
|
|
73
73
|
if (!allowedExt.includes(ext)) {
|
|
@@ -33,6 +33,7 @@ async function moveGeneratorInternal(tree, rawSchema) {
|
|
|
33
33
|
if (projectConfig.root === '.') {
|
|
34
34
|
(0, extract_base_configs_1.maybeExtractTsConfigBase)(tree);
|
|
35
35
|
await (0, extract_base_configs_1.maybeExtractJestConfigBase)(tree);
|
|
36
|
+
(0, extract_base_configs_1.maybeExtractEslintConfigIfRootProject)(tree, projectConfig);
|
|
36
37
|
// Reload config since it has been updated after extracting base configs
|
|
37
38
|
projectConfig = (0, devkit_1.readProjectConfiguration)(tree, rawSchema.projectName);
|
|
38
39
|
}
|
|
@@ -50,10 +51,6 @@ async function moveGeneratorInternal(tree, rawSchema) {
|
|
|
50
51
|
(0, update_build_targets_1.updateBuildTargets)(tree, schema);
|
|
51
52
|
(0, update_default_project_1.updateDefaultProject)(tree, schema);
|
|
52
53
|
(0, update_implicit_dependencies_1.updateImplicitDependencies)(tree, schema);
|
|
53
|
-
if (projectConfig.root === '.') {
|
|
54
|
-
// we want to migrate eslint config once the root project files are moved
|
|
55
|
-
(0, extract_base_configs_1.maybeMigrateEslintConfigIfRootProject)(tree, projectConfig);
|
|
56
|
-
}
|
|
57
54
|
await (0, run_angular_plugin_1.runAngularPlugin)(tree, schema);
|
|
58
55
|
if (!schema.skipFormat) {
|
|
59
56
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -2,85 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
|
|
4
4
|
|
|
5
|
-
✨ **This workspace has been generated by [Nx, Smart
|
|
5
|
+
✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨<% if (!!appName) { %>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<% if (includeServe) { %>
|
|
8
|
+
## Start the app
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
comes with a LSP for Vim users.
|
|
12
|
-
<% if (!!appName) {
|
|
13
|
-
if (isJsStandalone) { %>
|
|
14
|
-
## Build the library
|
|
15
|
-
|
|
16
|
-
Run `npx nx build` to build the library. The build artifacts are stored in the output directory (i.e. `dist/`), ready to be published.
|
|
17
|
-
<% } else { %>
|
|
18
|
-
## Start the application
|
|
19
|
-
|
|
20
|
-
Run `npx nx <%= serveCommand %> <%= appName %>` to start the development server. Happy coding!
|
|
21
|
-
|
|
22
|
-
## Build for production
|
|
23
|
-
|
|
24
|
-
Run `npx nx build <%= appName %>` to build the application. The build artifacts are stored in the output directory (e.g. `dist/` or `build/`), ready to be deployed.
|
|
25
|
-
<% } } else { %>
|
|
26
|
-
## Nx plugins and code generators
|
|
27
|
-
|
|
28
|
-
Add Nx plugins to leverage their code generators and automated, inferred tasks.
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
# Add plugin
|
|
32
|
-
npx nx add @nx/react
|
|
10
|
+
To start the development server run `nx serve <%= appName %>`. Open your browser and navigate to http://localhost:4200/. Happy coding!<% } %>
|
|
11
|
+
<% } %>
|
|
33
12
|
|
|
34
|
-
|
|
35
|
-
npx nx generate @nx/react:app demo
|
|
13
|
+
## Generate code
|
|
36
14
|
|
|
37
|
-
|
|
38
|
-
npx nx serve demo
|
|
15
|
+
If you happen to use Nx plugins, you can leverage code generators that might come with it.
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
npx nx show project demo --web
|
|
42
|
-
```
|
|
17
|
+
Run `nx list` to get a list of available plugins and whether they have generators. Then run `nx list <plugin-name>` to see what generators are available.
|
|
43
18
|
|
|
44
|
-
|
|
19
|
+
Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators).
|
|
45
20
|
|
|
46
|
-
Learn more about [code generators](https://nx.dev/features/generate-code) and [inferred tasks](https://nx.dev/concepts/inferred-tasks) in the docs.
|
|
47
|
-
<% } %>
|
|
48
21
|
## Running tasks
|
|
49
22
|
|
|
50
23
|
To execute tasks with Nx use the following syntax:
|
|
51
24
|
|
|
52
25
|
```
|
|
53
|
-
|
|
26
|
+
nx <target> <project> <...options>
|
|
54
27
|
```
|
|
55
28
|
|
|
56
29
|
You can also run multiple targets:
|
|
57
30
|
|
|
58
31
|
```
|
|
59
|
-
|
|
32
|
+
nx run-many -t <target1> <target2>
|
|
60
33
|
```
|
|
61
34
|
|
|
62
35
|
..or add `-p` to filter specific projects
|
|
63
36
|
|
|
64
37
|
```
|
|
65
|
-
|
|
38
|
+
nx run-many -t <target1> <target2> -p <proj1> <proj2>
|
|
66
39
|
```
|
|
67
40
|
|
|
68
|
-
Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/features/run-tasks).
|
|
41
|
+
Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).
|
|
69
42
|
|
|
70
|
-
##
|
|
43
|
+
## Want better Editor Integration?
|
|
71
44
|
|
|
72
|
-
|
|
45
|
+
Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.
|
|
73
46
|
|
|
74
|
-
|
|
75
|
-
- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution)
|
|
76
|
-
- [Learn more how to setup CI](https://nx.dev/recipes/ci)
|
|
47
|
+
## Ready to deploy?
|
|
77
48
|
|
|
78
|
-
|
|
49
|
+
Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed.
|
|
79
50
|
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
## Set up CI!
|
|
52
|
+
|
|
53
|
+
Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further.
|
|
82
54
|
|
|
83
|
-
- [
|
|
55
|
+
- [Set up remote caching](https://nx.dev/core-features/share-your-cache)
|
|
56
|
+
- [Set up task distribution across multiple machines](https://nx.dev/core-features/distribute-task-execution)
|
|
57
|
+
- [Learn more how to setup CI](https://nx.dev/recipes/ci)
|
|
84
58
|
|
|
85
59
|
## Connect with us!
|
|
86
60
|
|
|
@@ -56,7 +56,6 @@ function generatePreset(host, opts) {
|
|
|
56
56
|
opts.docker ? `--docker=${opts.docker}` : null,
|
|
57
57
|
opts.js ? `--js` : null,
|
|
58
58
|
opts.nextAppDir ? '--nextAppDir=true' : '--nextAppDir=false',
|
|
59
|
-
opts.nextSrcDir ? '--nextSrcDir=true' : '--nextSrcDir=false',
|
|
60
59
|
opts.packageManager ? `--packageManager=${opts.packageManager}` : null,
|
|
61
60
|
opts.standaloneApi !== undefined
|
|
62
61
|
? `--standaloneApi=${opts.standaloneApi}`
|
|
@@ -66,8 +65,6 @@ function generatePreset(host, opts) {
|
|
|
66
65
|
opts.e2eTestRunner !== undefined
|
|
67
66
|
? `--e2eTestRunner=${opts.e2eTestRunner}`
|
|
68
67
|
: null,
|
|
69
|
-
opts.ssr ? `--ssr` : null,
|
|
70
|
-
opts.prefix !== undefined ? `--prefix=${opts.prefix}` : null,
|
|
71
68
|
].filter((e) => !!e);
|
|
72
69
|
}
|
|
73
70
|
}
|
|
@@ -98,9 +95,6 @@ function getPresetDependencies({ preset, presetVersion, bundler, e2eTestRunner,
|
|
|
98
95
|
case presets_1.Preset.NextJs:
|
|
99
96
|
case presets_1.Preset.NextJsStandalone:
|
|
100
97
|
return { dependencies: { '@nx/next': versions_1.nxVersion }, dev: {} };
|
|
101
|
-
case presets_1.Preset.RemixStandalone:
|
|
102
|
-
case presets_1.Preset.RemixMonorepo:
|
|
103
|
-
return { dependencies: { '@nx/remix': versions_1.nxVersion }, dev: {} };
|
|
104
98
|
case presets_1.Preset.VueMonorepo:
|
|
105
99
|
case presets_1.Preset.VueStandalone:
|
|
106
100
|
return {
|
|
@@ -112,16 +106,6 @@ function getPresetDependencies({ preset, presetVersion, bundler, e2eTestRunner,
|
|
|
112
106
|
'@nx/vite': versions_1.nxVersion,
|
|
113
107
|
},
|
|
114
108
|
};
|
|
115
|
-
case presets_1.Preset.Nuxt:
|
|
116
|
-
case presets_1.Preset.NuxtStandalone:
|
|
117
|
-
return {
|
|
118
|
-
dependencies: {},
|
|
119
|
-
dev: {
|
|
120
|
-
'@nx/nuxt': versions_1.nxVersion,
|
|
121
|
-
'@nx/cypress': e2eTestRunner === 'cypress' ? versions_1.nxVersion : undefined,
|
|
122
|
-
'@nx/playwright': e2eTestRunner === 'playwright' ? versions_1.nxVersion : undefined,
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
109
|
case presets_1.Preset.ReactMonorepo:
|
|
126
110
|
case presets_1.Preset.ReactStandalone:
|
|
127
111
|
return {
|
|
@@ -45,21 +45,27 @@ function setPresetProperty(tree, options) {
|
|
|
45
45
|
function createNxJson(tree, { directory, defaultBase, preset }) {
|
|
46
46
|
const nxJson = {
|
|
47
47
|
$schema: './node_modules/nx/schemas/nx-schema.json',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
:
|
|
48
|
+
affected: {
|
|
49
|
+
defaultBase,
|
|
50
|
+
},
|
|
51
|
+
targetDefaults: {
|
|
52
|
+
build: {
|
|
53
|
+
cache: true,
|
|
54
|
+
dependsOn: ['^build'],
|
|
55
|
+
},
|
|
56
|
+
lint: {
|
|
57
|
+
cache: true,
|
|
58
|
+
},
|
|
59
|
+
test: {
|
|
60
|
+
cache: true,
|
|
61
|
+
},
|
|
62
|
+
e2e: {
|
|
63
|
+
cache: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
60
66
|
};
|
|
61
67
|
if (defaultBase === 'main') {
|
|
62
|
-
delete nxJson.
|
|
68
|
+
delete nxJson.affected;
|
|
63
69
|
}
|
|
64
70
|
if (preset !== presets_1.Preset.NPM) {
|
|
65
71
|
nxJson.namedInputs = {
|
|
@@ -67,10 +73,7 @@ function createNxJson(tree, { directory, defaultBase, preset }) {
|
|
|
67
73
|
production: ['default'],
|
|
68
74
|
sharedGlobals: [],
|
|
69
75
|
};
|
|
70
|
-
|
|
71
|
-
nxJson.targetDefaults.build.inputs = ['production', '^production'];
|
|
72
|
-
nxJson.useInferencePlugins = false;
|
|
73
|
-
}
|
|
76
|
+
nxJson.targetDefaults.build.inputs = ['production', '^production'];
|
|
74
77
|
}
|
|
75
78
|
(0, devkit_1.writeJson)(tree, (0, path_1.join)(directory, 'nx.json'), nxJson);
|
|
76
79
|
}
|
|
@@ -79,10 +82,8 @@ function createFiles(tree, options) {
|
|
|
79
82
|
const filesDirName = options.preset === presets_1.Preset.AngularStandalone ||
|
|
80
83
|
options.preset === presets_1.Preset.ReactStandalone ||
|
|
81
84
|
options.preset === presets_1.Preset.VueStandalone ||
|
|
82
|
-
options.preset === presets_1.Preset.NuxtStandalone ||
|
|
83
85
|
options.preset === presets_1.Preset.NodeStandalone ||
|
|
84
86
|
options.preset === presets_1.Preset.NextJsStandalone ||
|
|
85
|
-
options.preset === presets_1.Preset.RemixStandalone ||
|
|
86
87
|
options.preset === presets_1.Preset.TsStandalone
|
|
87
88
|
? './files-root-app'
|
|
88
89
|
: options.preset === presets_1.Preset.NPM
|
|
@@ -103,11 +104,8 @@ function createReadme(tree, { name, appName, directory, preset }) {
|
|
|
103
104
|
const formattedNames = (0, devkit_1.names)(name);
|
|
104
105
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files-readme'), directory, {
|
|
105
106
|
formattedNames,
|
|
106
|
-
|
|
107
|
+
includeServe: preset !== presets_1.Preset.TsStandalone,
|
|
107
108
|
appName,
|
|
108
|
-
serveCommand: preset === presets_1.Preset.NextJs || preset === presets_1.Preset.NextJsStandalone
|
|
109
|
-
? 'dev'
|
|
110
|
-
: 'serve',
|
|
111
109
|
name,
|
|
112
110
|
});
|
|
113
111
|
}
|
|
@@ -123,8 +121,8 @@ function addNpmScripts(tree, options) {
|
|
|
123
121
|
if (options.preset === presets_1.Preset.AngularStandalone ||
|
|
124
122
|
options.preset === presets_1.Preset.ReactStandalone ||
|
|
125
123
|
options.preset === presets_1.Preset.VueStandalone ||
|
|
126
|
-
options.preset === presets_1.Preset.
|
|
127
|
-
options.preset === presets_1.Preset.
|
|
124
|
+
options.preset === presets_1.Preset.NodeStandalone ||
|
|
125
|
+
options.preset === presets_1.Preset.NextJsStandalone) {
|
|
128
126
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'package.json'), (json) => {
|
|
129
127
|
Object.assign(json.scripts, {
|
|
130
128
|
start: 'nx serve',
|
|
@@ -134,17 +132,6 @@ function addNpmScripts(tree, options) {
|
|
|
134
132
|
return json;
|
|
135
133
|
});
|
|
136
134
|
}
|
|
137
|
-
if (options.preset === presets_1.Preset.NextJsStandalone) {
|
|
138
|
-
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'package.json'), (json) => {
|
|
139
|
-
Object.assign(json.scripts, {
|
|
140
|
-
dev: 'nx dev',
|
|
141
|
-
build: 'nx build',
|
|
142
|
-
start: 'nx start',
|
|
143
|
-
test: 'nx test',
|
|
144
|
-
});
|
|
145
|
-
return json;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
135
|
if (options.preset === presets_1.Preset.TsStandalone) {
|
|
149
136
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'package.json'), (json) => {
|
|
150
137
|
Object.assign(json.scripts, {
|
|
@@ -12,15 +12,12 @@ interface Schema {
|
|
|
12
12
|
docker?: boolean;
|
|
13
13
|
js?: boolean;
|
|
14
14
|
nextAppDir?: boolean;
|
|
15
|
-
nextSrcDir?: boolean;
|
|
16
15
|
linter?: Linter;
|
|
17
16
|
bundler?: 'vite' | 'webpack';
|
|
18
17
|
standaloneApi?: boolean;
|
|
19
18
|
routing?: boolean;
|
|
20
19
|
packageManager?: PackageManager;
|
|
21
20
|
e2eTestRunner?: 'cypress' | 'playwright' | 'detox' | 'jest' | 'none';
|
|
22
|
-
ssr?: boolean;
|
|
23
|
-
prefix?: string;
|
|
24
21
|
}
|
|
25
22
|
export interface NormalizedSchema extends Schema {
|
|
26
23
|
presetVersion?: string;
|