@modern-js/router-v5-generator 3.7.0 → 3.7.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.
- package/package.json +10 -10
- package/src/index.ts +0 -141
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.7.
|
|
18
|
+
"version": "3.7.2",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"files": [
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"/dist/index.js"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@modern-js/codesmith": "2.6.
|
|
27
|
-
"@modern-js/codesmith-utils": "2.6.
|
|
28
|
-
"@modern-js/codesmith-api-app": "2.6.
|
|
26
|
+
"@modern-js/codesmith": "2.6.5",
|
|
27
|
+
"@modern-js/codesmith-utils": "2.6.5",
|
|
28
|
+
"@modern-js/codesmith-api-app": "2.6.5",
|
|
29
29
|
"@types/jest": "^29",
|
|
30
30
|
"@types/node": "^14",
|
|
31
31
|
"jest": "^29",
|
|
32
32
|
"typescript": "^5",
|
|
33
|
-
"@modern-js/dependence-generator": "3.7.
|
|
34
|
-
"@modern-js/
|
|
35
|
-
"@
|
|
36
|
-
"@modern-js/
|
|
37
|
-
"@
|
|
38
|
-
"@scripts/
|
|
33
|
+
"@modern-js/dependence-generator": "3.7.2",
|
|
34
|
+
"@modern-js/generator-common": "3.7.2",
|
|
35
|
+
"@modern-js/generator-utils": "3.7.2",
|
|
36
|
+
"@modern-js/plugin-i18n": "2.60.6",
|
|
37
|
+
"@scripts/jest-config": "2.60.6",
|
|
38
|
+
"@scripts/build": "2.60.6"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|
|
41
41
|
"publishConfig": {
|
package/src/index.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import type { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
|
|
3
|
-
import { AppAPI } from '@modern-js/codesmith-api-app';
|
|
4
|
-
import {
|
|
5
|
-
DependenceGenerator,
|
|
6
|
-
i18n as commonI18n,
|
|
7
|
-
} from '@modern-js/generator-common';
|
|
8
|
-
import {
|
|
9
|
-
fs,
|
|
10
|
-
chalk,
|
|
11
|
-
getGeneratorPath,
|
|
12
|
-
getModernConfigFile,
|
|
13
|
-
} from '@modern-js/generator-utils';
|
|
14
|
-
import { i18n, localeKeys } from './locale';
|
|
15
|
-
|
|
16
|
-
const ReactRouter6Type = `/// <reference types='@modern-js/runtime/types/router' />`;
|
|
17
|
-
|
|
18
|
-
const handleTemplateFile = async (
|
|
19
|
-
context: GeneratorContext,
|
|
20
|
-
generator: GeneratorCore,
|
|
21
|
-
appApi: AppAPI,
|
|
22
|
-
) => {
|
|
23
|
-
const { sourceTypeFile, projectPath } = context.config;
|
|
24
|
-
|
|
25
|
-
const appDir = context.materials.default.basePath;
|
|
26
|
-
const isTs = fs.existsSync(
|
|
27
|
-
path.join(appDir, projectPath || '', 'tsconfig.json'),
|
|
28
|
-
);
|
|
29
|
-
if (isTs) {
|
|
30
|
-
const typePath = path.join(
|
|
31
|
-
appDir,
|
|
32
|
-
projectPath || '',
|
|
33
|
-
'src',
|
|
34
|
-
sourceTypeFile || 'modern-app-env.d.ts',
|
|
35
|
-
);
|
|
36
|
-
if (fs.existsSync(typePath)) {
|
|
37
|
-
const npmrc = fs.readFileSync(typePath, 'utf-8');
|
|
38
|
-
if (npmrc.includes(ReactRouter6Type)) {
|
|
39
|
-
fs.writeFileSync(
|
|
40
|
-
typePath,
|
|
41
|
-
npmrc.replace(ReactRouter6Type, ''),
|
|
42
|
-
'utf-8',
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await appApi.runSubGenerator(
|
|
49
|
-
getGeneratorPath(DependenceGenerator, context.config.distTag, [__dirname]),
|
|
50
|
-
undefined,
|
|
51
|
-
{
|
|
52
|
-
...context.config,
|
|
53
|
-
isSubGenerator: true,
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
59
|
-
const appApi = new AppAPI(context, generator);
|
|
60
|
-
|
|
61
|
-
const { locale } = context.config;
|
|
62
|
-
commonI18n.changeLanguage({ locale });
|
|
63
|
-
appApi.i18n.changeLanguage({ locale });
|
|
64
|
-
i18n.changeLanguage(locale);
|
|
65
|
-
|
|
66
|
-
if (!(await appApi.checkEnvironment())) {
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
generator.logger.debug(`🚀 [Start Run Router-v5 Generator]`);
|
|
71
|
-
generator.logger.debug(
|
|
72
|
-
'💡 [Current Config]:',
|
|
73
|
-
JSON.stringify(context.config),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
await handleTemplateFile(context, generator, appApi);
|
|
77
|
-
|
|
78
|
-
if (!context.config.isSubGenerator) {
|
|
79
|
-
await appApi.runInstall(undefined, { ignoreScripts: true });
|
|
80
|
-
if (!context.config.pluginName) {
|
|
81
|
-
appApi.showSuccessInfo();
|
|
82
|
-
} else {
|
|
83
|
-
const appDir = context.materials.default.basePath;
|
|
84
|
-
const configFile = await getModernConfigFile(appDir);
|
|
85
|
-
const isTS = configFile.endsWith('ts');
|
|
86
|
-
const { pluginName, pluginDependence, shouldUsePluginNameExport } =
|
|
87
|
-
context.config;
|
|
88
|
-
console.info(
|
|
89
|
-
chalk.green(`\n[INFO]`),
|
|
90
|
-
`${i18n.t(localeKeys.success)}`,
|
|
91
|
-
chalk.yellow.bold(`${configFile}`),
|
|
92
|
-
':',
|
|
93
|
-
'\n',
|
|
94
|
-
);
|
|
95
|
-
if (shouldUsePluginNameExport) {
|
|
96
|
-
console.info(
|
|
97
|
-
chalk.yellow.bold(
|
|
98
|
-
`import { ${pluginName} } from '${pluginDependence}';`,
|
|
99
|
-
),
|
|
100
|
-
);
|
|
101
|
-
} else {
|
|
102
|
-
console.info(
|
|
103
|
-
chalk.yellow.bold(`import ${pluginName} from '${pluginDependence}';`),
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
if (isTS) {
|
|
107
|
-
console.info(`
|
|
108
|
-
export default defineConfig({
|
|
109
|
-
...,
|
|
110
|
-
runtime: {
|
|
111
|
-
...,
|
|
112
|
-
router: {
|
|
113
|
-
${chalk.yellow.bold(`mode: 'react-router-5'`)},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
plugins: [..., ${chalk.yellow.bold(`${pluginName}()`)}],
|
|
117
|
-
});
|
|
118
|
-
`);
|
|
119
|
-
} else {
|
|
120
|
-
console.info(`
|
|
121
|
-
module.exports = {
|
|
122
|
-
...,
|
|
123
|
-
runtime: {
|
|
124
|
-
...,
|
|
125
|
-
router: {
|
|
126
|
-
${chalk.yellow.bold(`mode: 'react-router-5'`)},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
plugins: [..., ${chalk.yellow.bold(`${pluginName}()`)}],
|
|
130
|
-
};
|
|
131
|
-
`);
|
|
132
|
-
}
|
|
133
|
-
console.info(
|
|
134
|
-
`${i18n.t(localeKeys.successTooltip)} ${chalk.yellow.bold(
|
|
135
|
-
`@modern-js/runtime/router-v5`,
|
|
136
|
-
)} ${i18n.t(localeKeys.successTooltipSuffix)}`,
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
generator.logger.debug(`🌟 [End Run Repo Generator]`);
|
|
141
|
-
};
|