@modern-js/monorepo-tools 2.35.1 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/build.js +26 -9
- package/dist/cjs/cli/buildWatch.js +26 -9
- package/dist/cjs/cli/clear.js +26 -9
- package/dist/cjs/cli/deploy.js +26 -9
- package/dist/cjs/cli/index.js +30 -9
- package/dist/cjs/cli/install.js +26 -9
- package/dist/cjs/cli/new.js +29 -12
- package/dist/cjs/commands/build.js +33 -16
- package/dist/cjs/commands/buildWatch.js +32 -15
- package/dist/cjs/commands/clear.js +30 -13
- package/dist/cjs/commands/deploy.js +34 -17
- package/dist/cjs/commands/index.js +28 -8
- package/dist/cjs/commands/install.js +32 -15
- package/dist/cjs/constants.js +25 -15
- package/dist/cjs/dag/create.js +24 -7
- package/dist/cjs/dag/edgeManager.js +26 -9
- package/dist/cjs/dag/index.js +28 -11
- package/dist/cjs/dag/operator.js +58 -32
- package/dist/cjs/dag/task.js +46 -20
- package/dist/cjs/dag/utils.js +33 -25
- package/dist/cjs/features/build/index.js +51 -32
- package/dist/cjs/features/clear/index.js +47 -28
- package/dist/cjs/features/deploy/index.js +65 -39
- package/dist/cjs/features/dev/cmds.js +24 -7
- package/dist/cjs/features/dev/createTask.js +50 -31
- package/dist/cjs/features/dev/index.js +47 -21
- package/dist/cjs/features/dev/watchProjectsState.js +43 -17
- package/dist/cjs/features/install/index.js +53 -27
- package/dist/cjs/hooks/index.js +26 -9
- package/dist/cjs/index.js +45 -35
- package/dist/cjs/locale/en.js +24 -7
- package/dist/cjs/locale/index.js +31 -21
- package/dist/cjs/locale/zh.js +24 -7
- package/dist/cjs/log/error.js +24 -7
- package/dist/cjs/log/multiTasksLog.js +33 -16
- package/dist/cjs/log/time.js +29 -20
- package/dist/cjs/log/utils.js +24 -7
- package/dist/cjs/package/index.js +28 -11
- package/dist/cjs/parse-config/index.js +39 -13
- package/dist/cjs/parse-config/monorepo.js +55 -39
- package/dist/cjs/projects/checkProjectChange.js +65 -50
- package/dist/cjs/projects/clearMemoryFiles.js +39 -13
- package/dist/cjs/projects/getProjects.js +37 -27
- package/dist/cjs/projects/getProjectsByPackagesConfig.js +51 -33
- package/dist/cjs/projects/getProjectsByWorkspaceFile.js +59 -40
- package/dist/cjs/type.js +15 -3
- package/dist/cjs/utils/install.js +43 -24
- package/dist/cjs/utils/types.js +15 -3
- package/dist/esm/cli/build.js +4 -1
- package/dist/esm/cli/buildWatch.js +4 -1
- package/dist/esm/cli/clear.js +4 -1
- package/dist/esm/cli/deploy.js +4 -1
- package/dist/esm/cli/install.js +4 -1
- package/dist/esm/cli/new.js +4 -1
- package/dist/esm/commands/build.js +4 -1
- package/dist/esm/commands/buildWatch.js +4 -1
- package/dist/esm/commands/clear.js +4 -1
- package/dist/esm/commands/deploy.js +4 -1
- package/dist/esm/commands/install.js +4 -1
- package/dist/esm/constants.js +6 -2
- package/dist/esm/dag/create.js +4 -1
- package/dist/esm/dag/edgeManager.js +4 -1
- package/dist/esm/dag/index.js +4 -1
- package/dist/esm/dag/operator.js +4 -1
- package/dist/esm/dag/task.js +4 -1
- package/dist/esm/dag/utils.js +10 -4
- package/dist/esm/features/build/index.js +6 -2
- package/dist/esm/features/clear/index.js +6 -2
- package/dist/esm/features/deploy/index.js +4 -1
- package/dist/esm/features/dev/cmds.js +4 -1
- package/dist/esm/features/dev/createTask.js +6 -2
- package/dist/esm/features/dev/index.js +4 -1
- package/dist/esm/features/dev/watchProjectsState.js +4 -1
- package/dist/esm/features/install/index.js +4 -1
- package/dist/esm/hooks/index.js +4 -1
- package/dist/esm/index.js +6 -2
- package/dist/esm/locale/en.js +4 -1
- package/dist/esm/locale/index.js +4 -1
- package/dist/esm/locale/zh.js +4 -1
- package/dist/esm/log/error.js +4 -1
- package/dist/esm/log/multiTasksLog.js +4 -1
- package/dist/esm/log/time.js +8 -3
- package/dist/esm/log/utils.js +4 -1
- package/dist/esm/package/index.js +4 -1
- package/dist/esm/parse-config/index.js +4 -1
- package/dist/esm/parse-config/monorepo.js +12 -5
- package/dist/esm/projects/checkProjectChange.js +12 -5
- package/dist/esm/projects/clearMemoryFiles.js +4 -1
- package/dist/esm/projects/getProjects.js +6 -2
- package/dist/esm/projects/getProjectsByPackagesConfig.js +6 -2
- package/dist/esm/projects/getProjectsByWorkspaceFile.js +6 -2
- package/dist/esm/type.js +0 -1
- package/dist/esm/utils/install.js +6 -2
- package/dist/esm/utils/types.js +0 -1
- package/package.json +11 -11
|
@@ -1,41 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return runBuildTask;
|
|
15
|
-
},
|
|
16
|
-
runAllBuildTask: function() {
|
|
17
|
-
return runAllBuildTask;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var build_exports = {};
|
|
30
|
+
__export(build_exports, {
|
|
31
|
+
runAllBuildTask: () => runAllBuildTask,
|
|
32
|
+
runBuildTask: () => runBuildTask
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
module.exports = __toCommonJS(build_exports);
|
|
35
|
+
var import_os = __toESM(require("os"));
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var import_checkProjectChange = require("../../projects/checkProjectChange");
|
|
38
|
+
var import_error = require("../../log/error");
|
|
39
|
+
var import_multiTasksLog = require("../../log/multiTasksLog");
|
|
26
40
|
const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
27
41
|
const { rootPath, packageManager, disableContentHash = false, enableGitHash = false } = config;
|
|
28
42
|
const task = async (project) => {
|
|
29
43
|
console.info("run ", project.name);
|
|
30
44
|
if (!disableContentHash) {
|
|
31
|
-
const changed = await (0,
|
|
45
|
+
const changed = await (0, import_checkProjectChange.checkProjectChangeByContent)(project);
|
|
32
46
|
if (!changed) {
|
|
33
47
|
console.info(`${project.name} content not change, skip`);
|
|
34
48
|
return;
|
|
35
49
|
}
|
|
36
50
|
}
|
|
37
51
|
if (enableGitHash) {
|
|
38
|
-
const changed = await (0,
|
|
52
|
+
const changed = await (0, import_checkProjectChange.checkProjectChangeByGit)(project, rootPath);
|
|
39
53
|
if (!changed) {
|
|
40
54
|
console.info(`${project.name} not change, skip`);
|
|
41
55
|
return;
|
|
@@ -46,9 +60,9 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
46
60
|
for (const taskCmd of taskCmds) {
|
|
47
61
|
if (cmd[taskCmd]) {
|
|
48
62
|
const prefix = `run ${project.name} ${taskCmd} script`;
|
|
49
|
-
|
|
63
|
+
import_utils.signale.time(prefix);
|
|
50
64
|
try {
|
|
51
|
-
const childProcess = (0,
|
|
65
|
+
const childProcess = (0, import_utils.execa)(packageManager, [
|
|
52
66
|
taskCmd
|
|
53
67
|
], {
|
|
54
68
|
cwd: project.extra.path,
|
|
@@ -66,9 +80,9 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
66
80
|
}
|
|
67
81
|
});
|
|
68
82
|
await childProcess;
|
|
69
|
-
|
|
83
|
+
import_utils.signale.timeEnd(prefix);
|
|
70
84
|
} catch (e) {
|
|
71
|
-
(0,
|
|
85
|
+
(0, import_error.errorLog)(project.name, e.message);
|
|
72
86
|
}
|
|
73
87
|
} else {
|
|
74
88
|
console.info(`${project.name} not have ${taskCmd}, skip it.`);
|
|
@@ -82,7 +96,7 @@ const defaultBuildCmds = [
|
|
|
82
96
|
];
|
|
83
97
|
const runBuildTask = async (projectName, operator, config, taskCmds = defaultBuildCmds) => {
|
|
84
98
|
const { withSelf = true, onlySelf = false, disableWithDeps = false, withDept = false } = config;
|
|
85
|
-
const taskLogger = new
|
|
99
|
+
const taskLogger = new import_multiTasksLog.MultitasksLogger();
|
|
86
100
|
const task = createTask(config, taskCmds, taskLogger);
|
|
87
101
|
if (onlySelf) {
|
|
88
102
|
await task(operator.getNodeData(projectName, {
|
|
@@ -91,22 +105,27 @@ const runBuildTask = async (projectName, operator, config, taskCmds = defaultBui
|
|
|
91
105
|
} else if (!disableWithDeps && withDept) {
|
|
92
106
|
await operator.traverseDependenciesToProjectToDependent(projectName, task, {
|
|
93
107
|
withSelf,
|
|
94
|
-
runTaskConcurrency:
|
|
108
|
+
runTaskConcurrency: import_os.default.cpus().length
|
|
95
109
|
});
|
|
96
110
|
} else if (disableWithDeps && withDept) {
|
|
97
111
|
await operator.traverseProjectToDependent(projectName, task, {
|
|
98
112
|
withSelf,
|
|
99
|
-
runTaskConcurrency:
|
|
113
|
+
runTaskConcurrency: import_os.default.cpus().length
|
|
100
114
|
});
|
|
101
115
|
} else {
|
|
102
116
|
operator.traverseDependenciesToProject(projectName, task, {
|
|
103
117
|
withSelf,
|
|
104
|
-
runTaskConcurrency:
|
|
118
|
+
runTaskConcurrency: import_os.default.cpus().length
|
|
105
119
|
});
|
|
106
120
|
}
|
|
107
121
|
};
|
|
108
122
|
const runAllBuildTask = async (operator, config, taskCmds = defaultBuildCmds) => {
|
|
109
|
-
const taskLogger = new
|
|
123
|
+
const taskLogger = new import_multiTasksLog.MultitasksLogger();
|
|
110
124
|
const task = createTask(config, taskCmds, taskLogger);
|
|
111
125
|
await operator.traverseAllNodes(task);
|
|
112
126
|
};
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
runAllBuildTask,
|
|
130
|
+
runBuildTask
|
|
131
|
+
});
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return defaultRemoveDirs;
|
|
15
|
-
},
|
|
16
|
-
runClearTask: function() {
|
|
17
|
-
return runClearTask;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var clear_exports = {};
|
|
30
|
+
__export(clear_exports, {
|
|
31
|
+
defaultRemoveDirs: () => defaultRemoveDirs,
|
|
32
|
+
runClearTask: () => runClearTask
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
module.exports = __toCommonJS(clear_exports);
|
|
35
|
+
var path = __toESM(require("path"));
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
24
38
|
const defaultRemoveDirs = [
|
|
25
39
|
"node_modules"
|
|
26
40
|
];
|
|
@@ -30,24 +44,29 @@ const runClearTask = (projectNames, projects, config) => {
|
|
|
30
44
|
projects.forEach((project) => {
|
|
31
45
|
if (projectNames.includes(project.name)) {
|
|
32
46
|
removeDirs.forEach((dir) => {
|
|
33
|
-
const removePath =
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
const removePath = path.join(`${project.extra.path}`, dir);
|
|
48
|
+
import_utils.logger.info(`remove ${removePath}`);
|
|
49
|
+
import_node_core_library.FileSystem.deleteFolder(removePath);
|
|
36
50
|
});
|
|
37
51
|
}
|
|
38
52
|
});
|
|
39
53
|
} else {
|
|
40
54
|
removeDirs.forEach((dir) => {
|
|
41
|
-
const removePath =
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
const removePath = path.join(`${rootPath}`, dir);
|
|
56
|
+
import_utils.logger.info(`remove ${removePath}`);
|
|
57
|
+
import_node_core_library.FileSystem.deleteFolder(removePath);
|
|
44
58
|
});
|
|
45
59
|
projects.forEach((project) => {
|
|
46
60
|
removeDirs.forEach((dir) => {
|
|
47
|
-
const removePath =
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const removePath = path.join(`${project.extra.path}`, dir);
|
|
62
|
+
import_utils.logger.info(`remove ${removePath}`);
|
|
63
|
+
import_node_core_library.FileSystem.deleteFolder(removePath);
|
|
50
64
|
});
|
|
51
65
|
});
|
|
52
66
|
}
|
|
53
67
|
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
defaultRemoveDirs,
|
|
71
|
+
runClearTask
|
|
72
|
+
});
|
|
@@ -1,34 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var deploy_exports = {};
|
|
30
|
+
__export(deploy_exports, {
|
|
31
|
+
deploy: () => deploy
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
module.exports = __toCommonJS(deploy_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var import_constants = require("../../constants");
|
|
16
38
|
const createCopyMap = (rootPath, targetProject, copyProjects, deployDir) => {
|
|
17
39
|
const map = /* @__PURE__ */ new Map();
|
|
18
40
|
for (const project of copyProjects) {
|
|
19
|
-
const relativePath =
|
|
20
|
-
const targetPath =
|
|
41
|
+
const relativePath = path.relative(rootPath, project.extra.path);
|
|
42
|
+
const targetPath = path.join(deployDir, relativePath);
|
|
21
43
|
map.set(project.extra.path, targetPath);
|
|
22
44
|
}
|
|
23
|
-
const targetProjectDeployPath =
|
|
45
|
+
const targetProjectDeployPath = path.join(deployDir, "apps/app");
|
|
24
46
|
map.set(targetProject.extra.path, targetProjectDeployPath);
|
|
25
47
|
return map;
|
|
26
48
|
};
|
|
27
49
|
const createCopyFromMonorepoToDeployDirFn = (monorepoDir, deployDir) => (filename) => {
|
|
28
|
-
const sourcePath =
|
|
29
|
-
const destinationPath =
|
|
30
|
-
if (
|
|
31
|
-
|
|
50
|
+
const sourcePath = path.join(monorepoDir, filename);
|
|
51
|
+
const destinationPath = path.join(deployDir, filename);
|
|
52
|
+
if (import_node_core_library.FileSystem.exists(sourcePath)) {
|
|
53
|
+
import_node_core_library.FileSystem.copyFile({
|
|
32
54
|
sourcePath,
|
|
33
55
|
destinationPath
|
|
34
56
|
});
|
|
@@ -36,16 +58,16 @@ const createCopyFromMonorepoToDeployDirFn = (monorepoDir, deployDir) => (filenam
|
|
|
36
58
|
};
|
|
37
59
|
const checkAndUpdatePMWorkspaces = (deployDir) => {
|
|
38
60
|
var _pkg_workspaces;
|
|
39
|
-
const pnpmWp =
|
|
40
|
-
if (
|
|
41
|
-
const pnpmWorkspace =
|
|
61
|
+
const pnpmWp = path.join(deployDir, import_constants.WORKSPACE_FILE.PNPM);
|
|
62
|
+
if (import_utils.fs.existsSync(pnpmWp)) {
|
|
63
|
+
const pnpmWorkspace = import_utils.yaml.load(import_utils.fs.readFileSync(pnpmWp, "utf-8"));
|
|
42
64
|
if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
|
|
43
65
|
pnpmWorkspace.packages.push("apps/**");
|
|
44
66
|
}
|
|
45
|
-
|
|
67
|
+
import_utils.fs.writeFileSync(pnpmWp, import_utils.yaml.dump(pnpmWorkspace));
|
|
46
68
|
}
|
|
47
|
-
const pkgPath =
|
|
48
|
-
const pkg =
|
|
69
|
+
const pkgPath = path.join(deployDir, import_constants.WORKSPACE_FILE.YARN);
|
|
70
|
+
const pkg = import_node_core_library.JsonFile.load(pkgPath);
|
|
49
71
|
if (((_pkg_workspaces = pkg.workspaces) === null || _pkg_workspaces === void 0 ? void 0 : _pkg_workspaces.packages) && Array.isArray(pkg.workspaces.packages)) {
|
|
50
72
|
pkg.workspaces.packages.push("app/**");
|
|
51
73
|
}
|
|
@@ -69,13 +91,13 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
|
|
|
69
91
|
const scripts = ((_targetProject_extra = targetProject.extra) === null || _targetProject_extra === void 0 ? void 0 : _targetProject_extra.scripts) || {};
|
|
70
92
|
if (scripts.deploy) {
|
|
71
93
|
var _childProcess_stdout, _childProcess_stderr;
|
|
72
|
-
|
|
94
|
+
import_utils.logger.info(`The 'deploy' command for the ${targetProject.name} is detected, so 'deploy' will be executed`);
|
|
73
95
|
let runDeployCommands = [
|
|
74
96
|
"run",
|
|
75
97
|
"deploy"
|
|
76
98
|
];
|
|
77
99
|
if (packageManager === "pnpm") {
|
|
78
|
-
const pnpmVersion = await (0,
|
|
100
|
+
const pnpmVersion = await (0, import_utils.getPnpmVersion)();
|
|
79
101
|
if (pnpmVersion.startsWith("6")) {
|
|
80
102
|
runDeployCommands = [
|
|
81
103
|
"run",
|
|
@@ -100,7 +122,7 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
|
|
|
100
122
|
];
|
|
101
123
|
}
|
|
102
124
|
const cwd = packageManager === "npm" ? targetProject.extra.path : monorepoPath;
|
|
103
|
-
const childProcess = (0,
|
|
125
|
+
const childProcess = (0, import_utils.execa)(packageManager, runDeployCommands, {
|
|
104
126
|
cwd,
|
|
105
127
|
stdio: [
|
|
106
128
|
"pipe"
|
|
@@ -112,24 +134,24 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
|
|
|
112
134
|
}
|
|
113
135
|
};
|
|
114
136
|
const installDependency = async (deployDir, packageManager) => {
|
|
115
|
-
const packageJsonPath =
|
|
116
|
-
const packageJson =
|
|
137
|
+
const packageJsonPath = path.join(deployDir, "package.json");
|
|
138
|
+
const packageJson = import_node_core_library.JsonFile.load(packageJsonPath);
|
|
117
139
|
const scripts = (packageJson === null || packageJson === void 0 ? void 0 : packageJson.scripts) || {};
|
|
118
140
|
let commands = [];
|
|
119
141
|
if (scripts.setup) {
|
|
120
|
-
|
|
142
|
+
import_utils.logger.info(`The 'setup' command is detected, execute '${packageManager} run setup' to start installing the dependencies`);
|
|
121
143
|
commands = [
|
|
122
144
|
"run",
|
|
123
145
|
"setup"
|
|
124
146
|
];
|
|
125
147
|
} else {
|
|
126
|
-
|
|
148
|
+
import_utils.logger.info(`No 'setup' command detected, execute '${packageManager} install' to start installing dependencies`);
|
|
127
149
|
commands = [
|
|
128
150
|
"install"
|
|
129
151
|
];
|
|
130
152
|
}
|
|
131
|
-
|
|
132
|
-
const childProcess = (0,
|
|
153
|
+
import_utils.logger.log(import_utils.chalk.rgb(218, 152, 92)("Install Log:\n"));
|
|
154
|
+
const childProcess = (0, import_utils.execa)(packageManager, commands, {
|
|
133
155
|
stdio: "inherit",
|
|
134
156
|
cwd: deployDir,
|
|
135
157
|
env: {
|
|
@@ -142,8 +164,8 @@ const excludeDirs = (filePath, dirs) => dirs.some((dir) => filePath.includes(dir
|
|
|
142
164
|
const defaultDeployPath = "output";
|
|
143
165
|
const deploy = async (deployProjectNames, operator, config) => {
|
|
144
166
|
const { rootPath, packageManager, deployPath = defaultDeployPath } = config;
|
|
145
|
-
const realDeployPath =
|
|
146
|
-
|
|
167
|
+
const realDeployPath = path.isAbsolute(deployPath) ? deployPath : path.join(rootPath, deployPath);
|
|
168
|
+
import_node_core_library.FileSystem.deleteFolder(realDeployPath);
|
|
147
169
|
for (const deployProjectName of deployProjectNames) {
|
|
148
170
|
const currentProject = operator.getNodeData(deployProjectName, {
|
|
149
171
|
checkExist: true
|
|
@@ -151,9 +173,9 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
151
173
|
const alldeps = operator.getNodeAllDependencyData(deployProjectName);
|
|
152
174
|
const copyMap = createCopyMap(rootPath, currentProject, alldeps, realDeployPath);
|
|
153
175
|
await checkAndRunDeployCommand(rootPath, currentProject, packageManager);
|
|
154
|
-
|
|
176
|
+
import_node_core_library.FileSystem.ensureFolder(realDeployPath);
|
|
155
177
|
for (const [from, to] of copyMap) {
|
|
156
|
-
|
|
178
|
+
import_node_core_library.FileSystem.copyFiles({
|
|
157
179
|
sourcePath: from,
|
|
158
180
|
destinationPath: to,
|
|
159
181
|
// If true, then when copying symlinks, copy the target object instead of copying the link.
|
|
@@ -171,5 +193,9 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
171
193
|
}
|
|
172
194
|
}
|
|
173
195
|
generatorAndCopyRequiredFiles(rootPath, realDeployPath);
|
|
174
|
-
|
|
196
|
+
import_utils.logger.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
|
|
175
197
|
};
|
|
198
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
199
|
+
0 && (module.exports = {
|
|
200
|
+
deploy
|
|
201
|
+
});
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cmds_exports = {};
|
|
20
|
+
__export(cmds_exports, {
|
|
21
|
+
defaultBuildWatchCmds: () => defaultBuildWatchCmds
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(cmds_exports);
|
|
11
24
|
const defaultBuildWatchCmds = [
|
|
12
25
|
"dev",
|
|
13
26
|
"build"
|
|
14
27
|
];
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
defaultBuildWatchCmds
|
|
31
|
+
});
|
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return createDependenciesTask;
|
|
15
|
-
},
|
|
16
|
-
createDevTask: function() {
|
|
17
|
-
return createDevTask;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var createTask_exports = {};
|
|
30
|
+
__export(createTask_exports, {
|
|
31
|
+
createDependenciesTask: () => createDependenciesTask,
|
|
32
|
+
createDevTask: () => createDevTask
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
module.exports = __toCommonJS(createTask_exports);
|
|
35
|
+
var import_utils = require("@modern-js/utils");
|
|
36
|
+
var import_error = require("../../log/error");
|
|
37
|
+
var timeLog = __toESM(require("../../log/time"));
|
|
38
|
+
var import_cmds = require("./cmds");
|
|
25
39
|
const getFinalTaskCmds = (taskCmds, project) => {
|
|
26
40
|
let finalTaskCmds = [];
|
|
27
41
|
if (taskCmds.length === 1) {
|
|
@@ -41,18 +55,18 @@ const getFinalTaskCmds = (taskCmds, project) => {
|
|
|
41
55
|
}
|
|
42
56
|
return finalTaskCmds;
|
|
43
57
|
};
|
|
44
|
-
const createDependenciesTask = (config, taskCmds =
|
|
58
|
+
const createDependenciesTask = (config, taskCmds = import_cmds.defaultBuildWatchCmds, taskLogger) => {
|
|
45
59
|
const { packageManager } = config;
|
|
46
|
-
const timelogInstance =
|
|
60
|
+
const timelogInstance = timeLog.initTimeLog();
|
|
47
61
|
const task = async (project) => {
|
|
48
62
|
const finalTaskCmds = getFinalTaskCmds(taskCmds, project);
|
|
49
63
|
const cmd = project.extra.scripts || {};
|
|
50
64
|
for (const taskCmd of finalTaskCmds) {
|
|
51
65
|
if (cmd[taskCmd]) {
|
|
52
66
|
const prefix = `run ${project.name} ${taskCmd} script`;
|
|
53
|
-
|
|
67
|
+
timeLog.startTime(timelogInstance, prefix);
|
|
54
68
|
try {
|
|
55
|
-
const childProcess = (0,
|
|
69
|
+
const childProcess = (0, import_utils.execa)(packageManager, [
|
|
56
70
|
taskCmd
|
|
57
71
|
], {
|
|
58
72
|
cwd: project.extra.path,
|
|
@@ -71,17 +85,17 @@ const createDependenciesTask = (config, taskCmds = _cmds.defaultBuildWatchCmds,
|
|
|
71
85
|
});
|
|
72
86
|
await childProcess;
|
|
73
87
|
} catch (e) {
|
|
74
|
-
(0,
|
|
88
|
+
(0, import_error.errorLog)(project.name, e);
|
|
75
89
|
}
|
|
76
|
-
|
|
90
|
+
timeLog.endTime(timelogInstance, prefix);
|
|
77
91
|
} else {
|
|
78
|
-
|
|
92
|
+
import_utils.logger.info(`${project.name} not have ${taskCmd}, skip it.`);
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
};
|
|
82
96
|
return task;
|
|
83
97
|
};
|
|
84
|
-
const createDevTask = (config, taskCmds =
|
|
98
|
+
const createDevTask = (config, taskCmds = import_cmds.defaultBuildWatchCmds, taskLogger) => {
|
|
85
99
|
const { packageManager } = config;
|
|
86
100
|
const task = async (project) => {
|
|
87
101
|
const devCmds = [
|
|
@@ -91,7 +105,7 @@ const createDevTask = (config, taskCmds = _cmds.defaultBuildWatchCmds, taskLogge
|
|
|
91
105
|
for (const taskCmd of devCmds) {
|
|
92
106
|
if (cmd[taskCmd]) {
|
|
93
107
|
try {
|
|
94
|
-
const childProcess = (0,
|
|
108
|
+
const childProcess = (0, import_utils.execa)(packageManager, [
|
|
95
109
|
taskCmd
|
|
96
110
|
], {
|
|
97
111
|
cwd: project.extra.path,
|
|
@@ -108,12 +122,17 @@ const createDevTask = (config, taskCmds = _cmds.defaultBuildWatchCmds, taskLogge
|
|
|
108
122
|
const ret = await childProcess;
|
|
109
123
|
console.info(ret);
|
|
110
124
|
} catch (e) {
|
|
111
|
-
(0,
|
|
125
|
+
(0, import_error.errorLog)(project.name, e);
|
|
112
126
|
}
|
|
113
127
|
} else {
|
|
114
|
-
|
|
128
|
+
import_utils.logger.info(`${project.name} not have ${taskCmd}, skip it.`);
|
|
115
129
|
}
|
|
116
130
|
}
|
|
117
131
|
};
|
|
118
132
|
return task;
|
|
119
133
|
};
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
createDependenciesTask,
|
|
137
|
+
createDevTask
|
|
138
|
+
});
|