@modern-js/monorepo-tools 2.15.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.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/cli/build.js +10 -31
- package/dist/cjs/cli/buildWatch.js +11 -31
- package/dist/cjs/cli/clear.js +11 -31
- package/dist/cjs/cli/deploy.js +14 -36
- package/dist/cjs/cli/index.js +23 -22
- package/dist/cjs/cli/install.js +11 -31
- package/dist/cjs/cli/new.js +17 -37
- package/dist/cjs/commands/build.js +21 -46
- package/dist/cjs/commands/buildWatch.js +19 -36
- package/dist/cjs/commands/clear.js +17 -34
- package/dist/cjs/commands/deploy.js +25 -41
- package/dist/cjs/commands/index.js +22 -21
- package/dist/cjs/commands/install.js +19 -36
- package/dist/cjs/constants.js +13 -26
- package/dist/cjs/dag/create.js +16 -28
- package/dist/cjs/dag/edgeManager.js +24 -28
- package/dist/cjs/dag/index.js +11 -29
- package/dist/cjs/dag/operator.js +106 -123
- package/dist/cjs/dag/task.js +52 -63
- package/dist/cjs/dag/utils.js +52 -49
- package/dist/cjs/features/build/index.js +52 -68
- package/dist/cjs/features/clear/index.js +66 -47
- package/dist/cjs/features/deploy/index.js +126 -96
- package/dist/cjs/features/dev/cmds.js +10 -25
- package/dist/cjs/features/dev/createTask.js +93 -56
- package/dist/cjs/features/dev/index.js +43 -71
- package/dist/cjs/features/dev/watchProjectsState.js +89 -64
- package/dist/cjs/features/install/index.js +74 -63
- package/dist/cjs/hooks/index.js +9 -27
- package/dist/cjs/index.js +36 -53
- package/dist/cjs/locale/en.js +7 -25
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +7 -25
- package/dist/cjs/log/error.js +7 -25
- package/dist/cjs/log/multiTasksLog.js +42 -43
- package/dist/cjs/log/time.js +19 -29
- package/dist/cjs/log/utils.js +7 -25
- package/dist/cjs/package/index.js +28 -30
- package/dist/cjs/parse-config/index.js +61 -49
- package/dist/cjs/parse-config/monorepo.js +81 -67
- package/dist/cjs/projects/checkProjectChange.js +95 -73
- package/dist/cjs/projects/clearMemoryFiles.js +52 -44
- package/dist/cjs/projects/getProjects.js +38 -65
- package/dist/cjs/projects/getProjectsByPackagesConfig.js +93 -71
- package/dist/cjs/projects/getProjectsByWorkspaceFile.js +89 -85
- package/dist/cjs/type.js +4 -15
- package/dist/cjs/utils/install.js +69 -44
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/cli/build.js +2 -8
- package/dist/esm/cli/buildWatch.js +4 -9
- package/dist/esm/cli/clear.js +4 -9
- package/dist/esm/cli/deploy.js +7 -14
- package/dist/esm/cli/install.js +4 -9
- package/dist/esm/cli/new.js +9 -14
- package/dist/esm/commands/build.js +7 -17
- package/dist/esm/commands/buildWatch.js +6 -8
- package/dist/esm/commands/clear.js +6 -8
- package/dist/esm/commands/deploy.js +10 -11
- package/dist/esm/commands/install.js +6 -8
- package/dist/esm/constants.js +2 -6
- package/dist/esm/dag/create.js +10 -7
- package/dist/esm/dag/edgeManager.js +17 -6
- package/dist/esm/dag/index.js +1 -4
- package/dist/esm/dag/operator.js +77 -74
- package/dist/esm/dag/task.js +39 -30
- package/dist/esm/dag/utils.js +39 -27
- package/dist/esm/features/build/index.js +22 -27
- package/dist/esm/features/clear/index.js +4 -6
- package/dist/esm/features/deploy/index.js +55 -50
- package/dist/esm/features/dev/cmds.js +4 -4
- package/dist/esm/features/dev/createTask.js +31 -15
- package/dist/esm/features/dev/index.js +19 -27
- package/dist/esm/features/dev/watchProjectsState.js +41 -31
- package/dist/esm/features/install/index.js +11 -15
- package/dist/esm/hooks/index.js +1 -4
- package/dist/esm/index.js +12 -11
- package/dist/esm/locale/en.js +1 -4
- package/dist/esm/locale/index.js +5 -5
- package/dist/esm/locale/zh.js +1 -4
- package/dist/esm/log/error.js +1 -4
- package/dist/esm/log/multiTasksLog.js +32 -18
- package/dist/esm/log/time.js +7 -8
- package/dist/esm/log/utils.js +1 -4
- package/dist/esm/package/index.js +21 -8
- package/dist/esm/parse-config/index.js +11 -14
- package/dist/esm/parse-config/monorepo.js +20 -27
- package/dist/esm/projects/checkProjectChange.js +19 -23
- package/dist/esm/projects/clearMemoryFiles.js +3 -13
- package/dist/esm/projects/getProjects.js +21 -45
- package/dist/esm/projects/getProjectsByPackagesConfig.js +29 -33
- package/dist/esm/projects/getProjectsByWorkspaceFile.js +21 -41
- package/dist/esm/type.js +1 -0
- package/dist/esm/utils/install.js +12 -8
- package/dist/esm/utils/types.js +1 -0
- package/package.json +16 -12
|
@@ -1,59 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
49
|
+
_utils.signale.time(prefix);
|
|
68
50
|
try {
|
|
69
|
-
const childProcess = (0,
|
|
51
|
+
const childProcess = (0, _utils.execa)(packageManager, [
|
|
52
|
+
taskCmd
|
|
53
|
+
], {
|
|
70
54
|
cwd: project.extra.path,
|
|
71
|
-
stdio: [
|
|
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: {
|
|
64
|
+
logConfig: {
|
|
65
|
+
label: "BUILD: "
|
|
66
|
+
}
|
|
77
67
|
});
|
|
78
68
|
await childProcess;
|
|
79
|
-
|
|
69
|
+
_utils.signale.timeEnd(prefix);
|
|
80
70
|
} catch (e) {
|
|
81
|
-
(0,
|
|
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 = [
|
|
80
|
+
const defaultBuildCmds = [
|
|
81
|
+
"build"
|
|
82
|
+
];
|
|
91
83
|
const runBuildTask = async (projectName, operator, config, taskCmds = defaultBuildCmds) => {
|
|
92
|
-
const {
|
|
93
|
-
|
|
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, {
|
|
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:
|
|
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:
|
|
99
|
+
runTaskConcurrency: _os.default.cpus().length
|
|
111
100
|
});
|
|
112
101
|
} else {
|
|
113
102
|
operator.traverseDependenciesToProject(projectName, task, {
|
|
114
103
|
withSelf,
|
|
115
|
-
runTaskConcurrency:
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 =
|
|
45
|
-
|
|
46
|
-
|
|
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 =
|
|
53
|
-
|
|
54
|
-
|
|
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 =
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 =
|
|
41
|
-
const targetPath =
|
|
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 =
|
|
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 =
|
|
50
|
-
const destinationPath =
|
|
51
|
-
if (
|
|
52
|
-
|
|
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
|
|
60
|
-
const pnpmWp =
|
|
61
|
-
if (
|
|
62
|
-
const pnpmWorkspace =
|
|
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
|
-
|
|
82
|
+
_utils.fs.writeFileSync(pnpmWp, _utils.yaml.dump(pnpmWorkspace));
|
|
69
83
|
}
|
|
70
|
-
const pkgPath =
|
|
71
|
-
const pkg =
|
|
72
|
-
if (((
|
|
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
|
|
92
|
-
const 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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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,
|
|
115
|
+
const pnpmVersion = await (0, _utils.getPnpmVersion)();
|
|
100
116
|
if (pnpmVersion.startsWith("6")) {
|
|
101
|
-
runDeployCommands = [
|
|
117
|
+
runDeployCommands = [
|
|
118
|
+
"run",
|
|
119
|
+
"deploy",
|
|
120
|
+
"--filter",
|
|
121
|
+
targetProject.name
|
|
122
|
+
];
|
|
102
123
|
} else {
|
|
103
|
-
runDeployCommands = [
|
|
124
|
+
runDeployCommands = [
|
|
125
|
+
"run",
|
|
126
|
+
"--filter",
|
|
127
|
+
targetProject.name,
|
|
128
|
+
"deploy"
|
|
129
|
+
];
|
|
104
130
|
}
|
|
105
131
|
} else if (packageManager === "yarn") {
|
|
106
|
-
runDeployCommands = [
|
|
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,
|
|
140
|
+
const childProcess = (0, _utils.execa)(packageManager, runDeployCommands, {
|
|
110
141
|
cwd,
|
|
111
|
-
stdio: [
|
|
142
|
+
stdio: [
|
|
143
|
+
"pipe"
|
|
144
|
+
]
|
|
112
145
|
});
|
|
113
|
-
(
|
|
114
|
-
(
|
|
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 =
|
|
120
|
-
const packageJson =
|
|
121
|
-
const scripts = (packageJson
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
163
|
+
_utils.logger.info(`No 'setup' command detected, execute '${packageManager} install' to start installing dependencies`);
|
|
164
|
+
commands = [
|
|
165
|
+
"install"
|
|
166
|
+
];
|
|
133
167
|
}
|
|
134
|
-
|
|
135
|
-
const childProcess = (0,
|
|
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: {
|
|
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 =
|
|
147
|
-
|
|
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
|
-
|
|
191
|
+
_nodecorelibrary.FileSystem.ensureFolder(realDeployPath);
|
|
161
192
|
for (const [from, to] of copyMap) {
|
|
162
|
-
|
|
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, [
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
];
|