@nx/devkit 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba
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/package.json +5 -4
- package/public-api.d.ts +1 -1
- package/public-api.js +2 -1
- package/src/executors/parse-target-string.d.ts +1 -3
- package/src/executors/parse-target-string.js +5 -9
- package/src/executors/read-target-options.d.ts +1 -2
- package/src/executors/read-target-options.js +4 -17
- package/src/generators/add-build-target-defaults.d.ts +1 -1
- package/src/generators/add-build-target-defaults.js +3 -4
- package/src/generators/artifact-name-and-directory-utils.d.ts +1 -1
- package/src/generators/artifact-name-and-directory-utils.js +37 -26
- package/src/generators/executor-options-utils.d.ts +1 -2
- package/src/generators/executor-options-utils.js +3 -6
- package/src/generators/format-files.d.ts +1 -1
- package/src/generators/format-files.js +5 -8
- package/src/generators/generate-files.d.ts +20 -2
- package/src/generators/generate-files.js +27 -5
- package/src/generators/plugin-migrations/executor-to-plugin-migrator.d.ts +10 -0
- package/src/generators/plugin-migrations/executor-to-plugin-migrator.js +286 -0
- package/src/generators/plugin-migrations/plugin-migration-utils.d.ts +62 -0
- package/src/generators/plugin-migrations/plugin-migration-utils.js +143 -0
- package/src/generators/project-name-and-root-utils.d.ts +1 -2
- package/src/generators/project-name-and-root-utils.js +16 -17
- package/src/generators/run-tasks-in-serial.d.ts +1 -1
- package/src/generators/to-js.d.ts +1 -1
- package/src/generators/update-ts-configs-to-js.d.ts +1 -1
- package/src/generators/update-ts-configs-to-js.js +3 -4
- package/src/generators/visit-not-ignored-files.d.ts +1 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +1 -1
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.d.ts +1 -2
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.js +2 -3
- package/src/tasks/install-packages-task.d.ts +1 -2
- package/src/tasks/install-packages-task.js +5 -6
- package/src/utils/add-plugin.d.ts +13 -0
- package/src/utils/add-plugin.js +258 -0
- package/src/utils/async-iterable/combine-async-iterables.js +4 -2
- package/src/utils/binary-extensions.js +4 -0
- package/src/utils/calculate-hash-for-create-nodes.d.ts +2 -2
- package/src/utils/calculate-hash-for-create-nodes.js +6 -6
- package/src/utils/config-utils.d.ts +1 -0
- package/src/utils/config-utils.js +23 -11
- package/src/utils/convert-nx-executor.d.ts +1 -1
- package/src/utils/convert-nx-executor.js +21 -17
- package/src/utils/get-named-inputs.d.ts +1 -1
- package/src/utils/get-named-inputs.js +3 -4
- package/src/utils/get-workspace-layout.d.ts +1 -1
- package/src/utils/get-workspace-layout.js +2 -3
- package/src/utils/invoke-nx-generator.d.ts +1 -1
- package/src/utils/invoke-nx-generator.js +3 -5
- package/src/utils/log-show-project-command.js +2 -3
- package/src/utils/move-dir.d.ts +1 -1
- package/src/utils/move-dir.js +3 -4
- package/src/utils/package-json.d.ts +1 -2
- package/src/utils/package-json.js +13 -13
- package/src/utils/replace-package.d.ts +1 -1
- package/src/utils/replace-package.js +8 -9
- package/src/utils/replace-project-configuration-with-plugin.d.ts +1 -2
- package/src/utils/replace-project-configuration-with-plugin.js +12 -11
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/nx.d.ts +0 -1
- package/nx.js +0 -19
- package/src/utils/update-package-scripts.d.ts +0 -3
- package/src/utils/update-package-scripts.js +0 -175
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateTsConfigsToJs = void 0;
|
|
4
|
-
const
|
|
5
|
-
const { updateJson } = (0, nx_1.requireNx)();
|
|
4
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
5
|
function updateTsConfigsToJs(tree, options) {
|
|
7
6
|
let updateConfigPath;
|
|
8
7
|
const paths = {
|
|
@@ -19,7 +18,7 @@ function updateTsConfigsToJs(tree, options) {
|
|
|
19
18
|
}
|
|
20
19
|
throw new Error(`project is missing tsconfig.lib.json or tsconfig.app.json`);
|
|
21
20
|
};
|
|
22
|
-
updateJson(tree, paths.tsConfig, (json) => {
|
|
21
|
+
(0, devkit_exports_1.updateJson)(tree, paths.tsConfig, (json) => {
|
|
23
22
|
if (json.compilerOptions) {
|
|
24
23
|
json.compilerOptions.allowJs = true;
|
|
25
24
|
}
|
|
@@ -35,7 +34,7 @@ function updateTsConfigsToJs(tree, options) {
|
|
|
35
34
|
if (projectType === 'application') {
|
|
36
35
|
updateConfigPath = paths.tsConfigApp;
|
|
37
36
|
}
|
|
38
|
-
updateJson(tree, updateConfigPath, (json) => {
|
|
37
|
+
(0, devkit_exports_1.updateJson)(tree, updateConfigPath, (json) => {
|
|
39
38
|
json.include = uniq([...json.include, 'src/**/*.js']);
|
|
40
39
|
json.exclude = uniq([
|
|
41
40
|
...json.exclude,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Tree } from 'nx/src/
|
|
1
|
+
import type { Tree } from 'nx/src/devkit-exports';
|
|
2
2
|
export default function replacePackage(tree: Tree): Promise<void>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
|
1
|
+
import { GeneratorCallback, Tree } from 'nx/src/devkit-exports';
|
|
3
2
|
declare const _default: (tree: Tree) => Promise<GeneratorCallback | void>;
|
|
4
3
|
export default _default;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const visit_not_ignored_files_1 = require("../../generators/visit-not-ignored-files");
|
|
4
4
|
const format_files_1 = require("../../generators/format-files");
|
|
5
|
-
const nx_1 = require("../../../nx");
|
|
6
5
|
const package_json_1 = require("../../utils/package-json");
|
|
7
6
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
const
|
|
7
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
9
8
|
let tsModule;
|
|
10
9
|
const MODULE_FEDERATION_PUBLIC_TOKENS = [
|
|
11
10
|
'AdditionalSharedConfig',
|
|
@@ -45,7 +44,7 @@ exports.default = async (tree) => {
|
|
|
45
44
|
});
|
|
46
45
|
if (hasFileToMigrate) {
|
|
47
46
|
await (0, format_files_1.formatFiles)(tree);
|
|
48
|
-
const pkgJson = readJson(tree, 'package.json');
|
|
47
|
+
const pkgJson = (0, devkit_exports_1.readJson)(tree, 'package.json');
|
|
49
48
|
const nxVersion = pkgJson.devDependencies?.['nx'] ??
|
|
50
49
|
pkgJson.dependencies?.['nx'] ??
|
|
51
50
|
'17.0.0';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { PackageManager } from 'nx/src/utils/package-manager';
|
|
1
|
+
import { PackageManager, Tree } from 'nx/src/devkit-exports';
|
|
3
2
|
/**
|
|
4
3
|
* Runs `npm install` or `yarn install`. It will skip running the install if
|
|
5
4
|
* `package.json` hasn't changed at all or it hasn't changed since the last invocation.
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.installPackagesTask = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
7
|
-
const { detectPackageManager, getPackageManagerCommand, joinPathFragments } = (0, nx_1.requireNx)();
|
|
6
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
8
7
|
/**
|
|
9
8
|
* Runs `npm install` or `yarn install`. It will skip running the install if
|
|
10
9
|
* `package.json` hasn't changed at all or it hasn't changed since the last invocation.
|
|
@@ -12,19 +11,19 @@ const { detectPackageManager, getPackageManagerCommand, joinPathFragments } = (0
|
|
|
12
11
|
* @param tree - the file system tree
|
|
13
12
|
* @param alwaysRun - always run the command even if `package.json` hasn't changed.
|
|
14
13
|
*/
|
|
15
|
-
function installPackagesTask(tree, alwaysRun = false, cwd = '', packageManager = detectPackageManager(cwd)) {
|
|
14
|
+
function installPackagesTask(tree, alwaysRun = false, cwd = '', packageManager = (0, devkit_exports_1.detectPackageManager)(cwd)) {
|
|
16
15
|
if (!tree
|
|
17
16
|
.listChanges()
|
|
18
|
-
.find((f) => f.path === joinPathFragments(cwd, 'package.json')) &&
|
|
17
|
+
.find((f) => f.path === (0, devkit_exports_1.joinPathFragments)(cwd, 'package.json')) &&
|
|
19
18
|
!alwaysRun) {
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
|
-
const packageJsonValue = tree.read(joinPathFragments(cwd, 'package.json'), 'utf-8');
|
|
21
|
+
const packageJsonValue = tree.read((0, devkit_exports_1.joinPathFragments)(cwd, 'package.json'), 'utf-8');
|
|
23
22
|
let storedPackageJsonValue = global['__packageJsonInstallCache__'];
|
|
24
23
|
// Don't install again if install was already executed with package.json
|
|
25
24
|
if (storedPackageJsonValue != packageJsonValue || alwaysRun) {
|
|
26
25
|
global['__packageJsonInstallCache__'] = packageJsonValue;
|
|
27
|
-
const pmc = getPackageManagerCommand(packageManager);
|
|
26
|
+
const pmc = (0, devkit_exports_1.getPackageManagerCommand)(packageManager);
|
|
28
27
|
const execSyncOptions = {
|
|
29
28
|
cwd: (0, path_1.join)(tree.root, cwd),
|
|
30
29
|
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CreateNodes, CreateNodesV2, ProjectGraph, Tree } from 'nx/src/devkit-exports';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates through various forms of plugin options to find the one which does not conflict with the current graph
|
|
4
|
+
|
|
5
|
+
*/
|
|
6
|
+
export declare function addPlugin<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodesV2<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `addPlugin` instead
|
|
9
|
+
* Iterates through various forms of plugin options to find the one which does not conflict with the current graph
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
export declare function addPluginV1<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodes<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
|
|
13
|
+
export declare function generateCombinations<T>(input: Record<string, T[]>): Record<string, T>[];
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCombinations = exports.addPluginV1 = exports.addPlugin = void 0;
|
|
4
|
+
const yargs = require("yargs-parser");
|
|
5
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
7
|
+
/**
|
|
8
|
+
* Iterates through various forms of plugin options to find the one which does not conflict with the current graph
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
async function addPlugin(tree, graph, pluginName, createNodesTuple, options, shouldUpdatePackageJsonScripts) {
|
|
12
|
+
return _addPluginInternal(tree, graph, pluginName, (pluginOptions) => new devkit_internals_1.LoadedNxPlugin({
|
|
13
|
+
name: pluginName,
|
|
14
|
+
createNodesV2: createNodesTuple,
|
|
15
|
+
}, {
|
|
16
|
+
plugin: pluginName,
|
|
17
|
+
options: pluginOptions,
|
|
18
|
+
}), options, shouldUpdatePackageJsonScripts);
|
|
19
|
+
}
|
|
20
|
+
exports.addPlugin = addPlugin;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use `addPlugin` instead
|
|
23
|
+
* Iterates through various forms of plugin options to find the one which does not conflict with the current graph
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
async function addPluginV1(tree, graph, pluginName, createNodesTuple, options, shouldUpdatePackageJsonScripts) {
|
|
27
|
+
return _addPluginInternal(tree, graph, pluginName, (pluginOptions) => new devkit_internals_1.LoadedNxPlugin({
|
|
28
|
+
name: pluginName,
|
|
29
|
+
createNodes: createNodesTuple,
|
|
30
|
+
}, {
|
|
31
|
+
plugin: pluginName,
|
|
32
|
+
options: pluginOptions,
|
|
33
|
+
}), options, shouldUpdatePackageJsonScripts);
|
|
34
|
+
}
|
|
35
|
+
exports.addPluginV1 = addPluginV1;
|
|
36
|
+
async function _addPluginInternal(tree, graph, pluginName, pluginFactory, options, shouldUpdatePackageJsonScripts) {
|
|
37
|
+
const graphNodes = Object.values(graph.nodes);
|
|
38
|
+
const nxJson = (0, devkit_exports_1.readNxJson)(tree);
|
|
39
|
+
let pluginOptions;
|
|
40
|
+
let projConfigs;
|
|
41
|
+
const combinations = generateCombinations(options);
|
|
42
|
+
optionsLoop: for (const _pluginOptions of combinations) {
|
|
43
|
+
pluginOptions = _pluginOptions;
|
|
44
|
+
nxJson.plugins ??= [];
|
|
45
|
+
if (nxJson.plugins.some((p) => typeof p === 'string'
|
|
46
|
+
? p === pluginName
|
|
47
|
+
: p.plugin === pluginName && !p.include)) {
|
|
48
|
+
// Plugin has already been added
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
global.NX_GRAPH_CREATION = true;
|
|
52
|
+
try {
|
|
53
|
+
projConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)([pluginFactory(pluginOptions)], tree.root, nxJson);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
// Errors are okay for this because we're only running 1 plugin
|
|
57
|
+
if (e instanceof devkit_internals_1.ProjectConfigurationsError) {
|
|
58
|
+
projConfigs = e.partialProjectConfigurationsResult;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
global.NX_GRAPH_CREATION = false;
|
|
65
|
+
for (const projConfig of Object.values(projConfigs.projects)) {
|
|
66
|
+
const node = graphNodes.find((node) => node.data.root === projConfig.root);
|
|
67
|
+
if (!node) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const targetName in projConfig.targets) {
|
|
71
|
+
if (node.data.targets[targetName]) {
|
|
72
|
+
// Conflicting Target Name, check the next one
|
|
73
|
+
pluginOptions = null;
|
|
74
|
+
continue optionsLoop;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (!pluginOptions) {
|
|
81
|
+
throw new Error('Could not add the plugin in a way which does not conflict with existing targets. Please report this error at: https://github.com/nrwl/nx/issues/new/choose');
|
|
82
|
+
}
|
|
83
|
+
nxJson.plugins.push({
|
|
84
|
+
plugin: pluginName,
|
|
85
|
+
options: pluginOptions,
|
|
86
|
+
});
|
|
87
|
+
(0, devkit_exports_1.updateNxJson)(tree, nxJson);
|
|
88
|
+
if (shouldUpdatePackageJsonScripts) {
|
|
89
|
+
updatePackageScripts(tree, projConfigs);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function updatePackageScripts(tree, projectConfigurations) {
|
|
93
|
+
for (const projectConfig of Object.values(projectConfigurations.projects)) {
|
|
94
|
+
const projectRoot = projectConfig.root;
|
|
95
|
+
processProject(tree, projectRoot, projectConfig);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function processProject(tree, projectRoot, projectConfiguration) {
|
|
99
|
+
const packageJsonPath = `${projectRoot}/package.json`;
|
|
100
|
+
if (!tree.exists(packageJsonPath)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const packageJson = (0, devkit_exports_1.readJson)(tree, packageJsonPath);
|
|
104
|
+
if (!packageJson.scripts || !Object.keys(packageJson.scripts).length) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const targetCommands = getInferredTargetCommands(projectConfiguration);
|
|
108
|
+
if (!targetCommands.length) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const replacedTargets = new Set();
|
|
112
|
+
for (const targetCommand of targetCommands) {
|
|
113
|
+
const { command, target, configuration } = targetCommand;
|
|
114
|
+
const targetCommandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${command})((?: [^&\\r\\n\\s]+)*(?: )*)(?=$|&)`, 'g');
|
|
115
|
+
for (const scriptName of Object.keys(packageJson.scripts)) {
|
|
116
|
+
const script = packageJson.scripts[scriptName];
|
|
117
|
+
// quick check for exact match within the script
|
|
118
|
+
if (targetCommandRegex.test(script)) {
|
|
119
|
+
packageJson.scripts[scriptName] = script.replace(targetCommandRegex, configuration
|
|
120
|
+
? `$1nx ${target} --configuration=${configuration}$3`
|
|
121
|
+
: `$1nx ${target}$3`);
|
|
122
|
+
replacedTargets.add(target);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
/**
|
|
126
|
+
* Parse script and command to handle the following:
|
|
127
|
+
* - if command doesn't match script => don't replace
|
|
128
|
+
* - if command has more args => don't replace
|
|
129
|
+
* - if command has same args, regardless of order => replace removing args
|
|
130
|
+
* - if command has less args or with different value => replace leaving args
|
|
131
|
+
*/
|
|
132
|
+
const parsedCommand = yargs(command, {
|
|
133
|
+
configuration: { 'strip-dashed': true },
|
|
134
|
+
});
|
|
135
|
+
// this assumes there are no positional args in the command, everything is a command or subcommand
|
|
136
|
+
const commandCommand = parsedCommand._.join(' ');
|
|
137
|
+
const commandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${commandCommand})((?: [^&\\r\\n\\s]+)*( )*)(?=$|&)`, 'g');
|
|
138
|
+
const matches = script.match(commandRegex);
|
|
139
|
+
if (!matches) {
|
|
140
|
+
// the command doesn't match the script, don't replace
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
for (const match of matches) {
|
|
144
|
+
// parse the matched command within the script
|
|
145
|
+
const parsedScript = yargs(match, {
|
|
146
|
+
configuration: { 'strip-dashed': true },
|
|
147
|
+
});
|
|
148
|
+
let hasArgsWithDifferentValues = false;
|
|
149
|
+
let scriptHasExtraArgs = false;
|
|
150
|
+
let commandHasExtraArgs = false;
|
|
151
|
+
for (const [key, value] of Object.entries(parsedCommand)) {
|
|
152
|
+
if (key === '_') {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (parsedScript[key] === undefined) {
|
|
156
|
+
commandHasExtraArgs = true;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (parsedScript[key] !== value) {
|
|
160
|
+
hasArgsWithDifferentValues = true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (commandHasExtraArgs) {
|
|
164
|
+
// the command has extra args, don't replace
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
for (const key of Object.keys(parsedScript)) {
|
|
168
|
+
if (key === '_') {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!parsedCommand[key]) {
|
|
172
|
+
scriptHasExtraArgs = true;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!hasArgsWithDifferentValues && !scriptHasExtraArgs) {
|
|
177
|
+
// they are the same, replace with the command removing the args
|
|
178
|
+
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
179
|
+
? `$1nx ${target} --configuration=${configuration}$4`
|
|
180
|
+
: `$1nx ${target}$4`));
|
|
181
|
+
replacedTargets.add(target);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// there are different args or the script has extra args, replace with the command leaving the args
|
|
185
|
+
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
186
|
+
? `$1nx ${target} --configuration=${configuration}$3`
|
|
187
|
+
: `$1nx ${target}$3`));
|
|
188
|
+
replacedTargets.add(target);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
(0, devkit_exports_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
195
|
+
}
|
|
196
|
+
function getInferredTargetCommands(project) {
|
|
197
|
+
const targetCommands = [];
|
|
198
|
+
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
199
|
+
if (target.command) {
|
|
200
|
+
targetCommands.push({ command: target.command, target: targetName });
|
|
201
|
+
}
|
|
202
|
+
else if (target.executor === 'nx:run-commands' &&
|
|
203
|
+
target.options?.command) {
|
|
204
|
+
targetCommands.push({
|
|
205
|
+
command: target.options.command,
|
|
206
|
+
target: targetName,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (!target.configurations) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
for (const [configurationName, configuration] of Object.entries(target.configurations)) {
|
|
213
|
+
if (configuration.command) {
|
|
214
|
+
targetCommands.push({
|
|
215
|
+
command: configuration.command,
|
|
216
|
+
target: targetName,
|
|
217
|
+
configuration: configurationName,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else if (target.executor === 'nx:run-commands' &&
|
|
221
|
+
configuration.options?.command) {
|
|
222
|
+
targetCommands.push({
|
|
223
|
+
command: configuration.options.command,
|
|
224
|
+
target: targetName,
|
|
225
|
+
configuration: configurationName,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return targetCommands;
|
|
231
|
+
}
|
|
232
|
+
function generateCombinations(input) {
|
|
233
|
+
// This is reversed so that combinations have the first defined property updated first
|
|
234
|
+
const keys = Object.keys(input).reverse();
|
|
235
|
+
return _generateCombinations(Object.values(input).reverse()).map((combination) => {
|
|
236
|
+
const result = {};
|
|
237
|
+
combination.reverse().forEach((combo, i) => {
|
|
238
|
+
result[keys[keys.length - i - 1]] = combo;
|
|
239
|
+
});
|
|
240
|
+
return result;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
exports.generateCombinations = generateCombinations;
|
|
244
|
+
/**
|
|
245
|
+
* Generate all possible combinations of a 2-dimensional array.
|
|
246
|
+
*
|
|
247
|
+
* Useful for generating all possible combinations of options for a plugin
|
|
248
|
+
*/
|
|
249
|
+
function _generateCombinations(input) {
|
|
250
|
+
if (input.length === 0) {
|
|
251
|
+
return [[]];
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
const [first, ...rest] = input;
|
|
255
|
+
const partialCombinations = _generateCombinations(rest);
|
|
256
|
+
return first.flatMap((value) => partialCombinations.map((combination) => [value, ...combination]));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -24,8 +24,8 @@ async function* combineAsyncIterables(..._iterators) {
|
|
|
24
24
|
iterators.shift();
|
|
25
25
|
}
|
|
26
26
|
const getNextAsyncIteratorValue = getNextAsyncIteratorFactory(options);
|
|
27
|
+
const asyncIteratorsValues = new Map(iterators.map((it, idx) => [idx, getNextAsyncIteratorValue(it, idx)]));
|
|
27
28
|
try {
|
|
28
|
-
const asyncIteratorsValues = new Map(iterators.map((it, idx) => [idx, getNextAsyncIteratorValue(it, idx)]));
|
|
29
29
|
do {
|
|
30
30
|
const { iterator, index } = await Promise.race(asyncIteratorsValues.values());
|
|
31
31
|
if (iterator.done) {
|
|
@@ -38,7 +38,9 @@ async function* combineAsyncIterables(..._iterators) {
|
|
|
38
38
|
} while (asyncIteratorsValues.size > 0);
|
|
39
39
|
}
|
|
40
40
|
finally {
|
|
41
|
-
|
|
41
|
+
for (const [index, iterator] of asyncIteratorsValues.entries())
|
|
42
|
+
if (iterator?.['return'] !== null)
|
|
43
|
+
iterator['return']?.();
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
exports.combineAsyncIterables = combineAsyncIterables;
|
|
@@ -15,6 +15,7 @@ const binaryExtensions = new Set([
|
|
|
15
15
|
'.ai',
|
|
16
16
|
'.aif',
|
|
17
17
|
'.aiff',
|
|
18
|
+
'.als',
|
|
18
19
|
'.alz',
|
|
19
20
|
'.ape',
|
|
20
21
|
'.apk',
|
|
@@ -139,6 +140,7 @@ const binaryExtensions = new Set([
|
|
|
139
140
|
'.mxu',
|
|
140
141
|
'.nef',
|
|
141
142
|
'.npx',
|
|
143
|
+
'.npy',
|
|
142
144
|
'.numbers',
|
|
143
145
|
'.nupkg',
|
|
144
146
|
'.o',
|
|
@@ -159,6 +161,8 @@ const binaryExtensions = new Set([
|
|
|
159
161
|
'.pea',
|
|
160
162
|
'.pgm',
|
|
161
163
|
'.pic',
|
|
164
|
+
'.pkg',
|
|
165
|
+
'.plist',
|
|
162
166
|
'.png',
|
|
163
167
|
'.pnm',
|
|
164
168
|
'.pot',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext, additionalGlobs?: string[]): string
|
|
1
|
+
import { CreateNodesContext } from 'nx/src/devkit-exports';
|
|
2
|
+
export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext, additionalGlobs?: string[]): Promise<string>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateHashForCreateNodes = void 0;
|
|
4
|
-
const nx_1 = require("../../nx");
|
|
5
4
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
7
|
+
async function calculateHashForCreateNodes(projectRoot, options, context, additionalGlobs = []) {
|
|
8
|
+
return (0, devkit_exports_1.hashArray)([
|
|
9
|
+
await (0, devkit_internals_1.hashWithWorkspaceContext)(context.workspaceRoot, [
|
|
10
10
|
(0, path_1.join)(projectRoot, '**/*'),
|
|
11
11
|
...additionalGlobs,
|
|
12
12
|
]),
|
|
13
|
-
hashObject(options),
|
|
13
|
+
(0, devkit_internals_1.hashObject)(options),
|
|
14
14
|
]);
|
|
15
15
|
}
|
|
16
16
|
exports.calculateHashForCreateNodes = calculateHashForCreateNodes;
|
|
@@ -2,3 +2,4 @@ export declare let dynamicImport: Function;
|
|
|
2
2
|
export declare function loadConfigFile<T extends object = any>(configFilePath: string): Promise<T>;
|
|
3
3
|
export declare function getRootTsConfigPath(): string | null;
|
|
4
4
|
export declare function getRootTsConfigFileName(): string | null;
|
|
5
|
+
export declare function clearRequireCache(): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRootTsConfigFileName = exports.getRootTsConfigPath = exports.loadConfigFile = exports.dynamicImport = void 0;
|
|
3
|
+
exports.clearRequireCache = exports.getRootTsConfigFileName = exports.getRootTsConfigPath = exports.loadConfigFile = exports.dynamicImport = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const node_url_1 = require("node:url");
|
|
7
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
8
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
8
9
|
exports.dynamicImport = new Function('modulePath', 'return import(modulePath);');
|
|
9
10
|
async function loadConfigFile(configFilePath) {
|
|
10
11
|
{
|
|
@@ -15,7 +16,7 @@ async function loadConfigFile(configFilePath) {
|
|
|
15
16
|
? (0, path_1.join)((0, path_1.dirname)(configFilePath), 'tsconfig.json')
|
|
16
17
|
: getRootTsConfigPath();
|
|
17
18
|
if (tsConfigPath) {
|
|
18
|
-
const unregisterTsProject = registerTsProject(tsConfigPath);
|
|
19
|
+
const unregisterTsProject = (0, devkit_internals_1.registerTsProject)(tsConfigPath);
|
|
19
20
|
try {
|
|
20
21
|
module = await load(configFilePath);
|
|
21
22
|
}
|
|
@@ -36,12 +37,12 @@ async function loadConfigFile(configFilePath) {
|
|
|
36
37
|
exports.loadConfigFile = loadConfigFile;
|
|
37
38
|
function getRootTsConfigPath() {
|
|
38
39
|
const tsConfigFileName = getRootTsConfigFileName();
|
|
39
|
-
return tsConfigFileName ? (0, path_1.join)(workspaceRoot, tsConfigFileName) : null;
|
|
40
|
+
return tsConfigFileName ? (0, path_1.join)(devkit_exports_1.workspaceRoot, tsConfigFileName) : null;
|
|
40
41
|
}
|
|
41
42
|
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
42
43
|
function getRootTsConfigFileName() {
|
|
43
44
|
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
44
|
-
const pathExists = (0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, tsConfigName));
|
|
45
|
+
const pathExists = (0, fs_1.existsSync)((0, path_1.join)(devkit_exports_1.workspaceRoot, tsConfigName));
|
|
45
46
|
if (pathExists) {
|
|
46
47
|
return tsConfigName;
|
|
47
48
|
}
|
|
@@ -49,15 +50,25 @@ function getRootTsConfigFileName() {
|
|
|
49
50
|
return null;
|
|
50
51
|
}
|
|
51
52
|
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
|
53
|
+
const packageInstallationDirectories = [
|
|
54
|
+
`${path_1.sep}node_modules${path_1.sep}`,
|
|
55
|
+
`${path_1.sep}.yarn${path_1.sep}`,
|
|
56
|
+
];
|
|
57
|
+
function clearRequireCache() {
|
|
58
|
+
for (const k of Object.keys(require.cache)) {
|
|
59
|
+
if (!packageInstallationDirectories.some((dir) => k.includes(dir))) {
|
|
60
|
+
delete require.cache[k];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.clearRequireCache = clearRequireCache;
|
|
52
65
|
/**
|
|
53
66
|
* Load the module after ensuring that the require cache is cleared.
|
|
54
67
|
*/
|
|
55
68
|
async function load(path) {
|
|
56
69
|
// Clear cache if the path is in the cache
|
|
57
70
|
if (require.cache[path]) {
|
|
58
|
-
|
|
59
|
-
delete require.cache[k];
|
|
60
|
-
}
|
|
71
|
+
clearRequireCache();
|
|
61
72
|
}
|
|
62
73
|
try {
|
|
63
74
|
// Try using `require` first, which works for CJS modules.
|
|
@@ -66,8 +77,9 @@ async function load(path) {
|
|
|
66
77
|
}
|
|
67
78
|
catch (e) {
|
|
68
79
|
if (e.code === 'ERR_REQUIRE_ESM') {
|
|
69
|
-
// If `require` fails to load ESM, try dynamic `import()`.
|
|
70
|
-
|
|
80
|
+
// If `require` fails to load ESM, try dynamic `import()`. ESM requires file url protocol for handling absolute paths.
|
|
81
|
+
const pathAsFileUrl = (0, node_url_1.pathToFileURL)(path).pathname;
|
|
82
|
+
return await (0, exports.dynamicImport)(`${pathAsFileUrl}?t=${Date.now()}`);
|
|
71
83
|
}
|
|
72
84
|
// Re-throw all other errors
|
|
73
85
|
throw e;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertNxExecutor = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const package_json_1 = require("./package-json");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
6
7
|
/**
|
|
7
8
|
* Convert an Nx Executor into an Angular Devkit Builder
|
|
8
9
|
*
|
|
@@ -11,22 +12,25 @@ const { Workspaces, readNxJsonFromDisk, retrieveProjectConfigurationsWithAngular
|
|
|
11
12
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
12
13
|
function convertNxExecutor(executor) {
|
|
13
14
|
const builderFunction = (options, builderContext) => {
|
|
14
|
-
const
|
|
15
|
-
const nxJsonConfiguration = readNxJsonFromDisk
|
|
16
|
-
? readNxJsonFromDisk(builderContext.workspaceRoot)
|
|
17
|
-
: // TODO(v19): remove readNxJson. This is to be backwards compatible with Nx 16.5 and below.
|
|
18
|
-
workspaces.readNxJson();
|
|
15
|
+
const nxJsonConfiguration = (0, devkit_internals_1.readNxJsonFromDisk)(builderContext.workspaceRoot);
|
|
19
16
|
const promise = async () => {
|
|
20
|
-
const projectsConfigurations =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
const projectsConfigurations = {
|
|
18
|
+
version: 2,
|
|
19
|
+
projects: await (0, devkit_internals_1.retrieveProjectConfigurationsWithAngularProjects)(builderContext.workspaceRoot, nxJsonConfiguration).then((p) => {
|
|
20
|
+
if (p.projectNodes) {
|
|
21
|
+
return p.projectNodes;
|
|
22
|
+
}
|
|
23
|
+
// v18.3.4 changed projects to be keyed by root
|
|
24
|
+
// rather than project name
|
|
25
|
+
if ((0, semver_1.lt)(package_json_1.NX_VERSION, '18.3.4')) {
|
|
26
|
+
return p.projects;
|
|
27
|
+
}
|
|
28
|
+
if (devkit_internals_1.readProjectConfigurationsFromRootMap) {
|
|
29
|
+
return (0, devkit_internals_1.readProjectConfigurationsFromRootMap)(p.projects);
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Unable to successfully map Nx executor -> Angular Builder');
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
30
34
|
const context = {
|
|
31
35
|
root: builderContext.workspaceRoot,
|
|
32
36
|
projectName: builderContext.target.project,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CreateNodesContext } from 'nx/src/devkit-exports';
|
|
2
1
|
import type { InputDefinition } from 'nx/src/config/workspace-json-project-json';
|
|
2
|
+
import { CreateNodesContext } from 'nx/src/devkit-exports';
|
|
3
3
|
/**
|
|
4
4
|
* Get the named inputs available for a directory
|
|
5
5
|
*/
|
|
@@ -3,19 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNamedInputs = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const
|
|
7
|
-
const { readJsonFile } = (0, nx_1.requireNx)();
|
|
6
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
8
7
|
/**
|
|
9
8
|
* Get the named inputs available for a directory
|
|
10
9
|
*/
|
|
11
10
|
function getNamedInputs(directory, context) {
|
|
12
11
|
const projectJsonPath = (0, path_1.join)(directory, 'project.json');
|
|
13
12
|
const projectJson = (0, fs_1.existsSync)(projectJsonPath)
|
|
14
|
-
? readJsonFile(projectJsonPath)
|
|
13
|
+
? (0, devkit_exports_1.readJsonFile)(projectJsonPath)
|
|
15
14
|
: null;
|
|
16
15
|
const packageJsonPath = (0, path_1.join)(directory, 'package.json');
|
|
17
16
|
const packageJson = (0, fs_1.existsSync)(packageJsonPath)
|
|
18
|
-
? readJsonFile(packageJsonPath)
|
|
17
|
+
? (0, devkit_exports_1.readJsonFile)(packageJsonPath)
|
|
19
18
|
: null;
|
|
20
19
|
return {
|
|
21
20
|
...context.nxJsonConfiguration.namedInputs,
|