@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,101 +1,128 @@
|
|
|
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
|
+
findMonorepoRoot: () => findMonorepoRoot,
|
|
27
|
+
getMonorepoBaseData: () => getMonorepoBaseData,
|
|
28
|
+
getPackageManager: () => getPackageManager,
|
|
29
|
+
getWorkspaceFile: () => getWorkspaceFile,
|
|
30
|
+
packageManagerFlag: () => packageManagerFlag
|
|
5
31
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const useLerna = monorepoRootPath => {
|
|
13
|
-
if (_nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, _constants.WORKSPACE_FILE.LERNA))) {
|
|
32
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
+
var path = __toESM(require("path"));
|
|
34
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
35
|
+
var import_constants = require("../constants");
|
|
36
|
+
const useLerna = (monorepoRootPath) => {
|
|
37
|
+
if (import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, import_constants.WORKSPACE_FILE.LERNA))) {
|
|
14
38
|
return true;
|
|
15
39
|
}
|
|
16
40
|
return false;
|
|
17
41
|
};
|
|
18
|
-
const useYarnWorkspaces = monorepoRootPath => {
|
|
19
|
-
if (!
|
|
42
|
+
const useYarnWorkspaces = (monorepoRootPath) => {
|
|
43
|
+
if (!import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, import_constants.WORKSPACE_FILE.YARN))) {
|
|
20
44
|
return false;
|
|
21
45
|
}
|
|
22
|
-
const json =
|
|
23
|
-
if (
|
|
46
|
+
const json = import_node_core_library.JsonFile.load(path.join(monorepoRootPath, import_constants.WORKSPACE_FILE.YARN));
|
|
47
|
+
if ("workspaces" in json && json.workspaces.packages) {
|
|
24
48
|
return true;
|
|
25
49
|
}
|
|
26
50
|
return false;
|
|
27
51
|
};
|
|
28
|
-
const usePnpmWorkspaces = monorepoRootPath => {
|
|
29
|
-
if (
|
|
52
|
+
const usePnpmWorkspaces = (monorepoRootPath) => {
|
|
53
|
+
if (import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, import_constants.WORKSPACE_FILE.PNPM))) {
|
|
30
54
|
return true;
|
|
31
55
|
}
|
|
32
56
|
return false;
|
|
33
57
|
};
|
|
34
|
-
const isMonorepo = monorepoRootPath => {
|
|
58
|
+
const isMonorepo = (monorepoRootPath) => {
|
|
35
59
|
if (usePnpmWorkspaces(monorepoRootPath) || useLerna(monorepoRootPath) || useYarnWorkspaces(monorepoRootPath)) {
|
|
36
60
|
return true;
|
|
37
61
|
}
|
|
38
62
|
return false;
|
|
39
63
|
};
|
|
40
|
-
const findMonorepoRoot = starFindPath => {
|
|
64
|
+
const findMonorepoRoot = (starFindPath) => {
|
|
41
65
|
let inMonorepo = false;
|
|
42
66
|
let findPath = starFindPath;
|
|
43
|
-
while (findPath !==
|
|
67
|
+
while (findPath !== "/") {
|
|
44
68
|
if (isMonorepo(findPath)) {
|
|
45
69
|
inMonorepo = true;
|
|
46
70
|
break;
|
|
47
71
|
}
|
|
48
72
|
findPath = path.dirname(findPath);
|
|
49
73
|
}
|
|
50
|
-
return inMonorepo ? findPath :
|
|
74
|
+
return inMonorepo ? findPath : void 0;
|
|
51
75
|
};
|
|
52
|
-
|
|
53
|
-
const getWorkspaceFile = startFindPath => {
|
|
76
|
+
const getWorkspaceFile = (startFindPath) => {
|
|
54
77
|
const rootPath = findMonorepoRoot(startFindPath);
|
|
55
78
|
if (!rootPath) {
|
|
56
|
-
throw new Error(
|
|
79
|
+
throw new Error(
|
|
80
|
+
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
81
|
+
);
|
|
57
82
|
}
|
|
58
83
|
if (usePnpmWorkspaces(rootPath)) {
|
|
59
|
-
return
|
|
84
|
+
return import_constants.WORKSPACE_FILE.PNPM;
|
|
60
85
|
} else if (useLerna(rootPath)) {
|
|
61
|
-
return
|
|
86
|
+
return import_constants.WORKSPACE_FILE.LERNA;
|
|
62
87
|
} else if (useYarnWorkspaces(rootPath)) {
|
|
63
|
-
return
|
|
88
|
+
return import_constants.WORKSPACE_FILE.YARN;
|
|
64
89
|
} else {
|
|
65
|
-
throw new Error(
|
|
90
|
+
throw new Error(
|
|
91
|
+
"[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`"
|
|
92
|
+
);
|
|
66
93
|
}
|
|
67
94
|
};
|
|
68
|
-
exports.getWorkspaceFile = getWorkspaceFile;
|
|
69
95
|
const packageManagerFlag = {
|
|
70
|
-
pnpm: [
|
|
71
|
-
yarn: [
|
|
96
|
+
pnpm: [import_constants.WORKSPACE_FILE.PNPM, "pnpm-lock.yaml"],
|
|
97
|
+
yarn: ["yarn.lock", useYarnWorkspaces],
|
|
72
98
|
npm: [() => true]
|
|
73
99
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
100
|
+
const usePnpmPackageManager = (monorepoRootPath) => packageManagerFlag.pnpm.some(
|
|
101
|
+
(flag) => import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, flag))
|
|
102
|
+
);
|
|
103
|
+
const useYarnPackageManager = (monorepoRootPath) => packageManagerFlag.yarn.some((flag) => {
|
|
104
|
+
if (typeof flag === "function") {
|
|
78
105
|
return flag(monorepoRootPath);
|
|
79
106
|
}
|
|
80
|
-
return
|
|
107
|
+
return import_node_core_library.FileSystem.exists(path.join(monorepoRootPath, flag));
|
|
81
108
|
});
|
|
82
|
-
const getPackageManager = monorepoRootPath => {
|
|
109
|
+
const getPackageManager = (monorepoRootPath) => {
|
|
83
110
|
if (usePnpmPackageManager(monorepoRootPath)) {
|
|
84
|
-
return
|
|
111
|
+
return "pnpm";
|
|
85
112
|
} else if (useYarnPackageManager(monorepoRootPath)) {
|
|
86
|
-
return
|
|
113
|
+
return "yarn";
|
|
87
114
|
}
|
|
88
|
-
return
|
|
115
|
+
return "npm";
|
|
89
116
|
};
|
|
90
|
-
exports.getPackageManager = getPackageManager;
|
|
91
117
|
const getMonorepoBaseData = (root = process.cwd()) => {
|
|
92
118
|
const rootPath = findMonorepoRoot(root);
|
|
93
119
|
if (!rootPath) {
|
|
94
|
-
throw new Error(
|
|
120
|
+
throw new Error(
|
|
121
|
+
"not find any monorepo, you can add lerna、pnpm or yarn workspace file"
|
|
122
|
+
);
|
|
95
123
|
}
|
|
96
124
|
return {
|
|
97
125
|
rootPath,
|
|
98
126
|
packageManager: getPackageManager(rootPath)
|
|
99
127
|
};
|
|
100
128
|
};
|
|
101
|
-
exports.getMonorepoBaseData = getMonorepoBaseData;
|
|
@@ -1,100 +1,140 @@
|
|
|
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
|
+
MONOREPO_GIT_FILE_NAME: () => MONOREPO_GIT_FILE_NAME,
|
|
27
|
+
PROJECT_CONTENT_FILE_NAME: () => PROJECT_CONTENT_FILE_NAME,
|
|
28
|
+
PROJECT_MEMORY_PATH: () => PROJECT_MEMORY_PATH,
|
|
29
|
+
checkProjectChangeByContent: () => checkProjectChangeByContent,
|
|
30
|
+
checkProjectChangeByGit: () => checkProjectChangeByGit
|
|
5
31
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
+
var path = __toESM(require("path"));
|
|
34
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
35
|
+
var import_package_deps_hash = require("@rushstack/package-deps-hash");
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var import_md5 = __toESM(require("md5"));
|
|
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
|
+
const PROJECT_CONTENT_FILE_NAME = "project-content.json";
|
|
59
|
+
const MONOREPO_GIT_FILE_NAME = "monorepo-git.json";
|
|
60
|
+
const PROJECT_MEMORY_PATH = ".project-memory";
|
|
61
|
+
const getProjectGitHash = (project) => __async(void 0, null, function* () {
|
|
22
62
|
const projectDir = project.extra.path;
|
|
23
63
|
const globOption = {
|
|
24
64
|
cwd: projectDir,
|
|
25
65
|
absolute: true,
|
|
26
66
|
expandDirectories: false,
|
|
27
67
|
followSymbolicLinks: false,
|
|
28
|
-
ignore: [
|
|
68
|
+
ignore: ["**/node_modules/**", ".project-memory/**", "dist/**"]
|
|
29
69
|
};
|
|
30
70
|
const globPattern = `${projectDir}/**`;
|
|
31
|
-
const files =
|
|
32
|
-
const hashMap = (0,
|
|
71
|
+
const files = yield (0, import_utils.globby)(path.posix.join(globPattern), globOption);
|
|
72
|
+
const hashMap = (0, import_package_deps_hash.getGitHashForFiles)(files, projectDir);
|
|
33
73
|
const hashObject = {};
|
|
34
|
-
|
|
35
|
-
// sort is important
|
|
36
|
-
_nodeCoreLibrary.Sort.sortMapKeys(hashMap);
|
|
74
|
+
import_node_core_library.Sort.sortMapKeys(hashMap);
|
|
37
75
|
hashMap.forEach((value, key) => {
|
|
38
76
|
hashObject[key] = value;
|
|
39
77
|
});
|
|
40
|
-
return (0,
|
|
41
|
-
};
|
|
42
|
-
const checkProjectChangeByGit =
|
|
78
|
+
return (0, import_md5.default)(import_node_core_library.JsonFile.stringify(hashObject));
|
|
79
|
+
});
|
|
80
|
+
const checkProjectChangeByGit = (project, rootPath) => __async(void 0, null, function* () {
|
|
43
81
|
const monorepoGitMemory = path.join(rootPath, MONOREPO_GIT_FILE_NAME);
|
|
44
|
-
const currentProjectHash =
|
|
45
|
-
if (!
|
|
46
|
-
|
|
82
|
+
const currentProjectHash = yield getProjectGitHash(project);
|
|
83
|
+
if (!import_node_core_library.FileSystem.exists(monorepoGitMemory)) {
|
|
84
|
+
import_node_core_library.FileSystem.writeFile(monorepoGitMemory, import_node_core_library.JsonFile.stringify({}), {
|
|
47
85
|
ensureFolderExists: true
|
|
48
86
|
});
|
|
49
87
|
}
|
|
50
|
-
const monorepoProjectHashJson =
|
|
88
|
+
const monorepoProjectHashJson = import_node_core_library.JsonFile.load(monorepoGitMemory);
|
|
51
89
|
const changed = monorepoProjectHashJson[project.name] !== currentProjectHash;
|
|
52
90
|
if (changed) {
|
|
53
91
|
monorepoProjectHashJson[project.name] = currentProjectHash;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
import_node_core_library.FileSystem.writeFile(
|
|
93
|
+
monorepoGitMemory,
|
|
94
|
+
import_node_core_library.JsonFile.stringify(monorepoProjectHashJson),
|
|
95
|
+
{ ensureFolderExists: true }
|
|
96
|
+
);
|
|
57
97
|
}
|
|
58
98
|
return changed;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const getProjectContentHashObjectForFiles = async project => {
|
|
99
|
+
});
|
|
100
|
+
const getProjectContentHashObjectForFiles = (project) => __async(void 0, null, function* () {
|
|
62
101
|
const projectDir = project.extra.path;
|
|
63
102
|
const globOption = {
|
|
64
103
|
cwd: projectDir,
|
|
65
104
|
absolute: true,
|
|
66
105
|
expandDirectories: false,
|
|
67
106
|
followSymbolicLinks: false,
|
|
68
|
-
ignore: [
|
|
107
|
+
ignore: ["**/node_modules/**", ".project-memory/**", "**/dist/**"]
|
|
69
108
|
};
|
|
70
109
|
const globPattern = `${projectDir}/**`;
|
|
71
|
-
const files =
|
|
110
|
+
const files = yield (0, import_utils.globby)(path.posix.join(globPattern), globOption);
|
|
72
111
|
const hashObject = {};
|
|
73
|
-
// sort is important
|
|
74
112
|
for (const file of files.sort()) {
|
|
75
|
-
hashObject[file] = (0,
|
|
113
|
+
hashObject[file] = (0, import_md5.default)(import_node_core_library.FileSystem.readFile(file));
|
|
76
114
|
}
|
|
77
115
|
return hashObject;
|
|
78
|
-
};
|
|
79
|
-
const checkProjectChangeByContent =
|
|
116
|
+
});
|
|
117
|
+
const checkProjectChangeByContent = (project) => __async(void 0, null, function* () {
|
|
80
118
|
const projectDir = project.extra.path;
|
|
81
|
-
const projectMemoryFolder = path.resolve(projectDir,
|
|
82
|
-
const projectJsonFile = path.join(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
119
|
+
const projectMemoryFolder = path.resolve(projectDir, ".project-memory");
|
|
120
|
+
const projectJsonFile = path.join(
|
|
121
|
+
projectMemoryFolder,
|
|
122
|
+
PROJECT_CONTENT_FILE_NAME
|
|
123
|
+
);
|
|
124
|
+
const currentHashObject = yield getProjectContentHashObjectForFiles(project);
|
|
125
|
+
const currentHashString = import_node_core_library.JsonFile.stringify(currentHashObject);
|
|
126
|
+
if (!import_node_core_library.FileSystem.exists(projectJsonFile)) {
|
|
127
|
+
import_node_core_library.FileSystem.writeFile(projectJsonFile, currentHashString, {
|
|
87
128
|
ensureFolderExists: true
|
|
88
129
|
});
|
|
89
130
|
return true;
|
|
90
131
|
}
|
|
91
|
-
const localHashObject =
|
|
92
|
-
const changed =
|
|
132
|
+
const localHashObject = import_node_core_library.JsonFile.load(projectJsonFile);
|
|
133
|
+
const changed = import_node_core_library.JsonFile.stringify(localHashObject) !== currentHashString;
|
|
93
134
|
if (changed) {
|
|
94
|
-
|
|
135
|
+
import_node_core_library.FileSystem.writeFile(projectJsonFile, currentHashString, {
|
|
95
136
|
ensureFolderExists: true
|
|
96
137
|
});
|
|
97
138
|
}
|
|
98
139
|
return changed;
|
|
99
|
-
};
|
|
100
|
-
exports.checkProjectChangeByContent = checkProjectChangeByContent;
|
|
140
|
+
});
|
|
@@ -1,19 +1,42 @@
|
|
|
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
|
+
clearProjectsMemoryFile: () => clearProjectsMemoryFile
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
const clearProjectsMemoryFile = projects => {
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
31
|
+
var import_check_project_change = require("./check-project-change");
|
|
32
|
+
const clearProjectsMemoryFile = (projects) => {
|
|
13
33
|
for (const project of projects) {
|
|
14
|
-
const memoryFilePath = path.join(
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
const memoryFilePath = path.join(
|
|
35
|
+
project.extra.path,
|
|
36
|
+
import_check_project_change.PROJECT_MEMORY_PATH,
|
|
37
|
+
import_check_project_change.PROJECT_CONTENT_FILE_NAME
|
|
38
|
+
);
|
|
39
|
+
console.info("remove", memoryFilePath);
|
|
40
|
+
import_node_core_library.FileSystem.deleteFile(memoryFilePath);
|
|
17
41
|
}
|
|
18
42
|
};
|
|
19
|
-
exports.clearProjectsMemoryFile = clearProjectsMemoryFile;
|