@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,22 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
getProjectsByPackageConfig: () => getProjectsByPackageConfig,
|
|
27
|
+
syncGetProjectsByPackageConfig: () => syncGetProjectsByPackageConfig
|
|
5
28
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
30
|
+
var path = __toESM(require("path"));
|
|
31
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
32
|
+
var import_utils = require("@modern-js/utils");
|
|
33
|
+
var import_p_map = __toESM(require("p-map"));
|
|
34
|
+
var import_error = require("../log/error");
|
|
35
|
+
var import_package = require("../package");
|
|
36
|
+
var __defProp2 = Object.defineProperty;
|
|
37
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
38
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
39
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
40
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
41
|
+
var __spreadValues = (a, b) => {
|
|
42
|
+
for (var prop in b || (b = {}))
|
|
43
|
+
if (__hasOwnProp2.call(b, prop))
|
|
44
|
+
__defNormalProp(a, prop, b[prop]);
|
|
45
|
+
if (__getOwnPropSymbols)
|
|
46
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
47
|
+
if (__propIsEnum.call(b, prop))
|
|
48
|
+
__defNormalProp(a, prop, b[prop]);
|
|
49
|
+
}
|
|
50
|
+
return a;
|
|
51
|
+
};
|
|
52
|
+
var __async = (__this, __arguments, generator) => {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
var fulfilled = (value) => {
|
|
55
|
+
try {
|
|
56
|
+
step(generator.next(value));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var rejected = (value) => {
|
|
62
|
+
try {
|
|
63
|
+
step(generator.throw(value));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
reject(e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
69
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const normalize = (results) => results.map((fp) => path.normalize(fp));
|
|
20
73
|
const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
21
74
|
const globOpts = {
|
|
22
75
|
cwd: rootPath,
|
|
@@ -24,64 +77,61 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
24
77
|
expandDirectories: false,
|
|
25
78
|
followSymbolicLinks: false
|
|
26
79
|
};
|
|
27
|
-
if (packageConfigs.some(cfg => cfg.includes(
|
|
28
|
-
if (packageConfigs.some(cfg => cfg.includes(
|
|
29
|
-
(0,
|
|
80
|
+
if (packageConfigs.some((cfg) => cfg.includes("**"))) {
|
|
81
|
+
if (packageConfigs.some((cfg) => cfg.includes("node_modules"))) {
|
|
82
|
+
(0, import_error.errorLog)(
|
|
83
|
+
"An explicit node_modules package path does not allow globstars (**)"
|
|
84
|
+
);
|
|
30
85
|
}
|
|
31
86
|
globOpts.ignore = [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
87
|
+
"**/dist/**",
|
|
88
|
+
"**/node_modules/**",
|
|
89
|
+
...ignore || []
|
|
90
|
+
];
|
|
35
91
|
}
|
|
36
92
|
return globOpts;
|
|
37
93
|
};
|
|
38
94
|
const makeFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
39
95
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
40
|
-
return
|
|
41
|
-
const options =
|
|
42
|
-
const promise = (0,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// always flatten the results
|
|
55
|
-
const results = await promise;
|
|
96
|
+
return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (fileName, fileMapper, customGlobOpts = {}) {
|
|
97
|
+
const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
|
|
98
|
+
const promise = (0, import_p_map.default)(
|
|
99
|
+
Array.from(packageConfigs).sort(),
|
|
100
|
+
(globPath) => __async(void 0, null, function* () {
|
|
101
|
+
let result = yield (0, import_utils.globby)(path.posix.join(globPath, fileName), options);
|
|
102
|
+
result = result.sort();
|
|
103
|
+
result = normalize(result);
|
|
104
|
+
return fileMapper(result);
|
|
105
|
+
}),
|
|
106
|
+
{ concurrency: packageConfigs.length || Infinity }
|
|
107
|
+
);
|
|
108
|
+
const results = yield promise;
|
|
56
109
|
return results.reduce((acc, result) => acc.concat(result), []);
|
|
57
|
-
};
|
|
110
|
+
});
|
|
58
111
|
};
|
|
59
|
-
const getProjectsByPackageConfig =
|
|
112
|
+
const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) => __async(void 0, null, function* () {
|
|
60
113
|
const finder = makeFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
61
|
-
const fileName =
|
|
62
|
-
const mapper = packageConfigPath => {
|
|
63
|
-
const packageJsonLookup = new
|
|
64
|
-
loadExtraFields: true
|
|
65
|
-
});
|
|
114
|
+
const fileName = "package.json";
|
|
115
|
+
const mapper = (packageConfigPath) => {
|
|
116
|
+
const packageJsonLookup = new import_node_core_library.PackageJsonLookup({ loadExtraFields: true });
|
|
66
117
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
67
|
-
return new
|
|
118
|
+
return new import_package.Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
68
119
|
};
|
|
69
|
-
const projects =
|
|
70
|
-
|
|
71
|
-
|
|
120
|
+
const projects = yield finder(
|
|
121
|
+
fileName,
|
|
122
|
+
(filePaths) => (0, import_p_map.default)(filePaths, mapper, { concurrency: filePaths.length || Infinity }),
|
|
123
|
+
{}
|
|
124
|
+
);
|
|
72
125
|
return projects;
|
|
73
|
-
};
|
|
74
|
-
exports.getProjectsByPackageConfig = getProjectsByPackageConfig;
|
|
126
|
+
});
|
|
75
127
|
const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
76
128
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
77
129
|
return (fileName, fileMapper, customGlobOpts = {}) => {
|
|
78
130
|
const results = [];
|
|
79
|
-
const options =
|
|
131
|
+
const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
|
|
80
132
|
for (const globPath of Array.from(packageConfigs).sort()) {
|
|
81
|
-
let result =
|
|
82
|
-
// fast-glob does not respect pattern order, so we re-sort by absolute path
|
|
133
|
+
let result = import_utils.globby.sync(path.posix.join(globPath, fileName), options);
|
|
83
134
|
result = result.sort();
|
|
84
|
-
// POSIX results always need to be normalized
|
|
85
135
|
result = normalize(result);
|
|
86
136
|
results.push(fileMapper(result));
|
|
87
137
|
}
|
|
@@ -90,15 +140,16 @@ const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
|
90
140
|
};
|
|
91
141
|
const syncGetProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) => {
|
|
92
142
|
const finder = makeSyncFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
93
|
-
const fileName =
|
|
94
|
-
const mapper = packageConfigPath => {
|
|
95
|
-
const packageJsonLookup = new
|
|
96
|
-
loadExtraFields: true
|
|
97
|
-
});
|
|
143
|
+
const fileName = "package.json";
|
|
144
|
+
const mapper = (packageConfigPath) => {
|
|
145
|
+
const packageJsonLookup = new import_node_core_library.PackageJsonLookup({ loadExtraFields: true });
|
|
98
146
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
99
|
-
return new
|
|
147
|
+
return new import_package.Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
100
148
|
};
|
|
101
|
-
const projects = finder(
|
|
149
|
+
const projects = finder(
|
|
150
|
+
fileName,
|
|
151
|
+
(filePaths) => filePaths.map((filePath) => mapper(filePath)),
|
|
152
|
+
{}
|
|
153
|
+
);
|
|
102
154
|
return projects;
|
|
103
155
|
};
|
|
104
|
-
exports.syncGetProjectsByPackageConfig = syncGetProjectsByPackageConfig;
|
|
@@ -1,72 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
getProjectsByWorkspaceFile: () => getProjectsByWorkspaceFile,
|
|
27
|
+
syncGetProjectsByWorkspaceFile: () => syncGetProjectsByWorkspaceFile
|
|
5
28
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
30
|
+
var path = __toESM(require("path"));
|
|
31
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
32
|
+
var import_utils = require("@modern-js/utils");
|
|
33
|
+
var import_monorepo = require("../parse-config/monorepo");
|
|
34
|
+
var import_constants = require("../constants");
|
|
35
|
+
var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
|
|
36
|
+
var __async = (__this, __arguments, generator) => {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var fulfilled = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.next(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var rejected = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.throw(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const getProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => __async(void 0, null, function* () {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
let { workspaceFile } = config;
|
|
59
|
+
if (!config.enableAutoFinder && (!("workspaceFile" in config) || ((_a = config.workspaceFile) == null ? void 0 : _a.length) === 0)) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
"Missing workspaceFile Key or workspaceFile is empty string"
|
|
62
|
+
);
|
|
22
63
|
}
|
|
23
64
|
if (config.enableAutoFinder) {
|
|
24
|
-
workspaceFile = (0,
|
|
65
|
+
workspaceFile = (0, import_monorepo.getWorkspaceFile)(rootPath);
|
|
25
66
|
}
|
|
26
67
|
let packagesConfig = [];
|
|
27
|
-
if (workspaceFile ===
|
|
28
|
-
const yamlString =
|
|
29
|
-
|
|
68
|
+
if (workspaceFile === import_constants.WORKSPACE_FILE.PNPM) {
|
|
69
|
+
const yamlString = yield import_node_core_library.FileSystem.readFileAsync(
|
|
70
|
+
path.resolve("/", rootPath, workspaceFile)
|
|
71
|
+
).then((data) => data.toString());
|
|
72
|
+
const pnpmWorkspace = import_utils.yaml.load(yamlString);
|
|
30
73
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
31
|
-
} else if (workspaceFile ===
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const lernaJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
38
|
-
packagesConfig = (_lernaJson$packages = lernaJson.packages) !== null && _lernaJson$packages !== void 0 ? _lernaJson$packages : [];
|
|
74
|
+
} else if (workspaceFile === import_constants.WORKSPACE_FILE.YARN) {
|
|
75
|
+
const pkgJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
76
|
+
packagesConfig = ((_b = pkgJson == null ? void 0 : pkgJson.workspaces) == null ? void 0 : _b.packages) || [];
|
|
77
|
+
} else if (workspaceFile === import_constants.WORKSPACE_FILE.LERNA) {
|
|
78
|
+
const lernaJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
79
|
+
packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
|
|
39
80
|
}
|
|
40
|
-
const projects =
|
|
81
|
+
const projects = yield (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(
|
|
82
|
+
rootPath,
|
|
83
|
+
packagesConfig,
|
|
84
|
+
ignoreConfigs
|
|
85
|
+
);
|
|
41
86
|
return projects;
|
|
42
|
-
};
|
|
43
|
-
exports.getProjectsByWorkspaceFile = getProjectsByWorkspaceFile;
|
|
87
|
+
});
|
|
44
88
|
const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
|
|
45
|
-
var
|
|
46
|
-
let {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
89
|
+
var _a, _b, _c;
|
|
90
|
+
let { workspaceFile } = config;
|
|
91
|
+
if (!config.enableAutoFinder && (!("workspaceFile" in config) || ((_a = config.workspaceFile) == null ? void 0 : _a.length) === 0)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Missing workspaceFile Key or workspaceFile is empty string"
|
|
94
|
+
);
|
|
51
95
|
}
|
|
52
96
|
if (config.enableAutoFinder) {
|
|
53
|
-
workspaceFile = (0,
|
|
97
|
+
workspaceFile = (0, import_monorepo.getWorkspaceFile)(rootPath);
|
|
54
98
|
}
|
|
55
99
|
let packagesConfig = [];
|
|
56
|
-
if (workspaceFile ===
|
|
57
|
-
const yamlString =
|
|
58
|
-
|
|
100
|
+
if (workspaceFile === import_constants.WORKSPACE_FILE.PNPM) {
|
|
101
|
+
const yamlString = import_utils.fs.readFileSync(
|
|
102
|
+
path.resolve("/", rootPath, workspaceFile),
|
|
103
|
+
"utf-8"
|
|
104
|
+
);
|
|
105
|
+
const pnpmWorkspace = import_utils.yaml.load(yamlString);
|
|
59
106
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
60
|
-
} else if (workspaceFile ===
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const lernaJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
67
|
-
packagesConfig = (_lernaJson$packages2 = lernaJson.packages) !== null && _lernaJson$packages2 !== void 0 ? _lernaJson$packages2 : [];
|
|
107
|
+
} else if (workspaceFile === import_constants.WORKSPACE_FILE.YARN) {
|
|
108
|
+
const pkgJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
109
|
+
packagesConfig = ((_b = pkgJson == null ? void 0 : pkgJson.workspaces) == null ? void 0 : _b.packages) || [];
|
|
110
|
+
} else if (workspaceFile === import_constants.WORKSPACE_FILE.LERNA) {
|
|
111
|
+
const lernaJson = import_node_core_library.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
112
|
+
packagesConfig = (_c = lernaJson.packages) != null ? _c : [];
|
|
68
113
|
}
|
|
69
|
-
const projects = (0,
|
|
114
|
+
const projects = (0, import_get_projects_by_packages_config.syncGetProjectsByPackageConfig)(
|
|
115
|
+
rootPath,
|
|
116
|
+
packagesConfig,
|
|
117
|
+
ignoreConfigs
|
|
118
|
+
);
|
|
70
119
|
return projects;
|
|
71
120
|
};
|
|
72
|
-
exports.syncGetProjectsByWorkspaceFile = syncGetProjectsByWorkspaceFile;
|
|
@@ -1,30 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
getProjects: () => getProjects,
|
|
21
|
+
syncGetProjects: () => syncGetProjects
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
24
|
+
var import_error = require("../log/error");
|
|
25
|
+
var import_monorepo = require("../parse-config/monorepo");
|
|
26
|
+
var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
|
|
27
|
+
var import_get_projects_by_workspace_file = require("./get-projects-by-workspace-file");
|
|
28
|
+
var __defProp2 = Object.defineProperty;
|
|
29
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
30
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
31
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
32
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
33
|
+
var __spreadValues = (a, b) => {
|
|
34
|
+
for (var prop in b || (b = {}))
|
|
35
|
+
if (__hasOwnProp2.call(b, prop))
|
|
36
|
+
__defNormalProp(a, prop, b[prop]);
|
|
37
|
+
if (__getOwnPropSymbols)
|
|
38
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
39
|
+
if (__propIsEnum.call(b, prop))
|
|
40
|
+
__defNormalProp(a, prop, b[prop]);
|
|
41
|
+
}
|
|
42
|
+
return a;
|
|
43
|
+
};
|
|
44
|
+
var __async = (__this, __arguments, generator) => {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
var fulfilled = (value) => {
|
|
47
|
+
try {
|
|
48
|
+
step(generator.next(value));
|
|
49
|
+
} catch (e) {
|
|
50
|
+
reject(e);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var rejected = (value) => {
|
|
54
|
+
try {
|
|
55
|
+
step(generator.throw(value));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
reject(e);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
61
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var FindProjectsMode = /* @__PURE__ */ ((FindProjectsMode2) => {
|
|
65
|
+
FindProjectsMode2[FindProjectsMode2["Rough"] = 0] = "Rough";
|
|
66
|
+
FindProjectsMode2[FindProjectsMode2["Precise"] = 1] = "Precise";
|
|
67
|
+
return FindProjectsMode2;
|
|
68
|
+
})(FindProjectsMode || {});
|
|
19
69
|
const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
20
70
|
const subProjects = [];
|
|
21
71
|
for (const config of configs) {
|
|
22
72
|
subProjects.push({
|
|
23
73
|
name: config.name,
|
|
24
|
-
extra: {
|
|
25
|
-
path: config.path
|
|
26
|
-
},
|
|
27
|
-
// dagNodeEdge: 0,
|
|
74
|
+
extra: { path: config.path },
|
|
28
75
|
dependencyEdge: 0,
|
|
29
76
|
dependentEdge: 0,
|
|
30
77
|
checkedCircle: false,
|
|
@@ -33,23 +80,24 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
33
80
|
}
|
|
34
81
|
return subProjects;
|
|
35
82
|
};
|
|
36
|
-
const getProjectsByPackagesMatch =
|
|
83
|
+
const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0, null, function* () {
|
|
37
84
|
let projects = [];
|
|
38
85
|
if (Array.isArray(match)) {
|
|
39
|
-
|
|
40
|
-
projects = await (0, _getProjectsByPackagesConfig.getProjectsByPackageConfig)(rootPath, match, ignore);
|
|
86
|
+
projects = yield (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(rootPath, match, ignore);
|
|
41
87
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
projects = yield (0, import_get_projects_by_workspace_file.getProjectsByWorkspaceFile)(
|
|
89
|
+
rootPath,
|
|
90
|
+
match,
|
|
91
|
+
ignore
|
|
92
|
+
);
|
|
44
93
|
}
|
|
45
94
|
const subProjects = [];
|
|
46
95
|
for (const project of projects) {
|
|
47
96
|
subProjects.push({
|
|
48
97
|
name: project.name,
|
|
49
|
-
extra:
|
|
98
|
+
extra: __spreadValues({
|
|
50
99
|
path: project.path
|
|
51
100
|
}, project.json),
|
|
52
|
-
// dagNodeEdge: 0,
|
|
53
101
|
dependencyEdge: 0,
|
|
54
102
|
dependentEdge: 0,
|
|
55
103
|
checkedCircle: false,
|
|
@@ -57,25 +105,25 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
57
105
|
});
|
|
58
106
|
}
|
|
59
107
|
return subProjects;
|
|
60
|
-
};
|
|
108
|
+
});
|
|
61
109
|
const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
62
110
|
let projects = [];
|
|
63
|
-
// TODO: code start
|
|
64
111
|
if (Array.isArray(match)) {
|
|
65
|
-
|
|
66
|
-
projects = (0, _getProjectsByPackagesConfig.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
|
|
112
|
+
projects = (0, import_get_projects_by_packages_config.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
|
|
67
113
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
114
|
+
projects = (0, import_get_projects_by_workspace_file.syncGetProjectsByWorkspaceFile)(
|
|
115
|
+
rootPath,
|
|
116
|
+
match,
|
|
117
|
+
ignore
|
|
118
|
+
);
|
|
70
119
|
}
|
|
71
120
|
const subProjects = [];
|
|
72
121
|
for (const project of projects) {
|
|
73
122
|
subProjects.push({
|
|
74
123
|
name: project.name,
|
|
75
|
-
extra:
|
|
124
|
+
extra: __spreadValues({
|
|
76
125
|
path: project.path
|
|
77
126
|
}, project.json),
|
|
78
|
-
// dagNodeEdge: 0,
|
|
79
127
|
dependencyEdge: 0,
|
|
80
128
|
dependentEdge: 0,
|
|
81
129
|
checkedCircle: false,
|
|
@@ -84,48 +132,48 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
84
132
|
}
|
|
85
133
|
return subProjects;
|
|
86
134
|
};
|
|
87
|
-
const checkFindProjectsMode = (config
|
|
88
|
-
// eslint-disable-next-line consistent-return
|
|
89
|
-
) => {
|
|
135
|
+
const checkFindProjectsMode = (config) => {
|
|
90
136
|
if (config.packagesMatchs && Array.isArray(config.packagesMatchs)) {
|
|
91
|
-
return
|
|
137
|
+
return 0;
|
|
92
138
|
}
|
|
93
|
-
if (config.packagesMatchs && typeof config.packagesMatchs ===
|
|
94
|
-
return
|
|
139
|
+
if (config.packagesMatchs && typeof config.packagesMatchs === "object" && (config.packagesMatchs.workspaceFile || config.packagesMatchs.enableAutoFinder)) {
|
|
140
|
+
return 0;
|
|
95
141
|
}
|
|
96
142
|
if (config.projectsConfig && Array.isArray(config.projectsConfig)) {
|
|
97
|
-
return
|
|
143
|
+
return 1;
|
|
98
144
|
}
|
|
99
145
|
if (config.projectsConfig && config.packagesMatchs) {
|
|
100
|
-
(0,
|
|
146
|
+
(0, import_error.errorLog)("There can not be both `packagesMatchs` and `projectsConfig`");
|
|
101
147
|
}
|
|
102
|
-
(0,
|
|
148
|
+
(0, import_error.errorLog)("No `packagesMatchs` and `projectsConfig` configurations found");
|
|
103
149
|
};
|
|
104
|
-
const getProjects =
|
|
105
|
-
const {
|
|
106
|
-
rootPath
|
|
107
|
-
} = (0, _monorepo.getMonorepoBaseData)(currentDir);
|
|
150
|
+
const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (config, currentDir = process.cwd()) {
|
|
151
|
+
const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
|
|
108
152
|
const mode = checkFindProjectsMode(config);
|
|
109
153
|
let projects = [];
|
|
110
|
-
if (mode ===
|
|
111
|
-
projects =
|
|
112
|
-
|
|
154
|
+
if (mode === 0) {
|
|
155
|
+
projects = yield getProjectsByPackagesMatch(
|
|
156
|
+
rootPath,
|
|
157
|
+
config.packagesMatchs,
|
|
158
|
+
config.packagesIgnoreMatchs || []
|
|
159
|
+
);
|
|
160
|
+
} else if (mode === 1) {
|
|
113
161
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
114
162
|
}
|
|
115
163
|
return projects;
|
|
116
|
-
};
|
|
117
|
-
exports.getProjects = getProjects;
|
|
164
|
+
});
|
|
118
165
|
const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
119
|
-
const {
|
|
120
|
-
rootPath
|
|
121
|
-
} = (0, _monorepo.getMonorepoBaseData)(currentDir);
|
|
166
|
+
const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
|
|
122
167
|
const mode = checkFindProjectsMode(config);
|
|
123
168
|
let projects = [];
|
|
124
|
-
if (mode ===
|
|
125
|
-
projects = syncGetProjectsByPackagesMatch(
|
|
126
|
-
|
|
169
|
+
if (mode === 0) {
|
|
170
|
+
projects = syncGetProjectsByPackagesMatch(
|
|
171
|
+
rootPath,
|
|
172
|
+
config.packagesMatchs,
|
|
173
|
+
config.packagesIgnoreMatchs || []
|
|
174
|
+
);
|
|
175
|
+
} else if (mode === 1) {
|
|
127
176
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
128
177
|
}
|
|
129
178
|
return projects;
|
|
130
179
|
};
|
|
131
|
-
exports.syncGetProjects = syncGetProjects;
|