@nx/devkit 23.0.0-beta.11 → 23.0.0-beta.12

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": "23.0.0-beta.11",
3
+ "version": "23.0.0-beta.12",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "jest": "30.3.0",
63
- "nx": "23.0.0-beta.11"
63
+ "nx": "23.0.0-beta.12"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "nx": ">= 22 <= 24 || ^23.0.0-0"
@@ -1,2 +0,0 @@
1
- import { Tree } from 'nx/src/devkit-exports';
2
- export declare function replaceNrwlPackageWithNxPackage(tree: Tree, oldPackageName: string, newPackageName: string): void;
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceNrwlPackageWithNxPackage = replaceNrwlPackageWithNxPackage;
4
- const devkit_exports_1 = require("nx/src/devkit-exports");
5
- const visit_not_ignored_files_1 = require("../generators/visit-not-ignored-files");
6
- const path_1 = require("path");
7
- const binary_extensions_1 = require("./binary-extensions");
8
- function replaceNrwlPackageWithNxPackage(tree, oldPackageName, newPackageName) {
9
- replacePackageInDependencies(tree, oldPackageName, newPackageName);
10
- replacePackageInProjectConfigurations(tree, oldPackageName, newPackageName);
11
- replacePackageInNxJson(tree, oldPackageName, newPackageName);
12
- replaceMentions(tree, oldPackageName, newPackageName);
13
- }
14
- function replacePackageInDependencies(tree, oldPackageName, newPackageName) {
15
- (0, visit_not_ignored_files_1.visitNotIgnoredFiles)(tree, '.', (path) => {
16
- if ((0, path_1.basename)(path) !== 'package.json') {
17
- return;
18
- }
19
- try {
20
- (0, devkit_exports_1.updateJson)(tree, path, (packageJson) => {
21
- for (const deps of [
22
- packageJson.dependencies ?? {},
23
- packageJson.devDependencies ?? {},
24
- packageJson.peerDependencies ?? {},
25
- packageJson.optionalDependencies ?? {},
26
- ]) {
27
- if (oldPackageName in deps) {
28
- deps[newPackageName] = deps[oldPackageName];
29
- delete deps[oldPackageName];
30
- }
31
- }
32
- return packageJson;
33
- });
34
- }
35
- catch (e) {
36
- console.warn(`Could not replace ${oldPackageName} with ${newPackageName} in ${path}.`);
37
- }
38
- });
39
- }
40
- function replacePackageInProjectConfigurations(tree, oldPackageName, newPackageName) {
41
- const projects = (0, devkit_exports_1.getProjects)(tree);
42
- for (const [projectName, projectConfiguration] of projects) {
43
- let needsUpdate = false;
44
- for (const [targetName, targetConfig] of Object.entries(projectConfiguration.targets ?? {})) {
45
- if (!targetConfig.executor) {
46
- continue;
47
- }
48
- const [pkg, executorName] = targetConfig.executor.split(':');
49
- if (pkg === oldPackageName) {
50
- needsUpdate = true;
51
- projectConfiguration.targets[targetName].executor =
52
- newPackageName + ':' + executorName;
53
- }
54
- }
55
- for (const [collection, collectionDefaults] of Object.entries(projectConfiguration.generators ?? {})) {
56
- if (collection === oldPackageName) {
57
- needsUpdate = true;
58
- projectConfiguration.generators[newPackageName] = collectionDefaults;
59
- delete projectConfiguration.generators[collection];
60
- }
61
- }
62
- if (needsUpdate) {
63
- (0, devkit_exports_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
64
- }
65
- }
66
- }
67
- function replacePackageInNxJson(tree, oldPackageName, newPackageName) {
68
- if (!tree.exists('nx.json')) {
69
- return;
70
- }
71
- const nxJson = (0, devkit_exports_1.readNxJson)(tree);
72
- let needsUpdate = false;
73
- for (const [targetName, targetConfig] of Object.entries(nxJson.targetDefaults ?? {})) {
74
- if (!targetConfig.executor) {
75
- continue;
76
- }
77
- const [pkg, executorName] = targetConfig.executor.split(':');
78
- if (pkg === oldPackageName) {
79
- needsUpdate = true;
80
- nxJson.targetDefaults[targetName].executor =
81
- newPackageName + ':' + executorName;
82
- }
83
- }
84
- for (const [collection, collectionDefaults] of Object.entries(nxJson.generators ?? {})) {
85
- if (collection === oldPackageName) {
86
- needsUpdate = true;
87
- nxJson.generators[newPackageName] = collectionDefaults;
88
- delete nxJson.generators[collection];
89
- }
90
- }
91
- if (needsUpdate) {
92
- (0, devkit_exports_1.updateNxJson)(tree, nxJson);
93
- }
94
- }
95
- function replaceMentions(tree, oldPackageName, newPackageName) {
96
- (0, visit_not_ignored_files_1.visitNotIgnoredFiles)(tree, '.', (path) => {
97
- if ((0, binary_extensions_1.isBinaryPath)(path)) {
98
- return;
99
- }
100
- const ignoredFiles = [
101
- 'yarn.lock',
102
- 'package-lock.json',
103
- 'pnpm-lock.yaml',
104
- 'bun.lockb',
105
- 'bun.lock',
106
- 'CHANGELOG.md',
107
- ];
108
- if (ignoredFiles.includes((0, path_1.basename)(path))) {
109
- return;
110
- }
111
- try {
112
- const contents = tree.read(path).toString();
113
- if (!contents.includes(oldPackageName)) {
114
- return;
115
- }
116
- tree.write(path, contents.replace(new RegExp(oldPackageName, 'g'), newPackageName));
117
- }
118
- catch {
119
- // Its **probably** ok, contents can be null if the file is too large or
120
- // there was an access exception.
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.`);
122
- }
123
- });
124
- }