@modern-js/utils 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/FileSizeReporter.d.ts +5 -5
  3. package/dist/FileSizeReporter.js +143 -136
  4. package/dist/alias.d.ts +14 -12
  5. package/dist/alias.js +94 -54
  6. package/dist/analyzeProject.d.ts +1 -1
  7. package/dist/analyzeProject.js +58 -33
  8. package/dist/applyOptionsChain.d.ts +1 -1
  9. package/dist/applyOptionsChain.js +55 -27
  10. package/dist/chainId.d.ts +256 -184
  11. package/dist/chainId.js +132 -187
  12. package/dist/clearConsole.d.ts +1 -1
  13. package/dist/clearConsole.js +29 -7
  14. package/dist/commands.d.ts +1 -1
  15. package/dist/commands.js +33 -10
  16. package/dist/compatRequire.d.ts +3 -3
  17. package/dist/compatRequire.js +74 -38
  18. package/dist/compiled.d.ts +2 -1
  19. package/dist/compiled.js +137 -72
  20. package/dist/constants.d.ts +131 -105
  21. package/dist/constants.js +298 -277
  22. package/dist/debug.d.ts +1 -1
  23. package/dist/debug.js +28 -11
  24. package/dist/emptyDir.d.ts +1 -1
  25. package/dist/emptyDir.js +51 -9
  26. package/dist/ensureAbsolutePath.d.ts +1 -1
  27. package/dist/ensureAbsolutePath.js +33 -14
  28. package/dist/ensureArray.d.ts +1 -1
  29. package/dist/ensureArray.js +30 -8
  30. package/dist/findExists.d.ts +1 -1
  31. package/dist/findExists.js +37 -17
  32. package/dist/format.d.ts +3 -3
  33. package/dist/format.js +93 -81
  34. package/dist/generateMetaTags.d.ts +3 -3
  35. package/dist/generateMetaTags.js +56 -43
  36. package/dist/getBrowserslist.d.ts +1 -1
  37. package/dist/getBrowserslist.js +31 -7
  38. package/dist/getCoreJsVersion.d.ts +1 -1
  39. package/dist/getCoreJsVersion.js +39 -35
  40. package/dist/getEntryOptions.d.ts +1 -1
  41. package/dist/getEntryOptions.js +51 -24
  42. package/dist/getPackageManager.d.ts +1 -1
  43. package/dist/getPackageManager.js +75 -28
  44. package/dist/getPort.d.ts +7 -4
  45. package/dist/getPort.js +104 -58
  46. package/dist/getServerConfig.d.ts +1 -1
  47. package/dist/getServerConfig.js +61 -32
  48. package/dist/import.d.ts +2 -2
  49. package/dist/import.js +31 -8
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +59 -59
  52. package/dist/is/index.d.ts +12 -1
  53. package/dist/is/index.js +83 -82
  54. package/dist/is/node-env.d.ts +1 -1
  55. package/dist/is/node-env.js +39 -17
  56. package/dist/is/platform.d.ts +1 -1
  57. package/dist/is/platform.js +30 -10
  58. package/dist/is/type.d.ts +1 -1
  59. package/dist/is/type.js +48 -22
  60. package/dist/logger.d.ts +48 -48
  61. package/dist/logger.js +127 -95
  62. package/dist/monorepo.d.ts +3 -3
  63. package/dist/monorepo.js +117 -74
  64. package/dist/nodeEnv.d.ts +1 -1
  65. package/dist/nodeEnv.js +72 -25
  66. package/dist/path.d.ts +3 -1
  67. package/dist/path.js +76 -59
  68. package/dist/pathSerializer.d.ts +6 -6
  69. package/dist/pathSerializer.js +65 -43
  70. package/dist/plugin.d.ts +1 -1
  71. package/dist/plugin.js +45 -26
  72. package/dist/prettyInstructions.d.ts +4 -4
  73. package/dist/prettyInstructions.js +107 -65
  74. package/dist/printBuildError.d.ts +1 -1
  75. package/dist/printBuildError.js +54 -40
  76. package/dist/react.d.ts +1 -1
  77. package/dist/react.js +57 -21
  78. package/dist/readTsConfig.d.ts +1 -1
  79. package/dist/readTsConfig.js +38 -12
  80. package/dist/removeSlash.d.ts +1 -1
  81. package/dist/removeSlash.js +33 -9
  82. package/dist/routes.d.ts +1 -1
  83. package/dist/routes.js +49 -22
  84. package/dist/runtimeExports.d.ts +3 -3
  85. package/dist/runtimeExports.js +59 -39
  86. package/dist/ssr.d.ts +2 -1
  87. package/dist/ssr.js +30 -7
  88. package/dist/storage.d.ts +3 -3
  89. package/dist/storage.js +65 -59
  90. package/dist/test-utils.d.ts +1 -1
  91. package/dist/test-utils.js +30 -24
  92. package/dist/tryResolve.d.ts +2 -1
  93. package/dist/tryResolve.js +45 -33
  94. package/dist/types.d.ts +1 -1
  95. package/dist/types.js +15 -2
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +83 -24
  98. package/dist/wait.d.ts +1 -1
  99. package/dist/wait.js +28 -6
  100. package/dist/watch.d.ts +3 -3
  101. package/dist/watch.js +82 -55
  102. package/package.json +7 -8
@@ -1,49 +1,69 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createRuntimeExportsUtils = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const compiled_1 = require("./compiled");
9
- const path_2 = require("./path");
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var runtimeExports_exports = {};
25
+ __export(runtimeExports_exports, {
26
+ createRuntimeExportsUtils: () => createRuntimeExportsUtils
27
+ });
28
+ module.exports = __toCommonJS(runtimeExports_exports);
29
+ var import_path = __toESM(require("path"));
30
+ var import_compiled = require("./compiled");
31
+ var import_path2 = require("./path");
10
32
  const memo = (fn) => {
11
- const cache = new Map();
12
- return (...params) => {
13
- const stringifiedParams = JSON.stringify(params);
14
- const cachedResult = cache.get(stringifiedParams);
15
- if (cachedResult) {
16
- return cachedResult;
17
- }
18
- const res = fn(...params);
19
- cache.set(stringifiedParams, res);
20
- return res;
21
- };
33
+ const cache = /* @__PURE__ */ new Map();
34
+ return (...params) => {
35
+ const stringifiedParams = JSON.stringify(params);
36
+ const cachedResult = cache.get(stringifiedParams);
37
+ if (cachedResult) {
38
+ return cachedResult;
39
+ }
40
+ const res = fn(...params);
41
+ cache.set(stringifiedParams, res);
42
+ return res;
43
+ };
22
44
  };
23
- exports.createRuntimeExportsUtils = memo((pwd = '', namespace = 'index') => {
24
- const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace}.js`);
25
- // const ensure = () => {
26
- // if (!fs.existsSync(entryExportFile)) {
27
- // fs.outputFileSync(entryExportFile, '');
28
- // }
29
- // fs.ensureFileSync(entryExportFile);
30
- // };
45
+ const createRuntimeExportsUtils = memo(
46
+ (pwd = "", namespace = "index") => {
47
+ const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
31
48
  const addExport = (statement) => {
32
- // eslint-disable-next-line no-param-reassign
33
- statement = (0, path_2.normalizeOutputPath)(statement);
34
- try {
35
- compiled_1.fs.ensureFileSync(entryExportFile);
36
- if (!compiled_1.fs.readFileSync(entryExportFile, 'utf8').includes(statement)) {
37
- compiled_1.fs.appendFileSync(entryExportFile, `${statement}\n`);
38
- }
39
- }
40
- catch {
41
- // FIXME:
49
+ statement = (0, import_path2.normalizeOutputPath)(statement);
50
+ try {
51
+ import_compiled.fs.ensureFileSync(entryExportFile);
52
+ if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
53
+ import_compiled.fs.appendFileSync(entryExportFile, `${statement}
54
+ `);
42
55
  }
56
+ } catch (e) {
57
+ }
43
58
  };
44
59
  const getPath = () => entryExportFile;
45
60
  return {
46
- addExport,
47
- getPath,
61
+ addExport,
62
+ getPath
48
63
  };
64
+ }
65
+ );
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ createRuntimeExportsUtils
49
69
  });
package/dist/ssr.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
+
2
3
  /**
3
4
  * ssr helpers
4
5
  */
5
6
  import type { IncomingHttpHeaders } from 'http';
6
7
  declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
7
- export { run, useHeaders };
8
+ export { run, useHeaders };
package/dist/ssr.js CHANGED
@@ -1,7 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useHeaders = exports.run = void 0;
4
- const storage_1 = require("./storage");
5
- const { run, useContext: useHeaders } = (0, storage_1.createStorage)();
6
- exports.run = run;
7
- exports.useHeaders = useHeaders;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ssr_exports = {};
19
+ __export(ssr_exports, {
20
+ run: () => run,
21
+ useHeaders: () => useHeaders
22
+ });
23
+ module.exports = __toCommonJS(ssr_exports);
24
+ var import_storage = require("./storage");
25
+ const { run, useContext: useHeaders } = (0, import_storage.createStorage)();
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ run,
29
+ useHeaders
30
+ });
package/dist/storage.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare const createStorage: <T>() => {
2
- run: <O>(context: T, cb: () => O | Promise<O>) => Promise<O>;
3
- useContext: () => T;
2
+ run: <O>(context: T, cb: () => O | Promise<O>) => Promise<O>;
3
+ useContext: () => T;
4
4
  };
5
- export { createStorage };
5
+ export { createStorage };
package/dist/storage.js CHANGED
@@ -1,65 +1,71 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
24
18
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createStorage = void 0;
27
- const ah = __importStar(require("async_hooks"));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var storage_exports = {};
25
+ __export(storage_exports, {
26
+ createStorage: () => createStorage
27
+ });
28
+ module.exports = __toCommonJS(storage_exports);
29
+ var ah = __toESM(require("async_hooks"));
28
30
  const createStorage = () => {
29
- let storage;
30
- if (typeof ah.AsyncLocalStorage !== 'undefined') {
31
- storage = new ah.AsyncLocalStorage();
32
- }
33
- const run = (context, cb) => {
34
- if (!storage) {
35
- throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
31
+ let storage;
32
+ if (typeof ah.AsyncLocalStorage !== "undefined") {
33
+ storage = new ah.AsyncLocalStorage();
34
+ }
35
+ const run = (context, cb) => {
36
+ if (!storage) {
37
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
36
38
  `);
39
+ }
40
+ return new Promise((resolve, reject) => {
41
+ storage.run(context, () => {
42
+ try {
43
+ return resolve(cb());
44
+ } catch (error) {
45
+ return reject(error);
37
46
  }
38
- return new Promise((resolve, reject) => {
39
- storage.run(context, () => {
40
- try {
41
- return resolve(cb());
42
- }
43
- catch (error) {
44
- return reject(error);
45
- }
46
- });
47
- });
48
- };
49
- const useContext = () => {
50
- if (!storage) {
51
- throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
47
+ });
48
+ });
49
+ };
50
+ const useContext = () => {
51
+ if (!storage) {
52
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
52
53
  `);
53
- }
54
- const context = storage.getStore();
55
- if (!context) {
56
- throw new Error(`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`);
57
- }
58
- return context;
59
- };
60
- return {
61
- run,
62
- useContext,
63
- };
54
+ }
55
+ const context = storage.getStore();
56
+ if (!context) {
57
+ throw new Error(
58
+ `Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`
59
+ );
60
+ }
61
+ return context;
62
+ };
63
+ return {
64
+ run,
65
+ useContext
66
+ };
64
67
  };
65
- exports.createStorage = createStorage;
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ createStorage
71
+ });
@@ -2,4 +2,4 @@
2
2
  *
3
3
  * remove the path before "modern.js"
4
4
  */
5
- export declare const initSnapshotSerializer: (root: string) => void;
5
+ export declare const initSnapshotSerializer: (root: string) => void;
@@ -1,26 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initSnapshotSerializer = void 0;
4
- /**
5
- *
6
- * remove the path before "modern.js"
7
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var test_utils_exports = {};
19
+ __export(test_utils_exports, {
20
+ initSnapshotSerializer: () => initSnapshotSerializer
21
+ });
22
+ module.exports = __toCommonJS(test_utils_exports);
8
23
  const initSnapshotSerializer = (root) => {
9
- expect.addSnapshotSerializer({
10
- test: (val) => typeof val === 'string' &&
11
- (val.includes('modern.js') ||
12
- val.includes('node_modules') ||
13
- val.includes(root)),
14
- print: (val) =>
15
- // eslint-disable-next-line no-nested-ternary
16
- typeof val === 'string'
17
- ? // eslint-disable-next-line no-nested-ternary
18
- val.includes('node_modules')
19
- ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, '/')}"`
20
- : val.includes('modern.js')
21
- ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, '/')}"`
22
- : `"${val.replace(root, '').replace(/\\/g, '/')}"`
23
- : val,
24
- });
24
+ expect.addSnapshotSerializer({
25
+ test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
26
+ print: (val) => typeof val === "string" ? val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"` : val
27
+ });
25
28
  };
26
- exports.initSnapshotSerializer = initSnapshotSerializer;
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ initSnapshotSerializer
32
+ });
@@ -8,4 +8,5 @@ export declare const tryResolve: (name: string, resolvePath: string) => string;
8
8
  /**
9
9
  * Try to resolve npm package, return true if package is installed.
10
10
  */
11
- export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
11
+
12
+ export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
@@ -1,38 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPackageInstalled = exports.tryResolve = void 0;
4
- const ensureArray_1 = require("./ensureArray");
5
- /**
6
- * Try to resolve npm package entry file path.
7
- * @param name - Package name.
8
- * @param resolvePath - Path to resolve dependencies.
9
- * @returns Resolved file path.
10
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var tryResolve_exports = {};
19
+ __export(tryResolve_exports, {
20
+ isPackageInstalled: () => isPackageInstalled,
21
+ tryResolve: () => tryResolve
22
+ });
23
+ module.exports = __toCommonJS(tryResolve_exports);
24
+ var import_ensureArray = require("./ensureArray");
11
25
  const tryResolve = (name, resolvePath) => {
12
- let filePath = '';
13
- try {
14
- filePath = require.resolve(name, { paths: [resolvePath] });
15
- delete require.cache[filePath];
16
- }
17
- catch (err) {
18
- if (err.code === 'MODULE_NOT_FOUND') {
19
- throw new Error(`Can not find module ${name}.`);
20
- }
21
- throw err;
26
+ let filePath = "";
27
+ try {
28
+ filePath = require.resolve(name, { paths: [resolvePath] });
29
+ delete require.cache[filePath];
30
+ } catch (err) {
31
+ if (err.code === "MODULE_NOT_FOUND") {
32
+ throw new Error(`Can not find module ${name}.`);
22
33
  }
23
- return filePath;
34
+ throw err;
35
+ }
36
+ return filePath;
24
37
  };
25
- exports.tryResolve = tryResolve;
26
- /**
27
- * Try to resolve npm package, return true if package is installed.
28
- */
29
38
  const isPackageInstalled = (name, resolvePaths) => {
30
- try {
31
- require.resolve(name, { paths: (0, ensureArray_1.ensureArray)(resolvePaths) });
32
- return true;
33
- }
34
- catch (err) {
35
- return false;
36
- }
39
+ try {
40
+ require.resolve(name, { paths: (0, import_ensureArray.ensureArray)(resolvePaths) });
41
+ return true;
42
+ } catch (err) {
43
+ return false;
44
+ }
37
45
  };
38
- exports.isPackageInstalled = isPackageInstalled;
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ isPackageInstalled,
49
+ tryResolve
50
+ });
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export type Falsy = false | null | undefined | 0 | '';
1
+ export type Falsy = false | null | undefined | 0 | '';
package/dist/types.js CHANGED
@@ -1,2 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare function getPnpmVersion(): Promise<string>;
2
- export declare const isReact18: (cwd: string) => boolean;
2
+ export declare const isReact18: (cwd: string) => boolean;
package/dist/version.js CHANGED
@@ -1,29 +1,88 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
4
32
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isReact18 = exports.getPnpmVersion = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const compiled_1 = require("./compiled");
9
- async function getPnpmVersion() {
10
- const { stdout } = await (0, compiled_1.execa)('pnpm', ['--version']);
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var __async = (__this, __arguments, generator) => {
39
+ return new Promise((resolve, reject) => {
40
+ var fulfilled = (value) => {
41
+ try {
42
+ step(generator.next(value));
43
+ } catch (e) {
44
+ reject(e);
45
+ }
46
+ };
47
+ var rejected = (value) => {
48
+ try {
49
+ step(generator.throw(value));
50
+ } catch (e) {
51
+ reject(e);
52
+ }
53
+ };
54
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
55
+ step((generator = generator.apply(__this, __arguments)).next());
56
+ });
57
+ };
58
+ var version_exports = {};
59
+ __export(version_exports, {
60
+ getPnpmVersion: () => getPnpmVersion,
61
+ isReact18: () => isReact18
62
+ });
63
+ module.exports = __toCommonJS(version_exports);
64
+ var import_path = __toESM(require("path"));
65
+ var import_compiled = require("./compiled");
66
+ function getPnpmVersion() {
67
+ return __async(this, null, function* () {
68
+ const { stdout } = yield (0, import_compiled.execa)("pnpm", ["--version"]);
11
69
  return stdout;
70
+ });
12
71
  }
13
- exports.getPnpmVersion = getPnpmVersion;
14
72
  const isReact18 = (cwd) => {
15
- const pkgPath = path_1.default.join(cwd, 'package.json');
16
- if (!compiled_1.fs.existsSync(pkgPath)) {
17
- return false;
18
- }
19
- const pkgInfo = JSON.parse(compiled_1.fs.readFileSync(pkgPath, 'utf8'));
20
- const deps = {
21
- ...pkgInfo.devDependencies,
22
- ...pkgInfo.dependencies,
23
- };
24
- if (typeof deps.react !== 'string') {
25
- return false;
26
- }
27
- return compiled_1.semver.satisfies(compiled_1.semver.minVersion(deps.react), '>=18.0.0');
73
+ const pkgPath = import_path.default.join(cwd, "package.json");
74
+ if (!import_compiled.fs.existsSync(pkgPath)) {
75
+ return false;
76
+ }
77
+ const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
78
+ const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
79
+ if (typeof deps.react !== "string") {
80
+ return false;
81
+ }
82
+ return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
28
83
  };
29
- exports.isReact18 = isReact18;
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ getPnpmVersion,
87
+ isReact18
88
+ });
package/dist/wait.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  declare const wait: (time?: number) => Promise<unknown>;
2
- export { wait };
2
+ export { wait };
package/dist/wait.js CHANGED
@@ -1,7 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wait = void 0;
4
- const wait = (time = 0) => new Promise(resolve => {
5
- setTimeout(resolve, time);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var wait_exports = {};
19
+ __export(wait_exports, {
20
+ wait: () => wait
21
+ });
22
+ module.exports = __toCommonJS(wait_exports);
23
+ const wait = (time = 0) => new Promise((resolve) => {
24
+ setTimeout(resolve, time);
25
+ });
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ wait
6
29
  });
7
- exports.wait = wait;