@modern-js/monorepo-tools 2.4.1-beta.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +35 -8
  2. package/cli.js +1 -1
  3. package/dist/{js/node → cjs}/cli/build-watch.js +3 -23
  4. package/dist/{js/node → cjs}/cli/build.js +3 -23
  5. package/dist/{js/node → cjs}/cli/clear.js +3 -23
  6. package/dist/{js/node → cjs}/cli/deploy.js +3 -23
  7. package/dist/cjs/cli/install.js +34 -0
  8. package/dist/{js/node → cjs}/cli/new.js +3 -40
  9. package/dist/{js/node → cjs}/commands/build-watch.js +4 -24
  10. package/dist/{js/node → cjs}/commands/build.js +9 -41
  11. package/dist/{js/node → cjs}/commands/clear.js +3 -23
  12. package/dist/{js/node → cjs}/commands/deploy.js +4 -24
  13. package/dist/{js/node → cjs}/commands/install.js +4 -24
  14. package/dist/{js/node → cjs}/dag/create.js +9 -16
  15. package/dist/cjs/dag/operator.js +269 -0
  16. package/dist/{js/node → cjs}/dag/task.js +33 -53
  17. package/dist/{js/node → cjs}/features/build/index.js +17 -33
  18. package/dist/{js/node → cjs}/features/clear/index.js +4 -0
  19. package/dist/{js/node → cjs}/features/deploy/index.js +15 -30
  20. package/dist/{js/node → cjs}/features/dev/create-task.js +10 -26
  21. package/dist/{js/node → cjs}/features/dev/index.js +18 -34
  22. package/dist/{js/node → cjs}/features/dev/watch-projects-state.js +7 -19
  23. package/dist/{js/node → cjs}/features/install/index.js +7 -23
  24. package/dist/{js/node → cjs}/index.js +4 -0
  25. package/dist/{js/node → cjs}/log/time.js +1 -15
  26. package/dist/{js/node → cjs}/parse-config/index.js +13 -39
  27. package/dist/{js/node → cjs}/parse-config/monorepo.js +4 -0
  28. package/dist/{js/node → cjs}/projects/check-project-change.js +16 -32
  29. package/dist/{js/node → cjs}/projects/clear-memory-files.js +4 -0
  30. package/dist/{js/node → cjs}/projects/get-projects-by-packages-config.js +17 -45
  31. package/dist/{js/node → cjs}/projects/get-projects-by-workspace-file.js +8 -24
  32. package/dist/{js/node → cjs}/projects/get-projects.js +18 -47
  33. package/dist/{js/node → cjs}/utils/install.js +8 -24
  34. package/dist/esm/cli/build-watch.js +11 -0
  35. package/dist/esm/cli/build.js +12 -0
  36. package/dist/esm/cli/clear.js +11 -0
  37. package/dist/esm/cli/deploy.js +16 -0
  38. package/dist/esm/cli/install.js +11 -0
  39. package/dist/esm/cli/new.js +18 -0
  40. package/dist/esm/commands/build-watch.js +24 -0
  41. package/dist/esm/commands/build.js +56 -0
  42. package/dist/esm/commands/clear.js +19 -0
  43. package/dist/{js/modern → esm}/commands/deploy.js +4 -24
  44. package/dist/esm/commands/install.js +23 -0
  45. package/dist/{js/modern → esm}/dag/create.js +9 -18
  46. package/dist/esm/dag/operator.js +236 -0
  47. package/dist/esm/dag/task.js +55 -0
  48. package/dist/{js/modern → esm}/features/build/index.js +13 -33
  49. package/dist/{js/modern → esm}/features/deploy/index.js +11 -30
  50. package/dist/{js/modern → esm}/features/dev/create-task.js +6 -26
  51. package/dist/{js/modern → esm}/features/dev/index.js +14 -34
  52. package/dist/{js/modern → esm}/features/dev/watch-projects-state.js +3 -21
  53. package/dist/{js/modern → esm}/features/install/index.js +3 -23
  54. package/dist/esm/log/time.js +13 -0
  55. package/dist/esm/parse-config/index.js +19 -0
  56. package/dist/{js/modern → esm}/projects/check-project-change.js +12 -32
  57. package/dist/{js/modern → esm}/projects/get-projects-by-packages-config.js +13 -47
  58. package/dist/{js/modern → esm}/projects/get-projects-by-workspace-file.js +4 -24
  59. package/dist/{js/modern → esm}/projects/get-projects.js +18 -49
  60. package/dist/esm/utils/install.js +27 -0
  61. package/dist/types/package/index.d.ts +1 -1
  62. package/package.json +16 -16
  63. package/dist/js/modern/cli/build-watch.js +0 -31
  64. package/dist/js/modern/cli/build.js +0 -32
  65. package/dist/js/modern/cli/clear.js +0 -31
  66. package/dist/js/modern/cli/deploy.js +0 -36
  67. package/dist/js/modern/cli/install.js +0 -31
  68. package/dist/js/modern/cli/new.js +0 -57
  69. package/dist/js/modern/commands/build-watch.js +0 -44
  70. package/dist/js/modern/commands/build.js +0 -90
  71. package/dist/js/modern/commands/clear.js +0 -39
  72. package/dist/js/modern/commands/install.js +0 -43
  73. package/dist/js/modern/dag/operator.js +0 -251
  74. package/dist/js/modern/dag/task.js +0 -79
  75. package/dist/js/modern/log/time.js +0 -29
  76. package/dist/js/modern/parse-config/index.js +0 -51
  77. package/dist/js/modern/utils/install.js +0 -47
  78. package/dist/js/node/cli/install.js +0 -54
  79. package/dist/js/node/dag/operator.js +0 -278
  80. /package/dist/{js/node → cjs}/cli/index.js +0 -0
  81. /package/dist/{js/node → cjs}/commands/index.js +0 -0
  82. /package/dist/{js/node → cjs}/constants.js +0 -0
  83. /package/dist/{js/node → cjs}/dag/edge-manager.js +0 -0
  84. /package/dist/{js/node → cjs}/dag/index.js +0 -0
  85. /package/dist/{js/node → cjs}/dag/utils.js +0 -0
  86. /package/dist/{js/node → cjs}/features/dev/cmds.js +0 -0
  87. /package/dist/{js/node → cjs}/hooks/index.js +0 -0
  88. /package/dist/{js/node → cjs}/locale/en.js +0 -0
  89. /package/dist/{js/node → cjs}/locale/index.js +0 -0
  90. /package/dist/{js/node → cjs}/locale/zh.js +0 -0
  91. /package/dist/{js/node → cjs}/log/error.js +0 -0
  92. /package/dist/{js/node → cjs}/log/multi-tasks-log.js +0 -0
  93. /package/dist/{js/node → cjs}/log/utils.js +0 -0
  94. /package/dist/{js/node → cjs}/package/index.js +0 -0
  95. /package/dist/{js/node → cjs}/type.js +0 -0
  96. /package/dist/{js/node → cjs}/utils/language.js +0 -0
  97. /package/dist/{js/node → cjs}/utils/types.js +0 -0
  98. /package/dist/{js/modern → esm}/cli/index.js +0 -0
  99. /package/dist/{js/modern → esm}/commands/index.js +0 -0
  100. /package/dist/{js/modern → esm}/constants.js +0 -0
  101. /package/dist/{js/modern → esm}/dag/edge-manager.js +0 -0
  102. /package/dist/{js/modern → esm}/dag/index.js +0 -0
  103. /package/dist/{js/modern → esm}/dag/utils.js +0 -0
  104. /package/dist/{js/modern → esm}/features/clear/index.js +0 -0
  105. /package/dist/{js/modern → esm}/features/dev/cmds.js +0 -0
  106. /package/dist/{js/modern → esm}/hooks/index.js +0 -0
  107. /package/dist/{js/modern → esm}/index.js +0 -0
  108. /package/dist/{js/modern → esm}/locale/en.js +0 -0
  109. /package/dist/{js/modern → esm}/locale/index.js +0 -0
  110. /package/dist/{js/modern → esm}/locale/zh.js +0 -0
  111. /package/dist/{js/modern → esm}/log/error.js +0 -0
  112. /package/dist/{js/modern → esm}/log/multi-tasks-log.js +0 -0
  113. /package/dist/{js/modern → esm}/log/utils.js +0 -0
  114. /package/dist/{js/modern → esm}/package/index.js +0 -0
  115. /package/dist/{js/modern → esm}/parse-config/monorepo.js +0 -0
  116. /package/dist/{js/modern → esm}/projects/clear-memory-files.js +0 -0
  117. /package/dist/{js/modern → esm}/type.js +0 -0
  118. /package/dist/{js/modern → esm}/utils/language.js +0 -0
  119. /package/dist/{js/modern → esm}/utils/types.js +0 -0
@@ -2,22 +2,8 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
7
  var __export = (target, all) => {
22
8
  for (var name in all)
23
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -31,30 +17,14 @@ var __copyProps = (to, from, except, desc) => {
31
17
  return to;
32
18
  };
33
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.
34
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
25
  mod
36
26
  ));
37
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var __async = (__this, __arguments, generator) => {
39
- return new Promise((resolve, reject) => {
40
- var fulfilled = (value) => {
41
- try {
42
- step(generator.next(value));
43
- } catch (e) {
44
- reject(e);
45
- }
46
- };
47
- var rejected = (value) => {
48
- try {
49
- step(generator.throw(value));
50
- } catch (e) {
51
- reject(e);
52
- }
53
- };
54
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
55
- step((generator = generator.apply(__this, __arguments)).next());
56
- });
57
- };
58
28
  var get_projects_by_packages_config_exports = {};
59
29
  __export(get_projects_by_packages_config_exports, {
60
30
  getProjectsByPackageConfig: () => getProjectsByPackageConfig,
@@ -82,6 +52,8 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
82
52
  );
83
53
  }
84
54
  globOpts.ignore = [
55
+ // allow globs like "packages/**",
56
+ // but avoid picking up node_modules/**/package.json and dist/**/package.json
85
57
  "**/dist/**",
86
58
  "**/node_modules/**",
87
59
  ...ignore || []
@@ -91,23 +63,23 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
91
63
  };
92
64
  const makeFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
93
65
  const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
94
- return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (fileName, fileMapper, customGlobOpts = {}) {
95
- const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
66
+ return async (fileName, fileMapper, customGlobOpts = {}) => {
67
+ const options = { ...customGlobOpts, ...globOpts };
96
68
  const promise = (0, import_p_map.default)(
97
69
  Array.from(packageConfigs).sort(),
98
- (globPath) => __async(void 0, null, function* () {
99
- let result = yield (0, import_utils.globby)(path.posix.join(globPath, fileName), options);
70
+ async (globPath) => {
71
+ let result = await (0, import_utils.globby)(path.posix.join(globPath, fileName), options);
100
72
  result = result.sort();
101
73
  result = normalize(result);
102
74
  return fileMapper(result);
103
- }),
75
+ },
104
76
  { concurrency: packageConfigs.length || Infinity }
105
77
  );
106
- const results = yield promise;
78
+ const results = await promise;
107
79
  return results.reduce((acc, result) => acc.concat(result), []);
108
- });
80
+ };
109
81
  };
110
- const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) => __async(void 0, null, function* () {
82
+ const getProjectsByPackageConfig = async (rootPath, packagesConfig, ignoreConfigs) => {
111
83
  const finder = makeFileFinder(rootPath, packagesConfig, ignoreConfigs);
112
84
  const fileName = "package.json";
113
85
  const mapper = (packageConfigPath) => {
@@ -115,18 +87,18 @@ const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) =>
115
87
  const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
116
88
  return new import_package.Package(packageJson, path.dirname(packageConfigPath), rootPath);
117
89
  };
118
- const projects = yield finder(
90
+ const projects = await finder(
119
91
  fileName,
120
92
  (filePaths) => (0, import_p_map.default)(filePaths, mapper, { concurrency: filePaths.length || Infinity }),
121
93
  {}
122
94
  );
123
95
  return projects;
124
- });
96
+ };
125
97
  const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
126
98
  const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
127
99
  return (fileName, fileMapper, customGlobOpts = {}) => {
128
100
  const results = [];
129
- const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
101
+ const options = { ...customGlobOpts, ...globOpts };
130
102
  for (const globPath of Array.from(packageConfigs).sort()) {
131
103
  let result = import_utils.globby.sync(path.posix.join(globPath, fileName), options);
132
104
  result = result.sort();
@@ -17,30 +17,14 @@ 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 __async = (__this, __arguments, generator) => {
25
- return new Promise((resolve, reject) => {
26
- var fulfilled = (value) => {
27
- try {
28
- step(generator.next(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var rejected = (value) => {
34
- try {
35
- step(generator.throw(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- };
40
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
- step((generator = generator.apply(__this, __arguments)).next());
42
- });
43
- };
44
28
  var get_projects_by_workspace_file_exports = {};
45
29
  __export(get_projects_by_workspace_file_exports, {
46
30
  getProjectsByWorkspaceFile: () => getProjectsByWorkspaceFile,
@@ -53,7 +37,7 @@ var import_utils = require("@modern-js/utils");
53
37
  var import_monorepo = require("../parse-config/monorepo");
54
38
  var import_constants = require("../constants");
55
39
  var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
56
- const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(void 0, null, function* () {
40
+ const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
57
41
  var _a, _b, _c;
58
42
  let { workspaceFile } = config;
59
43
  if (!config.enableAutoFinder && (!("workspaceFile" in config) || ((_a = config.workspaceFile) == null ? void 0 : _a.length) === 0)) {
@@ -66,7 +50,7 @@ const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(
66
50
  }
67
51
  let packagesConfig = [];
68
52
  if (workspaceFile === import_constants.WORKSPACE_FILE.PNPM) {
69
- const yamlString = yield import_node_core_library.FileSystem.readFileAsync(
53
+ const yamlString = await import_node_core_library.FileSystem.readFileAsync(
70
54
  path.resolve("/", rootPath, workspaceFile)
71
55
  ).then((data) => data.toString());
72
56
  const pnpmWorkspace = import_utils.yaml.load(yamlString);
@@ -78,13 +62,13 @@ const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(
78
62
  const lernaJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
79
63
  packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
80
64
  }
81
- const projects = yield (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(
65
+ const projects = await (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(
82
66
  rootPath,
83
67
  packagesConfig,
84
68
  ignoreConfigs
85
69
  );
86
70
  return projects;
87
- });
71
+ };
88
72
  const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
89
73
  var _a, _b, _c;
90
74
  let { workspaceFile } = config;
@@ -1,21 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
5
  var __export = (target, all) => {
20
6
  for (var name in all)
21
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -29,26 +15,6 @@ var __copyProps = (to, from, except, desc) => {
29
15
  return to;
30
16
  };
31
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
18
  var get_projects_exports = {};
53
19
  __export(get_projects_exports, {
54
20
  getProjects: () => getProjects,
@@ -70,6 +36,7 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
70
36
  subProjects.push({
71
37
  name: config.name,
72
38
  extra: { path: config.path },
39
+ // dagNodeEdge: 0,
73
40
  dependencyEdge: 0,
74
41
  dependentEdge: 0,
75
42
  checkedCircle: false,
@@ -78,12 +45,12 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
78
45
  }
79
46
  return subProjects;
80
47
  };
81
- const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0, null, function* () {
48
+ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
82
49
  let projects = [];
83
50
  if (Array.isArray(match)) {
84
- projects = yield (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(rootPath, match, ignore);
51
+ projects = await (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(rootPath, match, ignore);
85
52
  } else {
86
- projects = yield (0, import_get_projects_by_workspace_file.getProjectsByWorkspaceFile)(
53
+ projects = await (0, import_get_projects_by_workspace_file.getProjectsByWorkspaceFile)(
87
54
  rootPath,
88
55
  match,
89
56
  ignore
@@ -93,9 +60,11 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
93
60
  for (const project of projects) {
94
61
  subProjects.push({
95
62
  name: project.name,
96
- extra: __spreadValues({
97
- path: project.path
98
- }, project.json),
63
+ extra: {
64
+ path: project.path,
65
+ ...project.json
66
+ },
67
+ // dagNodeEdge: 0,
99
68
  dependencyEdge: 0,
100
69
  dependentEdge: 0,
101
70
  checkedCircle: false,
@@ -103,7 +72,7 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
103
72
  });
104
73
  }
105
74
  return subProjects;
106
- });
75
+ };
107
76
  const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
108
77
  let projects = [];
109
78
  if (Array.isArray(match)) {
@@ -119,9 +88,11 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
119
88
  for (const project of projects) {
120
89
  subProjects.push({
121
90
  name: project.name,
122
- extra: __spreadValues({
123
- path: project.path
124
- }, project.json),
91
+ extra: {
92
+ path: project.path,
93
+ ...project.json
94
+ },
95
+ // dagNodeEdge: 0,
125
96
  dependencyEdge: 0,
126
97
  dependentEdge: 0,
127
98
  checkedCircle: false,
@@ -145,12 +116,12 @@ const checkFindProjectsMode = (config) => {
145
116
  }
146
117
  (0, import_error.errorLog)("No `packagesMatchs` and `projectsConfig` configurations found");
147
118
  };
148
- const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (config, currentDir = process.cwd()) {
119
+ const getProjects = async (config, currentDir = process.cwd()) => {
149
120
  const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
150
121
  const mode = checkFindProjectsMode(config);
151
122
  let projects = [];
152
123
  if (mode === 0 /* Rough */) {
153
- projects = yield getProjectsByPackagesMatch(
124
+ projects = await getProjectsByPackagesMatch(
154
125
  rootPath,
155
126
  config.packagesMatchs,
156
127
  config.packagesIgnoreMatchs || []
@@ -159,7 +130,7 @@ const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (confi
159
130
  projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
160
131
  }
161
132
  return projects;
162
- });
133
+ };
163
134
  const syncGetProjects = (config, currentDir = process.cwd()) => {
164
135
  const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
165
136
  const mode = checkFindProjectsMode(config);
@@ -17,30 +17,14 @@ 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 __async = (__this, __arguments, generator) => {
25
- return new Promise((resolve, reject) => {
26
- var fulfilled = (value) => {
27
- try {
28
- step(generator.next(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var rejected = (value) => {
34
- try {
35
- step(generator.throw(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- };
40
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
- step((generator = generator.apply(__this, __arguments)).next());
42
- });
43
- };
44
28
  var install_exports = {};
45
29
  __export(install_exports, {
46
30
  installByPackageManager: () => installByPackageManager,
@@ -59,17 +43,17 @@ const removeLockFile = (rootPath, packageManager) => {
59
43
  import_utils.fs.removeSync(path.join(rootPath, import_constants.LOCK_FILE.NPM));
60
44
  }
61
45
  };
62
- const installByPackageManager = (_0, _1) => __async(void 0, [_0, _1], function* (packageManager, { rootPath, removeLock }) {
46
+ const installByPackageManager = async (packageManager, { rootPath, removeLock }) => {
63
47
  if (removeLock) {
64
48
  removeLockFile(rootPath, packageManager);
65
49
  }
66
50
  if (packageManager === "pnpm") {
67
- yield (0, import_utils.execa)("pnpm", ["install"], { stdio: "inherit" });
51
+ await (0, import_utils.execa)("pnpm", ["install"], { stdio: "inherit" });
68
52
  }
69
53
  if (packageManager === "yarn") {
70
- yield (0, import_utils.execa)("yarn", ["install"], { stdio: "inherit" });
54
+ await (0, import_utils.execa)("yarn", ["install"], { stdio: "inherit" });
71
55
  }
72
- });
56
+ };
73
57
  // Annotate the CommonJS export names for ESM import in node:
74
58
  0 && (module.exports = {
75
59
  installByPackageManager,
@@ -0,0 +1,11 @@
1
+ import { buildWatch } from "../commands";
2
+ const buildWatchCli = (program, api) => {
3
+ program.command("build-watch [project]").usage("[options]").option("--only-self", "build target project with nothing").option("-i, --init", "init build beforebuild watch ").description("watch target project and target project’s dependencies").action(
4
+ async (targetProjectName, option) => {
5
+ await buildWatch(targetProjectName, option, api);
6
+ }
7
+ );
8
+ };
9
+ export {
10
+ buildWatchCli
11
+ };
@@ -0,0 +1,12 @@
1
+ import { build } from "../commands";
2
+ const buildCli = (program, api) => {
3
+ program.command("build [project]").usage("[options]").option("--no-self", "build without target project").option("-t, --dept", "build target project with project’s dependent").option("--no-deps", "build target project without project’s dependencies").option("--only-self", "build target project with nothing").option(
4
+ "-a, --all",
5
+ "build target project with project’s dependencies and dependent"
6
+ ).option("--content-hash", "build target project use content hash cache").option("--git-hash", "build target project use git hash cache").description("build target project").action(async (targetProjectName, option) => {
7
+ await build(targetProjectName, option, api);
8
+ });
9
+ };
10
+ export {
11
+ buildCli
12
+ };
@@ -0,0 +1,11 @@
1
+ import { clear } from "../commands";
2
+ const clearCli = (program, api) => {
3
+ program.command("clear [projects...]").usage("[options]").option("--remove-dirs [dirs...]", "remove dirs, default is node_modules").description("clear project dirs").action(
4
+ async (targetProjectNames, option) => {
5
+ await clear(targetProjectNames, option, api);
6
+ }
7
+ );
8
+ };
9
+ export {
10
+ clearCli
11
+ };
@@ -0,0 +1,16 @@
1
+ import { deploy } from "../commands";
2
+ const deployCli = (program, api) => {
3
+ program.command("deploy [project...]").usage("[options]").option(
4
+ "-p, --path [path]",
5
+ "Specify the path of the product output",
6
+ "output"
7
+ ).description("deploy project").action(
8
+ async (deployProjectNames, option) => {
9
+ const ignoreMatchs = ["**/output/**"];
10
+ await deploy(api, deployProjectNames, option, ignoreMatchs);
11
+ }
12
+ );
13
+ };
14
+ export {
15
+ deployCli
16
+ };
@@ -0,0 +1,11 @@
1
+ import { install } from "../commands";
2
+ const installCli = (program, api) => {
3
+ program.command("install [project...]").usage("[options]").description("install deps for some projects").action(
4
+ async (installProjectNames, option) => {
5
+ await install(installProjectNames, option, api);
6
+ }
7
+ );
8
+ };
9
+ export {
10
+ installCli
11
+ };
@@ -0,0 +1,18 @@
1
+ import { MonorepoNewAction } from "@modern-js/new-action";
2
+ import { i18n, localeKeys } from "../locale";
3
+ const newCli = (program, locale) => {
4
+ program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option(
5
+ "-p, --plugin <plugin>",
6
+ i18n.t(localeKeys.command.new.plugin),
7
+ (val, memo) => {
8
+ memo.push(val);
9
+ return memo;
10
+ },
11
+ []
12
+ ).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(async (options) => {
13
+ await MonorepoNewAction({ ...options, locale: options.lang || locale });
14
+ });
15
+ };
16
+ export {
17
+ newCli
18
+ };
@@ -0,0 +1,24 @@
1
+ import { getMonorepoBaseData } from "../parse-config/monorepo";
2
+ import { runBuildWatchTask } from "../features/dev";
3
+ import { getProjects } from "../projects/get-projects";
4
+ import { initDAG } from "../dag";
5
+ const buildWatch = async (targetProjectName, option, api) => {
6
+ const { appDirectory } = api.useAppContext();
7
+ const { onlySelf = false, init = false } = option;
8
+ const projects = await getProjects(
9
+ { packagesMatchs: { enableAutoFinder: true } },
10
+ appDirectory
11
+ );
12
+ const operator = initDAG(projects);
13
+ operator.checkCircle();
14
+ const { rootPath, packageManager } = getMonorepoBaseData(process.cwd());
15
+ await runBuildWatchTask(targetProjectName, operator, {
16
+ rootPath,
17
+ packageManager,
18
+ onlySelf,
19
+ needInit: init
20
+ });
21
+ };
22
+ export {
23
+ buildWatch
24
+ };
@@ -0,0 +1,56 @@
1
+ import { getMonorepoBaseData } from "../parse-config/monorepo";
2
+ import { runBuildTask, runAllBuildTask } from "../features/build";
3
+ import { getProjects } from "../projects/get-projects";
4
+ import { initDAG } from "../dag";
5
+ const build = async (targetProjectName, option, api) => {
6
+ const { appDirectory } = api.useAppContext();
7
+ const {
8
+ self = true,
9
+ dept = false,
10
+ deps = true,
11
+ onlySelf = false,
12
+ all = false,
13
+ contentHash = false,
14
+ gitHash = false
15
+ } = option;
16
+ const projects = await getProjects(
17
+ { packagesMatchs: { enableAutoFinder: true } },
18
+ appDirectory
19
+ );
20
+ const operator = initDAG(projects);
21
+ operator.checkCircle();
22
+ const { rootPath, packageManager } = getMonorepoBaseData(appDirectory);
23
+ const overrideConfig = {};
24
+ if (all) {
25
+ overrideConfig.disableWithDeps = false;
26
+ overrideConfig.withSelf = true;
27
+ overrideConfig.withDept = true;
28
+ }
29
+ if (targetProjectName) {
30
+ runBuildTask(targetProjectName, operator, {
31
+ rootPath,
32
+ packageManager,
33
+ withSelf: self,
34
+ withDept: dept,
35
+ onlySelf,
36
+ disableWithDeps: !deps,
37
+ // The CI/CD phase is recommended to be switched on
38
+ disableContentHash: !contentHash,
39
+ enableGitHash: gitHash,
40
+ ...overrideConfig
41
+ });
42
+ } else {
43
+ const currentDir = process.cwd();
44
+ if (currentDir === appDirectory) {
45
+ await runAllBuildTask(operator, {
46
+ rootPath: currentDir,
47
+ packageManager,
48
+ disableContentHash: !contentHash,
49
+ enableGitHash: gitHash
50
+ });
51
+ }
52
+ }
53
+ };
54
+ export {
55
+ build
56
+ };
@@ -0,0 +1,19 @@
1
+ import { getProjects } from "../projects/get-projects";
2
+ import { getMonorepoBaseData } from "../parse-config/monorepo";
3
+ import { runClearTask } from "../features/clear";
4
+ const clear = async (projectNames, option, api) => {
5
+ const { removeDirs } = option;
6
+ const { appDirectory } = api.useAppContext();
7
+ const projects = await getProjects(
8
+ { packagesMatchs: { enableAutoFinder: true } },
9
+ appDirectory
10
+ );
11
+ const { rootPath } = getMonorepoBaseData(appDirectory);
12
+ runClearTask(projectNames, projects, {
13
+ rootPath,
14
+ removeDirs
15
+ });
16
+ };
17
+ export {
18
+ clear
19
+ };
@@ -1,33 +1,13 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { logger } from "@modern-js/utils";
22
2
  import { initDAG } from "../dag";
23
3
  import { getMonorepoBaseData } from "../parse-config/monorepo";
24
4
  import { getProjects } from "../projects/get-projects";
25
5
  import { deploy as runDeployTask } from "../features/deploy";
26
- const deploy = (_0, _1, _2, ..._3) => __async(void 0, [_0, _1, _2, ..._3], function* (api, deployProjectNames, option, ignoreMatchs = []) {
6
+ const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
27
7
  const { deployPath = "output" } = option;
28
8
  const { appDirectory } = api.useAppContext();
29
9
  logger.info(`start deploy ${deployProjectNames.join(",")}`);
30
- const projects = yield getProjects(
10
+ const projects = await getProjects(
31
11
  {
32
12
  packagesMatchs: { enableAutoFinder: true },
33
13
  packagesIgnoreMatchs: ignoreMatchs
@@ -36,14 +16,14 @@ const deploy = (_0, _1, _2, ..._3) => __async(void 0, [_0, _1, _2, ..._3], funct
36
16
  );
37
17
  const { rootPath, packageManager } = getMonorepoBaseData(process.cwd());
38
18
  const operator = initDAG(projects);
39
- yield runDeployTask(deployProjectNames, operator, {
19
+ await runDeployTask(deployProjectNames, operator, {
40
20
  rootPath,
41
21
  packageManager,
42
22
  deployPath
43
23
  });
44
24
  const runners = api.useHookRunners();
45
25
  runners.afterMonorepoDeploy({ operator, deployProjectNames });
46
- });
26
+ };
47
27
  export {
48
28
  deploy
49
29
  };
@@ -0,0 +1,23 @@
1
+ import { runInstallTask } from "../features/install";
2
+ import { getMonorepoBaseData } from "../parse-config/monorepo";
3
+ import { getProjects } from "../projects/get-projects";
4
+ import { initDAG } from "../dag";
5
+ const install = async (projectNames = [], option, api) => {
6
+ const { appDirectory } = api.useAppContext();
7
+ const { auto } = option;
8
+ const projects = await getProjects(
9
+ { packagesMatchs: { enableAutoFinder: true } },
10
+ appDirectory
11
+ );
12
+ const operator = initDAG(projects);
13
+ operator.checkCircle();
14
+ const { rootPath, packageManager } = getMonorepoBaseData(appDirectory);
15
+ await runInstallTask(projectNames, operator, {
16
+ packageManager,
17
+ rootPath,
18
+ auto
19
+ });
20
+ };
21
+ export {
22
+ install
23
+ };