@modern-js/monorepo-tools 2.14.0 → 2.16.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 (96) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cjs/cli/build.js +10 -31
  3. package/dist/cjs/cli/buildWatch.js +11 -31
  4. package/dist/cjs/cli/clear.js +11 -31
  5. package/dist/cjs/cli/deploy.js +14 -36
  6. package/dist/cjs/cli/index.js +23 -22
  7. package/dist/cjs/cli/install.js +11 -31
  8. package/dist/cjs/cli/new.js +17 -37
  9. package/dist/cjs/commands/build.js +21 -46
  10. package/dist/cjs/commands/buildWatch.js +19 -36
  11. package/dist/cjs/commands/clear.js +17 -34
  12. package/dist/cjs/commands/deploy.js +25 -41
  13. package/dist/cjs/commands/index.js +22 -21
  14. package/dist/cjs/commands/install.js +19 -36
  15. package/dist/cjs/constants.js +13 -26
  16. package/dist/cjs/dag/create.js +16 -28
  17. package/dist/cjs/dag/edgeManager.js +24 -28
  18. package/dist/cjs/dag/index.js +11 -29
  19. package/dist/cjs/dag/operator.js +106 -123
  20. package/dist/cjs/dag/task.js +52 -63
  21. package/dist/cjs/dag/utils.js +52 -49
  22. package/dist/cjs/features/build/index.js +52 -68
  23. package/dist/cjs/features/clear/index.js +66 -47
  24. package/dist/cjs/features/deploy/index.js +126 -96
  25. package/dist/cjs/features/dev/cmds.js +10 -25
  26. package/dist/cjs/features/dev/createTask.js +93 -56
  27. package/dist/cjs/features/dev/index.js +43 -71
  28. package/dist/cjs/features/dev/watchProjectsState.js +89 -64
  29. package/dist/cjs/features/install/index.js +74 -63
  30. package/dist/cjs/hooks/index.js +9 -27
  31. package/dist/cjs/index.js +36 -53
  32. package/dist/cjs/locale/en.js +7 -25
  33. package/dist/cjs/locale/index.js +18 -28
  34. package/dist/cjs/locale/zh.js +7 -25
  35. package/dist/cjs/log/error.js +7 -25
  36. package/dist/cjs/log/multiTasksLog.js +42 -43
  37. package/dist/cjs/log/time.js +19 -29
  38. package/dist/cjs/log/utils.js +7 -25
  39. package/dist/cjs/package/index.js +28 -30
  40. package/dist/cjs/parse-config/index.js +61 -49
  41. package/dist/cjs/parse-config/monorepo.js +81 -67
  42. package/dist/cjs/projects/checkProjectChange.js +95 -73
  43. package/dist/cjs/projects/clearMemoryFiles.js +52 -44
  44. package/dist/cjs/projects/getProjects.js +38 -65
  45. package/dist/cjs/projects/getProjectsByPackagesConfig.js +93 -71
  46. package/dist/cjs/projects/getProjectsByWorkspaceFile.js +89 -85
  47. package/dist/cjs/type.js +4 -15
  48. package/dist/cjs/utils/install.js +69 -44
  49. package/dist/cjs/utils/types.js +4 -15
  50. package/dist/esm/cli/build.js +2 -8
  51. package/dist/esm/cli/buildWatch.js +4 -9
  52. package/dist/esm/cli/clear.js +4 -9
  53. package/dist/esm/cli/deploy.js +7 -14
  54. package/dist/esm/cli/install.js +4 -9
  55. package/dist/esm/cli/new.js +9 -14
  56. package/dist/esm/commands/build.js +7 -17
  57. package/dist/esm/commands/buildWatch.js +6 -8
  58. package/dist/esm/commands/clear.js +6 -8
  59. package/dist/esm/commands/deploy.js +10 -11
  60. package/dist/esm/commands/install.js +6 -8
  61. package/dist/esm/constants.js +2 -6
  62. package/dist/esm/dag/create.js +10 -7
  63. package/dist/esm/dag/edgeManager.js +17 -6
  64. package/dist/esm/dag/index.js +1 -4
  65. package/dist/esm/dag/operator.js +77 -74
  66. package/dist/esm/dag/task.js +39 -30
  67. package/dist/esm/dag/utils.js +39 -27
  68. package/dist/esm/features/build/index.js +22 -27
  69. package/dist/esm/features/clear/index.js +4 -6
  70. package/dist/esm/features/deploy/index.js +55 -50
  71. package/dist/esm/features/dev/cmds.js +4 -4
  72. package/dist/esm/features/dev/createTask.js +31 -15
  73. package/dist/esm/features/dev/index.js +19 -27
  74. package/dist/esm/features/dev/watchProjectsState.js +41 -31
  75. package/dist/esm/features/install/index.js +11 -15
  76. package/dist/esm/hooks/index.js +1 -4
  77. package/dist/esm/index.js +12 -11
  78. package/dist/esm/locale/en.js +1 -4
  79. package/dist/esm/locale/index.js +5 -5
  80. package/dist/esm/locale/zh.js +1 -4
  81. package/dist/esm/log/error.js +1 -4
  82. package/dist/esm/log/multiTasksLog.js +32 -18
  83. package/dist/esm/log/time.js +7 -8
  84. package/dist/esm/log/utils.js +1 -4
  85. package/dist/esm/package/index.js +21 -8
  86. package/dist/esm/parse-config/index.js +11 -14
  87. package/dist/esm/parse-config/monorepo.js +20 -27
  88. package/dist/esm/projects/checkProjectChange.js +19 -23
  89. package/dist/esm/projects/clearMemoryFiles.js +3 -13
  90. package/dist/esm/projects/getProjects.js +21 -45
  91. package/dist/esm/projects/getProjectsByPackagesConfig.js +29 -33
  92. package/dist/esm/projects/getProjectsByWorkspaceFile.js +21 -41
  93. package/dist/esm/type.js +1 -0
  94. package/dist/esm/utils/install.js +12 -8
  95. package/dist/esm/utils/types.js +1 -0
  96. package/package.json +16 -12
@@ -1,59 +1,41 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var build_exports = {};
29
- __export(build_exports, {
30
- runAllBuildTask: () => runAllBuildTask,
31
- runBuildTask: () => runBuildTask
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ runBuildTask: () => runBuildTask,
14
+ runAllBuildTask: () => runAllBuildTask
32
15
  });
33
- module.exports = __toCommonJS(build_exports);
34
- var import_os = __toESM(require("os"));
35
- var import_utils = require("@modern-js/utils");
36
- var import_checkProjectChange = require("../../projects/checkProjectChange");
37
- var import_error = require("../../log/error");
38
- var import_multiTasksLog = require("../../log/multiTasksLog");
16
+ const _os = /* @__PURE__ */ _interop_require_default(require("os"));
17
+ const _utils = require("@modern-js/utils");
18
+ const _checkProjectChange = require("../../projects/checkProjectChange");
19
+ const _error = require("../../log/error");
20
+ const _multiTasksLog = require("../../log/multiTasksLog");
21
+ function _interop_require_default(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
39
26
  const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
40
- const {
41
- rootPath,
42
- packageManager,
43
- disableContentHash = false,
44
- enableGitHash = false
45
- } = config;
27
+ const { rootPath, packageManager, disableContentHash = false, enableGitHash = false } = config;
46
28
  const task = async (project) => {
47
29
  console.info("run ", project.name);
48
30
  if (!disableContentHash) {
49
- const changed = await (0, import_checkProjectChange.checkProjectChangeByContent)(project);
31
+ const changed = await (0, _checkProjectChange.checkProjectChangeByContent)(project);
50
32
  if (!changed) {
51
33
  console.info(`${project.name} content not change, skip`);
52
34
  return;
53
35
  }
54
36
  }
55
37
  if (enableGitHash) {
56
- const changed = await (0, import_checkProjectChange.checkProjectChangeByGit)(project, rootPath);
38
+ const changed = await (0, _checkProjectChange.checkProjectChangeByGit)(project, rootPath);
57
39
  if (!changed) {
58
40
  console.info(`${project.name} not change, skip`);
59
41
  return;
@@ -64,21 +46,29 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
64
46
  for (const taskCmd of taskCmds) {
65
47
  if (cmd[taskCmd]) {
66
48
  const prefix = `run ${project.name} ${taskCmd} script`;
67
- import_utils.signale.time(prefix);
49
+ _utils.signale.time(prefix);
68
50
  try {
69
- const childProcess = (0, import_utils.execa)(packageManager, [taskCmd], {
51
+ const childProcess = (0, _utils.execa)(packageManager, [
52
+ taskCmd
53
+ ], {
70
54
  cwd: project.extra.path,
71
- stdio: ["pipe", "pipe", "pipe"]
55
+ stdio: [
56
+ "pipe",
57
+ "pipe",
58
+ "pipe"
59
+ ]
72
60
  });
73
61
  taskLogger.addLogProvider(project.name, {
74
62
  stdout: childProcess.stdout,
75
63
  stderr: childProcess.stderr,
76
- logConfig: { label: "BUILD: " }
64
+ logConfig: {
65
+ label: "BUILD: "
66
+ }
77
67
  });
78
68
  await childProcess;
79
- import_utils.signale.timeEnd(prefix);
69
+ _utils.signale.timeEnd(prefix);
80
70
  } catch (e) {
81
- (0, import_error.errorLog)(project.name, e.message);
71
+ (0, _error.errorLog)(project.name, e.message);
82
72
  }
83
73
  } else {
84
74
  console.info(`${project.name} not have ${taskCmd}, skip it.`);
@@ -87,42 +77,36 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
87
77
  };
88
78
  return task;
89
79
  };
90
- const defaultBuildCmds = ["build"];
80
+ const defaultBuildCmds = [
81
+ "build"
82
+ ];
91
83
  const runBuildTask = async (projectName, operator, config, taskCmds = defaultBuildCmds) => {
92
- const {
93
- withSelf = true,
94
- onlySelf = false,
95
- disableWithDeps = false,
96
- withDept = false
97
- } = config;
98
- const taskLogger = new import_multiTasksLog.MultitasksLogger();
84
+ const { withSelf = true, onlySelf = false, disableWithDeps = false, withDept = false } = config;
85
+ const taskLogger = new _multiTasksLog.MultitasksLogger();
99
86
  const task = createTask(config, taskCmds, taskLogger);
100
87
  if (onlySelf) {
101
- await task(operator.getNodeData(projectName, { checkExist: true }));
88
+ await task(operator.getNodeData(projectName, {
89
+ checkExist: true
90
+ }));
102
91
  } else if (!disableWithDeps && withDept) {
103
92
  await operator.traverseDependenciesToProjectToDependent(projectName, task, {
104
93
  withSelf,
105
- runTaskConcurrency: import_os.default.cpus().length
94
+ runTaskConcurrency: _os.default.cpus().length
106
95
  });
107
96
  } else if (disableWithDeps && withDept) {
108
97
  await operator.traverseProjectToDependent(projectName, task, {
109
98
  withSelf,
110
- runTaskConcurrency: import_os.default.cpus().length
99
+ runTaskConcurrency: _os.default.cpus().length
111
100
  });
112
101
  } else {
113
102
  operator.traverseDependenciesToProject(projectName, task, {
114
103
  withSelf,
115
- runTaskConcurrency: import_os.default.cpus().length
104
+ runTaskConcurrency: _os.default.cpus().length
116
105
  });
117
106
  }
118
107
  };
119
108
  const runAllBuildTask = async (operator, config, taskCmds = defaultBuildCmds) => {
120
- const taskLogger = new import_multiTasksLog.MultitasksLogger();
109
+ const taskLogger = new _multiTasksLog.MultitasksLogger();
121
110
  const task = createTask(config, taskCmds, taskLogger);
122
111
  await operator.traverseAllNodes(task);
123
112
  };
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- runAllBuildTask,
127
- runBuildTask
128
- });
@@ -1,69 +1,88 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var clear_exports = {};
29
- __export(clear_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
30
13
  defaultRemoveDirs: () => defaultRemoveDirs,
31
14
  runClearTask: () => runClearTask
32
15
  });
33
- module.exports = __toCommonJS(clear_exports);
34
- var path = __toESM(require("path"));
35
- var import_utils = require("@modern-js/utils");
36
- var import_node_core_library = require("@rushstack/node-core-library");
37
- const defaultRemoveDirs = ["node_modules"];
16
+ const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
17
+ const _utils = require("@modern-js/utils");
18
+ const _nodecorelibrary = require("@rushstack/node-core-library");
19
+ function _getRequireWildcardCache(nodeInterop) {
20
+ if (typeof WeakMap !== "function")
21
+ return null;
22
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
23
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
24
+ return (_getRequireWildcardCache = function(nodeInterop2) {
25
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
26
+ })(nodeInterop);
27
+ }
28
+ function _interop_require_wildcard(obj, nodeInterop) {
29
+ if (!nodeInterop && obj && obj.__esModule) {
30
+ return obj;
31
+ }
32
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
+ return {
34
+ default: obj
35
+ };
36
+ }
37
+ var cache = _getRequireWildcardCache(nodeInterop);
38
+ if (cache && cache.has(obj)) {
39
+ return cache.get(obj);
40
+ }
41
+ var newObj = {};
42
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
+ for (var key in obj) {
44
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
+ if (desc && (desc.get || desc.set)) {
47
+ Object.defineProperty(newObj, key, desc);
48
+ } else {
49
+ newObj[key] = obj[key];
50
+ }
51
+ }
52
+ }
53
+ newObj.default = obj;
54
+ if (cache) {
55
+ cache.set(obj, newObj);
56
+ }
57
+ return newObj;
58
+ }
59
+ const defaultRemoveDirs = [
60
+ "node_modules"
61
+ ];
38
62
  const runClearTask = (projectNames, projects, config) => {
39
63
  const { removeDirs = defaultRemoveDirs, rootPath } = config;
40
64
  if (projectNames.length > 0) {
41
65
  projects.forEach((project) => {
42
66
  if (projectNames.includes(project.name)) {
43
67
  removeDirs.forEach((dir) => {
44
- const removePath = path.join(`${project.extra.path}`, dir);
45
- import_utils.logger.info(`remove ${removePath}`);
46
- import_node_core_library.FileSystem.deleteFolder(removePath);
68
+ const removePath = _path.join(`${project.extra.path}`, dir);
69
+ _utils.logger.info(`remove ${removePath}`);
70
+ _nodecorelibrary.FileSystem.deleteFolder(removePath);
47
71
  });
48
72
  }
49
73
  });
50
74
  } else {
51
75
  removeDirs.forEach((dir) => {
52
- const removePath = path.join(`${rootPath}`, dir);
53
- import_utils.logger.info(`remove ${removePath}`);
54
- import_node_core_library.FileSystem.deleteFolder(removePath);
76
+ const removePath = _path.join(`${rootPath}`, dir);
77
+ _utils.logger.info(`remove ${removePath}`);
78
+ _nodecorelibrary.FileSystem.deleteFolder(removePath);
55
79
  });
56
80
  projects.forEach((project) => {
57
81
  removeDirs.forEach((dir) => {
58
- const removePath = path.join(`${project.extra.path}`, dir);
59
- import_utils.logger.info(`remove ${removePath}`);
60
- import_node_core_library.FileSystem.deleteFolder(removePath);
82
+ const removePath = _path.join(`${project.extra.path}`, dir);
83
+ _utils.logger.info(`remove ${removePath}`);
84
+ _nodecorelibrary.FileSystem.deleteFolder(removePath);
61
85
  });
62
86
  });
63
87
  }
64
88
  };
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- defaultRemoveDirs,
68
- runClearTask
69
- });
@@ -1,75 +1,89 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var deploy_exports = {};
29
- __export(deploy_exports, {
30
- deploy: () => deploy
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "deploy", {
6
+ enumerable: true,
7
+ get: () => deploy
31
8
  });
32
- module.exports = __toCommonJS(deploy_exports);
33
- var path = __toESM(require("path"));
34
- var import_node_core_library = require("@rushstack/node-core-library");
35
- var import_utils = require("@modern-js/utils");
36
- var import_constants = require("../../constants");
9
+ const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
10
+ const _nodecorelibrary = require("@rushstack/node-core-library");
11
+ const _utils = require("@modern-js/utils");
12
+ const _constants = require("../../constants");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function")
15
+ return null;
16
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
17
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop2) {
19
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interop_require_wildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {};
36
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
+ for (var key in obj) {
38
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
+ if (desc && (desc.get || desc.set)) {
41
+ Object.defineProperty(newObj, key, desc);
42
+ } else {
43
+ newObj[key] = obj[key];
44
+ }
45
+ }
46
+ }
47
+ newObj.default = obj;
48
+ if (cache) {
49
+ cache.set(obj, newObj);
50
+ }
51
+ return newObj;
52
+ }
37
53
  const createCopyMap = (rootPath, targetProject, copyProjects, deployDir) => {
38
54
  const map = /* @__PURE__ */ new Map();
39
55
  for (const project of copyProjects) {
40
- const relativePath = path.relative(rootPath, project.extra.path);
41
- const targetPath = path.join(deployDir, relativePath);
56
+ const relativePath = _path.relative(rootPath, project.extra.path);
57
+ const targetPath = _path.join(deployDir, relativePath);
42
58
  map.set(project.extra.path, targetPath);
43
59
  }
44
- const targetProjectDeployPath = path.join(deployDir, "apps/app");
60
+ const targetProjectDeployPath = _path.join(deployDir, "apps/app");
45
61
  map.set(targetProject.extra.path, targetProjectDeployPath);
46
62
  return map;
47
63
  };
48
64
  const createCopyFromMonorepoToDeployDirFn = (monorepoDir, deployDir) => (filename) => {
49
- const sourcePath = path.join(monorepoDir, filename);
50
- const destinationPath = path.join(deployDir, filename);
51
- if (import_node_core_library.FileSystem.exists(sourcePath)) {
52
- import_node_core_library.FileSystem.copyFile({
65
+ const sourcePath = _path.join(monorepoDir, filename);
66
+ const destinationPath = _path.join(deployDir, filename);
67
+ if (_nodecorelibrary.FileSystem.exists(sourcePath)) {
68
+ _nodecorelibrary.FileSystem.copyFile({
53
69
  sourcePath,
54
70
  destinationPath
55
71
  });
56
72
  }
57
73
  };
58
74
  const checkAndUpdatePMWorkspaces = (deployDir) => {
59
- var _a;
60
- const pnpmWp = path.join(deployDir, import_constants.WORKSPACE_FILE.PNPM);
61
- if (import_utils.fs.existsSync(pnpmWp)) {
62
- const pnpmWorkspace = import_utils.yaml.load(
63
- import_utils.fs.readFileSync(pnpmWp, "utf-8")
64
- );
75
+ var _pkg_workspaces;
76
+ const pnpmWp = _path.join(deployDir, _constants.WORKSPACE_FILE.PNPM);
77
+ if (_utils.fs.existsSync(pnpmWp)) {
78
+ const pnpmWorkspace = _utils.yaml.load(_utils.fs.readFileSync(pnpmWp, "utf-8"));
65
79
  if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
66
80
  pnpmWorkspace.packages.push("apps/**");
67
81
  }
68
- import_utils.fs.writeFileSync(pnpmWp, import_utils.yaml.dump(pnpmWorkspace));
82
+ _utils.fs.writeFileSync(pnpmWp, _utils.yaml.dump(pnpmWorkspace));
69
83
  }
70
- const pkgPath = path.join(deployDir, import_constants.WORKSPACE_FILE.YARN);
71
- const pkg = import_node_core_library.JsonFile.load(pkgPath);
72
- if (((_a = pkg.workspaces) == null ? void 0 : _a.packages) && Array.isArray(pkg.workspaces.packages)) {
84
+ const pkgPath = _path.join(deployDir, _constants.WORKSPACE_FILE.YARN);
85
+ const pkg = _nodecorelibrary.JsonFile.load(pkgPath);
86
+ if (((_pkg_workspaces = pkg.workspaces) === null || _pkg_workspaces === void 0 ? void 0 : _pkg_workspaces.packages) && Array.isArray(pkg.workspaces.packages)) {
73
87
  pkg.workspaces.packages.push("app/**");
74
88
  }
75
89
  };
@@ -88,54 +102,76 @@ const generatorAndCopyRequiredFiles = (rootPath, deployDir) => {
88
102
  checkAndUpdatePMWorkspaces(deployDir);
89
103
  };
90
104
  const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageManager) => {
91
- var _a, _b, _c;
92
- const scripts = ((_a = targetProject.extra) == null ? void 0 : _a.scripts) || {};
105
+ var _targetProject_extra;
106
+ const scripts = ((_targetProject_extra = targetProject.extra) === null || _targetProject_extra === void 0 ? void 0 : _targetProject_extra.scripts) || {};
93
107
  if (scripts.deploy) {
94
- import_utils.logger.info(
95
- `The 'deploy' command for the ${targetProject.name} is detected, so 'deploy' will be executed`
96
- );
97
- let runDeployCommands = ["run", "deploy"];
108
+ var _childProcess_stdout, _childProcess_stderr;
109
+ _utils.logger.info(`The 'deploy' command for the ${targetProject.name} is detected, so 'deploy' will be executed`);
110
+ let runDeployCommands = [
111
+ "run",
112
+ "deploy"
113
+ ];
98
114
  if (packageManager === "pnpm") {
99
- const pnpmVersion = await (0, import_utils.getPnpmVersion)();
115
+ const pnpmVersion = await (0, _utils.getPnpmVersion)();
100
116
  if (pnpmVersion.startsWith("6")) {
101
- runDeployCommands = ["run", "deploy", "--filter", targetProject.name];
117
+ runDeployCommands = [
118
+ "run",
119
+ "deploy",
120
+ "--filter",
121
+ targetProject.name
122
+ ];
102
123
  } else {
103
- runDeployCommands = ["run", "--filter", targetProject.name, "deploy"];
124
+ runDeployCommands = [
125
+ "run",
126
+ "--filter",
127
+ targetProject.name,
128
+ "deploy"
129
+ ];
104
130
  }
105
131
  } else if (packageManager === "yarn") {
106
- runDeployCommands = ["workspace", targetProject.name, "run", "deploy"];
132
+ runDeployCommands = [
133
+ "workspace",
134
+ targetProject.name,
135
+ "run",
136
+ "deploy"
137
+ ];
107
138
  }
108
139
  const cwd = packageManager === "npm" ? targetProject.extra.path : monorepoPath;
109
- const childProcess = (0, import_utils.execa)(packageManager, runDeployCommands, {
140
+ const childProcess = (0, _utils.execa)(packageManager, runDeployCommands, {
110
141
  cwd,
111
- stdio: ["pipe"]
142
+ stdio: [
143
+ "pipe"
144
+ ]
112
145
  });
113
- (_b = childProcess.stdout) == null ? void 0 : _b.pipe(process.stdout);
114
- (_c = childProcess.stderr) == null ? void 0 : _c.pipe(process.stderr);
146
+ (_childProcess_stdout = childProcess.stdout) === null || _childProcess_stdout === void 0 ? void 0 : _childProcess_stdout.pipe(process.stdout);
147
+ (_childProcess_stderr = childProcess.stderr) === null || _childProcess_stderr === void 0 ? void 0 : _childProcess_stderr.pipe(process.stderr);
115
148
  await childProcess;
116
149
  }
117
150
  };
118
151
  const installDependency = async (deployDir, packageManager) => {
119
- const packageJsonPath = path.join(deployDir, "package.json");
120
- const packageJson = import_node_core_library.JsonFile.load(packageJsonPath);
121
- const scripts = (packageJson == null ? void 0 : packageJson.scripts) || {};
152
+ const packageJsonPath = _path.join(deployDir, "package.json");
153
+ const packageJson = _nodecorelibrary.JsonFile.load(packageJsonPath);
154
+ const scripts = (packageJson === null || packageJson === void 0 ? void 0 : packageJson.scripts) || {};
122
155
  let commands = [];
123
156
  if (scripts.setup) {
124
- import_utils.logger.info(
125
- `The 'setup' command is detected, execute '${packageManager} run setup' to start installing the dependencies`
126
- );
127
- commands = ["run", "setup"];
157
+ _utils.logger.info(`The 'setup' command is detected, execute '${packageManager} run setup' to start installing the dependencies`);
158
+ commands = [
159
+ "run",
160
+ "setup"
161
+ ];
128
162
  } else {
129
- import_utils.logger.info(
130
- `No 'setup' command detected, execute '${packageManager} install' to start installing dependencies`
131
- );
132
- commands = ["install"];
163
+ _utils.logger.info(`No 'setup' command detected, execute '${packageManager} install' to start installing dependencies`);
164
+ commands = [
165
+ "install"
166
+ ];
133
167
  }
134
- import_utils.logger.log(import_utils.chalk.rgb(218, 152, 92)("Install Log:\n"));
135
- const childProcess = (0, import_utils.execa)(packageManager, commands, {
168
+ _utils.logger.log(_utils.chalk.rgb(218, 152, 92)("Install Log:\n"));
169
+ const childProcess = (0, _utils.execa)(packageManager, commands, {
136
170
  stdio: "inherit",
137
171
  cwd: deployDir,
138
- env: { NODE_ENV: void 0 }
172
+ env: {
173
+ NODE_ENV: void 0
174
+ }
139
175
  });
140
176
  await childProcess;
141
177
  };
@@ -143,29 +179,27 @@ const excludeDirs = (filePath, dirs) => dirs.some((dir) => filePath.includes(dir
143
179
  const defaultDeployPath = "output";
144
180
  const deploy = async (deployProjectNames, operator, config) => {
145
181
  const { rootPath, packageManager, deployPath = defaultDeployPath } = config;
146
- const realDeployPath = path.isAbsolute(deployPath) ? deployPath : path.join(rootPath, deployPath);
147
- import_node_core_library.FileSystem.deleteFolder(realDeployPath);
182
+ const realDeployPath = _path.isAbsolute(deployPath) ? deployPath : _path.join(rootPath, deployPath);
183
+ _nodecorelibrary.FileSystem.deleteFolder(realDeployPath);
148
184
  for (const deployProjectName of deployProjectNames) {
149
185
  const currentProject = operator.getNodeData(deployProjectName, {
150
186
  checkExist: true
151
187
  });
152
188
  const alldeps = operator.getNodeAllDependencyData(deployProjectName);
153
- const copyMap = createCopyMap(
154
- rootPath,
155
- currentProject,
156
- alldeps,
157
- realDeployPath
158
- );
189
+ const copyMap = createCopyMap(rootPath, currentProject, alldeps, realDeployPath);
159
190
  await checkAndRunDeployCommand(rootPath, currentProject, packageManager);
160
- import_node_core_library.FileSystem.ensureFolder(realDeployPath);
191
+ _nodecorelibrary.FileSystem.ensureFolder(realDeployPath);
161
192
  for (const [from, to] of copyMap) {
162
- import_node_core_library.FileSystem.copyFiles({
193
+ _nodecorelibrary.FileSystem.copyFiles({
163
194
  sourcePath: from,
164
195
  destinationPath: to,
165
196
  // If true, then when copying symlinks, copy the target object instead of copying the link.
166
197
  dereferenceSymlinks: false,
167
198
  filter(filePath) {
168
- if (excludeDirs(filePath, ["node_modules", "dist"])) {
199
+ if (excludeDirs(filePath, [
200
+ "node_modules",
201
+ "dist"
202
+ ])) {
169
203
  return false;
170
204
  }
171
205
  return true;
@@ -174,9 +208,5 @@ const deploy = async (deployProjectNames, operator, config) => {
174
208
  }
175
209
  }
176
210
  generatorAndCopyRequiredFiles(rootPath, realDeployPath);
177
- import_utils.logger.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
211
+ _utils.logger.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
178
212
  };
179
- // Annotate the CommonJS export names for ESM import in node:
180
- 0 && (module.exports = {
181
- deploy
182
- });
@@ -1,27 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var cmds_exports = {};
19
- __export(cmds_exports, {
20
- defaultBuildWatchCmds: () => defaultBuildWatchCmds
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
21
4
  });
22
- module.exports = __toCommonJS(cmds_exports);
23
- const defaultBuildWatchCmds = ["dev", "build"];
24
- // Annotate the CommonJS export names for ESM import in node:
25
- 0 && (module.exports = {
26
- defaultBuildWatchCmds
5
+ Object.defineProperty(exports, "defaultBuildWatchCmds", {
6
+ enumerable: true,
7
+ get: () => defaultBuildWatchCmds
27
8
  });
9
+ const defaultBuildWatchCmds = [
10
+ "dev",
11
+ "build"
12
+ ];