@umijs/preset-umi 4.0.64 → 4.0.66

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.
@@ -84,21 +84,12 @@ var ComponentGenerator = class {
84
84
  capitalizeName
85
85
  );
86
86
  const { _, eject: _eject, fallback, ...restArgs } = args;
87
- const indexFile = (0, import_path.join)(base, "index.ts");
88
- const compFile = (0, import_path.join)(base, `${capitalizeName}.tsx`);
89
87
  await (0, import_utils2.processGenerateFiles)({
90
88
  filesMap: [
91
89
  {
92
- from: (0, import_path.join)(appRoot, USER_TEMPLATE_COMP_DIR, "index"),
93
- fromFallback: INDEX_TPL,
94
- to: indexFile,
95
- exts: [".ts.tpl", ".ts", "tsx.tpl", "tsx"]
96
- },
97
- {
98
- from: (0, import_path.join)(appRoot, USER_TEMPLATE_COMP_DIR, "component"),
99
- fromFallback: COMP_TPL,
100
- to: compFile,
101
- exts: [".tsx.tpl", ".tsx"]
90
+ from: (0, import_path.join)(appRoot, USER_TEMPLATE_COMP_DIR),
91
+ fromFallback: COMP_TEMPLATE_DIR,
92
+ to: base
102
93
  }
103
94
  ],
104
95
  baseDir: appRoot,
@@ -112,8 +103,7 @@ var ComponentGenerator = class {
112
103
  });
113
104
  }
114
105
  };
115
- var INDEX_TPL = (0, import_path.join)(import_constants.TEMPLATES_DIR, "generate/component/index.ts.tpl");
116
- var COMP_TPL = (0, import_path.join)(import_constants.TEMPLATES_DIR, "generate/component/component.tsx.tpl");
106
+ var COMP_TEMPLATE_DIR = (0, import_path.join)(import_constants.TEMPLATES_DIR, "generate/component");
117
107
  var USER_TEMPLATE_COMP_DIR = "templates/component";
118
108
  // Annotate the CommonJS export names for ESM import in node:
119
109
  0 && (module.exports = {
@@ -39,11 +39,11 @@ var verify_commit_default = (api) => {
39
39
  api.describe({
40
40
  key: "verifyCommit",
41
41
  config: {
42
- schema(Joi) {
43
- return Joi.object({
44
- scope: Joi.array().items(Joi.string()),
45
- allowEmoji: Joi.boolean()
46
- });
42
+ schema({ zod }) {
43
+ return zod.object({
44
+ scope: zod.array(zod.string()),
45
+ allowEmoji: zod.boolean()
46
+ }).deepPartial();
47
47
  }
48
48
  }
49
49
  });
@@ -145,7 +145,7 @@ var icons_default = (api) => {
145
145
  const localIcons = [];
146
146
  if (import_fs.default.existsSync(localIconDir)) {
147
147
  localIcons.push(
148
- ...import_fs.default.readdirSync(localIconDir).filter((file) => file.endsWith(".svg")).map((file) => file.replace(/\.svg$/, ""))
148
+ ...readIconsFromDir(localIconDir).filter((file) => file.endsWith(".svg")).map((file) => file.replace(/\.svg$/, ""))
149
149
  );
150
150
  }
151
151
  api.writeTmpFile({
@@ -385,7 +385,7 @@ function normalizeRotate(rotate: number | string) {
385
385
  }
386
386
 
387
387
  function camelCase(str: string) {
388
- return str.replace(/-([a-z]|[1-9])/g, (g) => g[1].toUpperCase());
388
+ return str.replace(/\\//g, '-').replace(/-([a-zA-Z]|[1-9])/g, (g) => g[1].toUpperCase());
389
389
  }
390
390
 
391
391
  function normalizeIconName(name: string) {
@@ -433,5 +433,22 @@ function normalizeIconName(name: string) {
433
433
  return import_path.default.join(api.paths.absSrcPath, "icons");
434
434
  }
435
435
  };
436
+ function readIconsFromDir(dir) {
437
+ const icons = [];
438
+ const prefix = (0, import_utils.winPath)(import_path.default.join(dir, "./"));
439
+ const collect = (p) => {
440
+ if (import_fs.default.statSync(p).isDirectory()) {
441
+ const files = import_fs.default.readdirSync(p);
442
+ files.forEach((name) => {
443
+ collect(import_path.default.join(p, name));
444
+ });
445
+ } else {
446
+ const prunePath = (0, import_utils.winPath)(p).replace(prefix, "");
447
+ icons.push(prunePath);
448
+ }
449
+ };
450
+ collect(dir);
451
+ return icons;
452
+ }
436
453
  // Annotate the CommonJS export names for ESM import in node:
437
454
  0 && (module.exports = {});
@@ -38,7 +38,7 @@ var import_fs = __toESM(require("fs"));
38
38
  var import_path = __toESM(require("path"));
39
39
  var import_loadIcon = require("./loadIcon");
40
40
  function camelCase(str) {
41
- return str.replace(/-([a-z]|[0-9])/g, (g) => g[1].toUpperCase());
41
+ return str.replace(/\//g, "-").replace(/-([a-zA-Z]|[0-9])/g, (g) => g[1].toUpperCase());
42
42
  }
43
43
  function generateIconName(opts) {
44
44
  return camelCase(`${opts.collect}-${opts.icon}`);
@@ -79,13 +79,15 @@ var prepare_default = (api) => {
79
79
  api.register({
80
80
  key: "onGenerateFiles",
81
81
  async fn({ isFirstTime }) {
82
+ var _a, _b;
82
83
  if (api.appData.framework === "vue") {
83
84
  return;
84
85
  }
85
86
  if (!isFirstTime)
86
87
  return;
87
88
  import_utils.logger.info("Preparing...");
88
- const entryFile = import_path.default.join(api.paths.absTmpPath, "umi.ts");
89
+ const umiEntry = import_path.default.join(api.paths.absTmpPath, "umi.ts");
90
+ const entryPoints = [umiEntry];
89
91
  const { build } = await import("./build.js");
90
92
  const watch = api.name === "dev";
91
93
  const plugins = await api.applyPlugins({
@@ -95,8 +97,13 @@ var prepare_default = (api) => {
95
97
  const unwrappedAlias = import_utils.aliasUtils.parseCircleAlias({
96
98
  alias: api.config.alias
97
99
  });
100
+ if (api.userConfig.mpa) {
101
+ (_b = (_a = api.appData.mpa) == null ? void 0 : _a.entry) == null ? void 0 : _b.forEach(({ tmpFilePath }) => {
102
+ entryPoints.push(import_path.default.join(api.paths.absTmpPath, tmpFilePath));
103
+ });
104
+ }
98
105
  const buildResult = await build({
99
- entryPoints: [entryFile],
106
+ entryPoints,
100
107
  watch: watch && {
101
108
  async onRebuildSuccess({ result }) {
102
109
  const fileImports2 = await parseProjectImportSpecifiers(result);
@@ -119,8 +126,8 @@ var prepare_default = (api) => {
119
126
  });
120
127
  if (watch) {
121
128
  (0, import_watch.addUnWatch)(() => {
122
- var _a;
123
- (_a = buildResult.stop) == null ? void 0 : _a.call(buildResult);
129
+ var _a2;
130
+ (_a2 = buildResult.stop) == null ? void 0 : _a2.call(buildResult);
124
131
  });
125
132
  }
126
133
  const fileImports = await parseProjectImportSpecifiers(buildResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.0.64",
3
+ "version": "4.0.66",
4
4
  "description": "@umijs/preset-umi",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -37,20 +37,20 @@
37
37
  "react-router": "6.3.0",
38
38
  "react-router-dom": "6.3.0",
39
39
  "regenerator-runtime": "0.13.11",
40
- "@umijs/ast": "4.0.64",
41
- "@umijs/babel-preset-umi": "4.0.64",
42
- "@umijs/bundler-webpack": "4.0.64",
43
- "@umijs/bundler-utils": "4.0.64",
44
- "@umijs/bundler-vite": "4.0.64",
45
- "@umijs/core": "4.0.64",
46
- "@umijs/mfsu": "4.0.64",
47
- "@umijs/plugin-run": "4.0.64",
48
- "@umijs/renderer-react": "4.0.64",
49
- "@umijs/server": "4.0.64",
50
- "@umijs/zod2ts": "4.0.64",
51
- "@umijs/utils": "4.0.64",
52
- "@umijs/did-you-know": "1.0.3",
53
- "@umijs/ui": "3.0.0-alpha.0"
40
+ "@umijs/ast": "4.0.66",
41
+ "@umijs/babel-preset-umi": "4.0.66",
42
+ "@umijs/bundler-utils": "4.0.66",
43
+ "@umijs/bundler-vite": "4.0.66",
44
+ "@umijs/bundler-webpack": "4.0.66",
45
+ "@umijs/core": "4.0.66",
46
+ "@umijs/mfsu": "4.0.66",
47
+ "@umijs/plugin-run": "4.0.66",
48
+ "@umijs/renderer-react": "4.0.66",
49
+ "@umijs/server": "4.0.66",
50
+ "@umijs/utils": "4.0.66",
51
+ "@umijs/zod2ts": "4.0.66",
52
+ "@umijs/ui": "3.0.0-alpha.0",
53
+ "@umijs/did-you-know": "1.0.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@manypkg/get-packages": "1.1.3",