@modern-js/mwa-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.
- package/dist/index.js +15 -10
- package/package.json +13 -13
- package/templates/base-template/package.json.handlebars +5 -5
- package/src/index.ts +0 -253
package/dist/index.js
CHANGED
|
@@ -1290,9 +1290,9 @@
|
|
|
1290
1290
|
module1.exports.win32 = win32;
|
|
1291
1291
|
}
|
|
1292
1292
|
});
|
|
1293
|
-
// ../../../../node_modules/.pnpm/glob@7.2.
|
|
1293
|
+
// ../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js
|
|
1294
1294
|
var require_common = __commonJS({
|
|
1295
|
-
"../../../../node_modules/.pnpm/glob@7.2.
|
|
1295
|
+
"../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js" (exports) {
|
|
1296
1296
|
"use strict";
|
|
1297
1297
|
exports.setopts = setopts;
|
|
1298
1298
|
exports.ownProp = ownProp;
|
|
@@ -1383,6 +1383,7 @@
|
|
|
1383
1383
|
self2.nomount = !!options.nomount;
|
|
1384
1384
|
options.nonegate = true;
|
|
1385
1385
|
options.nocomment = true;
|
|
1386
|
+
options.allowWindowsEscape = false;
|
|
1386
1387
|
self2.minimatch = new Minimatch(pattern, options);
|
|
1387
1388
|
self2.options = self2.minimatch.options;
|
|
1388
1389
|
}
|
|
@@ -1470,9 +1471,9 @@
|
|
|
1470
1471
|
}
|
|
1471
1472
|
}
|
|
1472
1473
|
});
|
|
1473
|
-
// ../../../../node_modules/.pnpm/glob@7.2.
|
|
1474
|
+
// ../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js
|
|
1474
1475
|
var require_sync = __commonJS({
|
|
1475
|
-
"../../../../node_modules/.pnpm/glob@7.2.
|
|
1476
|
+
"../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js" (exports, module1) {
|
|
1476
1477
|
"use strict";
|
|
1477
1478
|
module1.exports = globSync;
|
|
1478
1479
|
globSync.GlobSync = GlobSync;
|
|
@@ -1507,7 +1508,7 @@
|
|
|
1507
1508
|
this._finish();
|
|
1508
1509
|
}
|
|
1509
1510
|
GlobSync.prototype._finish = function() {
|
|
1510
|
-
assert(this instanceof GlobSync);
|
|
1511
|
+
assert.ok(this instanceof GlobSync);
|
|
1511
1512
|
if (this.realpath) {
|
|
1512
1513
|
var self2 = this;
|
|
1513
1514
|
this.matches.forEach(function(matchset, index) {
|
|
@@ -1527,7 +1528,7 @@
|
|
|
1527
1528
|
common2.finish(this);
|
|
1528
1529
|
};
|
|
1529
1530
|
GlobSync.prototype._process = function(pattern, index, inGlobStar) {
|
|
1530
|
-
assert(this instanceof GlobSync);
|
|
1531
|
+
assert.ok(this instanceof GlobSync);
|
|
1531
1532
|
var n = 0;
|
|
1532
1533
|
while(typeof pattern[n] === "string"){
|
|
1533
1534
|
n++;
|
|
@@ -1547,7 +1548,9 @@
|
|
|
1547
1548
|
var remain = pattern.slice(n);
|
|
1548
1549
|
var read;
|
|
1549
1550
|
if (prefix === null) read = ".";
|
|
1550
|
-
else if (isAbsolute(prefix) || isAbsolute(pattern.
|
|
1551
|
+
else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
|
|
1552
|
+
return typeof p === "string" ? p : "[*]";
|
|
1553
|
+
}).join("/"))) {
|
|
1551
1554
|
if (!prefix || !isAbsolute(prefix)) prefix = "/" + prefix;
|
|
1552
1555
|
read = prefix;
|
|
1553
1556
|
} else read = prefix;
|
|
@@ -1898,9 +1901,9 @@
|
|
|
1898
1901
|
}
|
|
1899
1902
|
}
|
|
1900
1903
|
});
|
|
1901
|
-
// ../../../../node_modules/.pnpm/glob@7.2.
|
|
1904
|
+
// ../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js
|
|
1902
1905
|
var require_glob = __commonJS({
|
|
1903
|
-
"../../../../node_modules/.pnpm/glob@7.2.
|
|
1906
|
+
"../../../../node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js" (exports, module1) {
|
|
1904
1907
|
"use strict";
|
|
1905
1908
|
module1.exports = glob2;
|
|
1906
1909
|
var rp = require_fs();
|
|
@@ -2114,7 +2117,9 @@
|
|
|
2114
2117
|
var remain = pattern.slice(n);
|
|
2115
2118
|
var read;
|
|
2116
2119
|
if (prefix === null) read = ".";
|
|
2117
|
-
else if (isAbsolute(prefix) || isAbsolute(pattern.
|
|
2120
|
+
else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
|
|
2121
|
+
return typeof p === "string" ? p : "[*]";
|
|
2122
|
+
}).join("/"))) {
|
|
2118
2123
|
if (!prefix || !isAbsolute(prefix)) prefix = "/" + prefix;
|
|
2119
2124
|
read = prefix;
|
|
2120
2125
|
} else read = prefix;
|
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.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"files": [
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"/dist/index.js"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@modern-js/codesmith-utils": "2.6.
|
|
27
|
-
"@modern-js/codesmith": "2.6.
|
|
28
|
-
"@modern-js/codesmith-api-app": "2.6.
|
|
26
|
+
"@modern-js/codesmith-utils": "2.6.5",
|
|
27
|
+
"@modern-js/codesmith": "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/base-generator": "3.7.
|
|
34
|
-
"@modern-js/generator
|
|
35
|
-
"@modern-js/
|
|
36
|
-
"@modern-js/generator-
|
|
37
|
-
"@modern-js/
|
|
38
|
-
"@modern-js/packages-generator": "3.7.
|
|
39
|
-
"@modern-js/plugin-i18n": "2.60.
|
|
40
|
-
"@scripts/build": "2.60.
|
|
41
|
-
"@scripts/jest-config": "2.60.
|
|
33
|
+
"@modern-js/base-generator": "3.7.1",
|
|
34
|
+
"@modern-js/dependence-generator": "3.7.1",
|
|
35
|
+
"@modern-js/entry-generator": "3.7.1",
|
|
36
|
+
"@modern-js/generator-common": "3.7.1",
|
|
37
|
+
"@modern-js/generator-utils": "3.7.1",
|
|
38
|
+
"@modern-js/packages-generator": "3.7.1",
|
|
39
|
+
"@modern-js/plugin-i18n": "2.60.5",
|
|
40
|
+
"@scripts/build": "2.60.5",
|
|
41
|
+
"@scripts/jest-config": "2.60.5"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"publishConfig": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
{{/unless}}
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@modern-js/runtime": "{{modernVersion}}",
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
32
|
+
"react": "^18.3.1",
|
|
33
|
+
"react-dom": "^18.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@modern-js/app-tools": "{{modernVersion}}",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
{{#if isTs}}
|
|
40
40
|
"typescript": "~5.0.4",
|
|
41
41
|
"@types/jest": "~29.2.4",
|
|
42
|
-
"@types/node": "~
|
|
43
|
-
"@types/react": "
|
|
44
|
-
"@types/react-dom": "~18.
|
|
42
|
+
"@types/node": "~18.11.9",
|
|
43
|
+
"@types/react": "^18.3.11",
|
|
44
|
+
"@types/react-dom": "~18.3.1",
|
|
45
45
|
{{/if}}
|
|
46
46
|
"lint-staged": "~13.1.0",
|
|
47
47
|
"simple-git-hooks": "^2.11.1",
|
package/src/index.ts
DELETED
|
@@ -1,253 +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
|
-
BaseGenerator,
|
|
6
|
-
EntryGenerator,
|
|
7
|
-
Language,
|
|
8
|
-
PackagesGenerator,
|
|
9
|
-
Solution,
|
|
10
|
-
i18n as commonI18n,
|
|
11
|
-
getMWASchema,
|
|
12
|
-
} from '@modern-js/generator-common';
|
|
13
|
-
import {
|
|
14
|
-
getAllPackages,
|
|
15
|
-
getGeneratorPath,
|
|
16
|
-
getMWAProjectPath,
|
|
17
|
-
getModernVersion,
|
|
18
|
-
getPackageManagerText,
|
|
19
|
-
i18n as utilsI18n,
|
|
20
|
-
validatePackageName,
|
|
21
|
-
validatePackagePath,
|
|
22
|
-
} from '@modern-js/generator-utils';
|
|
23
|
-
import { i18n, localeKeys } from './locale';
|
|
24
|
-
|
|
25
|
-
export const handleTemplateFile = async (
|
|
26
|
-
context: GeneratorContext,
|
|
27
|
-
generator: GeneratorCore,
|
|
28
|
-
appApi: AppAPI,
|
|
29
|
-
) => {
|
|
30
|
-
generator.logger?.timing(`🕐 Get Modern.js app-tools version`);
|
|
31
|
-
const modernVersion = await getModernVersion(
|
|
32
|
-
Solution.MWA,
|
|
33
|
-
context.config.registry,
|
|
34
|
-
context.config.distTag,
|
|
35
|
-
);
|
|
36
|
-
generator.logger?.timing(`🕐 Get Modern.js app-tools version`, true);
|
|
37
|
-
|
|
38
|
-
const { isMonorepoSubProject, projectDir = '' } = context.config;
|
|
39
|
-
|
|
40
|
-
const { outputPath } = generator;
|
|
41
|
-
|
|
42
|
-
let packages: string[] = [];
|
|
43
|
-
|
|
44
|
-
if (isMonorepoSubProject) {
|
|
45
|
-
try {
|
|
46
|
-
packages = getAllPackages(outputPath);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
generator.logger.debug(`❗️ [Get All Packages Error]: ${e}`);
|
|
49
|
-
generator.logger.warn(`🟡 ${i18n.t(localeKeys.get_packages_error)}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
context.config = {
|
|
54
|
-
...context.config,
|
|
55
|
-
isMwa: true,
|
|
56
|
-
isEmptySrc: true,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const { hasPlugin, generatorPlugin, ...extra } = context.config;
|
|
60
|
-
|
|
61
|
-
let ans: Record<string, unknown> = {};
|
|
62
|
-
|
|
63
|
-
if (hasPlugin) {
|
|
64
|
-
await generatorPlugin.installPlugins(Solution.MWA, extra);
|
|
65
|
-
const schema = generatorPlugin.getInputSchema();
|
|
66
|
-
const inputValue = generatorPlugin.getInputValue();
|
|
67
|
-
const defaultConfig = generatorPlugin.getDefaultConfig();
|
|
68
|
-
context.config.gitCommitMessage =
|
|
69
|
-
generatorPlugin.getGitMessage() || context.config.gitCommitMessage;
|
|
70
|
-
ans = await appApi.getInputBySchema(
|
|
71
|
-
schema,
|
|
72
|
-
'formily',
|
|
73
|
-
{ ...context.config, ...defaultConfig },
|
|
74
|
-
{
|
|
75
|
-
packageName: input =>
|
|
76
|
-
validatePackageName(input as string, packages, {
|
|
77
|
-
isMonorepoSubProject,
|
|
78
|
-
}),
|
|
79
|
-
packagePath: input =>
|
|
80
|
-
validatePackagePath(
|
|
81
|
-
input as string,
|
|
82
|
-
path.join(process.cwd(), projectDir),
|
|
83
|
-
{
|
|
84
|
-
isMwa: true,
|
|
85
|
-
},
|
|
86
|
-
),
|
|
87
|
-
},
|
|
88
|
-
{ ...inputValue },
|
|
89
|
-
);
|
|
90
|
-
} else {
|
|
91
|
-
ans = await appApi.getInputBySchemaFunc(
|
|
92
|
-
getMWASchema,
|
|
93
|
-
{ ...context.config },
|
|
94
|
-
{
|
|
95
|
-
packageName: input =>
|
|
96
|
-
validatePackageName(input as string, packages, {
|
|
97
|
-
isMonorepoSubProject,
|
|
98
|
-
}),
|
|
99
|
-
packagePath: input =>
|
|
100
|
-
validatePackagePath(
|
|
101
|
-
input as string,
|
|
102
|
-
path.join(process.cwd(), projectDir),
|
|
103
|
-
{ isMwa: true },
|
|
104
|
-
),
|
|
105
|
-
},
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
generator.logger.debug(`💡 [Input Answer]: ${JSON.stringify(ans)}`);
|
|
110
|
-
|
|
111
|
-
const { packageName, packagePath, language, packageManager } = ans;
|
|
112
|
-
const { packagesInfo } = context.config;
|
|
113
|
-
|
|
114
|
-
const bundler = `'rspack', // Set to 'webpack' to enable webpack`;
|
|
115
|
-
|
|
116
|
-
const projectPath = getMWAProjectPath(
|
|
117
|
-
packagePath as string,
|
|
118
|
-
isMonorepoSubProject,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const dirname = path.basename(generator.outputPath);
|
|
122
|
-
|
|
123
|
-
await appApi.runSubGenerator(
|
|
124
|
-
getGeneratorPath(BaseGenerator, context.config.distTag, [__dirname]),
|
|
125
|
-
undefined,
|
|
126
|
-
{ ...context.config, hasPlugin: false },
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
await appApi.forgeTemplate(
|
|
130
|
-
'templates/base-template/**/*',
|
|
131
|
-
undefined,
|
|
132
|
-
resourceKey =>
|
|
133
|
-
resourceKey
|
|
134
|
-
.replace('templates/base-template/', projectPath)
|
|
135
|
-
.replace('.handlebars', ''),
|
|
136
|
-
{
|
|
137
|
-
name: packageName || dirname,
|
|
138
|
-
isMonorepoSubProject,
|
|
139
|
-
modernVersion,
|
|
140
|
-
packageManager,
|
|
141
|
-
isTs: language === Language.TS,
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
if (language === Language.TS) {
|
|
146
|
-
await appApi.forgeTemplate(
|
|
147
|
-
'templates/ts-template/**/*',
|
|
148
|
-
undefined,
|
|
149
|
-
resourceKey =>
|
|
150
|
-
resourceKey
|
|
151
|
-
.replace('templates/ts-template/', projectPath)
|
|
152
|
-
.replace('.handlebars', ''),
|
|
153
|
-
{
|
|
154
|
-
bundler,
|
|
155
|
-
},
|
|
156
|
-
);
|
|
157
|
-
} else {
|
|
158
|
-
await appApi.forgeTemplate(
|
|
159
|
-
'templates/js-template/**/*',
|
|
160
|
-
undefined,
|
|
161
|
-
resourceKey =>
|
|
162
|
-
resourceKey
|
|
163
|
-
.replace('templates/js-template/', projectPath)
|
|
164
|
-
.replace('.handlebars', ''),
|
|
165
|
-
{
|
|
166
|
-
bundler,
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
await appApi.runSubGenerator(
|
|
172
|
-
getGeneratorPath(EntryGenerator, context.config.distTag, [__dirname]),
|
|
173
|
-
`./${projectPath}`,
|
|
174
|
-
{
|
|
175
|
-
...context.config,
|
|
176
|
-
isSubGenerator: true,
|
|
177
|
-
},
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
if (isMonorepoSubProject) {
|
|
181
|
-
await appApi.updateWorkspace({
|
|
182
|
-
name: packagePath as string,
|
|
183
|
-
path: projectPath,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (packagesInfo && Object.keys(packagesInfo).length > 0) {
|
|
188
|
-
await appApi.runSubGenerator(
|
|
189
|
-
getGeneratorPath(PackagesGenerator, context.config.distTag, [__dirname]),
|
|
190
|
-
undefined,
|
|
191
|
-
context.config,
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return { projectPath };
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
199
|
-
const appApi = new AppAPI(context, generator);
|
|
200
|
-
|
|
201
|
-
const { locale, successInfo } = context.config;
|
|
202
|
-
commonI18n.changeLanguage({ locale });
|
|
203
|
-
utilsI18n.changeLanguage({ locale });
|
|
204
|
-
appApi.i18n.changeLanguage({ locale });
|
|
205
|
-
i18n.changeLanguage({ locale });
|
|
206
|
-
|
|
207
|
-
if (!(await appApi.checkEnvironment())) {
|
|
208
|
-
process.exit(1);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
generator.logger.debug(`🚀 [Start Run MWA Generator]`);
|
|
212
|
-
generator.logger.debug(
|
|
213
|
-
'💡 [Current Config]:',
|
|
214
|
-
JSON.stringify(context.config),
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
let projectPath = '';
|
|
218
|
-
try {
|
|
219
|
-
({ projectPath } = await handleTemplateFile(context, generator, appApi));
|
|
220
|
-
} catch (e) {
|
|
221
|
-
generator.logger.error(`🔴 [Handle MWA Template Error]:`, e);
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (context.handleForged) {
|
|
226
|
-
await context.handleForged(
|
|
227
|
-
Solution.MWA,
|
|
228
|
-
context,
|
|
229
|
-
context.config.hasPlugin,
|
|
230
|
-
projectPath,
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
await appApi.runGitAndInstall(context.config.gitCommitMessage);
|
|
236
|
-
} catch (e) {
|
|
237
|
-
process.exit(1);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const { packageManager } = context.config;
|
|
241
|
-
|
|
242
|
-
if (successInfo) {
|
|
243
|
-
appApi.showSuccessInfo(successInfo);
|
|
244
|
-
} else {
|
|
245
|
-
appApi.showSuccessInfo(
|
|
246
|
-
i18n.t(localeKeys.success, {
|
|
247
|
-
packageManager: getPackageManagerText(packageManager),
|
|
248
|
-
}),
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
generator.logger.debug(`🌟 [End Run MWA Generator]`);
|
|
253
|
-
};
|