@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,29 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import * as path from "path";
|
|
22
|
+
import { fs, yaml } from "@modern-js/utils";
|
|
23
|
+
import { JsonFile } from "@rushstack/node-core-library";
|
|
4
24
|
import { WORKSPACE_FILE } from "../../constants";
|
|
5
25
|
import { installByPackageManager } from "../../utils/install";
|
|
6
26
|
const replaceWorkspaces = ({
|
|
7
27
|
rootPath,
|
|
8
28
|
projectsInWorkspaces
|
|
9
29
|
}) => {
|
|
10
|
-
|
|
30
|
+
var _a;
|
|
11
31
|
const pnpmWsFilePath = path.join(rootPath, WORKSPACE_FILE.PNPM);
|
|
12
32
|
if (fs.existsSync(pnpmWsFilePath)) {
|
|
13
|
-
const pnpmWorkspace = fs.readFileSync(pnpmWsFilePath,
|
|
33
|
+
const pnpmWorkspace = fs.readFileSync(pnpmWsFilePath, "utf-8");
|
|
14
34
|
const originalPnpmWorkspaces = yaml.load(pnpmWorkspace);
|
|
15
|
-
fs.writeFileSync(
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
fs.writeFileSync(
|
|
36
|
+
pnpmWsFilePath,
|
|
37
|
+
yaml.dump({ packages: projectsInWorkspaces })
|
|
38
|
+
);
|
|
18
39
|
return () => {
|
|
19
40
|
yaml.dump(originalPnpmWorkspaces);
|
|
20
41
|
};
|
|
21
42
|
}
|
|
22
43
|
const pkgFilePath = path.join(rootPath, WORKSPACE_FILE.YARN);
|
|
23
44
|
if (fs.existsSync(pkgFilePath)) {
|
|
24
|
-
var _pkg$workspaces;
|
|
25
45
|
const pkg = JsonFile.load(pkgFilePath);
|
|
26
|
-
if (pkg
|
|
46
|
+
if ((_a = pkg == null ? void 0 : pkg.workspaces) == null ? void 0 : _a.packages) {
|
|
27
47
|
const originalPkg = pkg;
|
|
28
48
|
pkg.workspaces.packages = projectsInWorkspaces;
|
|
29
49
|
JsonFile.save(pkg, pkgFilePath);
|
|
@@ -34,30 +54,31 @@ const replaceWorkspaces = ({
|
|
|
34
54
|
}
|
|
35
55
|
return false;
|
|
36
56
|
};
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
rootPath,
|
|
40
|
-
packageManager
|
|
41
|
-
} = config;
|
|
57
|
+
const runInstallTask = (projectNames, operator, config) => __async(void 0, null, function* () {
|
|
58
|
+
const { rootPath, packageManager } = config;
|
|
42
59
|
let projectsInWorkspaces = [];
|
|
43
60
|
if (projectNames.length === 0) {
|
|
44
|
-
console.info(
|
|
61
|
+
console.info("install all projects");
|
|
45
62
|
return;
|
|
46
63
|
}
|
|
47
64
|
for (const projectName of projectNames) {
|
|
48
65
|
const allDeps = operator.getNodeAllDependencyData(projectName);
|
|
49
|
-
projectsInWorkspaces = [
|
|
66
|
+
projectsInWorkspaces = [
|
|
67
|
+
...projectsInWorkspaces,
|
|
68
|
+
path.relative(rootPath, operator.getNodeData(projectName).extra.path),
|
|
69
|
+
...allDeps.map((p) => path.relative(rootPath, p.extra.path))
|
|
70
|
+
];
|
|
50
71
|
}
|
|
51
72
|
const noDupProjectList = Array.from(new Set(projectsInWorkspaces));
|
|
52
73
|
const restorWorkspace = replaceWorkspaces({
|
|
53
74
|
rootPath,
|
|
54
75
|
projectsInWorkspaces: noDupProjectList
|
|
55
76
|
});
|
|
56
|
-
|
|
57
|
-
rootPath,
|
|
58
|
-
removeLock: true
|
|
59
|
-
});
|
|
77
|
+
yield installByPackageManager(packageManager, { rootPath, removeLock: true });
|
|
60
78
|
if (restorWorkspace) {
|
|
61
79
|
restorWorkspace();
|
|
62
80
|
}
|
|
63
|
-
};
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
runInstallTask
|
|
84
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { createAsyncWorkflow } from
|
|
1
|
+
import { createAsyncWorkflow } from "@modern-js/plugin";
|
|
2
2
|
const afterMonorepoDeploy = createAsyncWorkflow();
|
|
3
|
-
|
|
3
|
+
const hooks = {
|
|
4
4
|
afterMonorepoDeploy
|
|
5
|
-
};
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
hooks
|
|
8
|
+
};
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import ChangesetPlugin from
|
|
2
|
-
import LintPlugin from
|
|
3
|
-
import { Import } from
|
|
1
|
+
import ChangesetPlugin from "@modern-js/plugin-changeset";
|
|
2
|
+
import LintPlugin from "@modern-js/plugin-lint";
|
|
3
|
+
import { Import } from "@modern-js/utils";
|
|
4
4
|
import { i18n } from "./locale";
|
|
5
5
|
import { newCli, deployCli, clearCli } from "./cli";
|
|
6
6
|
import { getLocaleLanguage } from "./utils/language";
|
|
7
7
|
import { hooks } from "./hooks";
|
|
8
|
-
const upgradeModel = Import.lazy(
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const upgradeModel = Import.lazy(
|
|
9
|
+
"@modern-js/upgrade",
|
|
10
|
+
require
|
|
11
|
+
);
|
|
12
|
+
var src_default = () => ({
|
|
13
|
+
name: "@modern-js/monorepo-tools",
|
|
11
14
|
usePlugins: [ChangesetPlugin(), LintPlugin()],
|
|
12
15
|
registerHook: hooks,
|
|
13
|
-
setup: api => {
|
|
16
|
+
setup: (api) => {
|
|
14
17
|
const locale = getLocaleLanguage();
|
|
15
|
-
i18n.changeLanguage({
|
|
16
|
-
locale
|
|
17
|
-
});
|
|
18
|
+
i18n.changeLanguage({ locale });
|
|
18
19
|
return {
|
|
19
|
-
commands({
|
|
20
|
-
program
|
|
21
|
-
}) {
|
|
20
|
+
commands({ program }) {
|
|
22
21
|
clearCli(program, api);
|
|
23
22
|
deployCli(program, api);
|
|
24
23
|
newCli(program, locale);
|
|
25
|
-
upgradeModel.defineCommand(program.command(
|
|
24
|
+
upgradeModel.defineCommand(program.command("upgrade"));
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
},
|
|
29
|
-
post: [
|
|
30
|
-
})
|
|
28
|
+
post: ["@modern-js/plugin-changeset"]
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
src_default as default
|
|
32
|
+
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const EN_LOCALE = {
|
|
2
2
|
command: {
|
|
3
3
|
new: {
|
|
4
|
-
describe:
|
|
5
|
-
debug:
|
|
6
|
-
config:
|
|
7
|
-
plugin:
|
|
4
|
+
describe: "generator runner for monorepo project",
|
|
5
|
+
debug: "using debug mode to log something",
|
|
6
|
+
config: "set default generator config(json string)",
|
|
7
|
+
plugin: "use generator plugin to create new sub-solution project or customize Modern.js sub-solution project",
|
|
8
8
|
distTag: `use specified tag version for it's generator`,
|
|
9
|
-
registry:
|
|
9
|
+
registry: "set npm registry url to run npm command"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
};
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
EN_LOCALE
|
|
15
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I18n } from
|
|
1
|
+
import { I18n } from "@modern-js/plugin-i18n";
|
|
2
2
|
import { ZH_LOCALE } from "./zh";
|
|
3
3
|
import { EN_LOCALE } from "./en";
|
|
4
4
|
const i18n = new I18n();
|
|
5
|
-
const localeKeys = i18n.init(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const localeKeys = i18n.init("zh", { zh: ZH_LOCALE, en: EN_LOCALE });
|
|
6
|
+
export {
|
|
7
|
+
i18n,
|
|
8
|
+
localeKeys
|
|
9
|
+
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const ZH_LOCALE = {
|
|
2
2
|
command: {
|
|
3
3
|
new: {
|
|
4
|
-
describe:
|
|
5
|
-
debug:
|
|
6
|
-
config:
|
|
7
|
-
plugin:
|
|
8
|
-
distTag:
|
|
9
|
-
registry:
|
|
4
|
+
describe: "Monorepo 创建子项目",
|
|
5
|
+
debug: "开启 Debug 模式,打印调试日志信息",
|
|
6
|
+
config: "生成器运行默认配置(JSON 字符串)",
|
|
7
|
+
plugin: "使用生成器插件创建新的工程方案子项目或定制化 Modern.js 工程方案子项目",
|
|
8
|
+
distTag: "生成器使用特殊的 npm Tag 版本",
|
|
9
|
+
registry: "生成器运行过程中定制 npm Registry"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
};
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
ZH_LOCALE
|
|
15
|
+
};
|
|
@@ -1,54 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import { Signale } from '@modern-js/utils';
|
|
1
|
+
import { Signale } from "@modern-js/utils";
|
|
3
2
|
import { formatLog } from "./utils";
|
|
4
3
|
const createLogger = (name, config) => {
|
|
5
4
|
const options = {
|
|
6
5
|
scope: config.label ? config.label + name : name,
|
|
7
6
|
types: {
|
|
8
7
|
info: {
|
|
9
|
-
badge:
|
|
10
|
-
color:
|
|
11
|
-
label:
|
|
8
|
+
badge: "",
|
|
9
|
+
color: "blue",
|
|
10
|
+
label: ""
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
};
|
|
15
14
|
return new Signale(options);
|
|
16
15
|
};
|
|
17
16
|
const createListenHandler = (name, config) => {
|
|
18
|
-
// const sb = new StringBuilder();
|
|
19
17
|
const logger = createLogger(name, config);
|
|
20
|
-
|
|
21
|
-
const stdout = chunk => {
|
|
22
|
-
// console.info(chunk.toString().split(/\r\n|\n\r|\r|\n/g).length);
|
|
18
|
+
const stdout = (chunk) => {
|
|
23
19
|
logger.info(formatLog(chunk.toString()));
|
|
24
20
|
};
|
|
25
|
-
|
|
26
|
-
const stderr = chunk => {
|
|
21
|
+
const stderr = (chunk) => {
|
|
27
22
|
logger.error(chunk.toString());
|
|
28
|
-
// logger.log('#####################');
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
stdout,
|
|
33
|
-
stderr
|
|
34
23
|
};
|
|
24
|
+
return { stdout, stderr };
|
|
35
25
|
};
|
|
36
|
-
|
|
26
|
+
class MultitasksLogger {
|
|
37
27
|
constructor() {
|
|
38
|
-
_defineProperty(this, "_taskNameList", void 0);
|
|
39
|
-
_defineProperty(this, "_taskStdoutListenerMap", void 0);
|
|
40
|
-
_defineProperty(this, "_taskStderrListenerMap", void 0);
|
|
41
|
-
_defineProperty(this, "_taskLogConfigMap", void 0);
|
|
42
28
|
this._taskNameList = [];
|
|
43
|
-
this._taskStdoutListenerMap = new Map();
|
|
44
|
-
this._taskStderrListenerMap = new Map();
|
|
45
|
-
this._taskLogConfigMap = new Map();
|
|
29
|
+
this._taskStdoutListenerMap = /* @__PURE__ */ new Map();
|
|
30
|
+
this._taskStderrListenerMap = /* @__PURE__ */ new Map();
|
|
31
|
+
this._taskLogConfigMap = /* @__PURE__ */ new Map();
|
|
46
32
|
}
|
|
47
33
|
addLogProvider(name, config) {
|
|
34
|
+
var _a, _b;
|
|
48
35
|
if (this._taskNameList.includes(name)) {
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
(_this$_taskStderrList = this._taskStderrListenerMap.get(name)) === null || _this$_taskStderrList === void 0 ? void 0 : _this$_taskStderrList.removeAllListeners();
|
|
36
|
+
(_a = this._taskStdoutListenerMap.get(name)) == null ? void 0 : _a.removeAllListeners();
|
|
37
|
+
(_b = this._taskStderrListenerMap.get(name)) == null ? void 0 : _b.removeAllListeners();
|
|
52
38
|
this._taskStdoutListenerMap.delete(name);
|
|
53
39
|
this._taskStderrListenerMap.delete(name);
|
|
54
40
|
}
|
|
@@ -59,10 +45,13 @@ export class MultitasksLogger {
|
|
|
59
45
|
this.startListen(name);
|
|
60
46
|
}
|
|
61
47
|
startListen(taskName) {
|
|
62
|
-
const listenHandler = createListenHandler(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
const listenHandler = createListenHandler(
|
|
49
|
+
taskName,
|
|
50
|
+
this._taskLogConfigMap.get(taskName).logConfig
|
|
51
|
+
);
|
|
52
|
+
this._taskStdoutListenerMap.get(taskName).on("data", listenHandler.stdout);
|
|
53
|
+
this._taskStdoutListenerMap.get(taskName).on("error", listenHandler.stderr);
|
|
54
|
+
this._taskStderrListenerMap.get(taskName).on("data", listenHandler.stderr);
|
|
66
55
|
}
|
|
67
56
|
startListenAll() {
|
|
68
57
|
for (const taskName of this._taskNameList) {
|
|
@@ -70,6 +59,8 @@ export class MultitasksLogger {
|
|
|
70
59
|
}
|
|
71
60
|
}
|
|
72
61
|
finishListen() {
|
|
73
|
-
// 是否需要
|
|
74
62
|
}
|
|
75
|
-
}
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
MultitasksLogger
|
|
66
|
+
};
|
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { Signale } from "@modern-js/utils";
|
|
18
|
+
const initTimeLog = (option = {}) => new Signale(__spreadValues({ interactive: true, scope: "time-log" }, option));
|
|
19
|
+
const startTime = (signaleInstance, prefix = "") => {
|
|
10
20
|
signaleInstance.time(prefix);
|
|
11
21
|
};
|
|
12
|
-
|
|
22
|
+
const endTime = (signaleInstance, prefix = "") => {
|
|
13
23
|
signaleInstance.timeEnd(prefix);
|
|
14
|
-
};
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
endTime,
|
|
27
|
+
initTimeLog,
|
|
28
|
+
startTime
|
|
29
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
const formatLog = (log) => {
|
|
2
2
|
const strs = log.split(/\r\n|\n\r|\r|\n/g);
|
|
3
|
-
if (strs[0].trim() ===
|
|
4
|
-
return
|
|
3
|
+
if (strs[0].trim() === "") {
|
|
4
|
+
return `
|
|
5
|
+
${strs.slice(1).filter((s) => Boolean(s)).join("\n")}`;
|
|
5
6
|
}
|
|
6
|
-
return strs.filter(s => Boolean(s)).join(
|
|
7
|
-
};
|
|
7
|
+
return strs.filter((s) => Boolean(s)).join("\n");
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
formatLog
|
|
11
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export class Package {
|
|
1
|
+
class Package {
|
|
3
2
|
constructor(packageJson, packageConfigPath, rootPath) {
|
|
4
|
-
_defineProperty(this, "json", void 0);
|
|
5
|
-
_defineProperty(this, "configPath", void 0);
|
|
6
|
-
_defineProperty(this, "rootPath", void 0);
|
|
7
3
|
this.configPath = packageConfigPath;
|
|
8
4
|
this.rootPath = rootPath;
|
|
9
5
|
this.json = packageJson;
|
|
@@ -17,4 +13,7 @@ export class Package {
|
|
|
17
13
|
get(key) {
|
|
18
14
|
return this.json[key];
|
|
19
15
|
}
|
|
20
|
-
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
Package
|
|
19
|
+
};
|
|
@@ -1,24 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
11
36
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
37
|
+
import * as path from "path";
|
|
38
|
+
import { JsonFile } from "@rushstack/node-core-library";
|
|
39
|
+
import { getMonorepoBaseData } from "./monorepo";
|
|
40
|
+
const defaultConfig = {};
|
|
41
|
+
const getFinalConfig = (..._0) => __async(void 0, [..._0], function* (currentPath = process.cwd()) {
|
|
17
42
|
const monorepo = getMonorepoBaseData(currentPath);
|
|
18
|
-
const userConfig =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
const userConfig = yield JsonFile.loadAsync(
|
|
44
|
+
path.resolve(monorepo.rootPath, "mono-config.json")
|
|
45
|
+
);
|
|
46
|
+
const config = __spreadValues(__spreadValues({}, defaultConfig), userConfig);
|
|
47
|
+
return { monorepo, config };
|
|
48
|
+
});
|
|
49
|
+
export {
|
|
50
|
+
getFinalConfig
|
|
51
|
+
};
|
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import * as path from
|
|
2
|
-
import { FileSystem, JsonFile } from
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { FileSystem, JsonFile } from "@rushstack/node-core-library";
|
|
3
3
|
import { WORKSPACE_FILE } from "../constants";
|
|
4
|
-
const useLerna = monorepoRootPath => {
|
|
4
|
+
const useLerna = (monorepoRootPath) => {
|
|
5
5
|
if (FileSystem.exists(path.join(monorepoRootPath, WORKSPACE_FILE.LERNA))) {
|
|
6
6
|
return true;
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
|
-
const useYarnWorkspaces = monorepoRootPath => {
|
|
10
|
+
const useYarnWorkspaces = (monorepoRootPath) => {
|
|
11
11
|
if (!FileSystem.exists(path.join(monorepoRootPath, WORKSPACE_FILE.YARN))) {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
const json = JsonFile.load(path.join(monorepoRootPath, WORKSPACE_FILE.YARN));
|
|
15
|
-
if (
|
|
15
|
+
if ("workspaces" in json && json.workspaces.packages) {
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
18
|
return false;
|
|
19
19
|
};
|
|
20
|
-
const usePnpmWorkspaces = monorepoRootPath => {
|
|
20
|
+
const usePnpmWorkspaces = (monorepoRootPath) => {
|
|
21
21
|
if (FileSystem.exists(path.join(monorepoRootPath, WORKSPACE_FILE.PNPM))) {
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
return false;
|
|
25
25
|
};
|
|
26
|
-
const isMonorepo = monorepoRootPath => {
|
|
26
|
+
const isMonorepo = (monorepoRootPath) => {
|
|
27
27
|
if (usePnpmWorkspaces(monorepoRootPath) || useLerna(monorepoRootPath) || useYarnWorkspaces(monorepoRootPath)) {
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
return false;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
const findMonorepoRoot = (starFindPath) => {
|
|
33
33
|
let inMonorepo = false;
|
|
34
34
|
let findPath = starFindPath;
|
|
35
|
-
while (findPath !==
|
|
35
|
+
while (findPath !== "/") {
|
|
36
36
|
if (isMonorepo(findPath)) {
|
|
37
37
|
inMonorepo = true;
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
findPath = path.dirname(findPath);
|
|
41
41
|
}
|
|
42
|
-
return inMonorepo ? findPath :
|
|
42
|
+
return inMonorepo ? findPath : void 0;
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
const getWorkspaceFile = (startFindPath) => {
|
|
45
45
|
const rootPath = findMonorepoRoot(startFindPath);
|
|
46
46
|
if (!rootPath) {
|
|
47
|
-
throw new Error(
|
|
47
|
+
throw new Error(
|
|
48
|
+
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
49
|
+
);
|
|
48
50
|
}
|
|
49
51
|
if (usePnpmWorkspaces(rootPath)) {
|
|
50
52
|
return WORKSPACE_FILE.PNPM;
|
|
@@ -53,36 +55,49 @@ export const getWorkspaceFile = startFindPath => {
|
|
|
53
55
|
} else if (useYarnWorkspaces(rootPath)) {
|
|
54
56
|
return WORKSPACE_FILE.YARN;
|
|
55
57
|
} else {
|
|
56
|
-
throw new Error(
|
|
58
|
+
throw new Error(
|
|
59
|
+
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
60
|
+
);
|
|
57
61
|
}
|
|
58
62
|
};
|
|
59
|
-
|
|
60
|
-
pnpm: [WORKSPACE_FILE.PNPM,
|
|
61
|
-
yarn: [
|
|
63
|
+
const packageManagerFlag = {
|
|
64
|
+
pnpm: [WORKSPACE_FILE.PNPM, "pnpm-lock.yaml"],
|
|
65
|
+
yarn: ["yarn.lock", useYarnWorkspaces],
|
|
62
66
|
npm: [() => true]
|
|
63
67
|
};
|
|
64
|
-
const usePnpmPackageManager = monorepoRootPath => packageManagerFlag.pnpm.some(
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const usePnpmPackageManager = (monorepoRootPath) => packageManagerFlag.pnpm.some(
|
|
69
|
+
(flag) => FileSystem.exists(path.join(monorepoRootPath, flag))
|
|
70
|
+
);
|
|
71
|
+
const useYarnPackageManager = (monorepoRootPath) => packageManagerFlag.yarn.some((flag) => {
|
|
72
|
+
if (typeof flag === "function") {
|
|
67
73
|
return flag(monorepoRootPath);
|
|
68
74
|
}
|
|
69
75
|
return FileSystem.exists(path.join(monorepoRootPath, flag));
|
|
70
76
|
});
|
|
71
|
-
|
|
77
|
+
const getPackageManager = (monorepoRootPath) => {
|
|
72
78
|
if (usePnpmPackageManager(monorepoRootPath)) {
|
|
73
|
-
return
|
|
79
|
+
return "pnpm";
|
|
74
80
|
} else if (useYarnPackageManager(monorepoRootPath)) {
|
|
75
|
-
return
|
|
81
|
+
return "yarn";
|
|
76
82
|
}
|
|
77
|
-
return
|
|
83
|
+
return "npm";
|
|
78
84
|
};
|
|
79
|
-
|
|
85
|
+
const getMonorepoBaseData = (root = process.cwd()) => {
|
|
80
86
|
const rootPath = findMonorepoRoot(root);
|
|
81
87
|
if (!rootPath) {
|
|
82
|
-
throw new Error(
|
|
88
|
+
throw new Error(
|
|
89
|
+
"not find any monorepo, you can add lerna、pnpm or yarn workspace file"
|
|
90
|
+
);
|
|
83
91
|
}
|
|
84
92
|
return {
|
|
85
93
|
rootPath,
|
|
86
94
|
packageManager: getPackageManager(rootPath)
|
|
87
95
|
};
|
|
88
|
-
};
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
findMonorepoRoot,
|
|
99
|
+
getMonorepoBaseData,
|
|
100
|
+
getPackageManager,
|
|
101
|
+
getWorkspaceFile,
|
|
102
|
+
packageManagerFlag
|
|
103
|
+
};
|