@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
package/dist/nodeEnv.js
ADDED
@@ -0,0 +1,81 @@
|
|
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 nodeEnv_exports = {};
|
39
|
+
__export(nodeEnv_exports, {
|
40
|
+
canUseNpm: () => canUseNpm,
|
41
|
+
canUsePnpm: () => canUsePnpm,
|
42
|
+
canUseYarn: () => canUseYarn
|
43
|
+
});
|
44
|
+
module.exports = __toCommonJS(nodeEnv_exports);
|
45
|
+
var import_compiled = require("./compiled");
|
46
|
+
function canUseNpm() {
|
47
|
+
return __async(this, null, function* () {
|
48
|
+
try {
|
49
|
+
yield (0, import_compiled.execa)("npm", ["--version"], { env: process.env });
|
50
|
+
return true;
|
51
|
+
} catch (e) {
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
}
|
56
|
+
function canUseYarn() {
|
57
|
+
return __async(this, null, function* () {
|
58
|
+
try {
|
59
|
+
yield (0, import_compiled.execa)("yarn", ["--version"], { env: process.env });
|
60
|
+
return true;
|
61
|
+
} catch (e) {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
});
|
65
|
+
}
|
66
|
+
function canUsePnpm() {
|
67
|
+
return __async(this, null, function* () {
|
68
|
+
try {
|
69
|
+
yield (0, import_compiled.execa)("pnpm", ["--version"], { env: process.env });
|
70
|
+
return true;
|
71
|
+
} catch (e) {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
});
|
75
|
+
}
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
77
|
+
0 && (module.exports = {
|
78
|
+
canUseNpm,
|
79
|
+
canUsePnpm,
|
80
|
+
canUseYarn
|
81
|
+
});
|
package/dist/path.d.ts
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
import { lodash as _ } from './compiled';
|
2
|
+
export declare const isPathString: (test: string) => boolean;
|
3
|
+
export declare const isRelativePath: (test: string) => boolean;
|
4
|
+
export declare const normalizeOutputPath: (s: string) => string;
|
5
|
+
export declare const normalizeToPosixPath: (p: string | undefined) => string;
|
6
|
+
export declare const getTemplatePath: (prefix?: string) => string;
|
7
|
+
/**
|
8
|
+
* Compile path string to RegExp.
|
9
|
+
* @note Only support posix path.
|
10
|
+
*/
|
11
|
+
|
12
|
+
export declare function compilePathMatcherRegExp(match: string | RegExp): RegExp;
|
13
|
+
/** @internal @see {@link upwardPaths} */
|
14
|
+
|
15
|
+
export declare const _joinPathParts: (_part: unknown, i: number, parts: _.List<string>) => string;
|
16
|
+
export declare function upwardPaths(start: string): string[];
|
17
|
+
export declare function getRealTemporaryDirectory(): string | null;
|
18
|
+
export declare function splitPathString(str: string): string[];
|
package/dist/path.js
ADDED
@@ -0,0 +1,92 @@
|
|
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 path_exports = {};
|
29
|
+
__export(path_exports, {
|
30
|
+
_joinPathParts: () => _joinPathParts,
|
31
|
+
compilePathMatcherRegExp: () => compilePathMatcherRegExp,
|
32
|
+
getRealTemporaryDirectory: () => getRealTemporaryDirectory,
|
33
|
+
getTemplatePath: () => getTemplatePath,
|
34
|
+
isPathString: () => isPathString,
|
35
|
+
isRelativePath: () => isRelativePath,
|
36
|
+
normalizeOutputPath: () => normalizeOutputPath,
|
37
|
+
normalizeToPosixPath: () => normalizeToPosixPath,
|
38
|
+
splitPathString: () => splitPathString,
|
39
|
+
upwardPaths: () => upwardPaths
|
40
|
+
});
|
41
|
+
module.exports = __toCommonJS(path_exports);
|
42
|
+
var import_path = __toESM(require("path"));
|
43
|
+
var import_os = __toESM(require("os"));
|
44
|
+
var import_fs = __toESM(require("fs"));
|
45
|
+
var import_compiled = require("./compiled");
|
46
|
+
const isPathString = (test) => import_path.default.posix.basename(test) !== test || import_path.default.win32.basename(test) !== test;
|
47
|
+
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
48
|
+
const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
49
|
+
const normalizeToPosixPath = (p) => import_compiled.upath.normalizeSafe(import_path.default.normalize(p || "")).replace(/^([a-zA-Z]+):/, (_2, m) => `/${m.toLowerCase()}`);
|
50
|
+
const getTemplatePath = (prefix) => {
|
51
|
+
const tmpRoot = import_fs.default.realpathSync(import_os.default.tmpdir());
|
52
|
+
const parts = [tmpRoot];
|
53
|
+
prefix && parts.push(prefix);
|
54
|
+
parts.push((0, import_compiled.nanoid)());
|
55
|
+
return import_path.default.resolve(...parts);
|
56
|
+
};
|
57
|
+
function compilePathMatcherRegExp(match) {
|
58
|
+
if (typeof match !== "string") {
|
59
|
+
return match;
|
60
|
+
}
|
61
|
+
const escaped = import_compiled.lodash.escapeRegExp(match);
|
62
|
+
return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
|
63
|
+
}
|
64
|
+
const _joinPathParts = (_part, i, parts) => (0, import_compiled.lodash)(parts).filter((part) => !["/", "\\"].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
|
65
|
+
function upwardPaths(start) {
|
66
|
+
return (0, import_compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
|
67
|
+
}
|
68
|
+
function getRealTemporaryDirectory() {
|
69
|
+
let ret = null;
|
70
|
+
try {
|
71
|
+
ret = import_os.default.tmpdir();
|
72
|
+
ret = import_fs.default.realpathSync(ret);
|
73
|
+
} catch (e) {
|
74
|
+
}
|
75
|
+
return ret;
|
76
|
+
}
|
77
|
+
function splitPathString(str) {
|
78
|
+
return str.split(/[\\/]/);
|
79
|
+
}
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
81
|
+
0 && (module.exports = {
|
82
|
+
_joinPathParts,
|
83
|
+
compilePathMatcherRegExp,
|
84
|
+
getRealTemporaryDirectory,
|
85
|
+
getTemplatePath,
|
86
|
+
isPathString,
|
87
|
+
isRelativePath,
|
88
|
+
normalizeOutputPath,
|
89
|
+
normalizeToPosixPath,
|
90
|
+
splitPathString,
|
91
|
+
upwardPaths
|
92
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/** Different from */
|
2
|
+
export type PathMatchExpression = string | RegExp;
|
3
|
+
export interface PathMatcher {
|
4
|
+
match: PathMatchExpression;
|
5
|
+
mark: string | ((substring: string, ...args: any[]) => string);
|
6
|
+
}
|
7
|
+
export declare const matchUpwardPathsAsUnknown: (p: string) => {
|
8
|
+
match: string;
|
9
|
+
mark: string;
|
10
|
+
}[];
|
11
|
+
export interface ApplyPathMatcherOptions {
|
12
|
+
minPartials?: number;
|
13
|
+
}
|
14
|
+
export declare function applyPathMatcher(matcher: PathMatcher, str: string, options?: ApplyPathMatcherOptions): string;
|
15
|
+
export declare function applyMatcherReplacement(matchers: PathMatcher[], str: string, options?: ApplyPathMatcherOptions): string;
|
16
|
+
export declare const createDefaultPathMatchers: (root: string) => PathMatcher[];
|
@@ -0,0 +1,76 @@
|
|
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 pathSerializer_exports = {};
|
29
|
+
__export(pathSerializer_exports, {
|
30
|
+
applyMatcherReplacement: () => applyMatcherReplacement,
|
31
|
+
applyPathMatcher: () => applyPathMatcher,
|
32
|
+
createDefaultPathMatchers: () => createDefaultPathMatchers,
|
33
|
+
matchUpwardPathsAsUnknown: () => matchUpwardPathsAsUnknown
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(pathSerializer_exports);
|
36
|
+
var import_os = __toESM(require("os"));
|
37
|
+
var import_lodash = __toESM(require("../compiled/lodash"));
|
38
|
+
var import_path = require("./path");
|
39
|
+
const matchUpwardPathsAsUnknown = (p) => (0, import_lodash.default)((0, import_path.upwardPaths)((0, import_path.normalizeToPosixPath)(p))).map((match) => ({ match, mark: "unknown" })).slice(1, -1).value();
|
40
|
+
function applyPathMatcher(matcher, str, options = {}) {
|
41
|
+
const regex = (0, import_path.compilePathMatcherRegExp)(matcher.match);
|
42
|
+
const replacer = (substring, ...args) => {
|
43
|
+
if (options.minPartials && (0, import_path.splitPathString)(substring).length < options.minPartials) {
|
44
|
+
return substring;
|
45
|
+
}
|
46
|
+
const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
|
47
|
+
return `<${import_lodash.default.snakeCase(ret).toUpperCase()}>`;
|
48
|
+
};
|
49
|
+
return str.replace(regex, replacer);
|
50
|
+
}
|
51
|
+
function applyMatcherReplacement(matchers, str, options = {}) {
|
52
|
+
return matchers.reduce((ret, matcher) => {
|
53
|
+
return applyPathMatcher(matcher, ret, options);
|
54
|
+
}, str);
|
55
|
+
}
|
56
|
+
const createDefaultPathMatchers = (root) => {
|
57
|
+
const ret = [
|
58
|
+
{
|
59
|
+
match: new RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
|
60
|
+
mark: "pnpmInner"
|
61
|
+
}
|
62
|
+
];
|
63
|
+
const tmpdir = (0, import_path.getRealTemporaryDirectory)();
|
64
|
+
tmpdir && ret.push({ match: tmpdir, mark: "temp" });
|
65
|
+
ret.push({ match: import_os.default.tmpdir(), mark: "temp" });
|
66
|
+
ret.push({ match: import_os.default.homedir(), mark: "home" });
|
67
|
+
ret.push(...matchUpwardPathsAsUnknown(root));
|
68
|
+
return ret;
|
69
|
+
};
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
71
|
+
0 && (module.exports = {
|
72
|
+
applyMatcherReplacement,
|
73
|
+
applyPathMatcher,
|
74
|
+
createDefaultPathMatchers,
|
75
|
+
matchUpwardPathsAsUnknown
|
76
|
+
});
|
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
@@ -0,0 +1,46 @@
|
|
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 plugin_exports = {};
|
19
|
+
__export(plugin_exports, {
|
20
|
+
getInternalPlugins: () => getInternalPlugins
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(plugin_exports);
|
23
|
+
var import_constants = require("./constants");
|
24
|
+
var import_is = require("./is");
|
25
|
+
function getInternalPlugins(appDirectory, internalPlugins = import_constants.INTERNAL_CLI_PLUGINS) {
|
26
|
+
return [
|
27
|
+
...Object.keys(internalPlugins).filter((name) => {
|
28
|
+
const config = internalPlugins[name];
|
29
|
+
if (typeof config !== "string" && config.forced === true) {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
return (0, import_is.isDepExists)(appDirectory, name);
|
33
|
+
}).map((name) => {
|
34
|
+
const config = internalPlugins[name];
|
35
|
+
if (typeof config !== "string") {
|
36
|
+
return config.path;
|
37
|
+
} else {
|
38
|
+
return config;
|
39
|
+
}
|
40
|
+
})
|
41
|
+
];
|
42
|
+
}
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
44
|
+
0 && (module.exports = {
|
45
|
+
getInternalPlugins
|
46
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import os from 'os';
|
3
|
+
export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
|
4
|
+
export type AddressUrl = {
|
5
|
+
label: string;
|
6
|
+
url: string;
|
7
|
+
};
|
8
|
+
export declare const getAddressUrls: (protocol: string | undefined, port: number) => AddressUrl[];
|
9
|
+
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
@@ -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 prettyInstructions_exports = {};
|
29
|
+
__export(prettyInstructions_exports, {
|
30
|
+
getAddressUrls: () => getAddressUrls,
|
31
|
+
getIpv4Interfaces: () => getIpv4Interfaces,
|
32
|
+
prettyInstructions: () => prettyInstructions
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(prettyInstructions_exports);
|
35
|
+
var import_os = __toESM(require("os"));
|
36
|
+
var import_compiled = require("./compiled");
|
37
|
+
var import_is = require("./is");
|
38
|
+
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
39
|
+
const getIpv4Interfaces = () => {
|
40
|
+
const interfaces = import_os.default.networkInterfaces();
|
41
|
+
const ipv4Interfaces = [];
|
42
|
+
Object.keys(interfaces).forEach((key) => {
|
43
|
+
interfaces[key].forEach((detail) => {
|
44
|
+
const familyV4Value = typeof detail.family === "string" ? "IPv4" : 4;
|
45
|
+
if (detail.family === familyV4Value) {
|
46
|
+
ipv4Interfaces.push(detail);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
return ipv4Interfaces;
|
51
|
+
};
|
52
|
+
const getAddressUrls = (protocol = "http", port) => {
|
53
|
+
const ipv4Interfaces = getIpv4Interfaces();
|
54
|
+
return ipv4Interfaces.reduce((memo, detail) => {
|
55
|
+
let label = "Network: ";
|
56
|
+
let url = `${protocol}://${detail.address}:${port}`;
|
57
|
+
if (detail.address.includes(`localhost`) || detail.internal) {
|
58
|
+
label = "Local: ";
|
59
|
+
url = `${protocol}://localhost:${port}`;
|
60
|
+
}
|
61
|
+
memo.push({ label, url });
|
62
|
+
return memo;
|
63
|
+
}, []);
|
64
|
+
};
|
65
|
+
const prettyInstructions = (appContext, config) => {
|
66
|
+
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
67
|
+
const urls = getAddressUrls(
|
68
|
+
config.dev.https && (0, import_is.isDev)() ? "https" : "http",
|
69
|
+
port
|
70
|
+
);
|
71
|
+
const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
|
72
|
+
let message = "App running at:\n\n";
|
73
|
+
if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
|
74
|
+
message += urls.map(
|
75
|
+
({ label, url }) => ` ${import_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
|
76
|
+
normalizeUrl(`${url}/${routes[0].urlPath}`)
|
77
|
+
)}
|
78
|
+
`
|
79
|
+
).join("");
|
80
|
+
} else {
|
81
|
+
const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
|
82
|
+
urls.forEach(({ label, url }) => {
|
83
|
+
message += ` ${import_compiled.chalk.bold(`> ${label}`)}
|
84
|
+
`;
|
85
|
+
routes.forEach(({ entryName, urlPath, isSSR }) => {
|
86
|
+
if (!checkedEntries.includes(entryName)) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
message += ` ${import_compiled.chalk.yellowBright(
|
90
|
+
isSSR ? "λ" : "○"
|
91
|
+
)} ${import_compiled.chalk.yellowBright(
|
92
|
+
entryName.padEnd(maxNameLength + 8)
|
93
|
+
)}${import_compiled.chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}
|
94
|
+
`;
|
95
|
+
});
|
96
|
+
});
|
97
|
+
message += "\n";
|
98
|
+
message += import_compiled.chalk.cyanBright(
|
99
|
+
" λ (Server) server-side renders at runtime\n"
|
100
|
+
);
|
101
|
+
message += import_compiled.chalk.cyanBright(
|
102
|
+
" ○ (Static) client-side renders as static HTML\n"
|
103
|
+
);
|
104
|
+
}
|
105
|
+
return message;
|
106
|
+
};
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
108
|
+
0 && (module.exports = {
|
109
|
+
getAddressUrls,
|
110
|
+
getIpv4Interfaces,
|
111
|
+
prettyInstructions
|
112
|
+
});
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file at
|
6
|
+
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
7
|
+
*/
|
8
|
+
export declare function printBuildError(err: Error): void;
|
@@ -0,0 +1,57 @@
|
|
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 printBuildError_exports = {};
|
19
|
+
__export(printBuildError_exports, {
|
20
|
+
printBuildError: () => printBuildError
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(printBuildError_exports);
|
23
|
+
var import_compiled = require("./compiled");
|
24
|
+
var import_logger = require("./logger");
|
25
|
+
function printBuildError(err) {
|
26
|
+
const message = err != null && err.message;
|
27
|
+
const stack = err != null && err.stack;
|
28
|
+
if (stack && typeof message === "string" && message.indexOf("from Terser") !== -1) {
|
29
|
+
try {
|
30
|
+
const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
|
31
|
+
if (!matched) {
|
32
|
+
throw new Error("Using errors for control flow is bad.");
|
33
|
+
}
|
34
|
+
const problemPath = matched[2];
|
35
|
+
const line = matched[3];
|
36
|
+
const column = matched[4];
|
37
|
+
import_logger.logger.error(
|
38
|
+
`Failed to minify the code from this file:
|
39
|
+
|
40
|
+
${import_compiled.chalk.yellow(
|
41
|
+
` ${problemPath}:${line}${column !== "0" ? ":" + column : ""}`
|
42
|
+
)}
|
43
|
+
`
|
44
|
+
);
|
45
|
+
} catch (ignored) {
|
46
|
+
import_logger.logger.error(`Failed to minify the bundle. ${err}
|
47
|
+
`);
|
48
|
+
}
|
49
|
+
} else {
|
50
|
+
import_logger.logger.error((message || err) + "\n");
|
51
|
+
}
|
52
|
+
import_logger.logger.log();
|
53
|
+
}
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
55
|
+
0 && (module.exports = {
|
56
|
+
printBuildError
|
57
|
+
});
|
package/dist/react.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isBeyondReact17: (cwd: string) => boolean;
|
package/dist/react.js
ADDED
@@ -0,0 +1,64 @@
|
|
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;
|
32
|
+
};
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
39
|
+
mod
|
40
|
+
));
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
42
|
+
var react_exports = {};
|
43
|
+
__export(react_exports, {
|
44
|
+
isBeyondReact17: () => isBeyondReact17
|
45
|
+
});
|
46
|
+
module.exports = __toCommonJS(react_exports);
|
47
|
+
var import_path = __toESM(require("path"));
|
48
|
+
var import__ = require(".");
|
49
|
+
const isBeyondReact17 = (cwd) => {
|
50
|
+
const pkgPath = import_path.default.join(cwd, "package.json");
|
51
|
+
if (!import__.fs.existsSync(pkgPath)) {
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
const pkgInfo = JSON.parse(import__.fs.readFileSync(pkgPath, "utf8"));
|
55
|
+
const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
|
56
|
+
if (typeof deps.react !== "string") {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
return import__.semver.satisfies(import__.semver.minVersion(deps.react), ">=17.0.0");
|
60
|
+
};
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
62
|
+
0 && (module.exports = {
|
63
|
+
isBeyondReact17
|
64
|
+
});
|
@@ -0,0 +1,47 @@
|
|
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 readTsConfig_exports = {};
|
29
|
+
__export(readTsConfig_exports, {
|
30
|
+
readTsConfig: () => readTsConfig,
|
31
|
+
readTsConfigByFile: () => readTsConfigByFile
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(readTsConfig_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_compiled = require("./compiled");
|
36
|
+
const readTsConfig = (root) => {
|
37
|
+
return readTsConfigByFile(import_path.default.resolve(root, "./tsconfig.json"));
|
38
|
+
};
|
39
|
+
const readTsConfigByFile = (filename) => {
|
40
|
+
const content = import_compiled.fs.readFileSync(import_path.default.resolve(filename), "utf-8");
|
41
|
+
return import_compiled.json5.parse(content);
|
42
|
+
};
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
44
|
+
0 && (module.exports = {
|
45
|
+
readTsConfig,
|
46
|
+
readTsConfigByFile
|
47
|
+
});
|