@modern-js/utils 2.22.0 → 2.22.1-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/cjs/cli/constants/index.js +4 -0
- package/dist/cjs/runtime-node/walk.js +1 -0
- package/dist/cjs/universal/constants.js +4 -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/esm/cli/constants/index.js +1 -0
- package/dist/esm/runtime-node/walk.js +0 -0
- package/dist/esm/universal/constants.js +1 -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/cli/constants/index.d.ts +4 -0
- package/dist/types/runtime-node/walk.d.ts +0 -0
- package/dist/types/universal/constants.d.ts +5 -1
- 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 +12 -3
@@ -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
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
|
@@ -0,0 +1,67 @@
|
|
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 getServerConfig_exports = {};
|
49
|
+
__export(getServerConfig_exports, {
|
50
|
+
getServerConfig: () => getServerConfig
|
51
|
+
});
|
52
|
+
module.exports = __toCommonJS(getServerConfig_exports);
|
53
|
+
var path = __toESM(require("path"));
|
54
|
+
var import_constants = require("./constants");
|
55
|
+
var import_findExists = require("./findExists");
|
56
|
+
const getServerConfig = (appDirectory, configFile) => __async(void 0, null, function* () {
|
57
|
+
const configFilePath = (0, import_findExists.findExists)(
|
58
|
+
import_constants.CONFIG_FILE_EXTENSIONS.map(
|
59
|
+
(extension) => path.resolve(appDirectory, `${configFile}${extension}`)
|
60
|
+
)
|
61
|
+
);
|
62
|
+
return configFilePath;
|
63
|
+
});
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
65
|
+
0 && (module.exports = {
|
66
|
+
getServerConfig
|
67
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getTargetDir: (from: string, baseDir: string, targetBaseDir: string) => string;
|
@@ -0,0 +1,41 @@
|
|
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 getTargetDir_exports = {};
|
29
|
+
__export(getTargetDir_exports, {
|
30
|
+
getTargetDir: () => getTargetDir
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(getTargetDir_exports);
|
33
|
+
var path = __toESM(require("path"));
|
34
|
+
const getTargetDir = (from, baseDir, targetBaseDir) => {
|
35
|
+
const relativePath = path.relative(baseDir, from);
|
36
|
+
return path.resolve(targetBaseDir, relativePath);
|
37
|
+
};
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
39
|
+
0 && (module.exports = {
|
40
|
+
getTargetDir
|
41
|
+
});
|
package/dist/import.d.ts
ADDED
package/dist/import.js
ADDED
@@ -0,0 +1,33 @@
|
|
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 import_exports = {};
|
19
|
+
__export(import_exports, {
|
20
|
+
Import: () => Import,
|
21
|
+
lazyImport: () => lazy
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(import_exports);
|
24
|
+
const lazy = (moduleName, requireFn) => {
|
25
|
+
const importLazyLocal = require("../compiled/import-lazy")(requireFn);
|
26
|
+
return importLazyLocal(moduleName);
|
27
|
+
};
|
28
|
+
const Import = { lazy };
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
30
|
+
0 && (module.exports = {
|
31
|
+
Import,
|
32
|
+
lazyImport
|
33
|
+
});
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
export * from './compiled';
|
2
|
+
export * from './commands';
|
3
|
+
export * from './FileSizeReporter';
|
4
|
+
export * from './printBuildError';
|
5
|
+
export * from './debug';
|
6
|
+
export * from './findExists';
|
7
|
+
export * from './is';
|
8
|
+
export * from './compatRequire';
|
9
|
+
export * from './logger';
|
10
|
+
export * from './constants';
|
11
|
+
export * from './ensureArray';
|
12
|
+
export * from './ensureAbsolutePath';
|
13
|
+
export * from './clearConsole';
|
14
|
+
export * from './applyOptionsChain';
|
15
|
+
export * from './getBrowserslist';
|
16
|
+
export * from './removeSlash';
|
17
|
+
export * from './getEntryOptions';
|
18
|
+
export * from './getPort';
|
19
|
+
export * from './monorepo';
|
20
|
+
export * from './getPackageManager';
|
21
|
+
export * from './runtimeExports';
|
22
|
+
export * from './readTsConfig';
|
23
|
+
export * from './path';
|
24
|
+
export * from './pathSerializer';
|
25
|
+
export * from './generateMetaTags';
|
26
|
+
export * from './prettyInstructions';
|
27
|
+
export * from './alias';
|
28
|
+
export * from './import';
|
29
|
+
export * from './watch';
|
30
|
+
export * from './nodeEnv';
|
31
|
+
export * from './wait';
|
32
|
+
export * from './emptyDir';
|
33
|
+
export * from './getServerConfig';
|
34
|
+
export * from './resolve';
|
35
|
+
export * from './analyzeProject';
|
36
|
+
export * from './chainId';
|
37
|
+
export * from './version';
|
38
|
+
export * from './plugin';
|
39
|
+
export * from './routes';
|
40
|
+
export * from './testUtils';
|
41
|
+
export * from './getCoreJsVersion';
|
42
|
+
export * from './react';
|
43
|
+
export * from './getTargetDir';
|
44
|
+
export * from './babel';
|
package/dist/index.js
ADDED
@@ -0,0 +1,60 @@
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var src_exports = {};
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
17
|
+
__reExport(src_exports, require("./compiled"), module.exports);
|
18
|
+
__reExport(src_exports, require("./commands"), module.exports);
|
19
|
+
__reExport(src_exports, require("./FileSizeReporter"), module.exports);
|
20
|
+
__reExport(src_exports, require("./printBuildError"), module.exports);
|
21
|
+
__reExport(src_exports, require("./debug"), module.exports);
|
22
|
+
__reExport(src_exports, require("./findExists"), module.exports);
|
23
|
+
__reExport(src_exports, require("./is"), module.exports);
|
24
|
+
__reExport(src_exports, require("./compatRequire"), module.exports);
|
25
|
+
__reExport(src_exports, require("./logger"), module.exports);
|
26
|
+
__reExport(src_exports, require("./constants"), module.exports);
|
27
|
+
__reExport(src_exports, require("./ensureArray"), module.exports);
|
28
|
+
__reExport(src_exports, require("./ensureAbsolutePath"), module.exports);
|
29
|
+
__reExport(src_exports, require("./clearConsole"), module.exports);
|
30
|
+
__reExport(src_exports, require("./applyOptionsChain"), module.exports);
|
31
|
+
__reExport(src_exports, require("./getBrowserslist"), module.exports);
|
32
|
+
__reExport(src_exports, require("./removeSlash"), module.exports);
|
33
|
+
__reExport(src_exports, require("./getEntryOptions"), module.exports);
|
34
|
+
__reExport(src_exports, require("./getPort"), module.exports);
|
35
|
+
__reExport(src_exports, require("./monorepo"), module.exports);
|
36
|
+
__reExport(src_exports, require("./getPackageManager"), module.exports);
|
37
|
+
__reExport(src_exports, require("./runtimeExports"), module.exports);
|
38
|
+
__reExport(src_exports, require("./readTsConfig"), module.exports);
|
39
|
+
__reExport(src_exports, require("./path"), module.exports);
|
40
|
+
__reExport(src_exports, require("./pathSerializer"), module.exports);
|
41
|
+
__reExport(src_exports, require("./generateMetaTags"), module.exports);
|
42
|
+
__reExport(src_exports, require("./prettyInstructions"), module.exports);
|
43
|
+
__reExport(src_exports, require("./alias"), module.exports);
|
44
|
+
__reExport(src_exports, require("./import"), module.exports);
|
45
|
+
__reExport(src_exports, require("./watch"), module.exports);
|
46
|
+
__reExport(src_exports, require("./nodeEnv"), module.exports);
|
47
|
+
__reExport(src_exports, require("./wait"), module.exports);
|
48
|
+
__reExport(src_exports, require("./emptyDir"), module.exports);
|
49
|
+
__reExport(src_exports, require("./getServerConfig"), module.exports);
|
50
|
+
__reExport(src_exports, require("./resolve"), module.exports);
|
51
|
+
__reExport(src_exports, require("./analyzeProject"), module.exports);
|
52
|
+
__reExport(src_exports, require("./chainId"), module.exports);
|
53
|
+
__reExport(src_exports, require("./version"), module.exports);
|
54
|
+
__reExport(src_exports, require("./plugin"), module.exports);
|
55
|
+
__reExport(src_exports, require("./routes"), module.exports);
|
56
|
+
__reExport(src_exports, require("./testUtils"), module.exports);
|
57
|
+
__reExport(src_exports, require("./getCoreJsVersion"), module.exports);
|
58
|
+
__reExport(src_exports, require("./react"), module.exports);
|
59
|
+
__reExport(src_exports, require("./getTargetDir"), module.exports);
|
60
|
+
__reExport(src_exports, require("./babel"), module.exports);
|