@modern-js/monorepo-tools 2.4.0 → 2.5.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 +24 -0
- 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/{js/node → cjs}/cli/index.js +0 -0
- 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 +8 -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/index.js +0 -0
- package/dist/{js/node → cjs}/commands/install.js +4 -24
- package/dist/{js/node → cjs}/constants.js +0 -0
- package/dist/{js/node → cjs}/dag/create.js +5 -15
- package/dist/{js/node → cjs}/dag/edge-manager.js +0 -0
- package/dist/{js/node → cjs}/dag/index.js +0 -0
- package/dist/cjs/dag/operator.js +232 -0
- package/dist/{js/node → cjs}/dag/task.js +29 -53
- package/dist/{js/node → cjs}/dag/utils.js +0 -0
- package/dist/{js/node → cjs}/features/build/index.js +13 -33
- package/dist/{js/node → cjs}/features/clear/index.js +0 -0
- package/dist/{js/node → cjs}/features/deploy/index.js +10 -30
- package/dist/{js/node → cjs}/features/dev/cmds.js +0 -0
- package/dist/{js/node → cjs}/features/dev/create-task.js +6 -26
- package/dist/{js/node → cjs}/features/dev/index.js +14 -34
- package/dist/{js/node → cjs}/features/dev/watch-projects-state.js +3 -19
- package/dist/{js/node → cjs}/features/install/index.js +3 -23
- package/dist/{js/node → cjs}/hooks/index.js +0 -0
- package/dist/{js/node → cjs}/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/time.js +1 -15
- 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}/parse-config/index.js +4 -38
- package/dist/{js/node → cjs}/parse-config/monorepo.js +0 -0
- package/dist/{js/node → cjs}/projects/check-project-change.js +12 -32
- package/dist/{js/node → cjs}/projects/clear-memory-files.js +0 -0
- package/dist/{js/node → cjs}/projects/get-projects-by-packages-config.js +11 -45
- package/dist/{js/node → cjs}/projects/get-projects-by-workspace-file.js +4 -24
- package/dist/{js/node → cjs}/projects/get-projects.js +15 -47
- package/dist/{js/node → cjs}/type.js +0 -0
- package/dist/{js/node → cjs}/utils/install.js +4 -24
- package/dist/{js/node → cjs}/utils/language.js +0 -0
- package/dist/{js/node → cjs}/utils/types.js +0 -0
- 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/{js/modern → esm}/cli/index.js +0 -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 +55 -0
- package/dist/esm/commands/clear.js +19 -0
- package/dist/{js/modern → esm}/commands/deploy.js +4 -24
- package/dist/{js/modern → esm}/commands/index.js +0 -0
- package/dist/esm/commands/install.js +23 -0
- package/dist/{js/modern → esm}/constants.js +0 -0
- package/dist/{js/modern → esm}/dag/create.js +5 -17
- package/dist/{js/modern → esm}/dag/edge-manager.js +0 -0
- package/dist/{js/modern → esm}/dag/index.js +0 -0
- package/dist/esm/dag/operator.js +203 -0
- package/dist/esm/dag/task.js +55 -0
- package/dist/{js/modern → esm}/dag/utils.js +0 -0
- package/dist/{js/modern → esm}/features/build/index.js +13 -33
- package/dist/{js/modern → esm}/features/clear/index.js +0 -0
- package/dist/{js/modern → esm}/features/deploy/index.js +10 -30
- package/dist/{js/modern → esm}/features/dev/cmds.js +0 -0
- 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/{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/esm/log/time.js +13 -0
- package/dist/{js/modern → esm}/log/utils.js +0 -0
- package/dist/{js/modern → esm}/package/index.js +0 -0
- package/dist/esm/parse-config/index.js +15 -0
- package/dist/{js/modern → esm}/parse-config/monorepo.js +0 -0
- package/dist/{js/modern → esm}/projects/check-project-change.js +12 -32
- package/dist/{js/modern → esm}/projects/clear-memory-files.js +0 -0
- package/dist/{js/modern → esm}/projects/get-projects-by-packages-config.js +11 -47
- package/dist/{js/modern → esm}/projects/get-projects-by-workspace-file.js +4 -24
- package/dist/{js/modern → esm}/projects/get-projects.js +15 -49
- package/dist/{js/modern → esm}/type.js +0 -0
- package/dist/esm/utils/install.js +27 -0
- package/dist/{js/modern → esm}/utils/language.js +0 -0
- package/dist/{js/modern → esm}/utils/types.js +0 -0
- 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
|
@@ -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
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { JsonFile } from "@rushstack/node-core-library";
|
|
3
|
+
import { getMonorepoBaseData } from "./monorepo";
|
|
4
|
+
const defaultConfig = {};
|
|
5
|
+
const getFinalConfig = async (currentPath = process.cwd()) => {
|
|
6
|
+
const monorepo = getMonorepoBaseData(currentPath);
|
|
7
|
+
const userConfig = await JsonFile.loadAsync(
|
|
8
|
+
path.resolve(monorepo.rootPath, "mono-config.json")
|
|
9
|
+
);
|
|
10
|
+
const config = { ...defaultConfig, ...userConfig };
|
|
11
|
+
return { monorepo, config };
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getFinalConfig
|
|
15
|
+
};
|
|
File without changes
|
|
@@ -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,
|
|
File without changes
|
|
@@ -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";
|
|
@@ -64,23 +28,23 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
64
28
|
};
|
|
65
29
|
const makeFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
66
30
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
67
|
-
return
|
|
68
|
-
const options =
|
|
31
|
+
return async (fileName, fileMapper, customGlobOpts = {}) => {
|
|
32
|
+
const options = { ...customGlobOpts, ...globOpts };
|
|
69
33
|
const promise = pMap(
|
|
70
34
|
Array.from(packageConfigs).sort(),
|
|
71
|
-
(globPath) =>
|
|
72
|
-
let result =
|
|
35
|
+
async (globPath) => {
|
|
36
|
+
let result = await globby(path.posix.join(globPath, fileName), options);
|
|
73
37
|
result = result.sort();
|
|
74
38
|
result = normalize(result);
|
|
75
39
|
return fileMapper(result);
|
|
76
|
-
}
|
|
40
|
+
},
|
|
77
41
|
{ concurrency: packageConfigs.length || Infinity }
|
|
78
42
|
);
|
|
79
|
-
const results =
|
|
43
|
+
const results = await promise;
|
|
80
44
|
return results.reduce((acc, result) => acc.concat(result), []);
|
|
81
|
-
}
|
|
45
|
+
};
|
|
82
46
|
};
|
|
83
|
-
const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) =>
|
|
47
|
+
const getProjectsByPackageConfig = async (rootPath, packagesConfig, ignoreConfigs) => {
|
|
84
48
|
const finder = makeFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
85
49
|
const fileName = "package.json";
|
|
86
50
|
const mapper = (packageConfigPath) => {
|
|
@@ -88,18 +52,18 @@ const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) =>
|
|
|
88
52
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
89
53
|
return new Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
90
54
|
};
|
|
91
|
-
const projects =
|
|
55
|
+
const projects = await finder(
|
|
92
56
|
fileName,
|
|
93
57
|
(filePaths) => pMap(filePaths, mapper, { concurrency: filePaths.length || Infinity }),
|
|
94
58
|
{}
|
|
95
59
|
);
|
|
96
60
|
return projects;
|
|
97
|
-
}
|
|
61
|
+
};
|
|
98
62
|
const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
99
63
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
100
64
|
return (fileName, fileMapper, customGlobOpts = {}) => {
|
|
101
65
|
const results = [];
|
|
102
|
-
const options =
|
|
66
|
+
const options = { ...customGlobOpts, ...globOpts };
|
|
103
67
|
for (const globPath of Array.from(packageConfigs).sort()) {
|
|
104
68
|
let result = globby.sync(path.posix.join(globPath, fileName), options);
|
|
105
69
|
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 {
|
|
@@ -63,12 +27,12 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
63
27
|
}
|
|
64
28
|
return subProjects;
|
|
65
29
|
};
|
|
66
|
-
const getProjectsByPackagesMatch = (rootPath, match, ignore) =>
|
|
30
|
+
const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
67
31
|
let projects = [];
|
|
68
32
|
if (Array.isArray(match)) {
|
|
69
|
-
projects =
|
|
33
|
+
projects = await getProjectsByPackageConfig(rootPath, match, ignore);
|
|
70
34
|
} else {
|
|
71
|
-
projects =
|
|
35
|
+
projects = await getProjectsByWorkspaceFile(
|
|
72
36
|
rootPath,
|
|
73
37
|
match,
|
|
74
38
|
ignore
|
|
@@ -78,9 +42,10 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
|
|
|
78
42
|
for (const project of projects) {
|
|
79
43
|
subProjects.push({
|
|
80
44
|
name: project.name,
|
|
81
|
-
extra:
|
|
82
|
-
path: project.path
|
|
83
|
-
|
|
45
|
+
extra: {
|
|
46
|
+
path: project.path,
|
|
47
|
+
...project.json
|
|
48
|
+
},
|
|
84
49
|
dependencyEdge: 0,
|
|
85
50
|
dependentEdge: 0,
|
|
86
51
|
checkedCircle: false,
|
|
@@ -88,7 +53,7 @@ const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0,
|
|
|
88
53
|
});
|
|
89
54
|
}
|
|
90
55
|
return subProjects;
|
|
91
|
-
}
|
|
56
|
+
};
|
|
92
57
|
const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
93
58
|
let projects = [];
|
|
94
59
|
if (Array.isArray(match)) {
|
|
@@ -104,9 +69,10 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
104
69
|
for (const project of projects) {
|
|
105
70
|
subProjects.push({
|
|
106
71
|
name: project.name,
|
|
107
|
-
extra:
|
|
108
|
-
path: project.path
|
|
109
|
-
|
|
72
|
+
extra: {
|
|
73
|
+
path: project.path,
|
|
74
|
+
...project.json
|
|
75
|
+
},
|
|
110
76
|
dependencyEdge: 0,
|
|
111
77
|
dependentEdge: 0,
|
|
112
78
|
checkedCircle: false,
|
|
@@ -130,12 +96,12 @@ const checkFindProjectsMode = (config) => {
|
|
|
130
96
|
}
|
|
131
97
|
errorLog("No `packagesMatchs` and `projectsConfig` configurations found");
|
|
132
98
|
};
|
|
133
|
-
const getProjects =
|
|
99
|
+
const getProjects = async (config, currentDir = process.cwd()) => {
|
|
134
100
|
const { rootPath } = getMonorepoBaseData(currentDir);
|
|
135
101
|
const mode = checkFindProjectsMode(config);
|
|
136
102
|
let projects = [];
|
|
137
103
|
if (mode === 0 /* Rough */) {
|
|
138
|
-
projects =
|
|
104
|
+
projects = await getProjectsByPackagesMatch(
|
|
139
105
|
rootPath,
|
|
140
106
|
config.packagesMatchs,
|
|
141
107
|
config.packagesIgnoreMatchs || []
|
|
@@ -144,7 +110,7 @@ const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (confi
|
|
|
144
110
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
145
111
|
}
|
|
146
112
|
return projects;
|
|
147
|
-
}
|
|
113
|
+
};
|
|
148
114
|
const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
149
115
|
const { rootPath } = getMonorepoBaseData(currentDir);
|
|
150
116
|
const mode = checkFindProjectsMode(config);
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.5.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.5.0",
|
|
43
|
+
"@modern-js/new-action": "2.5.0",
|
|
44
|
+
"@modern-js/upgrade": "2.5.0",
|
|
45
|
+
"@modern-js/plugin": "2.5.0",
|
|
46
|
+
"@modern-js/plugin-changeset": "2.5.0",
|
|
47
|
+
"@modern-js/plugin-i18n": "2.5.0",
|
|
48
|
+
"@modern-js/plugin-lint": "2.5.0",
|
|
49
|
+
"@modern-js/utils": "2.5.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/
|
|
58
|
-
"@scripts/
|
|
57
|
+
"@scripts/build": "2.5.0",
|
|
58
|
+
"@scripts/jest-config": "2.5.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
|
-
};
|
|
@@ -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 { clear } from "../commands";
|
|
22
|
-
const clearCli = (program, api) => {
|
|
23
|
-
program.command("clear [projects...]").usage("[options]").option("--remove-dirs [dirs...]", "remove dirs, default is node_modules").description("clear project dirs").action(
|
|
24
|
-
(targetProjectNames, option) => __async(void 0, null, function* () {
|
|
25
|
-
yield clear(targetProjectNames, option, api);
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
clearCli
|
|
31
|
-
};
|