@modern-js/monorepo-tools 2.5.0 → 2.6.0
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/CHANGELOG.md +16 -0
- package/dist/cjs/commands/build.js +1 -0
- package/dist/cjs/dag/create.js +4 -1
- package/dist/cjs/dag/operator.js +37 -0
- package/dist/cjs/dag/task.js +4 -0
- package/dist/cjs/features/build/index.js +4 -0
- package/dist/cjs/features/clear/index.js +4 -0
- package/dist/cjs/features/deploy/index.js +5 -0
- package/dist/cjs/features/dev/create-task.js +4 -0
- package/dist/cjs/features/dev/index.js +4 -0
- package/dist/cjs/features/dev/watch-projects-state.js +4 -0
- package/dist/cjs/features/install/index.js +4 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/parse-config/index.js +9 -1
- package/dist/cjs/parse-config/monorepo.js +4 -0
- package/dist/cjs/projects/check-project-change.js +4 -0
- package/dist/cjs/projects/clear-memory-files.js +4 -0
- package/dist/cjs/projects/get-projects-by-packages-config.js +6 -0
- package/dist/cjs/projects/get-projects-by-workspace-file.js +4 -0
- package/dist/cjs/projects/get-projects.js +3 -0
- package/dist/cjs/utils/install.js +4 -0
- package/dist/esm/commands/build.js +1 -0
- package/dist/esm/dag/create.js +4 -1
- package/dist/esm/dag/operator.js +33 -0
- package/dist/esm/features/deploy/index.js +1 -0
- package/dist/esm/parse-config/index.js +5 -1
- package/dist/esm/projects/get-projects-by-packages-config.js +2 -0
- package/dist/esm/projects/get-projects.js +3 -0
- package/dist/types/package/index.d.ts +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @modern-js/monorepo-tools
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e1f799e]
|
|
8
|
+
- Updated dependencies [7915ab3]
|
|
9
|
+
- Updated dependencies [0fe658a]
|
|
10
|
+
- @modern-js/utils@2.6.0
|
|
11
|
+
- @modern-js/core@2.6.0
|
|
12
|
+
- @modern-js/plugin-changeset@2.6.0
|
|
13
|
+
- @modern-js/plugin-i18n@2.6.0
|
|
14
|
+
- @modern-js/plugin-lint@2.6.0
|
|
15
|
+
- @modern-js/new-action@2.6.0
|
|
16
|
+
- @modern-js/upgrade@2.6.0
|
|
17
|
+
- @modern-js/plugin@2.6.0
|
|
18
|
+
|
|
3
19
|
## 2.5.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/dag/create.js
CHANGED
|
@@ -33,7 +33,10 @@ const initProjectDependencyAndDependent = (project, projectsName, projectsMap) =
|
|
|
33
33
|
project.dependency = DependencyProjectsName.map((projectName) => {
|
|
34
34
|
const dependencyProject = projectsMap.get(projectName);
|
|
35
35
|
const dependent = (dependencyProject == null ? void 0 : dependencyProject.dependent) || [];
|
|
36
|
-
if (
|
|
36
|
+
if (
|
|
37
|
+
// 消除重复添加的情况
|
|
38
|
+
!dependent.some((p) => p.name === project.name)
|
|
39
|
+
) {
|
|
37
40
|
dependencyProject.dependent = [...dependent, project];
|
|
38
41
|
dependencyProject.dependentEdge = dependencyProject.dependent.length;
|
|
39
42
|
}
|
package/dist/cjs/dag/operator.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -91,6 +95,7 @@ class DagOperator {
|
|
|
91
95
|
}
|
|
92
96
|
await (0, import_p_map.default)(
|
|
93
97
|
projects,
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
94
99
|
async (project) => {
|
|
95
100
|
if (!finishTaskHash[project.name]) {
|
|
96
101
|
finishTaskHash[project.name] = true;
|
|
@@ -116,6 +121,14 @@ class DagOperator {
|
|
|
116
121
|
withSelf: false
|
|
117
122
|
});
|
|
118
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* 1. 把目标节点当做叶子节点集合 A 中的元素
|
|
126
|
+
* 2. 当叶子节点集合中某个 a 元素结束任务的时候进行如下操作:
|
|
127
|
+
* 2.1 剪(去额外的)枝:获取 a 元素的 dependent集合,将该集合中元素的依赖列表进行过滤,过滤条件为:排除 a 以及 a 元素的 dependent集合以外的元素。
|
|
128
|
+
* 2.2 入度减一:对 a 元素的 dependent 集合元素的 dependencyEdge 减一
|
|
129
|
+
* 3. 检查是否存在 dependencyEdge === 0 的节点,加入叶子节点集合 A中。
|
|
130
|
+
* 4. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
|
|
131
|
+
*/
|
|
119
132
|
async traverseProjectToDependent(name, task, { withSelf = false, runTaskConcurrency } = {}) {
|
|
120
133
|
if (!this._projectsMap.has(name)) {
|
|
121
134
|
(0, import_error.errorLog)(`No '${name}' project exist`);
|
|
@@ -146,6 +159,14 @@ class DagOperator {
|
|
|
146
159
|
});
|
|
147
160
|
await taskRunner.run();
|
|
148
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* 1. 找到叶子节点集合 A
|
|
164
|
+
* 2. 找到直接连接叶子节点的节点集合 B
|
|
165
|
+
* 3. 当有某个叶子节点结束任务,则对该节点的直接连接的节点(或者理解成dependent)的枝数(或者叫入度)减一。
|
|
166
|
+
* 4. 检查 B 集合中是否存在入度为0的节点,则此节点为叶子节点,并加入叶子节点集合 A
|
|
167
|
+
* 5. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
|
|
168
|
+
*/
|
|
169
|
+
// TODO: 执行顺序还需要再确定一下
|
|
149
170
|
async traverseDependenciesToProject(name, task, { withSelf = false, runTaskConcurrency } = {}) {
|
|
150
171
|
if (!this._projectsMap.has(name)) {
|
|
151
172
|
(0, import_error.errorLog)(`No '${name}' project exist`);
|
|
@@ -183,6 +204,16 @@ class DagOperator {
|
|
|
183
204
|
});
|
|
184
205
|
await taskRunner.run();
|
|
185
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
209
|
+
*
|
|
210
|
+
* This source code is licensed under the MIT license found in the
|
|
211
|
+
* LICENSE file at
|
|
212
|
+
* https://github.com/microsoft/rushstack/blob/master/apps/rush-lib/LICENSE
|
|
213
|
+
*
|
|
214
|
+
/**
|
|
215
|
+
* Checks for projects that indirectly depend on themselves.
|
|
216
|
+
*/
|
|
186
217
|
_checkForCyclicDependencies(projects, dependencyChain, alreadyCheckedProjects) {
|
|
187
218
|
for (const project of projects) {
|
|
188
219
|
if (dependencyChain.includes(project.name)) {
|
|
@@ -225,6 +256,12 @@ class DagOperator {
|
|
|
225
256
|
(p) => preNodes.map((preP) => preP.name).includes(p.name)
|
|
226
257
|
);
|
|
227
258
|
}
|
|
259
|
+
// public async getOrderTasks() {
|
|
260
|
+
// // Precalculate the number of dependent packages
|
|
261
|
+
// for (const project of this._projects) {
|
|
262
|
+
// calculateCriticalPaths(project);
|
|
263
|
+
// }
|
|
264
|
+
// }
|
|
228
265
|
}
|
|
229
266
|
// Annotate the CommonJS export names for ESM import in node:
|
|
230
267
|
0 && (module.exports = {
|
package/dist/cjs/dag/task.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -158,6 +162,7 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
158
162
|
import_node_core_library.FileSystem.copyFiles({
|
|
159
163
|
sourcePath: from,
|
|
160
164
|
destinationPath: to,
|
|
165
|
+
// If true, then when copying symlinks, copy the target object instead of copying the link.
|
|
161
166
|
dereferenceSymlinks: false,
|
|
162
167
|
filter(filePath) {
|
|
163
168
|
if (excludeDirs(filePath, ["node_modules", "dist"])) {
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -29,7 +33,11 @@ module.exports = __toCommonJS(parse_config_exports);
|
|
|
29
33
|
var path = __toESM(require("path"));
|
|
30
34
|
var import_node_core_library = require("@rushstack/node-core-library");
|
|
31
35
|
var import_monorepo = require("./monorepo");
|
|
32
|
-
const defaultConfig = {
|
|
36
|
+
const defaultConfig = {
|
|
37
|
+
// packagesMatchs: {
|
|
38
|
+
// workspaceFile: 'pnpm-lock.yaml',
|
|
39
|
+
// },
|
|
40
|
+
};
|
|
33
41
|
const getFinalConfig = async (currentPath = process.cwd()) => {
|
|
34
42
|
const monorepo = (0, import_monorepo.getMonorepoBaseData)(currentPath);
|
|
35
43
|
const userConfig = await import_node_core_library.JsonFile.loadAsync(
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -48,6 +52,8 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
48
52
|
);
|
|
49
53
|
}
|
|
50
54
|
globOpts.ignore = [
|
|
55
|
+
// allow globs like "packages/**",
|
|
56
|
+
// but avoid picking up node_modules/**/package.json and dist/**/package.json
|
|
51
57
|
"**/dist/**",
|
|
52
58
|
"**/node_modules/**",
|
|
53
59
|
...ignore || []
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -36,6 +36,7 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
36
36
|
subProjects.push({
|
|
37
37
|
name: config.name,
|
|
38
38
|
extra: { path: config.path },
|
|
39
|
+
// dagNodeEdge: 0,
|
|
39
40
|
dependencyEdge: 0,
|
|
40
41
|
dependentEdge: 0,
|
|
41
42
|
checkedCircle: false,
|
|
@@ -63,6 +64,7 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
63
64
|
path: project.path,
|
|
64
65
|
...project.json
|
|
65
66
|
},
|
|
67
|
+
// dagNodeEdge: 0,
|
|
66
68
|
dependencyEdge: 0,
|
|
67
69
|
dependentEdge: 0,
|
|
68
70
|
checkedCircle: false,
|
|
@@ -90,6 +92,7 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
90
92
|
path: project.path,
|
|
91
93
|
...project.json
|
|
92
94
|
},
|
|
95
|
+
// dagNodeEdge: 0,
|
|
93
96
|
dependencyEdge: 0,
|
|
94
97
|
dependentEdge: 0,
|
|
95
98
|
checkedCircle: false,
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/esm/dag/create.js
CHANGED
|
@@ -11,7 +11,10 @@ const initProjectDependencyAndDependent = (project, projectsName, projectsMap) =
|
|
|
11
11
|
project.dependency = DependencyProjectsName.map((projectName) => {
|
|
12
12
|
const dependencyProject = projectsMap.get(projectName);
|
|
13
13
|
const dependent = (dependencyProject == null ? void 0 : dependencyProject.dependent) || [];
|
|
14
|
-
if (
|
|
14
|
+
if (
|
|
15
|
+
// 消除重复添加的情况
|
|
16
|
+
!dependent.some((p) => p.name === project.name)
|
|
17
|
+
) {
|
|
15
18
|
dependencyProject.dependent = [...dependent, project];
|
|
16
19
|
dependencyProject.dependentEdge = dependencyProject.dependent.length;
|
|
17
20
|
}
|
package/dist/esm/dag/operator.js
CHANGED
|
@@ -63,6 +63,7 @@ class DagOperator {
|
|
|
63
63
|
}
|
|
64
64
|
await pMap(
|
|
65
65
|
projects,
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
66
67
|
async (project) => {
|
|
67
68
|
if (!finishTaskHash[project.name]) {
|
|
68
69
|
finishTaskHash[project.name] = true;
|
|
@@ -88,6 +89,14 @@ class DagOperator {
|
|
|
88
89
|
withSelf: false
|
|
89
90
|
});
|
|
90
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* 1. 把目标节点当做叶子节点集合 A 中的元素
|
|
94
|
+
* 2. 当叶子节点集合中某个 a 元素结束任务的时候进行如下操作:
|
|
95
|
+
* 2.1 剪(去额外的)枝:获取 a 元素的 dependent集合,将该集合中元素的依赖列表进行过滤,过滤条件为:排除 a 以及 a 元素的 dependent集合以外的元素。
|
|
96
|
+
* 2.2 入度减一:对 a 元素的 dependent 集合元素的 dependencyEdge 减一
|
|
97
|
+
* 3. 检查是否存在 dependencyEdge === 0 的节点,加入叶子节点集合 A中。
|
|
98
|
+
* 4. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
|
|
99
|
+
*/
|
|
91
100
|
async traverseProjectToDependent(name, task, { withSelf = false, runTaskConcurrency } = {}) {
|
|
92
101
|
if (!this._projectsMap.has(name)) {
|
|
93
102
|
errorLog(`No '${name}' project exist`);
|
|
@@ -118,6 +127,14 @@ class DagOperator {
|
|
|
118
127
|
});
|
|
119
128
|
await taskRunner.run();
|
|
120
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* 1. 找到叶子节点集合 A
|
|
132
|
+
* 2. 找到直接连接叶子节点的节点集合 B
|
|
133
|
+
* 3. 当有某个叶子节点结束任务,则对该节点的直接连接的节点(或者理解成dependent)的枝数(或者叫入度)减一。
|
|
134
|
+
* 4. 检查 B 集合中是否存在入度为0的节点,则此节点为叶子节点,并加入叶子节点集合 A
|
|
135
|
+
* 5. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
|
|
136
|
+
*/
|
|
137
|
+
// TODO: 执行顺序还需要再确定一下
|
|
121
138
|
async traverseDependenciesToProject(name, task, { withSelf = false, runTaskConcurrency } = {}) {
|
|
122
139
|
if (!this._projectsMap.has(name)) {
|
|
123
140
|
errorLog(`No '${name}' project exist`);
|
|
@@ -155,6 +172,16 @@ class DagOperator {
|
|
|
155
172
|
});
|
|
156
173
|
await taskRunner.run();
|
|
157
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
177
|
+
*
|
|
178
|
+
* This source code is licensed under the MIT license found in the
|
|
179
|
+
* LICENSE file at
|
|
180
|
+
* https://github.com/microsoft/rushstack/blob/master/apps/rush-lib/LICENSE
|
|
181
|
+
*
|
|
182
|
+
/**
|
|
183
|
+
* Checks for projects that indirectly depend on themselves.
|
|
184
|
+
*/
|
|
158
185
|
_checkForCyclicDependencies(projects, dependencyChain, alreadyCheckedProjects) {
|
|
159
186
|
for (const project of projects) {
|
|
160
187
|
if (dependencyChain.includes(project.name)) {
|
|
@@ -197,6 +224,12 @@ class DagOperator {
|
|
|
197
224
|
(p) => preNodes.map((preP) => preP.name).includes(p.name)
|
|
198
225
|
);
|
|
199
226
|
}
|
|
227
|
+
// public async getOrderTasks() {
|
|
228
|
+
// // Precalculate the number of dependent packages
|
|
229
|
+
// for (const project of this._projects) {
|
|
230
|
+
// calculateCriticalPaths(project);
|
|
231
|
+
// }
|
|
232
|
+
// }
|
|
200
233
|
}
|
|
201
234
|
export {
|
|
202
235
|
DagOperator
|
|
@@ -140,6 +140,7 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
140
140
|
FileSystem.copyFiles({
|
|
141
141
|
sourcePath: from,
|
|
142
142
|
destinationPath: to,
|
|
143
|
+
// If true, then when copying symlinks, copy the target object instead of copying the link.
|
|
143
144
|
dereferenceSymlinks: false,
|
|
144
145
|
filter(filePath) {
|
|
145
146
|
if (excludeDirs(filePath, ["node_modules", "dist"])) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
2
|
import { JsonFile } from "@rushstack/node-core-library";
|
|
3
3
|
import { getMonorepoBaseData } from "./monorepo";
|
|
4
|
-
const defaultConfig = {
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
// packagesMatchs: {
|
|
6
|
+
// workspaceFile: 'pnpm-lock.yaml',
|
|
7
|
+
// },
|
|
8
|
+
};
|
|
5
9
|
const getFinalConfig = async (currentPath = process.cwd()) => {
|
|
6
10
|
const monorepo = getMonorepoBaseData(currentPath);
|
|
7
11
|
const userConfig = await JsonFile.loadAsync(
|
|
@@ -19,6 +19,8 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
globOpts.ignore = [
|
|
22
|
+
// allow globs like "packages/**",
|
|
23
|
+
// but avoid picking up node_modules/**/package.json and dist/**/package.json
|
|
22
24
|
"**/dist/**",
|
|
23
25
|
"**/node_modules/**",
|
|
24
26
|
...ignore || []
|
|
@@ -19,6 +19,7 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
19
19
|
subProjects.push({
|
|
20
20
|
name: config.name,
|
|
21
21
|
extra: { path: config.path },
|
|
22
|
+
// dagNodeEdge: 0,
|
|
22
23
|
dependencyEdge: 0,
|
|
23
24
|
dependentEdge: 0,
|
|
24
25
|
checkedCircle: false,
|
|
@@ -46,6 +47,7 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
46
47
|
path: project.path,
|
|
47
48
|
...project.json
|
|
48
49
|
},
|
|
50
|
+
// dagNodeEdge: 0,
|
|
49
51
|
dependencyEdge: 0,
|
|
50
52
|
dependentEdge: 0,
|
|
51
53
|
checkedCircle: false,
|
|
@@ -73,6 +75,7 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
73
75
|
path: project.path,
|
|
74
76
|
...project.json
|
|
75
77
|
},
|
|
78
|
+
// dagNodeEdge: 0,
|
|
76
79
|
dependencyEdge: 0,
|
|
77
80
|
dependentEdge: 0,
|
|
78
81
|
checkedCircle: false,
|
|
@@ -6,5 +6,5 @@ export declare class Package {
|
|
|
6
6
|
constructor(packageJson: INodePackageJson, packageConfigPath: string, rootPath: string);
|
|
7
7
|
get name(): string;
|
|
8
8
|
get path(): string;
|
|
9
|
-
get(key: keyof INodePackageJson): string | boolean | Record<string, string> | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").
|
|
9
|
+
get(key: keyof INodePackageJson): string | boolean | Record<string, string> | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").IPackageJsonScriptTable | import("@rushstack/node-core-library").IPackageJsonRepository | undefined;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.6.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"anymatch": "^3.1.2",
|
|
40
40
|
"md5": "^2.3.0",
|
|
41
41
|
"p-map": "^4.0.0",
|
|
42
|
-
"@modern-js/core": "2.
|
|
43
|
-
"@modern-js/new-action": "2.
|
|
44
|
-
"@modern-js/upgrade": "2.
|
|
45
|
-
"@modern-js/plugin": "2.
|
|
46
|
-
"@modern-js/plugin-changeset": "2.
|
|
47
|
-
"@modern-js/plugin-i18n": "2.
|
|
48
|
-
"@modern-js/plugin-lint": "2.
|
|
49
|
-
"@modern-js/utils": "2.
|
|
42
|
+
"@modern-js/core": "2.6.0",
|
|
43
|
+
"@modern-js/new-action": "2.6.0",
|
|
44
|
+
"@modern-js/upgrade": "2.6.0",
|
|
45
|
+
"@modern-js/plugin": "2.6.0",
|
|
46
|
+
"@modern-js/plugin-changeset": "2.6.0",
|
|
47
|
+
"@modern-js/plugin-i18n": "2.6.0",
|
|
48
|
+
"@modern-js/plugin-lint": "2.6.0",
|
|
49
|
+
"@modern-js/utils": "2.6.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/jest": "^27",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@types/node": "^14",
|
|
55
55
|
"jest": "^27",
|
|
56
56
|
"typescript": "^4",
|
|
57
|
-
"@scripts/build": "2.
|
|
58
|
-
"@scripts/jest-config": "2.
|
|
57
|
+
"@scripts/build": "2.6.0",
|
|
58
|
+
"@scripts/jest-config": "2.6.0"
|
|
59
59
|
},
|
|
60
60
|
"sideEffects": false,
|
|
61
61
|
"publishConfig": {
|