@umijs/utils 3.5.20 → 4.0.0-beta.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/README.md +2 -0
- package/compiled/address/index.js +1 -0
- package/compiled/address/lib/address.d.ts +28 -0
- package/compiled/address/package.json +1 -0
- package/compiled/axios/LICENSE +19 -0
- package/compiled/axios/index.d.ts +206 -0
- package/compiled/axios/index.js +1 -0
- package/compiled/axios/package.json +1 -0
- package/compiled/chalk/LICENSE +9 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/cheerio/LICENSE +21 -0
- package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
- package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
- package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
- package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
- package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
- package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
- package/compiled/cheerio/index.js +16 -0
- package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
- package/compiled/cheerio/lib/api/css.d.ts +41 -0
- package/compiled/cheerio/lib/api/forms.d.ts +31 -0
- package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
- package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
- package/compiled/cheerio/lib/cheerio.d.ts +53 -0
- package/compiled/cheerio/lib/index.d.ts +91 -0
- package/compiled/cheerio/lib/load.d.ts +73 -0
- package/compiled/cheerio/lib/options.d.ts +31 -0
- package/compiled/cheerio/lib/static.d.ts +88 -0
- package/compiled/cheerio/lib/types.d.ts +20 -0
- package/compiled/cheerio/package.json +1 -0
- package/compiled/color/LICENSE +21 -0
- package/compiled/color/color-convert/conversions.d.ts +149 -0
- package/compiled/color/color-convert/index.d.ts +113 -0
- package/compiled/color/color-convert/route.d.ts +294 -0
- package/compiled/color/color-name/index.d.ts +161 -0
- package/compiled/color/index.d.ts +142 -0
- package/compiled/color/index.js +1 -0
- package/compiled/color/package.json +4 -0
- package/compiled/cross-spawn/LICENSE +21 -0
- package/compiled/cross-spawn/index.d.ts +36 -0
- package/compiled/cross-spawn/index.js +1 -0
- package/compiled/cross-spawn/package.json +1 -0
- package/compiled/debug/LICENSE +19 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/deepmerge/index.d.ts +16 -0
- package/compiled/deepmerge/index.js +1 -0
- package/compiled/deepmerge/package.json +1 -0
- package/compiled/execa/LICENSE +9 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/fs-extra/LICENSE +15 -0
- package/compiled/fs-extra/index.d.ts +332 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/LICENSE +21 -0
- package/compiled/glob/index.d.ts +89 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/import-lazy/LICENSE +9 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/lodash/LICENSE +47 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1430 -0
- package/compiled/lodash/common/lang.d.ts +1692 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1219 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/mustache/LICENSE +11 -0
- package/compiled/mustache/index.d.ts +437 -0
- package/compiled/mustache/index.js +5 -0
- package/compiled/mustache/package.json +1 -0
- package/compiled/pkg-up/LICENSE +9 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/portfinder/LICENSE +22 -0
- package/compiled/portfinder/index.js +1 -0
- package/compiled/portfinder/lib/portfinder.d.ts +47 -0
- package/compiled/portfinder/package.json +1 -0
- package/compiled/prettier/LICENSE +7 -0
- package/compiled/prettier/index.d.ts +867 -0
- package/compiled/prettier/index.js +475 -0
- package/compiled/prettier/package.json +5 -0
- package/compiled/prompts/LICENSE +21 -0
- package/compiled/prompts/index.d.ts +120 -0
- package/compiled/prompts/index.js +1 -0
- package/compiled/prompts/package.json +1 -0
- package/compiled/resolve/LICENSE +21 -0
- package/compiled/resolve/index.d.ts +166 -0
- package/compiled/resolve/index.js +1 -0
- package/compiled/resolve/package.json +1 -0
- package/compiled/rimraf/LICENSE +15 -0
- package/compiled/rimraf/glob/index.d.ts +89 -0
- package/compiled/rimraf/index.d.ts +49 -0
- package/compiled/rimraf/index.js +1 -0
- package/compiled/rimraf/minimatch/index.d.ts +204 -0
- package/compiled/rimraf/package.json +1 -0
- package/compiled/semver/LICENSE +15 -0
- package/compiled/semver/classes/comparator.d.ts +17 -0
- package/compiled/semver/classes/range.d.ts +21 -0
- package/compiled/semver/classes/semver.d.ts +62 -0
- package/compiled/semver/functions/clean.d.ts +8 -0
- package/compiled/semver/functions/cmp.d.ts +16 -0
- package/compiled/semver/functions/coerce.d.ts +12 -0
- package/compiled/semver/functions/compare-build.d.ts +16 -0
- package/compiled/semver/functions/compare-loose.d.ts +5 -0
- package/compiled/semver/functions/compare.d.ts +20 -0
- package/compiled/semver/functions/diff.d.ts +13 -0
- package/compiled/semver/functions/eq.d.ts +9 -0
- package/compiled/semver/functions/gt.d.ts +9 -0
- package/compiled/semver/functions/gte.d.ts +9 -0
- package/compiled/semver/functions/inc.d.ts +15 -0
- package/compiled/semver/functions/lt.d.ts +9 -0
- package/compiled/semver/functions/lte.d.ts +8 -0
- package/compiled/semver/functions/major.d.ts +9 -0
- package/compiled/semver/functions/minor.d.ts +9 -0
- package/compiled/semver/functions/neq.d.ts +9 -0
- package/compiled/semver/functions/parse.d.ts +12 -0
- package/compiled/semver/functions/patch.d.ts +9 -0
- package/compiled/semver/functions/prerelease.d.ts +12 -0
- package/compiled/semver/functions/rcompare.d.ts +15 -0
- package/compiled/semver/functions/rsort.d.ts +9 -0
- package/compiled/semver/functions/satisfies.d.ts +14 -0
- package/compiled/semver/functions/sort.d.ts +9 -0
- package/compiled/semver/functions/valid.d.ts +11 -0
- package/compiled/semver/index.d.ts +133 -0
- package/compiled/semver/index.js +1 -0
- package/compiled/semver/internals/identifiers.d.ts +13 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/semver/ranges/gtr.d.ts +14 -0
- package/compiled/semver/ranges/intersects.d.ts +13 -0
- package/compiled/semver/ranges/ltr.d.ts +14 -0
- package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-version.d.ts +10 -0
- package/compiled/semver/ranges/outside.d.ts +15 -0
- package/compiled/semver/ranges/simplify.d.ts +14 -0
- package/compiled/semver/ranges/subset.d.ts +13 -0
- package/compiled/semver/ranges/to-comparators.d.ts +9 -0
- package/compiled/semver/ranges/valid.d.ts +12 -0
- package/compiled/strip-ansi/LICENSE +9 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/yargs-parser/index.d.ts +112 -0
- package/compiled/yargs-parser/index.js +1 -0
- package/compiled/yargs-parser/package.json +1 -0
- package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
- package/dist/BaseGenerator/BaseGenerator.js +58 -0
- package/dist/BaseGenerator/generateFile.d.ts +8 -0
- package/dist/BaseGenerator/generateFile.js +25 -0
- package/{lib → dist}/Generator/Generator.d.ts +3 -3
- package/dist/Generator/Generator.js +74 -0
- package/dist/importLazy.d.ts +6 -0
- package/dist/importLazy.js +17 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +88 -0
- package/dist/installDeps.d.ts +9 -0
- package/dist/installDeps.js +39 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.js +39 -0
- package/dist/npmClient.d.ts +15 -0
- package/dist/npmClient.js +43 -0
- package/dist/randomColor/randomColor.d.ts +6 -0
- package/dist/randomColor/randomColor.js +19 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.js +47 -0
- package/dist/updatePackageJSON.d.ts +5 -0
- package/dist/updatePackageJSON.js +21 -0
- package/dist/winPath.d.ts +1 -0
- package/dist/winPath.js +11 -0
- package/package.json +96 -12
- package/lib/BabelRegister/BabelRegister.d.ts +0 -9
- package/lib/BabelRegister/BabelRegister.js +0 -66
- package/lib/Generator/Generator.js +0 -120
- package/lib/cheerio/cheerio.d.ts +0 -2
- package/lib/cheerio/cheerio.js +0 -37
- package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
- package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
- package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
- package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
- package/lib/delay/delay.d.ts +0 -1
- package/lib/delay/delay.js +0 -22
- package/lib/getFile/getFile.d.ts +0 -22
- package/lib/getFile/getFile.js +0 -85
- package/lib/index.d.ts +0 -66
- package/lib/index.js +0 -619
- package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
- package/lib/isLernaPackage/isLernaPackage.js +0 -42
- package/lib/mergeConfig/mergeConfig.d.ts +0 -8
- package/lib/mergeConfig/mergeConfig.js +0 -42
- package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
- package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
- package/lib/randomColor/randomColor.d.ts +0 -6
- package/lib/randomColor/randomColor.js +0 -42
- package/lib/routes.d.ts +0 -11
- package/lib/routes.js +0 -53
- package/lib/ssr.d.ts +0 -12
- package/lib/ssr.js +0 -41
- package/lib/types.d.ts +0 -7
- package/lib/types.js +0 -17
- package/lib/winEOL/winEOL.d.ts +0 -7
- package/lib/winEOL/winEOL.js +0 -39
- package/lib/winPath/winPath.d.ts +0 -1
- package/lib/winPath/winPath.js +0 -28
package/dist/logger.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.event = exports.info = exports.ready = exports.warn = exports.error = exports.wait = exports.prefixes = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("../compiled/chalk"));
|
|
8
|
+
exports.prefixes = {
|
|
9
|
+
wait: chalk_1.default.cyan('wait') + ' -',
|
|
10
|
+
error: chalk_1.default.red('error') + ' -',
|
|
11
|
+
warn: chalk_1.default.yellow('warn') + ' -',
|
|
12
|
+
ready: chalk_1.default.green('ready') + ' -',
|
|
13
|
+
info: chalk_1.default.cyan('info') + ' -',
|
|
14
|
+
event: chalk_1.default.magenta('event') + ' -',
|
|
15
|
+
};
|
|
16
|
+
function wait(...message) {
|
|
17
|
+
console.log(exports.prefixes.wait, ...message);
|
|
18
|
+
}
|
|
19
|
+
exports.wait = wait;
|
|
20
|
+
function error(...message) {
|
|
21
|
+
console.error(exports.prefixes.error, ...message);
|
|
22
|
+
}
|
|
23
|
+
exports.error = error;
|
|
24
|
+
function warn(...message) {
|
|
25
|
+
console.warn(exports.prefixes.warn, ...message);
|
|
26
|
+
}
|
|
27
|
+
exports.warn = warn;
|
|
28
|
+
function ready(...message) {
|
|
29
|
+
console.log(exports.prefixes.ready, ...message);
|
|
30
|
+
}
|
|
31
|
+
exports.ready = ready;
|
|
32
|
+
function info(...message) {
|
|
33
|
+
console.log(exports.prefixes.info, ...message);
|
|
34
|
+
}
|
|
35
|
+
exports.info = info;
|
|
36
|
+
function event(...message) {
|
|
37
|
+
console.log(exports.prefixes.event, ...message);
|
|
38
|
+
}
|
|
39
|
+
exports.event = event;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type NpmClient = 'npm' | 'cnpm' | 'tnpm' | 'yarn' | 'pnpm';
|
|
2
|
+
export declare const npmClients: string[];
|
|
3
|
+
export declare enum NpmClientEnum {
|
|
4
|
+
pnpm = "pnpm",
|
|
5
|
+
tnpm = "tnpm",
|
|
6
|
+
cnpm = "cnpm",
|
|
7
|
+
yarn = "yarn",
|
|
8
|
+
npm = "npm"
|
|
9
|
+
}
|
|
10
|
+
export declare const getNpmClient: () => NpmClient;
|
|
11
|
+
export declare const checkNpmClient: (npmClient: NpmClient) => boolean;
|
|
12
|
+
export declare const installWithNpmClient: ({ npmClient, cwd, }: {
|
|
13
|
+
npmClient: NpmClient;
|
|
14
|
+
cwd?: string | undefined;
|
|
15
|
+
}) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installWithNpmClient = exports.checkNpmClient = exports.getNpmClient = exports.NpmClientEnum = exports.npmClients = void 0;
|
|
4
|
+
exports.npmClients = ['pnpm', 'tnpm', 'cnpm', 'yarn', 'npm'];
|
|
5
|
+
var NpmClientEnum;
|
|
6
|
+
(function (NpmClientEnum) {
|
|
7
|
+
NpmClientEnum["pnpm"] = "pnpm";
|
|
8
|
+
NpmClientEnum["tnpm"] = "tnpm";
|
|
9
|
+
NpmClientEnum["cnpm"] = "cnpm";
|
|
10
|
+
NpmClientEnum["yarn"] = "yarn";
|
|
11
|
+
NpmClientEnum["npm"] = "npm";
|
|
12
|
+
})(NpmClientEnum = exports.NpmClientEnum || (exports.NpmClientEnum = {}));
|
|
13
|
+
const getNpmClient = () => {
|
|
14
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
15
|
+
if (userAgent) {
|
|
16
|
+
if (userAgent.includes('pnpm'))
|
|
17
|
+
return 'pnpm';
|
|
18
|
+
if (userAgent.includes('tnpm'))
|
|
19
|
+
return 'tnpm';
|
|
20
|
+
if (userAgent.includes('yarn'))
|
|
21
|
+
return 'yarn';
|
|
22
|
+
if (userAgent.includes('cnpm'))
|
|
23
|
+
return 'cnpm';
|
|
24
|
+
}
|
|
25
|
+
return 'npm';
|
|
26
|
+
};
|
|
27
|
+
exports.getNpmClient = getNpmClient;
|
|
28
|
+
const checkNpmClient = (npmClient) => {
|
|
29
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
30
|
+
return !!(userAgent && userAgent.includes(npmClient));
|
|
31
|
+
};
|
|
32
|
+
exports.checkNpmClient = checkNpmClient;
|
|
33
|
+
const installWithNpmClient = ({ npmClient, cwd, }) => {
|
|
34
|
+
const { spawnSync } = require('child_process');
|
|
35
|
+
const npm = spawnSync(npmClient, [npmClient === 'yarn' ? '' : 'install'], {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
cwd,
|
|
38
|
+
});
|
|
39
|
+
if (npm.error) {
|
|
40
|
+
throw npm.error;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.installWithNpmClient = installWithNpmClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.randomColor = void 0;
|
|
7
|
+
const color_1 = __importDefault(require("../../compiled/color"));
|
|
8
|
+
const ratio = 0.618033988749895;
|
|
9
|
+
let hue = Math.random();
|
|
10
|
+
function randomColor(saturation = 0.5, value = 0.95) {
|
|
11
|
+
hue += ratio;
|
|
12
|
+
hue %= 1;
|
|
13
|
+
return (0, color_1.default)({
|
|
14
|
+
h: hue * 360,
|
|
15
|
+
s: saturation * 100,
|
|
16
|
+
v: value * 100,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.randomColor = randomColor;
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restore = exports.clearFiles = exports.getFiles = exports.register = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
let registered = false;
|
|
6
|
+
let files = [];
|
|
7
|
+
const Extensions = {};
|
|
8
|
+
function transform(opts) {
|
|
9
|
+
return (mod, filename) => {
|
|
10
|
+
files.push(filename);
|
|
11
|
+
let code = (0, fs_1.readFileSync)(filename, 'utf-8');
|
|
12
|
+
if (['.ts', '.tsx'].includes(opts.extname)) {
|
|
13
|
+
code = opts.implementor.transformSync(code, {
|
|
14
|
+
loader: opts.extname.slice(1),
|
|
15
|
+
target: 'es2017',
|
|
16
|
+
format: 'cjs',
|
|
17
|
+
}).code;
|
|
18
|
+
}
|
|
19
|
+
mod._compile(code, filename);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function register(opts) {
|
|
23
|
+
files = [];
|
|
24
|
+
const types = ['.ts', '.tsx', '.js', '.jsx', '.mjs'];
|
|
25
|
+
if (!registered) {
|
|
26
|
+
for (const type of types) {
|
|
27
|
+
Extensions[type] = require.extensions[type];
|
|
28
|
+
require.extensions[type] = transform(Object.assign(Object.assign({}, opts), { extname: type }));
|
|
29
|
+
}
|
|
30
|
+
registered = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.register = register;
|
|
34
|
+
function getFiles() {
|
|
35
|
+
return files;
|
|
36
|
+
}
|
|
37
|
+
exports.getFiles = getFiles;
|
|
38
|
+
function clearFiles() {
|
|
39
|
+
files = [];
|
|
40
|
+
}
|
|
41
|
+
exports.clearFiles = clearFiles;
|
|
42
|
+
function restore() {
|
|
43
|
+
for (const type of Object.keys(Extensions)) {
|
|
44
|
+
require.extensions[type] = Extensions[type];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.restore = restore;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const deepmerge_1 = __importDefault(require("../compiled/deepmerge"));
|
|
9
|
+
const prettier_1 = __importDefault(require("../compiled/prettier"));
|
|
10
|
+
function updatePackageJSON({ opts, cwd = process.cwd(), }) {
|
|
11
|
+
const packageJsonPath = (0, path_1.resolve)(cwd, 'package.json');
|
|
12
|
+
const pkg = require(packageJsonPath);
|
|
13
|
+
const projectPkg = (0, deepmerge_1.default)(pkg, opts);
|
|
14
|
+
(0, fs_1.writeFileSync)(packageJsonPath,
|
|
15
|
+
// 删除一个包之后 json会多了一些空行。sortPackage 可以删除掉并且排序
|
|
16
|
+
// prettier 会容忍一个空行
|
|
17
|
+
prettier_1.default.format(JSON.stringify(projectPkg), {
|
|
18
|
+
parser: 'json',
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
exports.default = updatePackageJSON;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function winPath(path: string): string;
|
package/dist/winPath.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.winPath = void 0;
|
|
4
|
+
function winPath(path) {
|
|
5
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
6
|
+
if (isExtendedLengthPath) {
|
|
7
|
+
return path;
|
|
8
|
+
}
|
|
9
|
+
return path.replace(/\\/g, '/');
|
|
10
|
+
}
|
|
11
|
+
exports.winPath = winPath;
|
package/package.json
CHANGED
|
@@ -1,29 +1,113 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/utils",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
7
6
|
"files": [
|
|
8
|
-
"
|
|
7
|
+
"dist",
|
|
8
|
+
"compiled"
|
|
9
9
|
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "pnpm tsc",
|
|
12
|
+
"build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
|
|
13
|
+
"dev": "pnpm build -- --watch"
|
|
14
|
+
},
|
|
10
15
|
"repository": {
|
|
11
16
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/umijs/umi"
|
|
17
|
+
"url": "https://github.com/umijs/umi-next"
|
|
13
18
|
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"umi"
|
|
16
|
-
],
|
|
17
19
|
"authors": [
|
|
18
20
|
"chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
|
|
19
21
|
],
|
|
20
22
|
"license": "MIT",
|
|
21
|
-
"bugs": "
|
|
22
|
-
"homepage": "https://github.com/umijs/umi/tree/master/packages/utils#readme",
|
|
23
|
+
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
24
|
+
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/utils#readme",
|
|
23
25
|
"publishConfig": {
|
|
24
26
|
"access": "public"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"
|
|
29
|
+
"chokidar": "3.5.2",
|
|
30
|
+
"clipboardy": "2.3.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/color": "3.0.2",
|
|
34
|
+
"@types/cross-spawn": "6.0.2",
|
|
35
|
+
"@types/debug": "4.1.7",
|
|
36
|
+
"@types/lodash": "4.14.176",
|
|
37
|
+
"@types/mustache": "4.1.2",
|
|
38
|
+
"@types/prompts": "^2.0.14",
|
|
39
|
+
"@types/rimraf": "3.0.2",
|
|
40
|
+
"@types/semver": "7.3.9",
|
|
41
|
+
"address": "1.1.2",
|
|
42
|
+
"axios": "0.23.0",
|
|
43
|
+
"chalk": "4.1.2",
|
|
44
|
+
"cheerio": "1.0.0-rc.10",
|
|
45
|
+
"color": "4.0.1",
|
|
46
|
+
"cross-spawn": "7.0.3",
|
|
47
|
+
"debug": "4.3.2",
|
|
48
|
+
"deepmerge": "4.2.2",
|
|
49
|
+
"execa": "5.1.1",
|
|
50
|
+
"fs-extra": "10.0.0",
|
|
51
|
+
"glob": "7.2.0",
|
|
52
|
+
"globby": "11.0.4",
|
|
53
|
+
"import-lazy": "4.0.0",
|
|
54
|
+
"lodash": "4.17.21",
|
|
55
|
+
"mustache": "4.2.0",
|
|
56
|
+
"pkg-up": "3.1.0",
|
|
57
|
+
"portfinder": "1.0.28",
|
|
58
|
+
"prettier": "2.4.1",
|
|
59
|
+
"prompts": "2.4.2",
|
|
60
|
+
"resolve": "1.20.0",
|
|
61
|
+
"rimraf": "3.0.2",
|
|
62
|
+
"semver": "7.3.5",
|
|
63
|
+
"strip-ansi": "6.0.1",
|
|
64
|
+
"yargs-parser": "20.2.9"
|
|
65
|
+
},
|
|
66
|
+
"compiledConfig": {
|
|
67
|
+
"deps": [
|
|
68
|
+
"address",
|
|
69
|
+
"axios",
|
|
70
|
+
"chalk",
|
|
71
|
+
"cheerio",
|
|
72
|
+
"color",
|
|
73
|
+
"cross-spawn",
|
|
74
|
+
"debug",
|
|
75
|
+
"deepmerge",
|
|
76
|
+
"execa",
|
|
77
|
+
"glob",
|
|
78
|
+
"fs-extra",
|
|
79
|
+
"import-lazy",
|
|
80
|
+
"lodash",
|
|
81
|
+
"mustache",
|
|
82
|
+
"prettier",
|
|
83
|
+
"pkg-up",
|
|
84
|
+
"portfinder",
|
|
85
|
+
"prompts",
|
|
86
|
+
"rimraf",
|
|
87
|
+
"resolve",
|
|
88
|
+
"semver",
|
|
89
|
+
"strip-ansi",
|
|
90
|
+
"yargs-parser"
|
|
91
|
+
],
|
|
92
|
+
"externals": {
|
|
93
|
+
"address": "$$LOCAL",
|
|
94
|
+
"axios": "$$LOCAL",
|
|
95
|
+
"chalk": "$$LOCAL",
|
|
96
|
+
"cheerio": "$$LOCAL",
|
|
97
|
+
"cross-spawn": "$$LOCAL",
|
|
98
|
+
"debug": "$$LOCAL",
|
|
99
|
+
"fs-extra": "$$LOCAL",
|
|
100
|
+
"globby": "$$LOCAL",
|
|
101
|
+
"import-lazy": "$$LOCAL",
|
|
102
|
+
"lodash": "$$LOCAL",
|
|
103
|
+
"mustache": "$$LOCAL",
|
|
104
|
+
"pkg-up": "$$LOCAL",
|
|
105
|
+
"portfinder": "$$LOCAL",
|
|
106
|
+
"rimraf": "$$LOCAL",
|
|
107
|
+
"resolve": "$$LOCAL",
|
|
108
|
+
"semver": "$$LOCAL",
|
|
109
|
+
"strip-ansi": "$$LOCAL",
|
|
110
|
+
"yargs-parser": "$$LOCAL"
|
|
111
|
+
}
|
|
28
112
|
}
|
|
29
113
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _fs() {
|
|
19
|
-
const data = require("fs");
|
|
20
|
-
|
|
21
|
-
_fs = function _fs() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _ = require("../");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
const debug = (0, _.createDebug)('umi:utils:BabelRegister');
|
|
33
|
-
|
|
34
|
-
class BabelRegister {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.only = {};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
setOnlyMap({
|
|
40
|
-
key,
|
|
41
|
-
value
|
|
42
|
-
}) {
|
|
43
|
-
debug(`set ${key} of only map:`);
|
|
44
|
-
debug(value);
|
|
45
|
-
this.only[key] = value;
|
|
46
|
-
this.register();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
register() {
|
|
50
|
-
const only = _.lodash.uniq(Object.keys(this.only).reduce((memo, key) => {
|
|
51
|
-
return memo.concat(this.only[key]);
|
|
52
|
-
}, []).map(_.winPath).map(path => (0, _fs().existsSync)(path) ? (0, _fs().realpathSync)(path) : path));
|
|
53
|
-
|
|
54
|
-
require('@umijs/deps/compiled/babel/register')({
|
|
55
|
-
presets: [require.resolve('@umijs/babel-preset-umi/node')],
|
|
56
|
-
ignore: [/node_modules/],
|
|
57
|
-
only,
|
|
58
|
-
extensions: ['.jsx', '.js', '.ts', '.tsx'],
|
|
59
|
-
babelrc: false,
|
|
60
|
-
cache: false
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports.default = BabelRegister;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _fs() {
|
|
19
|
-
const data = require("fs");
|
|
20
|
-
|
|
21
|
-
_fs = function _fs() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _path() {
|
|
29
|
-
const data = require("path");
|
|
30
|
-
|
|
31
|
-
_path = function _path() {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var _index = require("../index");
|
|
39
|
-
|
|
40
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
-
|
|
42
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
43
|
-
|
|
44
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
45
|
-
|
|
46
|
-
class Generator {
|
|
47
|
-
constructor({
|
|
48
|
-
cwd,
|
|
49
|
-
args
|
|
50
|
-
}) {
|
|
51
|
-
this.cwd = void 0;
|
|
52
|
-
this.args = void 0;
|
|
53
|
-
this.prompts = void 0;
|
|
54
|
-
this.cwd = cwd;
|
|
55
|
-
this.args = args;
|
|
56
|
-
this.prompts = {};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
run() {
|
|
60
|
-
var _this = this;
|
|
61
|
-
|
|
62
|
-
return _asyncToGenerator(function* () {
|
|
63
|
-
const questions = _this.prompting();
|
|
64
|
-
|
|
65
|
-
_this.prompts = yield (0, _index.prompts)(questions);
|
|
66
|
-
yield _this.writing();
|
|
67
|
-
})();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
prompting() {
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
writing() {
|
|
75
|
-
return _asyncToGenerator(function* () {})();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
copyTpl(opts) {
|
|
79
|
-
const tpl = (0, _fs().readFileSync)(opts.templatePath, 'utf-8');
|
|
80
|
-
|
|
81
|
-
const content = _index.Mustache.render(tpl, opts.context);
|
|
82
|
-
|
|
83
|
-
_index.mkdirp.sync((0, _path().dirname)(opts.target));
|
|
84
|
-
|
|
85
|
-
console.log(`${_index.chalk.green('Write:')} ${(0, _path().relative)(this.cwd, opts.target)}`);
|
|
86
|
-
(0, _fs().writeFileSync)(opts.target, content, 'utf-8');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
copyDirectory(opts) {
|
|
90
|
-
const files = _index.glob.sync('**/*', {
|
|
91
|
-
cwd: opts.path,
|
|
92
|
-
dot: true,
|
|
93
|
-
ignore: ['**/node_modules/**']
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
files.forEach(file => {
|
|
97
|
-
const absFile = (0, _path().join)(opts.path, file);
|
|
98
|
-
if ((0, _fs().statSync)(absFile).isDirectory()) return;
|
|
99
|
-
|
|
100
|
-
if (file.endsWith('.tpl')) {
|
|
101
|
-
this.copyTpl({
|
|
102
|
-
templatePath: absFile,
|
|
103
|
-
target: (0, _path().join)(opts.target, file.replace(/\.tpl$/, '')),
|
|
104
|
-
context: opts.context
|
|
105
|
-
});
|
|
106
|
-
} else {
|
|
107
|
-
console.log(`${_index.chalk.green('Copy: ')} ${file}`);
|
|
108
|
-
const absTarget = (0, _path().join)(opts.target, file);
|
|
109
|
-
|
|
110
|
-
_index.mkdirp.sync((0, _path().dirname)(absTarget));
|
|
111
|
-
|
|
112
|
-
(0, _fs().copyFileSync)(absFile, absTarget);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
var _default = Generator;
|
|
120
|
-
exports.default = _default;
|
package/lib/cheerio/cheerio.d.ts
DELETED
package/lib/cheerio/cheerio.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function cheerio() {
|
|
19
|
-
const data = _interopRequireWildcard(require("@umijs/deps/compiled/cheerio"));
|
|
20
|
-
|
|
21
|
-
cheerio = function cheerio() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
var _default = cheerio();
|
|
36
|
-
|
|
37
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (cacheKey: string): void;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var _ = require("../");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
// 暂时无法使用 jest 进行单元测试,原因可参见
|
|
23
|
-
// https://github.com/facebook/jest/issues/5741
|
|
24
|
-
function _default(cacheKey) {
|
|
25
|
-
// windows 下 require.cache 中路径 key 为类似 ‘c:\demo\.umirc.ts’
|
|
26
|
-
const cachePath = _.isWindows ? cacheKey.replace(/\//g, '\\') : cacheKey;
|
|
27
|
-
|
|
28
|
-
if (require.cache[cachePath]) {
|
|
29
|
-
const cacheParent = require.cache[cachePath].parent;
|
|
30
|
-
let i = (cacheParent === null || cacheParent === void 0 ? void 0 : cacheParent.children.length) || 0; // 清理 require cache 中 parents 的引用
|
|
31
|
-
|
|
32
|
-
while (i--) {
|
|
33
|
-
if (cacheParent.children[i].id === cachePath) {
|
|
34
|
-
cacheParent.children.splice(i, 1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
delete require.cache[cachePath];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = compatESModuleRequire;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function compatESModuleRequire(m) {
|
|
21
|
-
return m.__esModule ? m.default : m;
|
|
22
|
-
}
|
package/lib/delay/delay.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function delay(ms: number): Promise<unknown>;
|