@modern-js/monorepo-tools 2.5.0 → 2.7.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/cli/{build-watch.js → buildWatch.js} +3 -3
  3. package/dist/cjs/cli/index.js +1 -1
  4. package/dist/cjs/commands/build.js +3 -2
  5. package/dist/cjs/commands/{build-watch.js → buildWatch.js} +5 -5
  6. package/dist/cjs/commands/clear.js +2 -2
  7. package/dist/cjs/commands/deploy.js +2 -2
  8. package/dist/cjs/commands/index.js +1 -1
  9. package/dist/cjs/commands/install.js +2 -2
  10. package/dist/cjs/dag/create.js +4 -1
  11. package/dist/cjs/dag/{edge-manager.js → edgeManager.js} +3 -3
  12. package/dist/cjs/dag/operator.js +40 -3
  13. package/dist/cjs/dag/task.js +4 -0
  14. package/dist/cjs/dag/utils.js +2 -2
  15. package/dist/cjs/features/build/index.js +10 -6
  16. package/dist/cjs/features/clear/index.js +4 -0
  17. package/dist/cjs/features/deploy/index.js +5 -0
  18. package/dist/cjs/features/dev/{create-task.js → createTask.js} +7 -3
  19. package/dist/cjs/features/dev/index.js +11 -7
  20. package/dist/cjs/features/dev/{watch-projects-state.js → watchProjectsState.js} +7 -3
  21. package/dist/cjs/features/install/index.js +4 -0
  22. package/dist/cjs/index.js +4 -0
  23. package/dist/cjs/log/{multi-tasks-log.js → multiTasksLog.js} +3 -3
  24. package/dist/cjs/parse-config/index.js +9 -1
  25. package/dist/cjs/parse-config/monorepo.js +4 -0
  26. package/dist/cjs/projects/{check-project-change.js → checkProjectChange.js} +7 -3
  27. package/dist/cjs/projects/{clear-memory-files.js → clearMemoryFiles.js} +10 -6
  28. package/dist/cjs/projects/{get-projects.js → getProjects.js} +12 -9
  29. package/dist/cjs/projects/{get-projects-by-packages-config.js → getProjectsByPackagesConfig.js} +9 -3
  30. package/dist/cjs/projects/{get-projects-by-workspace-file.js → getProjectsByWorkspaceFile.js} +10 -6
  31. package/dist/cjs/utils/install.js +4 -0
  32. package/dist/esm/cli/index.js +1 -1
  33. package/dist/esm/commands/build.js +2 -1
  34. package/dist/esm/commands/{build-watch.js → buildWatch.js} +1 -1
  35. package/dist/esm/commands/clear.js +1 -1
  36. package/dist/esm/commands/deploy.js +1 -1
  37. package/dist/esm/commands/index.js +1 -1
  38. package/dist/esm/commands/install.js +1 -1
  39. package/dist/esm/dag/create.js +4 -1
  40. package/dist/esm/dag/operator.js +34 -1
  41. package/dist/esm/dag/utils.js +1 -1
  42. package/dist/esm/features/build/index.js +2 -2
  43. package/dist/esm/features/deploy/index.js +1 -0
  44. package/dist/esm/features/dev/index.js +3 -3
  45. package/dist/esm/parse-config/index.js +5 -1
  46. package/dist/esm/projects/{clear-memory-files.js → clearMemoryFiles.js} +1 -1
  47. package/dist/esm/projects/{get-projects.js → getProjects.js} +5 -2
  48. package/dist/esm/projects/{get-projects-by-packages-config.js → getProjectsByPackagesConfig.js} +2 -0
  49. package/dist/esm/projects/{get-projects-by-workspace-file.js → getProjectsByWorkspaceFile.js} +1 -1
  50. package/dist/types/cli/index.d.ts +1 -1
  51. package/dist/types/commands/index.d.ts +1 -1
  52. package/dist/types/dag/create.d.ts +1 -1
  53. package/dist/types/dag/{edge-manager.d.ts → edgeManager.d.ts} +1 -1
  54. package/dist/types/dag/index.d.ts +1 -1
  55. package/dist/types/dag/operator.d.ts +1 -1
  56. package/dist/types/dag/utils.d.ts +1 -1
  57. package/dist/types/features/clear/index.d.ts +1 -1
  58. package/dist/types/features/dev/cmds.d.ts +1 -1
  59. package/dist/types/features/dev/{create-task.d.ts → createTask.d.ts} +2 -2
  60. package/dist/types/features/dev/index.d.ts +1 -1
  61. package/dist/types/features/dev/{watch-projects-state.d.ts → watchProjectsState.d.ts} +1 -1
  62. package/dist/types/package/index.d.ts +1 -1
  63. package/dist/types/projects/{check-project-change.d.ts → checkProjectChange.d.ts} +1 -1
  64. package/dist/types/projects/{clear-memory-files.d.ts → clearMemoryFiles.d.ts} +1 -1
  65. package/package.json +11 -11
  66. /package/dist/esm/cli/{build-watch.js → buildWatch.js} +0 -0
  67. /package/dist/esm/dag/{edge-manager.js → edgeManager.js} +0 -0
  68. /package/dist/esm/features/dev/{create-task.js → createTask.js} +0 -0
  69. /package/dist/esm/features/dev/{watch-projects-state.js → watchProjectsState.js} +0 -0
  70. /package/dist/esm/log/{multi-tasks-log.js → multiTasksLog.js} +0 -0
  71. /package/dist/esm/projects/{check-project-change.js → checkProjectChange.js} +0 -0
  72. /package/dist/types/cli/{build-watch.d.ts → buildWatch.d.ts} +0 -0
  73. /package/dist/types/commands/{build-watch.d.ts → buildWatch.d.ts} +0 -0
  74. /package/dist/types/log/{multi-tasks-log.d.ts → multiTasksLog.d.ts} +0 -0
  75. /package/dist/types/projects/{get-projects.d.ts → getProjects.d.ts} +0 -0
  76. /package/dist/types/projects/{get-projects-by-packages-config.d.ts → getProjectsByPackagesConfig.d.ts} +0 -0
  77. /package/dist/types/projects/{get-projects-by-workspace-file.d.ts → getProjectsByWorkspaceFile.d.ts} +0 -0
@@ -17,24 +17,28 @@ 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
  ));
23
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var clear_memory_files_exports = {};
25
- __export(clear_memory_files_exports, {
28
+ var clearMemoryFiles_exports = {};
29
+ __export(clearMemoryFiles_exports, {
26
30
  clearProjectsMemoryFile: () => clearProjectsMemoryFile
27
31
  });
28
- module.exports = __toCommonJS(clear_memory_files_exports);
32
+ module.exports = __toCommonJS(clearMemoryFiles_exports);
29
33
  var path = __toESM(require("path"));
30
34
  var import_node_core_library = require("@rushstack/node-core-library");
31
- var import_check_project_change = require("./check-project-change");
35
+ var import_checkProjectChange = require("./checkProjectChange");
32
36
  const clearProjectsMemoryFile = (projects) => {
33
37
  for (const project of projects) {
34
38
  const memoryFilePath = path.join(
35
39
  project.extra.path,
36
- import_check_project_change.PROJECT_MEMORY_PATH,
37
- import_check_project_change.PROJECT_CONTENT_FILE_NAME
40
+ import_checkProjectChange.PROJECT_MEMORY_PATH,
41
+ import_checkProjectChange.PROJECT_CONTENT_FILE_NAME
38
42
  );
39
43
  console.info("remove", memoryFilePath);
40
44
  import_node_core_library.FileSystem.deleteFile(memoryFilePath);
@@ -15,16 +15,16 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var get_projects_exports = {};
19
- __export(get_projects_exports, {
18
+ var getProjects_exports = {};
19
+ __export(getProjects_exports, {
20
20
  getProjects: () => getProjects,
21
21
  syncGetProjects: () => syncGetProjects
22
22
  });
23
- module.exports = __toCommonJS(get_projects_exports);
23
+ module.exports = __toCommonJS(getProjects_exports);
24
24
  var import_error = require("../log/error");
25
25
  var import_monorepo = require("../parse-config/monorepo");
26
- var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
27
- var import_get_projects_by_workspace_file = require("./get-projects-by-workspace-file");
26
+ var import_getProjectsByPackagesConfig = require("./getProjectsByPackagesConfig");
27
+ var import_getProjectsByWorkspaceFile = require("./getProjectsByWorkspaceFile");
28
28
  var FindProjectsMode = /* @__PURE__ */ ((FindProjectsMode2) => {
29
29
  FindProjectsMode2[FindProjectsMode2["Rough"] = 0] = "Rough";
30
30
  FindProjectsMode2[FindProjectsMode2["Precise"] = 1] = "Precise";
@@ -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,
@@ -47,9 +48,9 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
47
48
  const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
48
49
  let projects = [];
49
50
  if (Array.isArray(match)) {
50
- projects = await (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(rootPath, match, ignore);
51
+ projects = await (0, import_getProjectsByPackagesConfig.getProjectsByPackageConfig)(rootPath, match, ignore);
51
52
  } else {
52
- projects = await (0, import_get_projects_by_workspace_file.getProjectsByWorkspaceFile)(
53
+ projects = await (0, import_getProjectsByWorkspaceFile.getProjectsByWorkspaceFile)(
53
54
  rootPath,
54
55
  match,
55
56
  ignore
@@ -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,
@@ -74,9 +76,9 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
74
76
  const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
75
77
  let projects = [];
76
78
  if (Array.isArray(match)) {
77
- projects = (0, import_get_projects_by_packages_config.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
79
+ projects = (0, import_getProjectsByPackagesConfig.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
78
80
  } else {
79
- projects = (0, import_get_projects_by_workspace_file.syncGetProjectsByWorkspaceFile)(
81
+ projects = (0, import_getProjectsByWorkspaceFile.syncGetProjectsByWorkspaceFile)(
80
82
  rootPath,
81
83
  match,
82
84
  ignore
@@ -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,16 +17,20 @@ 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
  ));
23
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var get_projects_by_packages_config_exports = {};
25
- __export(get_projects_by_packages_config_exports, {
28
+ var getProjectsByPackagesConfig_exports = {};
29
+ __export(getProjectsByPackagesConfig_exports, {
26
30
  getProjectsByPackageConfig: () => getProjectsByPackageConfig,
27
31
  syncGetProjectsByPackageConfig: () => syncGetProjectsByPackageConfig
28
32
  });
29
- module.exports = __toCommonJS(get_projects_by_packages_config_exports);
33
+ module.exports = __toCommonJS(getProjectsByPackagesConfig_exports);
30
34
  var path = __toESM(require("path"));
31
35
  var import_node_core_library = require("@rushstack/node-core-library");
32
36
  var import_utils = require("@modern-js/utils");
@@ -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,22 +17,26 @@ 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
  ));
23
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var get_projects_by_workspace_file_exports = {};
25
- __export(get_projects_by_workspace_file_exports, {
28
+ var getProjectsByWorkspaceFile_exports = {};
29
+ __export(getProjectsByWorkspaceFile_exports, {
26
30
  getProjectsByWorkspaceFile: () => getProjectsByWorkspaceFile,
27
31
  syncGetProjectsByWorkspaceFile: () => syncGetProjectsByWorkspaceFile
28
32
  });
29
- module.exports = __toCommonJS(get_projects_by_workspace_file_exports);
33
+ module.exports = __toCommonJS(getProjectsByWorkspaceFile_exports);
30
34
  var path = __toESM(require("path"));
31
35
  var import_node_core_library = require("@rushstack/node-core-library");
32
36
  var import_utils = require("@modern-js/utils");
33
37
  var import_monorepo = require("../parse-config/monorepo");
34
38
  var import_constants = require("../constants");
35
- var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
39
+ var import_getProjectsByPackagesConfig = require("./getProjectsByPackagesConfig");
36
40
  const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
37
41
  var _a, _b, _c;
38
42
  let { workspaceFile } = config;
@@ -58,7 +62,7 @@ const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
58
62
  const lernaJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
59
63
  packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
60
64
  }
61
- const projects = await (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(
65
+ const projects = await (0, import_getProjectsByPackagesConfig.getProjectsByPackageConfig)(
62
66
  rootPath,
63
67
  packagesConfig,
64
68
  ignoreConfigs
@@ -91,7 +95,7 @@ const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
91
95
  const lernaJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
92
96
  packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
93
97
  }
94
- const projects = (0, import_get_projects_by_packages_config.syncGetProjectsByPackageConfig)(
98
+ const projects = (0, import_getProjectsByPackagesConfig.syncGetProjectsByPackageConfig)(
95
99
  rootPath,
96
100
  packagesConfig,
97
101
  ignoreConfigs
@@ -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
  ));
@@ -1,6 +1,6 @@
1
1
  export * from "./new";
2
2
  export * from "./deploy";
3
3
  export * from "./build";
4
- export * from "./build-watch";
4
+ export * from "./buildWatch";
5
5
  export * from "./clear";
6
6
  export * from "./install";
@@ -1,6 +1,6 @@
1
1
  import { getMonorepoBaseData } from "../parse-config/monorepo";
2
2
  import { runBuildTask, runAllBuildTask } from "../features/build";
3
- import { getProjects } from "../projects/get-projects";
3
+ import { getProjects } from "../projects/getProjects";
4
4
  import { initDAG } from "../dag";
5
5
  const build = async (targetProjectName, option, api) => {
6
6
  const { appDirectory } = api.useAppContext();
@@ -34,6 +34,7 @@ const build = async (targetProjectName, option, api) => {
34
34
  withDept: dept,
35
35
  onlySelf,
36
36
  disableWithDeps: !deps,
37
+ // The CI/CD phase is recommended to be switched on
37
38
  disableContentHash: !contentHash,
38
39
  enableGitHash: gitHash,
39
40
  ...overrideConfig
@@ -1,6 +1,6 @@
1
1
  import { getMonorepoBaseData } from "../parse-config/monorepo";
2
2
  import { runBuildWatchTask } from "../features/dev";
3
- import { getProjects } from "../projects/get-projects";
3
+ import { getProjects } from "../projects/getProjects";
4
4
  import { initDAG } from "../dag";
5
5
  const buildWatch = async (targetProjectName, option, api) => {
6
6
  const { appDirectory } = api.useAppContext();
@@ -1,4 +1,4 @@
1
- import { getProjects } from "../projects/get-projects";
1
+ import { getProjects } from "../projects/getProjects";
2
2
  import { getMonorepoBaseData } from "../parse-config/monorepo";
3
3
  import { runClearTask } from "../features/clear";
4
4
  const clear = async (projectNames, option, api) => {
@@ -1,7 +1,7 @@
1
1
  import { logger } from "@modern-js/utils";
2
2
  import { initDAG } from "../dag";
3
3
  import { getMonorepoBaseData } from "../parse-config/monorepo";
4
- import { getProjects } from "../projects/get-projects";
4
+ import { getProjects } from "../projects/getProjects";
5
5
  import { deploy as runDeployTask } from "../features/deploy";
6
6
  const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
7
7
  const { deployPath = "output" } = option;
@@ -1,5 +1,5 @@
1
1
  export * from "./deploy";
2
2
  export * from "./build";
3
- export * from "./build-watch";
3
+ export * from "./buildWatch";
4
4
  export * from "./clear";
5
5
  export * from "./install";
@@ -1,6 +1,6 @@
1
1
  import { runInstallTask } from "../features/install";
2
2
  import { getMonorepoBaseData } from "../parse-config/monorepo";
3
- import { getProjects } from "../projects/get-projects";
3
+ import { getProjects } from "../projects/getProjects";
4
4
  import { initDAG } from "../dag";
5
5
  const install = async (projectNames = [], option, api) => {
6
6
  const { appDirectory } = api.useAppContext();
@@ -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 (!dependent.some((p) => p.name === project.name)) {
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
  }
@@ -1,7 +1,7 @@
1
1
  import pMap from "p-map";
2
2
  import { errorLog } from "../log/error";
3
3
  import { TaskRunner } from "./task";
4
- import { EdgeManager } from "./edge-manager";
4
+ import { EdgeManager } from "./edgeManager";
5
5
  import { recursiveGetDependency, sortProjects } from "./utils";
6
6
  class DagOperator {
7
7
  constructor(projects, projectsMap) {
@@ -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
@@ -1,5 +1,5 @@
1
1
  import { errorLog } from "../log/error";
2
- import { EdgeManager } from "./edge-manager";
2
+ import { EdgeManager } from "./edgeManager";
3
3
  const calculateCriticalPaths = (project) => {
4
4
  var _a, _b;
5
5
  if (project.criticalPathLength !== void 0) {
@@ -3,9 +3,9 @@ import { execa, signale } from "@modern-js/utils";
3
3
  import {
4
4
  checkProjectChangeByGit,
5
5
  checkProjectChangeByContent
6
- } from "../../projects/check-project-change";
6
+ } from "../../projects/checkProjectChange";
7
7
  import { errorLog } from "../../log/error";
8
- import { MultitasksLogger } from "../../log/multi-tasks-log";
8
+ import { MultitasksLogger } from "../../log/multiTasksLog";
9
9
  const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
10
10
  const {
11
11
  rootPath,
@@ -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,9 +1,9 @@
1
1
  import anymatch from "anymatch";
2
2
  import { chokidar } from "@modern-js/utils";
3
- import { MultitasksLogger } from "../../log/multi-tasks-log";
4
- import { WatchedProjectsState } from "./watch-projects-state";
3
+ import { MultitasksLogger } from "../../log/multiTasksLog";
4
+ import { WatchedProjectsState } from "./watchProjectsState";
5
5
  import { defaultBuildWatchCmds } from "./cmds";
6
- import { createDependenciesTask, createDevTask } from "./create-task";
6
+ import { createDependenciesTask, createDevTask } from "./createTask";
7
7
  const getIgnored = (config) => (watchFilePath) => {
8
8
  const nodeModulesPattern = /(?:^|[\\/])node_modules/g;
9
9
  if (nodeModulesPattern.test(watchFilePath) || watchFilePath.includes("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(
@@ -3,7 +3,7 @@ import { FileSystem } from "@rushstack/node-core-library";
3
3
  import {
4
4
  PROJECT_MEMORY_PATH,
5
5
  PROJECT_CONTENT_FILE_NAME
6
- } from "./check-project-change";
6
+ } from "./checkProjectChange";
7
7
  const clearProjectsMemoryFile = (projects) => {
8
8
  for (const project of projects) {
9
9
  const memoryFilePath = path.join(
@@ -3,11 +3,11 @@ import { getMonorepoBaseData } from "../parse-config/monorepo";
3
3
  import {
4
4
  getProjectsByPackageConfig,
5
5
  syncGetProjectsByPackageConfig
6
- } from "./get-projects-by-packages-config";
6
+ } from "./getProjectsByPackagesConfig";
7
7
  import {
8
8
  getProjectsByWorkspaceFile,
9
9
  syncGetProjectsByWorkspaceFile
10
- } from "./get-projects-by-workspace-file";
10
+ } from "./getProjectsByWorkspaceFile";
11
11
  var FindProjectsMode = /* @__PURE__ */ ((FindProjectsMode2) => {
12
12
  FindProjectsMode2[FindProjectsMode2["Rough"] = 0] = "Rough";
13
13
  FindProjectsMode2[FindProjectsMode2["Precise"] = 1] = "Precise";
@@ -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,
@@ -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 || []
@@ -6,7 +6,7 @@ import { WORKSPACE_FILE } from "../constants";
6
6
  import {
7
7
  getProjectsByPackageConfig,
8
8
  syncGetProjectsByPackageConfig
9
- } from "./get-projects-by-packages-config";
9
+ } from "./getProjectsByPackagesConfig";
10
10
  const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
11
11
  var _a, _b, _c;
12
12
  let { workspaceFile } = config;
@@ -1,6 +1,6 @@
1
1
  export * from './new';
2
2
  export * from './deploy';
3
3
  export * from './build';
4
- export * from './build-watch';
4
+ export * from './buildWatch';
5
5
  export * from './clear';
6
6
  export * from './install';
@@ -1,5 +1,5 @@
1
1
  export * from './deploy';
2
2
  export * from './build';
3
- export * from './build-watch';
3
+ export * from './buildWatch';
4
4
  export * from './clear';
5
5
  export * from './install';
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../projects/get-projects';
1
+ import { IProjectNode } from '../projects/getProjects';
2
2
  export declare const create: (projects: IProjectNode[]) => {
3
3
  projectsMap: Map<any, any>;
4
4
  projectList: string[];
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../projects/get-projects';
1
+ import { IProjectNode } from '../projects/getProjects';
2
2
  export declare class EdgeManager {
3
3
  private _dependencyEdgeHash;
4
4
  constructor();
@@ -1,3 +1,3 @@
1
- import { IProjectNode } from '../projects/get-projects';
1
+ import { IProjectNode } from '../projects/getProjects';
2
2
  import { DagOperator } from './operator';
3
3
  export declare const initDAG: (projects: IProjectNode[]) => DagOperator;
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../projects/get-projects';
1
+ import { IProjectNode } from '../projects/getProjects';
2
2
  export type Task = (currentProject: IProjectNode, currentProjectPreviousProjects: IProjectNode[], earlyFinishFun: () => void) => Promise<void>;
3
3
  export interface ITraverseConfig {
4
4
  withSelf?: boolean;
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../projects/get-projects';
1
+ import { IProjectNode } from '../projects/getProjects';
2
2
  /**
3
3
  * Calculate the number of packages which must be built before we reach
4
4
  * the furthest away "root" node
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../../projects/get-projects';
1
+ import { IProjectNode } from '../../projects/getProjects';
2
2
  export interface IClearConfig {
3
3
  rootPath: string;
4
4
  removeDirs?: string[];
@@ -1,3 +1,3 @@
1
- import { IProjectNode } from '../../projects/get-projects';
1
+ import { IProjectNode } from '../../projects/getProjects';
2
2
  export type BuildWatchCmdsType = [string] | [string, string] | [string, (project: IProjectNode) => string[]];
3
3
  export declare const defaultBuildWatchCmds: BuildWatchCmdsType;
@@ -1,5 +1,5 @@
1
- import type { IProjectNode } from '../../projects/get-projects';
2
- import type { MultitasksLogger } from '../../log/multi-tasks-log';
1
+ import type { IProjectNode } from '../../projects/getProjects';
2
+ import type { MultitasksLogger } from '../../log/multiTasksLog';
3
3
  import { BuildWatchCmdsType } from './cmds';
4
4
  import type { IBuildWatchConfig } from '.';
5
5
  export declare const createDependenciesTask: (config: IBuildWatchConfig, taskCmds: BuildWatchCmdsType | undefined, taskLogger: MultitasksLogger) => (project: IProjectNode) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import anymatch from 'anymatch';
2
2
  import { ICommandConfig } from '../../type';
3
3
  import { DagOperator } from '../../dag/operator';
4
- import { IProjectNode } from '../../projects/get-projects';
4
+ import { IProjectNode } from '../../projects/getProjects';
5
5
  import { Argu } from '../../utils/types';
6
6
  import { BuildWatchCmdsType } from './cmds';
7
7
  export interface IBuildWatchConfig extends ICommandConfig {
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from '../../projects/get-projects';
1
+ import { IProjectNode } from '../../projects/getProjects';
2
2
  import { IBuildWatchConfig } from '.';
3
3
  export declare class WatchedProjectsState {
4
4
  private readonly _config;
@@ -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").IPackageJsonRepository | import("@rushstack/node-core-library").IPackageJsonScriptTable | undefined;
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
  }
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from './get-projects';
1
+ import { IProjectNode } from './getProjects';
2
2
  export declare const PROJECT_CONTENT_FILE_NAME = "project-content.json";
3
3
  export declare const MONOREPO_GIT_FILE_NAME = "monorepo-git.json";
4
4
  export declare const PROJECT_MEMORY_PATH = ".project-memory";
@@ -1,2 +1,2 @@
1
- import { IProjectNode } from './get-projects';
1
+ import { IProjectNode } from './getProjects';
2
2
  export declare const clearProjectsMemoryFile: (projects: IProjectNode[]) => void;