@modern-js/module-tools 1.4.2 → 1.4.5

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 (71) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/js/modern/cli/build.js +2 -2
  3. package/dist/js/modern/cli/dev.js +2 -2
  4. package/dist/js/modern/commands/build.js +4 -5
  5. package/dist/js/modern/commands/dev.js +6 -7
  6. package/dist/js/modern/features/build/build-platform.js +4 -5
  7. package/dist/js/modern/features/build/build-watch.js +6 -8
  8. package/dist/js/modern/features/build/build.js +7 -11
  9. package/dist/js/modern/features/build/index.js +5 -5
  10. package/dist/js/modern/features/build/utils.js +9 -10
  11. package/dist/js/modern/features/dev/index.js +10 -9
  12. package/dist/js/modern/hooks/build.js +20 -0
  13. package/dist/js/modern/hooks/dev.js +11 -0
  14. package/dist/js/modern/hooks/index.js +14 -0
  15. package/dist/js/modern/index.js +37 -37
  16. package/dist/js/modern/tasks/build-source-code.js +1 -2
  17. package/dist/js/modern/tasks/build-style.js +2 -3
  18. package/dist/js/modern/tasks/build-watch-style.js +3 -6
  19. package/dist/js/modern/tasks/copy-assets.js +1 -2
  20. package/dist/js/modern/tasks/generator-dts/index.js +8 -11
  21. package/dist/js/modern/tasks/generator-dts/utils.js +11 -3
  22. package/dist/js/modern/utils/babel.js +2 -19
  23. package/dist/js/modern/utils/copy.js +1 -2
  24. package/dist/js/modern/utils/logger.js +1 -2
  25. package/dist/js/node/cli/build.js +2 -2
  26. package/dist/js/node/cli/dev.js +2 -2
  27. package/dist/js/node/commands/build.js +4 -6
  28. package/dist/js/node/commands/dev.js +6 -8
  29. package/dist/js/node/features/build/build-platform.js +5 -7
  30. package/dist/js/node/features/build/build-watch.js +6 -10
  31. package/dist/js/node/features/build/build.js +6 -13
  32. package/dist/js/node/features/build/index.js +5 -5
  33. package/dist/js/node/features/build/utils.js +9 -11
  34. package/dist/js/node/features/dev/index.js +11 -14
  35. package/dist/js/node/hooks/build.js +37 -0
  36. package/dist/js/node/hooks/dev.js +25 -0
  37. package/dist/js/node/hooks/index.js +39 -0
  38. package/dist/js/node/index.js +50 -42
  39. package/dist/js/node/tasks/build-source-code.js +3 -3
  40. package/dist/js/node/tasks/build-style.js +2 -4
  41. package/dist/js/node/tasks/build-watch-style.js +3 -7
  42. package/dist/js/node/tasks/copy-assets.js +1 -3
  43. package/dist/js/node/tasks/generator-dts/index.js +8 -16
  44. package/dist/js/node/tasks/generator-dts/utils.js +18 -8
  45. package/dist/js/node/utils/babel.js +1 -18
  46. package/dist/js/node/utils/copy.js +1 -2
  47. package/dist/js/node/utils/logger.js +5 -7
  48. package/dist/types/cli/build.d.ts +3 -2
  49. package/dist/types/cli/dev.d.ts +3 -2
  50. package/dist/types/cli/new.d.ts +1 -1
  51. package/dist/types/commands/build.d.ts +2 -1
  52. package/dist/types/commands/dev.d.ts +2 -1
  53. package/dist/types/features/build/build-platform.d.ts +2 -1
  54. package/dist/types/features/build/build-watch.d.ts +2 -2
  55. package/dist/types/features/build/build.d.ts +2 -2
  56. package/dist/types/features/build/index.d.ts +2 -2
  57. package/dist/types/features/build/utils.d.ts +4 -3
  58. package/dist/types/features/dev/index.d.ts +4 -3
  59. package/dist/types/hooks/build.d.ts +46 -0
  60. package/dist/types/hooks/dev.d.ts +18 -0
  61. package/dist/types/hooks/index.d.ts +26 -0
  62. package/dist/types/index.d.ts +3 -19
  63. package/dist/types/tasks/generator-dts/utils.d.ts +2 -1
  64. package/dist/types/utils/babel.d.ts +2 -3
  65. package/jest.config.js +0 -3
  66. package/package.json +19 -22
  67. package/tests/dev-cli.test.ts +43 -9
  68. package/tests/dev-command.test.ts +36 -10
  69. package/tests/dev-feature.test.ts +45 -13
  70. package/tests/generate-dts.test.ts +9 -0
  71. package/tests/generator-dts.test.ts +0 -11
@@ -3,14 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.defineConfig = exports.default = void 0;
6
+ exports.default = void 0;
7
+ Object.defineProperty(exports, "defineConfig", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _core.defineConfig;
11
+ }
12
+ });
7
13
 
8
14
  var _utils = require("@modern-js/utils");
9
15
 
10
- const core = _utils.Import.lazy('@modern-js/core', require); // const { createPlugin, usePlugins, defineConfig } = core;
16
+ var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changeset"));
17
+
18
+ var _pluginAnalyze = _interopRequireDefault(require("@modern-js/plugin-analyze"));
19
+
20
+ var _hooks = require("./hooks");
11
21
 
22
+ var _core = require("@modern-js/core");
12
23
 
13
- const hooks = _utils.Import.lazy('@modern-js/module-tools-hooks', require);
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
25
 
15
26
  const cli = _utils.Import.lazy('./cli', require);
16
27
 
@@ -20,45 +31,42 @@ const schema = _utils.Import.lazy('./schema', require);
20
31
 
21
32
  const lang = _utils.Import.lazy('./utils/language', require);
22
33
 
23
- const {
24
- defineConfig
25
- } = core;
26
- exports.defineConfig = defineConfig;
27
- core.usePlugins([require.resolve('@modern-js/plugin-changeset/cli'), require.resolve('@modern-js/plugin-analyze/cli')]);
28
-
29
- var _default = core.createPlugin(() => {
30
- const locale = lang.getLocaleLanguage();
31
- local.i18n.changeLanguage({
32
- locale
33
- });
34
- hooks.lifecycle();
35
- return {
36
- validateSchema() {
37
- return schema.addSchema();
38
- },
39
-
40
- config() {
41
- return {
42
- output: {
43
- enableSourceMap: false,
44
- jsPath: 'js'
45
- }
46
- };
47
- },
48
-
49
- commands({
50
- program
51
- }) {
52
- cli.devCli(program);
53
- cli.buildCli(program);
54
- cli.newCli(program, locale); // 便于其他插件辨别
55
-
56
- program.$$libraryName = 'module-tools';
57
- }
58
-
59
- };
60
- }, {
61
- post: ['@modern-js/plugin-analyze', '@modern-js/plugin-changeset']
34
+ var _default = () => ({
35
+ name: '@modern-js/module-tools',
36
+ post: ['@modern-js/plugin-analyze', '@modern-js/plugin-changeset'],
37
+ registerHook: _hooks.hooks,
38
+ usePlugins: [(0, _pluginChangeset.default)(), (0, _pluginAnalyze.default)()],
39
+ setup: api => {
40
+ const locale = lang.getLocaleLanguage();
41
+ local.i18n.changeLanguage({
42
+ locale
43
+ });
44
+ return {
45
+ validateSchema() {
46
+ return schema.addSchema();
47
+ },
48
+
49
+ config() {
50
+ return {
51
+ output: {
52
+ enableSourceMap: false,
53
+ jsPath: 'js'
54
+ }
55
+ };
56
+ },
57
+
58
+ commands({
59
+ program
60
+ }) {
61
+ cli.devCli(program, api);
62
+ cli.buildCli(program, api);
63
+ cli.newCli(program, locale); // 便于其他插件辨别
64
+
65
+ program.$$libraryName = 'module-tools';
66
+ }
67
+
68
+ };
69
+ }
62
70
  });
63
71
 
64
72
  exports.default = _default;
@@ -17,8 +17,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17
17
 
18
18
  const babelCompiler = _utils.Import.lazy('@modern-js/babel-compiler', require);
19
19
 
20
- const glob = _utils.Import.lazy('glob', require);
21
-
22
20
  const argv = _utils.Import.lazy('process.argv', require);
23
21
 
24
22
  const core = _utils.Import.lazy('@modern-js/core', require);
@@ -79,10 +77,12 @@ const getWillCompilerCode = (srcDirOrFile, option) => {
79
77
 
80
78
  const exts = getExts(isTsProject);
81
79
  const globPattern = `${srcDirOrFile}/**/*{${exts.join(',')}}`;
82
- const files = glob.sync(globPattern, {
80
+
81
+ const files = _utils.glob.sync(globPattern, {
83
82
  ignore: [`${srcDirOrFile}/**/*.d.ts`],
84
83
  absolute: true
85
84
  });
85
+
86
86
  return files;
87
87
  };
88
88
 
@@ -14,9 +14,7 @@ const core = _utils.Import.lazy('@modern-js/core', require);
14
14
 
15
15
  const compiler = _utils.Import.lazy('@modern-js/style-compiler', require);
16
16
 
17
- const glob = _utils.Import.lazy('glob', require);
18
-
19
- const hooks = _utils.Import.lazy('@modern-js/module-tools-hooks', require);
17
+ const hooks = _utils.Import.lazy('../hooks', require);
20
18
 
21
19
  const STYLE_DIRS = 'styles';
22
20
  const SRC_STYLE_DIRS = 'src';
@@ -61,7 +59,7 @@ const copyOriginStyleFiles = ({
61
59
  targetDir,
62
60
  outputDir
63
61
  }) => {
64
- const styleFiles = glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
62
+ const styleFiles = _utils.glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
65
63
 
66
64
  if (styleFiles.length > 0) {
67
65
  _utils.fs.ensureDirSync(outputDir);
@@ -8,19 +8,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
8
8
 
9
9
  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; }
10
10
 
11
- /* eslint-disable max-statements */
12
11
  const logger = _utils.Import.lazy('../features/build/logger', require);
13
12
 
14
13
  const cssConfig = _utils.Import.lazy('@modern-js/css-config', require);
15
14
 
16
- const hooks = _utils.Import.lazy('@modern-js/module-tools-hooks', require);
15
+ const hooks = _utils.Import.lazy('../hooks', require);
17
16
 
18
17
  const core = _utils.Import.lazy('@modern-js/core', require);
19
18
 
20
19
  const compiler = _utils.Import.lazy('@modern-js/style-compiler', require);
21
20
 
22
- const glob = _utils.Import.lazy('glob', require);
23
-
24
21
  const STYLE_DIRS = 'styles';
25
22
  const SRC_STYLE_DIRS = 'src';
26
23
 
@@ -60,7 +57,7 @@ const copyOriginStyleFiles = ({
60
57
  targetDir,
61
58
  outputDir
62
59
  }) => {
63
- const styleFiles = glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
60
+ const styleFiles = _utils.glob.sync(`${targetDir}/**/*.{css,sass,scss,less}`);
64
61
 
65
62
  if (styleFiles.length > 0) {
66
63
  _utils.fs.ensureDirSync(outputDir);
@@ -232,5 +229,4 @@ const taskMain = async ({
232
229
  console.error(e);
233
230
  }
234
231
  });
235
- })();
236
- /* eslint-enable max-statements */
232
+ })();
@@ -10,8 +10,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
10
10
 
11
11
  const argv = _utils.Import.lazy('process.argv', require);
12
12
 
13
- const glob = _utils.Import.lazy('glob', require);
14
-
15
13
  const core = _utils.Import.lazy('@modern-js/core', require);
16
14
 
17
15
  const copyUtils = _utils.Import.lazy('../utils/copy', require);
@@ -23,7 +21,7 @@ const copyAssets = ({
23
21
  targetDir,
24
22
  outputDir
25
23
  }) => {
26
- const assetsFiles = glob.sync(`${targetDir}/**/*.*`, {
24
+ const assetsFiles = _utils.glob.sync(`${targetDir}/**/*.*`, {
27
25
  ignore: ['**/*.{js,jsx,ts,tsx,d.ts,scss,less,css,sass}']
28
26
  });
29
27
 
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var path = _interopRequireWildcard(require("path"));
4
-
5
3
  var _utils = require("@modern-js/utils");
6
4
 
7
- 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); }
8
-
9
- 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; }
5
+ var _utils2 = require("./utils");
10
6
 
11
7
  const core = _utils.Import.lazy('@modern-js/core', require);
12
8
 
13
- const execa = _utils.Import.lazy('execa', require);
14
-
15
9
  const JSON5 = _utils.Import.lazy('json5', require);
16
10
 
17
11
  const argv = _utils.Import.lazy('process.argv', require);
@@ -75,9 +69,9 @@ const generatorDts = async (_, config) => {
75
69
  sourceDir: sourceDirName
76
70
  });
77
71
  removeTsconfigPath = willDeleteTsconfigPath;
78
- const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
72
+ const tscBinFile = (0, _utils2.getTscBinPath)(appDirectory);
79
73
  const watchParams = watch ? ['-w'] : [];
80
- const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
74
+ const childProgress = (0, _utils.execa)(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
81
75
  stdio: 'pipe',
82
76
  cwd: appDirectory
83
77
  });
@@ -88,17 +82,15 @@ const generatorDts = async (_, config) => {
88
82
 
89
83
  try {
90
84
  await childProgress;
91
- console.info('[Tsc Compiler]: Successfully');
85
+ console.info('[TSC Compiler]: Successfully');
92
86
  } catch (e) {
93
87
  if (!tsCheck) {
94
88
  console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
89
+ } // 通过使用 execa,可以将 tsc 的 data 类型的报错信息变为异常错误信息
90
+ else if ((0, _utils.isObject)(e) && e.stdout) {
91
+ console.error(e.stdout);
95
92
  } else {
96
- const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
97
-
98
-
99
- if (isRecord(e)) {
100
- console.error(e.stdout);
101
- }
93
+ console.error(e);
102
94
  }
103
95
  }
104
96
 
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resolveAlias = exports.generatorTsConfig = void 0;
6
+ exports.resolveAlias = exports.getTscBinPath = exports.generatorTsConfig = void 0;
7
7
 
8
8
  var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
+ var _lodash = require("@modern-js/utils/lodash");
13
+
12
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); }
13
15
 
14
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; }
@@ -19,16 +21,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
19
21
 
20
22
  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; }
21
23
 
22
- const glob = _utils.Import.lazy('glob', require);
23
-
24
24
  const babel = _utils.Import.lazy('../../utils/babel', require);
25
25
 
26
26
  const tsPathsTransform = _utils.Import.lazy('../../utils/tspaths-transform', require);
27
27
 
28
28
  const constants = _utils.Import.lazy('../constants', require);
29
29
 
30
- const deepMerge = _utils.Import.lazy('lodash.merge', require);
31
-
32
30
  const generatorTsConfig = (projectTsconfig, {
33
31
  appDirectory,
34
32
  distDir,
@@ -69,7 +67,7 @@ const generatorTsConfig = (projectTsconfig, {
69
67
 
70
68
  _utils.fs.ensureFileSync(tempTsconfigPath);
71
69
 
72
- _utils.fs.writeJSONSync(tempTsconfigPath, deepMerge(recommendOption, projectTsconfig, // 此处是必须要覆盖用户默认配置
70
+ _utils.fs.writeJSONSync(tempTsconfigPath, (0, _lodash.merge)(recommendOption, projectTsconfig, // 此处是必须要覆盖用户默认配置
73
71
  resetConfig));
74
72
 
75
73
  return tempTsconfigPath;
@@ -85,7 +83,7 @@ const resolveAlias = (modernConfig, config, watchFilenames = []) => {
85
83
  '@': ['./src']
86
84
  };
87
85
  const dtsDistPath = `${config.distDir}/**/*.d.ts`;
88
- const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : glob.sync(dtsDistPath, {
86
+ const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : _utils.glob.sync(dtsDistPath, {
89
87
  absolute: true
90
88
  });
91
89
  const alias = babel.getFinalAlias(modernConfig, {
@@ -105,4 +103,16 @@ const resolveAlias = (modernConfig, config, watchFilenames = []) => {
105
103
  }
106
104
  };
107
105
 
108
- exports.resolveAlias = resolveAlias;
106
+ exports.resolveAlias = resolveAlias;
107
+
108
+ const getTscBinPath = appDirectory => {
109
+ const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
110
+
111
+ if (!_utils.fs.existsSync(tscBinFile)) {
112
+ throw new Error('Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.');
113
+ }
114
+
115
+ return tscBinFile;
116
+ };
117
+
118
+ exports.getTscBinPath = getTscBinPath;
@@ -84,25 +84,8 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
84
84
  }); // Preventing warning when files are too large
85
85
 
86
86
  internalBabelConfig.compact = false;
87
- const babelChain = (0, _babelPresetModule.getModuleBabelChain)({
88
- appDirectory,
89
- enableReactPreset: true,
90
- enableTypescriptPreset: true,
91
- alias: aliasConfig,
92
- envVars,
93
- globalVars,
94
- lodashOptions,
95
- jsxTransformRuntime,
96
- importStyle
97
- }, {
98
- type: option.type,
99
- syntax: option.syntax
100
- });
101
87
  const userBabelConfig = modernConfig.tools.babel;
102
- return (0, _utils.applyOptionsChain)(internalBabelConfig, // TODO: 感觉 userBabelConfig 的类型应该是TransformOptions
103
- userBabelConfig, {
104
- chain: babelChain
105
- });
88
+ return (0, _utils.applyOptionsChain)(internalBabelConfig, userBabelConfig);
106
89
  };
107
90
 
108
91
  exports.resolveBabelConfig = resolveBabelConfig;
@@ -23,8 +23,7 @@ const globby = _utils.Import.lazy('globby', require);
23
23
 
24
24
  const fastGlob = _utils.Import.lazy('fast-glob', require);
25
25
 
26
- const normalizePath = _utils.Import.lazy('normalize-path', require); // eslint-disable-next-line max-statements
27
-
26
+ const normalizePath = _utils.Import.lazy('normalize-path', require);
28
27
 
29
28
  const copyTask = async option => {
30
29
  const {
@@ -11,8 +11,6 @@ var _utils = require("@modern-js/utils");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- const chalk = _utils.Import.lazy('chalk', require);
15
-
16
14
  const clearFlag = '\x1Bc';
17
15
  exports.clearFlag = clearFlag;
18
16
 
@@ -89,16 +87,16 @@ class LoggerManager extends _events.default {
89
87
  error: true
90
88
  },
91
89
  colors = {
92
- data: chalk.green,
93
- error: chalk.red,
94
- warning: chalk.yellow
90
+ data: _utils.chalk.green,
91
+ error: _utils.chalk.red,
92
+ warning: _utils.chalk.yellow
95
93
  }
96
94
  } = config;
97
95
 
98
96
  if (event.data) {
99
97
  stdout === null || stdout === void 0 ? void 0 : stdout.on('data', chunk => {
100
98
  const data = chunk.toString();
101
- const content = colors.data ? colors.data(data) : chalk.green(data);
99
+ const content = colors.data ? colors.data(data) : _utils.chalk.green(data);
102
100
  loggerText.append(content);
103
101
  this.emit('data');
104
102
  });
@@ -107,7 +105,7 @@ class LoggerManager extends _events.default {
107
105
  if (event.error) {
108
106
  stdout === null || stdout === void 0 ? void 0 : stdout.on('error', error => {
109
107
  const data = error.message;
110
- const content = colors.error ? colors.error(data) : chalk.red(data);
108
+ const content = colors.error ? colors.error(data) : _utils.chalk.red(data);
111
109
  loggerText.append(content);
112
110
  this.emit('data');
113
111
  });
@@ -1,2 +1,3 @@
1
- import type { Command } from 'commander';
2
- export declare const buildCli: (program: Command) => void;
1
+ import { Command } from '@modern-js/utils';
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const buildCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,3 @@
1
- import type { Command } from 'commander';
2
- export declare const devCli: (program: Command) => void;
1
+ import { Command } from '@modern-js/utils';
2
+ import type { PluginAPI } from '@modern-js/core';
3
+ export declare const devCli: (program: Command, api: PluginAPI) => void;
@@ -1,2 +1,2 @@
1
- import type { Command } from 'commander';
1
+ import { Command } from '@modern-js/utils';
2
2
  export declare const newCli: (program: Command, locale?: string | undefined) => void;
@@ -1,3 +1,4 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  import type { Platform } from '../types';
2
3
  export interface IBuildOption {
3
4
  watch: boolean;
@@ -7,7 +8,7 @@ export interface IBuildOption {
7
8
  tsc: boolean;
8
9
  clear: boolean;
9
10
  }
10
- export declare const build: ({
11
+ export declare const build: (api: PluginAPI, {
11
12
  watch,
12
13
  tsconfig: tsconfigName,
13
14
  tsc,
@@ -1,4 +1,5 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IDevOption {
2
3
  tsconfig: string;
3
4
  }
4
- export declare const dev: (option: IDevOption, subCmd?: string) => Promise<void>;
5
+ export declare const dev: (api: PluginAPI, option: IDevOption, subCmd?: string) => Promise<void>;
@@ -1,6 +1,7 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export declare type Platform = 'all' | 'docs' | 'storybook';
2
3
  export interface IBuildPlatformOption {
3
4
  platform: Platform;
4
5
  isTsProject?: boolean;
5
6
  }
6
- export declare const buildPlatform: (option: IBuildPlatformOption) => Promise<void>;
7
+ export declare const buildPlatform: (api: PluginAPI, option: IBuildPlatformOption) => Promise<void>;
@@ -1,3 +1,3 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
2
2
  import type { IBuildConfig } from '../../types';
3
- export declare const buildInWatchMode: (config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
3
+ export declare const buildInWatchMode: (api: PluginAPI, config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
@@ -1,3 +1,3 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
2
2
  import type { IBuildConfig } from '../../types';
3
- export declare const buildSourceCode: (config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
3
+ export declare const buildSourceCode: (api: PluginAPI, config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
@@ -1,3 +1,3 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
2
2
  import type { IBuildConfig } from '../../types';
3
- export declare const build: (config: IBuildConfig, modernConfig: NormalizedConfig) => Promise<void>;
3
+ export declare const build: (api: PluginAPI, config: IBuildConfig, modernConfig: NormalizedConfig) => Promise<void>;
@@ -1,7 +1,8 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  import type { IBuildConfig, IPackageModeValue, ITaskMapper } from '../../types';
2
3
  import type { LoggerText } from './logger';
3
- export declare const getCodeInitMapper: (_: IBuildConfig) => IPackageModeValue[];
4
- export declare const getCodeMapper: ({
4
+ export declare const getCodeInitMapper: (api: PluginAPI, _: IBuildConfig) => IPackageModeValue[];
5
+ export declare const getCodeMapper: (api: PluginAPI, {
5
6
  logger,
6
7
  taskPath,
7
8
  config,
@@ -18,7 +19,7 @@ export declare const getCodeMapper: ({
18
19
  taskPath: string;
19
20
  params: string[];
20
21
  }[];
21
- export declare const getDtsMapper: (config: IBuildConfig, logger: LoggerText) => {
22
+ export declare const getDtsMapper: (api: PluginAPI, config: IBuildConfig, logger: LoggerText) => {
22
23
  logger: LoggerText;
23
24
  taskPath: string;
24
25
  params: string[];
@@ -1,8 +1,9 @@
1
+ import type { PluginAPI } from '@modern-js/core';
1
2
  export interface IDevConfig {
2
3
  appDirectory: string;
3
4
  isTsProject: boolean;
4
5
  }
5
6
  export declare type DevTaskType = 'storybook' | 'docsite' | 'unknow';
6
- export declare const showMenu: (config: IDevConfig) => Promise<void>;
7
- export declare const devStorybook: (config: IDevConfig) => Promise<void>;
8
- export declare const runSubCmd: (subCmd: string, config: IDevConfig) => Promise<void>;
7
+ export declare const showMenu: (api: PluginAPI, config: IDevConfig) => Promise<void>;
8
+ export declare const devStorybook: (api: PluginAPI, config: IDevConfig) => Promise<void>;
9
+ export declare const runSubCmd: (api: PluginAPI, subCmd: string, config: IDevConfig) => Promise<void>;
@@ -0,0 +1,46 @@
1
+ import { NormalizedConfig } from '@modern-js/core';
2
+ import { LessOption, SassOptions } from '@modern-js/style-compiler';
3
+ export interface PlatformBuildOption {
4
+ isTsProject: boolean;
5
+ }
6
+ export declare const platformBuild: import("@modern-js/plugin").ParallelWorkflow<PlatformBuildOption, {
7
+ name: string;
8
+ title: string;
9
+ taskPath: string;
10
+ params: string[];
11
+ }>;
12
+ export declare const moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
13
+ modernConfig: NormalizedConfig;
14
+ }, LessOption | undefined>;
15
+ export declare const moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
16
+ modernConfig: NormalizedConfig;
17
+ }, SassOptions<"sync"> | undefined>;
18
+ export declare const moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
19
+ modernConfig: NormalizedConfig;
20
+ }, any>;
21
+ export declare const buildHooks: {
22
+ platformBuild: import("@modern-js/plugin").ParallelWorkflow<PlatformBuildOption, {
23
+ name: string;
24
+ title: string;
25
+ taskPath: string;
26
+ params: string[];
27
+ }>;
28
+ moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
29
+ modernConfig: NormalizedConfig;
30
+ }, LessOption | undefined>;
31
+ moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
32
+ modernConfig: NormalizedConfig;
33
+ }, SassOptions<"sync"> | undefined>;
34
+ moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
35
+ modernConfig: NormalizedConfig;
36
+ }, any>;
37
+ };
38
+ export declare const lifecycle: () => void;
39
+ declare module '@modern-js/core' {
40
+ interface Hooks {
41
+ platformBuild: typeof platformBuild;
42
+ moduleLessConfig: typeof moduleLessConfig;
43
+ moduleSassConfig: typeof moduleSassConfig;
44
+ moduleTailwindConfig: typeof moduleTailwindConfig;
45
+ }
46
+ }
@@ -0,0 +1,18 @@
1
+ export declare const moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
2
+ name: string;
3
+ value: string;
4
+ runTask: (p: any) => void | Promise<void>;
5
+ }>;
6
+ export declare const devHooks: {
7
+ moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
8
+ name: string;
9
+ value: string;
10
+ runTask: (p: any) => void | Promise<void>;
11
+ }>;
12
+ };
13
+ export declare const lifecycle: () => void;
14
+ declare module '@modern-js/core' {
15
+ interface Hooks {
16
+ moduleToolsMenu: typeof moduleToolsMenu;
17
+ }
18
+ }
@@ -0,0 +1,26 @@
1
+ import { lifecycle as buildLifeCycle } from './build';
2
+ import { lifecycle as devLifeCycle } from './dev';
3
+ export { buildLifeCycle, devLifeCycle };
4
+ export declare const lifecycle: () => void;
5
+ export declare const hooks: {
6
+ moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
7
+ name: string;
8
+ value: string;
9
+ runTask: (p: any) => void | Promise<void>;
10
+ }>;
11
+ platformBuild: import("@modern-js/plugin").ParallelWorkflow<import("./build").PlatformBuildOption, {
12
+ name: string;
13
+ title: string;
14
+ taskPath: string;
15
+ params: string[];
16
+ }>;
17
+ moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
18
+ modernConfig: import("@modern-js/core").NormalizedConfig;
19
+ }, import("@modern-js/style-compiler").LessOption | undefined>;
20
+ moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
21
+ modernConfig: import("@modern-js/core").NormalizedConfig;
22
+ }, import("@modern-js/style-compiler").SassOptions<"sync"> | undefined>;
23
+ moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
24
+ modernConfig: import("@modern-js/core").NormalizedConfig;
25
+ }, any>;
26
+ };
@@ -1,22 +1,6 @@
1
- export declare const defineConfig: (config: import("@modern-js/core/src/config").ConfigParam) => import("@modern-js/core/src/config").ConfigParam;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+ export { defineConfig } from '@modern-js/core';
2
3
 
3
- declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
4
- config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
5
- resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
6
- resolved: import("@modern-js/core").NormalizedConfig;
7
- }>;
8
- validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
9
- prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
10
- commands: import("@modern-js/core").AsyncWorkflow<{
11
- program: import("commander").Command;
12
- }, void>;
13
- watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
14
- fileChange: import("@modern-js/core").AsyncWorkflow<{
15
- filename: string;
16
- eventType: "add" | "unlink" | "change";
17
- }, void>;
18
- beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
19
- beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
20
- } & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
4
+ declare const _default: () => CliPlugin;
21
5
 
22
6
  export default _default;
@@ -20,4 +20,5 @@ export declare const generatorTsConfig: (projectTsconfig: ITsconfig, {
20
20
  distDir: string;
21
21
  sourceDir?: string | undefined;
22
22
  }) => string;
23
- export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
23
+ export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
24
+ export declare const getTscBinPath: (appDirectory: string) => string;