@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.extractLayoutDirectory = exports.getWorkspaceLayout = void 0;
|
|
4
|
-
const
|
|
5
|
-
const { readNxJson } = (0, nx_1.requireNx)();
|
|
4
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
5
|
/**
|
|
7
6
|
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
|
8
7
|
* and the default scope.
|
|
@@ -15,7 +14,7 @@ const { readNxJson } = (0, nx_1.requireNx)();
|
|
|
15
14
|
* @param tree - file system tree
|
|
16
15
|
*/
|
|
17
16
|
function getWorkspaceLayout(tree) {
|
|
18
|
-
const nxJson = readNxJson(tree);
|
|
17
|
+
const nxJson = (0, devkit_exports_1.readNxJson)(tree);
|
|
19
18
|
return {
|
|
20
19
|
appsDir: nxJson?.workspaceLayout?.appsDir ??
|
|
21
20
|
inOrderOfPreference(tree, ['apps', 'packages'], '.'),
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertNxGenerator = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
// TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
|
|
8
|
-
stripIndent = stripIndent ?? require('nx/src/utils/logger').stripIndent;
|
|
5
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
9
7
|
class RunCallbackTask {
|
|
10
8
|
constructor(callback) {
|
|
11
9
|
this.callback = callback;
|
|
@@ -166,7 +164,7 @@ class DevkitTreeFromAngularDevkitTree {
|
|
|
166
164
|
this.warnUnsupportedFilePermissionsChange(filePath, mode);
|
|
167
165
|
}
|
|
168
166
|
warnUnsupportedFilePermissionsChange(filePath, mode) {
|
|
169
|
-
logger.warn(stripIndent(`The Angular DevKit tree does not support changing a file permissions.
|
|
167
|
+
devkit_exports_1.logger.warn((0, devkit_internals_1.stripIndent)(`The Angular DevKit tree does not support changing a file permissions.
|
|
170
168
|
Ignoring changing ${filePath} permissions to ${mode}.`));
|
|
171
169
|
}
|
|
172
170
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logShowProjectCommand = void 0;
|
|
4
|
-
const
|
|
4
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
5
5
|
function logShowProjectCommand(projectName) {
|
|
6
|
-
|
|
7
|
-
output.log({
|
|
6
|
+
devkit_exports_1.output.log({
|
|
8
7
|
title: `👀 View Details of ${projectName}`,
|
|
9
8
|
bodyLines: [
|
|
10
9
|
`Run "nx show project ${projectName} --web" to view details about this project.`,
|
package/src/utils/move-dir.d.ts
CHANGED
package/src/utils/move-dir.js
CHANGED
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.moveFilesToNewDirectory = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const visit_not_ignored_files_1 = require("../generators/visit-not-ignored-files");
|
|
6
|
-
const
|
|
7
|
-
const { normalizePath } = (0, nx_1.requireNx)();
|
|
6
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
8
7
|
/**
|
|
9
8
|
* Analogous to cp -r oldDir newDir
|
|
10
9
|
*/
|
|
11
10
|
function moveFilesToNewDirectory(tree, oldDir, newDir) {
|
|
12
|
-
oldDir = normalizePath(oldDir);
|
|
13
|
-
newDir = normalizePath(newDir);
|
|
11
|
+
oldDir = (0, devkit_exports_1.normalizePath)(oldDir);
|
|
12
|
+
newDir = (0, devkit_exports_1.normalizePath)(newDir);
|
|
14
13
|
(0, visit_not_ignored_files_1.visitNotIgnoredFiles)(tree, oldDir, (file) => {
|
|
15
14
|
try {
|
|
16
15
|
tree.rename(file, `${newDir}/${(0, path_1.relative)(oldDir, file)}`);
|
|
@@ -5,11 +5,11 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
const module_1 = require("module");
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const install_packages_task_1 = require("../tasks/install-packages-task");
|
|
8
|
-
const nx_1 = require("../../nx");
|
|
9
8
|
const tmp_1 = require("tmp");
|
|
10
9
|
const path_1 = require("path");
|
|
10
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
11
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
11
12
|
const fs_1 = require("fs");
|
|
12
|
-
const { readJson, updateJson, getPackageManagerCommand, workspaceRoot, detectPackageManager, createTempNpmDirectory, getPackageManagerVersion, } = (0, nx_1.requireNx)();
|
|
13
13
|
const UNIDENTIFIED_VERSION = 'UNIDENTIFIED_VERSION';
|
|
14
14
|
const NON_SEMVER_TAGS = {
|
|
15
15
|
'*': 2,
|
|
@@ -90,7 +90,7 @@ function updateExistingDependenciesVersion(dependencies, existingDependencies =
|
|
|
90
90
|
* @returns Callback to install dependencies only if necessary, no-op otherwise
|
|
91
91
|
*/
|
|
92
92
|
function addDependenciesToPackageJson(tree, dependencies, devDependencies, packageJsonPath = 'package.json', keepExistingVersions) {
|
|
93
|
-
const currentPackageJson = readJson(tree, packageJsonPath);
|
|
93
|
+
const currentPackageJson = (0, devkit_exports_1.readJson)(tree, packageJsonPath);
|
|
94
94
|
/** Dependencies to install that are not met in dev dependencies */
|
|
95
95
|
let filteredDependencies = filterExistingDependencies(dependencies, currentPackageJson.devDependencies);
|
|
96
96
|
/** Dev dependencies to install that are not met in dependencies */
|
|
@@ -117,7 +117,7 @@ function addDependenciesToPackageJson(tree, dependencies, devDependencies, packa
|
|
|
117
117
|
filteredDevDependencies = removeLowerVersions(filteredDevDependencies, currentPackageJson.devDependencies);
|
|
118
118
|
}
|
|
119
119
|
if (requiresAddingOfPackages(currentPackageJson, filteredDependencies, filteredDevDependencies)) {
|
|
120
|
-
updateJson(tree, packageJsonPath, (json) => {
|
|
120
|
+
(0, devkit_exports_1.updateJson)(tree, packageJsonPath, (json) => {
|
|
121
121
|
json.dependencies = {
|
|
122
122
|
...(json.dependencies || {}),
|
|
123
123
|
...filteredDependencies,
|
|
@@ -171,9 +171,9 @@ function removeExistingDependencies(incomingDeps, existingDeps) {
|
|
|
171
171
|
* @returns Callback to uninstall dependencies only if necessary. undefined is returned if changes are not necessary.
|
|
172
172
|
*/
|
|
173
173
|
function removeDependenciesFromPackageJson(tree, dependencies, devDependencies, packageJsonPath = 'package.json') {
|
|
174
|
-
const currentPackageJson = readJson(tree, packageJsonPath);
|
|
174
|
+
const currentPackageJson = (0, devkit_exports_1.readJson)(tree, packageJsonPath);
|
|
175
175
|
if (requiresRemovingOfPackages(currentPackageJson, dependencies, devDependencies)) {
|
|
176
|
-
updateJson(tree, packageJsonPath, (json) => {
|
|
176
|
+
(0, devkit_exports_1.updateJson)(tree, packageJsonPath, (json) => {
|
|
177
177
|
for (const dep of dependencies) {
|
|
178
178
|
delete json.dependencies[dep];
|
|
179
179
|
}
|
|
@@ -291,14 +291,14 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
|
|
|
291
291
|
if (process.env.NX_DRY_RUN && process.env.NX_DRY_RUN !== 'false') {
|
|
292
292
|
throw new Error('NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.\n');
|
|
293
293
|
}
|
|
294
|
-
const { dir: tempDir } = createTempNpmDirectory?.() ?? {
|
|
294
|
+
const { dir: tempDir } = (0, devkit_internals_1.createTempNpmDirectory)?.() ?? {
|
|
295
295
|
dir: (0, tmp_1.dirSync)().name,
|
|
296
296
|
};
|
|
297
297
|
console.log(`Fetching ${pkg}...`);
|
|
298
|
-
const packageManager = detectPackageManager();
|
|
298
|
+
const packageManager = (0, devkit_exports_1.detectPackageManager)();
|
|
299
299
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
300
300
|
generatePackageManagerFiles(tempDir, packageManager);
|
|
301
|
-
const preInstallCommand = getPackageManagerCommand(packageManager).preInstall;
|
|
301
|
+
const preInstallCommand = (0, devkit_exports_1.getPackageManagerCommand)(packageManager).preInstall;
|
|
302
302
|
if (preInstallCommand) {
|
|
303
303
|
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
|
304
304
|
(0, child_process_1.execSync)(preInstallCommand, {
|
|
@@ -306,7 +306,7 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
|
|
|
306
306
|
stdio: isVerbose ? 'inherit' : 'ignore',
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
|
-
let addCommand = getPackageManagerCommand(packageManager).addDev;
|
|
309
|
+
let addCommand = (0, devkit_exports_1.getPackageManagerCommand)(packageManager).addDev;
|
|
310
310
|
if (packageManager === 'pnpm') {
|
|
311
311
|
addCommand = 'pnpm add -D'; // we need to ensure that we are not using workspace command
|
|
312
312
|
}
|
|
@@ -314,7 +314,7 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
|
|
|
314
314
|
cwd: tempDir,
|
|
315
315
|
stdio: isVerbose ? 'inherit' : 'ignore',
|
|
316
316
|
});
|
|
317
|
-
addToNodePath((0, path_1.join)(workspaceRoot, 'node_modules'));
|
|
317
|
+
addToNodePath((0, path_1.join)(devkit_exports_1.workspaceRoot, 'node_modules'));
|
|
318
318
|
addToNodePath((0, path_1.join)(tempDir, 'node_modules'));
|
|
319
319
|
// Re-initialize the added paths into require
|
|
320
320
|
module_1.Module._initPaths();
|
|
@@ -340,8 +340,8 @@ exports.ensurePackage = ensurePackage;
|
|
|
340
340
|
* Generates necessary files needed for the package manager to work
|
|
341
341
|
* and for the node_modules to be accessible.
|
|
342
342
|
*/
|
|
343
|
-
function generatePackageManagerFiles(root, packageManager = detectPackageManager()) {
|
|
344
|
-
const [pmMajor] = getPackageManagerVersion(packageManager).split('.');
|
|
343
|
+
function generatePackageManagerFiles(root, packageManager = (0, devkit_exports_1.detectPackageManager)()) {
|
|
344
|
+
const [pmMajor] = (0, devkit_exports_1.getPackageManagerVersion)(packageManager).split('.');
|
|
345
345
|
switch (packageManager) {
|
|
346
346
|
case 'yarn':
|
|
347
347
|
if (+pmMajor >= 2) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Tree } from 'nx/src/devkit-exports';
|
|
2
2
|
export declare function replaceNrwlPackageWithNxPackage(tree: Tree, oldPackageName: string, newPackageName: string): void;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replaceNrwlPackageWithNxPackage = void 0;
|
|
4
|
-
const
|
|
4
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
5
5
|
const visit_not_ignored_files_1 = require("../generators/visit-not-ignored-files");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const binary_extensions_1 = require("./binary-extensions");
|
|
8
|
-
const { logger } = (0, nx_1.requireNx)();
|
|
9
|
-
const { getProjects, updateProjectConfiguration, readNxJson, updateNxJson, updateJson, } = (0, nx_1.requireNx)();
|
|
10
8
|
function replaceNrwlPackageWithNxPackage(tree, oldPackageName, newPackageName) {
|
|
11
9
|
replacePackageInDependencies(tree, oldPackageName, newPackageName);
|
|
12
10
|
replacePackageInProjectConfigurations(tree, oldPackageName, newPackageName);
|
|
@@ -20,7 +18,7 @@ function replacePackageInDependencies(tree, oldPackageName, newPackageName) {
|
|
|
20
18
|
return;
|
|
21
19
|
}
|
|
22
20
|
try {
|
|
23
|
-
updateJson(tree, path, (packageJson) => {
|
|
21
|
+
(0, devkit_exports_1.updateJson)(tree, path, (packageJson) => {
|
|
24
22
|
for (const deps of [
|
|
25
23
|
packageJson.dependencies ?? {},
|
|
26
24
|
packageJson.devDependencies ?? {},
|
|
@@ -41,7 +39,7 @@ function replacePackageInDependencies(tree, oldPackageName, newPackageName) {
|
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
41
|
function replacePackageInProjectConfigurations(tree, oldPackageName, newPackageName) {
|
|
44
|
-
const projects = getProjects(tree);
|
|
42
|
+
const projects = (0, devkit_exports_1.getProjects)(tree);
|
|
45
43
|
for (const [projectName, projectConfiguration] of projects) {
|
|
46
44
|
let needsUpdate = false;
|
|
47
45
|
for (const [targetName, targetConfig] of Object.entries(projectConfiguration.targets ?? {})) {
|
|
@@ -63,7 +61,7 @@ function replacePackageInProjectConfigurations(tree, oldPackageName, newPackageN
|
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
if (needsUpdate) {
|
|
66
|
-
updateProjectConfiguration(tree, projectName, projectConfiguration);
|
|
64
|
+
(0, devkit_exports_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
}
|
|
@@ -71,7 +69,7 @@ function replacePackageInNxJson(tree, oldPackageName, newPackageName) {
|
|
|
71
69
|
if (!tree.exists('nx.json')) {
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
74
|
-
const nxJson = readNxJson(tree);
|
|
72
|
+
const nxJson = (0, devkit_exports_1.readNxJson)(tree);
|
|
75
73
|
let needsUpdate = false;
|
|
76
74
|
for (const [targetName, targetConfig] of Object.entries(nxJson.targetDefaults ?? {})) {
|
|
77
75
|
if (!targetConfig.executor) {
|
|
@@ -92,7 +90,7 @@ function replacePackageInNxJson(tree, oldPackageName, newPackageName) {
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
if (needsUpdate) {
|
|
95
|
-
updateNxJson(tree, nxJson);
|
|
93
|
+
(0, devkit_exports_1.updateNxJson)(tree, nxJson);
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
function replaceMentions(tree, oldPackageName, newPackageName) {
|
|
@@ -104,6 +102,7 @@ function replaceMentions(tree, oldPackageName, newPackageName) {
|
|
|
104
102
|
'yarn.lock',
|
|
105
103
|
'package-lock.json',
|
|
106
104
|
'pnpm-lock.yaml',
|
|
105
|
+
'bun.lockb',
|
|
107
106
|
'CHANGELOG.md',
|
|
108
107
|
];
|
|
109
108
|
if (ignoredFiles.includes((0, path_1.basename)(path))) {
|
|
@@ -119,7 +118,7 @@ function replaceMentions(tree, oldPackageName, newPackageName) {
|
|
|
119
118
|
catch {
|
|
120
119
|
// Its **probably** ok, contents can be null if the file is too large or
|
|
121
120
|
// there was an access exception.
|
|
122
|
-
logger.warn(`An error was thrown when trying to update ${path}. If you believe the migration should have updated it, be sure to review the file and open an issue.`);
|
|
121
|
+
devkit_exports_1.logger.warn(`An error was thrown when trying to update ${path}. If you believe the migration should have updated it, be sure to review the file and open an issue.`);
|
|
123
122
|
}
|
|
124
123
|
});
|
|
125
124
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { CreateNodes } from 'nx/src/utils/nx-plugin';
|
|
1
|
+
import { CreateNodes, Tree } from 'nx/src/devkit-exports';
|
|
3
2
|
export declare function replaceProjectConfigurationsWithPlugin<T = unknown>(tree: Tree, rootMappings: Map<string, string>, pluginPath: string, createNodes: CreateNodes<T>, pluginOptions: T): Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replaceProjectConfigurationsWithPlugin = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
5
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
6
6
|
async function replaceProjectConfigurationsWithPlugin(tree, rootMappings, pluginPath, createNodes, pluginOptions) {
|
|
7
|
-
const nxJson = readNxJson(tree);
|
|
7
|
+
const nxJson = (0, devkit_exports_1.readNxJson)(tree);
|
|
8
8
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string' ? p === pluginPath : p.plugin === pluginPath);
|
|
9
9
|
if (hasPlugin) {
|
|
10
10
|
return;
|
|
@@ -14,16 +14,17 @@ async function replaceProjectConfigurationsWithPlugin(tree, rootMappings, plugin
|
|
|
14
14
|
plugin: pluginPath,
|
|
15
15
|
options: pluginOptions,
|
|
16
16
|
});
|
|
17
|
-
updateNxJson(tree, nxJson);
|
|
17
|
+
(0, devkit_exports_1.updateNxJson)(tree, nxJson);
|
|
18
18
|
const [pluginGlob, createNodesFunction] = createNodes;
|
|
19
|
-
const configFiles = glob(tree, [pluginGlob]);
|
|
19
|
+
const configFiles = (0, devkit_exports_1.glob)(tree, [pluginGlob]);
|
|
20
20
|
for (const configFile of configFiles) {
|
|
21
21
|
try {
|
|
22
|
-
const projectName = findProjectForPath(configFile, rootMappings);
|
|
23
|
-
const projectConfig = readProjectConfiguration(tree, projectName);
|
|
22
|
+
const projectName = (0, devkit_internals_1.findProjectForPath)(configFile, rootMappings);
|
|
23
|
+
const projectConfig = (0, devkit_exports_1.readProjectConfiguration)(tree, projectName);
|
|
24
24
|
const nodes = await createNodesFunction(configFile, pluginOptions, {
|
|
25
25
|
workspaceRoot: tree.root,
|
|
26
|
-
nxJsonConfiguration: readNxJson(tree),
|
|
26
|
+
nxJsonConfiguration: (0, devkit_exports_1.readNxJson)(tree),
|
|
27
|
+
configFiles,
|
|
27
28
|
});
|
|
28
29
|
const node = nodes.projects[Object.keys(nodes.projects)[0]];
|
|
29
30
|
for (const [targetName, targetConfig] of Object.entries(node.targets)) {
|
|
@@ -34,7 +35,7 @@ async function replaceProjectConfigurationsWithPlugin(tree, rootMappings, plugin
|
|
|
34
35
|
const targetFromCreateNodes = node.targets[targetName];
|
|
35
36
|
removeConfigurationDefinedByPlugin(targetName, targetFromProjectConfig, targetFromCreateNodes, projectConfig);
|
|
36
37
|
}
|
|
37
|
-
updateProjectConfiguration(tree, projectName, projectConfig);
|
|
38
|
+
(0, devkit_exports_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
38
39
|
}
|
|
39
40
|
catch (e) {
|
|
40
41
|
console.error(e);
|
|
@@ -102,7 +103,7 @@ function equals(a, b) {
|
|
|
102
103
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
103
104
|
}
|
|
104
105
|
if (typeof a === 'object' && typeof b === 'object') {
|
|
105
|
-
return hashObject(a) === hashObject(b);
|
|
106
|
+
return (0, devkit_internals_1.hashObject)(a) === (0, devkit_internals_1.hashObject)(b);
|
|
106
107
|
}
|
|
107
108
|
return a === b;
|
|
108
109
|
}
|
|
@@ -121,7 +122,7 @@ function shouldRemoveArrayProperty(arrayValuesFromProjectConfiguration, arrayVal
|
|
|
121
122
|
else {
|
|
122
123
|
for (const arrayValue of setOfArrayValuesFromProjectConfiguration.values()) {
|
|
123
124
|
if (typeof arrayValue !== 'string' &&
|
|
124
|
-
hashObject(arrayValue) === hashObject(arrayValueFromCreateNodes)) {
|
|
125
|
+
(0, devkit_internals_1.hashObject)(arrayValue) === (0, devkit_internals_1.hashObject)(arrayValueFromCreateNodes)) {
|
|
125
126
|
setOfArrayValuesFromProjectConfiguration.delete(arrayValue);
|
|
126
127
|
// Continue the outer loop, breaking out of this loop
|
|
127
128
|
continue loopThroughArrayValuesFromCreateNodes;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const typescriptVersion = "~5.
|
|
1
|
+
export declare const typescriptVersion = "~5.4.2";
|
package/src/utils/versions.js
CHANGED
package/nx.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function requireNx(): typeof import('nx/src/devkit-exports') & Partial<typeof import('nx/src/devkit-internals')>;
|
package/nx.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireNx = void 0;
|
|
4
|
-
// After Nx v19, this can be removed and replaced with either:
|
|
5
|
-
// - import {} from 'nx/src/devkit-exports'
|
|
6
|
-
// - import {} from 'nx/src/devkit-internals'
|
|
7
|
-
function requireNx() {
|
|
8
|
-
let result = { ...require('nx/src/devkit-exports') };
|
|
9
|
-
try {
|
|
10
|
-
result = {
|
|
11
|
-
...result,
|
|
12
|
-
// Remove in Nx v19, devkit should not support Nx v16.0.2 at that point.
|
|
13
|
-
...require('nx/src/devkit-internals'),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
catch { }
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
exports.requireNx = requireNx;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updatePackageScripts = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const yargs = require("yargs-parser");
|
|
6
|
-
const nx_1 = require("../../nx");
|
|
7
|
-
const { glob, readJson, readNxJson, workspaceRoot, writeJson } = (0, nx_1.requireNx)();
|
|
8
|
-
async function updatePackageScripts(tree, createNodesTuple) {
|
|
9
|
-
const nxJson = readNxJson(tree);
|
|
10
|
-
const [pattern, createNodes] = createNodesTuple;
|
|
11
|
-
const files = glob(tree, [pattern]);
|
|
12
|
-
for (const file of files) {
|
|
13
|
-
const projectRoot = getProjectRootFromConfigFile(file);
|
|
14
|
-
await processProject(tree, projectRoot, file, createNodes, nxJson);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.updatePackageScripts = updatePackageScripts;
|
|
18
|
-
async function processProject(tree, projectRoot, projectConfigurationFile, createNodesFunction, nxJsonConfiguration) {
|
|
19
|
-
const packageJsonPath = `${projectRoot}/package.json`;
|
|
20
|
-
if (!tree.exists(packageJsonPath)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const packageJson = readJson(tree, packageJsonPath);
|
|
24
|
-
if (!packageJson.scripts || !Object.keys(packageJson.scripts).length) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const result = await createNodesFunction(projectConfigurationFile, {}, { nxJsonConfiguration, workspaceRoot });
|
|
28
|
-
const targetCommands = getInferredTargetCommands(result);
|
|
29
|
-
if (!targetCommands.length) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const replacedTargets = new Set();
|
|
33
|
-
for (const targetCommand of targetCommands) {
|
|
34
|
-
const { command, target, configuration } = targetCommand;
|
|
35
|
-
const targetCommandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${command})((?: [^&\\r\\n\\s]+)*(?: )*)(?=$|&)`, 'g');
|
|
36
|
-
for (const scriptName of Object.keys(packageJson.scripts)) {
|
|
37
|
-
const script = packageJson.scripts[scriptName];
|
|
38
|
-
// quick check for exact match within the script
|
|
39
|
-
if (targetCommandRegex.test(script)) {
|
|
40
|
-
packageJson.scripts[scriptName] = script.replace(targetCommandRegex, configuration
|
|
41
|
-
? `$1nx ${target} --configuration=${configuration}$3`
|
|
42
|
-
: `$1nx ${target}$3`);
|
|
43
|
-
replacedTargets.add(target);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
/**
|
|
47
|
-
* Parse script and command to handle the following:
|
|
48
|
-
* - if command doesn't match script => don't replace
|
|
49
|
-
* - if command has more args => don't replace
|
|
50
|
-
* - if command has same args, regardless of order => replace removing args
|
|
51
|
-
* - if command has less args or with different value => replace leaving args
|
|
52
|
-
*/
|
|
53
|
-
const parsedCommand = yargs(command, {
|
|
54
|
-
configuration: { 'strip-dashed': true },
|
|
55
|
-
});
|
|
56
|
-
// this assumes there are no positional args in the command, everything is a command or subcommand
|
|
57
|
-
const commandCommand = parsedCommand._.join(' ');
|
|
58
|
-
const commandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${commandCommand})((?: [^&\\r\\n\\s]+)*( )*)(?=$|&)`, 'g');
|
|
59
|
-
const matches = script.match(commandRegex);
|
|
60
|
-
if (!matches) {
|
|
61
|
-
// the command doesn't match the script, don't replace
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
for (const match of matches) {
|
|
65
|
-
// parse the matched command within the script
|
|
66
|
-
const parsedScript = yargs(match, {
|
|
67
|
-
configuration: { 'strip-dashed': true },
|
|
68
|
-
});
|
|
69
|
-
let hasArgsWithDifferentValues = false;
|
|
70
|
-
let scriptHasExtraArgs = false;
|
|
71
|
-
let commandHasExtraArgs = false;
|
|
72
|
-
for (const [key, value] of Object.entries(parsedCommand)) {
|
|
73
|
-
if (key === '_') {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (parsedScript[key] === undefined) {
|
|
77
|
-
commandHasExtraArgs = true;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
if (parsedScript[key] !== value) {
|
|
81
|
-
hasArgsWithDifferentValues = true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (commandHasExtraArgs) {
|
|
85
|
-
// the command has extra args, don't replace
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
for (const key of Object.keys(parsedScript)) {
|
|
89
|
-
if (key === '_') {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (!parsedCommand[key]) {
|
|
93
|
-
scriptHasExtraArgs = true;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (!hasArgsWithDifferentValues && !scriptHasExtraArgs) {
|
|
98
|
-
// they are the same, replace with the command removing the args
|
|
99
|
-
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
100
|
-
? `$1nx ${target} --configuration=${configuration}$4`
|
|
101
|
-
: `$1nx ${target}$4`));
|
|
102
|
-
replacedTargets.add(target);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
// there are different args or the script has extra args, replace with the command leaving the args
|
|
106
|
-
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
107
|
-
? `$1nx ${target} --configuration=${configuration}$3`
|
|
108
|
-
: `$1nx ${target}$3`));
|
|
109
|
-
replacedTargets.add(target);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
packageJson.nx ??= {};
|
|
116
|
-
if (process.env.NX_RUNNING_NX_INIT === 'true') {
|
|
117
|
-
// running `nx init` so we want to exclude everything by default
|
|
118
|
-
packageJson.nx.includedScripts = [];
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
/**
|
|
122
|
-
* Running `nx add`. In this case we want to:
|
|
123
|
-
* - if `includedScripts` is already set: exclude scripts that match inferred targets that were used to replace a script
|
|
124
|
-
* - if `includedScripts` is not set: set `includedScripts` with all scripts except the ones that match an inferred target that was used to replace a script
|
|
125
|
-
*/
|
|
126
|
-
packageJson.nx.includedScripts ??= Object.keys(packageJson.scripts);
|
|
127
|
-
packageJson.nx.includedScripts = packageJson.nx.includedScripts.filter((s) => !replacedTargets.has(s));
|
|
128
|
-
}
|
|
129
|
-
writeJson(tree, packageJsonPath, packageJson);
|
|
130
|
-
}
|
|
131
|
-
function getInferredTargetCommands(result) {
|
|
132
|
-
const targetCommands = [];
|
|
133
|
-
for (const project of Object.values(result.projects ?? {})) {
|
|
134
|
-
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
135
|
-
if (target.command) {
|
|
136
|
-
targetCommands.push({ command: target.command, target: targetName });
|
|
137
|
-
}
|
|
138
|
-
else if (target.executor === 'nx:run-commands' &&
|
|
139
|
-
target.options?.command) {
|
|
140
|
-
targetCommands.push({
|
|
141
|
-
command: target.options.command,
|
|
142
|
-
target: targetName,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (!target.configurations) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
for (const [configurationName, configuration] of Object.entries(target.configurations)) {
|
|
149
|
-
if (configuration.command) {
|
|
150
|
-
targetCommands.push({
|
|
151
|
-
command: configuration.command,
|
|
152
|
-
target: targetName,
|
|
153
|
-
configuration: configurationName,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else if (target.executor === 'nx:run-commands' &&
|
|
157
|
-
configuration.options?.command) {
|
|
158
|
-
targetCommands.push({
|
|
159
|
-
command: configuration.options.command,
|
|
160
|
-
target: targetName,
|
|
161
|
-
configuration: configurationName,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return targetCommands;
|
|
168
|
-
}
|
|
169
|
-
function getProjectRootFromConfigFile(file) {
|
|
170
|
-
let projectRoot = (0, path_1.dirname)(file);
|
|
171
|
-
if ((0, path_1.basename)(projectRoot) === '.storybook') {
|
|
172
|
-
projectRoot = (0, path_1.dirname)(projectRoot);
|
|
173
|
-
}
|
|
174
|
-
return projectRoot;
|
|
175
|
-
}
|