@umijs/preset-umi 4.0.65 → 4.0.67
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/commands/generators/component.js +4 -14
- package/dist/commands/verify-commit.js +5 -5
- package/dist/features/icons/icons.js +19 -2
- package/dist/features/icons/svgr.js +1 -1
- package/dist/features/prepare/esbuildPlugins/esbuildExternalPlugin.js +5 -0
- package/dist/features/tmpFiles/tmpFiles.js +4 -6
- package/dist/features/ui/ui.js +10 -0
- package/dist/registerMethods.js +1 -0
- package/dist/types.d.ts +12 -0
- package/package.json +15 -15
|
@@ -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
|
|
93
|
-
fromFallback:
|
|
94
|
-
to:
|
|
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
|
|
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(
|
|
43
|
-
return
|
|
44
|
-
scope:
|
|
45
|
-
allowEmoji:
|
|
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
|
-
...
|
|
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-
|
|
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-
|
|
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}`);
|
|
@@ -41,6 +41,11 @@ function esbuildExternalPlugin(opts) {
|
|
|
41
41
|
name: "esbuildExternalPlugin",
|
|
42
42
|
setup(build) {
|
|
43
43
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
44
|
+
if (args.path.includes("_UMI_PREPARE_EXTERNAL_")) {
|
|
45
|
+
return {
|
|
46
|
+
external: true
|
|
47
|
+
};
|
|
48
|
+
}
|
|
44
49
|
if (!isSource(args.path)) {
|
|
45
50
|
return {
|
|
46
51
|
external: true
|
|
@@ -102,10 +102,7 @@ var tmpFiles_default = (api) => {
|
|
|
102
102
|
...api.appData.framework === "vue" ? {
|
|
103
103
|
// TODO Actually, it should be vite mode, but here it is written as vue only
|
|
104
104
|
// Required in Vite https://vitejs.dev/guide/features.html#typescript
|
|
105
|
-
isolatedModules: true
|
|
106
|
-
// For `<script setup>`
|
|
107
|
-
// See <https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports>
|
|
108
|
-
preserveValueImports: true
|
|
105
|
+
isolatedModules: true
|
|
109
106
|
} : {},
|
|
110
107
|
paths: {
|
|
111
108
|
"@/*": [`${srcPrefix}*`],
|
|
@@ -123,8 +120,9 @@ var tmpFiles_default = (api) => {
|
|
|
123
120
|
`${baseUrl}.umirc.ts`,
|
|
124
121
|
`${baseUrl}**/*.d.ts`,
|
|
125
122
|
`${baseUrl}**/*.ts`,
|
|
126
|
-
`${baseUrl}**/*.tsx
|
|
127
|
-
|
|
123
|
+
`${baseUrl}**/*.tsx`,
|
|
124
|
+
api.appData.framework === "vue" && `${baseUrl}**/*.vue`
|
|
125
|
+
].filter(Boolean)
|
|
128
126
|
},
|
|
129
127
|
null,
|
|
130
128
|
2
|
package/dist/features/ui/ui.js
CHANGED
|
@@ -113,6 +113,16 @@ var ui_default = (api) => {
|
|
|
113
113
|
`
|
|
114
114
|
];
|
|
115
115
|
});
|
|
116
|
+
api.modifyAppData(async (memo) => {
|
|
117
|
+
const uiModules = await api.applyPlugins({
|
|
118
|
+
key: "addUIModules",
|
|
119
|
+
initialValue: []
|
|
120
|
+
}) ?? [];
|
|
121
|
+
memo.ui = {
|
|
122
|
+
modules: uiModules
|
|
123
|
+
};
|
|
124
|
+
return memo;
|
|
125
|
+
});
|
|
116
126
|
api.onGenerateFiles(({ isFirstTime }) => {
|
|
117
127
|
if (!isFirstTime)
|
|
118
128
|
return;
|
package/dist/registerMethods.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -67,6 +67,17 @@ export interface IOnGenerateFiles {
|
|
|
67
67
|
files?: IFileInfo | null;
|
|
68
68
|
isFirstTime?: boolean;
|
|
69
69
|
}
|
|
70
|
+
export interface IUIMenu {
|
|
71
|
+
path: string;
|
|
72
|
+
url: string;
|
|
73
|
+
icon: string;
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
export interface IUIModule {
|
|
77
|
+
name: string;
|
|
78
|
+
menus?: IUIMenu[];
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
70
81
|
export declare type GenerateFilesFn = (opts: IOnGenerateFiles) => Promise<void>;
|
|
71
82
|
export declare type OnConfigChangeFn = (opts: {
|
|
72
83
|
generate: GenerateFilesFn;
|
|
@@ -101,6 +112,7 @@ export declare type IApi = PluginAPI & IServicePluginAPI & {
|
|
|
101
112
|
addRuntimePlugin: IAdd<null, string>;
|
|
102
113
|
addRuntimePluginKey: IAdd<null, string>;
|
|
103
114
|
addTmpGenerateWatcherPaths: IAdd<null, string>;
|
|
115
|
+
addUIModules: IAdd<null, IUIModule[]>;
|
|
104
116
|
chainWebpack: {
|
|
105
117
|
(fn: {
|
|
106
118
|
(memo: WebpackChain, args: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.67",
|
|
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.
|
|
41
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
42
|
-
"@umijs/bundler-
|
|
43
|
-
"@umijs/
|
|
40
|
+
"@umijs/ast": "4.0.67",
|
|
41
|
+
"@umijs/babel-preset-umi": "4.0.67",
|
|
42
|
+
"@umijs/bundler-utils": "4.0.67",
|
|
43
|
+
"@umijs/bundler-webpack": "4.0.67",
|
|
44
|
+
"@umijs/bundler-vite": "4.0.67",
|
|
45
|
+
"@umijs/core": "4.0.67",
|
|
46
|
+
"@umijs/mfsu": "4.0.67",
|
|
47
|
+
"@umijs/renderer-react": "4.0.67",
|
|
48
|
+
"@umijs/plugin-run": "4.0.67",
|
|
49
|
+
"@umijs/server": "4.0.67",
|
|
50
|
+
"@umijs/utils": "4.0.67",
|
|
51
|
+
"@umijs/zod2ts": "4.0.67",
|
|
44
52
|
"@umijs/did-you-know": "1.0.3",
|
|
45
|
-
"@umijs/
|
|
46
|
-
"@umijs/renderer-react": "4.0.65",
|
|
47
|
-
"@umijs/bundler-utils": "4.0.65",
|
|
48
|
-
"@umijs/bundler-webpack": "4.0.65",
|
|
49
|
-
"@umijs/ui": "3.0.0-alpha.0",
|
|
50
|
-
"@umijs/utils": "4.0.65",
|
|
51
|
-
"@umijs/zod2ts": "4.0.65",
|
|
52
|
-
"@umijs/plugin-run": "4.0.65",
|
|
53
|
-
"@umijs/server": "4.0.65"
|
|
53
|
+
"@umijs/ui": "3.0.0-alpha.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@manypkg/get-packages": "1.1.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"multer": "1.4.4",
|
|
65
65
|
"os-locale": "^6.0.2",
|
|
66
66
|
"sirv": "2.0.2",
|
|
67
|
-
"vite": "4.
|
|
67
|
+
"vite": "4.3.1"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|