@umijs/utils 3.5.20 → 4.0.0-beta.1

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.
Files changed (208) hide show
  1. package/README.md +2 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/axios/LICENSE +19 -0
  6. package/compiled/axios/index.d.ts +206 -0
  7. package/compiled/axios/index.js +1 -0
  8. package/compiled/axios/package.json +1 -0
  9. package/compiled/chalk/LICENSE +9 -0
  10. package/compiled/chalk/index.d.ts +415 -0
  11. package/compiled/chalk/index.js +1 -0
  12. package/compiled/chalk/package.json +1 -0
  13. package/compiled/cheerio/LICENSE +21 -0
  14. package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
  15. package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
  16. package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
  17. package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
  18. package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
  19. package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
  20. package/compiled/cheerio/index.js +16 -0
  21. package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
  22. package/compiled/cheerio/lib/api/css.d.ts +41 -0
  23. package/compiled/cheerio/lib/api/forms.d.ts +31 -0
  24. package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
  25. package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
  26. package/compiled/cheerio/lib/cheerio.d.ts +53 -0
  27. package/compiled/cheerio/lib/index.d.ts +91 -0
  28. package/compiled/cheerio/lib/load.d.ts +73 -0
  29. package/compiled/cheerio/lib/options.d.ts +31 -0
  30. package/compiled/cheerio/lib/static.d.ts +88 -0
  31. package/compiled/cheerio/lib/types.d.ts +20 -0
  32. package/compiled/cheerio/package.json +1 -0
  33. package/compiled/color/LICENSE +21 -0
  34. package/compiled/color/color-convert/conversions.d.ts +149 -0
  35. package/compiled/color/color-convert/index.d.ts +113 -0
  36. package/compiled/color/color-convert/route.d.ts +294 -0
  37. package/compiled/color/color-name/index.d.ts +161 -0
  38. package/compiled/color/index.d.ts +142 -0
  39. package/compiled/color/index.js +1 -0
  40. package/compiled/color/package.json +4 -0
  41. package/compiled/cross-spawn/LICENSE +21 -0
  42. package/compiled/cross-spawn/index.d.ts +36 -0
  43. package/compiled/cross-spawn/index.js +1 -0
  44. package/compiled/cross-spawn/package.json +1 -0
  45. package/compiled/debug/LICENSE +19 -0
  46. package/compiled/debug/index.d.ts +54 -0
  47. package/compiled/debug/index.js +1 -0
  48. package/compiled/debug/ms/index.d.ts +25 -0
  49. package/compiled/debug/package.json +1 -0
  50. package/compiled/fs-extra/LICENSE +15 -0
  51. package/compiled/fs-extra/index.d.ts +332 -0
  52. package/compiled/fs-extra/index.js +1 -0
  53. package/compiled/fs-extra/package.json +1 -0
  54. package/compiled/glob/LICENSE +21 -0
  55. package/compiled/glob/index.d.ts +89 -0
  56. package/compiled/glob/index.js +1 -0
  57. package/compiled/glob/minimatch/index.d.ts +204 -0
  58. package/compiled/glob/package.json +1 -0
  59. package/compiled/import-lazy/LICENSE +9 -0
  60. package/compiled/import-lazy/index.d.ts +26 -0
  61. package/compiled/import-lazy/index.js +1 -0
  62. package/compiled/import-lazy/package.json +1 -0
  63. package/compiled/lodash/LICENSE +47 -0
  64. package/compiled/lodash/common/array.d.ts +2126 -0
  65. package/compiled/lodash/common/collection.d.ts +1930 -0
  66. package/compiled/lodash/common/common.d.ts +280 -0
  67. package/compiled/lodash/common/date.d.ts +23 -0
  68. package/compiled/lodash/common/function.d.ts +1430 -0
  69. package/compiled/lodash/common/lang.d.ts +1692 -0
  70. package/compiled/lodash/common/math.d.ts +405 -0
  71. package/compiled/lodash/common/number.d.ts +131 -0
  72. package/compiled/lodash/common/object.d.ts +2519 -0
  73. package/compiled/lodash/common/seq.d.ts +210 -0
  74. package/compiled/lodash/common/string.d.ts +788 -0
  75. package/compiled/lodash/common/util.d.ts +1219 -0
  76. package/compiled/lodash/index.d.ts +46 -0
  77. package/compiled/lodash/index.js +9 -0
  78. package/compiled/lodash/package.json +1 -0
  79. package/compiled/mustache/LICENSE +11 -0
  80. package/compiled/mustache/index.d.ts +437 -0
  81. package/compiled/mustache/index.js +5 -0
  82. package/compiled/mustache/package.json +1 -0
  83. package/compiled/pkg-up/LICENSE +9 -0
  84. package/compiled/pkg-up/index.d.ts +48 -0
  85. package/compiled/pkg-up/index.js +1 -0
  86. package/compiled/pkg-up/package.json +1 -0
  87. package/compiled/portfinder/LICENSE +22 -0
  88. package/compiled/portfinder/index.js +1 -0
  89. package/compiled/portfinder/lib/portfinder.d.ts +47 -0
  90. package/compiled/portfinder/package.json +1 -0
  91. package/compiled/prettier/LICENSE +7 -0
  92. package/compiled/prettier/index.d.ts +867 -0
  93. package/compiled/prettier/index.js +475 -0
  94. package/compiled/prettier/package.json +5 -0
  95. package/compiled/prompts/LICENSE +21 -0
  96. package/compiled/prompts/index.d.ts +120 -0
  97. package/compiled/prompts/index.js +1 -0
  98. package/compiled/prompts/package.json +1 -0
  99. package/compiled/resolve/LICENSE +21 -0
  100. package/compiled/resolve/index.d.ts +166 -0
  101. package/compiled/resolve/index.js +1 -0
  102. package/compiled/resolve/package.json +1 -0
  103. package/compiled/rimraf/LICENSE +15 -0
  104. package/compiled/rimraf/glob/index.d.ts +89 -0
  105. package/compiled/rimraf/index.d.ts +49 -0
  106. package/compiled/rimraf/index.js +1 -0
  107. package/compiled/rimraf/minimatch/index.d.ts +204 -0
  108. package/compiled/rimraf/package.json +1 -0
  109. package/compiled/semver/LICENSE +15 -0
  110. package/compiled/semver/classes/comparator.d.ts +17 -0
  111. package/compiled/semver/classes/range.d.ts +21 -0
  112. package/compiled/semver/classes/semver.d.ts +62 -0
  113. package/compiled/semver/functions/clean.d.ts +8 -0
  114. package/compiled/semver/functions/cmp.d.ts +16 -0
  115. package/compiled/semver/functions/coerce.d.ts +12 -0
  116. package/compiled/semver/functions/compare-build.d.ts +16 -0
  117. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  118. package/compiled/semver/functions/compare.d.ts +20 -0
  119. package/compiled/semver/functions/diff.d.ts +13 -0
  120. package/compiled/semver/functions/eq.d.ts +9 -0
  121. package/compiled/semver/functions/gt.d.ts +9 -0
  122. package/compiled/semver/functions/gte.d.ts +9 -0
  123. package/compiled/semver/functions/inc.d.ts +15 -0
  124. package/compiled/semver/functions/lt.d.ts +9 -0
  125. package/compiled/semver/functions/lte.d.ts +8 -0
  126. package/compiled/semver/functions/major.d.ts +9 -0
  127. package/compiled/semver/functions/minor.d.ts +9 -0
  128. package/compiled/semver/functions/neq.d.ts +9 -0
  129. package/compiled/semver/functions/parse.d.ts +12 -0
  130. package/compiled/semver/functions/patch.d.ts +9 -0
  131. package/compiled/semver/functions/prerelease.d.ts +12 -0
  132. package/compiled/semver/functions/rcompare.d.ts +15 -0
  133. package/compiled/semver/functions/rsort.d.ts +9 -0
  134. package/compiled/semver/functions/satisfies.d.ts +14 -0
  135. package/compiled/semver/functions/sort.d.ts +9 -0
  136. package/compiled/semver/functions/valid.d.ts +11 -0
  137. package/compiled/semver/index.d.ts +133 -0
  138. package/compiled/semver/index.js +1 -0
  139. package/compiled/semver/internals/identifiers.d.ts +13 -0
  140. package/compiled/semver/package.json +1 -0
  141. package/compiled/semver/ranges/gtr.d.ts +14 -0
  142. package/compiled/semver/ranges/intersects.d.ts +13 -0
  143. package/compiled/semver/ranges/ltr.d.ts +14 -0
  144. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  145. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  146. package/compiled/semver/ranges/min-version.d.ts +10 -0
  147. package/compiled/semver/ranges/outside.d.ts +15 -0
  148. package/compiled/semver/ranges/simplify.d.ts +14 -0
  149. package/compiled/semver/ranges/subset.d.ts +13 -0
  150. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  151. package/compiled/semver/ranges/valid.d.ts +12 -0
  152. package/compiled/strip-ansi/LICENSE +9 -0
  153. package/compiled/strip-ansi/index.d.ts +17 -0
  154. package/compiled/strip-ansi/index.js +1 -0
  155. package/compiled/strip-ansi/package.json +1 -0
  156. package/compiled/yargs-parser/index.d.ts +112 -0
  157. package/compiled/yargs-parser/index.js +1 -0
  158. package/compiled/yargs-parser/package.json +1 -0
  159. package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
  160. package/dist/BaseGenerator/BaseGenerator.js +58 -0
  161. package/{lib → dist}/Generator/Generator.d.ts +3 -3
  162. package/dist/Generator/Generator.js +74 -0
  163. package/dist/importLazy.d.ts +6 -0
  164. package/dist/importLazy.js +17 -0
  165. package/dist/index.d.ts +28 -0
  166. package/dist/index.js +79 -0
  167. package/dist/logger.d.ts +14 -0
  168. package/dist/logger.js +39 -0
  169. package/dist/randomColor/randomColor.d.ts +6 -0
  170. package/dist/randomColor/randomColor.js +19 -0
  171. package/dist/register.d.ts +6 -0
  172. package/dist/register.js +47 -0
  173. package/dist/winPath.d.ts +1 -0
  174. package/dist/winPath.js +11 -0
  175. package/package.json +92 -12
  176. package/lib/BabelRegister/BabelRegister.d.ts +0 -9
  177. package/lib/BabelRegister/BabelRegister.js +0 -66
  178. package/lib/Generator/Generator.js +0 -120
  179. package/lib/cheerio/cheerio.d.ts +0 -2
  180. package/lib/cheerio/cheerio.js +0 -37
  181. package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
  182. package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
  183. package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
  184. package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
  185. package/lib/delay/delay.d.ts +0 -1
  186. package/lib/delay/delay.js +0 -22
  187. package/lib/getFile/getFile.d.ts +0 -22
  188. package/lib/getFile/getFile.js +0 -85
  189. package/lib/index.d.ts +0 -66
  190. package/lib/index.js +0 -619
  191. package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
  192. package/lib/isLernaPackage/isLernaPackage.js +0 -42
  193. package/lib/mergeConfig/mergeConfig.d.ts +0 -8
  194. package/lib/mergeConfig/mergeConfig.js +0 -42
  195. package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
  196. package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
  197. package/lib/randomColor/randomColor.d.ts +0 -6
  198. package/lib/randomColor/randomColor.js +0 -42
  199. package/lib/routes.d.ts +0 -11
  200. package/lib/routes.js +0 -53
  201. package/lib/ssr.d.ts +0 -12
  202. package/lib/ssr.js +0 -41
  203. package/lib/types.d.ts +0 -7
  204. package/lib/types.js +0 -17
  205. package/lib/winEOL/winEOL.d.ts +0 -7
  206. package/lib/winEOL/winEOL.js +0 -39
  207. package/lib/winPath/winPath.d.ts +0 -1
  208. package/lib/winPath/winPath.js +0 -28
@@ -0,0 +1 @@
1
+ export declare function winPath(path: string): string;
@@ -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,109 @@
1
1
  {
2
2
  "name": "@umijs/utils",
3
- "version": "3.5.20",
4
- "description": "@umijs/utils",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
3
+ "version": "4.0.0-beta.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
7
6
  "files": [
8
- "lib"
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": "http://github.com/umijs/umi/issues",
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
- "@umijs/deps": "3.5.20"
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.175",
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
+ "fs-extra": "10.0.0",
49
+ "glob": "7.2.0",
50
+ "globby": "11.0.4",
51
+ "import-lazy": "4.0.0",
52
+ "lodash": "4.17.21",
53
+ "mustache": "4.2.0",
54
+ "pkg-up": "3.1.0",
55
+ "portfinder": "1.0.28",
56
+ "prettier": "2.4.1",
57
+ "prompts": "2.4.2",
58
+ "resolve": "1.20.0",
59
+ "rimraf": "3.0.2",
60
+ "semver": "7.3.5",
61
+ "strip-ansi": "6.0.1",
62
+ "yargs-parser": "20.2.9"
63
+ },
64
+ "compiledConfig": {
65
+ "deps": [
66
+ "address",
67
+ "axios",
68
+ "chalk",
69
+ "cheerio",
70
+ "color",
71
+ "cross-spawn",
72
+ "debug",
73
+ "glob",
74
+ "fs-extra",
75
+ "import-lazy",
76
+ "lodash",
77
+ "mustache",
78
+ "prettier",
79
+ "pkg-up",
80
+ "portfinder",
81
+ "prompts",
82
+ "rimraf",
83
+ "resolve",
84
+ "semver",
85
+ "strip-ansi",
86
+ "yargs-parser"
87
+ ],
88
+ "externals": {
89
+ "address": "$$LOCAL",
90
+ "axios": "$$LOCAL",
91
+ "chalk": "$$LOCAL",
92
+ "cheerio": "$$LOCAL",
93
+ "cross-spawn": "$$LOCAL",
94
+ "debug": "$$LOCAL",
95
+ "fs-extra": "$$LOCAL",
96
+ "globby": "$$LOCAL",
97
+ "import-lazy": "$$LOCAL",
98
+ "lodash": "$$LOCAL",
99
+ "mustache": "$$LOCAL",
100
+ "pkg-up": "$$LOCAL",
101
+ "portfinder": "$$LOCAL",
102
+ "rimraf": "$$LOCAL",
103
+ "resolve": "$$LOCAL",
104
+ "semver": "$$LOCAL",
105
+ "strip-ansi": "$$LOCAL",
106
+ "yargs-parser": "$$LOCAL"
107
+ }
28
108
  }
29
109
  }
@@ -1,9 +0,0 @@
1
- export default class BabelRegister {
2
- only: Record<string, string[]>;
3
- constructor();
4
- setOnlyMap({ key, value }: {
5
- key: string;
6
- value: string[];
7
- }): void;
8
- register(): void;
9
- }
@@ -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;
@@ -1,2 +0,0 @@
1
- import * as cheerio from '@umijs/deps/compiled/cheerio';
2
- export default cheerio;
@@ -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,7 +0,0 @@
1
- export default function compatESModuleRequire<T extends {
2
- __esModule: boolean;
3
- default: any;
4
- }>(m: T): T extends {
5
- __esModule: true;
6
- default: infer U;
7
- } ? U : T;
@@ -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
- }
@@ -1 +0,0 @@
1
- export default function delay(ms: number): Promise<unknown>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = delay;
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 delay(ms) {
21
- return new Promise(resolve => setTimeout(resolve, ms));
22
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * @description
3
- * - `'javascript'`: try to match the file with extname `.{ts(x)|js(x)}`
4
- * - `'css'`: try to match the file with extname `.{less|sass|scss|stylus|css}`
5
- */
6
- declare type FileType = 'javascript' | 'css';
7
- interface IGetFileOpts {
8
- base: string;
9
- type: FileType;
10
- fileNameWithoutExt: string;
11
- }
12
- /**
13
- * Try to match the exact extname of the file in a specific directory.
14
- * @returns
15
- * - matched: `{ path: string; filename: string }`
16
- * - otherwise: `null`
17
- */
18
- export default function getFile(opts: IGetFileOpts): {
19
- path: string;
20
- filename: string;
21
- } | null;
22
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = getFile;
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 _winPath = _interopRequireDefault(require("../winPath/winPath"));
39
-
40
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
-
42
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
43
-
44
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
-
46
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
47
-
48
- const extsMap = {
49
- javascript: ['.ts', '.tsx', '.js', '.jsx'],
50
- css: ['.less', '.sass', '.scss', '.stylus', '.css']
51
- };
52
- /**
53
- * Try to match the exact extname of the file in a specific directory.
54
- * @returns
55
- * - matched: `{ path: string; filename: string }`
56
- * - otherwise: `null`
57
- */
58
-
59
- function getFile(opts) {
60
- const exts = extsMap[opts.type];
61
-
62
- var _iterator = _createForOfIteratorHelper(exts),
63
- _step;
64
-
65
- try {
66
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
67
- const ext = _step.value;
68
- const filename = `${opts.fileNameWithoutExt}${ext}`;
69
- const path = (0, _winPath.default)((0, _path().join)(opts.base, filename));
70
-
71
- if ((0, _fs().existsSync)(path)) {
72
- return {
73
- path,
74
- filename
75
- };
76
- }
77
- }
78
- } catch (err) {
79
- _iterator.e(err);
80
- } finally {
81
- _iterator.f();
82
- }
83
-
84
- return null;
85
- }
package/lib/index.d.ts DELETED
@@ -1,66 +0,0 @@
1
- import address from '@umijs/deps/compiled/address';
2
- import * as parser from '@umijs/deps/compiled/babel/parser';
3
- import * as traverse from '@umijs/deps/compiled/babel/traverse';
4
- import * as t from '@umijs/deps/compiled/babel/types';
5
- import chalk from '@umijs/deps/compiled/chalk';
6
- import spawn from '@umijs/deps/compiled/cross-spawn';
7
- import createDebug, { Debugger } from '@umijs/deps/compiled/debug';
8
- import deepmerge from '@umijs/deps/compiled/deepmerge';
9
- import execa from '@umijs/deps/compiled/execa';
10
- import glob from '@umijs/deps/compiled/glob';
11
- import got from '@umijs/deps/compiled/got';
12
- import lodash from '@umijs/deps/compiled/lodash';
13
- import mkdirp from '@umijs/deps/compiled/mkdirp';
14
- import Mustache from '@umijs/deps/compiled/mustache';
15
- import pkgUp from '@umijs/deps/compiled/pkg-up';
16
- import portfinder from '@umijs/deps/compiled/portfinder';
17
- import prompts from '@umijs/deps/compiled/prompts';
18
- import resolve from '@umijs/deps/compiled/resolve';
19
- import rimraf from '@umijs/deps/compiled/rimraf';
20
- import semver from '@umijs/deps/compiled/semver';
21
- import signale from '@umijs/deps/compiled/signale';
22
- import yargs from '@umijs/deps/compiled/yargs';
23
- import yParser from '@umijs/deps/compiled/yargs-parser';
24
- import * as chokidar from '@umijs/deps/reexported/chokidar';
25
- import clipboardy from '@umijs/deps/reexported/clipboardy';
26
- export { default as BabelRegister } from './BabelRegister/BabelRegister';
27
- export { default as cheerio } from './cheerio/cheerio';
28
- export { default as cleanRequireCache } from './cleanRequireCache/cleanRequireCache';
29
- export { default as compatESModuleRequire } from './compatESModuleRequire/compatESModuleRequire';
30
- export { default as delay } from './delay/delay';
31
- export { default as Generator } from './Generator/Generator';
32
- export { default as getFile } from './getFile/getFile';
33
- export { default as isLernaPackage } from './isLernaPackage/isLernaPackage';
34
- export { default as mergeConfig } from './mergeConfig/mergeConfig';
35
- export { default as parseRequireDeps } from './parseRequireDeps/parseRequireDeps';
36
- export { default as randomColor } from './randomColor/randomColor';
37
- export * from './routes';
38
- export * from './ssr';
39
- export * from './types';
40
- export { default as winEOL, isWindows } from './winEOL/winEOL';
41
- export { default as winPath } from './winPath/winPath';
42
- export { spawn };
43
- export { semver };
44
- export { address };
45
- export { chalk };
46
- export { clipboardy };
47
- export { chokidar };
48
- export { createDebug, Debugger };
49
- export { deepmerge };
50
- export { execa };
51
- export { lodash };
52
- export { glob };
53
- export { got };
54
- export { prompts };
55
- export { portfinder };
56
- export { pkgUp };
57
- export { resolve };
58
- export { yargs };
59
- export { mkdirp };
60
- export { Mustache };
61
- export { rimraf };
62
- export { yParser };
63
- export { t };
64
- export { parser };
65
- export { traverse };
66
- export { signale };