@modern-js/monorepo-tools 2.0.0-beta.3 → 2.0.0-beta.6
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 +103 -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 +51 -10
- package/dist/js/node/cli/build.js +52 -10
- package/dist/js/node/cli/clear.js +51 -10
- package/dist/js/node/cli/deploy.js +56 -12
- package/dist/js/node/cli/index.js +22 -71
- package/dist/js/node/cli/install.js +51 -10
- package/dist/js/node/cli/new.js +75 -19
- package/dist/js/node/commands/build-watch.js +59 -29
- package/dist/js/node/commands/build.js +74 -32
- package/dist/js/node/commands/clear.js +57 -25
- package/dist/js/node/commands/deploy.js +65 -35
- package/dist/js/node/commands/index.js +21 -60
- package/dist/js/node/commands/install.js +59 -28
- package/dist/js/node/constants.js +33 -13
- package/dist/js/node/dag/create.js +46 -28
- package/dist/js/node/dag/edge-manager.js +25 -8
- package/dist/js/node/dag/index.js +30 -13
- package/dist/js/node/dag/operator.js +211 -174
- package/dist/js/node/dag/task.js +92 -46
- package/dist/js/node/dag/utils.js +58 -47
- package/dist/js/node/features/build/index.js +84 -47
- package/dist/js/node/features/clear/index.js +49 -28
- package/dist/js/node/features/deploy/index.js +139 -104
- package/dist/js/node/features/dev/cmds.js +26 -9
- package/dist/js/node/features/dev/create-task.js +80 -51
- package/dist/js/node/features/dev/index.js +98 -58
- package/dist/js/node/features/dev/watch-projects-state.js +71 -30
- package/dist/js/node/features/install/index.js +82 -41
- package/dist/js/node/hooks/index.js +27 -8
- package/dist/js/node/index.js +53 -32
- package/dist/js/node/locale/en.js +30 -11
- package/dist/js/node/locale/index.js +31 -14
- package/dist/js/node/locale/zh.js +31 -12
- package/dist/js/node/log/error.js +26 -7
- package/dist/js/node/log/multi-tasks-log.js +48 -41
- package/dist/js/node/log/time.js +47 -18
- package/dist/js/node/log/utils.js +30 -10
- package/dist/js/node/package/index.js +25 -10
- package/dist/js/node/parse-config/index.js +76 -31
- package/dist/js/node/parse-config/monorepo.js +79 -44
- package/dist/js/node/projects/check-project-change.js +104 -56
- package/dist/js/node/projects/clear-memory-files.js +42 -15
- package/dist/js/node/projects/get-projects-by-packages-config.js +119 -65
- package/dist/js/node/projects/get-projects-by-workspace-file.js +108 -55
- package/dist/js/node/projects/get-projects.js +112 -61
- package/dist/js/node/type.js +15 -5
- package/dist/js/node/utils/install.js +68 -31
- package/dist/js/node/utils/language.js +28 -8
- package/dist/js/node/utils/types.js +15 -0
- 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,73 @@
|
|
|
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var __async = (__this, __arguments, generator) => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
var fulfilled = (value) => {
|
|
41
|
+
try {
|
|
42
|
+
step(generator.next(value));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
reject(e);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var rejected = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.throw(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
55
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var get_projects_by_packages_config_exports = {};
|
|
59
|
+
__export(get_projects_by_packages_config_exports, {
|
|
60
|
+
getProjectsByPackageConfig: () => getProjectsByPackageConfig,
|
|
61
|
+
syncGetProjectsByPackageConfig: () => syncGetProjectsByPackageConfig
|
|
5
62
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
const normalize = results => results.map(fp => path.normalize(fp));
|
|
63
|
+
module.exports = __toCommonJS(get_projects_by_packages_config_exports);
|
|
64
|
+
var path = __toESM(require("path"));
|
|
65
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
66
|
+
var import_utils = require("@modern-js/utils");
|
|
67
|
+
var import_p_map = __toESM(require("p-map"));
|
|
68
|
+
var import_error = require("../log/error");
|
|
69
|
+
var import_package = require("../package");
|
|
70
|
+
const normalize = (results) => results.map((fp) => path.normalize(fp));
|
|
20
71
|
const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
21
72
|
const globOpts = {
|
|
22
73
|
cwd: rootPath,
|
|
@@ -24,64 +75,61 @@ const getGlobOpts = (rootPath, packageConfigs, ignore = []) => {
|
|
|
24
75
|
expandDirectories: false,
|
|
25
76
|
followSymbolicLinks: false
|
|
26
77
|
};
|
|
27
|
-
if (packageConfigs.some(cfg => cfg.includes(
|
|
28
|
-
if (packageConfigs.some(cfg => cfg.includes(
|
|
29
|
-
(0,
|
|
78
|
+
if (packageConfigs.some((cfg) => cfg.includes("**"))) {
|
|
79
|
+
if (packageConfigs.some((cfg) => cfg.includes("node_modules"))) {
|
|
80
|
+
(0, import_error.errorLog)(
|
|
81
|
+
"An explicit node_modules package path does not allow globstars (**)"
|
|
82
|
+
);
|
|
30
83
|
}
|
|
31
84
|
globOpts.ignore = [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
85
|
+
"**/dist/**",
|
|
86
|
+
"**/node_modules/**",
|
|
87
|
+
...ignore || []
|
|
88
|
+
];
|
|
35
89
|
}
|
|
36
90
|
return globOpts;
|
|
37
91
|
};
|
|
38
92
|
const makeFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
39
93
|
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;
|
|
94
|
+
return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (fileName, fileMapper, customGlobOpts = {}) {
|
|
95
|
+
const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
|
|
96
|
+
const promise = (0, import_p_map.default)(
|
|
97
|
+
Array.from(packageConfigs).sort(),
|
|
98
|
+
(globPath) => __async(void 0, null, function* () {
|
|
99
|
+
let result = yield (0, import_utils.globby)(path.posix.join(globPath, fileName), options);
|
|
100
|
+
result = result.sort();
|
|
101
|
+
result = normalize(result);
|
|
102
|
+
return fileMapper(result);
|
|
103
|
+
}),
|
|
104
|
+
{ concurrency: packageConfigs.length || Infinity }
|
|
105
|
+
);
|
|
106
|
+
const results = yield promise;
|
|
56
107
|
return results.reduce((acc, result) => acc.concat(result), []);
|
|
57
|
-
};
|
|
108
|
+
});
|
|
58
109
|
};
|
|
59
|
-
const getProjectsByPackageConfig =
|
|
110
|
+
const getProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) => __async(void 0, null, function* () {
|
|
60
111
|
const finder = makeFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
61
|
-
const fileName =
|
|
62
|
-
const mapper = packageConfigPath => {
|
|
63
|
-
const packageJsonLookup = new
|
|
64
|
-
loadExtraFields: true
|
|
65
|
-
});
|
|
112
|
+
const fileName = "package.json";
|
|
113
|
+
const mapper = (packageConfigPath) => {
|
|
114
|
+
const packageJsonLookup = new import_node_core_library.PackageJsonLookup({ loadExtraFields: true });
|
|
66
115
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
67
|
-
return new
|
|
116
|
+
return new import_package.Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
68
117
|
};
|
|
69
|
-
const projects =
|
|
70
|
-
|
|
71
|
-
|
|
118
|
+
const projects = yield finder(
|
|
119
|
+
fileName,
|
|
120
|
+
(filePaths) => (0, import_p_map.default)(filePaths, mapper, { concurrency: filePaths.length || Infinity }),
|
|
121
|
+
{}
|
|
122
|
+
);
|
|
72
123
|
return projects;
|
|
73
|
-
};
|
|
74
|
-
exports.getProjectsByPackageConfig = getProjectsByPackageConfig;
|
|
124
|
+
});
|
|
75
125
|
const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
76
126
|
const globOpts = getGlobOpts(rootPath, packageConfigs, ignoreConfigs);
|
|
77
127
|
return (fileName, fileMapper, customGlobOpts = {}) => {
|
|
78
128
|
const results = [];
|
|
79
|
-
const options =
|
|
129
|
+
const options = __spreadValues(__spreadValues({}, customGlobOpts), globOpts);
|
|
80
130
|
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
|
|
131
|
+
let result = import_utils.globby.sync(path.posix.join(globPath, fileName), options);
|
|
83
132
|
result = result.sort();
|
|
84
|
-
// POSIX results always need to be normalized
|
|
85
133
|
result = normalize(result);
|
|
86
134
|
results.push(fileMapper(result));
|
|
87
135
|
}
|
|
@@ -90,15 +138,21 @@ const makeSyncFileFinder = (rootPath, packageConfigs, ignoreConfigs = []) => {
|
|
|
90
138
|
};
|
|
91
139
|
const syncGetProjectsByPackageConfig = (rootPath, packagesConfig, ignoreConfigs) => {
|
|
92
140
|
const finder = makeSyncFileFinder(rootPath, packagesConfig, ignoreConfigs);
|
|
93
|
-
const fileName =
|
|
94
|
-
const mapper = packageConfigPath => {
|
|
95
|
-
const packageJsonLookup = new
|
|
96
|
-
loadExtraFields: true
|
|
97
|
-
});
|
|
141
|
+
const fileName = "package.json";
|
|
142
|
+
const mapper = (packageConfigPath) => {
|
|
143
|
+
const packageJsonLookup = new import_node_core_library.PackageJsonLookup({ loadExtraFields: true });
|
|
98
144
|
const packageJson = packageJsonLookup.loadNodePackageJson(packageConfigPath);
|
|
99
|
-
return new
|
|
145
|
+
return new import_package.Package(packageJson, path.dirname(packageConfigPath), rootPath);
|
|
100
146
|
};
|
|
101
|
-
const projects = finder(
|
|
147
|
+
const projects = finder(
|
|
148
|
+
fileName,
|
|
149
|
+
(filePaths) => filePaths.map((filePath) => mapper(filePath)),
|
|
150
|
+
{}
|
|
151
|
+
);
|
|
102
152
|
return projects;
|
|
103
153
|
};
|
|
104
|
-
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
getProjectsByPackageConfig,
|
|
157
|
+
syncGetProjectsByPackageConfig
|
|
158
|
+
});
|
|
@@ -1,72 +1,125 @@
|
|
|
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 __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var get_projects_by_workspace_file_exports = {};
|
|
45
|
+
__export(get_projects_by_workspace_file_exports, {
|
|
46
|
+
getProjectsByWorkspaceFile: () => getProjectsByWorkspaceFile,
|
|
47
|
+
syncGetProjectsByWorkspaceFile: () => syncGetProjectsByWorkspaceFile
|
|
5
48
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!config.enableAutoFinder && (!('workspaceFile' in config) || ((_config$workspaceFile = config.workspaceFile) === null || _config$workspaceFile === void 0 ? void 0 : _config$workspaceFile.length) === 0)) {
|
|
21
|
-
throw new Error('Missing workspaceFile Key or workspaceFile is empty string');
|
|
49
|
+
module.exports = __toCommonJS(get_projects_by_workspace_file_exports);
|
|
50
|
+
var path = __toESM(require("path"));
|
|
51
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
52
|
+
var import_utils = require("@modern-js/utils");
|
|
53
|
+
var import_monorepo = require("../parse-config/monorepo");
|
|
54
|
+
var import_constants = require("../constants");
|
|
55
|
+
var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
|
|
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
|
-
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
getProjectsByWorkspaceFile,
|
|
124
|
+
syncGetProjectsByWorkspaceFile
|
|
125
|
+
});
|
|
@@ -1,30 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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 __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var get_projects_exports = {};
|
|
53
|
+
__export(get_projects_exports, {
|
|
54
|
+
getProjects: () => getProjects,
|
|
55
|
+
syncGetProjects: () => syncGetProjects
|
|
5
56
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
FindProjectsMode[FindProjectsMode["Rough"] = 0] = "Rough";
|
|
17
|
-
FindProjectsMode[FindProjectsMode["Precise"] = 1] = "Precise";
|
|
18
|
-
})(FindProjectsMode || (FindProjectsMode = {}));
|
|
57
|
+
module.exports = __toCommonJS(get_projects_exports);
|
|
58
|
+
var import_error = require("../log/error");
|
|
59
|
+
var import_monorepo = require("../parse-config/monorepo");
|
|
60
|
+
var import_get_projects_by_packages_config = require("./get-projects-by-packages-config");
|
|
61
|
+
var import_get_projects_by_workspace_file = require("./get-projects-by-workspace-file");
|
|
62
|
+
var FindProjectsMode = /* @__PURE__ */ ((FindProjectsMode2) => {
|
|
63
|
+
FindProjectsMode2[FindProjectsMode2["Rough"] = 0] = "Rough";
|
|
64
|
+
FindProjectsMode2[FindProjectsMode2["Precise"] = 1] = "Precise";
|
|
65
|
+
return FindProjectsMode2;
|
|
66
|
+
})(FindProjectsMode || {});
|
|
19
67
|
const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
20
68
|
const subProjects = [];
|
|
21
69
|
for (const config of configs) {
|
|
22
70
|
subProjects.push({
|
|
23
71
|
name: config.name,
|
|
24
|
-
extra: {
|
|
25
|
-
path: config.path
|
|
26
|
-
},
|
|
27
|
-
// dagNodeEdge: 0,
|
|
72
|
+
extra: { path: config.path },
|
|
28
73
|
dependencyEdge: 0,
|
|
29
74
|
dependentEdge: 0,
|
|
30
75
|
checkedCircle: false,
|
|
@@ -33,23 +78,24 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
33
78
|
}
|
|
34
79
|
return subProjects;
|
|
35
80
|
};
|
|
36
|
-
const getProjectsByPackagesMatch =
|
|
81
|
+
const getProjectsByPackagesMatch = (rootPath, match, ignore) => __async(void 0, null, function* () {
|
|
37
82
|
let projects = [];
|
|
38
83
|
if (Array.isArray(match)) {
|
|
39
|
-
|
|
40
|
-
projects = await (0, _getProjectsByPackagesConfig.getProjectsByPackageConfig)(rootPath, match, ignore);
|
|
84
|
+
projects = yield (0, import_get_projects_by_packages_config.getProjectsByPackageConfig)(rootPath, match, ignore);
|
|
41
85
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
86
|
+
projects = yield (0, import_get_projects_by_workspace_file.getProjectsByWorkspaceFile)(
|
|
87
|
+
rootPath,
|
|
88
|
+
match,
|
|
89
|
+
ignore
|
|
90
|
+
);
|
|
44
91
|
}
|
|
45
92
|
const subProjects = [];
|
|
46
93
|
for (const project of projects) {
|
|
47
94
|
subProjects.push({
|
|
48
95
|
name: project.name,
|
|
49
|
-
extra:
|
|
96
|
+
extra: __spreadValues({
|
|
50
97
|
path: project.path
|
|
51
98
|
}, project.json),
|
|
52
|
-
// dagNodeEdge: 0,
|
|
53
99
|
dependencyEdge: 0,
|
|
54
100
|
dependentEdge: 0,
|
|
55
101
|
checkedCircle: false,
|
|
@@ -57,25 +103,25 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
57
103
|
});
|
|
58
104
|
}
|
|
59
105
|
return subProjects;
|
|
60
|
-
};
|
|
106
|
+
});
|
|
61
107
|
const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
62
108
|
let projects = [];
|
|
63
|
-
// TODO: code start
|
|
64
109
|
if (Array.isArray(match)) {
|
|
65
|
-
|
|
66
|
-
projects = (0, _getProjectsByPackagesConfig.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
|
|
110
|
+
projects = (0, import_get_projects_by_packages_config.syncGetProjectsByPackageConfig)(rootPath, match, ignore);
|
|
67
111
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
112
|
+
projects = (0, import_get_projects_by_workspace_file.syncGetProjectsByWorkspaceFile)(
|
|
113
|
+
rootPath,
|
|
114
|
+
match,
|
|
115
|
+
ignore
|
|
116
|
+
);
|
|
70
117
|
}
|
|
71
118
|
const subProjects = [];
|
|
72
119
|
for (const project of projects) {
|
|
73
120
|
subProjects.push({
|
|
74
121
|
name: project.name,
|
|
75
|
-
extra:
|
|
122
|
+
extra: __spreadValues({
|
|
76
123
|
path: project.path
|
|
77
124
|
}, project.json),
|
|
78
|
-
// dagNodeEdge: 0,
|
|
79
125
|
dependencyEdge: 0,
|
|
80
126
|
dependentEdge: 0,
|
|
81
127
|
checkedCircle: false,
|
|
@@ -84,48 +130,53 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
84
130
|
}
|
|
85
131
|
return subProjects;
|
|
86
132
|
};
|
|
87
|
-
const checkFindProjectsMode = (config
|
|
88
|
-
// eslint-disable-next-line consistent-return
|
|
89
|
-
) => {
|
|
133
|
+
const checkFindProjectsMode = (config) => {
|
|
90
134
|
if (config.packagesMatchs && Array.isArray(config.packagesMatchs)) {
|
|
91
|
-
return
|
|
135
|
+
return 0 /* Rough */;
|
|
92
136
|
}
|
|
93
|
-
if (config.packagesMatchs && typeof config.packagesMatchs ===
|
|
94
|
-
return
|
|
137
|
+
if (config.packagesMatchs && typeof config.packagesMatchs === "object" && (config.packagesMatchs.workspaceFile || config.packagesMatchs.enableAutoFinder)) {
|
|
138
|
+
return 0 /* Rough */;
|
|
95
139
|
}
|
|
96
140
|
if (config.projectsConfig && Array.isArray(config.projectsConfig)) {
|
|
97
|
-
return
|
|
141
|
+
return 1 /* Precise */;
|
|
98
142
|
}
|
|
99
143
|
if (config.projectsConfig && config.packagesMatchs) {
|
|
100
|
-
(0,
|
|
144
|
+
(0, import_error.errorLog)("There can not be both `packagesMatchs` and `projectsConfig`");
|
|
101
145
|
}
|
|
102
|
-
(0,
|
|
146
|
+
(0, import_error.errorLog)("No `packagesMatchs` and `projectsConfig` configurations found");
|
|
103
147
|
};
|
|
104
|
-
const getProjects =
|
|
105
|
-
const {
|
|
106
|
-
rootPath
|
|
107
|
-
} = (0, _monorepo.getMonorepoBaseData)(currentDir);
|
|
148
|
+
const getProjects = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (config, currentDir = process.cwd()) {
|
|
149
|
+
const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
|
|
108
150
|
const mode = checkFindProjectsMode(config);
|
|
109
151
|
let projects = [];
|
|
110
|
-
if (mode ===
|
|
111
|
-
projects =
|
|
112
|
-
|
|
152
|
+
if (mode === 0 /* Rough */) {
|
|
153
|
+
projects = yield getProjectsByPackagesMatch(
|
|
154
|
+
rootPath,
|
|
155
|
+
config.packagesMatchs,
|
|
156
|
+
config.packagesIgnoreMatchs || []
|
|
157
|
+
);
|
|
158
|
+
} else if (mode === 1 /* Precise */) {
|
|
113
159
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
114
160
|
}
|
|
115
161
|
return projects;
|
|
116
|
-
};
|
|
117
|
-
exports.getProjects = getProjects;
|
|
162
|
+
});
|
|
118
163
|
const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
119
|
-
const {
|
|
120
|
-
rootPath
|
|
121
|
-
} = (0, _monorepo.getMonorepoBaseData)(currentDir);
|
|
164
|
+
const { rootPath } = (0, import_monorepo.getMonorepoBaseData)(currentDir);
|
|
122
165
|
const mode = checkFindProjectsMode(config);
|
|
123
166
|
let projects = [];
|
|
124
|
-
if (mode ===
|
|
125
|
-
projects = syncGetProjectsByPackagesMatch(
|
|
126
|
-
|
|
167
|
+
if (mode === 0 /* Rough */) {
|
|
168
|
+
projects = syncGetProjectsByPackagesMatch(
|
|
169
|
+
rootPath,
|
|
170
|
+
config.packagesMatchs,
|
|
171
|
+
config.packagesIgnoreMatchs || []
|
|
172
|
+
);
|
|
173
|
+
} else if (mode === 1 /* Precise */) {
|
|
127
174
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
128
175
|
}
|
|
129
176
|
return projects;
|
|
130
177
|
};
|
|
131
|
-
|
|
178
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
179
|
+
0 && (module.exports = {
|
|
180
|
+
getProjects,
|
|
181
|
+
syncGetProjects
|
|
182
|
+
});
|