@nx/workspace 22.7.0-beta.4 → 22.7.0-beta.5
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 +4 -4
- package/src/generators/move/lib/update-owners-and-conformance.d.ts +4 -0
- package/src/generators/move/lib/update-owners-and-conformance.d.ts.map +1 -0
- package/src/generators/move/lib/update-owners-and-conformance.js +78 -0
- package/src/generators/move/move.d.ts.map +1 -1
- package/src/generators/move/move.js +2 -0
- package/src/generators/remove/lib/remove-project-references-in-config.d.ts.map +1 -1
- package/src/generators/remove/lib/remove-project-references-in-config.js +87 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "22.7.0-beta.
|
|
3
|
+
"version": "22.7.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@nx/devkit": "22.7.0-beta.
|
|
41
|
+
"@nx/devkit": "22.7.0-beta.5",
|
|
42
42
|
"@zkochan/js-yaml": "0.0.7",
|
|
43
43
|
"chalk": "^4.1.0",
|
|
44
44
|
"enquirer": "~2.3.6",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"semver": "^7.6.3",
|
|
47
47
|
"tslib": "^2.3.0",
|
|
48
48
|
"yargs-parser": "21.1.1",
|
|
49
|
-
"nx": "22.7.0-beta.
|
|
49
|
+
"nx": "22.7.0-beta.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"nx": "22.7.0-beta.
|
|
52
|
+
"nx": "22.7.0-beta.5"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-owners-and-conformance.d.ts","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/move/lib/update-owners-and-conformance.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,EAEL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,QA4BzB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateOwnersAndConformance = updateOwnersAndConformance;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function updateOwnersAndConformance(tree, schema) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
let changed = false;
|
|
8
|
+
if (renameProjectInConformanceRules(nxJson, schema.projectName, schema.newProjectName)) {
|
|
9
|
+
changed = true;
|
|
10
|
+
}
|
|
11
|
+
if (renameProjectInOwnersPatterns(nxJson, schema.projectName, schema.newProjectName)) {
|
|
12
|
+
changed = true;
|
|
13
|
+
}
|
|
14
|
+
if (changed) {
|
|
15
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function renameProjectInConformanceRules(nxJson, oldName, newName) {
|
|
19
|
+
const conformance = nxJson['conformance'];
|
|
20
|
+
if (!conformance?.rules) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
let changed = false;
|
|
24
|
+
for (const rule of conformance.rules) {
|
|
25
|
+
if (!rule.projects) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < rule.projects.length; i++) {
|
|
29
|
+
const entry = rule.projects[i];
|
|
30
|
+
if (typeof entry === 'string' && entry === oldName) {
|
|
31
|
+
rule.projects[i] = newName;
|
|
32
|
+
changed = true;
|
|
33
|
+
}
|
|
34
|
+
else if (typeof entry === 'object' && entry.matcher === oldName) {
|
|
35
|
+
entry.matcher = newName;
|
|
36
|
+
changed = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return changed;
|
|
41
|
+
}
|
|
42
|
+
function renameProjectInOwnersPatterns(nxJson, oldName, newName) {
|
|
43
|
+
const owners = nxJson['owners'];
|
|
44
|
+
if (typeof owners !== 'object' || !owners) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
let changed = false;
|
|
48
|
+
if (owners.patterns) {
|
|
49
|
+
if (renameInPatternsList(owners.patterns, oldName, newName)) {
|
|
50
|
+
changed = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (owners.sections) {
|
|
54
|
+
for (const section of owners.sections) {
|
|
55
|
+
if (section.patterns) {
|
|
56
|
+
if (renameInPatternsList(section.patterns, oldName, newName)) {
|
|
57
|
+
changed = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return changed;
|
|
63
|
+
}
|
|
64
|
+
function renameInPatternsList(patterns, oldName, newName) {
|
|
65
|
+
let changed = false;
|
|
66
|
+
for (const pattern of patterns) {
|
|
67
|
+
if (!pattern.projects) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < pattern.projects.length; i++) {
|
|
71
|
+
if (pattern.projects[i] === oldName) {
|
|
72
|
+
pattern.projects[i] = newName;
|
|
73
|
+
changed = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return changed;
|
|
78
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/generators/move/move.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/generators/move/move.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAyBpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,8BA8DhE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -16,6 +16,7 @@ const update_default_project_1 = require("./lib/update-default-project");
|
|
|
16
16
|
const update_eslint_config_1 = require("./lib/update-eslint-config");
|
|
17
17
|
const update_implicit_dependencies_1 = require("./lib/update-implicit-dependencies");
|
|
18
18
|
const update_imports_1 = require("./lib/update-imports");
|
|
19
|
+
const update_owners_and_conformance_1 = require("./lib/update-owners-and-conformance");
|
|
19
20
|
const update_jest_config_1 = require("./lib/update-jest-config");
|
|
20
21
|
const update_package_json_1 = require("./lib/update-package-json");
|
|
21
22
|
const update_project_root_files_1 = require("./lib/update-project-root-files");
|
|
@@ -46,6 +47,7 @@ async function moveGenerator(tree, rawSchema) {
|
|
|
46
47
|
(0, update_build_targets_1.updateBuildTargets)(tree, schema);
|
|
47
48
|
(0, update_default_project_1.updateDefaultProject)(tree, schema);
|
|
48
49
|
(0, update_implicit_dependencies_1.updateImplicitDependencies)(tree, schema);
|
|
50
|
+
(0, update_owners_and_conformance_1.updateOwnersAndConformance)(tree, schema);
|
|
49
51
|
if (projectConfig.root === '.') {
|
|
50
52
|
// we want to migrate eslint config once the root project files are moved
|
|
51
53
|
(0, extract_base_configs_1.maybeMigrateEslintConfigIfRootProject)(tree, projectConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-project-references-in-config.d.ts","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/remove-project-references-in-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"remove-project-references-in-config.d.ts","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/remove-project-references-in-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAIL,IAAI,EAGL,MAAM,YAAY,CAAC;AAEpB,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAsCzE"}
|
|
@@ -3,10 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.removeProjectReferencesInConfig = removeProjectReferencesInConfig;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function removeProjectReferencesInConfig(tree, schema) {
|
|
6
|
-
// Unset default project if deleting the default project
|
|
7
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
let nxJsonChanged = false;
|
|
8
|
+
// Unset default project if deleting the default project
|
|
8
9
|
if (nxJson.defaultProject && nxJson.defaultProject === schema.projectName) {
|
|
9
10
|
delete nxJson.defaultProject;
|
|
11
|
+
nxJsonChanged = true;
|
|
12
|
+
}
|
|
13
|
+
// Remove project from conformance rules
|
|
14
|
+
if (removeProjectFromConformanceRules(nxJson, schema.projectName)) {
|
|
15
|
+
nxJsonChanged = true;
|
|
16
|
+
}
|
|
17
|
+
// Remove project from owners patterns
|
|
18
|
+
if (removeProjectFromOwnersPatterns(nxJson, schema.projectName)) {
|
|
19
|
+
nxJsonChanged = true;
|
|
20
|
+
}
|
|
21
|
+
if (nxJsonChanged) {
|
|
10
22
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
11
23
|
}
|
|
12
24
|
// Remove implicit dependencies onto removed project
|
|
@@ -18,3 +30,77 @@ function removeProjectReferencesInConfig(tree, schema) {
|
|
|
18
30
|
}
|
|
19
31
|
});
|
|
20
32
|
}
|
|
33
|
+
function removeProjectFromConformanceRules(nxJson, projectName) {
|
|
34
|
+
const conformance = nxJson['conformance'];
|
|
35
|
+
if (!conformance?.rules) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
let changed = false;
|
|
39
|
+
// Iterate backwards so that splicing doesn't shift unvisited indices
|
|
40
|
+
for (let i = conformance.rules.length - 1; i >= 0; i--) {
|
|
41
|
+
const rule = conformance.rules[i];
|
|
42
|
+
if (!rule.projects) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const originalLength = rule.projects.length;
|
|
46
|
+
rule.projects = rule.projects.filter((entry) => {
|
|
47
|
+
if (typeof entry === 'string') {
|
|
48
|
+
return entry !== projectName;
|
|
49
|
+
}
|
|
50
|
+
if (typeof entry === 'object' && entry.matcher) {
|
|
51
|
+
return entry.matcher !== projectName;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
if (rule.projects.length !== originalLength) {
|
|
56
|
+
changed = true;
|
|
57
|
+
if (rule.projects.length === 0) {
|
|
58
|
+
conformance.rules.splice(i, 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return changed;
|
|
63
|
+
}
|
|
64
|
+
function removeProjectFromOwnersPatterns(nxJson, projectName) {
|
|
65
|
+
const owners = nxJson['owners'];
|
|
66
|
+
if (typeof owners !== 'object' || !owners) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
let changed = false;
|
|
70
|
+
// Filter top-level patterns
|
|
71
|
+
if (owners.patterns) {
|
|
72
|
+
if (filterOwnersPatternsList(owners.patterns, projectName)) {
|
|
73
|
+
changed = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Filter section-level patterns (GitLab)
|
|
77
|
+
if (owners.sections) {
|
|
78
|
+
for (const section of owners.sections) {
|
|
79
|
+
if (section.patterns) {
|
|
80
|
+
if (filterOwnersPatternsList(section.patterns, projectName)) {
|
|
81
|
+
changed = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return changed;
|
|
87
|
+
}
|
|
88
|
+
function filterOwnersPatternsList(patterns, projectName) {
|
|
89
|
+
let changed = false;
|
|
90
|
+
// Iterate backwards so that splicing doesn't shift unvisited indices
|
|
91
|
+
for (let i = patterns.length - 1; i >= 0; i--) {
|
|
92
|
+
const pattern = patterns[i];
|
|
93
|
+
if (!pattern.projects) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const originalLength = pattern.projects.length;
|
|
97
|
+
pattern.projects = pattern.projects.filter((entry) => entry !== projectName);
|
|
98
|
+
if (pattern.projects.length !== originalLength) {
|
|
99
|
+
changed = true;
|
|
100
|
+
if (pattern.projects.length === 0) {
|
|
101
|
+
patterns.splice(i, 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return changed;
|
|
106
|
+
}
|