@umijs/utils 4.0.0-beta.9 → 4.0.0-rc.3

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 (69) hide show
  1. package/compiled/axios/index.d.ts +29 -14
  2. package/compiled/axios/index.js +1 -1
  3. package/compiled/chalk/LICENSE +1 -1
  4. package/compiled/chalk/index.js +1 -1
  5. package/compiled/chalk/package.json +1 -1
  6. package/compiled/chalk/source/index.d.ts +318 -0
  7. package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
  8. package/compiled/color/color-convert/conversions.d.ts +87 -87
  9. package/compiled/color/color-convert/index.d.ts +75 -60
  10. package/compiled/color/color-convert/route.d.ts +271 -271
  11. package/compiled/color/index.d.ts +118 -121
  12. package/compiled/color/index.js +1 -1
  13. package/compiled/color/package.json +1 -4
  14. package/compiled/debug/LICENSE +10 -9
  15. package/compiled/debug/index.js +1 -1
  16. package/compiled/debug/package.json +1 -1
  17. package/compiled/execa/index.d.ts +467 -445
  18. package/compiled/execa/index.js +1 -1
  19. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  20. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
  21. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  22. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  23. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  24. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  25. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
  26. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  27. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
  28. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  29. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
  30. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  31. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  32. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  33. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
  34. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  35. package/compiled/globby/LICENSE +9 -0
  36. package/compiled/globby/fast-glob/out/index.d.ts +27 -0
  37. package/compiled/globby/fast-glob/out/managers/tasks.d.ts +22 -0
  38. package/compiled/globby/fast-glob/out/settings.d.ts +164 -0
  39. package/compiled/globby/fast-glob/out/types/index.d.ts +31 -0
  40. package/compiled/globby/index.d.ts +206 -0
  41. package/compiled/globby/index.js +37 -0
  42. package/compiled/globby/package.json +1 -0
  43. package/compiled/pirates/LICENSE +21 -0
  44. package/compiled/pirates/index.d.ts +82 -0
  45. package/compiled/pirates/index.js +1 -0
  46. package/compiled/pirates/package.json +1 -0
  47. package/compiled/pkg-up/LICENSE +1 -1
  48. package/compiled/pkg-up/index.d.ts +55 -44
  49. package/compiled/pkg-up/index.js +1 -1
  50. package/compiled/pkg-up/package.json +1 -1
  51. package/compiled/resolve/index.js +1 -1
  52. package/compiled/strip-ansi/LICENSE +1 -1
  53. package/compiled/strip-ansi/index.d.ts +2 -4
  54. package/compiled/strip-ansi/index.js +1 -1
  55. package/compiled/strip-ansi/package.json +1 -1
  56. package/compiled/yargs-parser/index.js +1 -1
  57. package/dist/getCorejsVersion.d.ts +1 -0
  58. package/dist/getCorejsVersion.js +11 -0
  59. package/dist/index.d.ts +5 -3
  60. package/dist/index.js +6 -5
  61. package/dist/installDeps.js +20 -4
  62. package/dist/isStyleFile.d.ts +5 -0
  63. package/dist/isStyleFile.js +16 -0
  64. package/dist/logger.d.ts +8 -6
  65. package/dist/logger.js +8 -1
  66. package/dist/register.js +21 -22
  67. package/dist/tryPaths.d.ts +1 -0
  68. package/dist/tryPaths.js +11 -0
  69. package/package.json +19 -18
package/dist/logger.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.event = exports.info = exports.ready = exports.warn = exports.error = exports.wait = exports.prefixes = void 0;
6
+ exports.debug = exports.event = exports.info = exports.ready = exports.warn = exports.error = exports.wait = exports.prefixes = void 0;
7
7
  const chalk_1 = __importDefault(require("../compiled/chalk"));
8
8
  exports.prefixes = {
9
9
  wait: chalk_1.default.cyan('wait') + ' -',
@@ -12,6 +12,7 @@ exports.prefixes = {
12
12
  ready: chalk_1.default.green('ready') + ' -',
13
13
  info: chalk_1.default.cyan('info') + ' -',
14
14
  event: chalk_1.default.magenta('event') + ' -',
15
+ debug: chalk_1.default.gray('debug') + ' -',
15
16
  };
16
17
  function wait(...message) {
17
18
  console.log(exports.prefixes.wait, ...message);
@@ -37,3 +38,9 @@ function event(...message) {
37
38
  console.log(exports.prefixes.event, ...message);
38
39
  }
39
40
  exports.event = event;
41
+ function debug(...message) {
42
+ if (process.env.DEBUG) {
43
+ console.log(exports.prefixes.debug, ...message);
44
+ }
45
+ }
46
+ exports.debug = debug;
package/dist/register.js CHANGED
@@ -1,32 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.restore = exports.clearFiles = exports.getFiles = exports.register = void 0;
4
- const fs_1 = require("fs");
4
+ const path_1 = require("path");
5
+ const pirates_1 = require("../compiled/pirates");
6
+ const COMPILE_EXTS = ['.ts', '.tsx', '.js', '.jsx'];
7
+ const HOOK_EXTS = [...COMPILE_EXTS, '.mjs'];
5
8
  let registered = false;
6
9
  let files = [];
7
- const Extensions = {};
10
+ let revert = () => { };
8
11
  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
- };
12
+ const { code, filename, implementor } = opts;
13
+ files.push(filename);
14
+ const ext = (0, path_1.extname)(filename);
15
+ if (COMPILE_EXTS.includes(ext)) {
16
+ return implementor.transformSync(code, {
17
+ loader: ext.slice(1),
18
+ target: 'es2017',
19
+ format: 'cjs',
20
+ }).code;
21
+ }
22
+ return code;
21
23
  }
22
24
  function register(opts) {
23
25
  files = [];
24
- const types = ['.ts', '.tsx', '.js', '.jsx', '.mjs'];
25
26
  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
- }
27
+ revert = (0, pirates_1.addHook)((code, filename) => transform({ code, filename, implementor: opts.implementor }), {
28
+ ext: HOOK_EXTS,
29
+ ignoreNodeModules: true,
30
+ });
30
31
  registered = true;
31
32
  }
32
33
  }
@@ -40,9 +41,7 @@ function clearFiles() {
40
41
  }
41
42
  exports.clearFiles = clearFiles;
42
43
  function restore() {
43
- for (const type of Object.keys(Extensions)) {
44
- require.extensions[type] = Extensions[type];
45
- }
44
+ revert();
46
45
  registered = false;
47
46
  }
48
47
  exports.restore = restore;
@@ -0,0 +1 @@
1
+ export declare function tryPaths(paths: string[]): string | undefined;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryPaths = void 0;
4
+ const fs_1 = require("fs");
5
+ function tryPaths(paths) {
6
+ for (const path of paths) {
7
+ if ((0, fs_1.existsSync)(path))
8
+ return path;
9
+ }
10
+ }
11
+ exports.tryPaths = tryPaths;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/utils",
3
- "version": "4.0.0-beta.9",
3
+ "version": "4.0.0-rc.3",
4
4
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/utils#readme",
5
5
  "bugs": "https://github.com/umijs/umi-next/issues",
6
6
  "repository": {
@@ -20,42 +20,41 @@
20
20
  "dev": "pnpm build -- --watch"
21
21
  },
22
22
  "dependencies": {
23
- "chokidar": "3.5.2",
24
- "clipboardy": "2.3.0"
23
+ "chokidar": "3.5.3"
25
24
  },
26
25
  "devDependencies": {
27
- "@types/color": "3.0.2",
26
+ "@types/color": "3.0.3",
28
27
  "@types/cross-spawn": "6.0.2",
29
28
  "@types/debug": "4.1.7",
30
- "@types/lodash": "4.14.176",
29
+ "@types/lodash": "4.14.178",
31
30
  "@types/mustache": "4.1.2",
32
31
  "@types/prompts": "^2.0.14",
33
32
  "@types/rimraf": "3.0.2",
34
33
  "@types/semver": "7.3.9",
35
34
  "address": "1.1.2",
36
- "axios": "0.23.0",
37
- "chalk": "4.1.2",
35
+ "axios": "0.26.0",
36
+ "chalk": "5.0.0",
38
37
  "cheerio": "1.0.0-rc.10",
39
- "color": "4.0.1",
38
+ "color": "4.2.1",
40
39
  "cross-spawn": "7.0.3",
41
- "debug": "4.3.2",
40
+ "debug": "4.3.3",
42
41
  "deepmerge": "4.2.2",
43
- "execa": "5.1.1",
42
+ "execa": "6.1.0",
44
43
  "fs-extra": "10.0.0",
45
44
  "glob": "7.2.0",
46
- "globby": "11.0.4",
47
45
  "import-lazy": "4.0.0",
48
46
  "lodash": "4.17.21",
49
47
  "mustache": "4.2.0",
50
- "pkg-up": "3.1.0",
48
+ "pirates": "4.0.5",
49
+ "pkg-up": "4.0.0",
51
50
  "portfinder": "1.0.28",
52
- "prettier": "2.5.0",
51
+ "prettier": "2.5.1",
53
52
  "prompts": "2.4.2",
54
- "resolve": "1.20.0",
53
+ "resolve": "1.22.0",
55
54
  "rimraf": "3.0.2",
56
55
  "semver": "7.3.5",
57
- "strip-ansi": "6.0.1",
58
- "yargs-parser": "20.2.9"
56
+ "strip-ansi": "7.0.1",
57
+ "yargs-parser": "21.0.0"
59
58
  },
60
59
  "publishConfig": {
61
60
  "access": "public"
@@ -87,7 +86,8 @@
87
86
  "resolve",
88
87
  "semver",
89
88
  "strip-ansi",
90
- "yargs-parser"
89
+ "yargs-parser",
90
+ "pirates"
91
91
  ],
92
92
  "externals": {
93
93
  "address": "$$LOCAL",
@@ -107,7 +107,8 @@
107
107
  "resolve": "$$LOCAL",
108
108
  "semver": "$$LOCAL",
109
109
  "strip-ansi": "$$LOCAL",
110
- "yargs-parser": "$$LOCAL"
110
+ "yargs-parser": "$$LOCAL",
111
+ "pirates": "$$LOCAL"
111
112
  }
112
113
  }
113
114
  }