@umijs/plugins 4.0.0-rc.1 → 4.0.0-rc.4
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/antd.js +3 -3
- package/dist/dva.js +5 -1
- package/dist/layout.js +6 -2
- package/dist/locale.js +10 -10
- package/dist/model.js +5 -1
- package/dist/moment2dayjs.js +4 -4
- package/dist/qiankun/master.js +3 -2
- package/dist/qiankun/slave.js +3 -2
- package/dist/request.js +6 -6
- package/dist/tailwindcss.js +5 -1
- package/dist/unocss.js +7 -3
- package/dist/utils/astUtils.js +5 -1
- package/dist/utils/localeUtils.js +10 -10
- package/dist/utils/modelUtils.js +8 -4
- package/dist/utils/withTmpPath.js +2 -2
- package/package.json +7 -7
package/dist/antd.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.default = (api) => {
|
|
|
67
67
|
});
|
|
68
68
|
// antd config provider
|
|
69
69
|
api.onGenerateFiles(() => {
|
|
70
|
-
if (!api.config.antd.
|
|
70
|
+
if (!api.config.antd.configProvider)
|
|
71
71
|
return;
|
|
72
72
|
api.writeTmpFile({
|
|
73
73
|
path: `runtime.tsx`,
|
|
@@ -90,12 +90,12 @@ export function rootContainer(container) {
|
|
|
90
90
|
return <ConfigProvider {...finalConfig}>{container}</ConfigProvider>;
|
|
91
91
|
}
|
|
92
92
|
`.trim(), {
|
|
93
|
-
config: JSON.stringify(api.config.antd.
|
|
93
|
+
config: JSON.stringify(api.config.antd.configProvider),
|
|
94
94
|
}),
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
api.addRuntimePlugin(() => {
|
|
98
|
-
return api.config.antd.
|
|
98
|
+
return api.config.antd.configProvider
|
|
99
99
|
? [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })]
|
|
100
100
|
: [];
|
|
101
101
|
});
|
package/dist/dva.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/layout.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -187,7 +191,7 @@ const { formatMessage } = useIntl();
|
|
|
187
191
|
return memo;
|
|
188
192
|
}, {});
|
|
189
193
|
const icons = Object.keys(iconsMap);
|
|
190
|
-
const antIconsPath = (0, path_1.dirname)(require.resolve('@ant-design/icons/package'));
|
|
194
|
+
const antIconsPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('@ant-design/icons/package')));
|
|
191
195
|
api.writeTmpFile({
|
|
192
196
|
path: 'icons.tsx',
|
|
193
197
|
content: `
|
package/dist/locale.js
CHANGED
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.packageNormalize = void 0;
|
|
13
|
-
const utils_1 = require("@umijs/utils");
|
|
14
13
|
const fs_1 = require("fs");
|
|
15
14
|
const path_1 = require("path");
|
|
15
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
16
16
|
const localeUtils_1 = require("./utils/localeUtils");
|
|
17
17
|
const withTmpPath_1 = require("./utils/withTmpPath");
|
|
18
18
|
const packageNormalize = (packageName) => packageName.replace(/[@\/\-.]/g, '_');
|
|
@@ -50,7 +50,7 @@ exports.default = (api) => {
|
|
|
50
50
|
},
|
|
51
51
|
enableBy: api.EnableBy.config,
|
|
52
52
|
});
|
|
53
|
-
const reactIntlPkgPath = (0, path_1.dirname)(require.resolve('react-intl/package'));
|
|
53
|
+
const reactIntlPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('react-intl/package')));
|
|
54
54
|
// polyfill
|
|
55
55
|
if ((0, localeUtils_1.isNeedPolyfill)(((_a = api.userConfig) === null || _a === void 0 ? void 0 : _a.targets) || {})) {
|
|
56
56
|
api.addEntryImportsAhead(() => [
|
|
@@ -87,8 +87,8 @@ exports.default = (api) => {
|
|
|
87
87
|
const localeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/locale.tpl'), 'utf-8');
|
|
88
88
|
// moment2dayjs
|
|
89
89
|
const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
|
|
90
|
-
const momentPkgPath = (0, path_1.dirname)(require.resolve(`${resolveKey}/package.json`));
|
|
91
|
-
const EventEmitterPkg = (0, path_1.dirname)(require.resolve('event-emitter/package'));
|
|
90
|
+
const momentPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve(`${resolveKey}/package.json`)));
|
|
91
|
+
const EventEmitterPkg = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('event-emitter/package')));
|
|
92
92
|
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = api
|
|
93
93
|
.config.locale;
|
|
94
94
|
const defaultLocale = ((_e = api.config.locale) === null || _e === void 0 ? void 0 : _e.default) || `zh${baseSeparator}CN`;
|
|
@@ -114,7 +114,7 @@ exports.default = (api) => {
|
|
|
114
114
|
// set antd default locale
|
|
115
115
|
if (!antdLocales.length && ((_g = api.config.locale) === null || _g === void 0 ? void 0 : _g.antd)) {
|
|
116
116
|
const [lang, country = ''] = defaultLocale.split(baseSeparator);
|
|
117
|
-
DefaultAntdLocales =
|
|
117
|
+
DefaultAntdLocales = plugin_utils_1.lodash.uniq(yield addAntdLocales({
|
|
118
118
|
lang,
|
|
119
119
|
country,
|
|
120
120
|
}));
|
|
@@ -124,7 +124,7 @@ exports.default = (api) => {
|
|
|
124
124
|
return (0, exports.packageNormalize)(this);
|
|
125
125
|
};
|
|
126
126
|
api.writeTmpFile({
|
|
127
|
-
content:
|
|
127
|
+
content: plugin_utils_1.Mustache.render(localeTpl, {
|
|
128
128
|
MomentLocales,
|
|
129
129
|
DefaultMomentLocale,
|
|
130
130
|
NormalizeAntdLocalesName,
|
|
@@ -143,7 +143,7 @@ exports.default = (api) => {
|
|
|
143
143
|
const localeDirPath = (0, path_1.join)(api.paths.absSrcPath, localeDirName);
|
|
144
144
|
api.writeTmpFile({
|
|
145
145
|
path: 'localeExports.ts',
|
|
146
|
-
content:
|
|
146
|
+
content: plugin_utils_1.Mustache.render(localeExportsTpl, {
|
|
147
147
|
EventEmitterPkg,
|
|
148
148
|
BaseSeparator: baseSeparator,
|
|
149
149
|
BaseNavigator: baseNavigator,
|
|
@@ -159,7 +159,7 @@ exports.default = (api) => {
|
|
|
159
159
|
})) }))),
|
|
160
160
|
Antd: !!antd,
|
|
161
161
|
DefaultLocale: JSON.stringify(defaultLocale),
|
|
162
|
-
warningPkgPath: require.resolve('warning/package'),
|
|
162
|
+
warningPkgPath: (0, plugin_utils_1.winPath)(require.resolve('warning/package')),
|
|
163
163
|
reactIntlPkgPath,
|
|
164
164
|
}),
|
|
165
165
|
});
|
|
@@ -167,7 +167,7 @@ exports.default = (api) => {
|
|
|
167
167
|
const runtimeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/runtime.tpl'), 'utf-8');
|
|
168
168
|
api.writeTmpFile({
|
|
169
169
|
path: 'runtime.tsx',
|
|
170
|
-
content:
|
|
170
|
+
content: plugin_utils_1.Mustache.render(runtimeTpl, {
|
|
171
171
|
Title: !!title,
|
|
172
172
|
}),
|
|
173
173
|
});
|
|
@@ -175,7 +175,7 @@ exports.default = (api) => {
|
|
|
175
175
|
const selectLang = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/SelectLang.tpl'), 'utf-8');
|
|
176
176
|
api.writeTmpFile({
|
|
177
177
|
path: 'SelectLang.tsx',
|
|
178
|
-
content:
|
|
178
|
+
content: plugin_utils_1.Mustache.render(selectLang, {
|
|
179
179
|
Antd: !!antd,
|
|
180
180
|
LocaleList: localeList,
|
|
181
181
|
ShowSelectLang: localeList.length > 1 && !!antd,
|
package/dist/model.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/moment2dayjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@umijs/utils");
|
|
4
3
|
const path_1 = require("path");
|
|
4
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
5
5
|
/*
|
|
6
6
|
As long as moment2dayjs is registered, moment will be replaced by dayjs.
|
|
7
7
|
The presets that can adapt to antd is registered by default.
|
|
@@ -81,11 +81,11 @@ dayjs.extend({{.}});
|
|
|
81
81
|
|
|
82
82
|
dayjs.extend(antdPlugin);
|
|
83
83
|
`;
|
|
84
|
-
const dayjsAntdPluginPath = require.resolve('antd-dayjs-webpack-plugin/src/antd-plugin');
|
|
85
|
-
const dayjsPath = (0, path_1.dirname)(require.resolve('dayjs/package.json'));
|
|
84
|
+
const dayjsAntdPluginPath = (0, plugin_utils_1.winPath)(require.resolve('antd-dayjs-webpack-plugin/src/antd-plugin'));
|
|
85
|
+
const dayjsPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('dayjs/package.json')));
|
|
86
86
|
api.writeTmpFile({
|
|
87
87
|
path: 'runtime.tsx',
|
|
88
|
-
content:
|
|
88
|
+
content: plugin_utils_1.Mustache.render(runtimeTpl, {
|
|
89
89
|
plugins,
|
|
90
90
|
dayjsPath,
|
|
91
91
|
dayjsAntdPluginPath,
|
package/dist/qiankun/master.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isMasterEnable = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
6
7
|
const withTmpPath_1 = require("../utils/withTmpPath");
|
|
7
8
|
const constants_1 = require("./constants");
|
|
8
9
|
function isMasterEnable(opts) {
|
|
@@ -105,8 +106,8 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
|
|
|
105
106
|
.replace('__USE_MODEL__', api.isPluginEnable('model')
|
|
106
107
|
? `import { useModel } from '@@/plugin-model'`
|
|
107
108
|
: `const useModel = null;`)
|
|
108
|
-
.replace(/from 'qiankun'/g, `from '${(0, path_1.dirname)(require.resolve('qiankun/package'))}'`)
|
|
109
|
-
.replace(/from 'lodash\//g, `from '${(0, path_1.dirname)(require.resolve('lodash/package'))}/`),
|
|
109
|
+
.replace(/from 'qiankun'/g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('qiankun/package')))}'`)
|
|
110
|
+
.replace(/from 'lodash\//g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('lodash/package')))}/`),
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
});
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const assert_1 = __importDefault(require("assert"));
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
9
10
|
const withTmpPath_1 = require("../utils/withTmpPath");
|
|
10
11
|
const constants_1 = require("./constants");
|
|
11
12
|
// BREAK CHANGE: 需要手动配置 slave: {},不能留空
|
|
@@ -133,8 +134,8 @@ if (!window.__POWERED_BY_QIANKUN__) {
|
|
|
133
134
|
.replace('__USE_MODEL__', api.isPluginEnable('model')
|
|
134
135
|
? `import { useModel } from '@@/plugin/model'`
|
|
135
136
|
: `const useModel = null;`)
|
|
136
|
-
.replace(/from 'qiankun'/g, `from '${(0, path_1.dirname)(require.resolve('qiankun/package'))}'`)
|
|
137
|
-
.replace(/from 'lodash\//g, `from '${(0, path_1.dirname)(require.resolve('lodash/package'))}/`),
|
|
137
|
+
.replace(/from 'qiankun'/g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('qiankun/package')))}'`)
|
|
138
|
+
.replace(/from 'lodash\//g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('lodash/package')))}/`),
|
|
138
139
|
});
|
|
139
140
|
});
|
|
140
141
|
});
|
package/dist/request.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@umijs/utils");
|
|
4
3
|
const path_1 = require("path");
|
|
4
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
5
5
|
exports.default = (api) => {
|
|
6
6
|
api.describe({
|
|
7
7
|
key: 'request',
|
|
@@ -276,15 +276,15 @@ export type {
|
|
|
276
276
|
`;
|
|
277
277
|
api.onGenerateFiles(() => {
|
|
278
278
|
var _a;
|
|
279
|
-
const umiRequestPath = (0, path_1.dirname)(require.resolve('@ahooksjs/use-request/package.json'));
|
|
280
|
-
const axiosPath = (0, path_1.dirname)(require.resolve('axios/package.json'));
|
|
281
|
-
const antdPkg =
|
|
279
|
+
const umiRequestPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('@ahooksjs/use-request/package.json')));
|
|
280
|
+
const axiosPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('axios/package.json')));
|
|
281
|
+
const antdPkg = (0, plugin_utils_1.winPath)(
|
|
282
282
|
// use path from antd plugin first
|
|
283
283
|
((_a = api.appData.antd) === null || _a === void 0 ? void 0 : _a.pkgPath) ||
|
|
284
|
-
(0, path_1.dirname)(require.resolve('antd/package.json'));
|
|
284
|
+
(0, path_1.dirname)(require.resolve('antd/package.json')));
|
|
285
285
|
api.writeTmpFile({
|
|
286
286
|
path: 'request.ts',
|
|
287
|
-
content:
|
|
287
|
+
content: plugin_utils_1.Mustache.render(requestTpl, {
|
|
288
288
|
umiRequestPath,
|
|
289
289
|
axiosPath,
|
|
290
290
|
antdPkg,
|
package/dist/tailwindcss.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/unocss.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -22,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
27
|
};
|
|
24
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const utils_1 = require("@umijs/utils");
|
|
26
29
|
const child_process_1 = require("child_process");
|
|
27
30
|
const fs = __importStar(require("fs"));
|
|
28
31
|
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
29
33
|
exports.default = (api) => {
|
|
30
34
|
api.describe({
|
|
31
35
|
key: 'unocss',
|
|
@@ -42,7 +46,7 @@ exports.default = (api) => {
|
|
|
42
46
|
/** 由于 @unocss/cli 对设置文件进行了检查,因此加入需要 unocss.config.ts 设置的提示
|
|
43
47
|
* https://github.com/antfu/unocss/blob/main/packages/cli/src/index.ts#L93 */
|
|
44
48
|
if (!fs.existsSync(path_1.default.resolve(api.paths.cwd, 'unocss.config.ts')))
|
|
45
|
-
|
|
49
|
+
plugin_utils_1.logger.warn('请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!');
|
|
46
50
|
const generatedPath = path_1.default.resolve(api.paths.absTmpPath, 'uno.css');
|
|
47
51
|
const binPath = path_1.default.resolve(api.cwd, 'node_modules/.bin/unocss');
|
|
48
52
|
const watchDirs = api.config.unocss.watch;
|
package/dist/utils/astUtils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.isNeedPolyfill = exports.exactLocalePaths = exports.getLocaleList = exports.getAntdLocale = exports.getMomentLocale = void 0;
|
|
13
|
-
const utils_1 = require("@umijs/utils");
|
|
14
13
|
const fs_1 = require("fs");
|
|
15
14
|
const path_1 = require("path");
|
|
15
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
16
16
|
/**
|
|
17
17
|
* 获取 moment 包的 locale 名称
|
|
18
18
|
* @param lang 语言
|
|
@@ -58,16 +58,16 @@ const modulesHasLocale = (localePath) => {
|
|
|
58
58
|
const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
59
|
const { localeFolder, separator = '-', absSrcPath = '', absPagesPath = '', addAntdLocales, resolveKey = 'moment', } = opts;
|
|
60
60
|
const localeFileMath = new RegExp(`^([a-z]{2})${separator}?([A-Z]{2})?\.(js|json|ts)$`);
|
|
61
|
-
const localeFiles =
|
|
61
|
+
const localeFiles = plugin_utils_1.glob
|
|
62
62
|
.sync('*.{ts,js,json}', {
|
|
63
|
-
cwd: (0,
|
|
63
|
+
cwd: (0, plugin_utils_1.winPath)((0, path_1.join)(absSrcPath, localeFolder)),
|
|
64
64
|
})
|
|
65
|
-
.map((name) => (0,
|
|
66
|
-
.concat(
|
|
65
|
+
.map((name) => (0, plugin_utils_1.winPath)((0, path_1.join)(absSrcPath, localeFolder, name)))
|
|
66
|
+
.concat(plugin_utils_1.glob
|
|
67
67
|
.sync(`**/${localeFolder}/*.{ts,js,json}`, {
|
|
68
68
|
cwd: absPagesPath,
|
|
69
69
|
})
|
|
70
|
-
.map((name) => (0,
|
|
70
|
+
.map((name) => (0, plugin_utils_1.winPath)((0, path_1.join)(absPagesPath, name))))
|
|
71
71
|
.filter((p) => localeFileMath.test((0, path_1.basename)(p)) && (0, fs_1.existsSync)(p))
|
|
72
72
|
.map((fullName) => {
|
|
73
73
|
var _a, _b;
|
|
@@ -79,11 +79,11 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
79
79
|
path: fullName,
|
|
80
80
|
};
|
|
81
81
|
});
|
|
82
|
-
const groups =
|
|
82
|
+
const groups = plugin_utils_1.lodash.groupBy(localeFiles, 'name');
|
|
83
83
|
const promises = Object.keys(groups).map((name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
84
|
const [lang, country = ''] = name.split(separator);
|
|
85
85
|
const { momentLocale } = (0, exports.getMomentLocale)(lang, country, resolveKey);
|
|
86
|
-
const antdLocale =
|
|
86
|
+
const antdLocale = plugin_utils_1.lodash
|
|
87
87
|
.uniq(yield addAntdLocales({ lang, country }))
|
|
88
88
|
.filter((localePath) => modulesHasLocale(localePath));
|
|
89
89
|
return {
|
|
@@ -94,7 +94,7 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
94
94
|
locale: name.split(separator).join('-'),
|
|
95
95
|
country,
|
|
96
96
|
antdLocale,
|
|
97
|
-
paths: groups[name].map((item) => (0,
|
|
97
|
+
paths: groups[name].map((item) => (0, plugin_utils_1.winPath)(item.path)),
|
|
98
98
|
momentLocale,
|
|
99
99
|
};
|
|
100
100
|
}));
|
|
@@ -102,7 +102,7 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
102
102
|
});
|
|
103
103
|
exports.getLocaleList = getLocaleList;
|
|
104
104
|
const exactLocalePaths = (data) => {
|
|
105
|
-
return
|
|
105
|
+
return plugin_utils_1.lodash.flatten(data.map((item) => item.paths));
|
|
106
106
|
};
|
|
107
107
|
exports.exactLocalePaths = exactLocalePaths;
|
|
108
108
|
function isNeedPolyfill(targets = {}) {
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -26,9 +30,9 @@ exports.ModelUtils = exports.Model = void 0;
|
|
|
26
30
|
const parser = __importStar(require("@umijs/bundler-utils/compiled/babel/parser"));
|
|
27
31
|
const traverse_1 = __importDefault(require("@umijs/bundler-utils/compiled/babel/traverse"));
|
|
28
32
|
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
29
|
-
const utils_1 = require("@umijs/utils");
|
|
30
33
|
const fs_1 = require("fs");
|
|
31
34
|
const path_1 = require("path");
|
|
35
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
32
36
|
const astUtils_1 = require("./astUtils");
|
|
33
37
|
class Model {
|
|
34
38
|
constructor(file, id) {
|
|
@@ -76,12 +80,12 @@ class ModelUtils {
|
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
getModels(opts) {
|
|
79
|
-
return
|
|
83
|
+
return plugin_utils_1.glob
|
|
80
84
|
.sync(opts.pattern || '**/*.{ts,js}', {
|
|
81
85
|
cwd: opts.base,
|
|
82
86
|
absolute: true,
|
|
83
87
|
})
|
|
84
|
-
.map(
|
|
88
|
+
.map(plugin_utils_1.winPath)
|
|
85
89
|
.filter((file) => {
|
|
86
90
|
if (/\.d.ts$/.test(file))
|
|
87
91
|
return false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withTmpPath = void 0;
|
|
4
|
-
const utils_1 = require("@umijs/utils");
|
|
5
4
|
const path_1 = require("path");
|
|
5
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
6
6
|
function withTmpPath(opts) {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, plugin_utils_1.winPath)((0, path_1.join)(opts.api.paths.absTmpPath, opts.api.plugin.key && !opts.noPluginDir
|
|
8
8
|
? `plugin-${opts.api.plugin.key}`
|
|
9
9
|
: '', opts.path));
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.4",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ahooksjs/use-request": "^2.0.0",
|
|
25
25
|
"@ant-design/icons": "^4.7.0",
|
|
26
|
-
"@ant-design/pro-layout": "^
|
|
27
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
28
|
-
"antd": "^4.
|
|
26
|
+
"@ant-design/pro-layout": "^7.0.1-beta.2",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.0-rc.4",
|
|
28
|
+
"antd": "^4.18.9",
|
|
29
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
30
|
-
"axios": "^0.
|
|
30
|
+
"axios": "^0.26.0",
|
|
31
31
|
"babel-plugin-import": "^1.13.3",
|
|
32
|
-
"dayjs": "^1.10.
|
|
32
|
+
"dayjs": "^1.10.8",
|
|
33
33
|
"dva-core": "^2.0.4",
|
|
34
34
|
"event-emitter": "~0.3.5",
|
|
35
35
|
"fast-deep-equal": "3.1.3",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"warning": "^4.0.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"umi": "4.0.0-rc.
|
|
45
|
+
"umi": "4.0.0-rc.4"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|