@modern-js/utils 2.22.0 → 2.22.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FileSizeReporter.d.ts +16 -0
- package/dist/FileSizeReporter.js +162 -0
- package/dist/alias.d.ts +25 -0
- package/dist/alias.js +108 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeProject.js +71 -0
- package/dist/applyOptionsChain.d.ts +3 -0
- package/dist/applyOptionsChain.js +58 -0
- package/dist/babel.d.ts +3 -0
- package/dist/babel.js +136 -0
- package/dist/chainId.d.ts +244 -0
- package/dist/chainId.js +196 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +31 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +48 -0
- package/dist/compatRequire.d.ts +13 -0
- package/dist/compatRequire.js +82 -0
- package/dist/compiled.d.ts +43 -0
- package/dist/compiled.js +142 -0
- package/dist/constants.d.ts +244 -0
- package/dist/constants.js +320 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.js +28 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +52 -0
- package/dist/ensureAbsolutePath.d.ts +7 -0
- package/dist/ensureAbsolutePath.js +38 -0
- package/dist/ensureArray.d.ts +1 -0
- package/dist/ensureArray.js +32 -0
- package/dist/findExists.d.ts +6 -0
- package/dist/findExists.js +45 -0
- package/dist/generateMetaTags.d.ts +16 -0
- package/dist/generateMetaTags.js +61 -0
- package/dist/getBrowserslist.d.ts +2 -0
- package/dist/getBrowserslist.js +31 -0
- package/dist/getCoreJsVersion.d.ts +1 -0
- package/dist/getCoreJsVersion.js +46 -0
- package/dist/getEntryOptions.d.ts +1 -0
- package/dist/getEntryOptions.js +54 -0
- package/dist/getPackageManager.d.ts +1 -0
- package/dist/getPackageManager.js +87 -0
- package/dist/getPort.d.ts +14 -0
- package/dist/getPort.js +112 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +67 -0
- package/dist/getTargetDir.d.ts +1 -0
- package/dist/getTargetDir.js +41 -0
- package/dist/import.d.ts +5 -0
- package/dist/import.js +33 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +60 -0
- package/dist/is/index.d.ts +58 -0
- package/dist/is/index.js +114 -0
- package/dist/is/nodeEnv.d.ts +8 -0
- package/dist/is/nodeEnv.js +39 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +30 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +64 -0
- package/dist/logger.d.ts +65 -0
- package/dist/logger.js +145 -0
- package/dist/monorepo.d.ts +11 -0
- package/dist/monorepo.js +137 -0
- package/dist/nodeEnv.d.ts +3 -0
- package/dist/nodeEnv.js +81 -0
- package/dist/path.d.ts +18 -0
- package/dist/path.js +92 -0
- package/dist/pathSerializer.d.ts +16 -0
- package/dist/pathSerializer.js +76 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +46 -0
- package/dist/prettyInstructions.d.ts +9 -0
- package/dist/prettyInstructions.js +112 -0
- package/dist/printBuildError.d.ts +8 -0
- package/dist/printBuildError.js +57 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +64 -0
- package/dist/readTsConfig.d.ts +2 -0
- package/dist/readTsConfig.js +47 -0
- package/dist/removeSlash.d.ts +3 -0
- package/dist/removeSlash.js +33 -0
- package/dist/resolve.d.ts +13 -0
- package/dist/resolve.js +63 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +58 -0
- package/dist/runtimeExports.d.ts +4 -0
- package/dist/runtimeExports.js +73 -0
- package/dist/ssr.d.ts +8 -0
- package/dist/ssr.js +30 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +75 -0
- package/dist/testUtils.d.ts +5 -0
- package/dist/testUtils.js +38 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +15 -0
- package/dist/universal/constants.d.ts +9 -0
- package/dist/universal/constants.js +30 -0
- package/dist/universal/formatWebpack.d.ts +13 -0
- package/dist/universal/formatWebpack.js +100 -0
- package/dist/universal/nestedRoutes.d.ts +8 -0
- package/dist/universal/nestedRoutes.js +131 -0
- package/dist/universal/remixRouter.d.ts +1 -0
- package/dist/universal/remixRouter.js +17 -0
- package/dist/universal/serialize.d.ts +1 -0
- package/dist/universal/serialize.js +40 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +92 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +29 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +90 -0
- package/package.json +3 -3
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create debug function with unified namespace prefix.
|
|
3
|
+
* @param scope - Custom module name of your debug function.
|
|
4
|
+
* @returns Debug function which namespace start with modern-js:.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createDebugger: (scope: string) => import("../compiled/debug").Debugger;
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 debug_exports = {};
|
|
19
|
+
__export(debug_exports, {
|
|
20
|
+
createDebugger: () => createDebugger
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(debug_exports);
|
|
23
|
+
var import_debug = require("../compiled/debug");
|
|
24
|
+
const createDebugger = (scope) => (0, import_debug.debug)(`modern-js:${scope}`);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
createDebugger
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const emptyDir: (dir: string) => Promise<void>;
|
package/dist/emptyDir.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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 __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var emptyDir_exports = {};
|
|
39
|
+
__export(emptyDir_exports, {
|
|
40
|
+
emptyDir: () => emptyDir
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(emptyDir_exports);
|
|
43
|
+
var import_compiled = require("./compiled");
|
|
44
|
+
const emptyDir = (dir) => __async(void 0, null, function* () {
|
|
45
|
+
if (yield import_compiled.fs.pathExists(dir)) {
|
|
46
|
+
yield import_compiled.fs.emptyDir(dir);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
emptyDir
|
|
52
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ensure absolute file path.
|
|
3
|
+
* @param base - Base path to resolve relative from.
|
|
4
|
+
* @param filePath - Absolute or relative file path.
|
|
5
|
+
* @returns Resolved absolute file path.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
|
@@ -0,0 +1,38 @@
|
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var ensureAbsolutePath_exports = {};
|
|
29
|
+
__export(ensureAbsolutePath_exports, {
|
|
30
|
+
ensureAbsolutePath: () => ensureAbsolutePath
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(ensureAbsolutePath_exports);
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
const ensureAbsolutePath = (base, filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.resolve(base, filePath);
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
ensureAbsolutePath
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ensureArray: <T>(params: T | T[]) => T[];
|
|
@@ -0,0 +1,32 @@
|
|
|
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 ensureArray_exports = {};
|
|
19
|
+
__export(ensureArray_exports, {
|
|
20
|
+
ensureArray: () => ensureArray
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(ensureArray_exports);
|
|
23
|
+
const ensureArray = (params) => {
|
|
24
|
+
if (Array.isArray(params)) {
|
|
25
|
+
return params;
|
|
26
|
+
}
|
|
27
|
+
return [params];
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
ensureArray
|
|
32
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var findExists_exports = {};
|
|
29
|
+
__export(findExists_exports, {
|
|
30
|
+
findExists: () => findExists
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(findExists_exports);
|
|
33
|
+
var import_fs = __toESM(require("fs"));
|
|
34
|
+
const findExists = (files) => {
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
if (import_fs.default.existsSync(file) && import_fs.default.statSync(file).isFile()) {
|
|
37
|
+
return file;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
findExists
|
|
45
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright JS Foundation and other contributors.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file at
|
|
6
|
+
* https://github.com/jantimon/html-webpack-plugin/blob/main/LICENSE
|
|
7
|
+
*
|
|
8
|
+
* Modified from https://github.com/jantimon/html-webpack-plugin/blob/2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4/index.js#L800
|
|
9
|
+
*/
|
|
10
|
+
export type MetaAttributes = {
|
|
11
|
+
[attributeName: string]: string | boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface MetaOptions {
|
|
14
|
+
[name: string]: string | false | MetaAttributes;
|
|
15
|
+
}
|
|
16
|
+
export declare const generateMetaTags: (metaOptions?: MetaOptions) => string;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 generateMetaTags_exports = {};
|
|
19
|
+
__export(generateMetaTags_exports, {
|
|
20
|
+
generateMetaTags: () => generateMetaTags
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(generateMetaTags_exports);
|
|
23
|
+
const tagObjectToString = (tagDefinition) => {
|
|
24
|
+
const attributes = Object.keys(tagDefinition.attributes || {}).filter((attributeName) => tagDefinition.attributes[attributeName] !== false).map((attributeName) => {
|
|
25
|
+
if (tagDefinition.attributes[attributeName] === true) {
|
|
26
|
+
return attributeName;
|
|
27
|
+
}
|
|
28
|
+
return `${attributeName}="${tagDefinition.attributes[attributeName]}"`;
|
|
29
|
+
});
|
|
30
|
+
return `<${[tagDefinition.tagName].concat(attributes).join(" ")}>${tagDefinition.innerHTML || ""}${tagDefinition.voidTag ? "" : `</${tagDefinition.tagName}>`}`;
|
|
31
|
+
};
|
|
32
|
+
const generateMetaTags = (metaOptions) => {
|
|
33
|
+
if (!metaOptions) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
const metaTagAttributeObjects = Object.keys(metaOptions).map((metaName) => {
|
|
37
|
+
const metaTagContent = metaOptions[metaName];
|
|
38
|
+
return typeof metaTagContent === "string" ? {
|
|
39
|
+
name: metaName,
|
|
40
|
+
content: metaTagContent
|
|
41
|
+
} : metaTagContent;
|
|
42
|
+
}).filter((attribute) => attribute !== false);
|
|
43
|
+
return metaTagAttributeObjects.map((metaTagAttributes) => {
|
|
44
|
+
if (metaTagAttributes === false) {
|
|
45
|
+
throw new Error("Invalid meta tag");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
tagName: "meta",
|
|
49
|
+
voidTag: true,
|
|
50
|
+
attributes: metaTagAttributes
|
|
51
|
+
};
|
|
52
|
+
}).reduce(
|
|
53
|
+
(memo, tagObject) => `${memo}
|
|
54
|
+
${tagObjectToString(tagObject)}`,
|
|
55
|
+
""
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
generateMetaTags
|
|
61
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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 getBrowserslist_exports = {};
|
|
19
|
+
__export(getBrowserslist_exports, {
|
|
20
|
+
defaults: () => defaults,
|
|
21
|
+
getBrowserslist: () => getBrowserslist
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getBrowserslist_exports);
|
|
24
|
+
var import_compiled = require("./compiled");
|
|
25
|
+
const defaults = ["> 0.01%", "not dead", "not op_mini all"];
|
|
26
|
+
const getBrowserslist = (appDirectory) => import_compiled.browserslist.loadConfig({ path: appDirectory }) || defaults;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
defaults,
|
|
30
|
+
getBrowserslist
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var getCoreJsVersion_exports = {};
|
|
29
|
+
__export(getCoreJsVersion_exports, {
|
|
30
|
+
getCoreJsVersion: () => getCoreJsVersion
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(getCoreJsVersion_exports);
|
|
33
|
+
var fs = __toESM(require("../compiled/fs-extra"));
|
|
34
|
+
const getCoreJsVersion = (corejsPkgPath) => {
|
|
35
|
+
try {
|
|
36
|
+
const { version } = fs.readJSONSync(corejsPkgPath);
|
|
37
|
+
const [major, minor] = version.split(".");
|
|
38
|
+
return `${major}.${minor}`;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return "3";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
getCoreJsVersion
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var getEntryOptions_exports = {};
|
|
33
|
+
__export(getEntryOptions_exports, {
|
|
34
|
+
getEntryOptions: () => getEntryOptions
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(getEntryOptions_exports);
|
|
37
|
+
var import_is = require("./is");
|
|
38
|
+
var import_constants = require("./constants");
|
|
39
|
+
const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
|
40
|
+
if (optionsByEntries) {
|
|
41
|
+
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
|
42
|
+
if (optionsByEntry === void 0 && name === import_constants.MAIN_ENTRY_NAME && packageName) {
|
|
43
|
+
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
|
44
|
+
}
|
|
45
|
+
return optionsByEntry !== void 0 ? (0, import_is.isPlainObject)(optionsByEntry) && (0, import_is.isPlainObject)(baseOptions) ? __spreadValues(__spreadValues({}, baseOptions), optionsByEntry) : optionsByEntry : baseOptions;
|
|
46
|
+
} else {
|
|
47
|
+
return baseOptions;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
getEntryOptions
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;
|
|
@@ -0,0 +1,87 @@
|
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var getPackageManager_exports = {};
|
|
49
|
+
__export(getPackageManager_exports, {
|
|
50
|
+
getPackageManager: () => getPackageManager
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(getPackageManager_exports);
|
|
53
|
+
var import_os = __toESM(require("os"));
|
|
54
|
+
var import_path = __toESM(require("path"));
|
|
55
|
+
var import_compiled = require("./compiled");
|
|
56
|
+
var import_nodeEnv = require("./nodeEnv");
|
|
57
|
+
const MAX_TIMES = 5;
|
|
58
|
+
function getPackageManager() {
|
|
59
|
+
return __async(this, arguments, function* (cwd = process.cwd()) {
|
|
60
|
+
let appDirectory = cwd;
|
|
61
|
+
let times = 0;
|
|
62
|
+
while (import_os.default.homedir() !== appDirectory && times < MAX_TIMES) {
|
|
63
|
+
times++;
|
|
64
|
+
if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "pnpm-lock.yaml"))) {
|
|
65
|
+
return "pnpm";
|
|
66
|
+
}
|
|
67
|
+
if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "yarn.lock"))) {
|
|
68
|
+
return "yarn";
|
|
69
|
+
}
|
|
70
|
+
if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "package-lock.json"))) {
|
|
71
|
+
return "npm";
|
|
72
|
+
}
|
|
73
|
+
appDirectory = import_path.default.join(appDirectory, "..");
|
|
74
|
+
}
|
|
75
|
+
if (yield (0, import_nodeEnv.canUsePnpm)()) {
|
|
76
|
+
return "pnpm";
|
|
77
|
+
}
|
|
78
|
+
if (yield (0, import_nodeEnv.canUseYarn)()) {
|
|
79
|
+
return "yarn";
|
|
80
|
+
}
|
|
81
|
+
return "npm";
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
getPackageManager
|
|
87
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get available free port.
|
|
3
|
+
* @param port - Current port want to use.
|
|
4
|
+
* @param tryLimits - Maximum number of retries.
|
|
5
|
+
* @param strictPort - Whether to throw an error when the port is occupied.
|
|
6
|
+
* @returns Available port number.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPort: (port: string | number, {
|
|
9
|
+
tryLimits,
|
|
10
|
+
strictPort
|
|
11
|
+
}?: {
|
|
12
|
+
tryLimits?: number | undefined;
|
|
13
|
+
strictPort?: boolean | undefined;
|
|
14
|
+
}) => Promise<number>;
|
package/dist/getPort.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var getPort_exports = {};
|
|
49
|
+
__export(getPort_exports, {
|
|
50
|
+
getPort: () => getPort
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(getPort_exports);
|
|
53
|
+
var import_net = __toESM(require("net"));
|
|
54
|
+
var import_compiled = require("./compiled");
|
|
55
|
+
var import_logger = require("./logger");
|
|
56
|
+
const getPort = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (port, {
|
|
57
|
+
tryLimits = 20,
|
|
58
|
+
strictPort = false
|
|
59
|
+
} = {}) {
|
|
60
|
+
if (typeof port === "string") {
|
|
61
|
+
port = parseInt(port, 10);
|
|
62
|
+
}
|
|
63
|
+
if (strictPort) {
|
|
64
|
+
tryLimits = 1;
|
|
65
|
+
}
|
|
66
|
+
const original = port;
|
|
67
|
+
let found = false;
|
|
68
|
+
let attempts = 0;
|
|
69
|
+
while (!found && attempts <= tryLimits) {
|
|
70
|
+
try {
|
|
71
|
+
yield new Promise((resolve, reject) => {
|
|
72
|
+
const server = import_net.default.createServer();
|
|
73
|
+
server.unref();
|
|
74
|
+
server.on("error", reject);
|
|
75
|
+
server.listen(
|
|
76
|
+
{
|
|
77
|
+
port,
|
|
78
|
+
host: "0.0.0.0"
|
|
79
|
+
},
|
|
80
|
+
() => {
|
|
81
|
+
found = true;
|
|
82
|
+
server.close(resolve);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
if (e.code !== "EADDRINUSE") {
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
port++;
|
|
91
|
+
attempts++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (port !== original) {
|
|
95
|
+
if (strictPort) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Port "${original}" is occupied, please choose another one.`
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
import_logger.logger.info(
|
|
101
|
+
`Something is already running on port ${original}. ${import_compiled.chalk.yellow(
|
|
102
|
+
`Use port ${port} instead.`
|
|
103
|
+
)}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return port;
|
|
108
|
+
});
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
getPort
|
|
112
|
+
});
|