@modern-js/base-generator 3.7.0 → 3.7.1

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 (2) hide show
  1. package/package.json +8 -8
  2. package/src/index.ts +0 -76
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.7.0",
18
+ "version": "3.7.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./src/index.ts",
21
21
  "main": "./dist/index.js",
@@ -24,17 +24,17 @@
24
24
  "/dist/index.js"
25
25
  ],
26
26
  "devDependencies": {
27
- "@modern-js/codesmith-utils": "2.6.4",
28
- "@modern-js/codesmith": "2.6.4",
29
- "@modern-js/codesmith-api-app": "2.6.4",
27
+ "@modern-js/codesmith-utils": "2.6.5",
28
+ "@modern-js/codesmith": "2.6.5",
29
+ "@modern-js/codesmith-api-app": "2.6.5",
30
30
  "@types/jest": "^29",
31
31
  "@types/node": "^14",
32
32
  "jest": "^29",
33
33
  "typescript": "^5",
34
- "@modern-js/generator-common": "3.7.0",
35
- "@modern-js/generator-utils": "3.7.0",
36
- "@scripts/build": "2.60.4",
37
- "@scripts/jest-config": "2.60.4"
34
+ "@modern-js/generator-utils": "3.7.1",
35
+ "@modern-js/generator-common": "3.7.1",
36
+ "@scripts/jest-config": "2.60.5",
37
+ "@scripts/build": "2.60.5"
38
38
  },
39
39
  "sideEffects": false,
40
40
  "publishConfig": {
package/src/index.ts DELETED
@@ -1,76 +0,0 @@
1
- import type { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
2
- import { AppAPI } from '@modern-js/codesmith-api-app';
3
- import { PackageManager, getBaseSchema } from '@modern-js/generator-common';
4
-
5
- const handleTemplateFile = async (
6
- context: GeneratorContext,
7
- _generator: GeneratorCore,
8
- appApi: AppAPI,
9
- ) => {
10
- const { hasPlugin, generatorPlugin, ...extra } = context.config;
11
- let ans: Record<string, unknown> = {};
12
- if (hasPlugin) {
13
- await generatorPlugin.installPlugins('custom', extra);
14
- const schema = generatorPlugin.getInputSchema();
15
- const inputValue = generatorPlugin.getInputValue();
16
- const defaultConfig = generatorPlugin.getDefaultConfig();
17
- ans = await appApi.getInputBySchema(
18
- schema,
19
- 'formily',
20
- {
21
- ...context.config,
22
- ...defaultConfig,
23
- },
24
- {},
25
- { ...inputValue },
26
- );
27
- } else {
28
- ans = await appApi.getInputBySchemaFunc(getBaseSchema, context.config);
29
- }
30
-
31
- const { packageManager } = ans;
32
-
33
- await appApi.forgeTemplate(
34
- 'templates/base-template/**/*',
35
- undefined,
36
- resourceKey =>
37
- resourceKey
38
- .replace('templates/base-template/', '')
39
- .replace('.handlebars', ''),
40
- );
41
-
42
- if (packageManager === PackageManager.Pnpm) {
43
- await appApi.forgeTemplate(
44
- 'templates/pnpm-template/**/*',
45
- undefined,
46
- resourceKey =>
47
- resourceKey
48
- .replace('templates/pnpm-template/npmrc', '.npmrc')
49
- .replace('.handlebars', ''),
50
- );
51
- }
52
- };
53
-
54
- export default async (context: GeneratorContext, generator: GeneratorCore) => {
55
- const appApi = new AppAPI(context, generator);
56
- const { locale } = context.config;
57
- appApi.i18n.changeLanguage({ locale });
58
-
59
- if (!(await appApi.checkEnvironment())) {
60
- process.exit(1);
61
- }
62
-
63
- generator.logger.debug(`🚀 [Start Run Base Generator]`);
64
- generator.logger.debug(
65
- '💡 [Current Config]:',
66
- JSON.stringify(context.config),
67
- );
68
-
69
- await handleTemplateFile(context, generator, appApi);
70
-
71
- if (context.handleForged) {
72
- await context.handleForged('custom', context, context.config.hasPlugin);
73
- }
74
-
75
- generator.logger.debug(`🌟 [End Run Base Generator]`);
76
- };