@modern-js/monorepo-tools 1.1.2-rc.0 → 1.3.1

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 (74) hide show
  1. package/CHANGELOG.md +52 -14
  2. package/dist/js/modern/cli/new.js +4 -1
  3. package/dist/js/modern/dag/operator.js +1 -1
  4. package/dist/js/modern/dag/utils.js +1 -1
  5. package/dist/js/modern/locale/en.js +1 -0
  6. package/dist/js/modern/locale/zh.js +1 -0
  7. package/dist/js/modern/projects/get-projects-by-workspace-file.js +1 -1
  8. package/dist/js/node/cli/new.js +4 -1
  9. package/dist/js/node/dag/operator.js +2 -2
  10. package/dist/js/node/dag/utils.js +2 -2
  11. package/dist/js/node/locale/en.js +1 -0
  12. package/dist/js/node/locale/zh.js +1 -0
  13. package/dist/js/node/projects/get-projects-by-workspace-file.js +2 -2
  14. package/dist/types/dag/edge-manager.d.ts +1 -1
  15. package/dist/types/dag/index.d.ts +1 -1
  16. package/dist/types/dag/utils.d.ts +1 -1
  17. package/dist/types/features/deploy/index.d.ts +2 -2
  18. package/dist/types/features/dev/cmds.d.ts +1 -1
  19. package/dist/types/locale/en.d.ts +1 -0
  20. package/dist/types/locale/index.d.ts +2 -0
  21. package/dist/types/locale/zh.d.ts +1 -0
  22. package/dist/types/package/index.d.ts +1 -1
  23. package/jest.config.js +8 -0
  24. package/package.json +18 -12
  25. package/tests/index.test.ts +7 -0
  26. package/tsconfig.json +1 -3
  27. package/src/cli/build-watch.ts +0 -16
  28. package/src/cli/build.ts +0 -22
  29. package/src/cli/clear.ts +0 -15
  30. package/src/cli/deploy.ts +0 -20
  31. package/src/cli/index.ts +0 -6
  32. package/src/cli/install.ts +0 -14
  33. package/src/cli/new.ts +0 -17
  34. package/src/commands/build-watch.ts +0 -34
  35. package/src/commands/build.ts +0 -73
  36. package/src/commands/clear.ts +0 -26
  37. package/src/commands/deploy.ts +0 -32
  38. package/src/commands/index.ts +0 -5
  39. package/src/commands/install.ts +0 -32
  40. package/src/constants.ts +0 -11
  41. package/src/dag/create.ts +0 -61
  42. package/src/dag/edge-manager.ts +0 -37
  43. package/src/dag/index.ts +0 -9
  44. package/src/dag/operator.ts +0 -340
  45. package/src/dag/task.ts +0 -74
  46. package/src/dag/utils.ts +0 -135
  47. package/src/features/build/index.ts +0 -134
  48. package/src/features/clear/index.ts +0 -43
  49. package/src/features/deploy/index.ts +0 -211
  50. package/src/features/dev/cmds.ts +0 -9
  51. package/src/features/dev/create-task.ts +0 -121
  52. package/src/features/dev/index.ts +0 -124
  53. package/src/features/dev/watch-projects-state.ts +0 -75
  54. package/src/features/install/index.ts +0 -87
  55. package/src/index.ts +0 -25
  56. package/src/locale/en.ts +0 -11
  57. package/src/locale/index.ts +0 -9
  58. package/src/locale/zh.ts +0 -11
  59. package/src/log/error.ts +0 -3
  60. package/src/log/multi-tasks-log.ts +0 -112
  61. package/src/log/time.ts +0 -12
  62. package/src/log/utils.ts +0 -11
  63. package/src/package/index.ts +0 -31
  64. package/src/parse-config/index.ts +0 -26
  65. package/src/parse-config/monorepo.ts +0 -124
  66. package/src/projects/check-project-change.ts +0 -116
  67. package/src/projects/clear-memory-files.ts +0 -19
  68. package/src/projects/get-projects-by-packages-config.ts +0 -150
  69. package/src/projects/get-projects-by-workspace-file.ts +0 -106
  70. package/src/projects/get-projects.ts +0 -221
  71. package/src/type.ts +0 -10
  72. package/src/utils/install.ts +0 -36
  73. package/src/utils/language.ts +0 -6
  74. package/src/utils/types.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,22 +1,60 @@
1
1
  # @modern-js/monorepo-tools
2
2
 
3
- ## 1.1.2-rc.0
3
+ ## 1.3.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [d927bc83]
8
- - Updated dependencies [d73ff455]
9
- - Updated dependencies [9c1ab865]
10
- - Updated dependencies [d73ff455]
11
- - Updated dependencies [d73ff455]
12
- - Updated dependencies [d73ff455]
13
- - Updated dependencies [d73ff455]
14
- - @modern-js/utils@1.1.4-rc.0
15
- - @modern-js/core@1.1.4-rc.0
16
- - @modern-js/plugin-changeset@1.1.2-rc.0
17
- - @modern-js/i18n-cli-language-detector@1.1.1
18
- - @modern-js/plugin-i18n@1.1.1
19
- - @modern-js/new-action@1.1.6-rc.0
7
+ - 83166714: change .npmignore
8
+ - Updated dependencies [83166714]
9
+ - Updated dependencies [c3de9882]
10
+ - Updated dependencies [33ff48af]
11
+ - @modern-js/core@1.3.2
12
+ - @modern-js/i18n-cli-language-detector@1.2.1
13
+ - @modern-js/plugin-changeset@1.2.1
14
+ - @modern-js/plugin-i18n@1.2.1
15
+ - @modern-js/new-action@1.3.1
16
+ - @modern-js/utils@1.2.2
17
+
18
+ ## 1.3.0
19
+
20
+ ### Minor Changes
21
+
22
+ - cfe11628: Make Modern.js self bootstraping
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [2da09c69]
27
+ - Updated dependencies [fc71e36f]
28
+ - Updated dependencies [2c049918]
29
+ - Updated dependencies [c3d46ee4]
30
+ - Updated dependencies [cfe11628]
31
+ - Updated dependencies [1ebc7ee2]
32
+ - @modern-js/utils@1.2.0
33
+ - @modern-js/core@1.3.0
34
+ - @modern-js/new-action@1.3.0
35
+ - @modern-js/i18n-cli-language-detector@1.2.0
36
+ - @modern-js/plugin-changeset@1.2.0
37
+ - @modern-js/plugin-i18n@1.2.0
38
+
39
+ ## 1.2.0
40
+
41
+ ### Minor Changes
42
+
43
+ - e12b3d0b: feat: support generator plugin
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [90eeb72c]
48
+ - Updated dependencies [e04914ce]
49
+ - Updated dependencies [e12b3d0b]
50
+ - Updated dependencies [e12b3d0b]
51
+ - Updated dependencies [5a4c557e]
52
+ - Updated dependencies [e04914ce]
53
+ - Updated dependencies [ca7dcb32]
54
+ - Updated dependencies [ecb344dc]
55
+ - @modern-js/core@1.2.0
56
+ - @modern-js/new-action@1.2.0
57
+ - @modern-js/utils@1.1.5
20
58
 
21
59
  ## 1.1.1
22
60
 
@@ -7,7 +7,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import { MonorepoNewAction } from '@modern-js/new-action';
8
8
  import { i18n, localeKeys } from "../locale";
9
9
  export const newCli = (program, locale) => {
10
- program.command('new').usage('[options]').description(i18n.t(localeKeys.command.new.describe)).option('-d, --debug', i18n.t(localeKeys.command.new.debug), false).option('-c, --config <config>', i18n.t(localeKeys.command.new.config)).option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag)).option('--registry', i18n.t(localeKeys.command.new.registry)).action(async options => {
10
+ program.command('new').usage('[options]').description(i18n.t(localeKeys.command.new.describe)).option('-d, --debug', i18n.t(localeKeys.command.new.debug), false).option('-c, --config <config>', i18n.t(localeKeys.command.new.config)).option('-p, --plugin <plugin>', i18n.t(localeKeys.command.new.plugin), (val, memo) => {
11
+ memo.push(val);
12
+ return memo;
13
+ }, []).option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag)).option('--registry', i18n.t(localeKeys.command.new.registry)).action(async options => {
11
14
  await MonorepoNewAction(_objectSpread(_objectSpread({}, options), {}, {
12
15
  locale
13
16
  }));
@@ -5,10 +5,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import pMap from 'p-map';
8
+ import { errorLog } from "../log/error";
8
9
  import { TaskRunner } from "./task";
9
10
  import { EdgeManager } from "./edge-manager";
10
11
  import { recursiveGetDependency, sortProjects } from "./utils";
11
- import { errorLog } from "../log/error";
12
12
  export class DagOperator {
13
13
  // 排序好的项目列表
14
14
  constructor(projects, projectsMap) {
@@ -1,5 +1,5 @@
1
- import { EdgeManager } from "./edge-manager";
2
1
  import { errorLog } from "../log/error";
2
+ import { EdgeManager } from "./edge-manager";
3
3
  /**
4
4
  * Calculate the number of packages which must be built before we reach
5
5
  * the furthest away "root" node
@@ -4,6 +4,7 @@ export const EN_LOCALE = {
4
4
  describe: 'generator runner for monorepo project',
5
5
  debug: 'using debug mode to log something',
6
6
  config: 'set default generator config(json string)',
7
+ plugin: 'use generator plugin to create new sub-solution project or customize Modern.js sub-solution project',
7
8
  distTag: `use specified tag version for it's generator`,
8
9
  registry: 'set npm registry url to run npm command'
9
10
  }
@@ -4,6 +4,7 @@ export const ZH_LOCALE = {
4
4
  describe: 'Monorepo 创建子项目',
5
5
  debug: '开启 Debug 模式,打印调试日志信息',
6
6
  config: '生成器运行默认配置(JSON 字符串)',
7
+ plugin: '使用生成器插件创建新的工程方案子项目或定制化 Modern.js 工程方案子项目',
7
8
  distTag: '生成器使用特殊的 npm Tag 版本',
8
9
  registry: '生成器运行过程中定制 npm Registry'
9
10
  }
@@ -3,8 +3,8 @@ import { FileSystem, JsonFile } from '@rushstack/node-core-library';
3
3
  import { fs } from '@modern-js/utils';
4
4
  import yaml from 'js-yaml';
5
5
  import { getWorkspaceFile } from "../parse-config/monorepo";
6
- import { getProjetsByPackageConfig, syncGetProjetsByPackageConfig } from "./get-projects-by-packages-config";
7
6
  import { WORKSPACE_FILE } from "../constants";
7
+ import { getProjetsByPackageConfig, syncGetProjetsByPackageConfig } from "./get-projects-by-packages-config";
8
8
  export const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
9
9
  var _config$workspaceFile;
10
10
 
@@ -16,7 +16,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
16
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
17
 
18
18
  const newCli = (program, locale) => {
19
- program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('--dist-tag <tag>', _locale.i18n.t(_locale.localeKeys.command.new.distTag)).option('--registry', _locale.i18n.t(_locale.localeKeys.command.new.registry)).action(async options => {
19
+ program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('-p, --plugin <plugin>', _locale.i18n.t(_locale.localeKeys.command.new.plugin), (val, memo) => {
20
+ memo.push(val);
21
+ return memo;
22
+ }, []).option('--dist-tag <tag>', _locale.i18n.t(_locale.localeKeys.command.new.distTag)).option('--registry', _locale.i18n.t(_locale.localeKeys.command.new.registry)).action(async options => {
20
23
  await (0, _newAction.MonorepoNewAction)(_objectSpread(_objectSpread({}, options), {}, {
21
24
  locale
22
25
  }));
@@ -7,14 +7,14 @@ exports.DagOperator = void 0;
7
7
 
8
8
  var _pMap = _interopRequireDefault(require("p-map"));
9
9
 
10
+ var _error = require("../log/error");
11
+
10
12
  var _task = require("./task");
11
13
 
12
14
  var _edgeManager = require("./edge-manager");
13
15
 
14
16
  var _utils = require("./utils");
15
17
 
16
- var _error = require("../log/error");
17
-
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
20
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.sortProjects = exports.recursiveGetDependency = exports.findCircle = exports.calculateCriticalPaths = void 0;
7
7
 
8
- var _edgeManager = require("./edge-manager");
9
-
10
8
  var _error = require("../log/error");
11
9
 
10
+ var _edgeManager = require("./edge-manager");
11
+
12
12
  /**
13
13
  * Calculate the number of packages which must be built before we reach
14
14
  * the furthest away "root" node
@@ -10,6 +10,7 @@ const EN_LOCALE = {
10
10
  describe: 'generator runner for monorepo project',
11
11
  debug: 'using debug mode to log something',
12
12
  config: 'set default generator config(json string)',
13
+ plugin: 'use generator plugin to create new sub-solution project or customize Modern.js sub-solution project',
13
14
  distTag: `use specified tag version for it's generator`,
14
15
  registry: 'set npm registry url to run npm command'
15
16
  }
@@ -10,6 +10,7 @@ const ZH_LOCALE = {
10
10
  describe: 'Monorepo 创建子项目',
11
11
  debug: '开启 Debug 模式,打印调试日志信息',
12
12
  config: '生成器运行默认配置(JSON 字符串)',
13
+ plugin: '使用生成器插件创建新的工程方案子项目或定制化 Modern.js 工程方案子项目',
13
14
  distTag: '生成器使用特殊的 npm Tag 版本',
14
15
  registry: '生成器运行过程中定制 npm Registry'
15
16
  }
@@ -15,10 +15,10 @@ var _jsYaml = _interopRequireDefault(require("js-yaml"));
15
15
 
16
16
  var _monorepo = require("../parse-config/monorepo");
17
17
 
18
- var _getProjectsByPackagesConfig = require("./get-projects-by-packages-config");
19
-
20
18
  var _constants = require("../constants");
21
19
 
20
+ var _getProjectsByPackagesConfig = require("./get-projects-by-packages-config");
21
+
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
24
  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); }
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from "../projects/get-projects.d";
1
+ import { IProjectNode } from '../projects/get-projects';
2
2
  export declare class EdgeManager {
3
3
  private _dependencyEdgeHash;
4
4
  constructor();
@@ -1,3 +1,3 @@
1
+ import { IProjectNode } from '../projects/get-projects';
1
2
  import { DagOperator } from './operator';
2
- import { IProjectNode } from "../projects/get-projects.d";
3
3
  export declare const initDAG: (projects: IProjectNode[]) => DagOperator;
@@ -1,4 +1,4 @@
1
- import { IProjectNode } from "../projects/get-projects.d";
1
+ import { IProjectNode } from '../projects/get-projects';
2
2
  /**
3
3
  * Calculate the number of packages which must be built before we reach
4
4
  * the furthest away "root" node
@@ -1,5 +1,5 @@
1
- import { DagOperator } from "../../dag/operator.d";
2
- import { PackageManagerType } from "../../parse-config";
1
+ import { DagOperator } from '../../dag/operator';
2
+ import { PackageManagerType } from '../../parse-config';
3
3
  interface IDeployConfig {
4
4
  rootPath: string;
5
5
  packageManager: PackageManagerType;
@@ -1,3 +1,3 @@
1
- import { IProjectNode } from "../../projects/get-projects.d";
1
+ import { IProjectNode } from '../../projects/get-projects';
2
2
  export declare type BuildWatchCmdsType = [string] | [string, string] | [string, (project: IProjectNode) => string[]];
3
3
  export declare const defaultBuildWatchCmds: BuildWatchCmdsType;
@@ -4,6 +4,7 @@ export declare const EN_LOCALE: {
4
4
  describe: string;
5
5
  debug: string;
6
6
  config: string;
7
+ plugin: string;
7
8
  distTag: string;
8
9
  registry: string;
9
10
  };
@@ -6,6 +6,7 @@ declare const localeKeys: {
6
6
  describe: string;
7
7
  debug: string;
8
8
  config: string;
9
+ plugin: string;
9
10
  distTag: string;
10
11
  registry: string;
11
12
  };
@@ -16,6 +17,7 @@ declare const localeKeys: {
16
17
  describe: string;
17
18
  debug: string;
18
19
  config: string;
20
+ plugin: string;
19
21
  distTag: string;
20
22
  registry: string;
21
23
  };
@@ -4,6 +4,7 @@ export declare const ZH_LOCALE: {
4
4
  describe: string;
5
5
  debug: string;
6
6
  config: string;
7
+ plugin: string;
7
8
  distTag: string;
8
9
  registry: string;
9
10
  };
@@ -6,5 +6,5 @@ export declare class Package {
6
6
  constructor(packageJson: INodePackageJson, packageConfigPath: string, rootPath: string);
7
7
  get name(): string;
8
8
  get path(): string;
9
- get(key: keyof INodePackageJson): string | boolean | import("@rushstack/node-core-library").IPackageJsonRepository | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").IPackageJsonScriptTable | Record<string, string> | undefined;
9
+ get(key: keyof INodePackageJson): string | boolean | Record<string, string> | import("@rushstack/node-core-library").IPackageJsonDependencyTable | import("@rushstack/node-core-library").IPackageJsonRepository | import("@rushstack/node-core-library").IPackageJsonScriptTable | undefined;
10
10
  }
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ const sharedConfig = require('@scripts/jest-config');
2
+
3
+ /** @type {import('@jest/types').Config.InitialOptions} */
4
+ module.exports = {
5
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
+ ...sharedConfig,
7
+ rootDir: __dirname,
8
+ };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.2-rc.0",
14
+ "version": "1.3.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -20,25 +20,29 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "node": {
23
+ "jsnext:source": "./src/index.ts",
23
24
  "import": "./dist/js/modern/index.js",
24
25
  "require": "./dist/js/node/index.js"
25
26
  },
26
27
  "default": "./dist/js/treeshaking/index.js"
27
28
  },
28
- "./cli": "./dist/js/node/index.js"
29
+ "./cli": {
30
+ "jsnext:source": "./src/index.ts",
31
+ "default": "./dist/js/node/index.js"
32
+ }
29
33
  },
30
34
  "bin": {
31
35
  "modern": "./bin/modern.js"
32
36
  },
33
37
  "dependencies": {
34
38
  "@babel/runtime": "^7",
35
- "@modern-js/core": "^1.1.4-rc.0",
36
- "@modern-js/i18n-cli-language-detector": "^1.1.1",
37
- "@modern-js/new-action": "^1.1.6-rc.0",
38
- "@modern-js/plugin-changeset": "^1.1.2-rc.0",
39
- "@modern-js/plugin-i18n": "^1.1.1",
39
+ "@modern-js/core": "^1.3.2",
40
+ "@modern-js/i18n-cli-language-detector": "^1.2.1",
41
+ "@modern-js/new-action": "^1.3.1",
42
+ "@modern-js/plugin-changeset": "^1.2.1",
43
+ "@modern-js/plugin-i18n": "^1.2.1",
40
44
  "commander": "^8.1.0",
41
- "@modern-js/utils": "^1.1.4-rc.0",
45
+ "@modern-js/utils": "^1.2.2",
42
46
  "@rushstack/node-core-library": "^3.39.1",
43
47
  "@rushstack/package-deps-hash": "^3.0.54",
44
48
  "anymatch": "^3.1.2",
@@ -61,8 +65,9 @@
61
65
  "@types/signale": "^1.4.2",
62
66
  "execa": "^5.1.1",
63
67
  "typescript": "^4",
64
- "@modern-js/plugin-testing": "^1.1.1",
65
- "@modern-js/module-tools": "^1.1.1"
68
+ "@scripts/build": "0.0.0",
69
+ "jest": "^27",
70
+ "@scripts/jest-config": "0.0.0"
66
71
  },
67
72
  "sideEffects": false,
68
73
  "modernConfig": {
@@ -72,12 +77,13 @@
72
77
  },
73
78
  "publishConfig": {
74
79
  "registry": "https://registry.npmjs.org/",
75
- "access": "public"
80
+ "access": "public",
81
+ "types": "./dist/types/index.d.ts"
76
82
  },
77
83
  "scripts": {
78
84
  "new": "modern new",
79
85
  "build": "modern build",
80
- "test": "modern test --passWithNoTests"
86
+ "test": "jest --passWithNoTests"
81
87
  },
82
88
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
83
89
  }
@@ -0,0 +1,7 @@
1
+ import plugin from '../src';
2
+
3
+ describe('monorepo-tools', () => {
4
+ it('default', () => {
5
+ expect(plugin).toBeDefined();
6
+ });
7
+ });
package/tsconfig.json CHANGED
@@ -5,9 +5,7 @@
5
5
  "jsx": "preserve",
6
6
  "baseUrl": "./",
7
7
  "isolatedModules": true,
8
- "paths": {
9
- "@/*": ["./src/*"]
10
- }
8
+ "paths": {}
11
9
  },
12
10
  "include": ["src"]
13
11
  }
@@ -1,16 +0,0 @@
1
- import { Command } from 'commander';
2
- import { buildWatch, IBuildWatchCommandOption } from '../commands';
3
-
4
- export const buildWatchCli = (program: Command) => {
5
- program
6
- .command('build-watch [project]')
7
- .usage('[options]')
8
- .option('--only-self', 'build target project with nothing')
9
- .option('-i, --init', 'init build beforebuild watch ')
10
- .description('watch target project and target project’s dependences')
11
- .action(
12
- async (targetProjectName: string, option: IBuildWatchCommandOption) => {
13
- await buildWatch(targetProjectName, option);
14
- },
15
- );
16
- };
package/src/cli/build.ts DELETED
@@ -1,22 +0,0 @@
1
- import { Command } from 'commander';
2
- import { build, IBuildCommandOption } from '../commands';
3
-
4
- export const buildCli = (program: Command) => {
5
- program
6
- .command('build [project]')
7
- .usage('[options]')
8
- .option('--no-self', 'build without target project')
9
- .option('-t, --dept', 'build target project with project’s dependent')
10
- .option('--no-deps', 'build target project without project’s dependences')
11
- .option('--only-self', 'build target project with nothing')
12
- .option(
13
- '-a, --all',
14
- 'build target project with project’s dependences and dependent',
15
- )
16
- .option('--content-hash', 'build target project use content hash cache')
17
- .option('--git-hash', 'build target project use git hash cache')
18
- .description('build target project')
19
- .action(async (targetProjectName: string, option: IBuildCommandOption) => {
20
- await build(targetProjectName, option);
21
- });
22
- };
package/src/cli/clear.ts DELETED
@@ -1,15 +0,0 @@
1
- import { Command } from 'commander';
2
- import { clear, IClearCommandOption } from '../commands';
3
-
4
- export const clearCli = (program: Command) => {
5
- program
6
- .command('clear [projects...]')
7
- .usage('[options]')
8
- .option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules')
9
- .description('clear project dirs')
10
- .action(
11
- async (targetProjectNames: string[], option: IClearCommandOption) => {
12
- await clear(targetProjectNames, option);
13
- },
14
- );
15
- };
package/src/cli/deploy.ts DELETED
@@ -1,20 +0,0 @@
1
- import { Command } from 'commander';
2
- import { deploy } from '../commands';
3
- import type { IDeployCommandOption } from '../commands';
4
-
5
- export const deployCli = (program: Command) => {
6
- program
7
- .command('deploy [project...]')
8
- .usage('[options]')
9
- .option(
10
- '-p, --path [path]',
11
- 'Specify the path of the product output',
12
- 'output',
13
- )
14
- .description('deploy project')
15
- .action(
16
- async (deployProjectNames: string[], option: IDeployCommandOption) => {
17
- await deploy(deployProjectNames, option);
18
- },
19
- );
20
- };
package/src/cli/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './new';
2
- export * from './deploy';
3
- export * from './build';
4
- export * from './build-watch';
5
- export * from './clear';
6
- export * from './install';
@@ -1,14 +0,0 @@
1
- import { Command } from 'commander';
2
- import { install, IInstallCommandOption } from '../commands';
3
-
4
- export const installCli = (program: Command) => {
5
- program
6
- .command('install [project...]')
7
- .usage('[options]')
8
- .description('install deps for some projects')
9
- .action(
10
- async (installProjectNames: string[], option: IInstallCommandOption) => {
11
- await install(installProjectNames, option);
12
- },
13
- );
14
- };
package/src/cli/new.ts DELETED
@@ -1,17 +0,0 @@
1
- import { Command } from 'commander';
2
- import { MonorepoNewAction } from '@modern-js/new-action';
3
- import { i18n, localeKeys } from '@/locale';
4
-
5
- export const newCli = (program: Command, locale?: string) => {
6
- program
7
- .command('new')
8
- .usage('[options]')
9
- .description(i18n.t(localeKeys.command.new.describe))
10
- .option('-d, --debug', i18n.t(localeKeys.command.new.debug), false)
11
- .option('-c, --config <config>', i18n.t(localeKeys.command.new.config))
12
- .option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag))
13
- .option('--registry', i18n.t(localeKeys.command.new.registry))
14
- .action(async options => {
15
- await MonorepoNewAction({ ...options, locale });
16
- });
17
- };
@@ -1,34 +0,0 @@
1
- import { useAppContext } from '@modern-js/core';
2
- import { getMonorepoBaseData } from '../parse-config/monorepo';
3
- import { runBuildWatchTask } from '../features/dev';
4
- import { getProjects } from '../projects/get-projects';
5
- import { initDAG } from '../dag';
6
-
7
- export interface IBuildWatchCommandOption {
8
- onlySelf?: boolean;
9
- init?: boolean;
10
- }
11
-
12
- export const buildWatch = async (
13
- targetProjectName: string,
14
- option: IBuildWatchCommandOption,
15
- ) => {
16
- // eslint-disable-next-line react-hooks/rules-of-hooks
17
- const { appDirectory } = useAppContext();
18
- const { onlySelf = false, init = false } = option;
19
- const projects = await getProjects(
20
- { packagesMatchs: { enableAutoFinder: true } },
21
- appDirectory,
22
- );
23
- const operator = initDAG(projects);
24
- operator.checkCircle();
25
-
26
- const { rootPath, packageManager } = getMonorepoBaseData(process.cwd());
27
-
28
- await runBuildWatchTask(targetProjectName, operator, {
29
- rootPath,
30
- packageManager,
31
- onlySelf,
32
- needInit: init,
33
- });
34
- };
@@ -1,73 +0,0 @@
1
- import { useAppContext } from '@modern-js/core';
2
- import { getMonorepoBaseData } from '../parse-config/monorepo';
3
- import { runBuildTask, runAllBuildTask } from '../features/build';
4
- import { getProjects } from '../projects/get-projects';
5
- import { initDAG } from '../dag';
6
- // import { clearProjectsMemoryFile } from './projects/clear-memory-files';
7
-
8
- export interface IBuildCommandOption {
9
- self?: boolean;
10
- dept?: boolean;
11
- deps?: boolean;
12
- onlySelf: boolean;
13
- all: boolean;
14
- contentHash?: boolean;
15
- gitHash?: boolean;
16
- }
17
-
18
- export const build = async (
19
- targetProjectName: string,
20
- option: IBuildCommandOption,
21
- ) => {
22
- // eslint-disable-next-line react-hooks/rules-of-hooks
23
- const { appDirectory } = useAppContext();
24
- const {
25
- self = true,
26
- dept = false,
27
- deps = true,
28
- onlySelf = false,
29
- all = false,
30
- contentHash = false,
31
- gitHash = false,
32
- } = option;
33
- const projects = await getProjects(
34
- { packagesMatchs: { enableAutoFinder: true } },
35
- appDirectory,
36
- );
37
- const operator = initDAG(projects);
38
- operator.checkCircle();
39
-
40
- const { rootPath, packageManager } = getMonorepoBaseData(appDirectory);
41
- const overrideConfig: Record<string, boolean> = {};
42
- if (all) {
43
- overrideConfig.disableWithDeps = false;
44
- overrideConfig.withSelf = true;
45
- overrideConfig.withDept = true;
46
- }
47
-
48
- if (targetProjectName) {
49
- runBuildTask(targetProjectName, operator, {
50
- rootPath,
51
- packageManager,
52
- withSelf: self,
53
- withDept: dept,
54
- onlySelf,
55
- disableWithDeps: !deps,
56
- // The CI/CD phase is recommended to be switched on
57
- disableContentHash: !contentHash,
58
- enableGitHash: gitHash,
59
- ...overrideConfig,
60
- });
61
- } else {
62
- const currentDir = process.cwd();
63
- if (currentDir === appDirectory) {
64
- await runAllBuildTask(operator, {
65
- rootPath: currentDir,
66
- packageManager,
67
- disableContentHash: !contentHash,
68
- enableGitHash: gitHash,
69
- });
70
- }
71
- // TODO: 没有指定项目名称的构建任务如何处理
72
- }
73
- };