@modern-js/app-tools 1.0.0-alpha.3

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 (60) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +32 -0
  4. package/bin/modern.js +3 -0
  5. package/dist/js/modern/commands/build.js +116 -0
  6. package/dist/js/modern/commands/dev.js +65 -0
  7. package/dist/js/modern/commands/index.js +3 -0
  8. package/dist/js/modern/commands/start.js +32 -0
  9. package/dist/js/modern/index.js +60 -0
  10. package/dist/js/modern/lifecycle.js +20 -0
  11. package/dist/js/modern/locale/en.js +21 -0
  12. package/dist/js/modern/locale/index.js +9 -0
  13. package/dist/js/modern/locale/zh.js +21 -0
  14. package/dist/js/modern/utils/createCompiler.js +73 -0
  15. package/dist/js/modern/utils/createServer.js +12 -0
  16. package/dist/js/modern/utils/language.js +5 -0
  17. package/dist/js/modern/utils/printInstructions.js +17 -0
  18. package/dist/js/node/commands/build.js +135 -0
  19. package/dist/js/node/commands/dev.js +82 -0
  20. package/dist/js/node/commands/index.js +44 -0
  21. package/dist/js/node/commands/start.js +49 -0
  22. package/dist/js/node/index.js +87 -0
  23. package/dist/js/node/lifecycle.js +39 -0
  24. package/dist/js/node/locale/en.js +28 -0
  25. package/dist/js/node/locale/index.js +20 -0
  26. package/dist/js/node/locale/zh.js +28 -0
  27. package/dist/js/node/utils/createCompiler.js +95 -0
  28. package/dist/js/node/utils/createServer.js +23 -0
  29. package/dist/js/node/utils/language.js +13 -0
  30. package/dist/js/node/utils/printInstructions.js +29 -0
  31. package/dist/types/commands/build.d.ts +1 -0
  32. package/dist/types/commands/dev.d.ts +1 -0
  33. package/dist/types/commands/index.d.ts +3 -0
  34. package/dist/types/commands/start.d.ts +1 -0
  35. package/dist/types/index.d.ts +18 -0
  36. package/dist/types/lifecycle.d.ts +17 -0
  37. package/dist/types/locale/en.d.ts +21 -0
  38. package/dist/types/locale/index.d.ts +44 -0
  39. package/dist/types/locale/zh.d.ts +21 -0
  40. package/dist/types/utils/createCompiler.d.ts +11 -0
  41. package/dist/types/utils/createServer.d.ts +2 -0
  42. package/dist/types/utils/language.d.ts +1 -0
  43. package/dist/types/utils/printInstructions.d.ts +2 -0
  44. package/lib/types.d.ts +138 -0
  45. package/modern.config.js +6 -0
  46. package/package.json +58 -0
  47. package/src/commands/build.ts +123 -0
  48. package/src/commands/dev.ts +80 -0
  49. package/src/commands/index.ts +3 -0
  50. package/src/commands/start.ts +30 -0
  51. package/src/index.ts +87 -0
  52. package/src/lifecycle.ts +37 -0
  53. package/src/locale/en.ts +17 -0
  54. package/src/locale/index.ts +9 -0
  55. package/src/locale/zh.ts +17 -0
  56. package/src/utils/createCompiler.ts +80 -0
  57. package/src/utils/createServer.ts +16 -0
  58. package/src/utils/language.ts +6 -0
  59. package/src/utils/printInstructions.ts +22 -0
  60. package/tsconfig.json +16 -0
@@ -0,0 +1,21 @@
1
+ export declare const ZH_LOCALE: {
2
+ command: {
3
+ dev: {
4
+ describe: string;
5
+ config: string;
6
+ };
7
+ build: {
8
+ describe: string;
9
+ };
10
+ start: {
11
+ describe: string;
12
+ };
13
+ new: {
14
+ describe: string;
15
+ debug: string;
16
+ config: string;
17
+ distTag: string;
18
+ registry: string;
19
+ };
20
+ };
21
+ };
@@ -0,0 +1,11 @@
1
+ import webpack, { Configuration } from 'webpack';
2
+ import { IAppContext, NormalizedConfig } from '@modern-js/core';
3
+ export declare const createCompiler: ({
4
+ webpackConfigs,
5
+ userConfig: _userConfig,
6
+ appContext
7
+ }: {
8
+ webpackConfigs: Configuration[];
9
+ userConfig: NormalizedConfig;
10
+ appContext: IAppContext;
11
+ }) => Promise<webpack.MultiCompiler>;
@@ -0,0 +1,2 @@
1
+ import { Server, ModernServerOptions } from '@modern-js/server';
2
+ export declare const createServer: (options: ModernServerOptions) => Promise<Server>;
@@ -0,0 +1 @@
1
+ export declare function getLocaleLanguage(): string;
@@ -0,0 +1,2 @@
1
+ import { IAppContext } from '@modern-js/core';
2
+ export declare const printInstructions: (appContext: IAppContext) => Promise<void>;
package/lib/types.d.ts ADDED
@@ -0,0 +1,138 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="react" />
3
+ /// <reference types="react-dom" />
4
+ /// <reference path="./dist/types/index.d.ts" />
5
+ /// <reference types="@modern-js/plugin-express/types" />
6
+ /// <reference types="@modern-js/plugin-koa/types" />
7
+ /// <reference types="@modern-js/plugin-egg" />
8
+ /// <reference types="@modern-js/plugin-nest" />
9
+
10
+ declare namespace NodeJS {
11
+ interface ProcessEnv {
12
+ readonly NODE_ENV: 'development' | 'production' | 'test';
13
+ readonly PUBLIC_URL: string;
14
+ }
15
+ }
16
+
17
+ declare module '*.bmp' {
18
+ const src: string;
19
+ export default src;
20
+ }
21
+
22
+ declare module '*.gif' {
23
+ const src: string;
24
+ export default src;
25
+ }
26
+
27
+ declare module '*.jpg' {
28
+ const src: string;
29
+ export default src;
30
+ }
31
+
32
+ declare module '*.jpeg' {
33
+ const src: string;
34
+ export default src;
35
+ }
36
+
37
+ declare module '*.png' {
38
+ const src: string;
39
+ export default src;
40
+ }
41
+
42
+ declare module '*.ico' {
43
+ const src: string;
44
+ export default src;
45
+ }
46
+
47
+ declare module '*.webp' {
48
+ const src: string;
49
+ export default src;
50
+ }
51
+
52
+ declare module '*.svg' {
53
+ import * as React from 'react';
54
+
55
+ export const ReactComponent: React.FunctionComponent<
56
+ React.SVGProps<SVGSVGElement>
57
+ >;
58
+
59
+ const src: string;
60
+ export default src;
61
+ }
62
+
63
+ declare module '*.css' {
64
+ const classes: { readonly [key: string]: string };
65
+ export default classes;
66
+ }
67
+
68
+ declare module '*.scss' {
69
+ const classes: { readonly [key: string]: string };
70
+ export default classes;
71
+ }
72
+
73
+ declare module '*.less' {
74
+ const classes: { readonly [key: string]: string };
75
+ export default classes;
76
+ }
77
+
78
+ declare module '*.styl' {
79
+ const classes: { readonly [key: string]: string };
80
+ export default classes;
81
+ }
82
+
83
+ declare module '*.sass' {
84
+ const classes: { readonly [key: string]: string };
85
+ export default classes;
86
+ }
87
+
88
+ declare module '*.module.css' {
89
+ const classes: { readonly [key: string]: string };
90
+ export default classes;
91
+ }
92
+
93
+ declare module '*.module.scss' {
94
+ const classes: { readonly [key: string]: string };
95
+ export default classes;
96
+ }
97
+
98
+ declare module '*.module.less' {
99
+ const classes: { readonly [key: string]: string };
100
+ export default classes;
101
+ }
102
+
103
+ declare module '*.module.styl' {
104
+ const classes: { readonly [key: string]: string };
105
+ export default classes;
106
+ }
107
+
108
+ declare module '*.module.sass' {
109
+ const classes: { readonly [key: string]: string };
110
+ export default classes;
111
+ }
112
+
113
+ declare module '*.md' {
114
+ const src: string;
115
+ export default src;
116
+ }
117
+
118
+ declare module '*.hbs' {
119
+ const src: string;
120
+ export default src;
121
+ }
122
+
123
+ declare module '*.yaml' {
124
+ const src: string;
125
+ export default src;
126
+ }
127
+
128
+ declare module '*.toml' {
129
+ const src: string;
130
+ export default src;
131
+ }
132
+
133
+ declare module '*.xml' {
134
+ const src: string;
135
+ export default src;
136
+ }
137
+
138
+ declare module '@modern-js/runtime/*' {}
@@ -0,0 +1,6 @@
1
+ /** @type {import('@modern-js/module-tools').UserConfig} */
2
+ module.exports = {
3
+ output: {
4
+ disableSourceMap: true,
5
+ },
6
+ };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@modern-js/app-tools",
3
+ "version": "1.0.0-alpha.3",
4
+ "jsnext:source": "./src/index.ts",
5
+ "types": "./lib/types.d.ts",
6
+ "main": "./dist/js/node/index.js",
7
+ "module": "./dist/js/treeshaking/index.js",
8
+ "jsnext:modern": "./dist/js/modern/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "node": {
12
+ "import": "./dist/js/modern/index.js",
13
+ "require": "./dist/js/node/index.js"
14
+ },
15
+ "default": "./dist/js/treeshaking/index.js"
16
+ },
17
+ "./cli": "./dist/js/node/index.js"
18
+ },
19
+ "bin": {
20
+ "modern": "./bin/modern.js"
21
+ },
22
+ "dependencies": {
23
+ "@babel/runtime": "^7",
24
+ "@modern-js/core": "^1.0.0-alpha.3",
25
+ "@modern-js/types": "^1.0.0-alpha.3",
26
+ "@modern-js/i18n-cli-language-detector": "^1.0.0-alpha.3",
27
+ "@modern-js/new-action": "^1.0.0-alpha.3",
28
+ "@modern-js/plugin": "^1.0.0-alpha.3",
29
+ "@modern-js/plugin-analyze": "^1.0.0-alpha.3",
30
+ "@modern-js/plugin-fast-refresh": "^1.0.0-alpha.3",
31
+ "@modern-js/plugin-i18n": "^1.0.0-alpha.3",
32
+ "@modern-js/plugin-polyfill": "^1.0.0-alpha.3",
33
+ "@modern-js/server": "^1.0.0-alpha.3",
34
+ "@modern-js/utils": "^1.0.0-alpha.3",
35
+ "@modern-js/webpack": "^1.0.0-alpha.3",
36
+ "webpack": "^5.54.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/jest": "^26",
40
+ "@types/node": "^14",
41
+ "@types/react": "^17",
42
+ "@types/react-dom": "^17",
43
+ "typescript": "^4",
44
+ "@modern-js/plugin-testing": "^1.0.0-alpha.3",
45
+ "@modern-js/module-tools": "^1.0.0-alpha.3"
46
+ },
47
+ "sideEffects": false,
48
+ "modernConfig": {
49
+ "output": {
50
+ "packageMode": "node-js"
51
+ }
52
+ },
53
+ "scripts": {
54
+ "new": "modern new",
55
+ "build": "modern build",
56
+ "test": "modern test --passWithNoTests"
57
+ }
58
+ }
@@ -0,0 +1,123 @@
1
+ import { Configuration, webpack } from 'webpack';
2
+ import { WebpackConfigTarget, getWebpackConfig } from '@modern-js/webpack';
3
+ import {
4
+ useAppContext,
5
+ useResolvedConfigContext,
6
+ mountHook,
7
+ } from '@modern-js/core';
8
+ import {
9
+ fs,
10
+ formatWebpackMessages,
11
+ measureFileSizesBeforeBuild,
12
+ printFileSizesAfterBuild,
13
+ printBuildError,
14
+ logger,
15
+ isUseSSRBundle,
16
+ } from '@modern-js/utils';
17
+
18
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
19
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
20
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
21
+
22
+ export const build = async () => {
23
+ const webpackBuild = async (webpackConfig: Configuration, type?: string) => {
24
+ const compiler = webpack(webpackConfig);
25
+
26
+ return new Promise((resolve, reject) => {
27
+ let label = process.env.NODE_ENV || '';
28
+ if (type && type !== 'legacy') {
29
+ label += ` ${type}`;
30
+ }
31
+ logger.info(`Creating a ${label} build...`);
32
+
33
+ compiler.run((err, stats) => {
34
+ let messages: {
35
+ errors: any;
36
+ warnings: any;
37
+ };
38
+ if (!err) {
39
+ messages = formatWebpackMessages(
40
+ stats!.toJson({ all: false, warnings: true, errors: true }),
41
+ );
42
+
43
+ if (messages.errors.length === 0) {
44
+ logger.info(`File sizes after ${label} build:\n`);
45
+ printFileSizesAfterBuild(
46
+ stats,
47
+ previousFileSizes,
48
+ outputPath,
49
+ WARN_AFTER_BUNDLE_GZIP_SIZE,
50
+ WARN_AFTER_CHUNK_GZIP_SIZE,
51
+ );
52
+ logger.log();
53
+ }
54
+ }
55
+
56
+ // When using run or watch, call close and wait for it to finish before calling run or watch again.
57
+ // Concurrent compilations will corrupt the output files.
58
+ compiler.close(closeErr => {
59
+ if (closeErr) {
60
+ logger.error(closeErr);
61
+ }
62
+ if (err) {
63
+ reject(err);
64
+ } else {
65
+ if (messages.errors.length) {
66
+ reject(new Error(messages.errors.join('\n\n')));
67
+ return;
68
+ }
69
+ resolve({ warnings: messages.warnings });
70
+ }
71
+ });
72
+ });
73
+ });
74
+ };
75
+
76
+ /* eslint-disable react-hooks/rules-of-hooks */
77
+ const { value: resolvedConfig } = useResolvedConfigContext();
78
+ const { value: appContext } = useAppContext();
79
+ /* eslint-enable react-hooks/rules-of-hooks */
80
+
81
+ const outputPath = appContext.distDirectory;
82
+ const previousFileSizes = await measureFileSizesBeforeBuild(outputPath);
83
+ fs.emptyDirSync(outputPath);
84
+
85
+ const buildConfigs = [];
86
+
87
+ buildConfigs.push({
88
+ type: 'legacy',
89
+ config: getWebpackConfig(WebpackConfigTarget.CLIENT)!,
90
+ });
91
+
92
+ if (resolvedConfig.output.enableModernMode) {
93
+ buildConfigs.push({
94
+ type: 'modern',
95
+ config: getWebpackConfig(WebpackConfigTarget.MODERN)!,
96
+ });
97
+ }
98
+
99
+ if (isUseSSRBundle(resolvedConfig)) {
100
+ buildConfigs.push({
101
+ type: 'ssr',
102
+ config: getWebpackConfig(WebpackConfigTarget.NODE)!,
103
+ });
104
+ }
105
+
106
+ await (mountHook() as any).beforeBuild({
107
+ webpackConfigs: buildConfigs.map(({ config }) => config),
108
+ });
109
+
110
+ for (const buildConfig of buildConfigs) {
111
+ const { type: buildType, config } = buildConfig;
112
+ try {
113
+ await webpackBuild(config, buildType);
114
+ } catch (error) {
115
+ printBuildError(error as Error);
116
+ }
117
+ }
118
+ await (mountHook() as any).afterBuild();
119
+
120
+ // force exit after build.
121
+ // eslint-disable-next-line no-process-exit
122
+ process.exit(0);
123
+ };
@@ -0,0 +1,80 @@
1
+ import {
2
+ Configuration,
3
+ getWebpackConfig,
4
+ WebpackConfigTarget,
5
+ } from '@modern-js/webpack';
6
+ import {
7
+ fs,
8
+ logger,
9
+ HMR_SOCK_PATH,
10
+ clearConsole,
11
+ chalk,
12
+ isSSR,
13
+ } from '@modern-js/utils';
14
+ import {
15
+ useAppContext,
16
+ useResolvedConfigContext,
17
+ mountHook,
18
+ } from '@modern-js/core';
19
+ import { createCompiler } from '../utils/createCompiler';
20
+ import { createServer } from '../utils/createServer';
21
+
22
+ export const dev = async () => {
23
+ /* eslint-disable react-hooks/rules-of-hooks */
24
+ const { value: appContext } = useAppContext();
25
+ const { value: userConfig } = useResolvedConfigContext();
26
+ /* eslint-enable react-hooks/rules-of-hooks */
27
+
28
+ const { appDirectory, distDirectory, port } = appContext;
29
+
30
+ fs.emptyDirSync(distDirectory);
31
+
32
+ await (mountHook() as any).beforeDev();
33
+
34
+ const webpackConfigs = [
35
+ isSSR(userConfig) && getWebpackConfig(WebpackConfigTarget.NODE),
36
+ getWebpackConfig(WebpackConfigTarget.CLIENT),
37
+ ].filter(Boolean) as Configuration[];
38
+
39
+ const compiler = await createCompiler({
40
+ webpackConfigs,
41
+ userConfig,
42
+ appContext,
43
+ });
44
+
45
+ const app = await createServer({
46
+ dev: {
47
+ ...{
48
+ client: {
49
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
50
+ port: port!.toString(),
51
+ overlay: false,
52
+ logging: 'none',
53
+ path: HMR_SOCK_PATH,
54
+ host: 'localhost',
55
+ },
56
+ dev: { writeToDisk: (file: string) => !file.includes('.hot-update.') },
57
+ hot: true,
58
+ liveReload: true,
59
+ port,
60
+ },
61
+ ...userConfig.tools.devServer,
62
+ },
63
+ compiler,
64
+ pwd: appDirectory,
65
+ config: userConfig as any,
66
+ plugins: appContext.plugins
67
+ .filter((p: any) => p.server)
68
+ .map((p: any) => p.server),
69
+ });
70
+
71
+ app.listen(port, (err: Error) => {
72
+ if (err) {
73
+ throw err;
74
+ }
75
+
76
+ clearConsole();
77
+
78
+ logger.log(chalk.cyan(`Starting the development server...`));
79
+ });
80
+ };
@@ -0,0 +1,3 @@
1
+ export * from './dev';
2
+ export * from './build';
3
+ export * from './start';
@@ -0,0 +1,30 @@
1
+ import { logger, chalk } from '@modern-js/utils';
2
+ import { useAppContext, useResolvedConfigContext } from '@modern-js/core';
3
+ import server from '@modern-js/server';
4
+ import { printInstructions } from '../utils/printInstructions';
5
+
6
+ export const start = async () => {
7
+ /* eslint-disable react-hooks/rules-of-hooks */
8
+ const { value: appContext } = useAppContext();
9
+ const { value: userConfig } = useResolvedConfigContext();
10
+ /* eslint-enable react-hooks/rules-of-hooks */
11
+
12
+ const { appDirectory, port } = appContext;
13
+
14
+ logger.log(chalk.cyan(`Starting the modern server...`));
15
+
16
+ const app = await server({
17
+ pwd: appDirectory,
18
+ config: userConfig as any,
19
+ plugins: appContext.plugins
20
+ .filter((p: any) => p.server)
21
+ .map((p: any) => p.server),
22
+ });
23
+
24
+ app.listen(port, async (err: Error) => {
25
+ if (err) {
26
+ throw err;
27
+ }
28
+ await printInstructions(appContext);
29
+ });
30
+ };
package/src/index.ts ADDED
@@ -0,0 +1,87 @@
1
+ import { createPlugin, defineConfig, usePlugins, cli } from '@modern-js/core';
2
+ import { lifecycle } from './lifecycle';
3
+ import { i18n, localeKeys } from './locale';
4
+ import { getLocaleLanguage } from './utils/language';
5
+ import { start } from './commands/start';
6
+ import { dev } from './commands/dev';
7
+
8
+ export { defineConfig };
9
+
10
+ // eslint-disable-next-line react-hooks/rules-of-hooks
11
+ usePlugins([
12
+ require.resolve('@modern-js/plugin-analyze/cli'),
13
+ require.resolve('@modern-js/plugin-fast-refresh/cli'),
14
+ require.resolve('@modern-js/plugin-polyfill/cli'),
15
+ ]);
16
+
17
+ export default createPlugin(
18
+ (() => {
19
+ const locale = getLocaleLanguage();
20
+ i18n.changeLanguage({ locale });
21
+
22
+ lifecycle();
23
+
24
+ return {
25
+ commands({ program }: any) {
26
+ program
27
+ .command('dev')
28
+ .usage('[options]')
29
+ .description(i18n.t(localeKeys.command.dev.describe))
30
+ .option('-c --config <config>', i18n.t(localeKeys.command.dev.config))
31
+ .action(async () => {
32
+ await dev();
33
+ });
34
+
35
+ program
36
+ .command('build')
37
+ .usage('[options]')
38
+ .description(i18n.t(localeKeys.command.build.describe))
39
+ .action(async () => {
40
+ const { build } = await import('./commands/build');
41
+ await build();
42
+ });
43
+
44
+ program
45
+ .command('start')
46
+ .usage('[options]')
47
+ .description(i18n.t(localeKeys.command.start.describe))
48
+ .action(async () => {
49
+ await start();
50
+ });
51
+
52
+ program
53
+ .command('new')
54
+ .usage('[options]')
55
+ .description(i18n.t(localeKeys.command.new.describe))
56
+ .option('-d, --debug', i18n.t(localeKeys.command.new.debug), false)
57
+ .option(
58
+ '-c, --config <config>',
59
+ i18n.t(localeKeys.command.new.config),
60
+ )
61
+ .option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag))
62
+ .option('--registry', i18n.t(localeKeys.command.new.registry))
63
+ .action(async (options: any) => {
64
+ const { MWANewAction } = await import('@modern-js/new-action');
65
+ await MWANewAction({ ...options, locale });
66
+ });
67
+ },
68
+ async fileChange() {
69
+ // restart cli.
70
+ const shouldRestart = await cli.restart();
71
+ if (shouldRestart) {
72
+ await dev();
73
+ }
74
+ },
75
+ };
76
+ }) as any,
77
+ {
78
+ post: [
79
+ '@modern-js/plugin-analyze',
80
+ '@modern-js/plugin-fast-refresh',
81
+ '@modern-js/plugin-ssr',
82
+ '@modern-js/plugin-state',
83
+ '@modern-js/plugin-router',
84
+ '@modern-js/plugin-polyfill',
85
+ ],
86
+ },
87
+ );
@@ -0,0 +1,37 @@
1
+ import { createAsyncWaterfall, createAsyncWorkflow } from '@modern-js/plugin';
2
+ import { registerHook } from '@modern-js/core';
3
+
4
+ import type { Compiler, Configuration, MultiCompiler } from '@modern-js/types';
5
+
6
+ export const beforeDev = createAsyncWorkflow();
7
+
8
+ export const afterDev = createAsyncWorkflow();
9
+
10
+ export const beforeCreateCompiler = createAsyncWorkflow<{
11
+ webpackConfigs: Configuration[];
12
+ }>();
13
+
14
+ export const afterCreateCompiler = createAsyncWorkflow<{
15
+ compiler: Compiler | MultiCompiler | undefined;
16
+ }>();
17
+
18
+ export const beforePrintInstructions =
19
+ createAsyncWaterfall<{ instructions: string }>();
20
+
21
+ export const beforeBuild = createAsyncWorkflow<{
22
+ webpackConfigs: Configuration[];
23
+ }>();
24
+
25
+ export const afterBuild = createAsyncWorkflow();
26
+
27
+ export const lifecycle = () => {
28
+ registerHook({
29
+ beforeDev,
30
+ afterDev,
31
+ beforeCreateCompiler,
32
+ afterCreateCompiler,
33
+ beforePrintInstructions,
34
+ beforeBuild,
35
+ afterBuild,
36
+ });
37
+ };
@@ -0,0 +1,17 @@
1
+ export const EN_LOCALE = {
2
+ command: {
3
+ dev: {
4
+ describe: 'start dev server',
5
+ config: 'specify config file',
6
+ },
7
+ build: { describe: 'build application' },
8
+ start: { describe: 'start server' },
9
+ new: {
10
+ describe: 'generator runner for MWA project',
11
+ debug: 'using debug mode to log something',
12
+ config: 'set default generator config(json string)',
13
+ distTag: `use specified tag version for it's generator`,
14
+ registry: 'set npm registry url to run npm command',
15
+ },
16
+ },
17
+ };
@@ -0,0 +1,9 @@
1
+ import { I18n } from '@modern-js/plugin-i18n';
2
+ import { ZH_LOCALE } from './zh';
3
+ import { EN_LOCALE } from './en';
4
+
5
+ const i18n = new I18n();
6
+
7
+ const localeKeys = i18n.init('zh', { zh: ZH_LOCALE, en: EN_LOCALE });
8
+
9
+ export { i18n, localeKeys };
@@ -0,0 +1,17 @@
1
+ export const ZH_LOCALE = {
2
+ command: {
3
+ dev: {
4
+ describe: '本地开发命令',
5
+ config: '制定配置文件路径',
6
+ },
7
+ build: { describe: '构建应用命令' },
8
+ start: { describe: '应用启动命令' },
9
+ new: {
10
+ describe: 'MWA 项目中中执行生成器',
11
+ debug: '开启 Debug 模式,打印调试日志信息',
12
+ config: '生成器运行默认配置(JSON 字符串)',
13
+ distTag: '生成器使用特殊的 npm Tag 版本',
14
+ registry: '生成器运行过程中定制 npm Registry',
15
+ },
16
+ },
17
+ };