@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.
Files changed (105) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/bin/modern.js +3 -1
  3. package/dist/js/modern/cli/build-watch.js +30 -5
  4. package/dist/js/modern/cli/build.js +31 -5
  5. package/dist/js/modern/cli/clear.js +30 -5
  6. package/dist/js/modern/cli/deploy.js +35 -7
  7. package/dist/js/modern/cli/index.js +1 -1
  8. package/dist/js/modern/cli/install.js +30 -5
  9. package/dist/js/modern/cli/new.js +56 -14
  10. package/dist/js/modern/commands/build-watch.js +32 -18
  11. package/dist/js/modern/commands/build.js +49 -23
  12. package/dist/js/modern/commands/clear.js +31 -15
  13. package/dist/js/modern/commands/deploy.js +38 -24
  14. package/dist/js/modern/commands/index.js +1 -1
  15. package/dist/js/modern/commands/install.js +32 -17
  16. package/dist/js/modern/constants.js +13 -9
  17. package/dist/js/modern/dag/create.js +27 -23
  18. package/dist/js/modern/dag/edge-manager.js +5 -4
  19. package/dist/js/modern/dag/index.js +6 -5
  20. package/dist/js/modern/dag/operator.js +174 -156
  21. package/dist/js/modern/dag/task.js +64 -39
  22. package/dist/js/modern/dag/utils.js +32 -38
  23. package/dist/js/modern/features/build/index.js +47 -28
  24. package/dist/js/modern/features/clear/index.js +16 -15
  25. package/dist/js/modern/features/deploy/index.js +107 -82
  26. package/dist/js/modern/features/dev/cmds.js +4 -3
  27. package/dist/js/modern/features/dev/create-task.js +43 -34
  28. package/dist/js/modern/features/dev/index.js +60 -41
  29. package/dist/js/modern/features/dev/watch-projects-state.js +47 -24
  30. package/dist/js/modern/features/install/index.js +43 -22
  31. package/dist/js/modern/hooks/index.js +6 -3
  32. package/dist/js/modern/index.js +18 -16
  33. package/dist/js/modern/locale/en.js +10 -7
  34. package/dist/js/modern/locale/index.js +6 -6
  35. package/dist/js/modern/locale/zh.js +11 -8
  36. package/dist/js/modern/log/error.js +6 -3
  37. package/dist/js/modern/log/multi-tasks-log.js +25 -34
  38. package/dist/js/modern/log/time.js +26 -11
  39. package/dist/js/modern/log/utils.js +9 -5
  40. package/dist/js/modern/package/index.js +5 -6
  41. package/dist/js/modern/parse-config/index.js +49 -22
  42. package/dist/js/modern/parse-config/monorepo.js +41 -26
  43. package/dist/js/modern/projects/check-project-change.js +59 -30
  44. package/dist/js/modern/projects/clear-memory-files.js +17 -7
  45. package/dist/js/modern/projects/get-projects-by-packages-config.js +89 -52
  46. package/dist/js/modern/projects/get-projects-by-workspace-file.js +68 -32
  47. package/dist/js/modern/projects/get-projects.js +96 -53
  48. package/dist/js/modern/type.js +0 -1
  49. package/dist/js/modern/utils/install.js +36 -19
  50. package/dist/js/modern/utils/language.js +6 -3
  51. package/dist/js/node/cli/build-watch.js +51 -10
  52. package/dist/js/node/cli/build.js +52 -10
  53. package/dist/js/node/cli/clear.js +51 -10
  54. package/dist/js/node/cli/deploy.js +56 -12
  55. package/dist/js/node/cli/index.js +22 -71
  56. package/dist/js/node/cli/install.js +51 -10
  57. package/dist/js/node/cli/new.js +75 -19
  58. package/dist/js/node/commands/build-watch.js +59 -29
  59. package/dist/js/node/commands/build.js +74 -32
  60. package/dist/js/node/commands/clear.js +57 -25
  61. package/dist/js/node/commands/deploy.js +65 -35
  62. package/dist/js/node/commands/index.js +21 -60
  63. package/dist/js/node/commands/install.js +59 -28
  64. package/dist/js/node/constants.js +33 -13
  65. package/dist/js/node/dag/create.js +46 -28
  66. package/dist/js/node/dag/edge-manager.js +25 -8
  67. package/dist/js/node/dag/index.js +30 -13
  68. package/dist/js/node/dag/operator.js +211 -174
  69. package/dist/js/node/dag/task.js +92 -46
  70. package/dist/js/node/dag/utils.js +58 -47
  71. package/dist/js/node/features/build/index.js +84 -47
  72. package/dist/js/node/features/clear/index.js +49 -28
  73. package/dist/js/node/features/deploy/index.js +139 -104
  74. package/dist/js/node/features/dev/cmds.js +26 -9
  75. package/dist/js/node/features/dev/create-task.js +80 -51
  76. package/dist/js/node/features/dev/index.js +98 -58
  77. package/dist/js/node/features/dev/watch-projects-state.js +71 -30
  78. package/dist/js/node/features/install/index.js +82 -41
  79. package/dist/js/node/hooks/index.js +27 -8
  80. package/dist/js/node/index.js +53 -32
  81. package/dist/js/node/locale/en.js +30 -11
  82. package/dist/js/node/locale/index.js +31 -14
  83. package/dist/js/node/locale/zh.js +31 -12
  84. package/dist/js/node/log/error.js +26 -7
  85. package/dist/js/node/log/multi-tasks-log.js +48 -41
  86. package/dist/js/node/log/time.js +47 -18
  87. package/dist/js/node/log/utils.js +30 -10
  88. package/dist/js/node/package/index.js +25 -10
  89. package/dist/js/node/parse-config/index.js +76 -31
  90. package/dist/js/node/parse-config/monorepo.js +79 -44
  91. package/dist/js/node/projects/check-project-change.js +104 -56
  92. package/dist/js/node/projects/clear-memory-files.js +42 -15
  93. package/dist/js/node/projects/get-projects-by-packages-config.js +119 -65
  94. package/dist/js/node/projects/get-projects-by-workspace-file.js +108 -55
  95. package/dist/js/node/projects/get-projects.js +112 -61
  96. package/dist/js/node/type.js +15 -5
  97. package/dist/js/node/utils/install.js +68 -31
  98. package/dist/js/node/utils/language.js +28 -8
  99. package/dist/js/node/utils/types.js +15 -0
  100. package/dist/types/dag/operator.d.ts +3 -0
  101. package/dist/types/dag/utils.d.ts +1 -0
  102. package/dist/types/features/dev/index.d.ts +1 -0
  103. package/dist/types/index.d.ts +2 -0
  104. package/dist/types/projects/get-projects.d.ts +1 -0
  105. package/package.json +12 -19
@@ -1,101 +1,136 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 monorepo_exports = {};
25
+ __export(monorepo_exports, {
26
+ findMonorepoRoot: () => findMonorepoRoot,
27
+ getMonorepoBaseData: () => getMonorepoBaseData,
28
+ getPackageManager: () => getPackageManager,
29
+ getWorkspaceFile: () => getWorkspaceFile,
30
+ packageManagerFlag: () => packageManagerFlag
5
31
  });
6
- exports.packageManagerFlag = exports.getWorkspaceFile = exports.getPackageManager = exports.getMonorepoBaseData = exports.findMonorepoRoot = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _nodeCoreLibrary = require("@rushstack/node-core-library");
9
- var _constants = require("../constants");
10
- 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); }
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 useLerna = monorepoRootPath => {
13
- if (_nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, _constants.WORKSPACE_FILE.LERNA))) {
32
+ module.exports = __toCommonJS(monorepo_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 (!_nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, _constants.WORKSPACE_FILE.YARN))) {
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 = _nodeCoreLibrary.JsonFile.load(path.join(monorepoRootPath, _constants.WORKSPACE_FILE.YARN));
23
- if ('workspaces' in json && json.workspaces.packages) {
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 (_nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, _constants.WORKSPACE_FILE.PNPM))) {
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 : undefined;
74
+ return inMonorepo ? findPath : void 0;
51
75
  };
52
- exports.findMonorepoRoot = findMonorepoRoot;
53
- const getWorkspaceFile = startFindPath => {
76
+ const getWorkspaceFile = (startFindPath) => {
54
77
  const rootPath = findMonorepoRoot(startFindPath);
55
78
  if (!rootPath) {
56
- throw new Error('[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`');
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 _constants.WORKSPACE_FILE.PNPM;
84
+ return import_constants.WORKSPACE_FILE.PNPM;
60
85
  } else if (useLerna(rootPath)) {
61
- return _constants.WORKSPACE_FILE.LERNA;
86
+ return import_constants.WORKSPACE_FILE.LERNA;
62
87
  } else if (useYarnWorkspaces(rootPath)) {
63
- return _constants.WORKSPACE_FILE.YARN;
88
+ return import_constants.WORKSPACE_FILE.YARN;
64
89
  } else {
65
- throw new Error('[Auto Find Mode]: not find any monorepo workspace file, you can set `packagesMatchs.workspaceFile`');
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: [_constants.WORKSPACE_FILE.PNPM, 'pnpm-lock.yaml'],
71
- yarn: ['yarn.lock', useYarnWorkspaces],
96
+ pnpm: [import_constants.WORKSPACE_FILE.PNPM, "pnpm-lock.yaml"],
97
+ yarn: ["yarn.lock", useYarnWorkspaces],
72
98
  npm: [() => true]
73
99
  };
74
- exports.packageManagerFlag = packageManagerFlag;
75
- const usePnpmPackageManager = monorepoRootPath => packageManagerFlag.pnpm.some(flag => _nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, flag)));
76
- const useYarnPackageManager = monorepoRootPath => packageManagerFlag.yarn.some(flag => {
77
- if (typeof flag === 'function') {
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 _nodeCoreLibrary.FileSystem.exists(path.join(monorepoRootPath, flag));
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 'pnpm';
111
+ return "pnpm";
85
112
  } else if (useYarnPackageManager(monorepoRootPath)) {
86
- return 'yarn';
113
+ return "yarn";
87
114
  }
88
- return 'npm';
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('not find any monorepo, you can add lerna、pnpm or yarn workspace file');
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;
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ findMonorepoRoot,
132
+ getMonorepoBaseData,
133
+ getPackageManager,
134
+ getWorkspaceFile,
135
+ packageManagerFlag
136
+ });
@@ -1,100 +1,148 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 check_project_change_exports = {};
45
+ __export(check_project_change_exports, {
46
+ MONOREPO_GIT_FILE_NAME: () => MONOREPO_GIT_FILE_NAME,
47
+ PROJECT_CONTENT_FILE_NAME: () => PROJECT_CONTENT_FILE_NAME,
48
+ PROJECT_MEMORY_PATH: () => PROJECT_MEMORY_PATH,
49
+ checkProjectChangeByContent: () => checkProjectChangeByContent,
50
+ checkProjectChangeByGit: () => checkProjectChangeByGit
5
51
  });
6
- exports.checkProjectChangeByGit = exports.checkProjectChangeByContent = exports.PROJECT_MEMORY_PATH = exports.PROJECT_CONTENT_FILE_NAME = exports.MONOREPO_GIT_FILE_NAME = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _nodeCoreLibrary = require("@rushstack/node-core-library");
9
- var _packageDepsHash = require("@rushstack/package-deps-hash");
10
- var _utils = require("@modern-js/utils");
11
- var _md = _interopRequireDefault(require("md5"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- 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); }
14
- 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; }
15
- const PROJECT_CONTENT_FILE_NAME = 'project-content.json';
16
- exports.PROJECT_CONTENT_FILE_NAME = PROJECT_CONTENT_FILE_NAME;
17
- const MONOREPO_GIT_FILE_NAME = 'monorepo-git.json';
18
- exports.MONOREPO_GIT_FILE_NAME = MONOREPO_GIT_FILE_NAME;
19
- const PROJECT_MEMORY_PATH = '.project-memory';
20
- exports.PROJECT_MEMORY_PATH = PROJECT_MEMORY_PATH;
21
- const getProjectGitHash = async project => {
52
+ module.exports = __toCommonJS(check_project_change_exports);
53
+ var path = __toESM(require("path"));
54
+ var import_node_core_library = require("@rushstack/node-core-library");
55
+ var import_package_deps_hash = require("@rushstack/package-deps-hash");
56
+ var import_utils = require("@modern-js/utils");
57
+ var import_md5 = __toESM(require("md5"));
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: ['**/node_modules/**', '.project-memory/**', 'dist/**']
68
+ ignore: ["**/node_modules/**", ".project-memory/**", "dist/**"]
29
69
  };
30
70
  const globPattern = `${projectDir}/**`;
31
- const files = await (0, _utils.globby)(path.posix.join(globPattern), globOption);
32
- const hashMap = (0, _packageDepsHash.getGitHashForFiles)(files, projectDir);
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, _md.default)(_nodeCoreLibrary.JsonFile.stringify(hashObject));
41
- };
42
- const checkProjectChangeByGit = async (project, rootPath) => {
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 = await getProjectGitHash(project);
45
- if (!_nodeCoreLibrary.FileSystem.exists(monorepoGitMemory)) {
46
- _nodeCoreLibrary.FileSystem.writeFile(monorepoGitMemory, _nodeCoreLibrary.JsonFile.stringify({}), {
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 = _nodeCoreLibrary.JsonFile.load(monorepoGitMemory);
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
- _nodeCoreLibrary.FileSystem.writeFile(monorepoGitMemory, _nodeCoreLibrary.JsonFile.stringify(monorepoProjectHashJson), {
55
- ensureFolderExists: true
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
- exports.checkProjectChangeByGit = checkProjectChangeByGit;
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: ['**/node_modules/**', '.project-memory/**', '**/dist/**']
107
+ ignore: ["**/node_modules/**", ".project-memory/**", "**/dist/**"]
69
108
  };
70
109
  const globPattern = `${projectDir}/**`;
71
- const files = await (0, _utils.globby)(path.posix.join(globPattern), globOption);
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, _md.default)(_nodeCoreLibrary.FileSystem.readFile(file));
113
+ hashObject[file] = (0, import_md5.default)(import_node_core_library.FileSystem.readFile(file));
76
114
  }
77
115
  return hashObject;
78
- };
79
- const checkProjectChangeByContent = async project => {
116
+ });
117
+ const checkProjectChangeByContent = (project) => __async(void 0, null, function* () {
80
118
  const projectDir = project.extra.path;
81
- const projectMemoryFolder = path.resolve(projectDir, '.project-memory');
82
- const projectJsonFile = path.join(projectMemoryFolder, PROJECT_CONTENT_FILE_NAME);
83
- const currentHashObject = await getProjectContentHashObjectForFiles(project);
84
- const currentHashString = _nodeCoreLibrary.JsonFile.stringify(currentHashObject);
85
- if (!_nodeCoreLibrary.FileSystem.exists(projectJsonFile)) {
86
- _nodeCoreLibrary.FileSystem.writeFile(projectJsonFile, currentHashString, {
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 = _nodeCoreLibrary.JsonFile.load(projectJsonFile);
92
- const changed = _nodeCoreLibrary.JsonFile.stringify(localHashObject) !== currentHashString;
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
- _nodeCoreLibrary.FileSystem.writeFile(projectJsonFile, currentHashString, {
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
+ });
141
+ // Annotate the CommonJS export names for ESM import in node:
142
+ 0 && (module.exports = {
143
+ MONOREPO_GIT_FILE_NAME,
144
+ PROJECT_CONTENT_FILE_NAME,
145
+ PROJECT_MEMORY_PATH,
146
+ checkProjectChangeByContent,
147
+ checkProjectChangeByGit
148
+ });
@@ -1,19 +1,46 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 clear_memory_files_exports = {};
25
+ __export(clear_memory_files_exports, {
26
+ clearProjectsMemoryFile: () => clearProjectsMemoryFile
5
27
  });
6
- exports.clearProjectsMemoryFile = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _nodeCoreLibrary = require("@rushstack/node-core-library");
9
- var _checkProjectChange = require("./check-project-change");
10
- 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); }
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(clear_memory_files_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(project.extra.path, _checkProjectChange.PROJECT_MEMORY_PATH, _checkProjectChange.PROJECT_CONTENT_FILE_NAME);
15
- console.info('remove', memoryFilePath);
16
- _nodeCoreLibrary.FileSystem.deleteFile(memoryFilePath);
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;
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ clearProjectsMemoryFile
46
+ });