@nx/devkit 19.0.0-canary.20240502-5ded713 → 19.0.0-canary.20240504-fd5ea92
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/devkit",
|
3
|
-
"version": "19.0.0-canary.
|
3
|
+
"version": "19.0.0-canary.20240504-fd5ea92",
|
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. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
|
6
6
|
"repository": {
|
@@ -36,7 +36,7 @@
|
|
36
36
|
"semver": "^7.5.3",
|
37
37
|
"yargs-parser": "21.1.1",
|
38
38
|
"minimatch": "9.0.3",
|
39
|
-
"@nrwl/devkit": "19.0.0-canary.
|
39
|
+
"@nrwl/devkit": "19.0.0-canary.20240504-fd5ea92"
|
40
40
|
},
|
41
41
|
"peerDependencies": {
|
42
42
|
"nx": ">= 17 <= 20"
|
@@ -33,9 +33,7 @@ function forEachProjectConfig(projects, executorName, callback) {
|
|
33
33
|
if (executorName !== target.executor) {
|
34
34
|
continue;
|
35
35
|
}
|
36
|
-
|
37
|
-
callback(target.options, projectName, targetName);
|
38
|
-
}
|
36
|
+
callback(target.options ?? {}, projectName, targetName);
|
39
37
|
if (!target.configurations) {
|
40
38
|
continue;
|
41
39
|
}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { ProjectGraph, TargetConfiguration, Tree, CreateNodes } from 'nx/src/devkit-exports';
|
2
2
|
type PluginOptionsBuilder<T> = (targetName: string) => T;
|
3
|
-
type PostTargetTransformer = (targetConfiguration: TargetConfiguration, tree?: Tree
|
3
|
+
type PostTargetTransformer = (targetConfiguration: TargetConfiguration, tree?: Tree, projectDetails?: {
|
4
|
+
projectName: string;
|
5
|
+
root: string;
|
6
|
+
}) => TargetConfiguration;
|
4
7
|
type SkipTargetFilter = (targetConfiguration: TargetConfiguration) => [boolean, string];
|
5
|
-
export declare function migrateExecutorToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, executor: string, pluginPath: string, pluginOptionsBuilder: PluginOptionsBuilder<T>, postTargetTransformer: PostTargetTransformer, createNodes: CreateNodes<T>, specificProjectToMigrate?: string, skipTargetFilter?: SkipTargetFilter): Promise<
|
8
|
+
export declare function migrateExecutorToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, executor: string, pluginPath: string, pluginOptionsBuilder: PluginOptionsBuilder<T>, postTargetTransformer: PostTargetTransformer, createNodes: CreateNodes<T>, specificProjectToMigrate?: string, skipTargetFilter?: SkipTargetFilter): Promise<Map<string, Set<string>>>;
|
6
9
|
export {};
|
@@ -37,10 +37,13 @@ class ExecutorToPluginMigrator {
|
|
37
37
|
}
|
38
38
|
async run() {
|
39
39
|
await tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_init).call(this);
|
40
|
-
|
41
|
-
tslib_1.__classPrivateFieldGet(this,
|
40
|
+
if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size > 0) {
|
41
|
+
for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
|
42
|
+
tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_migrateTarget).call(this, targetName);
|
43
|
+
}
|
44
|
+
tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_addPlugins).call(this);
|
42
45
|
}
|
43
|
-
tslib_1.__classPrivateFieldGet(this,
|
46
|
+
return tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f");
|
44
47
|
}
|
45
48
|
}
|
46
49
|
_ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrator_executor = new WeakMap(), _ExecutorToPluginMigrator_pluginPath = new WeakMap(), _ExecutorToPluginMigrator_pluginOptionsBuilder = new WeakMap(), _ExecutorToPluginMigrator_postTargetTransformer = new WeakMap(), _ExecutorToPluginMigrator_skipTargetFilter = new WeakMap(), _ExecutorToPluginMigrator_specificProjectToMigrate = new WeakMap(), _ExecutorToPluginMigrator_nxJson = new WeakMap(), _ExecutorToPluginMigrator_targetDefaultsForExecutor = new WeakMap(), _ExecutorToPluginMigrator_targetAndProjectsToMigrate = new WeakMap(), _ExecutorToPluginMigrator_pluginToAddForTarget = new WeakMap(), _ExecutorToPluginMigrator_createNodes = new WeakMap(), _ExecutorToPluginMigrator_configFiles = new WeakMap(), _ExecutorToPluginMigrator_createNodesResultsForTargets = new WeakMap(), _ExecutorToPluginMigrator_instances = new WeakSet(), _ExecutorToPluginMigrator_init = async function _ExecutorToPluginMigrator_init() {
|
@@ -71,7 +74,10 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
71
74
|
projectTarget = (0, devkit_internals_1.mergeTargetConfigurations)(projectTarget, tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, "f"));
|
72
75
|
delete projectTarget.executor;
|
73
76
|
(0, plugin_migration_utils_1.deleteMatchingProperties)(projectTarget, createdTarget);
|
74
|
-
projectTarget = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_postTargetTransformer, "f").call(this, projectTarget, this.tree
|
77
|
+
projectTarget = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_postTargetTransformer, "f").call(this, projectTarget, this.tree, {
|
78
|
+
projectName,
|
79
|
+
root: projectFromGraph.data.root,
|
80
|
+
});
|
75
81
|
if (projectTarget.options &&
|
76
82
|
Object.keys(projectTarget.options).length === 0) {
|
77
83
|
delete projectTarget.options;
|
@@ -82,6 +88,9 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
82
88
|
else {
|
83
89
|
delete projectConfig.targets[targetName];
|
84
90
|
}
|
91
|
+
if (!projectConfig['// targets']) {
|
92
|
+
projectConfig['// targets'] = `to see all targets run: nx show project ${projectName} --web`;
|
93
|
+
}
|
85
94
|
(0, devkit_exports_1.updateProjectConfiguration)(this.tree, projectName, projectConfig);
|
86
95
|
return `${projectFromGraph.data.root}/**/*`;
|
87
96
|
}, _ExecutorToPluginMigrator_addPlugins = function _ExecutorToPluginMigrator_addPlugins() {
|
@@ -120,6 +129,17 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
120
129
|
}
|
121
130
|
}
|
122
131
|
if (!existingPlugin) {
|
132
|
+
const allConfigFilesAreIncluded = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_configFiles, "f").every((configFile) => {
|
133
|
+
for (const includePattern of plugin.include) {
|
134
|
+
if ((0, minimatch_1.minimatch)(configFile, includePattern, { dot: true })) {
|
135
|
+
return true;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return false;
|
139
|
+
});
|
140
|
+
if (allConfigFilesAreIncluded) {
|
141
|
+
plugin.include = undefined;
|
142
|
+
}
|
123
143
|
tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_nxJson, "f").plugins.push(plugin);
|
124
144
|
}
|
125
145
|
}
|
@@ -151,12 +171,6 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
151
171
|
tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").set(targetName, new Set([projectName]));
|
152
172
|
}
|
153
173
|
});
|
154
|
-
if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size === 0) {
|
155
|
-
const errorMsg = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, "f")
|
156
|
-
? `Project "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, "f")}" does not contain any targets using the "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")}" executor. Please select a project that does.`
|
157
|
-
: `Could not find any targets using the "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")}" executor.`;
|
158
|
-
throw new Error(errorMsg);
|
159
|
-
}
|
160
174
|
}, _ExecutorToPluginMigrator_getTargetDefaultsForExecutor = function _ExecutorToPluginMigrator_getTargetDefaultsForExecutor() {
|
161
175
|
tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_nxJson, "f").targetDefaults?.[tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")], "f");
|
162
176
|
}, _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot = function _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot(targetName, projectRoot) {
|
@@ -166,6 +180,9 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
166
180
|
delete createdTarget.options?.cwd;
|
167
181
|
return createdTarget;
|
168
182
|
}, _ExecutorToPluginMigrator_getCreateNodesResults = async function _ExecutorToPluginMigrator_getCreateNodesResults() {
|
183
|
+
if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size === 0) {
|
184
|
+
return;
|
185
|
+
}
|
169
186
|
for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
|
170
187
|
const loadedPlugin = new devkit_internals_1.LoadedNxPlugin({
|
171
188
|
createNodes: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodes, "f"),
|
@@ -192,6 +209,6 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
|
|
192
209
|
};
|
193
210
|
async function migrateExecutorToPlugin(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter) {
|
194
211
|
const migrator = new ExecutorToPluginMigrator(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter);
|
195
|
-
await migrator.run();
|
212
|
+
return await migrator.run();
|
196
213
|
}
|
197
214
|
exports.migrateExecutorToPlugin = migrateExecutorToPlugin;
|