create-module-federation 2.6.0 → 2.7.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 CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import external_path_default from "path";
3
- import external_fs_default from "fs";
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 external_minimist_default from "minimist";
7
+ import minimist from "minimist";
8
8
  import { logger } from "rslog";
9
- import external_glob_default from "glob";
9
+ import glob from "glob";
10
10
  import { mkdir, readFile, writeFile } from "fs/promises";
11
- import external_handlebars_default from "handlebars";
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 = external_path_default.extname(this.filePath);
32
+ const resourceFileExt = path_0.extname(this.filePath);
33
33
  if (IMAGE_EXT_LIST.includes(resourceFileExt)) {
34
- const buffer = await readFile(external_path_default.resolve(this.filePath));
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(external_path_default.resolve(this.filePath), 'utf8');
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
- external_glob_default(pattern, options, (err, files)=>null === err ? resolve(files) : reject(err));
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(external_path_default.resolve(this.basePath, resourceKey), resourceKey);
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: external_path_default.resolve(this.basePath),
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(external_path_default.resolve(this.basePath, cur), cur);
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 external_handlebars_default.compile(template)(fullData) || '';
69
+ return handlebars.compile(template)(fullData) || '';
70
70
  }
71
71
  async function outputFs(file, content, outputPath, options) {
72
- const filePath = external_path_default.resolve(outputPath, file.toString());
73
- await mkdir(external_path_default.dirname(filePath), {
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 = external_path_default.dirname(create_filename);
99
- const packageDir = external_path_default.resolve(create_dirname, '..');
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 = external_fs_default.readdirSync(path);
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 = external_minimist_default(process.argv.slice(2), {
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(`\u{25C6} Create ${upperFirst(name)} Project`);
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.6.0";
293
+ const mfVersion = "2.7.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(external_path_default.join(argv.dir || mfName));
319
- const distFolder = external_path_default.isAbsolute(targetDir) ? targetDir : external_path_default.join(cwd, targetDir);
320
- if (!argv.override && external_fs_default.existsSync(distFolder) && !isEmptyDir(distFolder)) {
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.0",
6
+ "version": "2.7.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.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.9.0",
41
+ "@rslib/core": "^0.23.2",
42
42
  "rsbuild-plugin-publint": "^0.2.1"
43
43
  },
44
44
  "scripts": {
@@ -33,7 +33,6 @@
33
33
  "@modern-js/tsconfig": "0.0.0-canary-20260129131527",
34
34
  "@biomejs/biome": "1.8.3",
35
35
  "typescript": "~5.0.4",
36
- "@types/jest": "~29.2.4",
37
36
  "@types/node": "~18.11.9",
38
37
  "@types/react": "^18.3.11",
39
38
  "@types/react-dom": "~18.3.1",
@@ -22,9 +22,9 @@
22
22
  "mf-dev": "rslib mf-dev"
23
23
  },
24
24
  "devDependencies": {
25
- "@rsbuild/core": "2.0.0-beta.2",
26
- "@rsbuild/plugin-react": "^1.4.5",
27
- "@rslib/core": ">=0.9.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.0.0-beta.2",
24
- "@rsbuild/plugin-react": "^1.4.5",
25
- "@rslib/core": ">=0.9.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.0.0-beta.2",
16
- "@rsbuild/plugin-react": "^1.4.5",
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",