@nx/devkit 16.7.1 → 16.8.0-beta.0
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/package.json +3 -3
- package/src/executors/parse-target-string.js +4 -4
- package/src/executors/read-target-options.js +5 -4
- package/src/generators/format-files.js +5 -4
- package/src/generators/project-name-and-root-utils.d.ts +4 -1
- package/src/generators/project-name-and-root-utils.js +29 -10
- package/src/utils/convert-nx-executor.js +1 -1
- package/src/utils/invoke-nx-generator.js +4 -4
- package/src/utils/module-federation/secondary-entry-points.js +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/devkit",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.8.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more.",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://nx.dev",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nrwl/devkit": "16.
|
|
31
|
+
"@nrwl/devkit": "16.8.0-beta.0",
|
|
32
32
|
"ejs": "^3.1.7",
|
|
33
33
|
"enquirer": "~2.3.6",
|
|
34
34
|
"ignore": "^5.0.4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"migrations": "./migrations.json"
|
|
47
47
|
},
|
|
48
48
|
"type": "commonjs",
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "818352404283c1d34ab303d91b3bd16474f54916"
|
|
50
50
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.targetToTargetString = exports.parseTargetString = void 0;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
5
|
-
const split_target_1 = require("nx/src/utils/split-target");
|
|
6
4
|
const nx_1 = require("../../nx");
|
|
7
|
-
|
|
5
|
+
let { readCachedProjectGraph, splitTarget } = (0, nx_1.requireNx)();
|
|
6
|
+
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
7
|
+
splitTarget = splitTarget !== null && splitTarget !== void 0 ? splitTarget : require('nx/src/utils/split-target').splitTarget;
|
|
8
8
|
function parseTargetString(targetString, projectGraph) {
|
|
9
9
|
if (!projectGraph) {
|
|
10
10
|
try {
|
|
@@ -14,7 +14,7 @@ function parseTargetString(targetString, projectGraph) {
|
|
|
14
14
|
projectGraph = { nodes: {} };
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
const [project, target, configuration] =
|
|
17
|
+
const [project, target, configuration] = splitTarget(targetString, projectGraph);
|
|
18
18
|
if (!project || !target) {
|
|
19
19
|
throw new Error(`Invalid Target String: ${targetString}`);
|
|
20
20
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readTargetOptions = void 0;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
5
|
-
const params_1 = require("nx/src/utils/params");
|
|
6
4
|
const nx_1 = require("../../nx");
|
|
7
5
|
const path_1 = require("path");
|
|
8
|
-
|
|
6
|
+
let { Workspaces, getExecutorInformation, calculateDefaultProjectName, combineOptionsForExecutor, } = (0, nx_1.requireNx)();
|
|
7
|
+
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
8
|
+
combineOptionsForExecutor =
|
|
9
|
+
combineOptionsForExecutor !== null && combineOptionsForExecutor !== void 0 ? combineOptionsForExecutor : require('nx/src/utils/params').combineOptionsForExecutor;
|
|
9
10
|
/**
|
|
10
11
|
* Reads and combines options for a given target.
|
|
11
12
|
*
|
|
@@ -26,6 +27,6 @@ function readTargetOptions({ project, target, configuration }, context) {
|
|
|
26
27
|
? calculateDefaultProjectName(context.cwd, context.root, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration)
|
|
27
28
|
: // TODO(v18): remove calculateDefaultProjectName. This is to be backwards compatible with Nx 16.5 and below.
|
|
28
29
|
ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
|
|
29
|
-
return
|
|
30
|
+
return combineOptionsForExecutor({}, (_a = configuration !== null && configuration !== void 0 ? configuration : targetConfiguration.defaultConfiguration) !== null && _a !== void 0 ? _a : '', targetConfiguration, schema, defaultProject, (0, path_1.relative)(context.cwd, context.root));
|
|
30
31
|
}
|
|
31
32
|
exports.readTargetOptions = readTargetOptions;
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.formatFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
|
-
const object_sort_1 = require("nx/src/utils/object-sort");
|
|
8
6
|
const nx_1 = require("../../nx");
|
|
9
|
-
|
|
7
|
+
let { updateJson, readJson, sortObjectByKeys } = (0, nx_1.requireNx)();
|
|
8
|
+
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
9
|
+
sortObjectByKeys =
|
|
10
|
+
sortObjectByKeys !== null && sortObjectByKeys !== void 0 ? sortObjectByKeys : require('nx/src/utils/object-sort').sortObjectByKeys;
|
|
10
11
|
/**
|
|
11
12
|
* Formats all the created or updated files using Prettier
|
|
12
13
|
* @param tree - the file system tree
|
|
@@ -52,7 +53,7 @@ function sortTsConfig(tree) {
|
|
|
52
53
|
if (!tsConfigPath) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
updateJson(tree, tsConfigPath, (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { paths:
|
|
56
|
+
updateJson(tree, tsConfigPath, (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { paths: sortObjectByKeys(tsconfig.compilerOptions.paths) }) })));
|
|
56
57
|
}
|
|
57
58
|
catch (e) {
|
|
58
59
|
// catch noop
|
|
@@ -4,6 +4,7 @@ export type ProjectNameAndRootFormat = 'as-provided' | 'derived';
|
|
|
4
4
|
export type ProjectGenerationOptions = {
|
|
5
5
|
name: string;
|
|
6
6
|
projectType: ProjectType;
|
|
7
|
+
callingGenerator: string;
|
|
7
8
|
directory?: string;
|
|
8
9
|
importPath?: string;
|
|
9
10
|
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
@@ -37,4 +38,6 @@ export type ProjectNameAndRootOptions = {
|
|
|
37
38
|
*/
|
|
38
39
|
importPath?: string;
|
|
39
40
|
};
|
|
40
|
-
export declare function determineProjectNameAndRootOptions(tree: Tree, options: ProjectGenerationOptions): Promise<ProjectNameAndRootOptions
|
|
41
|
+
export declare function determineProjectNameAndRootOptions(tree: Tree, options: ProjectGenerationOptions): Promise<ProjectNameAndRootOptions & {
|
|
42
|
+
projectNameAndRootFormat: ProjectNameAndRootFormat;
|
|
43
|
+
}>;
|
|
@@ -6,14 +6,14 @@ const enquirer_1 = require("enquirer");
|
|
|
6
6
|
const nx_1 = require("../../nx");
|
|
7
7
|
const get_workspace_layout_1 = require("../utils/get-workspace-layout");
|
|
8
8
|
const names_1 = require("../utils/names");
|
|
9
|
-
const { joinPathFragments, readJson, readNxJson } = (0, nx_1.requireNx)();
|
|
9
|
+
const { joinPathFragments, normalizePath, readJson, readNxJson, updateNxJson } = (0, nx_1.requireNx)();
|
|
10
10
|
function determineProjectNameAndRootOptions(tree, options) {
|
|
11
11
|
var _a;
|
|
12
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
validateName(options.name, options.projectNameAndRootFormat);
|
|
14
14
|
const formats = getProjectNameAndRootFormats(tree, options);
|
|
15
|
-
const format = (_a = options.projectNameAndRootFormat) !== null && _a !== void 0 ? _a : (yield determineFormat(formats));
|
|
16
|
-
return formats[format];
|
|
15
|
+
const format = (_a = options.projectNameAndRootFormat) !== null && _a !== void 0 ? _a : (yield determineFormat(tree, formats, options.callingGenerator));
|
|
16
|
+
return Object.assign(Object.assign({}, formats[format]), { projectNameAndRootFormat: format });
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
exports.determineProjectNameAndRootOptions = determineProjectNameAndRootOptions;
|
|
@@ -37,7 +37,9 @@ function validateName(name, projectNameAndRootFormat) {
|
|
|
37
37
|
throw new Error(`The project name should match the pattern "${pattern}". The provided value "${name}" does not match.`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function determineFormat(formats) {
|
|
40
|
+
function determineFormat(tree, formats, callingGenerator) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
var _c;
|
|
41
43
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
44
|
if (!formats.derived) {
|
|
43
45
|
return 'as-provided';
|
|
@@ -53,7 +55,7 @@ function determineFormat(formats) {
|
|
|
53
55
|
Name: ${formats['derived'].projectName}
|
|
54
56
|
Root: ${formats['derived'].projectRoot}`;
|
|
55
57
|
const derivedSelectedValue = `${formats['derived'].projectName} @ ${formats['derived'].projectRoot} (This was derived from the folder structure. Please provide the exact name and directory in the future)`;
|
|
56
|
-
|
|
58
|
+
const result = yield (0, enquirer_1.prompt)({
|
|
57
59
|
type: 'select',
|
|
58
60
|
name: 'format',
|
|
59
61
|
message: 'What should be the project name and where should it be generated?',
|
|
@@ -69,12 +71,29 @@ function determineFormat(formats) {
|
|
|
69
71
|
],
|
|
70
72
|
initial: 'as-provided',
|
|
71
73
|
}).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
|
|
74
|
+
if (result === 'as-provided' && callingGenerator) {
|
|
75
|
+
const { saveDefault } = yield (0, enquirer_1.prompt)({
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
message: 'Would you like to save this layout as a default?',
|
|
78
|
+
name: 'saveDefault',
|
|
79
|
+
});
|
|
80
|
+
if (saveDefault) {
|
|
81
|
+
const nxJson = readNxJson(tree);
|
|
82
|
+
(_a = nxJson.generators) !== null && _a !== void 0 ? _a : (nxJson.generators = {});
|
|
83
|
+
(_b = (_c = nxJson.generators)[callingGenerator]) !== null && _b !== void 0 ? _b : (_c[callingGenerator] = {});
|
|
84
|
+
nxJson.generators[callingGenerator].projectNameAndRootFormat = result;
|
|
85
|
+
updateNxJson(tree, nxJson);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
72
89
|
});
|
|
73
90
|
}
|
|
74
91
|
function getProjectNameAndRootFormats(tree, options) {
|
|
75
|
-
var _a, _b, _c
|
|
92
|
+
var _a, _b, _c;
|
|
76
93
|
const name = (0, names_1.names)(options.name).fileName;
|
|
77
|
-
const directory =
|
|
94
|
+
const directory = options.directory
|
|
95
|
+
? normalizePath(options.directory.replace(/^\.?\//, ''))
|
|
96
|
+
: undefined;
|
|
78
97
|
const asProvidedProjectName = name;
|
|
79
98
|
const asProvidedProjectDirectory = directory
|
|
80
99
|
? (0, names_1.names)(directory).fileName
|
|
@@ -90,7 +109,7 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
90
109
|
projectSimpleName: nameWithoutScope,
|
|
91
110
|
projectFileName: nameWithoutScope,
|
|
92
111
|
},
|
|
93
|
-
importPath: (
|
|
112
|
+
importPath: (_a = options.importPath) !== null && _a !== void 0 ? _a : asProvidedProjectName,
|
|
94
113
|
projectRoot: asProvidedProjectDirectory,
|
|
95
114
|
},
|
|
96
115
|
};
|
|
@@ -103,7 +122,7 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
103
122
|
npmScope = getNpmScope(tree);
|
|
104
123
|
asProvidedImportPath =
|
|
105
124
|
asProvidedProjectDirectory === '.'
|
|
106
|
-
? (
|
|
125
|
+
? (_b = readJson(tree, 'package.json').name) !== null && _b !== void 0 ? _b : getImportPath(npmScope, asProvidedProjectName)
|
|
107
126
|
: getImportPath(npmScope, asProvidedProjectName);
|
|
108
127
|
}
|
|
109
128
|
}
|
|
@@ -129,7 +148,7 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
129
148
|
if (!derivedImportPath) {
|
|
130
149
|
derivedImportPath =
|
|
131
150
|
derivedProjectDirectory === '.'
|
|
132
|
-
? (
|
|
151
|
+
? (_c = readJson(tree, 'package.json').name) !== null && _c !== void 0 ? _c : getImportPath(npmScope, derivedProjectName)
|
|
133
152
|
: getImportPath(npmScope, derivedProjectDirectoryWithoutLayout);
|
|
134
153
|
}
|
|
135
154
|
}
|
|
@@ -21,7 +21,7 @@ function convertNxExecutor(executor) {
|
|
|
21
21
|
const projectsConfigurations = retrieveProjectConfigurationsWithAngularProjects
|
|
22
22
|
? {
|
|
23
23
|
version: 2,
|
|
24
|
-
projects: yield retrieveProjectConfigurationsWithAngularProjects(builderContext.workspaceRoot, nxJsonConfiguration),
|
|
24
|
+
projects: yield retrieveProjectConfigurationsWithAngularProjects(builderContext.workspaceRoot, nxJsonConfiguration).then((p) => p.projectNodes),
|
|
25
25
|
}
|
|
26
26
|
: // TODO(v18): remove retrieveProjectConfigurations. This is to be backwards compatible with Nx 16.5 and below.
|
|
27
27
|
workspaces.readProjectsConfigurations({
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertNxGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
6
|
-
const logger_1 = require("nx/src/utils/logger");
|
|
7
5
|
const path_1 = require("path");
|
|
8
6
|
const nx_1 = require("../../nx");
|
|
9
|
-
|
|
7
|
+
let { logger, stripIndent } = (0, nx_1.requireNx)();
|
|
8
|
+
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
9
|
+
stripIndent = stripIndent !== null && stripIndent !== void 0 ? stripIndent : require('nx/src/utils/logger').stripIndent;
|
|
10
10
|
class RunCallbackTask {
|
|
11
11
|
constructor(callback) {
|
|
12
12
|
this.callback = callback;
|
|
@@ -167,7 +167,7 @@ class DevkitTreeFromAngularDevkitTree {
|
|
|
167
167
|
this.warnUnsupportedFilePermissionsChange(filePath, mode);
|
|
168
168
|
}
|
|
169
169
|
warnUnsupportedFilePermissionsChange(filePath, mode) {
|
|
170
|
-
logger.warn(
|
|
170
|
+
logger.warn(stripIndent(`The Angular DevKit tree does not support changing a file permissions.
|
|
171
171
|
Ignoring changing ${filePath} permissions to ${mode}.`));
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.collectPackageSecondaryEntryPoints = exports.recursivelyCollectSecondaryEntryPointsFromDirectory = exports.getNonNodeModulesSubDirs = exports.collectWorkspaceLibrarySecondaryEntryPoints = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
|
-
const package_json_1 = require("nx/src/utils/package-json");
|
|
8
6
|
const nx_1 = require("../../../nx");
|
|
9
|
-
|
|
7
|
+
let { readJsonFile, joinPathFragments, workspaceRoot, readModulePackageJson } = (0, nx_1.requireNx)();
|
|
8
|
+
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
9
|
+
readModulePackageJson =
|
|
10
|
+
readModulePackageJson !== null && readModulePackageJson !== void 0 ? readModulePackageJson : require('nx/src/utils/package-json').readModulePackageJson;
|
|
10
11
|
function collectWorkspaceLibrarySecondaryEntryPoints(library, tsconfigPathAliases) {
|
|
11
12
|
const libraryRoot = (0, path_1.join)(workspaceRoot, library.root);
|
|
12
13
|
const needsSecondaryEntryPointsCollected = (0, fs_1.existsSync)((0, path_1.join)(libraryRoot, 'ng-package.json'));
|
|
@@ -83,7 +84,7 @@ function collectPackageSecondaryEntryPoints(pkgName, pkgVersion, collectedPackag
|
|
|
83
84
|
let packageJsonPath;
|
|
84
85
|
let packageJson;
|
|
85
86
|
try {
|
|
86
|
-
({ path: packageJsonPath, packageJson } =
|
|
87
|
+
({ path: packageJsonPath, packageJson } = readModulePackageJson(pkgName));
|
|
87
88
|
pathToPackage = (0, path_1.dirname)(packageJsonPath);
|
|
88
89
|
}
|
|
89
90
|
catch (_a) {
|