@modern-js/monorepo-tools 1.3.3-beta.2 → 1.4.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 (40) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/js/modern/cli/build-watch.js +3 -3
  3. package/dist/js/modern/cli/build.js +2 -2
  4. package/dist/js/modern/cli/clear.js +2 -2
  5. package/dist/js/modern/cli/deploy.js +4 -2
  6. package/dist/js/modern/cli/install.js +2 -2
  7. package/dist/js/modern/commands/build-watch.js +2 -4
  8. package/dist/js/modern/commands/build.js +2 -4
  9. package/dist/js/modern/commands/clear.js +3 -5
  10. package/dist/js/modern/commands/deploy.js +7 -7
  11. package/dist/js/modern/commands/install.js +2 -4
  12. package/dist/js/modern/features/deploy/index.js +2 -1
  13. package/dist/js/modern/hooks/index.js +5 -0
  14. package/dist/js/modern/index.js +22 -30
  15. package/dist/js/node/cli/build-watch.js +3 -3
  16. package/dist/js/node/cli/build.js +2 -2
  17. package/dist/js/node/cli/clear.js +2 -2
  18. package/dist/js/node/cli/deploy.js +4 -2
  19. package/dist/js/node/cli/install.js +2 -2
  20. package/dist/js/node/commands/build-watch.js +2 -5
  21. package/dist/js/node/commands/build.js +2 -5
  22. package/dist/js/node/commands/clear.js +3 -6
  23. package/dist/js/node/commands/deploy.js +7 -8
  24. package/dist/js/node/commands/install.js +2 -5
  25. package/dist/js/node/features/deploy/index.js +2 -1
  26. package/dist/js/node/hooks/index.js +14 -0
  27. package/dist/js/node/index.js +22 -34
  28. package/dist/types/cli/build-watch.d.ts +2 -1
  29. package/dist/types/cli/build.d.ts +2 -1
  30. package/dist/types/cli/clear.d.ts +2 -1
  31. package/dist/types/cli/deploy.d.ts +2 -1
  32. package/dist/types/cli/install.d.ts +2 -1
  33. package/dist/types/commands/build-watch.d.ts +2 -1
  34. package/dist/types/commands/build.d.ts +2 -1
  35. package/dist/types/commands/clear.d.ts +2 -1
  36. package/dist/types/commands/deploy.d.ts +2 -1
  37. package/dist/types/commands/install.d.ts +2 -1
  38. package/dist/types/hooks/index.d.ts +7 -0
  39. package/dist/types/index.d.ts +2 -3
  40. package/package.json +7 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @modern-js/monorepo-tools
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 57419eb4: convert to new plugin
8
+ - Updated dependencies [05ce88a0]
9
+ - Updated dependencies [a8df060e]
10
+ - Updated dependencies [c2046f37]
11
+ - Updated dependencies [dc88abf9]
12
+ - Updated dependencies [0462ff77]
13
+ - Updated dependencies [61e3f623]
14
+ - Updated dependencies [6a7acb81]
15
+ - Updated dependencies [681a1ff9]
16
+ - Updated dependencies [4e2026e4]
17
+ - @modern-js/core@1.6.0
18
+ - @modern-js/utils@1.3.6
19
+ - @modern-js/plugin@1.3.2
20
+ - @modern-js/plugin-changeset@1.2.3
21
+
22
+ ## 1.4.0
23
+
24
+ ### Minor Changes
25
+
26
+ - e37ea5b2: feat: add afterMonorepoDeploy hook
27
+
28
+ ### Patch Changes
29
+
30
+ - 55e18278: chore: remove unused dependencies and devDependencies
31
+ - edc3bd3d: fix: @modern-js/core package not found
32
+ - Updated dependencies [969f172f]
33
+ - Updated dependencies [4c792f68]
34
+ - Updated dependencies [83059b93]
35
+ - Updated dependencies [4b5d4bf4]
36
+ - Updated dependencies [62f5b8c8]
37
+ - Updated dependencies [55e18278]
38
+ - Updated dependencies [4499a674]
39
+ - Updated dependencies [403f5169]
40
+ - Updated dependencies [a7f42f48]
41
+ - Updated dependencies [83059b93]
42
+ - @modern-js/core@1.4.4
43
+ - @modern-js/utils@1.3.3
44
+ - @modern-js/new-action@1.3.3
45
+
3
46
  ## 1.3.2
4
47
 
5
48
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import { buildWatch } from "../commands";
2
- export const buildWatchCli = program => {
3
- program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependences').action(async (targetProjectName, option) => {
4
- await buildWatch(targetProjectName, option);
2
+ export const buildWatchCli = (program, api) => {
3
+ program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependencies').action(async (targetProjectName, option) => {
4
+ await buildWatch(targetProjectName, option, api);
5
5
  });
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { build } from "../commands";
2
- export const buildCli = program => {
2
+ export const buildCli = (program, api) => {
3
3
  program.command('build [project]').usage('[options]').option('--no-self', 'build without target project').option('-t, --dept', 'build target project with project’s dependent').option('--no-deps', 'build target project without project’s dependences').option('--only-self', 'build target project with nothing').option('-a, --all', 'build target project with project’s dependences and dependent').option('--content-hash', 'build target project use content hash cache').option('--git-hash', 'build target project use git hash cache').description('build target project').action(async (targetProjectName, option) => {
4
- await build(targetProjectName, option);
4
+ await build(targetProjectName, option, api);
5
5
  });
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { clear } from "../commands";
2
- export const clearCli = program => {
2
+ export const clearCli = (program, api) => {
3
3
  program.command('clear [projects...]').usage('[options]').option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules').description('clear project dirs').action(async (targetProjectNames, option) => {
4
- await clear(targetProjectNames, option);
4
+ await clear(targetProjectNames, option, api);
5
5
  });
6
6
  };
@@ -1,6 +1,8 @@
1
1
  import { deploy } from "../commands";
2
- export const deployCli = program => {
2
+ export const deployCli = (program, api) => {
3
3
  program.command('deploy [project...]').usage('[options]').option('-p, --path [path]', 'Specify the path of the product output', 'output').description('deploy project').action(async (deployProjectNames, option) => {
4
- await deploy(deployProjectNames, option);
4
+ // 在查找 workspace 下项目时,默认忽略 output 下面的项目
5
+ const ignoreMatchs = ['**/output/**'];
6
+ await deploy(api, deployProjectNames, option, ignoreMatchs);
5
7
  });
6
8
  };
@@ -1,6 +1,6 @@
1
1
  import { install } from "../commands";
2
- export const installCli = program => {
2
+ export const installCli = (program, api) => {
3
3
  program.command('install [project...]').usage('[options]').description('install deps for some projects').action(async (installProjectNames, option) => {
4
- await install(installProjectNames, option);
4
+ await install(installProjectNames, option, api);
5
5
  });
6
6
  };
@@ -1,13 +1,11 @@
1
- import { useAppContext } from '@modern-js/core';
2
1
  import { getMonorepoBaseData } from "../parse-config/monorepo";
3
2
  import { runBuildWatchTask } from "../features/dev";
4
3
  import { getProjects } from "../projects/get-projects";
5
4
  import { initDAG } from "../dag";
6
- export const buildWatch = async (targetProjectName, option) => {
7
- // eslint-disable-next-line react-hooks/rules-of-hooks
5
+ export const buildWatch = async (targetProjectName, option, api) => {
8
6
  const {
9
7
  appDirectory
10
- } = useAppContext();
8
+ } = api.useAppContext();
11
9
  const {
12
10
  onlySelf = false,
13
11
  init = false
@@ -4,17 +4,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
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
- import { useAppContext } from '@modern-js/core';
8
7
  import { getMonorepoBaseData } from "../parse-config/monorepo";
9
8
  import { runBuildTask, runAllBuildTask } from "../features/build";
10
9
  import { getProjects } from "../projects/get-projects";
11
10
  import { initDAG } from "../dag"; // import { clearProjectsMemoryFile } from './projects/clear-memory-files';
12
11
 
13
- export const build = async (targetProjectName, option) => {
14
- // eslint-disable-next-line react-hooks/rules-of-hooks
12
+ export const build = async (targetProjectName, option, api) => {
15
13
  const {
16
14
  appDirectory
17
- } = useAppContext();
15
+ } = api.useAppContext();
18
16
  const {
19
17
  self = true,
20
18
  dept = false,
@@ -1,15 +1,13 @@
1
- import { useAppContext } from '@modern-js/core';
2
1
  import { getProjects } from "../projects/get-projects";
3
2
  import { getMonorepoBaseData } from "../parse-config/monorepo";
4
3
  import { runClearTask } from "../features/clear";
5
- export const clear = async (projectNames, option) => {
4
+ export const clear = async (projectNames, option, api) => {
6
5
  const {
7
6
  removeDirs
8
- } = option; // eslint-disable-next-line react-hooks/rules-of-hooks
9
-
7
+ } = option;
10
8
  const {
11
9
  appDirectory
12
- } = useAppContext();
10
+ } = api.useAppContext();
13
11
  const projects = await getProjects({
14
12
  packagesMatchs: {
15
13
  enableAutoFinder: true
@@ -1,22 +1,21 @@
1
- import { useAppContext, mountHook } from '@modern-js/core';
2
1
  import { logger } from '@modern-js/utils';
3
2
  import { initDAG } from "../dag";
4
3
  import { getMonorepoBaseData } from "../parse-config/monorepo";
5
4
  import { getProjects } from "../projects/get-projects";
6
5
  import { deploy as runDeployTask } from "../features/deploy";
7
- export const deploy = async (deployProjectNames, option) => {
6
+ export const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
8
7
  const {
9
8
  deployPath = 'output'
10
- } = option; // eslint-disable-next-line react-hooks/rules-of-hooks
11
-
9
+ } = option;
12
10
  const {
13
11
  appDirectory
14
- } = useAppContext();
12
+ } = api.useAppContext();
15
13
  logger.info(`start deploy ${deployProjectNames.join(',')}`);
16
14
  const projects = await getProjects({
17
15
  packagesMatchs: {
18
16
  enableAutoFinder: true
19
- }
17
+ },
18
+ packagesIgnoreMatchs: ignoreMatchs
20
19
  }, appDirectory);
21
20
  const {
22
21
  rootPath,
@@ -28,7 +27,8 @@ export const deploy = async (deployProjectNames, option) => {
28
27
  packageManager,
29
28
  deployPath
30
29
  });
31
- mountHook().afterMonorepoDeploy({
30
+ const runners = api.useHookRunners();
31
+ runners.afterMonorepoDeploy({
32
32
  operator,
33
33
  deployProjectNames
34
34
  });
@@ -1,13 +1,11 @@
1
- import { useAppContext } from '@modern-js/core';
2
1
  import { runInstallTask } from "../features/install";
3
2
  import { getMonorepoBaseData } from "../parse-config/monorepo";
4
3
  import { getProjects } from "../projects/get-projects";
5
4
  import { initDAG } from "../dag";
6
- export const install = async (projectNames = [], option) => {
7
- // eslint-disable-next-line react-hooks/rules-of-hooks
5
+ export const install = async (projectNames = [], option, api) => {
8
6
  const {
9
7
  appDirectory
10
- } = useAppContext();
8
+ } = api.useAppContext();
11
9
  const {
12
10
  auto
13
11
  } = option;
@@ -103,7 +103,8 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
103
103
  (_childProcess$stderr = childProcess.stderr) === null || _childProcess$stderr === void 0 ? void 0 : _childProcess$stderr.pipe(process.stderr);
104
104
  await childProcess;
105
105
  }
106
- };
106
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
+
107
108
 
108
109
  const installDependency = async (deployDir, packageManager) => {
109
110
  // TODO: 使用公共方法替换
@@ -0,0 +1,5 @@
1
+ import { createAsyncWorkflow } from '@modern-js/plugin';
2
+ const afterMonorepoDeploy = createAsyncWorkflow();
3
+ export const hooks = {
4
+ afterMonorepoDeploy
5
+ };
@@ -1,35 +1,27 @@
1
- import { createPlugin, usePlugins, defineConfig, registerHook } from '@modern-js/core';
2
- import { createAsyncWorkflow } from '@modern-js/plugin';
1
+ import ChangesetPlugin from '@modern-js/plugin-changeset';
3
2
  import { i18n } from "./locale";
4
3
  import { newCli, deployCli, clearCli } from "./cli";
5
4
  import { getLocaleLanguage } from "./utils/language";
6
- export { defineConfig };
7
- const afterMonorepoDeploy = createAsyncWorkflow();
5
+ import { hooks } from "./hooks";
6
+ export default (() => ({
7
+ name: '@modern-js/monorepo-tools',
8
+ usePlugins: [ChangesetPlugin()],
9
+ registerHook: hooks,
10
+ setup: api => {
11
+ const locale = getLocaleLanguage();
12
+ i18n.changeLanguage({
13
+ locale
14
+ });
15
+ return {
16
+ commands({
17
+ program
18
+ }) {
19
+ clearCli(program, api);
20
+ deployCli(program, api);
21
+ newCli(program, locale);
22
+ }
8
23
 
9
- const lifecycle = () => {
10
- registerHook({
11
- afterMonorepoDeploy
12
- });
13
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
14
-
15
-
16
- usePlugins([require.resolve('@modern-js/plugin-changeset/cli')]);
17
- export default createPlugin(() => {
18
- lifecycle();
19
- const locale = getLocaleLanguage();
20
- i18n.changeLanguage({
21
- locale
22
- });
23
- return {
24
- commands({
25
- program
26
- }) {
27
- clearCli(program);
28
- deployCli(program);
29
- newCli(program, locale);
30
- }
31
-
32
- };
33
- }, {
24
+ };
25
+ },
34
26
  post: ['@modern-js/plugin-changeset']
35
- });
27
+ }));
@@ -7,9 +7,9 @@ exports.buildWatchCli = void 0;
7
7
 
8
8
  var _commands = require("../commands");
9
9
 
10
- const buildWatchCli = program => {
11
- program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependences').action(async (targetProjectName, option) => {
12
- await (0, _commands.buildWatch)(targetProjectName, option);
10
+ const buildWatchCli = (program, api) => {
11
+ program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependencies').action(async (targetProjectName, option) => {
12
+ await (0, _commands.buildWatch)(targetProjectName, option, api);
13
13
  });
14
14
  };
15
15
 
@@ -7,9 +7,9 @@ exports.buildCli = void 0;
7
7
 
8
8
  var _commands = require("../commands");
9
9
 
10
- const buildCli = program => {
10
+ const buildCli = (program, api) => {
11
11
  program.command('build [project]').usage('[options]').option('--no-self', 'build without target project').option('-t, --dept', 'build target project with project’s dependent').option('--no-deps', 'build target project without project’s dependences').option('--only-self', 'build target project with nothing').option('-a, --all', 'build target project with project’s dependences and dependent').option('--content-hash', 'build target project use content hash cache').option('--git-hash', 'build target project use git hash cache').description('build target project').action(async (targetProjectName, option) => {
12
- await (0, _commands.build)(targetProjectName, option);
12
+ await (0, _commands.build)(targetProjectName, option, api);
13
13
  });
14
14
  };
15
15
 
@@ -7,9 +7,9 @@ exports.clearCli = void 0;
7
7
 
8
8
  var _commands = require("../commands");
9
9
 
10
- const clearCli = program => {
10
+ const clearCli = (program, api) => {
11
11
  program.command('clear [projects...]').usage('[options]').option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules').description('clear project dirs').action(async (targetProjectNames, option) => {
12
- await (0, _commands.clear)(targetProjectNames, option);
12
+ await (0, _commands.clear)(targetProjectNames, option, api);
13
13
  });
14
14
  };
15
15
 
@@ -7,9 +7,11 @@ exports.deployCli = void 0;
7
7
 
8
8
  var _commands = require("../commands");
9
9
 
10
- const deployCli = program => {
10
+ const deployCli = (program, api) => {
11
11
  program.command('deploy [project...]').usage('[options]').option('-p, --path [path]', 'Specify the path of the product output', 'output').description('deploy project').action(async (deployProjectNames, option) => {
12
- await (0, _commands.deploy)(deployProjectNames, option);
12
+ // 在查找 workspace 下项目时,默认忽略 output 下面的项目
13
+ const ignoreMatchs = ['**/output/**'];
14
+ await (0, _commands.deploy)(api, deployProjectNames, option, ignoreMatchs);
13
15
  });
14
16
  };
15
17
 
@@ -7,9 +7,9 @@ exports.installCli = void 0;
7
7
 
8
8
  var _commands = require("../commands");
9
9
 
10
- const installCli = program => {
10
+ const installCli = (program, api) => {
11
11
  program.command('install [project...]').usage('[options]').description('install deps for some projects').action(async (installProjectNames, option) => {
12
- await (0, _commands.install)(installProjectNames, option);
12
+ await (0, _commands.install)(installProjectNames, option, api);
13
13
  });
14
14
  };
15
15
 
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildWatch = void 0;
7
7
 
8
- var _core = require("@modern-js/core");
9
-
10
8
  var _monorepo = require("../parse-config/monorepo");
11
9
 
12
10
  var _dev = require("../features/dev");
@@ -15,11 +13,10 @@ var _getProjects = require("../projects/get-projects");
15
13
 
16
14
  var _dag = require("../dag");
17
15
 
18
- const buildWatch = async (targetProjectName, option) => {
19
- // eslint-disable-next-line react-hooks/rules-of-hooks
16
+ const buildWatch = async (targetProjectName, option, api) => {
20
17
  const {
21
18
  appDirectory
22
- } = (0, _core.useAppContext)();
19
+ } = api.useAppContext();
23
20
  const {
24
21
  onlySelf = false,
25
22
  init = false
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.build = void 0;
7
7
 
8
- var _core = require("@modern-js/core");
9
-
10
8
  var _monorepo = require("../parse-config/monorepo");
11
9
 
12
10
  var _build = require("../features/build");
@@ -21,11 +19,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
21
19
 
22
20
  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; }
23
21
 
24
- const build = async (targetProjectName, option) => {
25
- // eslint-disable-next-line react-hooks/rules-of-hooks
22
+ const build = async (targetProjectName, option, api) => {
26
23
  const {
27
24
  appDirectory
28
- } = (0, _core.useAppContext)();
25
+ } = api.useAppContext();
29
26
  const {
30
27
  self = true,
31
28
  dept = false,
@@ -5,22 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.clear = void 0;
7
7
 
8
- var _core = require("@modern-js/core");
9
-
10
8
  var _getProjects = require("../projects/get-projects");
11
9
 
12
10
  var _monorepo = require("../parse-config/monorepo");
13
11
 
14
12
  var _clear = require("../features/clear");
15
13
 
16
- const clear = async (projectNames, option) => {
14
+ const clear = async (projectNames, option, api) => {
17
15
  const {
18
16
  removeDirs
19
- } = option; // eslint-disable-next-line react-hooks/rules-of-hooks
20
-
17
+ } = option;
21
18
  const {
22
19
  appDirectory
23
- } = (0, _core.useAppContext)();
20
+ } = api.useAppContext();
24
21
  const projects = await (0, _getProjects.getProjects)({
25
22
  packagesMatchs: {
26
23
  enableAutoFinder: true
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.deploy = void 0;
7
7
 
8
- var _core = require("@modern-js/core");
9
-
10
8
  var _utils = require("@modern-js/utils");
11
9
 
12
10
  var _dag = require("../dag");
@@ -17,21 +15,21 @@ var _getProjects = require("../projects/get-projects");
17
15
 
18
16
  var _deploy = require("../features/deploy");
19
17
 
20
- const deploy = async (deployProjectNames, option) => {
18
+ const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
21
19
  const {
22
20
  deployPath = 'output'
23
- } = option; // eslint-disable-next-line react-hooks/rules-of-hooks
24
-
21
+ } = option;
25
22
  const {
26
23
  appDirectory
27
- } = (0, _core.useAppContext)();
24
+ } = api.useAppContext();
28
25
 
29
26
  _utils.logger.info(`start deploy ${deployProjectNames.join(',')}`);
30
27
 
31
28
  const projects = await (0, _getProjects.getProjects)({
32
29
  packagesMatchs: {
33
30
  enableAutoFinder: true
34
- }
31
+ },
32
+ packagesIgnoreMatchs: ignoreMatchs
35
33
  }, appDirectory);
36
34
  const {
37
35
  rootPath,
@@ -43,7 +41,8 @@ const deploy = async (deployProjectNames, option) => {
43
41
  packageManager,
44
42
  deployPath
45
43
  });
46
- (0, _core.mountHook)().afterMonorepoDeploy({
44
+ const runners = api.useHookRunners();
45
+ runners.afterMonorepoDeploy({
47
46
  operator,
48
47
  deployProjectNames
49
48
  });
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.install = void 0;
7
7
 
8
- var _core = require("@modern-js/core");
9
-
10
8
  var _install = require("../features/install");
11
9
 
12
10
  var _monorepo = require("../parse-config/monorepo");
@@ -15,11 +13,10 @@ var _getProjects = require("../projects/get-projects");
15
13
 
16
14
  var _dag = require("../dag");
17
15
 
18
- const install = async (projectNames = [], option) => {
19
- // eslint-disable-next-line react-hooks/rules-of-hooks
16
+ const install = async (projectNames = [], option, api) => {
20
17
  const {
21
18
  appDirectory
22
- } = (0, _core.useAppContext)();
19
+ } = api.useAppContext();
23
20
  const {
24
21
  auto
25
22
  } = option;
@@ -124,7 +124,8 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
124
124
  (_childProcess$stderr = childProcess.stderr) === null || _childProcess$stderr === void 0 ? void 0 : _childProcess$stderr.pipe(process.stderr);
125
125
  await childProcess;
126
126
  }
127
- };
127
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
128
+
128
129
 
129
130
  const installDependency = async (deployDir, packageManager) => {
130
131
  // TODO: 使用公共方法替换
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hooks = void 0;
7
+
8
+ var _plugin = require("@modern-js/plugin");
9
+
10
+ const afterMonorepoDeploy = (0, _plugin.createAsyncWorkflow)();
11
+ const hooks = {
12
+ afterMonorepoDeploy
13
+ };
14
+ exports.hooks = hooks;
@@ -4,16 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- Object.defineProperty(exports, "defineConfig", {
8
- enumerable: true,
9
- get: function () {
10
- return _core.defineConfig;
11
- }
12
- });
13
-
14
- var _core = require("@modern-js/core");
15
7
 
16
- var _plugin = require("@modern-js/plugin");
8
+ var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changeset"));
17
9
 
18
10
  var _locale = require("./locale");
19
11
 
@@ -21,36 +13,32 @@ var _cli = require("./cli");
21
13
 
22
14
  var _language = require("./utils/language");
23
15
 
24
- const afterMonorepoDeploy = (0, _plugin.createAsyncWorkflow)();
25
-
26
- const lifecycle = () => {
27
- (0, _core.registerHook)({
28
- afterMonorepoDeploy
29
- });
30
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
31
-
16
+ var _hooks = require("./hooks");
32
17
 
33
- (0, _core.usePlugins)([require.resolve('@modern-js/plugin-changeset/cli')]);
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
19
 
35
- var _default = (0, _core.createPlugin)(() => {
36
- lifecycle();
37
- const locale = (0, _language.getLocaleLanguage)();
20
+ var _default = () => ({
21
+ name: '@modern-js/monorepo-tools',
22
+ usePlugins: [(0, _pluginChangeset.default)()],
23
+ registerHook: _hooks.hooks,
24
+ setup: api => {
25
+ const locale = (0, _language.getLocaleLanguage)();
38
26
 
39
- _locale.i18n.changeLanguage({
40
- locale
41
- });
27
+ _locale.i18n.changeLanguage({
28
+ locale
29
+ });
42
30
 
43
- return {
44
- commands({
45
- program
46
- }) {
47
- (0, _cli.clearCli)(program);
48
- (0, _cli.deployCli)(program);
49
- (0, _cli.newCli)(program, locale);
50
- }
31
+ return {
32
+ commands({
33
+ program
34
+ }) {
35
+ (0, _cli.clearCli)(program, api);
36
+ (0, _cli.deployCli)(program, api);
37
+ (0, _cli.newCli)(program, locale);
38
+ }
51
39
 
52
- };
53
- }, {
40
+ };
41
+ },
54
42
  post: ['@modern-js/plugin-changeset']
55
43
  });
56
44
 
@@ -1,2 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  import { Command } from 'commander';
2
- export declare const buildWatchCli: (program: Command) => void;
3
+ export declare const buildWatchCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  import { Command } from 'commander';
2
- export declare const buildCli: (program: Command) => void;
3
+ export declare const buildCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
1
  import { Command } from 'commander';
2
- export declare const clearCli: (program: Command) => void;
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const clearCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
1
  import { Command } from 'commander';
2
- export declare const deployCli: (program: Command) => void;
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const deployCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  import { Command } from 'commander';
2
- export declare const installCli: (program: Command) => void;
3
+ export declare const installCli: (program: Command, api: PluginAPI) => void;
@@ -1,5 +1,6 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IBuildWatchCommandOption {
2
3
  onlySelf?: boolean;
3
4
  init?: boolean;
4
5
  }
5
- export declare const buildWatch: (targetProjectName: string, option: IBuildWatchCommandOption) => Promise<void>;
6
+ export declare const buildWatch: (targetProjectName: string, option: IBuildWatchCommandOption, api: PluginAPI) => Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IBuildCommandOption {
2
3
  self?: boolean;
3
4
  dept?: boolean;
@@ -7,4 +8,4 @@ export interface IBuildCommandOption {
7
8
  contentHash?: boolean;
8
9
  gitHash?: boolean;
9
10
  }
10
- export declare const build: (targetProjectName: string, option: IBuildCommandOption) => Promise<void>;
11
+ export declare const build: (targetProjectName: string, option: IBuildCommandOption, api: PluginAPI) => Promise<void>;
@@ -1,4 +1,5 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IClearCommandOption {
2
3
  removeDirs?: string[];
3
4
  }
4
- export declare const clear: (projectNames: string[], option: IClearCommandOption) => Promise<void>;
5
+ export declare const clear: (projectNames: string[], option: IClearCommandOption, api: PluginAPI) => Promise<void>;
@@ -1,4 +1,5 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IDeployCommandOption {
2
3
  deployPath?: string;
3
4
  }
4
- export declare const deploy: (deployProjectNames: string[], option: IDeployCommandOption) => Promise<void>;
5
+ export declare const deploy: (api: PluginAPI, deployProjectNames: string[], option: IDeployCommandOption, ignoreMatchs?: string[]) => Promise<void>;
@@ -1,4 +1,5 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IInstallCommandOption {
2
3
  auto?: boolean;
3
4
  }
4
- export declare const install: (projectNames: string[] | undefined, option: IInstallCommandOption) => Promise<void>;
5
+ export declare const install: (projectNames: string[] | undefined, option: IInstallCommandOption, api: PluginAPI) => Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { DagOperator } from '../dag/operator';
2
+ export declare const hooks: {
3
+ afterMonorepoDeploy: import("@modern-js/plugin").AsyncWorkflow<{
4
+ operator: DagOperator;
5
+ deployProjectNames: string[];
6
+ }, void>;
7
+ };
@@ -1,6 +1,5 @@
1
- import { defineConfig } from '@modern-js/core';
2
- export { defineConfig };
1
+ import type { CliPlugin } from '@modern-js/core';
3
2
 
4
- declare const _default: any;
3
+ declare const _default: () => CliPlugin;
5
4
 
6
5
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.3-beta.2",
14
+ "version": "1.4.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -35,13 +35,14 @@
35
35
  "modern": "./bin/modern.js"
36
36
  },
37
37
  "dependencies": {
38
+ "@modern-js/core": "^1.6.0",
38
39
  "@babel/runtime": "^7",
39
40
  "@modern-js/i18n-cli-language-detector": "^1.2.1",
40
- "@modern-js/new-action": "^1.3.2",
41
- "@modern-js/plugin": "^1.2.1",
42
- "@modern-js/plugin-changeset": "^1.2.2",
41
+ "@modern-js/new-action": "^1.3.3",
42
+ "@modern-js/plugin": "^1.3.2",
43
+ "@modern-js/plugin-changeset": "^1.2.3",
43
44
  "@modern-js/plugin-i18n": "^1.2.1",
44
- "@modern-js/utils": "^1.3.2",
45
+ "@modern-js/utils": "^1.3.6",
45
46
  "@rushstack/node-core-library": "^3.39.1",
46
47
  "@rushstack/package-deps-hash": "^3.0.54",
47
48
  "anymatch": "^3.1.2",
@@ -54,11 +55,7 @@
54
55
  "p-map": "^4.0.0",
55
56
  "signale": "^1.4.0"
56
57
  },
57
- "peerDependencies": {
58
- "@modern-js/core": "^1.4.3"
59
- },
60
58
  "devDependencies": {
61
- "@modern-js/core": "^1.4.3",
62
59
  "@scripts/build": "0.0.0",
63
60
  "@scripts/jest-config": "0.0.0",
64
61
  "@types/jest": "^26",
@@ -80,8 +77,7 @@
80
77
  },
81
78
  "publishConfig": {
82
79
  "registry": "https://registry.npmjs.org/",
83
- "access": "public",
84
- "types": "./dist/types/index.d.ts"
80
+ "access": "public"
85
81
  },
86
82
  "scripts": {
87
83
  "new": "modern new",