@modern-js/monorepo-tools 1.3.3-beta.3 → 1.4.2

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 (61) hide show
  1. package/CHANGELOG.md +62 -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 +2 -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 +5 -6
  11. package/dist/js/modern/commands/install.js +2 -4
  12. package/dist/js/modern/dag/utils.js +0 -1
  13. package/dist/js/modern/features/build/index.js +2 -3
  14. package/dist/js/modern/features/deploy/index.js +3 -8
  15. package/dist/js/modern/features/dev/create-task.js +1 -2
  16. package/dist/js/modern/features/dev/index.js +1 -2
  17. package/dist/js/modern/features/install/index.js +3 -7
  18. package/dist/js/modern/hooks/index.js +2 -5
  19. package/dist/js/modern/index.js +22 -22
  20. package/dist/js/modern/log/multi-tasks-log.js +1 -1
  21. package/dist/js/modern/log/time.js +1 -1
  22. package/dist/js/modern/projects/get-projects-by-workspace-file.js +3 -6
  23. package/dist/js/modern/utils/install.js +1 -2
  24. package/dist/js/node/cli/build-watch.js +3 -3
  25. package/dist/js/node/cli/build.js +2 -2
  26. package/dist/js/node/cli/clear.js +2 -2
  27. package/dist/js/node/cli/deploy.js +2 -2
  28. package/dist/js/node/cli/install.js +2 -2
  29. package/dist/js/node/commands/build-watch.js +2 -5
  30. package/dist/js/node/commands/build.js +2 -5
  31. package/dist/js/node/commands/clear.js +3 -6
  32. package/dist/js/node/commands/deploy.js +5 -7
  33. package/dist/js/node/commands/install.js +2 -5
  34. package/dist/js/node/dag/utils.js +0 -1
  35. package/dist/js/node/features/build/index.js +5 -7
  36. package/dist/js/node/features/deploy/index.js +6 -16
  37. package/dist/js/node/features/dev/create-task.js +2 -6
  38. package/dist/js/node/features/dev/index.js +3 -5
  39. package/dist/js/node/features/install/index.js +4 -11
  40. package/dist/js/node/hooks/index.js +4 -10
  41. package/dist/js/node/index.js +25 -29
  42. package/dist/js/node/log/multi-tasks-log.js +4 -4
  43. package/dist/js/node/log/time.js +2 -2
  44. package/dist/js/node/projects/get-projects-by-workspace-file.js +4 -9
  45. package/dist/js/node/utils/install.js +2 -6
  46. package/dist/types/cli/build-watch.d.ts +3 -2
  47. package/dist/types/cli/build.d.ts +3 -2
  48. package/dist/types/cli/clear.d.ts +3 -2
  49. package/dist/types/cli/deploy.d.ts +3 -2
  50. package/dist/types/cli/install.d.ts +3 -2
  51. package/dist/types/cli/new.d.ts +1 -1
  52. package/dist/types/commands/build-watch.d.ts +2 -1
  53. package/dist/types/commands/build.d.ts +2 -1
  54. package/dist/types/commands/clear.d.ts +2 -1
  55. package/dist/types/commands/deploy.d.ts +2 -1
  56. package/dist/types/commands/install.d.ts +2 -1
  57. package/dist/types/hooks/index.d.ts +7 -1
  58. package/dist/types/index.d.ts +2 -3
  59. package/dist/types/log/time.d.ts +2 -2
  60. package/jest.config.js +0 -1
  61. package/package.json +9 -21
@@ -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;
@@ -72,7 +72,6 @@ const recursiveGetDependency = (project, skipCircleProjects = false) => {
72
72
 
73
73
  return allDependency;
74
74
  }; // 拓扑排序
75
- // eslint-disable-next-line max-statements
76
75
 
77
76
 
78
77
  exports.recursiveGetDependency = recursiveGetDependency;
@@ -7,9 +7,7 @@ exports.runBuildTask = exports.runAllBuildTask = void 0;
7
7
 
8
8
  var _os = _interopRequireDefault(require("os"));
9
9
 
10
- var _execa = _interopRequireDefault(require("execa"));
11
-
12
- var _signale = _interopRequireDefault(require("signale"));
10
+ var _utils = require("@modern-js/utils");
13
11
 
14
12
  var _checkProjectChange = require("../../projects/check-project-change");
15
13
 
@@ -25,7 +23,7 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
25
23
  packageManager,
26
24
  disableContentHash = false,
27
25
  enableGitHash = false
28
- } = config; // eslint-disable-next-line max-statements
26
+ } = config;
29
27
 
30
28
  const task = async project => {
31
29
  console.info('run ', project.name); // const taskTimeLog = timeLog.initTimeLog({ scope: '' });
@@ -56,10 +54,10 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
56
54
  if (cmd[taskCmd]) {
57
55
  const prefix = `run ${project.name} ${taskCmd} script`; // timeLog.startTime(taskTimeLog, prefix);
58
56
 
59
- _signale.default.time(prefix);
57
+ _utils.signale.time(prefix);
60
58
 
61
59
  try {
62
- const childProcess = (0, _execa.default)(packageManager, [taskCmd], {
60
+ const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
63
61
  cwd: project.extra.path,
64
62
  stdio: ['pipe', 'pipe', 'pipe']
65
63
  });
@@ -72,7 +70,7 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
72
70
  });
73
71
  await childProcess; // timeLog.endTime(taskTimeLog, prefix);
74
72
 
75
- _signale.default.timeEnd(prefix);
73
+ _utils.signale.timeEnd(prefix);
76
74
  } catch (e) {
77
75
  (0, _error.errorLog)(project.name, e.message);
78
76
  }
@@ -9,18 +9,10 @@ var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _nodeCoreLibrary = require("@rushstack/node-core-library");
11
11
 
12
- var _execa = _interopRequireDefault(require("execa"));
13
-
14
- var _signale = require("signale");
15
-
16
- var _jsYaml = _interopRequireDefault(require("js-yaml"));
17
-
18
12
  var _utils = require("@modern-js/utils");
19
13
 
20
14
  var _constants = require("../../constants");
21
15
 
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
16
  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); }
25
17
 
26
18
  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; }
@@ -58,15 +50,13 @@ const checkAndUpdatePMWorkspaces = deployDir => {
58
50
  const pnpmWp = path.join(deployDir, _constants.WORKSPACE_FILE.PNPM);
59
51
 
60
52
  if (_utils.fs.existsSync(pnpmWp)) {
61
- // eslint-disable-next-line import/no-named-as-default-member
62
- const pnpmWorkspace = _jsYaml.default.load(_utils.fs.readFileSync(pnpmWp, 'utf-8'));
53
+ const pnpmWorkspace = _utils.yaml.load(_utils.fs.readFileSync(pnpmWp, 'utf-8'));
63
54
 
64
55
  if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
65
56
  pnpmWorkspace.packages.push('apps/**');
66
- } // eslint-disable-next-line import/no-named-as-default-member
67
-
57
+ }
68
58
 
69
- _utils.fs.writeFileSync(pnpmWp, _jsYaml.default.dump(pnpmWorkspace));
59
+ _utils.fs.writeFileSync(pnpmWp, _utils.yaml.dump(pnpmWorkspace));
70
60
  }
71
61
 
72
62
  const pkgPath = path.join(deployDir, _constants.WORKSPACE_FILE.YARN);
@@ -116,7 +106,7 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
116
106
  }
117
107
 
118
108
  const cwd = packageManager === 'npm' ? targetProject.extra.path : monorepoPath;
119
- const childProcess = (0, _execa.default)(packageManager, runDeployCommands, {
109
+ const childProcess = (0, _utils.execa)(packageManager, runDeployCommands, {
120
110
  cwd,
121
111
  stdio: ['pipe']
122
112
  });
@@ -148,7 +138,7 @@ const installDependency = async (deployDir, packageManager) => {
148
138
 
149
139
  _utils.logger.log(_utils.chalk.rgb(218, 152, 92)('Install Log:\n'));
150
140
 
151
- const childProcess = (0, _execa.default)(packageManager, commands, {
141
+ const childProcess = (0, _utils.execa)(packageManager, commands, {
152
142
  stdio: 'inherit',
153
143
  cwd: deployDir,
154
144
  env: {
@@ -205,7 +195,7 @@ const deploy = async (deployProjectNames, operator, config) => {
205
195
 
206
196
  generatorAndCopyRequiredFiles(rootPath, realDeployPath); // await installDependency(realDeployPath, packageManager);
207
197
 
208
- (0, _signale.success)(`Deploy success. The deploy dir is in '${rootPath}/output'`);
198
+ _utils.signale.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
209
199
  };
210
200
 
211
201
  exports.deploy = deploy;
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createDevTask = exports.createDependenciesTask = void 0;
7
7
 
8
- var _execa = _interopRequireDefault(require("execa"));
9
-
10
8
  var _utils = require("@modern-js/utils");
11
9
 
12
10
  var _error = require("../../log/error");
@@ -19,8 +17,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
17
 
20
18
  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; }
21
19
 
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
20
  const getFinalTaskCmds = (taskCmds, project) => {
25
21
  let finalTaskCmds = []; // case1: ["build"]
26
22
  // case2: ["dev", "build"]
@@ -57,7 +53,7 @@ const createDependenciesTask = (config, taskCmds = _cmds.defaultBuildWatchCmds,
57
53
  timeLog.startTime(timelogInstance, prefix);
58
54
 
59
55
  try {
60
- const childProcess = (0, _execa.default)(packageManager, [taskCmd], {
56
+ const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
61
57
  cwd: project.extra.path,
62
58
  stdio: ['pipe', 'pipe', 'pipe']
63
59
  });
@@ -99,7 +95,7 @@ const createDevTask = (config, taskCmds = _cmds.defaultBuildWatchCmds, taskLogge
99
95
  // const prefix = `run ${project.name} ${taskCmd} script`;
100
96
  // log.info(prefix);
101
97
  try {
102
- const childProcess = (0, _execa.default)(packageManager, [taskCmd], {
98
+ const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
103
99
  cwd: project.extra.path,
104
100
  stdio: 'pipe',
105
101
  all: true
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.runBuildWatchTask = void 0;
7
7
 
8
- var _nodeCoreLibrary = require("@rushstack/node-core-library");
9
-
10
8
  var _anymatch = _interopRequireDefault(require("anymatch"));
11
9
 
10
+ var _utils = require("@modern-js/utils");
11
+
12
12
  var _multiTasksLog = require("../../log/multi-tasks-log");
13
13
 
14
14
  var _watchProjectsState = require("./watch-projects-state");
@@ -19,8 +19,6 @@ var _createTask = require("./create-task");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- const chokidar = _nodeCoreLibrary.Import.lazy('chokidar', require);
23
-
24
22
  const getIgnored = config => watchFilePath => {
25
23
  // 默认忽略 node_modules 的变化和 dist 目录下文件的变化
26
24
  const nodeModulesPattern = /(?:^|[\\/])node_modules/g;
@@ -45,7 +43,7 @@ const runBuildWatchTask = async (projectName, operator, config, taskCmds = _cmds
45
43
  const devTask = (0, _createTask.createDevTask)(config, taskCmds, taskLogger);
46
44
  const fromNodes = operator.getNodeAllDependencyData(projectName);
47
45
  const watchedProjectState = new _watchProjectsState.WatchedProjectsState(fromNodes, config);
48
- const watcher = new chokidar.FSWatcher({
46
+ const watcher = new _utils.chokidar.FSWatcher({
49
47
  persistent: true,
50
48
  cwd: config.rootPath,
51
49
  followSymlinks: false,
@@ -9,16 +9,12 @@ var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _jsYaml = _interopRequireDefault(require("js-yaml"));
13
-
14
12
  var _nodeCoreLibrary = require("@rushstack/node-core-library");
15
13
 
16
14
  var _constants = require("../../constants");
17
15
 
18
16
  var _install = require("../../utils/install");
19
17
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
18
  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); }
23
19
 
24
20
  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; }
@@ -31,19 +27,16 @@ const replaceWorkspaces = ({
31
27
  const pnpmWsFilePath = path.join(rootPath, _constants.WORKSPACE_FILE.PNPM);
32
28
 
33
29
  if (_utils.fs.existsSync(pnpmWsFilePath)) {
34
- const pnpmWorkspace = _utils.fs.readFileSync(pnpmWsFilePath, 'utf-8'); // eslint-disable-next-line import/no-named-as-default-member
35
-
30
+ const pnpmWorkspace = _utils.fs.readFileSync(pnpmWsFilePath, 'utf-8');
36
31
 
37
- const orignalPnpmWorkspaces = _jsYaml.default.load(pnpmWorkspace);
32
+ const orignalPnpmWorkspaces = _utils.yaml.load(pnpmWorkspace);
38
33
 
39
- _utils.fs.writeFileSync(pnpmWsFilePath, // eslint-disable-next-line import/no-named-as-default-member
40
- _jsYaml.default.dump({
34
+ _utils.fs.writeFileSync(pnpmWsFilePath, _utils.yaml.dump({
41
35
  packages: projectsInWorkspacs
42
36
  }));
43
37
 
44
38
  return () => {
45
- // eslint-disable-next-line import/no-named-as-default-member
46
- _jsYaml.default.dump(orignalPnpmWorkspaces);
39
+ _utils.yaml.dump(orignalPnpmWorkspaces);
47
40
  };
48
41
  }
49
42
 
@@ -3,18 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.lifecycle = void 0;
7
-
8
- var _core = require("@modern-js/core");
6
+ exports.hooks = void 0;
9
7
 
10
8
  var _plugin = require("@modern-js/plugin");
11
9
 
12
10
  const afterMonorepoDeploy = (0, _plugin.createAsyncWorkflow)();
13
-
14
- const lifecycle = () => {
15
- (0, _core.registerHook)({
16
- afterMonorepoDeploy
17
- });
11
+ const hooks = {
12
+ afterMonorepoDeploy
18
13
  };
19
-
20
- exports.lifecycle = lifecycle;
14
+ exports.hooks = hooks;
@@ -4,14 +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
7
 
14
- var _core = require("@modern-js/core");
8
+ var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changeset"));
15
9
 
16
10
  var _locale = require("./locale");
17
11
 
@@ -21,28 +15,30 @@ var _language = require("./utils/language");
21
15
 
22
16
  var _hooks = require("./hooks");
23
17
 
24
- // eslint-disable-next-line react-hooks/rules-of-hooks
25
- (0, _core.usePlugins)([require.resolve('@modern-js/plugin-changeset/cli')]);
26
-
27
- var _default = (0, _core.createPlugin)(() => {
28
- (0, _hooks.lifecycle)();
29
- const locale = (0, _language.getLocaleLanguage)();
30
-
31
- _locale.i18n.changeLanguage({
32
- locale
33
- });
34
-
35
- return {
36
- commands({
37
- program
38
- }) {
39
- (0, _cli.clearCli)(program);
40
- (0, _cli.deployCli)(program);
41
- (0, _cli.newCli)(program, locale);
42
- }
43
-
44
- };
45
- }, {
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
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)();
26
+
27
+ _locale.i18n.changeLanguage({
28
+ locale
29
+ });
30
+
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
+ }
39
+
40
+ };
41
+ },
46
42
  post: ['@modern-js/plugin-changeset']
47
43
  });
48
44
 
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.MultitasksLogger = void 0;
7
7
 
8
- var _signale = require("signale");
8
+ var _utils = require("@modern-js/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
12
  const createLogger = (name, config) => {
13
13
  const options = {
@@ -20,7 +20,7 @@ const createLogger = (name, config) => {
20
20
  }
21
21
  }
22
22
  };
23
- return new _signale.Signale(options);
23
+ return new _utils.Signale(options);
24
24
  };
25
25
 
26
26
  const createListenHandler = (name, config) => {
@@ -29,7 +29,7 @@ const createListenHandler = (name, config) => {
29
29
 
30
30
  const stdout = chunk => {
31
31
  // console.info(chunk.toString().split(/\r\n|\n\r|\r|\n/g).length);
32
- logger.info((0, _utils.formatLog)(chunk.toString()));
32
+ logger.info((0, _utils2.formatLog)(chunk.toString()));
33
33
  }; // eslint-disable-next-line node/prefer-global/buffer
34
34
 
35
35
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.startTime = exports.initTimeLog = exports.endTime = void 0;
7
7
 
8
- var _signale = require("signale");
8
+ var _utils = require("@modern-js/utils");
9
9
 
10
10
  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; }
11
11
 
@@ -13,7 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
13
 
14
14
  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; }
15
15
 
16
- const initTimeLog = (option = {}) => new _signale.Signale(_objectSpread({
16
+ const initTimeLog = (option = {}) => new _utils.Signale(_objectSpread({
17
17
  interactive: true,
18
18
  scope: 'time-log'
19
19
  }, option));
@@ -11,16 +11,12 @@ var _nodeCoreLibrary = require("@rushstack/node-core-library");
11
11
 
12
12
  var _utils = require("@modern-js/utils");
13
13
 
14
- var _jsYaml = _interopRequireDefault(require("js-yaml"));
15
-
16
14
  var _monorepo = require("../parse-config/monorepo");
17
15
 
18
16
  var _constants = require("../constants");
19
17
 
20
18
  var _getProjectsByPackagesConfig = require("./get-projects-by-packages-config");
21
19
 
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
20
  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); }
25
21
 
26
22
  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; }
@@ -43,9 +39,9 @@ const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
43
39
  let packagesConfig = [];
44
40
 
45
41
  if (workspaceFile === _constants.WORKSPACE_FILE.PNPM) {
46
- const yamlString = await _nodeCoreLibrary.FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString()); // eslint-disable-next-line import/no-named-as-default-member
42
+ const yamlString = await _nodeCoreLibrary.FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString());
47
43
 
48
- const pnpmWorkspace = _jsYaml.default.load(yamlString);
44
+ const pnpmWorkspace = _utils.yaml.load(yamlString);
49
45
 
50
46
  packagesConfig = pnpmWorkspace.packages || [];
51
47
  } else if (workspaceFile === _constants.WORKSPACE_FILE.YARN) {
@@ -80,10 +76,9 @@ const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
80
76
  let packagesConfig = [];
81
77
 
82
78
  if (workspaceFile === _constants.WORKSPACE_FILE.PNPM) {
83
- const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8'); // eslint-disable-next-line import/no-named-as-default-member
84
-
79
+ const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
85
80
 
86
- const pnpmWorkspace = _jsYaml.default.load(yamlString);
81
+ const pnpmWorkspace = _utils.yaml.load(yamlString);
87
82
 
88
83
  packagesConfig = pnpmWorkspace.packages || [];
89
84
  } else if (workspaceFile === _constants.WORKSPACE_FILE.YARN) {
@@ -9,12 +9,8 @@ var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _execa = _interopRequireDefault(require("execa"));
13
-
14
12
  var _constants = require("../constants");
15
13
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
14
  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); }
19
15
 
20
16
  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; }
@@ -40,13 +36,13 @@ const installByPackageManager = async (packageManager, {
40
36
  }
41
37
 
42
38
  if (packageManager === 'pnpm') {
43
- await (0, _execa.default)('pnpm', ['install'], {
39
+ await (0, _utils.execa)('pnpm', ['install'], {
44
40
  stdio: 'inherit'
45
41
  });
46
42
  }
47
43
 
48
44
  if (packageManager === 'yarn') {
49
- await (0, _execa.default)('yarn', ['install'], {
45
+ await (0, _utils.execa)('yarn', ['install'], {
50
46
  stdio: 'inherit'
51
47
  });
52
48
  }
@@ -1,2 +1,3 @@
1
- import { Command } from 'commander';
2
- export declare const buildWatchCli: (program: Command) => void;
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { Command } from '@modern-js/utils';
3
+ export declare const buildWatchCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
- import { Command } from 'commander';
2
- export declare const buildCli: (program: Command) => void;
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { Command } from '@modern-js/utils';
3
+ export declare const buildCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
- import { Command } from 'commander';
2
- export declare const clearCli: (program: Command) => void;
1
+ import type { Command } from '@modern-js/utils';
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const clearCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
- import { Command } from 'commander';
2
- export declare const deployCli: (program: Command) => void;
1
+ import type { Command } from '@modern-js/utils';
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const deployCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
- import { Command } from 'commander';
2
- export declare const installCli: (program: Command) => void;
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { Command } from '@modern-js/utils';
3
+ export declare const installCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,2 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from '@modern-js/utils';
2
2
  export declare const newCli: (program: Command, locale?: string | undefined) => 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, ignoreMatchs?: string[]) => 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>;
@@ -1 +1,7 @@
1
- export declare const lifecycle: () => void;
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;
@@ -1,4 +1,4 @@
1
- import signale, { Signale } from 'signale';
2
- export declare const initTimeLog: (option?: signale.SignaleOptions) => signale.Signale<signale.DefaultMethods>;
1
+ import { Signale, SignaleOptions } from '@modern-js/utils';
2
+ export declare const initTimeLog: (option?: SignaleOptions) => import("@modern-js/utils/compiled/signale").Signale<import("@modern-js/utils/compiled/signale").DefaultMethods>;
3
3
  export declare const startTime: (signaleInstance: Signale, prefix?: string) => void;
4
4
  export declare const endTime: (signaleInstance: Signale, prefix?: string) => void;
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };