@modern-js/repo-generator 3.6.3 → 3.6.4-next.0
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/dist/index.js +35736 -89500
- package/package.json +4 -16
- package/src/index.ts +17 -108
package/package.json
CHANGED
@@ -15,37 +15,25 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "3.6.
|
18
|
+
"version": "3.6.4-next.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"main": "./dist/index.js",
|
21
21
|
"files": [
|
22
22
|
"/templates",
|
23
23
|
"/dist/index.js"
|
24
24
|
],
|
25
|
-
"dependencies": {
|
26
|
-
"@modern-js/utils": "2.60.3"
|
27
|
-
},
|
28
25
|
"devDependencies": {
|
29
|
-
"@modern-js/codesmith": "2.
|
30
|
-
"@modern-js/codesmith-api-app": "2.5.2",
|
31
|
-
"@types/jest": "^29",
|
26
|
+
"@modern-js/codesmith": "2.6.0",
|
32
27
|
"@types/node": "^14",
|
33
|
-
"jest": "^29",
|
34
28
|
"typescript": "^5",
|
35
|
-
"@modern-js/generator-common": "3.6.3",
|
36
|
-
"@modern-js/base-generator": "3.6.3",
|
37
29
|
"@modern-js/generator-utils": "3.6.3",
|
38
|
-
"@modern-js/generator-plugin": "3.6.3",
|
39
|
-
"@modern-js/module-generator": "3.6.3",
|
40
|
-
"@modern-js/mwa-generator": "3.6.3",
|
41
30
|
"@scripts/build": "2.60.3",
|
42
|
-
"@
|
31
|
+
"@modern-js/repo-next-generator": "3.6.3"
|
43
32
|
},
|
44
33
|
"sideEffects": false,
|
45
34
|
"publishConfig": {
|
46
35
|
"registry": "https://registry.npmjs.org/",
|
47
|
-
"access": "public"
|
48
|
-
"provenance": true
|
36
|
+
"access": "public"
|
49
37
|
},
|
50
38
|
"types": "./src/index.ts",
|
51
39
|
"scripts": {
|
package/src/index.ts
CHANGED
@@ -1,123 +1,32 @@
|
|
1
|
-
import type { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
|
2
|
-
import { AppAPI } from '@modern-js/codesmith-api-app';
|
3
1
|
import {
|
4
|
-
|
5
|
-
type
|
6
|
-
|
7
|
-
|
8
|
-
getScenesSchema,
|
9
|
-
getSolutionSchema,
|
10
|
-
i18n,
|
11
|
-
} from '@modern-js/generator-common';
|
12
|
-
import { GeneratorPlugin } from '@modern-js/generator-plugin';
|
2
|
+
CodeSmith,
|
3
|
+
type GeneratorContext,
|
4
|
+
type GeneratorCore,
|
5
|
+
} from '@modern-js/codesmith';
|
13
6
|
import { getGeneratorPath } from '@modern-js/generator-utils';
|
14
|
-
import { merge } from '@modern-js/utils/lodash';
|
15
7
|
|
16
|
-
|
17
|
-
|
8
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
9
|
+
process.setMaxListeners(20);
|
18
10
|
|
19
|
-
|
20
|
-
merge(
|
21
|
-
context.config,
|
22
|
-
{ solution: defaultSolution },
|
23
|
-
SolutionDefaultConfig[defaultSolution as Solution],
|
24
|
-
);
|
25
|
-
}
|
26
|
-
};
|
11
|
+
// check prepare global
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
const { extendPlugin, customPlugin } = generatorPlugin;
|
36
|
-
const { solution, scenes } = context.config;
|
37
|
-
if (!scenes || scenes === solution) {
|
38
|
-
return extendPlugin?.[solution] && extendPlugin[solution].length > 0;
|
13
|
+
if (!(global as any).codesmith) {
|
14
|
+
generator.logger.warn(
|
15
|
+
'🟡 Please use the latest @modern-js/create version to run generator',
|
16
|
+
);
|
17
|
+
const codesmith = new CodeSmith({});
|
18
|
+
await codesmith.prepareGlobal();
|
39
19
|
}
|
40
|
-
return Boolean(customPlugin[solution]?.find(plugin => plugin.key === scenes));
|
41
|
-
};
|
42
|
-
|
43
|
-
const handleTemplateFile = async (
|
44
|
-
context: GeneratorContext,
|
45
|
-
generator: GeneratorCore,
|
46
|
-
appApi: AppAPI,
|
47
|
-
generatorPlugin?: GeneratorPlugin,
|
48
|
-
) => {
|
49
|
-
const { solution } = await appApi.getInputBySchemaFunc(getSolutionSchema, {
|
50
|
-
...context.config,
|
51
|
-
customPlugin: generatorPlugin?.customPlugin,
|
52
|
-
});
|
53
20
|
|
54
|
-
|
21
|
+
const RepoNextGeneratort = '@modern-js/repo-next-generator';
|
55
22
|
|
56
|
-
|
57
|
-
|
58
|
-
? BaseGenerator
|
59
|
-
: SolutionGenerator[solution as Solution];
|
60
|
-
|
61
|
-
if (!solution || !solutionGenerator) {
|
62
|
-
generator.logger.error(`🔴 [Check Solution]: ${solution} is not support`);
|
63
|
-
}
|
64
|
-
|
65
|
-
await appApi.runSubGenerator(
|
66
|
-
getGeneratorPath(solutionGenerator, context.config.distTag, [__dirname]),
|
23
|
+
generator.runSubGenerator(
|
24
|
+
getGeneratorPath(RepoNextGeneratort, context.config.distTag, [__dirname]),
|
67
25
|
undefined,
|
68
|
-
|
69
|
-
...context.config,
|
70
|
-
hasPlugin: getNeedRunPlugin(context, generatorPlugin),
|
71
|
-
generatorPlugin,
|
72
|
-
},
|
73
|
-
);
|
74
|
-
};
|
75
|
-
|
76
|
-
const handlePlugin = async (
|
77
|
-
context: GeneratorContext,
|
78
|
-
generator: GeneratorCore,
|
79
|
-
) => {
|
80
|
-
const { plugins, registry, locale } = context.config;
|
81
|
-
const generatorPlugin = new GeneratorPlugin(
|
82
|
-
generator.logger,
|
83
|
-
generator.event,
|
84
|
-
locale,
|
26
|
+
context.config,
|
85
27
|
);
|
86
|
-
await generatorPlugin.setupPlugin(plugins, registry);
|
87
|
-
return generatorPlugin;
|
88
|
-
};
|
89
|
-
|
90
|
-
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
91
|
-
process.setMaxListeners(20);
|
92
|
-
|
93
|
-
const appApi = new AppAPI(context, generator);
|
94
|
-
|
95
|
-
const { locale } = context.config;
|
96
|
-
i18n.changeLanguage({ locale });
|
97
|
-
appApi.i18n.changeLanguage({ locale });
|
98
28
|
|
99
|
-
if (!(await appApi.checkEnvironment())) {
|
100
|
-
process.exit(1);
|
101
|
-
}
|
102
29
|
generator.logger.debug(`🚀 [Start Run Repo Generator]`);
|
103
|
-
generator.logger.debug(
|
104
|
-
'💡 [Current Config]:',
|
105
|
-
JSON.stringify(context.config),
|
106
|
-
);
|
107
|
-
|
108
|
-
mergeDefaultConfig(context);
|
109
|
-
|
110
|
-
let generatorPlugin;
|
111
|
-
if (context.config.plugins?.length > 0) {
|
112
|
-
generatorPlugin = await handlePlugin(context, generator);
|
113
|
-
}
|
114
|
-
|
115
|
-
try {
|
116
|
-
await handleTemplateFile(context, generator, appApi, generatorPlugin);
|
117
|
-
} catch (e) {
|
118
|
-
generator.logger.error(`🔴 [Handle Repo Template Error]:`, e);
|
119
|
-
process.exit(1);
|
120
|
-
}
|
121
30
|
|
122
31
|
generator.logger.debug(`🚀 [End Run Repo Generator]`);
|
123
32
|
};
|