@modern-js/monorepo-tools 2.0.0-beta.2 → 2.0.0-beta.4
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 +99 -0
- package/bin/modern.js +3 -1
- package/dist/js/modern/cli/build-watch.js +30 -5
- package/dist/js/modern/cli/build.js +31 -5
- package/dist/js/modern/cli/clear.js +30 -5
- package/dist/js/modern/cli/deploy.js +35 -7
- package/dist/js/modern/cli/index.js +1 -1
- package/dist/js/modern/cli/install.js +30 -5
- package/dist/js/modern/cli/new.js +56 -14
- package/dist/js/modern/commands/build-watch.js +32 -18
- package/dist/js/modern/commands/build.js +49 -23
- package/dist/js/modern/commands/clear.js +31 -15
- package/dist/js/modern/commands/deploy.js +38 -24
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/install.js +32 -17
- package/dist/js/modern/constants.js +13 -9
- package/dist/js/modern/dag/create.js +27 -23
- package/dist/js/modern/dag/edge-manager.js +5 -4
- package/dist/js/modern/dag/index.js +6 -5
- package/dist/js/modern/dag/operator.js +174 -156
- package/dist/js/modern/dag/task.js +64 -39
- package/dist/js/modern/dag/utils.js +32 -38
- package/dist/js/modern/features/build/index.js +47 -28
- package/dist/js/modern/features/clear/index.js +16 -15
- package/dist/js/modern/features/deploy/index.js +107 -82
- package/dist/js/modern/features/dev/cmds.js +4 -3
- package/dist/js/modern/features/dev/create-task.js +43 -34
- package/dist/js/modern/features/dev/index.js +60 -41
- package/dist/js/modern/features/dev/watch-projects-state.js +47 -24
- package/dist/js/modern/features/install/index.js +43 -22
- package/dist/js/modern/hooks/index.js +6 -3
- package/dist/js/modern/index.js +18 -16
- package/dist/js/modern/locale/en.js +10 -7
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +11 -8
- package/dist/js/modern/log/error.js +6 -3
- package/dist/js/modern/log/multi-tasks-log.js +25 -34
- package/dist/js/modern/log/time.js +26 -11
- package/dist/js/modern/log/utils.js +9 -5
- package/dist/js/modern/package/index.js +5 -6
- package/dist/js/modern/parse-config/index.js +49 -22
- package/dist/js/modern/parse-config/monorepo.js +41 -26
- package/dist/js/modern/projects/check-project-change.js +59 -30
- package/dist/js/modern/projects/clear-memory-files.js +17 -7
- package/dist/js/modern/projects/get-projects-by-packages-config.js +89 -52
- package/dist/js/modern/projects/get-projects-by-workspace-file.js +68 -32
- package/dist/js/modern/projects/get-projects.js +96 -53
- package/dist/js/modern/type.js +0 -1
- package/dist/js/modern/utils/install.js +36 -19
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/node/cli/build-watch.js +47 -10
- package/dist/js/node/cli/build.js +48 -10
- package/dist/js/node/cli/clear.js +47 -10
- package/dist/js/node/cli/deploy.js +52 -12
- package/dist/js/node/cli/index.js +22 -71
- package/dist/js/node/cli/install.js +47 -10
- package/dist/js/node/cli/new.js +73 -19
- package/dist/js/node/commands/build-watch.js +55 -29
- package/dist/js/node/commands/build.js +72 -32
- package/dist/js/node/commands/clear.js +53 -25
- package/dist/js/node/commands/deploy.js +61 -35
- package/dist/js/node/commands/index.js +21 -60
- package/dist/js/node/commands/install.js +55 -28
- package/dist/js/node/constants.js +28 -13
- package/dist/js/node/dag/create.js +44 -28
- package/dist/js/node/dag/edge-manager.js +21 -8
- package/dist/js/node/dag/index.js +26 -13
- package/dist/js/node/dag/operator.js +209 -174
- package/dist/js/node/dag/task.js +88 -46
- package/dist/js/node/dag/utils.js +51 -47
- package/dist/js/node/features/build/index.js +79 -47
- package/dist/js/node/features/clear/index.js +44 -28
- package/dist/js/node/features/deploy/index.js +135 -104
- package/dist/js/node/features/dev/cmds.js +22 -9
- package/dist/js/node/features/dev/create-task.js +75 -51
- package/dist/js/node/features/dev/index.js +94 -58
- package/dist/js/node/features/dev/watch-projects-state.js +69 -30
- package/dist/js/node/features/install/index.js +78 -41
- package/dist/js/node/hooks/index.js +23 -8
- package/dist/js/node/index.js +51 -32
- package/dist/js/node/locale/en.js +26 -11
- package/dist/js/node/locale/index.js +27 -15
- package/dist/js/node/locale/zh.js +27 -12
- package/dist/js/node/log/error.js +22 -7
- package/dist/js/node/log/multi-tasks-log.js +44 -41
- package/dist/js/node/log/time.js +43 -18
- package/dist/js/node/log/utils.js +26 -10
- package/dist/js/node/package/index.js +21 -10
- package/dist/js/node/parse-config/index.js +73 -30
- package/dist/js/node/parse-config/monorepo.js +71 -44
- package/dist/js/node/projects/check-project-change.js +96 -56
- package/dist/js/node/projects/clear-memory-files.js +38 -15
- package/dist/js/node/projects/get-projects-by-packages-config.js +116 -65
- package/dist/js/node/projects/get-projects-by-workspace-file.js +103 -55
- package/dist/js/node/projects/get-projects.js +109 -61
- package/dist/js/node/type.js +0 -5
- package/dist/js/node/utils/install.js +63 -31
- package/dist/js/node/utils/language.js +24 -8
- package/dist/types/dag/operator.d.ts +3 -0
- package/dist/types/dag/utils.d.ts +1 -0
- package/dist/types/features/dev/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/projects/get-projects.d.ts +1 -0
- package/package.json +12 -19
|
@@ -1,86 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
runBuildWatchTask: () => runBuildWatchTask
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var import_anymatch = __toESM(require("anymatch"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var import_multi_tasks_log = require("../../log/multi-tasks-log");
|
|
32
|
+
var import_watch_projects_state = require("./watch-projects-state");
|
|
33
|
+
var import_cmds = require("./cmds");
|
|
34
|
+
var import_create_task = require("./create-task");
|
|
35
|
+
var __async = (__this, __arguments, generator) => {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
var fulfilled = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.next(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var rejected = (value) => {
|
|
45
|
+
try {
|
|
46
|
+
step(generator.throw(value));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
52
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const getIgnored = (config) => (watchFilePath) => {
|
|
16
56
|
const nodeModulesPattern = /(?:^|[\\/])node_modules/g;
|
|
17
|
-
if (nodeModulesPattern.test(watchFilePath) || watchFilePath.includes(
|
|
57
|
+
if (nodeModulesPattern.test(watchFilePath) || watchFilePath.includes("dist")) {
|
|
18
58
|
return true;
|
|
19
59
|
}
|
|
20
60
|
if (config.ignoreMaybeChanged) {
|
|
21
|
-
return (0,
|
|
61
|
+
return (0, import_anymatch.default)(config.ignoreMaybeChanged)(watchFilePath);
|
|
22
62
|
}
|
|
23
63
|
return false;
|
|
24
64
|
};
|
|
25
|
-
const runBuildWatchTask =
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const dependenciesTask = (0, _createTask.createDependenciesTask)(config, taskCmds, taskLogger);
|
|
31
|
-
const devTask = (0, _createTask.createDevTask)(config, taskCmds, taskLogger);
|
|
65
|
+
const runBuildWatchTask = (_0, _1, _2, ..._3) => __async(void 0, [_0, _1, _2, ..._3], function* (projectName, operator, config, taskCmds = import_cmds.defaultBuildWatchCmds) {
|
|
66
|
+
const { needInit = true } = config;
|
|
67
|
+
const taskLogger = new import_multi_tasks_log.MultitasksLogger();
|
|
68
|
+
const dependenciesTask = (0, import_create_task.createDependenciesTask)(config, taskCmds, taskLogger);
|
|
69
|
+
const devTask = (0, import_create_task.createDevTask)(config, taskCmds, taskLogger);
|
|
32
70
|
const fromNodes = operator.getNodeAllDependencyData(projectName);
|
|
33
|
-
const watchedProjectState = new
|
|
34
|
-
const watcher = new
|
|
71
|
+
const watchedProjectState = new import_watch_projects_state.WatchedProjectsState(fromNodes, config);
|
|
72
|
+
const watcher = new import_utils.chokidar.FSWatcher({
|
|
35
73
|
persistent: true,
|
|
36
74
|
cwd: config.rootPath,
|
|
37
75
|
followSymlinks: false,
|
|
38
76
|
ignoreInitial: true,
|
|
39
77
|
ignored: getIgnored(config),
|
|
40
78
|
disableGlobbing: true,
|
|
41
|
-
interval:
|
|
79
|
+
interval: 1e3
|
|
42
80
|
});
|
|
43
81
|
watcher.add(watchedProjectState.getWatchedProjectsPath());
|
|
44
|
-
|
|
45
|
-
// 可能会移除该判断和 neeInit 配置
|
|
46
82
|
if (needInit) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
83
|
+
yield operator.traverseDependenciesToProject(
|
|
84
|
+
projectName,
|
|
85
|
+
(currentProject) => __async(void 0, null, function* () {
|
|
86
|
+
yield dependenciesTask(currentProject);
|
|
87
|
+
})
|
|
88
|
+
);
|
|
50
89
|
}
|
|
51
|
-
|
|
52
|
-
console.info(
|
|
53
|
-
watcher.on(
|
|
54
|
-
|
|
55
|
-
if (eventName === 'add') {
|
|
90
|
+
yield new Promise((resolve) => {
|
|
91
|
+
console.info("start watch");
|
|
92
|
+
watcher.on("all", (eventName, changeFilePath) => __async(void 0, null, function* () {
|
|
93
|
+
if (eventName === "add") {
|
|
56
94
|
watchedProjectState.updateState();
|
|
57
95
|
}
|
|
58
96
|
const changedProject = watchedProjectState.getChangedProject(changeFilePath);
|
|
59
97
|
if (changedProject) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
98
|
+
yield operator.traverseProjectToDependent(
|
|
99
|
+
changedProject.name,
|
|
100
|
+
(currentProject, _, earlyFinish) => __async(void 0, null, function* () {
|
|
101
|
+
if (currentProject.name === projectName) {
|
|
102
|
+
earlyFinish();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (watchedProjectState.watchProjectsName.includes(
|
|
106
|
+
currentProject.name
|
|
107
|
+
)) {
|
|
108
|
+
console.info("run build", currentProject.name);
|
|
109
|
+
yield dependenciesTask(currentProject);
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
{ withSelf: true }
|
|
113
|
+
);
|
|
73
114
|
resolve(null);
|
|
74
115
|
} else {
|
|
75
|
-
console.info(
|
|
116
|
+
console.info("changed is not in monorepo manager");
|
|
76
117
|
}
|
|
77
|
-
});
|
|
118
|
+
}));
|
|
78
119
|
resolve(null);
|
|
79
120
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
await devTask(operator.getNodeData(projectName, {
|
|
83
|
-
checkExist: true
|
|
84
|
-
}));
|
|
85
|
-
};
|
|
86
|
-
exports.runBuildWatchTask = runBuildWatchTask;
|
|
121
|
+
yield devTask(operator.getNodeData(projectName, { checkExist: true }));
|
|
122
|
+
});
|
|
@@ -1,25 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
WatchedProjectsState: () => WatchedProjectsState
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var __defProp2 = Object.defineProperty;
|
|
32
|
+
var __defProps = Object.defineProperties;
|
|
33
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
34
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
35
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
36
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
38
|
+
var __spreadValues = (a, b) => {
|
|
39
|
+
for (var prop in b || (b = {}))
|
|
40
|
+
if (__hasOwnProp2.call(b, prop))
|
|
41
|
+
__defNormalProp(a, prop, b[prop]);
|
|
42
|
+
if (__getOwnPropSymbols)
|
|
43
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
44
|
+
if (__propIsEnum.call(b, prop))
|
|
45
|
+
__defNormalProp(a, prop, b[prop]);
|
|
46
|
+
}
|
|
47
|
+
return a;
|
|
48
|
+
};
|
|
49
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
14
50
|
class WatchedProjectsState {
|
|
15
51
|
constructor(fromNodes, config) {
|
|
16
|
-
_defineProperty(this, "_config", void 0);
|
|
17
|
-
_defineProperty(this, "_fromNodes", void 0);
|
|
18
|
-
_defineProperty(this, "_watchProjects", void 0);
|
|
19
|
-
_defineProperty(this, "_projectsFileMap", void 0);
|
|
20
52
|
this._fromNodes = fromNodes;
|
|
21
53
|
this._config = config;
|
|
22
|
-
this._projectsFileMap = new Map();
|
|
54
|
+
this._projectsFileMap = /* @__PURE__ */ new Map();
|
|
23
55
|
this._watchProjects = {};
|
|
24
56
|
this._initState();
|
|
25
57
|
}
|
|
@@ -29,24 +61,30 @@ class WatchedProjectsState {
|
|
|
29
61
|
absolute: true,
|
|
30
62
|
expandDirectories: false,
|
|
31
63
|
followSymbolicLinks: false,
|
|
32
|
-
ignore: [
|
|
64
|
+
ignore: ["**/node_modules/**", ".project-memory/**", "dist/**"]
|
|
33
65
|
};
|
|
34
|
-
this._watchProjects = this._fromNodes.reduce(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
66
|
+
this._watchProjects = this._fromNodes.reduce(
|
|
67
|
+
(ret, node) => {
|
|
68
|
+
const files = import_utils.globby.sync(`${node.extra.path}/**`, globOption);
|
|
69
|
+
for (const filePath of files) {
|
|
70
|
+
this._projectsFileMap.set(
|
|
71
|
+
path.relative(this._config.rootPath, filePath),
|
|
72
|
+
node.extra.path
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return __spreadProps(__spreadValues({}, ret), {
|
|
76
|
+
[node.extra.path]: node
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
{}
|
|
80
|
+
);
|
|
43
81
|
}
|
|
44
82
|
getChangedProject(changedFilPath) {
|
|
45
83
|
if (this._projectsFileMap.has(changedFilPath)) {
|
|
46
84
|
const projectPath = this._projectsFileMap.get(changedFilPath);
|
|
47
85
|
return this._watchProjects[projectPath];
|
|
48
86
|
}
|
|
49
|
-
return
|
|
87
|
+
return void 0;
|
|
50
88
|
}
|
|
51
89
|
getWatchedProjectsPath() {
|
|
52
90
|
return Object.keys(this._watchProjects);
|
|
@@ -58,7 +96,8 @@ class WatchedProjectsState {
|
|
|
58
96
|
return this._watchProjects;
|
|
59
97
|
}
|
|
60
98
|
get watchProjectsName() {
|
|
61
|
-
return Object.keys(this._watchProjects).map(
|
|
99
|
+
return Object.keys(this._watchProjects).map(
|
|
100
|
+
(projectPath) => this._watchProjects[projectPath].name
|
|
101
|
+
);
|
|
62
102
|
}
|
|
63
103
|
}
|
|
64
|
-
exports.WatchedProjectsState = WatchedProjectsState;
|
|
@@ -1,72 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
runInstallTask: () => runInstallTask
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
32
|
+
var import_constants = require("../../constants");
|
|
33
|
+
var import_install = require("../../utils/install");
|
|
34
|
+
var __async = (__this, __arguments, generator) => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
var fulfilled = (value) => {
|
|
37
|
+
try {
|
|
38
|
+
step(generator.next(value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var rejected = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.throw(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
51
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
52
|
+
});
|
|
53
|
+
};
|
|
14
54
|
const replaceWorkspaces = ({
|
|
15
55
|
rootPath,
|
|
16
56
|
projectsInWorkspaces
|
|
17
57
|
}) => {
|
|
18
|
-
|
|
19
|
-
const pnpmWsFilePath = path.join(rootPath,
|
|
20
|
-
if (
|
|
21
|
-
const pnpmWorkspace =
|
|
22
|
-
const originalPnpmWorkspaces =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
58
|
+
var _a;
|
|
59
|
+
const pnpmWsFilePath = path.join(rootPath, import_constants.WORKSPACE_FILE.PNPM);
|
|
60
|
+
if (import_utils.fs.existsSync(pnpmWsFilePath)) {
|
|
61
|
+
const pnpmWorkspace = import_utils.fs.readFileSync(pnpmWsFilePath, "utf-8");
|
|
62
|
+
const originalPnpmWorkspaces = import_utils.yaml.load(pnpmWorkspace);
|
|
63
|
+
import_utils.fs.writeFileSync(
|
|
64
|
+
pnpmWsFilePath,
|
|
65
|
+
import_utils.yaml.dump({ packages: projectsInWorkspaces })
|
|
66
|
+
);
|
|
26
67
|
return () => {
|
|
27
|
-
|
|
68
|
+
import_utils.yaml.dump(originalPnpmWorkspaces);
|
|
28
69
|
};
|
|
29
70
|
}
|
|
30
|
-
const pkgFilePath = path.join(rootPath,
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (pkg !== null && pkg !== void 0 && (_pkg$workspaces = pkg.workspaces) !== null && _pkg$workspaces !== void 0 && _pkg$workspaces.packages) {
|
|
71
|
+
const pkgFilePath = path.join(rootPath, import_constants.WORKSPACE_FILE.YARN);
|
|
72
|
+
if (import_utils.fs.existsSync(pkgFilePath)) {
|
|
73
|
+
const pkg = import_node_core_library.JsonFile.load(pkgFilePath);
|
|
74
|
+
if ((_a = pkg == null ? void 0 : pkg.workspaces) == null ? void 0 : _a.packages) {
|
|
35
75
|
const originalPkg = pkg;
|
|
36
76
|
pkg.workspaces.packages = projectsInWorkspaces;
|
|
37
|
-
|
|
77
|
+
import_node_core_library.JsonFile.save(pkg, pkgFilePath);
|
|
38
78
|
return () => {
|
|
39
|
-
|
|
79
|
+
import_node_core_library.JsonFile.save(originalPkg, pkgFilePath);
|
|
40
80
|
};
|
|
41
81
|
}
|
|
42
82
|
}
|
|
43
83
|
return false;
|
|
44
84
|
};
|
|
45
|
-
const runInstallTask =
|
|
46
|
-
const {
|
|
47
|
-
rootPath,
|
|
48
|
-
packageManager
|
|
49
|
-
} = config;
|
|
85
|
+
const runInstallTask = (projectNames, operator, config) => __async(void 0, null, function* () {
|
|
86
|
+
const { rootPath, packageManager } = config;
|
|
50
87
|
let projectsInWorkspaces = [];
|
|
51
88
|
if (projectNames.length === 0) {
|
|
52
|
-
console.info(
|
|
89
|
+
console.info("install all projects");
|
|
53
90
|
return;
|
|
54
91
|
}
|
|
55
92
|
for (const projectName of projectNames) {
|
|
56
93
|
const allDeps = operator.getNodeAllDependencyData(projectName);
|
|
57
|
-
projectsInWorkspaces = [
|
|
94
|
+
projectsInWorkspaces = [
|
|
95
|
+
...projectsInWorkspaces,
|
|
96
|
+
path.relative(rootPath, operator.getNodeData(projectName).extra.path),
|
|
97
|
+
...allDeps.map((p) => path.relative(rootPath, p.extra.path))
|
|
98
|
+
];
|
|
58
99
|
}
|
|
59
100
|
const noDupProjectList = Array.from(new Set(projectsInWorkspaces));
|
|
60
101
|
const restorWorkspace = replaceWorkspaces({
|
|
61
102
|
rootPath,
|
|
62
103
|
projectsInWorkspaces: noDupProjectList
|
|
63
104
|
});
|
|
64
|
-
|
|
65
|
-
rootPath,
|
|
66
|
-
removeLock: true
|
|
67
|
-
});
|
|
105
|
+
yield (0, import_install.installByPackageManager)(packageManager, { rootPath, removeLock: true });
|
|
68
106
|
if (restorWorkspace) {
|
|
69
107
|
restorWorkspace();
|
|
70
108
|
}
|
|
71
|
-
};
|
|
72
|
-
exports.runInstallTask = runInstallTask;
|
|
109
|
+
});
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
hooks: () => hooks
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
const afterMonorepoDeploy = (0,
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_plugin = require("@modern-js/plugin");
|
|
24
|
+
const afterMonorepoDeploy = (0, import_plugin.createAsyncWorkflow)();
|
|
9
25
|
const hooks = {
|
|
10
26
|
afterMonorepoDeploy
|
|
11
27
|
};
|
|
12
|
-
exports.hooks = hooks;
|
package/dist/js/node/index.js
CHANGED
|
@@ -1,38 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
default: () => src_default
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var import_plugin_changeset = __toESM(require("@modern-js/plugin-changeset"));
|
|
30
|
+
var import_plugin_lint = __toESM(require("@modern-js/plugin-lint"));
|
|
31
|
+
var import_utils = require("@modern-js/utils");
|
|
32
|
+
var import_locale = require("./locale");
|
|
33
|
+
var import_cli = require("./cli");
|
|
34
|
+
var import_language = require("./utils/language");
|
|
35
|
+
var import_hooks = require("./hooks");
|
|
36
|
+
const upgradeModel = import_utils.Import.lazy(
|
|
37
|
+
"@modern-js/upgrade",
|
|
38
|
+
require
|
|
39
|
+
);
|
|
40
|
+
var src_default = () => ({
|
|
41
|
+
name: "@modern-js/monorepo-tools",
|
|
42
|
+
usePlugins: [(0, import_plugin_changeset.default)(), (0, import_plugin_lint.default)()],
|
|
43
|
+
registerHook: import_hooks.hooks,
|
|
44
|
+
setup: (api) => {
|
|
45
|
+
const locale = (0, import_language.getLocaleLanguage)();
|
|
46
|
+
import_locale.i18n.changeLanguage({ locale });
|
|
25
47
|
return {
|
|
26
|
-
commands({
|
|
27
|
-
program
|
|
28
|
-
|
|
29
|
-
(0,
|
|
30
|
-
(
|
|
31
|
-
(0, _cli.newCli)(program, locale);
|
|
32
|
-
upgradeModel.defineCommand(program.command('upgrade'));
|
|
48
|
+
commands({ program }) {
|
|
49
|
+
(0, import_cli.clearCli)(program, api);
|
|
50
|
+
(0, import_cli.deployCli)(program, api);
|
|
51
|
+
(0, import_cli.newCli)(program, locale);
|
|
52
|
+
upgradeModel.defineCommand(program.command("upgrade"));
|
|
33
53
|
}
|
|
34
54
|
};
|
|
35
55
|
},
|
|
36
|
-
post: [
|
|
56
|
+
post: ["@modern-js/plugin-changeset"]
|
|
37
57
|
});
|
|
38
|
-
exports.default = _default;
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
EN_LOCALE: () => EN_LOCALE
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
7
23
|
const EN_LOCALE = {
|
|
8
24
|
command: {
|
|
9
25
|
new: {
|
|
10
|
-
describe:
|
|
11
|
-
debug:
|
|
12
|
-
config:
|
|
13
|
-
plugin:
|
|
26
|
+
describe: "generator runner for monorepo project",
|
|
27
|
+
debug: "using debug mode to log something",
|
|
28
|
+
config: "set default generator config(json string)",
|
|
29
|
+
plugin: "use generator plugin to create new sub-solution project or customize Modern.js sub-solution project",
|
|
14
30
|
distTag: `use specified tag version for it's generator`,
|
|
15
|
-
registry:
|
|
31
|
+
registry: "set npm registry url to run npm command"
|
|
16
32
|
}
|
|
17
33
|
}
|
|
18
34
|
};
|
|
19
|
-
exports.EN_LOCALE = EN_LOCALE;
|