@modern-js/router-v5-generator 3.0.5 → 3.0.7
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.
- package/README.md +14 -18
- package/dist/index.js +3344 -2278
- package/package.json +10 -10
- package/src/index.ts +45 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/router-v5-generator",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
|
4
4
|
"homepage": "https://modernjs.dev",
|
|
5
5
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|
|
6
6
|
"repository": "modern-js-dev/modern.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "3.0.
|
|
14
|
+
"version": "3.0.7",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
17
|
"files": [
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/runtime": "^7.18.0",
|
|
23
|
-
"@modern-js/codesmith": "2.0.
|
|
24
|
-
"@modern-js/codesmith-api-app": "2.0.
|
|
23
|
+
"@modern-js/codesmith": "2.0.4",
|
|
24
|
+
"@modern-js/codesmith-api-app": "2.0.4",
|
|
25
25
|
"@types/jest": "^27",
|
|
26
26
|
"@types/node": "^14",
|
|
27
27
|
"jest": "^27",
|
|
28
28
|
"typescript": "^4",
|
|
29
|
-
"@modern-js/
|
|
30
|
-
"@modern-js/
|
|
31
|
-
"@modern-js/generator
|
|
32
|
-
"@modern-js/
|
|
33
|
-
"@scripts/
|
|
34
|
-
"@scripts/
|
|
29
|
+
"@modern-js/plugin-i18n": "2.5.0",
|
|
30
|
+
"@modern-js/generator-utils": "3.0.7",
|
|
31
|
+
"@modern-js/dependence-generator": "3.0.7",
|
|
32
|
+
"@modern-js/generator-common": "3.0.7",
|
|
33
|
+
"@scripts/jest-config": "2.5.0",
|
|
34
|
+
"@scripts/build": "2.5.0"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
|
|
3
3
|
import { AppAPI } from '@modern-js/codesmith-api-app';
|
|
4
|
-
import { fs, getModernConfigFile } from '@modern-js/generator-utils';
|
|
4
|
+
import { fs, chalk, getModernConfigFile } from '@modern-js/generator-utils';
|
|
5
5
|
import {
|
|
6
6
|
DependenceGenerator,
|
|
7
7
|
i18n as commonI18n,
|
|
@@ -65,6 +65,7 @@ export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
|
65
65
|
const { locale } = context.config;
|
|
66
66
|
commonI18n.changeLanguage({ locale });
|
|
67
67
|
appApi.i18n.changeLanguage({ locale });
|
|
68
|
+
i18n.changeLanguage(locale);
|
|
68
69
|
|
|
69
70
|
if (!(await appApi.checkEnvironment())) {
|
|
70
71
|
// eslint-disable-next-line no-process-exit
|
|
@@ -84,17 +85,49 @@ export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
|
84
85
|
} else {
|
|
85
86
|
const appDir = context.materials.default.basePath;
|
|
86
87
|
const configFile = await getModernConfigFile(appDir);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
),
|
|
88
|
+
const isTS = configFile.endsWith('ts');
|
|
89
|
+
const { pluginName, pluginDependence } = context.config;
|
|
90
|
+
console.info(
|
|
91
|
+
chalk.green(`\n[INFO]`),
|
|
92
|
+
`${i18n.t(localeKeys.success)}`,
|
|
93
|
+
chalk.yellow.bold(`${configFile}`),
|
|
94
|
+
':',
|
|
95
|
+
'\n',
|
|
96
|
+
);
|
|
97
|
+
console.info(
|
|
98
|
+
chalk.yellow.bold(`import ${pluginName} from '${pluginDependence}';`),
|
|
99
|
+
);
|
|
100
|
+
if (isTS) {
|
|
101
|
+
console.info(`
|
|
102
|
+
export default defineConfig({
|
|
103
|
+
...,
|
|
104
|
+
runtime: {
|
|
105
|
+
...,
|
|
106
|
+
router: {
|
|
107
|
+
${chalk.yellow.bold(`mode: 'react-router-5'`)},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
plugins: [..., ${chalk.yellow.bold(`${pluginName}()`)}],
|
|
111
|
+
});
|
|
112
|
+
`);
|
|
113
|
+
} else {
|
|
114
|
+
console.info(`
|
|
115
|
+
module.exports = {
|
|
116
|
+
...,
|
|
117
|
+
runtime: {
|
|
118
|
+
...,
|
|
119
|
+
router: {
|
|
120
|
+
${chalk.yellow.bold(`mode: 'react-router-5'`)},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
plugins: [..., ${chalk.yellow.bold(`${pluginName}()`)}],
|
|
124
|
+
};
|
|
125
|
+
`);
|
|
126
|
+
}
|
|
127
|
+
console.info(
|
|
128
|
+
`${i18n.t(localeKeys.successTooltip)} ${chalk.yellow.bold(
|
|
129
|
+
`@modern-js/runtime/router-v5`,
|
|
130
|
+
)} ${i18n.t(localeKeys.successTooltipSuffix)}`,
|
|
98
131
|
);
|
|
99
132
|
}
|
|
100
133
|
}
|