@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.
- package/CHANGELOG.md +14 -0
- package/dist/FileSizeReporter.d.ts +5 -5
- package/dist/FileSizeReporter.js +143 -136
- package/dist/alias.d.ts +14 -12
- package/dist/alias.js +94 -54
- package/dist/analyzeProject.d.ts +1 -1
- package/dist/analyzeProject.js +58 -33
- package/dist/applyOptionsChain.d.ts +1 -1
- package/dist/applyOptionsChain.js +55 -27
- package/dist/chainId.d.ts +256 -184
- package/dist/chainId.js +132 -187
- package/dist/clearConsole.d.ts +1 -1
- package/dist/clearConsole.js +29 -7
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +33 -10
- package/dist/compatRequire.d.ts +3 -3
- package/dist/compatRequire.js +74 -38
- package/dist/compiled.d.ts +2 -1
- package/dist/compiled.js +137 -72
- package/dist/constants.d.ts +131 -105
- package/dist/constants.js +298 -277
- package/dist/debug.d.ts +1 -1
- package/dist/debug.js +28 -11
- package/dist/emptyDir.d.ts +1 -1
- package/dist/emptyDir.js +51 -9
- package/dist/ensureAbsolutePath.d.ts +1 -1
- package/dist/ensureAbsolutePath.js +33 -14
- package/dist/ensureArray.d.ts +1 -1
- package/dist/ensureArray.js +30 -8
- package/dist/findExists.d.ts +1 -1
- package/dist/findExists.js +37 -17
- package/dist/format.d.ts +3 -3
- package/dist/format.js +93 -81
- package/dist/generateMetaTags.d.ts +3 -3
- package/dist/generateMetaTags.js +56 -43
- package/dist/getBrowserslist.d.ts +1 -1
- package/dist/getBrowserslist.js +31 -7
- package/dist/getCoreJsVersion.d.ts +1 -1
- package/dist/getCoreJsVersion.js +39 -35
- package/dist/getEntryOptions.d.ts +1 -1
- package/dist/getEntryOptions.js +51 -24
- package/dist/getPackageManager.d.ts +1 -1
- package/dist/getPackageManager.js +75 -28
- package/dist/getPort.d.ts +7 -4
- package/dist/getPort.js +104 -58
- package/dist/getServerConfig.d.ts +1 -1
- package/dist/getServerConfig.js +61 -32
- package/dist/import.d.ts +2 -2
- package/dist/import.js +31 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +59 -59
- package/dist/is/index.d.ts +12 -1
- package/dist/is/index.js +83 -82
- package/dist/is/node-env.d.ts +1 -1
- package/dist/is/node-env.js +39 -17
- package/dist/is/platform.d.ts +1 -1
- package/dist/is/platform.js +30 -10
- package/dist/is/type.d.ts +1 -1
- package/dist/is/type.js +48 -22
- package/dist/logger.d.ts +48 -48
- package/dist/logger.js +127 -95
- package/dist/monorepo.d.ts +3 -3
- package/dist/monorepo.js +117 -74
- package/dist/nodeEnv.d.ts +1 -1
- package/dist/nodeEnv.js +72 -25
- package/dist/path.d.ts +3 -1
- package/dist/path.js +76 -59
- package/dist/pathSerializer.d.ts +6 -6
- package/dist/pathSerializer.js +65 -43
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +45 -26
- package/dist/prettyInstructions.d.ts +4 -4
- package/dist/prettyInstructions.js +107 -65
- package/dist/printBuildError.d.ts +1 -1
- package/dist/printBuildError.js +54 -40
- package/dist/react.d.ts +1 -1
- package/dist/react.js +57 -21
- package/dist/readTsConfig.d.ts +1 -1
- package/dist/readTsConfig.js +38 -12
- package/dist/removeSlash.d.ts +1 -1
- package/dist/removeSlash.js +33 -9
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +49 -22
- package/dist/runtimeExports.d.ts +3 -3
- package/dist/runtimeExports.js +59 -39
- package/dist/ssr.d.ts +2 -1
- package/dist/ssr.js +30 -7
- package/dist/storage.d.ts +3 -3
- package/dist/storage.js +65 -59
- package/dist/test-utils.d.ts +1 -1
- package/dist/test-utils.js +30 -24
- package/dist/tryResolve.d.ts +2 -1
- package/dist/tryResolve.js +45 -33
- package/dist/types.d.ts +1 -1
- package/dist/types.js +15 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +83 -24
- package/dist/wait.d.ts +1 -1
- package/dist/wait.js +28 -6
- package/dist/watch.d.ts +3 -3
- package/dist/watch.js +82 -55
- package/package.json +7 -8
package/dist/runtimeExports.js
CHANGED
@@ -1,49 +1,69 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
47
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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 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
|
-
|
3
|
-
|
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
|
-
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
60
|
-
return
|
61
|
-
|
62
|
-
|
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
|
-
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
69
|
+
0 && (module.exports = {
|
70
|
+
createStorage
|
71
|
+
});
|
package/dist/test-utils.d.ts
CHANGED
package/dist/test-utils.js
CHANGED
@@ -1,26 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
30
|
+
0 && (module.exports = {
|
31
|
+
initSnapshotSerializer
|
32
|
+
});
|
package/dist/tryResolve.d.ts
CHANGED
@@ -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
|
-
|
11
|
+
|
12
|
+
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
package/dist/tryResolve.js
CHANGED
@@ -1,38 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
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
|
-
|
2
|
-
var
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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;
|