@modern-js/monorepo-tools 2.0.0-beta.3 → 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.
Files changed (104) hide show
  1. package/CHANGELOG.md +51 -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 +47 -10
  52. package/dist/js/node/cli/build.js +48 -10
  53. package/dist/js/node/cli/clear.js +47 -10
  54. package/dist/js/node/cli/deploy.js +52 -12
  55. package/dist/js/node/cli/index.js +22 -71
  56. package/dist/js/node/cli/install.js +47 -10
  57. package/dist/js/node/cli/new.js +73 -19
  58. package/dist/js/node/commands/build-watch.js +55 -29
  59. package/dist/js/node/commands/build.js +72 -32
  60. package/dist/js/node/commands/clear.js +53 -25
  61. package/dist/js/node/commands/deploy.js +61 -35
  62. package/dist/js/node/commands/index.js +21 -60
  63. package/dist/js/node/commands/install.js +55 -28
  64. package/dist/js/node/constants.js +28 -13
  65. package/dist/js/node/dag/create.js +44 -28
  66. package/dist/js/node/dag/edge-manager.js +21 -8
  67. package/dist/js/node/dag/index.js +26 -13
  68. package/dist/js/node/dag/operator.js +209 -174
  69. package/dist/js/node/dag/task.js +88 -46
  70. package/dist/js/node/dag/utils.js +51 -47
  71. package/dist/js/node/features/build/index.js +79 -47
  72. package/dist/js/node/features/clear/index.js +44 -28
  73. package/dist/js/node/features/deploy/index.js +135 -104
  74. package/dist/js/node/features/dev/cmds.js +22 -9
  75. package/dist/js/node/features/dev/create-task.js +75 -51
  76. package/dist/js/node/features/dev/index.js +94 -58
  77. package/dist/js/node/features/dev/watch-projects-state.js +69 -30
  78. package/dist/js/node/features/install/index.js +78 -41
  79. package/dist/js/node/hooks/index.js +23 -8
  80. package/dist/js/node/index.js +51 -32
  81. package/dist/js/node/locale/en.js +26 -11
  82. package/dist/js/node/locale/index.js +27 -15
  83. package/dist/js/node/locale/zh.js +27 -12
  84. package/dist/js/node/log/error.js +22 -7
  85. package/dist/js/node/log/multi-tasks-log.js +44 -41
  86. package/dist/js/node/log/time.js +43 -18
  87. package/dist/js/node/log/utils.js +26 -10
  88. package/dist/js/node/package/index.js +21 -10
  89. package/dist/js/node/parse-config/index.js +73 -30
  90. package/dist/js/node/parse-config/monorepo.js +71 -44
  91. package/dist/js/node/projects/check-project-change.js +96 -56
  92. package/dist/js/node/projects/clear-memory-files.js +38 -15
  93. package/dist/js/node/projects/get-projects-by-packages-config.js +116 -65
  94. package/dist/js/node/projects/get-projects-by-workspace-file.js +103 -55
  95. package/dist/js/node/projects/get-projects.js +109 -61
  96. package/dist/js/node/type.js +0 -5
  97. package/dist/js/node/utils/install.js +63 -31
  98. package/dist/js/node/utils/language.js +24 -8
  99. package/dist/types/dag/operator.d.ts +3 -0
  100. package/dist/types/dag/utils.d.ts +1 -0
  101. package/dist/types/features/dev/index.d.ts +1 -0
  102. package/dist/types/index.d.ts +2 -0
  103. package/dist/types/projects/get-projects.d.ts +1 -0
  104. package/package.json +12 -19
@@ -1,40 +1,72 @@
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 stdin_exports = {};
25
+ __export(stdin_exports, {
26
+ installByPackageManager: () => installByPackageManager,
27
+ removeLockFile: () => removeLockFile
5
28
  });
6
- exports.removeLockFile = exports.installByPackageManager = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _utils = require("@modern-js/utils");
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; }
29
+ module.exports = __toCommonJS(stdin_exports);
30
+ var path = __toESM(require("path"));
31
+ var import_utils = require("@modern-js/utils");
32
+ var import_constants = require("../constants");
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
12
53
  const removeLockFile = (rootPath, packageManager) => {
13
- if (packageManager === 'pnpm') {
14
- _utils.fs.removeSync(path.join(rootPath, _constants.LOCK_FILE.PNPM));
15
- } else if (packageManager === 'yarn') {
16
- _utils.fs.removeSync(path.join(rootPath, _constants.LOCK_FILE.YARN));
17
- } else if (packageManager === 'npm') {
18
- _utils.fs.removeSync(path.join(rootPath, _constants.LOCK_FILE.NPM));
54
+ if (packageManager === "pnpm") {
55
+ import_utils.fs.removeSync(path.join(rootPath, import_constants.LOCK_FILE.PNPM));
56
+ } else if (packageManager === "yarn") {
57
+ import_utils.fs.removeSync(path.join(rootPath, import_constants.LOCK_FILE.YARN));
58
+ } else if (packageManager === "npm") {
59
+ import_utils.fs.removeSync(path.join(rootPath, import_constants.LOCK_FILE.NPM));
19
60
  }
20
61
  };
21
- exports.removeLockFile = removeLockFile;
22
- const installByPackageManager = async (packageManager, {
23
- rootPath,
24
- removeLock
25
- }) => {
62
+ const installByPackageManager = (_0, _1) => __async(void 0, [_0, _1], function* (packageManager, { rootPath, removeLock }) {
26
63
  if (removeLock) {
27
64
  removeLockFile(rootPath, packageManager);
28
65
  }
29
- if (packageManager === 'pnpm') {
30
- await (0, _utils.execa)('pnpm', ['install'], {
31
- stdio: 'inherit'
32
- });
66
+ if (packageManager === "pnpm") {
67
+ yield (0, import_utils.execa)("pnpm", ["install"], { stdio: "inherit" });
33
68
  }
34
- if (packageManager === 'yarn') {
35
- await (0, _utils.execa)('yarn', ['install'], {
36
- stdio: 'inherit'
37
- });
69
+ if (packageManager === "yarn") {
70
+ yield (0, import_utils.execa)("yarn", ["install"], { stdio: "inherit" });
38
71
  }
39
- };
40
- exports.installByPackageManager = installByPackageManager;
72
+ });
@@ -1,11 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ getLocaleLanguage: () => getLocaleLanguage
5
21
  });
6
- exports.getLocaleLanguage = getLocaleLanguage;
7
- var _languageDetector = require("@modern-js/plugin-i18n/language-detector");
22
+ module.exports = __toCommonJS(stdin_exports);
23
+ var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
8
24
  function getLocaleLanguage() {
9
- const detector = new _languageDetector.I18CLILanguageDetector();
25
+ const detector = new import_language_detector.I18CLILanguageDetector();
10
26
  return detector.detect();
11
- }
27
+ }
@@ -31,6 +31,7 @@ export declare class DagOperator {
31
31
  * 3. 检查是否存在 dependencyEdge === 0 的节点,加入叶子节点集合 A中。
32
32
  * 4. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
33
33
  */
34
+
34
35
  traverseProjectToDependent(name: string, task: Task, {
35
36
  withSelf,
36
37
  runTaskConcurrency
@@ -42,6 +43,7 @@ export declare class DagOperator {
42
43
  * 4. 检查 B 集合中是否存在入度为0的节点,则此节点为叶子节点,并加入叶子节点集合 A
43
44
  * 5. 根据情况(是否存在空闲的进程)选择是否执行新加入的节点对应的任务。
44
45
  */
46
+
45
47
  traverseDependenciesToProject(name: string, task: Task, {
46
48
  withSelf,
47
49
  runTaskConcurrency
@@ -56,6 +58,7 @@ export declare class DagOperator {
56
58
  /**
57
59
  * Checks for projects that indirectly depend on themselves.
58
60
  */
61
+
59
62
  private _checkForCyclicDependencies;
60
63
  private _getDependencyLeafNodes;
61
64
  private readonly _createTask;
@@ -3,6 +3,7 @@ import { IProjectNode } from '../projects/get-projects';
3
3
  * Calculate the number of packages which must be built before we reach
4
4
  * the furthest away "root" node
5
5
  */
6
+
6
7
  export declare const calculateCriticalPaths: (project: IProjectNode) => number;
7
8
  export declare const recursiveGetDependency: (project: IProjectNode, skipCircleProjects?: boolean) => IProjectNode[];
8
9
  export declare const sortProjects: (projects: IProjectNode[]) => IProjectNode[][];
@@ -17,6 +17,7 @@ export interface IProjectChangeResult {
17
17
  /**
18
18
  * Contains the git hashes for all tracked files in the repo
19
19
  */
20
+
20
21
  state: any;
21
22
  }
22
23
  export declare const runBuildWatchTask: (projectName: string, operator: DagOperator, config: IBuildWatchConfig, taskCmds?: BuildWatchCmdsType) => Promise<void>;
@@ -1,4 +1,6 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
2
  import { MonorepoTools } from './type';
3
+
3
4
  declare const _default: () => CliPlugin<MonorepoTools>;
5
+
4
6
  export default _default;
@@ -10,6 +10,7 @@ export interface IFindSubProjectConfig {
10
10
  /**
11
11
  * https://github.com/mrmlnc/fast-glob#ignore
12
12
  */
13
+
13
14
  packagesIgnoreMatchs?: string[];
14
15
  }
15
16
  export interface IProjectNode {
package/package.json CHANGED
@@ -11,12 +11,10 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.3",
14
+ "version": "2.0.0-beta.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
18
- "module": "./dist/js/treeshaking/index.js",
19
- "jsnext:modern": "./dist/js/modern/index.js",
20
18
  "exports": {
21
19
  ".": {
22
20
  "node": {
@@ -24,7 +22,7 @@
24
22
  "import": "./dist/js/modern/index.js",
25
23
  "require": "./dist/js/node/index.js"
26
24
  },
27
- "default": "./dist/js/treeshaking/index.js"
25
+ "default": "./dist/js/node/index.js"
28
26
  },
29
27
  "./cli": {
30
28
  "jsnext:source": "./src/index.ts",
@@ -41,14 +39,14 @@
41
39
  "anymatch": "^3.1.2",
42
40
  "md5": "^2.3.0",
43
41
  "p-map": "^4.0.0",
44
- "@modern-js/core": "2.0.0-beta.3",
45
- "@modern-js/new-action": "2.0.0-beta.3",
46
- "@modern-js/upgrade": "2.0.0-beta.3",
47
- "@modern-js/plugin": "2.0.0-beta.3",
48
- "@modern-js/plugin-changeset": "2.0.0-beta.3",
49
- "@modern-js/plugin-i18n": "2.0.0-beta.3",
50
- "@modern-js/plugin-lint": "2.0.0-beta.3",
51
- "@modern-js/utils": "2.0.0-beta.3"
42
+ "@modern-js/core": "2.0.0-beta.4",
43
+ "@modern-js/new-action": "2.0.0-beta.4",
44
+ "@modern-js/upgrade": "2.0.0-beta.4",
45
+ "@modern-js/plugin": "2.0.0-beta.4",
46
+ "@modern-js/plugin-changeset": "2.0.0-beta.4",
47
+ "@modern-js/plugin-i18n": "2.0.0-beta.4",
48
+ "@modern-js/plugin-lint": "2.0.0-beta.4",
49
+ "@modern-js/utils": "2.0.0-beta.4"
52
50
  },
53
51
  "devDependencies": {
54
52
  "@types/jest": "^27",
@@ -56,15 +54,10 @@
56
54
  "@types/node": "^14",
57
55
  "jest": "^27",
58
56
  "typescript": "^4",
59
- "@scripts/build": "2.0.0-beta.3",
60
- "@scripts/jest-config": "2.0.0-beta.3"
57
+ "@scripts/build": "2.0.0-beta.4",
58
+ "@scripts/jest-config": "2.0.0-beta.4"
61
59
  },
62
60
  "sideEffects": false,
63
- "modernConfig": {
64
- "output": {
65
- "packageMode": "node-js"
66
- }
67
- },
68
61
  "publishConfig": {
69
62
  "registry": "https://registry.npmjs.org/",
70
63
  "access": "public"