nx 16.6.0-beta.2 → 16.6.0-beta.4
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 +13 -13
- package/src/adapter/angular-json.js +1 -0
- package/src/adapter/ngcli-adapter.d.ts +6 -0
- package/src/adapter/ngcli-adapter.js +134 -70
- package/src/command-line/generate/generate.js +6 -5
- package/src/command-line/generate/generator-utils.d.ts +16 -0
- package/src/command-line/generate/generator-utils.js +85 -0
- package/src/command-line/migrate/migrate.js +1 -1
- package/src/command-line/new/new.js +2 -3
- package/src/command-line/run/executor-utils.d.ts +6 -0
- package/src/command-line/run/executor-utils.js +61 -0
- package/src/command-line/run/run.js +3 -2
- package/src/config/schema-utils.d.ts +15 -0
- package/src/config/schema-utils.js +60 -0
- package/src/config/workspaces.d.ts +0 -25
- package/src/config/workspaces.js +1 -174
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +3 -0
- package/src/devkit-internals.d.ts +1 -0
- package/src/devkit-internals.js +3 -1
- package/src/native/index.d.ts +7 -0
- package/src/native/index.js +3 -1
- package/src/plugins/js/index.js +4 -0
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +13 -12
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +89 -5
- package/src/tasks-runner/batch/run-batch.js +2 -3
- package/src/tasks-runner/forked-process-task-runner.js +0 -11
- package/src/tasks-runner/utils.d.ts +1 -0
- package/src/tasks-runner/utils.js +3 -1
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/package-manager.d.ts +1 -1
- package/src/utils/package-manager.js +7 -4
- package/src/utils/testing/temp-fs.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "16.6.0-beta.
|
|
3
|
+
"version": "16.6.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nx.dev",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nrwl/tao": "16.6.0-beta.
|
|
35
|
+
"@nrwl/tao": "16.6.0-beta.4",
|
|
36
36
|
"@parcel/watcher": "2.0.4",
|
|
37
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
38
38
|
"@yarnpkg/parsers": "3.0.0-rc.46",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-arm64": "16.6.0-beta.
|
|
85
|
-
"@nx/nx-darwin-x64": "16.6.0-beta.
|
|
86
|
-
"@nx/nx-freebsd-x64": "16.6.0-beta.
|
|
87
|
-
"@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.
|
|
88
|
-
"@nx/nx-linux-arm64-gnu": "16.6.0-beta.
|
|
89
|
-
"@nx/nx-linux-arm64-musl": "16.6.0-beta.
|
|
90
|
-
"@nx/nx-linux-x64-gnu": "16.6.0-beta.
|
|
91
|
-
"@nx/nx-linux-x64-musl": "16.6.0-beta.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "16.6.0-beta.
|
|
93
|
-
"@nx/nx-win32-x64-msvc": "16.6.0-beta.
|
|
84
|
+
"@nx/nx-darwin-arm64": "16.6.0-beta.4",
|
|
85
|
+
"@nx/nx-darwin-x64": "16.6.0-beta.4",
|
|
86
|
+
"@nx/nx-freebsd-x64": "16.6.0-beta.4",
|
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.4",
|
|
88
|
+
"@nx/nx-linux-arm64-gnu": "16.6.0-beta.4",
|
|
89
|
+
"@nx/nx-linux-arm64-musl": "16.6.0-beta.4",
|
|
90
|
+
"@nx/nx-linux-x64-gnu": "16.6.0-beta.4",
|
|
91
|
+
"@nx/nx-linux-x64-musl": "16.6.0-beta.4",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "16.6.0-beta.4",
|
|
93
|
+
"@nx/nx-win32-x64-msvc": "16.6.0-beta.4"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
|
@@ -177,5 +177,5 @@
|
|
|
177
177
|
},
|
|
178
178
|
"main": "./bin/nx.js",
|
|
179
179
|
"types": "./bin/nx.d.ts",
|
|
180
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "b1a9ae7ce76697019b26ec9a172005840cca8da6"
|
|
181
181
|
}
|
|
@@ -21,6 +21,7 @@ function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
|
|
|
21
21
|
exports.shouldMergeAngularProjects = shouldMergeAngularProjects;
|
|
22
22
|
function isAngularPluginInstalled() {
|
|
23
23
|
try {
|
|
24
|
+
// nx-ignore-next-line
|
|
24
25
|
require.resolve('@nx/angular');
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
@@ -4,6 +4,12 @@ import { Observable } from 'rxjs';
|
|
|
4
4
|
import type { GenerateOptions } from '../command-line/generate/generate';
|
|
5
5
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
|
6
6
|
import { Tree } from '../generators/tree';
|
|
7
|
+
import { ExecutorContext } from '../config/misc-interfaces';
|
|
8
|
+
export declare function createBuilderContext(builderInfo: {
|
|
9
|
+
builderName: string;
|
|
10
|
+
description: string;
|
|
11
|
+
optionSchema: any;
|
|
12
|
+
}, context: ExecutorContext): Promise<import("@angular-devkit/architect").BuilderContext>;
|
|
7
13
|
export declare function scheduleTarget(root: string, opts: {
|
|
8
14
|
project: string;
|
|
9
15
|
target: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.overrideCollectionResolutionForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = void 0;
|
|
3
|
+
exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.overrideCollectionResolutionForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@angular-devkit/core");
|
|
6
6
|
const node_1 = require("@angular-devkit/core/node");
|
|
@@ -19,8 +19,68 @@ const logger_1 = require("../utils/logger");
|
|
|
19
19
|
const package_json_1 = require("../utils/package-json");
|
|
20
20
|
const package_manager_1 = require("../utils/package-manager");
|
|
21
21
|
const angular_json_1 = require("./angular-json");
|
|
22
|
-
const
|
|
22
|
+
const executor_utils_1 = require("../command-line/run/executor-utils");
|
|
23
23
|
const nx_plugin_1 = require("../utils/nx-plugin");
|
|
24
|
+
const schema_utils_1 = require("../config/schema-utils");
|
|
25
|
+
function createBuilderContext(builderInfo, context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
require('nx/src/adapter/compat');
|
|
28
|
+
const fsHost = new NxScopedHost(context.root);
|
|
29
|
+
const { workspace } = yield core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
|
|
30
|
+
const architectHost = yield getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root);
|
|
31
|
+
const registry = new core_1.schema.CoreSchemaRegistry();
|
|
32
|
+
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
33
|
+
registry.addSmartDefaultProvider('unparsed', () => {
|
|
34
|
+
// This happens when context.scheduleTarget is used to run a target using nx:run-commands
|
|
35
|
+
return [];
|
|
36
|
+
});
|
|
37
|
+
const { Architect } = require('@angular-devkit/architect');
|
|
38
|
+
const architect = new Architect(architectHost, registry);
|
|
39
|
+
const { firstValueFrom } = require('rxjs');
|
|
40
|
+
const toPromise = (obs) => firstValueFrom ? firstValueFrom(obs) : obs.toPromise();
|
|
41
|
+
const validateOptions = (options, builderName) => toPromise(architect['_scheduler'].schedule('..validateOptions', [
|
|
42
|
+
builderName,
|
|
43
|
+
options,
|
|
44
|
+
]).output);
|
|
45
|
+
const getProjectMetadata = (target) => toPromise(architect['_scheduler'].schedule('..getProjectMetadata', target).output);
|
|
46
|
+
const builderContext = {
|
|
47
|
+
workspaceRoot: context.root,
|
|
48
|
+
target: {
|
|
49
|
+
project: context.projectName,
|
|
50
|
+
target: context.targetName,
|
|
51
|
+
configuration: context.configurationName,
|
|
52
|
+
},
|
|
53
|
+
builder: Object.assign({}, builderInfo),
|
|
54
|
+
logger: (0, exports.getLogger)(),
|
|
55
|
+
id: 1,
|
|
56
|
+
currentDirectory: process.cwd(),
|
|
57
|
+
scheduleTarget: architect.scheduleTarget,
|
|
58
|
+
getBuilderNameForTarget: architectHost.getBuilderNameForTarget,
|
|
59
|
+
scheduleBuilder: architect.scheduleBuilder,
|
|
60
|
+
getTargetOptions: architectHost.getOptionsForTarget,
|
|
61
|
+
addTeardown(teardown) {
|
|
62
|
+
// No-op as Nx doesn't require an implementation of this function
|
|
63
|
+
return;
|
|
64
|
+
},
|
|
65
|
+
reportProgress(...args) {
|
|
66
|
+
// No-op as Nx doesn't require an implementation of this function
|
|
67
|
+
return;
|
|
68
|
+
},
|
|
69
|
+
reportRunning(...args) {
|
|
70
|
+
// No-op as Nx doesn't require an implementation of this function
|
|
71
|
+
return;
|
|
72
|
+
},
|
|
73
|
+
reportStatus(status) {
|
|
74
|
+
// No-op as Nx doesn't require an implementation of this function
|
|
75
|
+
return;
|
|
76
|
+
},
|
|
77
|
+
getProjectMetadata,
|
|
78
|
+
validateOptions,
|
|
79
|
+
};
|
|
80
|
+
return builderContext;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.createBuilderContext = createBuilderContext;
|
|
24
84
|
function scheduleTarget(root, opts, verbose) {
|
|
25
85
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
86
|
const { Architect } = require('@angular-devkit/architect');
|
|
@@ -33,74 +93,7 @@ function scheduleTarget(root, opts, verbose) {
|
|
|
33
93
|
// This happens when context.scheduleTarget is used to run a target using nx:run-commands
|
|
34
94
|
return [];
|
|
35
95
|
});
|
|
36
|
-
const
|
|
37
|
-
class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
|
|
38
|
-
constructor(workspace, root) {
|
|
39
|
-
super(workspace, root);
|
|
40
|
-
this.workspace = workspace;
|
|
41
|
-
this.root = root;
|
|
42
|
-
this.workspaces = new workspaces_1.Workspaces(this.root);
|
|
43
|
-
}
|
|
44
|
-
resolveBuilder(builderStr) {
|
|
45
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const [packageName, builderName] = builderStr.split(':');
|
|
47
|
-
const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
|
|
48
|
-
const builderInfo = this.readExecutor(packageName, builderName);
|
|
49
|
-
return {
|
|
50
|
-
name: builderStr,
|
|
51
|
-
builderName,
|
|
52
|
-
description: (0, fileutils_1.readJsonFile)(executorsFilePath).builders[builderName]
|
|
53
|
-
.description,
|
|
54
|
-
optionSchema: builderInfo.schema,
|
|
55
|
-
import: this.workspaces['resolveImplementation'].bind(this.workspaces)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
readExecutorsJson(nodeModule, builder) {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.workspaces['resolvePaths'].bind(this.workspaces)());
|
|
62
|
-
const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
|
|
63
|
-
if (!executorsFile) {
|
|
64
|
-
throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
|
|
65
|
-
}
|
|
66
|
-
const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
|
|
67
|
-
const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
|
|
68
|
-
const executorConfig = (_b = executorsJson.builders) === null || _b === void 0 ? void 0 : _b[builder];
|
|
69
|
-
if (!executorConfig) {
|
|
70
|
-
throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
|
|
71
|
-
}
|
|
72
|
-
return { executorsFilePath, executorConfig, isNgCompat: true };
|
|
73
|
-
}
|
|
74
|
-
readExecutor(nodeModule, executor) {
|
|
75
|
-
try {
|
|
76
|
-
const { executorsFilePath, executorConfig, isNgCompat } = this.readExecutorsJson(nodeModule, executor);
|
|
77
|
-
const executorsDir = (0, path_1.dirname)(executorsFilePath);
|
|
78
|
-
const schemaPath = this.workspaces['resolveSchema'].bind(this.workspaces)(executorConfig.schema, executorsDir);
|
|
79
|
-
const schema = (0, workspaces_1.normalizeExecutorSchema)((0, fileutils_1.readJsonFile)(schemaPath));
|
|
80
|
-
const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
|
|
81
|
-
const batchImplementationFactory = executorConfig.batchImplementation
|
|
82
|
-
? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
|
|
83
|
-
: null;
|
|
84
|
-
const hasherFactory = executorConfig.hasher
|
|
85
|
-
? this.getImplementationFactory(executorConfig.hasher, executorsDir)
|
|
86
|
-
: null;
|
|
87
|
-
return {
|
|
88
|
-
schema,
|
|
89
|
-
implementationFactory,
|
|
90
|
-
batchImplementationFactory,
|
|
91
|
-
hasherFactory,
|
|
92
|
-
isNgCompat,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
getImplementationFactory(implementation, executorsDir) {
|
|
100
|
-
return this.workspaces['getImplementationFactory'].bind(this.workspaces)(implementation, executorsDir);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const architectHost = new WrappedWorkspaceNodeModulesArchitectHost(workspace, root);
|
|
96
|
+
const architectHost = yield getWrappedWorkspaceNodeModulesArchitectHost(workspace, root);
|
|
104
97
|
const architect = new Architect(architectHost, registry);
|
|
105
98
|
const run = yield architect.scheduleTarget({
|
|
106
99
|
project: opts.project,
|
|
@@ -724,3 +717,74 @@ function saveProjectsConfigurationsInWrappedSchematic(host, content) {
|
|
|
724
717
|
host.write('angular.json', JSON.stringify((0, angular_json_1.toOldFormat)(newAngularJson), null, 2));
|
|
725
718
|
}
|
|
726
719
|
}
|
|
720
|
+
function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root) {
|
|
721
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
722
|
+
const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = yield Promise.resolve().then(() => require('@angular-devkit/architect/node'));
|
|
723
|
+
class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
|
|
724
|
+
constructor(workspace, root) {
|
|
725
|
+
super(workspace, root);
|
|
726
|
+
this.workspace = workspace;
|
|
727
|
+
this.root = root;
|
|
728
|
+
}
|
|
729
|
+
resolveBuilder(builderStr) {
|
|
730
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
731
|
+
const [packageName, builderName] = builderStr.split(':');
|
|
732
|
+
const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
|
|
733
|
+
const builderInfo = this.readExecutor(packageName, builderName);
|
|
734
|
+
return {
|
|
735
|
+
name: builderStr,
|
|
736
|
+
builderName,
|
|
737
|
+
description: (0, fileutils_1.readJsonFile)(executorsFilePath).builders[builderName]
|
|
738
|
+
.description,
|
|
739
|
+
optionSchema: builderInfo.schema,
|
|
740
|
+
import: (0, schema_utils_1.resolveImplementation)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
|
|
741
|
+
};
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
readExecutorsJson(nodeModule, builder) {
|
|
745
|
+
var _a, _b;
|
|
746
|
+
const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.root ? [this.root, __dirname] : [__dirname]);
|
|
747
|
+
const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
|
|
748
|
+
if (!executorsFile) {
|
|
749
|
+
throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
|
|
750
|
+
}
|
|
751
|
+
const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
|
|
752
|
+
const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
|
|
753
|
+
const executorConfig = (_b = executorsJson.builders) === null || _b === void 0 ? void 0 : _b[builder];
|
|
754
|
+
if (!executorConfig) {
|
|
755
|
+
throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
|
|
756
|
+
}
|
|
757
|
+
return { executorsFilePath, executorConfig, isNgCompat: true };
|
|
758
|
+
}
|
|
759
|
+
readExecutor(nodeModule, executor) {
|
|
760
|
+
try {
|
|
761
|
+
const { executorsFilePath, executorConfig, isNgCompat } = this.readExecutorsJson(nodeModule, executor);
|
|
762
|
+
const executorsDir = (0, path_1.dirname)(executorsFilePath);
|
|
763
|
+
const schemaPath = (0, schema_utils_1.resolveSchema)(executorConfig.schema, executorsDir);
|
|
764
|
+
const schema = (0, executor_utils_1.normalizeExecutorSchema)((0, fileutils_1.readJsonFile)(schemaPath));
|
|
765
|
+
const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
|
|
766
|
+
const batchImplementationFactory = executorConfig.batchImplementation
|
|
767
|
+
? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
|
|
768
|
+
: null;
|
|
769
|
+
const hasherFactory = executorConfig.hasher
|
|
770
|
+
? this.getImplementationFactory(executorConfig.hasher, executorsDir)
|
|
771
|
+
: null;
|
|
772
|
+
return {
|
|
773
|
+
schema,
|
|
774
|
+
implementationFactory,
|
|
775
|
+
batchImplementationFactory,
|
|
776
|
+
hasherFactory,
|
|
777
|
+
isNgCompat,
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
catch (e) {
|
|
781
|
+
throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
getImplementationFactory(implementation, executorsDir) {
|
|
785
|
+
return (0, schema_utils_1.getImplementationFactory)(implementation, executorsDir);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return new WrappedWorkspaceNodeModulesArchitectHost(workspace, root);
|
|
789
|
+
});
|
|
790
|
+
}
|
|
@@ -15,6 +15,7 @@ const print_help_1 = require("../../utils/print-help");
|
|
|
15
15
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
16
16
|
const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
|
|
17
17
|
const output_1 = require("../../utils/output");
|
|
18
|
+
const generator_utils_1 = require("./generator-utils");
|
|
18
19
|
function printChanges(fileChanges) {
|
|
19
20
|
fileChanges.forEach((f) => {
|
|
20
21
|
if (f.type === 'CREATE') {
|
|
@@ -37,7 +38,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
|
|
|
37
38
|
const deprecatedChoices = new Set();
|
|
38
39
|
for (const collectionName of installedCollections) {
|
|
39
40
|
try {
|
|
40
|
-
const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } =
|
|
41
|
+
const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName, workspace_root_1.workspaceRoot);
|
|
41
42
|
if (hidden) {
|
|
42
43
|
continue;
|
|
43
44
|
}
|
|
@@ -53,7 +54,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
|
|
|
53
54
|
const choicesFromLocalPlugins = [];
|
|
54
55
|
for (const [name] of localPlugins) {
|
|
55
56
|
try {
|
|
56
|
-
const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } =
|
|
57
|
+
const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(name, generatorName, workspace_root_1.workspaceRoot);
|
|
57
58
|
if (hidden) {
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
@@ -107,7 +108,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
|
|
|
107
108
|
return true;
|
|
108
109
|
}
|
|
109
110
|
try {
|
|
110
|
-
|
|
111
|
+
(0, generator_utils_1.getGeneratorInformation)(value, generatorName, workspace_root_1.workspaceRoot);
|
|
111
112
|
return true;
|
|
112
113
|
}
|
|
113
114
|
catch (_a) {
|
|
@@ -224,7 +225,7 @@ function generate(cwd, args) {
|
|
|
224
225
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
225
226
|
return (0, params_1.handleErrors)(verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
226
227
|
const opts = yield convertToGenerateOptions(args, ws, readDefaultCollection(nxJsonConfiguration), 'generate', projectsConfigurations);
|
|
227
|
-
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } =
|
|
228
|
+
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot);
|
|
228
229
|
if (deprecated) {
|
|
229
230
|
logger_1.logger.warn([
|
|
230
231
|
`${logger_1.NX_PREFIX}: ${opts.collectionName}:${normalizedGeneratorName} is deprecated`,
|
|
@@ -239,7 +240,7 @@ function generate(cwd, args) {
|
|
|
239
240
|
return 0;
|
|
240
241
|
}
|
|
241
242
|
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, ws.calculateDefaultProjectName(cwd, projectsConfigurations, nxJsonConfiguration), ws.relativeCwd(cwd), verbose);
|
|
242
|
-
if (
|
|
243
|
+
if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
|
|
243
244
|
const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
|
|
244
245
|
const implementation = implementationFactory();
|
|
245
246
|
// @todo(v17): Remove this, isStandalonePreset property is defunct.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Generator, GeneratorsJson, GeneratorsJsonEntry } from '../../config/misc-interfaces';
|
|
2
|
+
export declare function getGeneratorInformation(collectionName: string, generatorName: string, root: string | null): {
|
|
3
|
+
resolvedCollectionName: string;
|
|
4
|
+
normalizedGeneratorName: string;
|
|
5
|
+
schema: any;
|
|
6
|
+
implementationFactory: () => Generator<unknown>;
|
|
7
|
+
isNgCompat: boolean;
|
|
8
|
+
isNxGenerator: boolean;
|
|
9
|
+
generatorConfiguration: GeneratorsJsonEntry;
|
|
10
|
+
};
|
|
11
|
+
export declare function readGeneratorsJson(collectionName: string, generator: string, root: string | null): {
|
|
12
|
+
generatorsFilePath: string;
|
|
13
|
+
generatorsJson: GeneratorsJson;
|
|
14
|
+
normalizedGeneratorName: string;
|
|
15
|
+
resolvedCollectionName: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readGeneratorsJson = exports.getGeneratorInformation = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const schema_utils_1 = require("../../config/schema-utils");
|
|
6
|
+
const fileutils_1 = require("../../utils/fileutils");
|
|
7
|
+
const nx_plugin_1 = require("../../utils/nx-plugin");
|
|
8
|
+
function getGeneratorInformation(collectionName, generatorName, root) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
try {
|
|
11
|
+
const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = readGeneratorsJson(collectionName, generatorName, root);
|
|
12
|
+
const generatorsDir = (0, path_1.dirname)(generatorsFilePath);
|
|
13
|
+
const generatorConfig = ((_a = generatorsJson.generators) === null || _a === void 0 ? void 0 : _a[normalizedGeneratorName]) ||
|
|
14
|
+
((_b = generatorsJson.schematics) === null || _b === void 0 ? void 0 : _b[normalizedGeneratorName]);
|
|
15
|
+
const isNgCompat = !((_c = generatorsJson.generators) === null || _c === void 0 ? void 0 : _c[normalizedGeneratorName]);
|
|
16
|
+
const schemaPath = (0, schema_utils_1.resolveSchema)(generatorConfig.schema, generatorsDir);
|
|
17
|
+
const schema = (0, fileutils_1.readJsonFile)(schemaPath);
|
|
18
|
+
if (!schema.properties || typeof schema.properties !== 'object') {
|
|
19
|
+
schema.properties = {};
|
|
20
|
+
}
|
|
21
|
+
generatorConfig.implementation =
|
|
22
|
+
generatorConfig.implementation || generatorConfig.factory;
|
|
23
|
+
const implementationFactory = (0, schema_utils_1.getImplementationFactory)(generatorConfig.implementation, generatorsDir);
|
|
24
|
+
const normalizedGeneratorConfiguration = Object.assign(Object.assign({}, generatorConfig), { aliases: (_d = generatorConfig.aliases) !== null && _d !== void 0 ? _d : [], hidden: !!generatorConfig.hidden });
|
|
25
|
+
return {
|
|
26
|
+
resolvedCollectionName,
|
|
27
|
+
normalizedGeneratorName,
|
|
28
|
+
schema,
|
|
29
|
+
implementationFactory,
|
|
30
|
+
isNgCompat,
|
|
31
|
+
isNxGenerator: !isNgCompat,
|
|
32
|
+
generatorConfiguration: normalizedGeneratorConfiguration,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new Error(`Unable to resolve ${collectionName}:${generatorName}.\n${e.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.getGeneratorInformation = getGeneratorInformation;
|
|
40
|
+
function readGeneratorsJson(collectionName, generator, root) {
|
|
41
|
+
var _a;
|
|
42
|
+
let generatorsFilePath;
|
|
43
|
+
if (collectionName.endsWith('.json')) {
|
|
44
|
+
generatorsFilePath = require.resolve(collectionName, {
|
|
45
|
+
paths: root ? [root, __dirname] : [__dirname],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, root ? [root, __dirname] : [__dirname]);
|
|
50
|
+
const generatorsFile = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
|
|
51
|
+
if (!generatorsFile) {
|
|
52
|
+
throw new Error(`The "${collectionName}" package does not support Nx generators.`);
|
|
53
|
+
}
|
|
54
|
+
generatorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), generatorsFile));
|
|
55
|
+
}
|
|
56
|
+
const generatorsJson = (0, fileutils_1.readJsonFile)(generatorsFilePath);
|
|
57
|
+
let normalizedGeneratorName = findFullGeneratorName(generator, generatorsJson.generators) ||
|
|
58
|
+
findFullGeneratorName(generator, generatorsJson.schematics);
|
|
59
|
+
if (!normalizedGeneratorName) {
|
|
60
|
+
for (let parent of generatorsJson.extends || []) {
|
|
61
|
+
try {
|
|
62
|
+
return readGeneratorsJson(parent, generator, root);
|
|
63
|
+
}
|
|
64
|
+
catch (e) { }
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Cannot find generator '${generator}' in ${generatorsFilePath}.`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
generatorsFilePath,
|
|
70
|
+
generatorsJson,
|
|
71
|
+
normalizedGeneratorName,
|
|
72
|
+
resolvedCollectionName: collectionName,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.readGeneratorsJson = readGeneratorsJson;
|
|
76
|
+
function findFullGeneratorName(name, generators) {
|
|
77
|
+
if (generators) {
|
|
78
|
+
for (let [key, data] of Object.entries(generators)) {
|
|
79
|
+
if (key === name ||
|
|
80
|
+
(data.aliases && data.aliases.includes(name))) {
|
|
81
|
+
return key;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -833,7 +833,7 @@ function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
|
|
|
833
833
|
? [
|
|
834
834
|
`- You opted out of some migrations for now. Write the following command down somewhere to apply these migrations later:`,
|
|
835
835
|
` nx migrate ${opts.targetVersion} --from ${opts.targetPackage}@${minVersionWithSkippedUpdates} --exclude-applied-migrations`,
|
|
836
|
-
`- To learn more go to https://nx.dev/recipes/
|
|
836
|
+
`- To learn more go to https://nx.dev/recipes/managing-repository/advanced-update`,
|
|
837
837
|
]
|
|
838
838
|
: [
|
|
839
839
|
`- To learn more go to https://nx.dev/core-features/automate-updating-dependencies`,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newWorkspace = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
6
5
|
const tree_1 = require("../../generators/tree");
|
|
7
6
|
const params_1 = require("../../utils/params");
|
|
7
|
+
const generator_utils_1 = require("../generate/generator-utils");
|
|
8
8
|
function removeSpecialFlags(generatorOptions) {
|
|
9
9
|
delete generatorOptions.interactive;
|
|
10
10
|
delete generatorOptions.help;
|
|
@@ -14,10 +14,9 @@ function removeSpecialFlags(generatorOptions) {
|
|
|
14
14
|
}
|
|
15
15
|
function newWorkspace(cwd, args) {
|
|
16
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const ws = new workspaces_1.Workspaces(null);
|
|
18
17
|
return (0, params_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true' || args.verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
const isInteractive = args.interactive;
|
|
20
|
-
const { normalizedGeneratorName, schema, implementationFactory } =
|
|
19
|
+
const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)('@nx/workspace/generators.json', 'new', null);
|
|
21
20
|
removeSpecialFlags(args);
|
|
22
21
|
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(args, '@nx/workspace/generators.json', normalizedGeneratorName, null, null, schema, isInteractive, null, null, false);
|
|
23
22
|
const host = new tree_1.FsTree(cwd, false, 'nx new');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorConfig } from '../../config/misc-interfaces';
|
|
2
|
+
export declare function normalizeExecutorSchema(schema: Partial<ExecutorConfig['schema']>): ExecutorConfig['schema'];
|
|
3
|
+
export declare function getExecutorInformation(nodeModule: string, executor: string, root: string): ExecutorConfig & {
|
|
4
|
+
isNgCompat: boolean;
|
|
5
|
+
isNxExecutor: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExecutorInformation = exports.normalizeExecutorSchema = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const nx_plugin_1 = require("../../utils/nx-plugin");
|
|
6
|
+
const fileutils_1 = require("../../utils/fileutils");
|
|
7
|
+
const schema_utils_1 = require("../../config/schema-utils");
|
|
8
|
+
const installation_directory_1 = require("../../utils/installation-directory");
|
|
9
|
+
function normalizeExecutorSchema(schema) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const version = ((_a = schema.version) !== null && _a !== void 0 ? _a : (schema.version = 1));
|
|
12
|
+
return Object.assign({ version, outputCapture: ((_b = schema.outputCapture) !== null && _b !== void 0 ? _b : version < 2) ? 'direct-nodejs' : 'pipe', properties: !schema.properties || typeof schema.properties !== 'object'
|
|
13
|
+
? {}
|
|
14
|
+
: schema.properties }, schema);
|
|
15
|
+
}
|
|
16
|
+
exports.normalizeExecutorSchema = normalizeExecutorSchema;
|
|
17
|
+
function getExecutorInformation(nodeModule, executor, root) {
|
|
18
|
+
try {
|
|
19
|
+
const { executorsFilePath, executorConfig, isNgCompat } = readExecutorsJson(nodeModule, executor, root);
|
|
20
|
+
const executorsDir = (0, path_1.dirname)(executorsFilePath);
|
|
21
|
+
const schemaPath = (0, schema_utils_1.resolveSchema)(executorConfig.schema, executorsDir);
|
|
22
|
+
const schema = normalizeExecutorSchema((0, fileutils_1.readJsonFile)(schemaPath));
|
|
23
|
+
const implementationFactory = (0, schema_utils_1.getImplementationFactory)(executorConfig.implementation, executorsDir);
|
|
24
|
+
const batchImplementationFactory = executorConfig.batchImplementation
|
|
25
|
+
? (0, schema_utils_1.getImplementationFactory)(executorConfig.batchImplementation, executorsDir)
|
|
26
|
+
: null;
|
|
27
|
+
const hasherFactory = executorConfig.hasher
|
|
28
|
+
? (0, schema_utils_1.getImplementationFactory)(executorConfig.hasher, executorsDir)
|
|
29
|
+
: null;
|
|
30
|
+
return {
|
|
31
|
+
schema,
|
|
32
|
+
implementationFactory,
|
|
33
|
+
batchImplementationFactory,
|
|
34
|
+
hasherFactory,
|
|
35
|
+
isNgCompat,
|
|
36
|
+
isNxExecutor: !isNgCompat,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.getExecutorInformation = getExecutorInformation;
|
|
44
|
+
function readExecutorsJson(nodeModule, executor, root) {
|
|
45
|
+
var _a, _b, _c, _d;
|
|
46
|
+
const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, root
|
|
47
|
+
? [root, __dirname, process.cwd(), ...(0, installation_directory_1.getNxRequirePaths)()]
|
|
48
|
+
: [__dirname, process.cwd(), ...(0, installation_directory_1.getNxRequirePaths)()]);
|
|
49
|
+
const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
|
|
50
|
+
if (!executorsFile) {
|
|
51
|
+
throw new Error(`The "${nodeModule}" package does not support Nx executors.`);
|
|
52
|
+
}
|
|
53
|
+
const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
|
|
54
|
+
const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
|
|
55
|
+
const executorConfig = ((_b = executorsJson.executors) === null || _b === void 0 ? void 0 : _b[executor]) || ((_c = executorsJson.builders) === null || _c === void 0 ? void 0 : _c[executor]);
|
|
56
|
+
if (!executorConfig) {
|
|
57
|
+
throw new Error(`Cannot find executor '${executor}' in ${executorsFilePath}.`);
|
|
58
|
+
}
|
|
59
|
+
const isNgCompat = !((_d = executorsJson.executors) === null || _d === void 0 ? void 0 : _d[executor]);
|
|
60
|
+
return { executorsFilePath, executorConfig, isNgCompat };
|
|
61
|
+
}
|
|
@@ -14,6 +14,7 @@ const serialize_overrides_into_command_line_1 = require("../../utils/serialize-o
|
|
|
14
14
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
15
15
|
const configuration_1 = require("../../config/configuration");
|
|
16
16
|
const async_iterator_1 = require("../../utils/async-iterator");
|
|
17
|
+
const executor_utils_1 = require("./executor-utils");
|
|
17
18
|
function printRunHelp(opts, schema, plugin) {
|
|
18
19
|
(0, print_help_1.printHelp)(`run ${opts.project}:${opts.target}`, schema, Object.assign({ mode: 'run' }, plugin));
|
|
19
20
|
}
|
|
@@ -74,7 +75,7 @@ function parseExecutorAndTarget(ws, { project, target, configuration }, root, pr
|
|
|
74
75
|
throw new Error(`Cannot find target '${target}' for project '${project}'`);
|
|
75
76
|
}
|
|
76
77
|
const [nodeModule, executor] = targetConfig.executor.split(':');
|
|
77
|
-
const { schema, implementationFactory } =
|
|
78
|
+
const { schema, implementationFactory } = (0, executor_utils_1.getExecutorInformation)(nodeModule, executor, root);
|
|
78
79
|
return { executor, implementationFactory, nodeModule, schema, targetConfig };
|
|
79
80
|
});
|
|
80
81
|
}
|
|
@@ -96,7 +97,7 @@ function runExecutorInternal({ project, target, configuration }, overrides, root
|
|
|
96
97
|
const { executor, implementationFactory, nodeModule, schema, targetConfig } = yield parseExecutorAndTarget(ws, { project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration);
|
|
97
98
|
configuration !== null && configuration !== void 0 ? configuration : (configuration = targetConfig.defaultConfiguration);
|
|
98
99
|
const combinedOptions = (0, params_1.combineOptionsForExecutor)(overrides, configuration, targetConfig, schema, project, ws.relativeCwd(cwd), isVerbose);
|
|
99
|
-
if (
|
|
100
|
+
if ((0, executor_utils_1.getExecutorInformation)(nodeModule, executor, root).isNxExecutor) {
|
|
100
101
|
const implementation = implementationFactory();
|
|
101
102
|
const r = implementation(combinedOptions, {
|
|
102
103
|
root,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function is used to get the implementation factory of an executor or generator.
|
|
3
|
+
* @param implementation path to the implementation
|
|
4
|
+
* @param directory path to the directory
|
|
5
|
+
* @returns a function that returns the implementation
|
|
6
|
+
*/
|
|
7
|
+
export declare function getImplementationFactory<T>(implementation: string, directory: string): () => T;
|
|
8
|
+
/**
|
|
9
|
+
* This function is used to resolve the implementation of an executor or generator.
|
|
10
|
+
* @param implementationModulePath
|
|
11
|
+
* @param directory
|
|
12
|
+
* @returns path to the implementation
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveImplementation(implementationModulePath: string, directory: string): string;
|
|
15
|
+
export declare function resolveSchema(schemaPath: string, directory: string): string;
|