@modern-js/monorepo-tools 2.14.0 → 2.16.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 +38 -0
- package/dist/cjs/cli/build.js +10 -31
- package/dist/cjs/cli/buildWatch.js +11 -31
- package/dist/cjs/cli/clear.js +11 -31
- package/dist/cjs/cli/deploy.js +14 -36
- package/dist/cjs/cli/index.js +23 -22
- package/dist/cjs/cli/install.js +11 -31
- package/dist/cjs/cli/new.js +17 -37
- package/dist/cjs/commands/build.js +21 -46
- package/dist/cjs/commands/buildWatch.js +19 -36
- package/dist/cjs/commands/clear.js +17 -34
- package/dist/cjs/commands/deploy.js +25 -41
- package/dist/cjs/commands/index.js +22 -21
- package/dist/cjs/commands/install.js +19 -36
- package/dist/cjs/constants.js +13 -26
- package/dist/cjs/dag/create.js +16 -28
- package/dist/cjs/dag/edgeManager.js +24 -28
- package/dist/cjs/dag/index.js +11 -29
- package/dist/cjs/dag/operator.js +106 -123
- package/dist/cjs/dag/task.js +52 -63
- package/dist/cjs/dag/utils.js +52 -49
- package/dist/cjs/features/build/index.js +52 -68
- package/dist/cjs/features/clear/index.js +66 -47
- package/dist/cjs/features/deploy/index.js +126 -96
- package/dist/cjs/features/dev/cmds.js +10 -25
- package/dist/cjs/features/dev/createTask.js +93 -56
- package/dist/cjs/features/dev/index.js +43 -71
- package/dist/cjs/features/dev/watchProjectsState.js +89 -64
- package/dist/cjs/features/install/index.js +74 -63
- package/dist/cjs/hooks/index.js +9 -27
- package/dist/cjs/index.js +36 -53
- package/dist/cjs/locale/en.js +7 -25
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +7 -25
- package/dist/cjs/log/error.js +7 -25
- package/dist/cjs/log/multiTasksLog.js +42 -43
- package/dist/cjs/log/time.js +19 -29
- package/dist/cjs/log/utils.js +7 -25
- package/dist/cjs/package/index.js +28 -30
- package/dist/cjs/parse-config/index.js +61 -49
- package/dist/cjs/parse-config/monorepo.js +81 -67
- package/dist/cjs/projects/checkProjectChange.js +95 -73
- package/dist/cjs/projects/clearMemoryFiles.js +52 -44
- package/dist/cjs/projects/getProjects.js +38 -65
- package/dist/cjs/projects/getProjectsByPackagesConfig.js +93 -71
- package/dist/cjs/projects/getProjectsByWorkspaceFile.js +89 -85
- package/dist/cjs/type.js +4 -15
- package/dist/cjs/utils/install.js +69 -44
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/cli/build.js +2 -8
- package/dist/esm/cli/buildWatch.js +4 -9
- package/dist/esm/cli/clear.js +4 -9
- package/dist/esm/cli/deploy.js +7 -14
- package/dist/esm/cli/install.js +4 -9
- package/dist/esm/cli/new.js +9 -14
- package/dist/esm/commands/build.js +7 -17
- package/dist/esm/commands/buildWatch.js +6 -8
- package/dist/esm/commands/clear.js +6 -8
- package/dist/esm/commands/deploy.js +10 -11
- package/dist/esm/commands/install.js +6 -8
- package/dist/esm/constants.js +2 -6
- package/dist/esm/dag/create.js +10 -7
- package/dist/esm/dag/edgeManager.js +17 -6
- package/dist/esm/dag/index.js +1 -4
- package/dist/esm/dag/operator.js +77 -74
- package/dist/esm/dag/task.js +39 -30
- package/dist/esm/dag/utils.js +39 -27
- package/dist/esm/features/build/index.js +22 -27
- package/dist/esm/features/clear/index.js +4 -6
- package/dist/esm/features/deploy/index.js +55 -50
- package/dist/esm/features/dev/cmds.js +4 -4
- package/dist/esm/features/dev/createTask.js +31 -15
- package/dist/esm/features/dev/index.js +19 -27
- package/dist/esm/features/dev/watchProjectsState.js +41 -31
- package/dist/esm/features/install/index.js +11 -15
- package/dist/esm/hooks/index.js +1 -4
- package/dist/esm/index.js +12 -11
- package/dist/esm/locale/en.js +1 -4
- package/dist/esm/locale/index.js +5 -5
- package/dist/esm/locale/zh.js +1 -4
- package/dist/esm/log/error.js +1 -4
- package/dist/esm/log/multiTasksLog.js +32 -18
- package/dist/esm/log/time.js +7 -8
- package/dist/esm/log/utils.js +1 -4
- package/dist/esm/package/index.js +21 -8
- package/dist/esm/parse-config/index.js +11 -14
- package/dist/esm/parse-config/monorepo.js +20 -27
- package/dist/esm/projects/checkProjectChange.js +19 -23
- package/dist/esm/projects/clearMemoryFiles.js +3 -13
- package/dist/esm/projects/getProjects.js +21 -45
- package/dist/esm/projects/getProjectsByPackagesConfig.js +29 -33
- package/dist/esm/projects/getProjectsByWorkspaceFile.js +21 -41
- package/dist/esm/type.js +1 -0
- package/dist/esm/utils/install.js +12 -8
- package/dist/esm/utils/types.js +1 -0
- package/package.json +16 -12
package/dist/cjs/log/utils.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 utils_exports = {};
|
|
19
|
-
__export(utils_exports, {
|
|
20
|
-
formatLog: () => formatLog
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatLog", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => formatLog
|
|
21
8
|
});
|
|
22
|
-
module.exports = __toCommonJS(utils_exports);
|
|
23
9
|
const formatLog = (log) => {
|
|
24
10
|
const strs = log.split(/\r\n|\n\r|\r|\n/g);
|
|
25
11
|
if (strs[0].trim() === "") {
|
|
@@ -28,7 +14,3 @@ ${strs.slice(1).filter((s) => Boolean(s)).join("\n")}`;
|
|
|
28
14
|
}
|
|
29
15
|
return strs.filter((s) => Boolean(s)).join("\n");
|
|
30
16
|
};
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
formatLog
|
|
34
|
-
});
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 package_exports = {};
|
|
19
|
-
__export(package_exports, {
|
|
20
|
-
Package: () => Package
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
21
4
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
Object.defineProperty(exports, "Package", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => Package
|
|
8
|
+
});
|
|
9
|
+
function _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
28
19
|
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
class Package {
|
|
29
23
|
get name() {
|
|
30
24
|
return this.json.name;
|
|
31
25
|
}
|
|
@@ -35,8 +29,12 @@ class Package {
|
|
|
35
29
|
get(key) {
|
|
36
30
|
return this.json[key];
|
|
37
31
|
}
|
|
32
|
+
constructor(packageJson, packageConfigPath, rootPath) {
|
|
33
|
+
_define_property(this, "json", void 0);
|
|
34
|
+
_define_property(this, "configPath", void 0);
|
|
35
|
+
_define_property(this, "rootPath", void 0);
|
|
36
|
+
this.configPath = packageConfigPath;
|
|
37
|
+
this.rootPath = rootPath;
|
|
38
|
+
this.json = packageJson;
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
Package
|
|
42
|
-
});
|
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var parse_config_exports = {};
|
|
29
|
-
__export(parse_config_exports, {
|
|
30
|
-
getFinalConfig: () => getFinalConfig
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
5
|
+
Object.defineProperty(exports, "getFinalConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getFinalConfig
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
+
const _nodecorelibrary = require("@rushstack/node-core-library");
|
|
11
|
+
const _monorepo = require("./monorepo");
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
13
|
+
if (typeof WeakMap !== "function")
|
|
14
|
+
return null;
|
|
15
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
18
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
+
})(nodeInterop);
|
|
20
|
+
}
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
+
return {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
+
if (cache && cache.has(obj)) {
|
|
32
|
+
return cache.get(obj);
|
|
33
|
+
}
|
|
34
|
+
var newObj = {};
|
|
35
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
|
+
for (var key in obj) {
|
|
37
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
39
|
+
if (desc && (desc.get || desc.set)) {
|
|
40
|
+
Object.defineProperty(newObj, key, desc);
|
|
41
|
+
} else {
|
|
42
|
+
newObj[key] = obj[key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
newObj.default = obj;
|
|
47
|
+
if (cache) {
|
|
48
|
+
cache.set(obj, newObj);
|
|
49
|
+
}
|
|
50
|
+
return newObj;
|
|
51
|
+
}
|
|
52
|
+
const defaultConfig = {};
|
|
41
53
|
const getFinalConfig = async (currentPath = process.cwd()) => {
|
|
42
|
-
const monorepo = (0,
|
|
43
|
-
const userConfig = await
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
const monorepo = (0, _monorepo.getMonorepoBaseData)(currentPath);
|
|
55
|
+
const userConfig = await _nodecorelibrary.JsonFile.loadAsync(_path.resolve(monorepo.rootPath, "mono-config.json"));
|
|
56
|
+
const config = {
|
|
57
|
+
...defaultConfig,
|
|
58
|
+
...userConfig
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
monorepo,
|
|
62
|
+
config
|
|
63
|
+
};
|
|
48
64
|
};
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
getFinalConfig
|
|
52
|
-
});
|
|
@@ -1,60 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var monorepo_exports = {};
|
|
29
|
-
__export(monorepo_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
findMonorepoRoot: () => findMonorepoRoot,
|
|
31
|
-
getMonorepoBaseData: () => getMonorepoBaseData,
|
|
32
|
-
getPackageManager: () => getPackageManager,
|
|
33
14
|
getWorkspaceFile: () => getWorkspaceFile,
|
|
34
|
-
packageManagerFlag: () => packageManagerFlag
|
|
15
|
+
packageManagerFlag: () => packageManagerFlag,
|
|
16
|
+
getPackageManager: () => getPackageManager,
|
|
17
|
+
getMonorepoBaseData: () => getMonorepoBaseData
|
|
35
18
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
20
|
+
const _nodecorelibrary = require("@rushstack/node-core-library");
|
|
21
|
+
const _constants = require("../constants");
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
23
|
+
if (typeof WeakMap !== "function")
|
|
24
|
+
return null;
|
|
25
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
28
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
29
|
+
})(nodeInterop);
|
|
30
|
+
}
|
|
31
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
32
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
36
|
+
return {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
41
|
+
if (cache && cache.has(obj)) {
|
|
42
|
+
return cache.get(obj);
|
|
43
|
+
}
|
|
44
|
+
var newObj = {};
|
|
45
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
|
+
for (var key in obj) {
|
|
47
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
48
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
49
|
+
if (desc && (desc.get || desc.set)) {
|
|
50
|
+
Object.defineProperty(newObj, key, desc);
|
|
51
|
+
} else {
|
|
52
|
+
newObj[key] = obj[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
newObj.default = obj;
|
|
57
|
+
if (cache) {
|
|
58
|
+
cache.set(obj, newObj);
|
|
59
|
+
}
|
|
60
|
+
return newObj;
|
|
61
|
+
}
|
|
40
62
|
const useLerna = (monorepoRootPath) => {
|
|
41
|
-
if (
|
|
63
|
+
if (_nodecorelibrary.FileSystem.exists(_path.join(monorepoRootPath, _constants.WORKSPACE_FILE.LERNA))) {
|
|
42
64
|
return true;
|
|
43
65
|
}
|
|
44
66
|
return false;
|
|
45
67
|
};
|
|
46
68
|
const useYarnWorkspaces = (monorepoRootPath) => {
|
|
47
|
-
if (!
|
|
69
|
+
if (!_nodecorelibrary.FileSystem.exists(_path.join(monorepoRootPath, _constants.WORKSPACE_FILE.YARN))) {
|
|
48
70
|
return false;
|
|
49
71
|
}
|
|
50
|
-
const json =
|
|
72
|
+
const json = _nodecorelibrary.JsonFile.load(_path.join(monorepoRootPath, _constants.WORKSPACE_FILE.YARN));
|
|
51
73
|
if ("workspaces" in json && json.workspaces.packages) {
|
|
52
74
|
return true;
|
|
53
75
|
}
|
|
54
76
|
return false;
|
|
55
77
|
};
|
|
56
78
|
const usePnpmWorkspaces = (monorepoRootPath) => {
|
|
57
|
-
if (
|
|
79
|
+
if (_nodecorelibrary.FileSystem.exists(_path.join(monorepoRootPath, _constants.WORKSPACE_FILE.PNPM))) {
|
|
58
80
|
return true;
|
|
59
81
|
}
|
|
60
82
|
return false;
|
|
@@ -73,42 +95,44 @@ const findMonorepoRoot = (starFindPath) => {
|
|
|
73
95
|
inMonorepo = true;
|
|
74
96
|
break;
|
|
75
97
|
}
|
|
76
|
-
findPath =
|
|
98
|
+
findPath = _path.dirname(findPath);
|
|
77
99
|
}
|
|
78
100
|
return inMonorepo ? findPath : void 0;
|
|
79
101
|
};
|
|
80
102
|
const getWorkspaceFile = (startFindPath) => {
|
|
81
103
|
const rootPath = findMonorepoRoot(startFindPath);
|
|
82
104
|
if (!rootPath) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
85
|
-
);
|
|
105
|
+
throw new Error("[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`");
|
|
86
106
|
}
|
|
87
107
|
if (usePnpmWorkspaces(rootPath)) {
|
|
88
|
-
return
|
|
108
|
+
return _constants.WORKSPACE_FILE.PNPM;
|
|
89
109
|
} else if (useLerna(rootPath)) {
|
|
90
|
-
return
|
|
110
|
+
return _constants.WORKSPACE_FILE.LERNA;
|
|
91
111
|
} else if (useYarnWorkspaces(rootPath)) {
|
|
92
|
-
return
|
|
112
|
+
return _constants.WORKSPACE_FILE.YARN;
|
|
93
113
|
} else {
|
|
94
|
-
throw new Error(
|
|
95
|
-
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
96
|
-
);
|
|
114
|
+
throw new Error("[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`");
|
|
97
115
|
}
|
|
98
116
|
};
|
|
99
117
|
const packageManagerFlag = {
|
|
100
|
-
pnpm: [
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
pnpm: [
|
|
119
|
+
_constants.WORKSPACE_FILE.PNPM,
|
|
120
|
+
"pnpm-lock.yaml"
|
|
121
|
+
],
|
|
122
|
+
yarn: [
|
|
123
|
+
"yarn.lock",
|
|
124
|
+
useYarnWorkspaces
|
|
125
|
+
],
|
|
126
|
+
npm: [
|
|
127
|
+
() => true
|
|
128
|
+
]
|
|
103
129
|
};
|
|
104
|
-
const usePnpmPackageManager = (monorepoRootPath) => packageManagerFlag.pnpm.some(
|
|
105
|
-
(flag) => import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, flag))
|
|
106
|
-
);
|
|
130
|
+
const usePnpmPackageManager = (monorepoRootPath) => packageManagerFlag.pnpm.some((flag) => _nodecorelibrary.FileSystem.exists(_path.join(monorepoRootPath, flag)));
|
|
107
131
|
const useYarnPackageManager = (monorepoRootPath) => packageManagerFlag.yarn.some((flag) => {
|
|
108
132
|
if (typeof flag === "function") {
|
|
109
133
|
return flag(monorepoRootPath);
|
|
110
134
|
}
|
|
111
|
-
return
|
|
135
|
+
return _nodecorelibrary.FileSystem.exists(_path.join(monorepoRootPath, flag));
|
|
112
136
|
});
|
|
113
137
|
const getPackageManager = (monorepoRootPath) => {
|
|
114
138
|
if (usePnpmPackageManager(monorepoRootPath)) {
|
|
@@ -121,20 +145,10 @@ const getPackageManager = (monorepoRootPath) => {
|
|
|
121
145
|
const getMonorepoBaseData = (root = process.cwd()) => {
|
|
122
146
|
const rootPath = findMonorepoRoot(root);
|
|
123
147
|
if (!rootPath) {
|
|
124
|
-
throw new Error(
|
|
125
|
-
"not find any monorepo, you can add lerna、pnpm or yarn workspace file"
|
|
126
|
-
);
|
|
148
|
+
throw new Error("not find any monorepo, you can add lerna、pnpm or yarn workspace file");
|
|
127
149
|
}
|
|
128
150
|
return {
|
|
129
151
|
rootPath,
|
|
130
152
|
packageManager: getPackageManager(rootPath)
|
|
131
153
|
};
|
|
132
154
|
};
|
|
133
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
-
0 && (module.exports = {
|
|
135
|
-
findMonorepoRoot,
|
|
136
|
-
getMonorepoBaseData,
|
|
137
|
-
getPackageManager,
|
|
138
|
-
getWorkspaceFile,
|
|
139
|
-
packageManagerFlag
|
|
140
|
-
});
|
|
@@ -1,44 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var checkProjectChange_exports = {};
|
|
29
|
-
__export(checkProjectChange_exports, {
|
|
30
|
-
MONOREPO_GIT_FILE_NAME: () => MONOREPO_GIT_FILE_NAME,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
31
13
|
PROJECT_CONTENT_FILE_NAME: () => PROJECT_CONTENT_FILE_NAME,
|
|
14
|
+
MONOREPO_GIT_FILE_NAME: () => MONOREPO_GIT_FILE_NAME,
|
|
32
15
|
PROJECT_MEMORY_PATH: () => PROJECT_MEMORY_PATH,
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
checkProjectChangeByGit: () => checkProjectChangeByGit,
|
|
17
|
+
checkProjectChangeByContent: () => checkProjectChangeByContent
|
|
35
18
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
20
|
+
const _nodecorelibrary = require("@rushstack/node-core-library");
|
|
21
|
+
const _packagedepshash = require("@rushstack/package-deps-hash");
|
|
22
|
+
const _utils = require("@modern-js/utils");
|
|
23
|
+
const _md5 = /* @__PURE__ */ _interop_require_default(require("md5"));
|
|
24
|
+
function _interop_require_default(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
30
|
+
if (typeof WeakMap !== "function")
|
|
31
|
+
return null;
|
|
32
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
33
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
35
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
+
})(nodeInterop);
|
|
37
|
+
}
|
|
38
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
39
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
+
return {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
+
if (cache && cache.has(obj)) {
|
|
49
|
+
return cache.get(obj);
|
|
50
|
+
}
|
|
51
|
+
var newObj = {};
|
|
52
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
|
+
for (var key in obj) {
|
|
54
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
+
if (desc && (desc.get || desc.set)) {
|
|
57
|
+
Object.defineProperty(newObj, key, desc);
|
|
58
|
+
} else {
|
|
59
|
+
newObj[key] = obj[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
newObj.default = obj;
|
|
64
|
+
if (cache) {
|
|
65
|
+
cache.set(obj, newObj);
|
|
66
|
+
}
|
|
67
|
+
return newObj;
|
|
68
|
+
}
|
|
42
69
|
const PROJECT_CONTENT_FILE_NAME = "project-content.json";
|
|
43
70
|
const MONOREPO_GIT_FILE_NAME = "monorepo-git.json";
|
|
44
71
|
const PROJECT_MEMORY_PATH = ".project-memory";
|
|
@@ -49,35 +76,37 @@ const getProjectGitHash = async (project) => {
|
|
|
49
76
|
absolute: true,
|
|
50
77
|
expandDirectories: false,
|
|
51
78
|
followSymbolicLinks: false,
|
|
52
|
-
ignore: [
|
|
79
|
+
ignore: [
|
|
80
|
+
"**/node_modules/**",
|
|
81
|
+
".project-memory/**",
|
|
82
|
+
"dist/**"
|
|
83
|
+
]
|
|
53
84
|
};
|
|
54
85
|
const globPattern = `${projectDir}/**`;
|
|
55
|
-
const files = await (0,
|
|
56
|
-
const hashMap = (0,
|
|
86
|
+
const files = await (0, _utils.globby)(_path.posix.join(globPattern), globOption);
|
|
87
|
+
const hashMap = (0, _packagedepshash.getGitHashForFiles)(files, projectDir);
|
|
57
88
|
const hashObject = {};
|
|
58
|
-
|
|
89
|
+
_nodecorelibrary.Sort.sortMapKeys(hashMap);
|
|
59
90
|
hashMap.forEach((value, key) => {
|
|
60
91
|
hashObject[key] = value;
|
|
61
92
|
});
|
|
62
|
-
return (0,
|
|
93
|
+
return (0, _md5.default)(_nodecorelibrary.JsonFile.stringify(hashObject));
|
|
63
94
|
};
|
|
64
95
|
const checkProjectChangeByGit = async (project, rootPath) => {
|
|
65
|
-
const monorepoGitMemory =
|
|
96
|
+
const monorepoGitMemory = _path.join(rootPath, MONOREPO_GIT_FILE_NAME);
|
|
66
97
|
const currentProjectHash = await getProjectGitHash(project);
|
|
67
|
-
if (!
|
|
68
|
-
|
|
98
|
+
if (!_nodecorelibrary.FileSystem.exists(monorepoGitMemory)) {
|
|
99
|
+
_nodecorelibrary.FileSystem.writeFile(monorepoGitMemory, _nodecorelibrary.JsonFile.stringify({}), {
|
|
69
100
|
ensureFolderExists: true
|
|
70
101
|
});
|
|
71
102
|
}
|
|
72
|
-
const monorepoProjectHashJson =
|
|
103
|
+
const monorepoProjectHashJson = _nodecorelibrary.JsonFile.load(monorepoGitMemory);
|
|
73
104
|
const changed = monorepoProjectHashJson[project.name] !== currentProjectHash;
|
|
74
105
|
if (changed) {
|
|
75
106
|
monorepoProjectHashJson[project.name] = currentProjectHash;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{ ensureFolderExists: true }
|
|
80
|
-
);
|
|
107
|
+
_nodecorelibrary.FileSystem.writeFile(monorepoGitMemory, _nodecorelibrary.JsonFile.stringify(monorepoProjectHashJson), {
|
|
108
|
+
ensureFolderExists: true
|
|
109
|
+
});
|
|
81
110
|
}
|
|
82
111
|
return changed;
|
|
83
112
|
};
|
|
@@ -88,45 +117,38 @@ const getProjectContentHashObjectForFiles = async (project) => {
|
|
|
88
117
|
absolute: true,
|
|
89
118
|
expandDirectories: false,
|
|
90
119
|
followSymbolicLinks: false,
|
|
91
|
-
ignore: [
|
|
120
|
+
ignore: [
|
|
121
|
+
"**/node_modules/**",
|
|
122
|
+
".project-memory/**",
|
|
123
|
+
"**/dist/**"
|
|
124
|
+
]
|
|
92
125
|
};
|
|
93
126
|
const globPattern = `${projectDir}/**`;
|
|
94
|
-
const files = await (0,
|
|
127
|
+
const files = await (0, _utils.globby)(_path.posix.join(globPattern), globOption);
|
|
95
128
|
const hashObject = {};
|
|
96
129
|
for (const file of files.sort()) {
|
|
97
|
-
hashObject[file] = (0,
|
|
130
|
+
hashObject[file] = (0, _md5.default)(_nodecorelibrary.FileSystem.readFile(file));
|
|
98
131
|
}
|
|
99
132
|
return hashObject;
|
|
100
133
|
};
|
|
101
134
|
const checkProjectChangeByContent = async (project) => {
|
|
102
135
|
const projectDir = project.extra.path;
|
|
103
|
-
const projectMemoryFolder =
|
|
104
|
-
const projectJsonFile =
|
|
105
|
-
projectMemoryFolder,
|
|
106
|
-
PROJECT_CONTENT_FILE_NAME
|
|
107
|
-
);
|
|
136
|
+
const projectMemoryFolder = _path.resolve(projectDir, ".project-memory");
|
|
137
|
+
const projectJsonFile = _path.join(projectMemoryFolder, PROJECT_CONTENT_FILE_NAME);
|
|
108
138
|
const currentHashObject = await getProjectContentHashObjectForFiles(project);
|
|
109
|
-
const currentHashString =
|
|
110
|
-
if (!
|
|
111
|
-
|
|
139
|
+
const currentHashString = _nodecorelibrary.JsonFile.stringify(currentHashObject);
|
|
140
|
+
if (!_nodecorelibrary.FileSystem.exists(projectJsonFile)) {
|
|
141
|
+
_nodecorelibrary.FileSystem.writeFile(projectJsonFile, currentHashString, {
|
|
112
142
|
ensureFolderExists: true
|
|
113
143
|
});
|
|
114
144
|
return true;
|
|
115
145
|
}
|
|
116
|
-
const localHashObject =
|
|
117
|
-
const changed =
|
|
146
|
+
const localHashObject = _nodecorelibrary.JsonFile.load(projectJsonFile);
|
|
147
|
+
const changed = _nodecorelibrary.JsonFile.stringify(localHashObject) !== currentHashString;
|
|
118
148
|
if (changed) {
|
|
119
|
-
|
|
149
|
+
_nodecorelibrary.FileSystem.writeFile(projectJsonFile, currentHashString, {
|
|
120
150
|
ensureFolderExists: true
|
|
121
151
|
});
|
|
122
152
|
}
|
|
123
153
|
return changed;
|
|
124
154
|
};
|
|
125
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
-
0 && (module.exports = {
|
|
127
|
-
MONOREPO_GIT_FILE_NAME,
|
|
128
|
-
PROJECT_CONTENT_FILE_NAME,
|
|
129
|
-
PROJECT_MEMORY_PATH,
|
|
130
|
-
checkProjectChangeByContent,
|
|
131
|
-
checkProjectChangeByGit
|
|
132
|
-
});
|