@modern-js/monorepo-tools 2.4.1-beta.0 → 2.6.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 +35 -8
- package/cli.js +1 -1
- package/dist/{js/node → cjs}/cli/build-watch.js +3 -23
- package/dist/{js/node → cjs}/cli/build.js +3 -23
- package/dist/{js/node → cjs}/cli/clear.js +3 -23
- package/dist/{js/node → cjs}/cli/deploy.js +3 -23
- package/dist/cjs/cli/install.js +34 -0
- package/dist/{js/node → cjs}/cli/new.js +3 -40
- package/dist/{js/node → cjs}/commands/build-watch.js +4 -24
- package/dist/{js/node → cjs}/commands/build.js +9 -41
- package/dist/{js/node → cjs}/commands/clear.js +3 -23
- package/dist/{js/node → cjs}/commands/deploy.js +4 -24
- package/dist/{js/node → cjs}/commands/install.js +4 -24
- package/dist/{js/node → cjs}/dag/create.js +9 -16
- package/dist/cjs/dag/operator.js +269 -0
- package/dist/{js/node → cjs}/dag/task.js +33 -53
- package/dist/{js/node → cjs}/features/build/index.js +17 -33
- package/dist/{js/node → cjs}/features/clear/index.js +4 -0
- package/dist/{js/node → cjs}/features/deploy/index.js +15 -30
- package/dist/{js/node → cjs}/features/dev/create-task.js +10 -26
- package/dist/{js/node → cjs}/features/dev/index.js +18 -34
- package/dist/{js/node → cjs}/features/dev/watch-projects-state.js +7 -19
- package/dist/{js/node → cjs}/features/install/index.js +7 -23
- package/dist/{js/node → cjs}/index.js +4 -0
- package/dist/{js/node → cjs}/log/time.js +1 -15
- package/dist/{js/node → cjs}/parse-config/index.js +13 -39
- package/dist/{js/node → cjs}/parse-config/monorepo.js +4 -0
- package/dist/{js/node → cjs}/projects/check-project-change.js +16 -32
- package/dist/{js/node → cjs}/projects/clear-memory-files.js +4 -0
- package/dist/{js/node → cjs}/projects/get-projects-by-packages-config.js +17 -45
- package/dist/{js/node → cjs}/projects/get-projects-by-workspace-file.js +8 -24
- package/dist/{js/node → cjs}/projects/get-projects.js +18 -47
- package/dist/{js/node → cjs}/utils/install.js +8 -24
- package/dist/esm/cli/build-watch.js +11 -0
- package/dist/esm/cli/build.js +12 -0
- package/dist/esm/cli/clear.js +11 -0
- package/dist/esm/cli/deploy.js +16 -0
- package/dist/esm/cli/install.js +11 -0
- package/dist/esm/cli/new.js +18 -0
- package/dist/esm/commands/build-watch.js +24 -0
- package/dist/esm/commands/build.js +56 -0
- package/dist/esm/commands/clear.js +19 -0
- package/dist/{js/modern → esm}/commands/deploy.js +4 -24
- package/dist/esm/commands/install.js +23 -0
- package/dist/{js/modern → esm}/dag/create.js +9 -18
- package/dist/esm/dag/operator.js +236 -0
- package/dist/esm/dag/task.js +55 -0
- package/dist/{js/modern → esm}/features/build/index.js +13 -33
- package/dist/{js/modern → esm}/features/deploy/index.js +11 -30
- package/dist/{js/modern → esm}/features/dev/create-task.js +6 -26
- package/dist/{js/modern → esm}/features/dev/index.js +14 -34
- package/dist/{js/modern → esm}/features/dev/watch-projects-state.js +3 -21
- package/dist/{js/modern → esm}/features/install/index.js +3 -23
- package/dist/esm/log/time.js +13 -0
- package/dist/esm/parse-config/index.js +19 -0
- package/dist/{js/modern → esm}/projects/check-project-change.js +12 -32
- package/dist/{js/modern → esm}/projects/get-projects-by-packages-config.js +13 -47
- package/dist/{js/modern → esm}/projects/get-projects-by-workspace-file.js +4 -24
- package/dist/{js/modern → esm}/projects/get-projects.js +18 -49
- package/dist/esm/utils/install.js +27 -0
- package/dist/types/package/index.d.ts +1 -1
- package/package.json +16 -16
- package/dist/js/modern/cli/build-watch.js +0 -31
- package/dist/js/modern/cli/build.js +0 -32
- package/dist/js/modern/cli/clear.js +0 -31
- package/dist/js/modern/cli/deploy.js +0 -36
- package/dist/js/modern/cli/install.js +0 -31
- package/dist/js/modern/cli/new.js +0 -57
- package/dist/js/modern/commands/build-watch.js +0 -44
- package/dist/js/modern/commands/build.js +0 -90
- package/dist/js/modern/commands/clear.js +0 -39
- package/dist/js/modern/commands/install.js +0 -43
- package/dist/js/modern/dag/operator.js +0 -251
- package/dist/js/modern/dag/task.js +0 -79
- package/dist/js/modern/log/time.js +0 -29
- package/dist/js/modern/parse-config/index.js +0 -51
- package/dist/js/modern/utils/install.js +0 -47
- package/dist/js/node/cli/install.js +0 -54
- package/dist/js/node/dag/operator.js +0 -278
- /package/dist/{js/node → cjs}/cli/index.js +0 -0
- /package/dist/{js/node → cjs}/commands/index.js +0 -0
- /package/dist/{js/node → cjs}/constants.js +0 -0
- /package/dist/{js/node → cjs}/dag/edge-manager.js +0 -0
- /package/dist/{js/node → cjs}/dag/index.js +0 -0
- /package/dist/{js/node → cjs}/dag/utils.js +0 -0
- /package/dist/{js/node → cjs}/features/dev/cmds.js +0 -0
- /package/dist/{js/node → cjs}/hooks/index.js +0 -0
- /package/dist/{js/node → cjs}/locale/en.js +0 -0
- /package/dist/{js/node → cjs}/locale/index.js +0 -0
- /package/dist/{js/node → cjs}/locale/zh.js +0 -0
- /package/dist/{js/node → cjs}/log/error.js +0 -0
- /package/dist/{js/node → cjs}/log/multi-tasks-log.js +0 -0
- /package/dist/{js/node → cjs}/log/utils.js +0 -0
- /package/dist/{js/node → cjs}/package/index.js +0 -0
- /package/dist/{js/node → cjs}/type.js +0 -0
- /package/dist/{js/node → cjs}/utils/language.js +0 -0
- /package/dist/{js/node → cjs}/utils/types.js +0 -0
- /package/dist/{js/modern → esm}/cli/index.js +0 -0
- /package/dist/{js/modern → esm}/commands/index.js +0 -0
- /package/dist/{js/modern → esm}/constants.js +0 -0
- /package/dist/{js/modern → esm}/dag/edge-manager.js +0 -0
- /package/dist/{js/modern → esm}/dag/index.js +0 -0
- /package/dist/{js/modern → esm}/dag/utils.js +0 -0
- /package/dist/{js/modern → esm}/features/clear/index.js +0 -0
- /package/dist/{js/modern → esm}/features/dev/cmds.js +0 -0
- /package/dist/{js/modern → esm}/hooks/index.js +0 -0
- /package/dist/{js/modern → esm}/index.js +0 -0
- /package/dist/{js/modern → esm}/locale/en.js +0 -0
- /package/dist/{js/modern → esm}/locale/index.js +0 -0
- /package/dist/{js/modern → esm}/locale/zh.js +0 -0
- /package/dist/{js/modern → esm}/log/error.js +0 -0
- /package/dist/{js/modern → esm}/log/multi-tasks-log.js +0 -0
- /package/dist/{js/modern → esm}/log/utils.js +0 -0
- /package/dist/{js/modern → esm}/package/index.js +0 -0
- /package/dist/{js/modern → esm}/parse-config/monorepo.js +0 -0
- /package/dist/{js/modern → esm}/projects/clear-memory-files.js +0 -0
- /package/dist/{js/modern → esm}/type.js +0 -0
- /package/dist/{js/modern → esm}/utils/language.js +0 -0
- /package/dist/{js/modern → esm}/utils/types.js +0 -0
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import * as path from "path";
|
|
21
2
|
import { globby } from "@modern-js/utils";
|
|
22
3
|
class WatchedProjectsState {
|
|
@@ -44,9 +25,10 @@ class WatchedProjectsState {
|
|
|
44
25
|
node.extra.path
|
|
45
26
|
);
|
|
46
27
|
}
|
|
47
|
-
return
|
|
28
|
+
return {
|
|
29
|
+
...ret,
|
|
48
30
|
[node.extra.path]: node
|
|
49
|
-
}
|
|
31
|
+
};
|
|
50
32
|
},
|
|
51
33
|
{}
|
|
52
34
|
);
|
|
@@ -1,23 +1,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
1
|
import * as path from "path";
|
|
22
2
|
import { fs, yaml } from "@modern-js/utils";
|
|
23
3
|
import { JsonFile } from "@rushstack/node-core-library";
|
|
@@ -54,7 +34,7 @@ const replaceWorkspaces = ({
|
|
|
54
34
|
}
|
|
55
35
|
return false;
|
|
56
36
|
};
|
|
57
|
-
const runInstallTask = (projectNames, operator, config) =>
|
|
37
|
+
const runInstallTask = async (projectNames, operator, config) => {
|
|
58
38
|
const { rootPath, packageManager } = config;
|
|
59
39
|
let projectsInWorkspaces = [];
|
|
60
40
|
if (projectNames.length === 0) {
|
|
@@ -74,11 +54,11 @@ const runInstallTask = (projectNames, operator, config) => __async(void 0, null,
|
|
|
74
54
|
rootPath,
|
|
75
55
|
projectsInWorkspaces: noDupProjectList
|
|
76
56
|
});
|
|
77
|
-
|
|
57
|
+
await installByPackageManager(packageManager, { rootPath, removeLock: true });
|
|
78
58
|
if (restorWorkspace) {
|
|
79
59
|
restorWorkspace();
|
|
80
60
|
}
|
|
81
|
-
}
|
|
61
|
+
};
|
|
82
62
|
export {
|
|
83
63
|
runInstallTask
|
|
84
64
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Signale } from "@modern-js/utils";
|
|
2
|
+
const initTimeLog = (option = {}) => new Signale({ interactive: true, scope: "time-log", ...option });
|
|
3
|
+
const startTime = (signaleInstance, prefix = "") => {
|
|
4
|
+
signaleInstance.time(prefix);
|
|
5
|
+
};
|
|
6
|
+
const endTime = (signaleInstance, prefix = "") => {
|
|
7
|
+
signaleInstance.timeEnd(prefix);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
endTime,
|
|
11
|
+
initTimeLog,
|
|
12
|
+
startTime
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { JsonFile } from "@rushstack/node-core-library";
|
|
3
|
+
import { getMonorepoBaseData } from "./monorepo";
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
// packagesMatchs: {
|
|
6
|
+
// workspaceFile: 'pnpm-lock.yaml',
|
|
7
|
+
// },
|
|
8
|
+
};
|
|
9
|
+
const getFinalConfig = async (currentPath = process.cwd()) => {
|
|
10
|
+
const monorepo = getMonorepoBaseData(currentPath);
|
|
11
|
+
const userConfig = await JsonFile.loadAsync(
|
|
12
|
+
path.resolve(monorepo.rootPath, "mono-config.json")
|
|
13
|
+
);
|
|
14
|
+
const config = { ...defaultConfig, ...userConfig };
|
|
15
|
+
return { monorepo, config };
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
getFinalConfig
|
|
19
|
+
};
|
|
@@ -1,23 +1,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
1
|
import * as path from "path";
|
|
22
2
|
import { FileSystem, JsonFile, Sort } from "@rushstack/node-core-library";
|
|
23
3
|
import { getGitHashForFiles } from "@rushstack/package-deps-hash";
|
|
@@ -26,7 +6,7 @@ import md5 from "md5";
|
|
|
26
6
|
const PROJECT_CONTENT_FILE_NAME = "project-content.json";
|
|
27
7
|
const MONOREPO_GIT_FILE_NAME = "monorepo-git.json";
|
|
28
8
|
const PROJECT_MEMORY_PATH = ".project-memory";
|
|
29
|
-
const getProjectGitHash = (project) =>
|
|
9
|
+
const getProjectGitHash = async (project) => {
|
|
30
10
|
const projectDir = project.extra.path;
|
|
31
11
|
const globOption = {
|
|
32
12
|
cwd: projectDir,
|
|
@@ -36,7 +16,7 @@ const getProjectGitHash = (project) => __async(void 0, null, function* () {
|
|
|
36
16
|
ignore: ["**/node_modules/**", ".project-memory/**", "dist/**"]
|
|
37
17
|
};
|
|
38
18
|
const globPattern = `${projectDir}/**`;
|
|
39
|
-
const files =
|
|
19
|
+
const files = await globby(path.posix.join(globPattern), globOption);
|
|
40
20
|
const hashMap = getGitHashForFiles(files, projectDir);
|
|
41
21
|
const hashObject = {};
|
|
42
22
|
Sort.sortMapKeys(hashMap);
|
|
@@ -44,10 +24,10 @@ const getProjectGitHash = (project) => __async(void 0, null, function* () {
|
|
|
44
24
|
hashObject[key] = value;
|
|
45
25
|
});
|
|
46
26
|
return md5(JsonFile.stringify(hashObject));
|
|
47
|
-
}
|
|
48
|
-
const checkProjectChangeByGit = (project, rootPath) =>
|
|
27
|
+
};
|
|
28
|
+
const checkProjectChangeByGit = async (project, rootPath) => {
|
|
49
29
|
const monorepoGitMemory = path.join(rootPath, MONOREPO_GIT_FILE_NAME);
|
|
50
|
-
const currentProjectHash =
|
|
30
|
+
const currentProjectHash = await getProjectGitHash(project);
|
|
51
31
|
if (!FileSystem.exists(monorepoGitMemory)) {
|
|
52
32
|
FileSystem.writeFile(monorepoGitMemory, JsonFile.stringify({}), {
|
|
53
33
|
ensureFolderExists: true
|
|
@@ -64,8 +44,8 @@ const checkProjectChangeByGit = (project, rootPath) => __async(void 0, null, fun
|
|
|
64
44
|
);
|
|
65
45
|
}
|
|
66
46
|
return changed;
|
|
67
|
-
}
|
|
68
|
-
const getProjectContentHashObjectForFiles = (project) =>
|
|
47
|
+
};
|
|
48
|
+
const getProjectContentHashObjectForFiles = async (project) => {
|
|
69
49
|
const projectDir = project.extra.path;
|
|
70
50
|
const globOption = {
|
|
71
51
|
cwd: projectDir,
|
|
@@ -75,21 +55,21 @@ const getProjectContentHashObjectForFiles = (project) => __async(void 0, null, f
|
|
|
75
55
|
ignore: ["**/node_modules/**", ".project-memory/**", "**/dist/**"]
|
|
76
56
|
};
|
|
77
57
|
const globPattern = `${projectDir}/**`;
|
|
78
|
-
const files =
|
|
58
|
+
const files = await globby(path.posix.join(globPattern), globOption);
|
|
79
59
|
const hashObject = {};
|
|
80
60
|
for (const file of files.sort()) {
|
|
81
61
|
hashObject[file] = md5(FileSystem.readFile(file));
|
|
82
62
|
}
|
|
83
63
|
return hashObject;
|
|
84
|
-
}
|
|
85
|
-
const checkProjectChangeByContent = (project) =>
|
|
64
|
+
};
|
|
65
|
+
const checkProjectChangeByContent = async (project) => {
|
|
86
66
|
const projectDir = project.extra.path;
|
|
87
67
|
const projectMemoryFolder = path.resolve(projectDir, ".project-memory");
|
|
88
68
|
const projectJsonFile = path.join(
|
|
89
69
|
projectMemoryFolder,
|
|
90
70
|
PROJECT_CONTENT_FILE_NAME
|
|
91
71
|
);
|
|
92
|
-
const currentHashObject =
|
|
72
|
+
const currentHashObject = await getProjectContentHashObjectForFiles(project);
|
|
93
73
|
const currentHashString = JsonFile.stringify(currentHashObject);
|
|
94
74
|
if (!FileSystem.exists(projectJsonFile)) {
|
|
95
75
|
FileSystem.writeFile(projectJsonFile, currentHashString, {
|
|
@@ -105,7 +85,7 @@ const checkProjectChangeByContent = (project) => __async(void 0, null, function*
|
|
|
105
85
|
});
|
|
106
86
|
}
|
|
107
87
|
return changed;
|
|
108
|
-
}
|
|
88
|
+
};
|
|
109
89
|
export {
|
|
110
90
|
MONOREPO_GIT_FILE_NAME,
|
|
111
91
|
PROJECT_CONTENT_FILE_NAME,
|
|
@@ -1,39 +1,3 @@
|
|
|
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
|
-
});
|
|
36
|
-
};
|
|
37
1
|
import * as path from "path";
|
|
38
2
|
import { PackageJsonLookup } from "@rushstack/node-core-library";
|
|
39
3
|
import { globby } from "@modern-js/utils";
|
|
@@ -55,6 +19,8 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
55
19
|
);
|
|
56
20
|
}
|
|
57
21
|
globOpts.ignore = [
|
|
22
|
+
// allow globs like "packages/**",
|
|
23
|
+
// but avoid picking up node_modules/**/package.json and dist/**/package.json
|
|
58
24
|
"**/dist/**",
|
|
59
25
|
"**/node_modules/**",
|
|
60
26
|
...ignore || []
|
|
@@ -64,23 +30,23 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
64
30
|
};
|
|
65
31
|
const makeFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
66
32
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
67
|
-
return
|
|
68
|
-
const options =
|
|
33
|
+
return async (fileName, fileMapper, customGlobOpts = {}) => {
|
|
34
|
+
const options = { ...customGlobOpts, ...globOpts };
|
|
69
35
|
const promise = pMap(
|
|
70
36
|
Array.from(packageConfigs).sort(),
|
|
71
|
-
(globPath) =>
|
|
72
|
-
let result =
|
|
37
|
+
async (globPath) => {
|
|
38
|
+
let result = await globby(path.posix.join(globPath, fileName), options);
|
|
73
39
|
result = result.sort();
|
|
74
40
|
result = normalize(result);
|
|
75
41
|
return fileMapper(result);
|
|
76
|
-
}
|
|
42
|
+
},
|
|
77
43
|
{ concurrency: packageConfigs.length || Infinity }
|
|
78
44
|
);
|
|
79
|
-
const results =
|
|
45
|
+
const results = await promise;
|
|
80
46
|
return results.reduce((acc, result) => acc.concat(result), []);
|
|
81
|
-
}
|
|
47
|
+
};
|
|
82
48
|
};
|
|
83
|
-
const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) =>
|
|
49
|
+
const getProjectsByPackageConfig = async (rootPath, packagesConfig, ignoreConfigs) => {
|
|
84
50
|
const finder = makeFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
85
51
|
const fileName = "package.json";
|
|
86
52
|
const mapper = (packageConfigPath) => {
|
|
@@ -88,18 +54,18 @@ const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) =>
|
|
|
88
54
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
89
55
|
return new Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
90
56
|
};
|
|
91
|
-
const projects =
|
|
57
|
+
const projects = await finder(
|
|
92
58
|
fileName,
|
|
93
59
|
(filePaths) => pMap(filePaths, mapper, { concurrency: filePaths.length || Infinity }),
|
|
94
60
|
{}
|
|
95
61
|
);
|
|
96
62
|
return projects;
|
|
97
|
-
}
|
|
63
|
+
};
|
|
98
64
|
const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
99
65
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
100
66
|
return (fileName, fileMapper, customGlobOpts = {}) => {
|
|
101
67
|
const results = [];
|
|
102
|
-
const options =
|
|
68
|
+
const options = { ...customGlobOpts, ...globOpts };
|
|
103
69
|
for (const globPath of Array.from(packageConfigs).sort()) {
|
|
104
70
|
let result = globby.sync(path.posix.join(globPath, fileName), options);
|
|
105
71
|
result = result.sort();
|
|
@@ -1,23 +1,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
1
|
import * as path from "path";
|
|
22
2
|
import { FileSystem, JsonFile } from "@rushstack/node-core-library";
|
|
23
3
|
import { fs, yaml } from "@modern-js/utils";
|
|
@@ -27,7 +7,7 @@ import {
|
|
|
27
7
|
getProjectsByPackageConfig,
|
|
28
8
|
syncGetProjectsByPackageConfig
|
|
29
9
|
} from "./get-projects-by-packages-config";
|
|
30
|
-
const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) =>
|
|
10
|
+
const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
|
|
31
11
|
var _a, _b, _c;
|
|
32
12
|
let { workspaceFile } = config;
|
|
33
13
|
if (!config.enableAutoFinder && (!("workspaceFile" in config) || ((_a = config.workspaceFile) == null ? void 0 : _a.length) === 0)) {
|
|
@@ -40,7 +20,7 @@ const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(
|
|
|
40
20
|
}
|
|
41
21
|
let packagesConfig = [];
|
|
42
22
|
if (workspaceFile === WORKSPACE_FILE.PNPM) {
|
|
43
|
-
const yamlString =
|
|
23
|
+
const yamlString = await FileSystem.readFileAsync(
|
|
44
24
|
path.resolve("/", rootPath, workspaceFile)
|
|
45
25
|
).then((data) => data.toString());
|
|
46
26
|
const pnpmWorkspace = yaml.load(yamlString);
|
|
@@ -52,13 +32,13 @@ const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(
|
|
|
52
32
|
const lernaJson = JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
53
33
|
packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
|
|
54
34
|
}
|
|
55
|
-
const projects =
|
|
35
|
+
const projects = await getProjectsByPackageConfig(
|
|
56
36
|
rootPath,
|
|
57
37
|
packagesConfig,
|
|
58
38
|
ignoreConfigs
|
|
59
39
|
);
|
|
60
40
|
return projects;
|
|
61
|
-
}
|
|
41
|
+
};
|
|
62
42
|
const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
|
|
63
43
|
var _a, _b, _c;
|
|
64
44
|
let { workspaceFile } = config;
|
|
@@ -1,39 +1,3 @@
|
|
|
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
|
-
});
|
|
36
|
-
};
|
|
37
1
|
import { errorLog } from "../log/error";
|
|
38
2
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
39
3
|
import {
|
|
@@ -55,6 +19,7 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
55
19
|
subProjects.push({
|
|
56
20
|
name: config.name,
|
|
57
21
|
extra: { path: config.path },
|
|
22
|
+
// dagNodeEdge: 0,
|
|
58
23
|
dependencyEdge: 0,
|
|
59
24
|
dependentEdge: 0,
|
|
60
25
|
checkedCircle: false,
|
|
@@ -63,12 +28,12 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
63
28
|
}
|
|
64
29
|
return subProjects;
|
|
65
30
|
};
|
|
66
|
-
const getProjectsByPackagesMatch = (rootPath, match, ignore) =>
|
|
31
|
+
const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
67
32
|
let projects = [];
|
|
68
33
|
if (Array.isArray(match)) {
|
|
69
|
-
projects =
|
|
34
|
+
projects = await getProjectsByPackageConfig(rootPath, match, ignore);
|
|
70
35
|
} else {
|
|
71
|
-
projects =
|
|
36
|
+
projects = await getProjectsByWorkspaceFile(
|
|
72
37
|
rootPath,
|
|
73
38
|
match,
|
|
74
39
|
ignore
|
|
@@ -78,9 +43,11 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
|
|
|
78
43
|
for (const project of projects) {
|
|
79
44
|
subProjects.push({
|
|
80
45
|
name: project.name,
|
|
81
|
-
extra:
|
|
82
|
-
path: project.path
|
|
83
|
-
|
|
46
|
+
extra: {
|
|
47
|
+
path: project.path,
|
|
48
|
+
...project.json
|
|
49
|
+
},
|
|
50
|
+
// dagNodeEdge: 0,
|
|
84
51
|
dependencyEdge: 0,
|
|
85
52
|
dependentEdge: 0,
|
|
86
53
|
checkedCircle: false,
|
|
@@ -88,7 +55,7 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
|
|
|
88
55
|
});
|
|
89
56
|
}
|
|
90
57
|
return subProjects;
|
|
91
|
-
}
|
|
58
|
+
};
|
|
92
59
|
const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
93
60
|
let projects = [];
|
|
94
61
|
if (Array.isArray(match)) {
|
|
@@ -104,9 +71,11 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
104
71
|
for (const project of projects) {
|
|
105
72
|
subProjects.push({
|
|
106
73
|
name: project.name,
|
|
107
|
-
extra:
|
|
108
|
-
path: project.path
|
|
109
|
-
|
|
74
|
+
extra: {
|
|
75
|
+
path: project.path,
|
|
76
|
+
...project.json
|
|
77
|
+
},
|
|
78
|
+
// dagNodeEdge: 0,
|
|
110
79
|
dependencyEdge: 0,
|
|
111
80
|
dependentEdge: 0,
|
|
112
81
|
checkedCircle: false,
|
|
@@ -130,12 +99,12 @@ const checkFindProjectsMode = (config) => {
|
|
|
130
99
|
}
|
|
131
100
|
errorLog("No `packagesMatchs` and `projectsConfig` configurations found");
|
|
132
101
|
};
|
|
133
|
-
const getProjects =
|
|
102
|
+
const getProjects = async (config, currentDir = process.cwd()) => {
|
|
134
103
|
const { rootPath } = getMonorepoBaseData(currentDir);
|
|
135
104
|
const mode = checkFindProjectsMode(config);
|
|
136
105
|
let projects = [];
|
|
137
106
|
if (mode === 0 /* Rough */) {
|
|
138
|
-
projects =
|
|
107
|
+
projects = await getProjectsByPackagesMatch(
|
|
139
108
|
rootPath,
|
|
140
109
|
config.packagesMatchs,
|
|
141
110
|
config.packagesIgnoreMatchs || []
|
|
@@ -144,7 +113,7 @@ const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (confi
|
|
|
144
113
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
145
114
|
}
|
|
146
115
|
return projects;
|
|
147
|
-
}
|
|
116
|
+
};
|
|
148
117
|
const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
149
118
|
const { rootPath } = getMonorepoBaseData(currentDir);
|
|
150
119
|
const mode = checkFindProjectsMode(config);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { fs, execa } from "@modern-js/utils";
|
|
3
|
+
import { LOCK_FILE } from "../constants";
|
|
4
|
+
const removeLockFile = (rootPath, packageManager) => {
|
|
5
|
+
if (packageManager === "pnpm") {
|
|
6
|
+
fs.removeSync(path.join(rootPath, LOCK_FILE.PNPM));
|
|
7
|
+
} else if (packageManager === "yarn") {
|
|
8
|
+
fs.removeSync(path.join(rootPath, LOCK_FILE.YARN));
|
|
9
|
+
} else if (packageManager === "npm") {
|
|
10
|
+
fs.removeSync(path.join(rootPath, LOCK_FILE.NPM));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const installByPackageManager = async (packageManager, { rootPath, removeLock }) => {
|
|
14
|
+
if (removeLock) {
|
|
15
|
+
removeLockFile(rootPath, packageManager);
|
|
16
|
+
}
|
|
17
|
+
if (packageManager === "pnpm") {
|
|
18
|
+
await execa("pnpm", ["install"], { stdio: "inherit" });
|
|
19
|
+
}
|
|
20
|
+
if (packageManager === "yarn") {
|
|
21
|
+
await execa("yarn", ["install"], { stdio: "inherit" });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
installByPackageManager,
|
|
26
|
+
removeLockFile
|
|
27
|
+
};
|
|
@@ -6,5 +6,5 @@ export declare class Package {
|
|
|
6
6
|
constructor(packageJson: INodePackageJson, packageConfigPath: string, rootPath: string);
|
|
7
7
|
get name(): string;
|
|
8
8
|
get path(): string;
|
|
9
|
-
get(key: keyof INodePackageJson): string | boolean | Record<string, string> | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").
|
|
9
|
+
get(key: keyof INodePackageJson): string | boolean | Record<string, string> | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").IPackageJsonScriptTable | import("@rushstack/node-core-library").IPackageJsonRepository | undefined;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.6.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
|
-
"main": "./dist/
|
|
17
|
+
"main": "./dist/cjs/index.js",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"node": {
|
|
21
21
|
"jsnext:source": "./src/index.ts",
|
|
22
|
-
"import": "./dist/
|
|
23
|
-
"require": "./dist/
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
24
24
|
},
|
|
25
|
-
"default": "./dist/
|
|
25
|
+
"default": "./dist/cjs/index.js"
|
|
26
26
|
},
|
|
27
27
|
"./cli": {
|
|
28
28
|
"jsnext:source": "./src/index.ts",
|
|
29
|
-
"default": "./dist/
|
|
29
|
+
"default": "./dist/cjs/index.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"bin": {
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"anymatch": "^3.1.2",
|
|
40
40
|
"md5": "^2.3.0",
|
|
41
41
|
"p-map": "^4.0.0",
|
|
42
|
-
"@modern-js/core": "2.
|
|
43
|
-
"@modern-js/new-action": "2.
|
|
44
|
-
"@modern-js/upgrade": "2.
|
|
45
|
-
"@modern-js/plugin": "2.
|
|
46
|
-
"@modern-js/plugin-changeset": "2.
|
|
47
|
-
"@modern-js/plugin-i18n": "2.
|
|
48
|
-
"@modern-js/plugin-lint": "2.
|
|
49
|
-
"@modern-js/utils": "2.
|
|
42
|
+
"@modern-js/core": "2.6.0",
|
|
43
|
+
"@modern-js/new-action": "2.6.0",
|
|
44
|
+
"@modern-js/upgrade": "2.6.0",
|
|
45
|
+
"@modern-js/plugin": "2.6.0",
|
|
46
|
+
"@modern-js/plugin-changeset": "2.6.0",
|
|
47
|
+
"@modern-js/plugin-i18n": "2.6.0",
|
|
48
|
+
"@modern-js/plugin-lint": "2.6.0",
|
|
49
|
+
"@modern-js/utils": "2.6.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/jest": "^27",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@types/node": "^14",
|
|
55
55
|
"jest": "^27",
|
|
56
56
|
"typescript": "^4",
|
|
57
|
-
"@scripts/build": "2.
|
|
58
|
-
"@scripts/jest-config": "2.
|
|
57
|
+
"@scripts/build": "2.6.0",
|
|
58
|
+
"@scripts/jest-config": "2.6.0"
|
|
59
59
|
},
|
|
60
60
|
"sideEffects": false,
|
|
61
61
|
"publishConfig": {
|
|
@@ -1,31 +0,0 @@
|
|
|
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 { buildWatch } from "../commands";
|
|
22
|
-
const buildWatchCli = (program, api) => {
|
|
23
|
-
program.command("build-watch [project]").usage("[options]").option("--only-self", "build target project with nothing").option("-i, --init", "init build beforebuild watch ").description("watch target project and target project’s dependencies").action(
|
|
24
|
-
(targetProjectName, option) => __async(void 0, null, function* () {
|
|
25
|
-
yield buildWatch(targetProjectName, option, api);
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
buildWatchCli
|
|
31
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
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 { build } from "../commands";
|
|
22
|
-
const buildCli = (program, api) => {
|
|
23
|
-
program.command("build [project]").usage("[options]").option("--no-self", "build without target project").option("-t, --dept", "build target project with project’s dependent").option("--no-deps", "build target project without project’s dependencies").option("--only-self", "build target project with nothing").option(
|
|
24
|
-
"-a, --all",
|
|
25
|
-
"build target project with project’s dependencies and dependent"
|
|
26
|
-
).option("--content-hash", "build target project use content hash cache").option("--git-hash", "build target project use git hash cache").description("build target project").action((targetProjectName, option) => __async(void 0, null, function* () {
|
|
27
|
-
yield build(targetProjectName, option, api);
|
|
28
|
-
}));
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
buildCli
|
|
32
|
-
};
|