create-module-federation 2.6.0 → 2.8.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 +24 -24
- package/package.json +3 -3
- package/templates/modern-common/package.json.handlebars +0 -1
- package/templates/modern-common/tsconfig.json +1 -2
- package/templates/provider-rslib-storybook-ts/package.json.handlebars +3 -3
- package/templates/provider-rslib-ts/package.json.handlebars +3 -3
- package/templates/rsbuild-common/package.json.handlebars +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import path_0 from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import { spawnSync } from "child_process";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
6
|
import { cancel, isCancel, multiselect, note, outro, select as prompts_select, text as prompts_text } from "@clack/prompts";
|
|
7
|
-
import
|
|
7
|
+
import minimist from "minimist";
|
|
8
8
|
import { logger } from "rslog";
|
|
9
|
-
import
|
|
9
|
+
import glob from "glob";
|
|
10
10
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
11
|
-
import
|
|
11
|
+
import handlebars from "handlebars";
|
|
12
12
|
const IMAGE_EXT_LIST = [
|
|
13
13
|
'.jpg',
|
|
14
14
|
'.jpeg',
|
|
@@ -29,48 +29,48 @@ class FsResource {
|
|
|
29
29
|
this.resourceKey = resourceKey;
|
|
30
30
|
}
|
|
31
31
|
async value() {
|
|
32
|
-
const resourceFileExt =
|
|
32
|
+
const resourceFileExt = path_0.extname(this.filePath);
|
|
33
33
|
if (IMAGE_EXT_LIST.includes(resourceFileExt)) {
|
|
34
|
-
const buffer = await readFile(
|
|
34
|
+
const buffer = await readFile(path_0.resolve(this.filePath));
|
|
35
35
|
return {
|
|
36
36
|
content: buffer
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
const text = await readFile(
|
|
39
|
+
const text = await readFile(path_0.resolve(this.filePath), 'utf8');
|
|
40
40
|
return {
|
|
41
41
|
content: text
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
const promisifyGlob = (pattern, options)=>new Promise((resolve, reject)=>{
|
|
46
|
-
|
|
46
|
+
glob(pattern, options, (err, files)=>null === err ? resolve(files) : reject(err));
|
|
47
47
|
});
|
|
48
48
|
class FsMaterial {
|
|
49
49
|
constructor(basePath){
|
|
50
50
|
this.basePath = basePath;
|
|
51
51
|
}
|
|
52
52
|
get(resourceKey) {
|
|
53
|
-
return new FsResource(
|
|
53
|
+
return new FsResource(path_0.resolve(this.basePath, resourceKey), resourceKey);
|
|
54
54
|
}
|
|
55
55
|
async find(globStr, options) {
|
|
56
56
|
const matches = await promisifyGlob(globStr, {
|
|
57
|
-
cwd:
|
|
57
|
+
cwd: path_0.resolve(this.basePath),
|
|
58
58
|
nodir: options?.nodir,
|
|
59
59
|
dot: options?.dot,
|
|
60
60
|
ignore: options?.ignore
|
|
61
61
|
});
|
|
62
62
|
return matches.reduce((pre, cur)=>{
|
|
63
|
-
pre[cur] = new FsResource(
|
|
63
|
+
pre[cur] = new FsResource(path_0.resolve(this.basePath, cur), cur);
|
|
64
64
|
return pre;
|
|
65
65
|
}, {});
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
function renderString(template, fullData) {
|
|
69
|
-
return
|
|
69
|
+
return handlebars.compile(template)(fullData) || '';
|
|
70
70
|
}
|
|
71
71
|
async function outputFs(file, content, outputPath, options) {
|
|
72
|
-
const filePath =
|
|
73
|
-
await mkdir(
|
|
72
|
+
const filePath = path_0.resolve(outputPath, file.toString());
|
|
73
|
+
await mkdir(path_0.dirname(filePath), {
|
|
74
74
|
recursive: true
|
|
75
75
|
});
|
|
76
76
|
await writeFile(filePath, content, options);
|
|
@@ -95,8 +95,8 @@ class HandlebarsAPI {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
const create_filename = fileURLToPath(import.meta.url);
|
|
98
|
-
const create_dirname =
|
|
99
|
-
const packageDir =
|
|
98
|
+
const create_dirname = path_0.dirname(create_filename);
|
|
99
|
+
const packageDir = path_0.resolve(create_dirname, '..');
|
|
100
100
|
const OTHER_TYPE = {
|
|
101
101
|
zephyr: {
|
|
102
102
|
label: 'zephyr',
|
|
@@ -149,7 +149,7 @@ function formatProjectName(input) {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
function isEmptyDir(path) {
|
|
152
|
-
const files =
|
|
152
|
+
const files = fs.readdirSync(path);
|
|
153
153
|
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
154
154
|
}
|
|
155
155
|
async function getAppTemplateName({ roleType, framework }, { template }) {
|
|
@@ -275,7 +275,7 @@ async function forgeTemplate({ projectType, argv, templateParameters, distFolder
|
|
|
275
275
|
await renderTemplate(templateDir);
|
|
276
276
|
}
|
|
277
277
|
async function create({ name, templates }) {
|
|
278
|
-
const argv =
|
|
278
|
+
const argv = minimist(process.argv.slice(2), {
|
|
279
279
|
alias: {
|
|
280
280
|
h: 'help',
|
|
281
281
|
d: 'dir',
|
|
@@ -285,12 +285,12 @@ async function create({ name, templates }) {
|
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
287
|
console.log('');
|
|
288
|
-
logger.greet(
|
|
288
|
+
logger.greet(`◆ Create ${upperFirst(name)} Project`);
|
|
289
289
|
if (argv.help) return void logHelpMessage(name, templates);
|
|
290
290
|
const cwd = process.cwd();
|
|
291
291
|
const pkgInfo = pkgFromUserAgent(process.env['npm_config_user_agent']);
|
|
292
292
|
const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
|
|
293
|
-
const mfVersion = "2.
|
|
293
|
+
const mfVersion = "2.8.0";
|
|
294
294
|
argv.template = templates.includes(argv.template || '') ? argv.template : void 0;
|
|
295
295
|
const projectType = await getProjectType(argv.template);
|
|
296
296
|
if ("zephyr" === projectType) {
|
|
@@ -315,9 +315,9 @@ async function create({ name, templates }) {
|
|
|
315
315
|
if (0 === value.length) return 'Name is required';
|
|
316
316
|
}
|
|
317
317
|
}));
|
|
318
|
-
const { targetDir } = formatProjectName(
|
|
319
|
-
const distFolder =
|
|
320
|
-
if (!argv.override &&
|
|
318
|
+
const { targetDir } = formatProjectName(path_0.join(argv.dir || mfName));
|
|
319
|
+
const distFolder = path_0.isAbsolute(targetDir) ? targetDir : path_0.join(cwd, targetDir);
|
|
320
|
+
if (!argv.override && fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
321
321
|
const option = checkCancel(await prompts_select({
|
|
322
322
|
message: `"${targetDir}" is not empty, please choose:`,
|
|
323
323
|
options: [
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Create a new Module Federation project",
|
|
4
4
|
"public": true,
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.8.0",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"minimist": "1.2.8",
|
|
34
34
|
"rslog": "1.2.3",
|
|
35
35
|
"glob": "7.2.0",
|
|
36
|
-
"handlebars": "4.7.
|
|
36
|
+
"handlebars": "4.7.9"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/glob": "7.2.0",
|
|
40
40
|
"@types/minimist": "^1.2.5",
|
|
41
|
-
"@rslib/core": "^0.
|
|
41
|
+
"@rslib/core": "^0.23.2",
|
|
42
42
|
"rsbuild-plugin-publint": "^0.2.1"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"declaration": false,
|
|
5
5
|
"jsx": "preserve",
|
|
6
|
-
"baseUrl": "./",
|
|
7
6
|
"paths": {
|
|
8
7
|
"@/*": ["./src/*"],
|
|
9
8
|
"@shared/*": ["./shared/*"],
|
|
10
|
-
"*": ["./@mf-types/*"]
|
|
9
|
+
"*": ["./@mf-types/*", "./*"]
|
|
11
10
|
}
|
|
12
11
|
},
|
|
13
12
|
"include": ["src", "shared", "config", "modern.config.ts"],
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"mf-dev": "rslib mf-dev"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@rsbuild/core": "2.
|
|
26
|
-
"@rsbuild/plugin-react": "^1.
|
|
27
|
-
"@rslib/core": ">=0.
|
|
25
|
+
"@rsbuild/core": "2.1.4",
|
|
26
|
+
"@rsbuild/plugin-react": "^2.1.0",
|
|
27
|
+
"@rslib/core": ">=0.23.2",
|
|
28
28
|
"@storybook/addon-essentials": "^8.4.7",
|
|
29
29
|
"@storybook/addon-interactions": "^8.4.7",
|
|
30
30
|
"@storybook/addon-links": "^8.4.7",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"mf-dev": "rslib mf-dev"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@rsbuild/core": "2.
|
|
24
|
-
"@rsbuild/plugin-react": "^1.
|
|
25
|
-
"@rslib/core": ">=0.
|
|
23
|
+
"@rsbuild/core": "2.1.4",
|
|
24
|
+
"@rsbuild/plugin-react": "^2.1.0",
|
|
25
|
+
"@rslib/core": ">=0.23.2",
|
|
26
26
|
"@types/react": "^18.3.11",
|
|
27
27
|
"react": "^18.3.1",
|
|
28
28
|
"typescript": "^5.7.3",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"react-dom": "^19.2.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@rsbuild/core": "2.
|
|
16
|
-
"@rsbuild/plugin-react": "^1.
|
|
15
|
+
"@rsbuild/core": "2.1.4",
|
|
16
|
+
"@rsbuild/plugin-react": "^2.1.0",
|
|
17
17
|
"@types/react": "^19.2.7",
|
|
18
18
|
"@types/react-dom": "^19.2.3",
|
|
19
19
|
"typescript": "^5.7.2",
|