vercel 59.11.2 → 59.11.7
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/chunks/{add-BKSHWTPX.js → add-KSJQYR5C.js} +23 -18
- package/dist/chunks/{add-RBW7QITR.js → add-PERLOALD.js} +37 -23
- package/dist/chunks/{add-HPLJZFM2.js → add-WU2QYHYL.js} +23 -18
- package/dist/chunks/{build-V4ZLAJWB.js → build-F3J6FLPD.js} +23 -18
- package/dist/chunks/{chunk-NGGLYKNU.js → chunk-26CU4Q3C.js} +3 -115
- package/dist/chunks/{chunk-QFAS4OVW.js → chunk-2JIX6UMI.js} +3 -84
- package/dist/chunks/chunk-2TSBB22D.js +14059 -0
- package/dist/chunks/chunk-332LMJLZ.js +16014 -0
- package/dist/chunks/{chunk-AYLY3ZVL.js → chunk-3VM7HWF6.js} +2 -2
- package/dist/chunks/chunk-4IALDGB7.js +22 -0
- package/dist/chunks/chunk-4IVSM24H.js +522 -0
- package/dist/chunks/{chunk-5XECIWME.js → chunk-5NF5HOBJ.js} +5 -3
- package/dist/chunks/chunk-6E6KPBXY.js +43 -0
- package/dist/chunks/chunk-7KROIXQM.js +59 -0
- package/dist/chunks/{chunk-ASBP32T6.js → chunk-7MRDIPJY.js} +1 -1
- package/dist/chunks/chunk-A5JZS6ZN.js +92 -0
- package/dist/chunks/{chunk-7ST552E3.js → chunk-AKLTIZCU.js} +1 -1
- package/dist/chunks/{chunk-26XDDLXM.js → chunk-ARU7VBKR.js} +2 -2
- package/dist/chunks/chunk-B5XLQKHI.js +849 -0
- package/dist/chunks/chunk-C762AAVU.js +137 -0
- package/dist/chunks/{chunk-WA2SJE5S.js → chunk-CEDN47PH.js} +4 -4
- package/dist/chunks/{chunk-ONRLTUP2.js → chunk-CNDPIHY5.js} +24 -22
- package/dist/chunks/{chunk-BMKU5KEL.js → chunk-CV5YC2EN.js} +1 -1
- package/dist/chunks/chunk-DBYHS3CK.js +257 -0
- package/dist/chunks/{chunk-HDBQPBL6.js → chunk-DSTNNQVV.js} +12 -8
- package/dist/chunks/{chunk-QAT3CW4G.js → chunk-EFYMIIER.js} +2 -2
- package/dist/chunks/{chunk-NBW3BWOJ.js → chunk-EPOLDWRA.js} +2 -2
- package/dist/chunks/{chunk-B4TXCKXE.js → chunk-EZQDYIVB.js} +10 -8
- package/dist/chunks/{chunk-2EAIC3SH.js → chunk-FL4JLNT2.js} +8 -8
- package/dist/chunks/chunk-FRVG4OW3.js +7438 -0
- package/dist/chunks/{chunk-FKDO3CM4.js → chunk-FVNJTRCE.js} +17 -13
- package/dist/chunks/chunk-FVT74RZ5.js +1536 -0
- package/dist/chunks/chunk-G3PXSXIB.js +18188 -0
- package/dist/chunks/chunk-G5FBSUL4.js +822 -0
- package/dist/chunks/{chunk-FRAXI2WT.js → chunk-GCVXKRR5.js} +3 -3
- package/dist/chunks/chunk-GHKJAK5V.js +1288 -0
- package/dist/chunks/{chunk-Q5K5DEOK.js → chunk-GUU4Z2AQ.js} +42 -28
- package/dist/chunks/{chunk-OQ3C5VXZ.js → chunk-GVNCVKCI.js} +4 -2
- package/dist/chunks/chunk-HB4UKFDO.js +1295 -0
- package/dist/chunks/chunk-HRXRELD3.js +338 -0
- package/dist/chunks/{chunk-IJ4X426J.js → chunk-IIMSID24.js} +1 -1
- package/dist/chunks/{chunk-O75LSD3C.js → chunk-JSD4EZL3.js} +1 -1
- package/dist/chunks/{chunk-7AEEQOD4.js → chunk-K3RED3VO.js} +1 -1
- package/dist/chunks/{chunk-RSEAADCE.js → chunk-KEKR7OCB.js} +6 -4
- package/dist/chunks/{chunk-3T7WSWZH.js → chunk-KFWQ3EFH.js} +1 -1
- package/dist/chunks/{chunk-L3UXB2CW.js → chunk-KW7BS25T.js} +1 -1
- package/dist/chunks/{chunk-RO44KX6Y.js → chunk-N4QHMXOO.js} +11 -7
- package/dist/chunks/{chunk-XRWOTCDO.js → chunk-ND5CF2H3.js} +1 -1
- package/dist/chunks/{chunk-RSJBU3ON.js → chunk-NSOYO6JQ.js} +35 -27
- package/dist/chunks/{chunk-RKDCNQ4S.js → chunk-NW34PW6V.js} +3 -105
- package/dist/chunks/{chunk-C5HKWXRR.js → chunk-OAMU5QO6.js} +1 -1
- package/dist/chunks/{chunk-MTWHQEXI.js → chunk-OIH6FP5Y.js} +5 -3
- package/dist/chunks/chunk-P7VSBDR4.js +827 -0
- package/dist/chunks/chunk-PEC3CQSK.js +90 -0
- package/dist/chunks/{chunk-QDV5LZ4Q.js → chunk-PFM75KY3.js} +12 -8
- package/dist/chunks/chunk-PJXMXMCO.js +81 -0
- package/dist/chunks/chunk-PNGVSHR3.js +40 -0
- package/dist/chunks/{chunk-TPATD2MM.js → chunk-QHS645AZ.js} +14 -6
- package/dist/chunks/{chunk-OTXE7MHI.js → chunk-QKX7WKIN.js} +8 -6
- package/dist/chunks/chunk-QOPTXV4G.js +417 -0
- package/dist/chunks/chunk-RN6V5ODW.js +114 -0
- package/dist/chunks/chunk-RVBZ64EQ.js +52 -0
- package/dist/chunks/chunk-SHFNEZVI.js +49 -0
- package/dist/chunks/{chunk-OO3OF6MK.js → chunk-TGNEG57M.js} +44 -15
- package/dist/chunks/{chunk-WNAKOXGK.js → chunk-TO7QZGYK.js} +1 -1
- package/dist/chunks/chunk-UARGTFCT.js +875 -0
- package/dist/chunks/{chunk-FWKSJYDV.js → chunk-UG2WOB5L.js} +1 -1
- package/dist/chunks/chunk-V4RMJKQP.js +36 -0
- package/dist/chunks/chunk-VT3Z7HF6.js +233 -0
- package/dist/chunks/chunk-VUS2JQB2.js +121 -0
- package/dist/chunks/{chunk-6CZZ3SH3.js → chunk-VYC45Q4Z.js} +2 -2
- package/dist/chunks/{chunk-4KVJ2M4J.js → chunk-WL6QYSGD.js} +78 -17
- package/dist/chunks/{chunk-FZRBF25Y.js → chunk-X7DBBZQD.js} +4 -4
- package/dist/chunks/{chunk-2NJJ2K5S.js → chunk-XD4DCYMX.js} +6 -6
- package/dist/chunks/{chunk-ZSFEACZU.js → chunk-XFF5TGRA.js} +1 -1
- package/dist/chunks/{chunk-6TBDHUXK.js → chunk-XIFATBH5.js} +21 -15
- package/dist/chunks/chunk-XNIZGCN5.js +58 -0
- package/dist/chunks/chunk-XPJLPUKO.js +117 -0
- package/dist/chunks/{chunk-FXD67VN5.js → chunk-XUAWTW4W.js} +1 -1
- package/dist/chunks/{chunk-I526H4AS.js → chunk-YS76T533.js} +2 -2
- package/dist/chunks/chunk-Z7JWYFOY.js +58 -0
- package/dist/chunks/{chunk-6JPVTPTU.js → chunk-ZBEECGFD.js} +3 -3
- package/dist/chunks/{chunk-52QYYTM5.js → chunk-ZDU2NODC.js} +3 -127
- package/dist/chunks/chunk-ZW6HETRE.js +97 -0
- package/dist/chunks/{clear-IYGWCNXT.js → clear-XUQO4ZTK.js} +23 -18
- package/dist/chunks/{compile-vercel-config-NEEBZRUJ.js → compile-vercel-config-D3ARNHTN.js} +8 -11
- package/dist/chunks/{config-6DS6BBR2.js → config-37OAE7QJ.js} +22 -17
- package/dist/chunks/{config-NTB5EMV4.js → config-MEDLXUVM.js} +23 -18
- package/dist/chunks/{delete-LLC2OGHA.js → delete-3N3YZZOF.js} +16 -12
- package/dist/chunks/{delete-LSGID5FV.js → delete-VSWDZ2SW.js} +19 -14
- package/dist/chunks/detect-projects-ODNU4PK2.js +18 -0
- package/dist/chunks/detect-services-TESZCQWG.js +40 -0
- package/dist/chunks/{disable-H4EXEQK7.js → disable-A4FLFMC7.js} +17 -13
- package/dist/chunks/{discard-FG6VKHWN.js → discard-CHGFULBZ.js} +17 -13
- package/dist/chunks/{edit-YE7D3CPJ.js → edit-JZ63AJYQ.js} +17 -13
- package/dist/chunks/{edit-BZJSGUHT.js → edit-MHSYAPDR.js} +19 -15
- package/dist/chunks/{enable-6ESD4QTE.js → enable-KD46SEC5.js} +17 -13
- package/dist/chunks/{exec-XH4K34JM.js → exec-4IPHZ55G.js} +9 -5
- package/dist/chunks/{export-QWSJROLG.js → export-42QZLBSN.js} +16 -13
- package/dist/chunks/{image-LTHQMKFG.js → image-GP4H73A2.js} +11 -8
- package/dist/chunks/{import-builders-6O7ILGQJ.js → import-builders-6TBLMPL2.js} +18 -13
- package/dist/chunks/{inspect-2C4ZSNYC.js → inspect-5FMWMY3C.js} +22 -18
- package/dist/chunks/{inspect-N6SMHV3Z.js → inspect-MUVK6MMT.js} +18 -14
- package/dist/chunks/{inspect-F7KCTHIL.js → inspect-Q3DWW7MC.js} +22 -18
- package/dist/chunks/{inspect-TWDPMXZ5.js → inspect-QFXAOUL4.js} +18 -14
- package/dist/chunks/{inspect-ICKNCDMT.js → inspect-RNTSYM6O.js} +18 -14
- package/dist/chunks/{list-NWTIJF3L.js → list-IHHIPXEC.js} +20 -16
- package/dist/chunks/{list-IPGQVBJO.js → list-JRNWLSO5.js} +16 -14
- package/dist/chunks/{list-DS7ZOUXA.js → list-XHD5DLEX.js} +23 -19
- package/dist/chunks/{login-F7A7ONKC.js → login-PCT6KFWY.js} +23 -18
- package/dist/chunks/{ls-NBDX3MKN.js → ls-GPEHEFCF.js} +24 -18
- package/dist/chunks/{ls-RNGO257R.js → ls-PF7F4PP4.js} +27 -23
- package/dist/chunks/{ls-XINES6PL.js → ls-PQZ2RIDX.js} +24 -18
- package/dist/chunks/{ls-D4TUDBIH.js → ls-SVOHC3XW.js} +24 -18
- package/dist/chunks/{ls-2QW3ZSM6.js → ls-TGHCCARZ.js} +24 -18
- package/dist/chunks/{ls-LSJEUPFX.js → ls-VRIH5WA3.js} +22 -15
- package/dist/chunks/{open-VRQDWZAW.js → open-E7DEKYDU.js} +18 -13
- package/dist/chunks/{permissions-6C5C7TEV.js → permissions-JKOONWVL.js} +14 -11
- package/dist/chunks/{publish-GVIZPNLN.js → publish-EDDELDE5.js} +17 -13
- package/dist/chunks/pull-646WEVDE.js +45 -0
- package/dist/chunks/{push-EFZ5P5Z6.js → push-LTNW5OVD.js} +23 -18
- package/dist/chunks/{query-GBS2PIT4.js → query-LU4N6KPO.js} +22 -19
- package/dist/chunks/{reorder-TN65IFRL.js → reorder-22PKJMZP.js} +17 -13
- package/dist/chunks/{reply-DYVEV3PY.js → reply-SF2EZMVZ.js} +17 -13
- package/dist/chunks/{resolve-JAWFBPUM.js → resolve-ZCZGXTOT.js} +16 -12
- package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +36 -0
- package/dist/chunks/{restore-TJVMHUBQ.js → restore-VJAWZXB4.js} +17 -13
- package/dist/chunks/{rm-7XACNZ2U.js → rm-KN2QFCKO.js} +23 -18
- package/dist/chunks/{rm-REJVXALW.js → rm-KVEAJPRE.js} +23 -18
- package/dist/chunks/{rm-CBPNMSRP.js → rm-OSZ5FZUM.js} +23 -16
- package/dist/chunks/{rm-5B5VHWWN.js → rm-W722Q2AO.js} +21 -18
- package/dist/chunks/{rm-HQ5CYNJA.js → rm-WNPGTUBH.js} +23 -18
- package/dist/chunks/{routes-2OLIBRYX.js → routes-QVMBXOSX.js} +7 -3
- package/dist/chunks/{rule-inspect-ZSTDDFID.js → rule-inspect-25Z6SNX3.js} +28 -24
- package/dist/chunks/{rules-VGV4M4KY.js → rules-65LKAQ35.js} +15 -12
- package/dist/chunks/{schema-45SJNY5L.js → schema-7D6IGJEJ.js} +9 -7
- package/dist/chunks/{schema-GMTQOQCV.js → schema-NXCW4M75.js} +19 -17
- package/dist/chunks/{set-Z5FO2FCC.js → set-FYJVKMPV.js} +20 -13
- package/dist/chunks/setup-and-link-KXPZE32P.js +65 -0
- package/dist/chunks/{tags-SDRXWJ63.js → tags-ANIRP5E3.js} +10 -7
- package/dist/chunks/{types-JGANJ5EQ.js → types-4GAJ7XQQ.js} +9 -7
- package/dist/chunks/{update-JBQBC3IV.js → update-UT6CTKVG.js} +32 -19
- package/dist/commands/build/index.js +86 -49
- package/dist/commands/deploy/index.js +75 -66
- package/dist/commands/dev/index.js +98 -52
- package/dist/commands/env/index.js +67 -43
- package/dist/commands/link/index.js +48 -27
- package/dist/commands/list/index.js +33 -22
- package/dist/commands-bulk.js +1659 -1287
- package/dist/index.js +62 -40
- package/dist/version.mjs +1 -1
- package/package.json +46 -46
- package/dist/chunks/chunk-WYU64FLP.js +0 -62123
- package/dist/chunks/chunk-XNFHNTS2.js +0 -2939
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
VERCEL_DIR
|
|
9
|
+
} from "./chunk-2TSBB22D.js";
|
|
10
|
+
import {
|
|
11
|
+
ConflictingConfigFiles,
|
|
12
|
+
DeprecatedNowJson
|
|
13
|
+
} from "./chunk-CV5YC2EN.js";
|
|
14
|
+
import {
|
|
15
|
+
output_manager_default
|
|
16
|
+
} from "./chunk-2JIX6UMI.js";
|
|
17
|
+
import {
|
|
18
|
+
__commonJS,
|
|
19
|
+
__require,
|
|
20
|
+
__toESM
|
|
21
|
+
} from "./chunk-TZ2YI2VH.js";
|
|
22
|
+
|
|
23
|
+
// ../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js
|
|
24
|
+
var require_main = __commonJS({
|
|
25
|
+
"../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
26
|
+
"use strict";
|
|
27
|
+
var fs = __require("fs");
|
|
28
|
+
function parse(src) {
|
|
29
|
+
var obj = {};
|
|
30
|
+
src.toString().split("\n").forEach(function(line) {
|
|
31
|
+
var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/);
|
|
32
|
+
if (keyValueArr != null) {
|
|
33
|
+
var key = keyValueArr[1];
|
|
34
|
+
var value = keyValueArr[2] ? keyValueArr[2] : "";
|
|
35
|
+
var len = value ? value.length : 0;
|
|
36
|
+
if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
|
|
37
|
+
value = value.replace(/\\n/gm, "\n");
|
|
38
|
+
}
|
|
39
|
+
value = value.replace(/(^['"]|['"]$)/g, "").trim();
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return obj;
|
|
44
|
+
}
|
|
45
|
+
function config(options) {
|
|
46
|
+
var path = ".env";
|
|
47
|
+
var encoding = "utf8";
|
|
48
|
+
if (options) {
|
|
49
|
+
if (options.path) {
|
|
50
|
+
path = options.path;
|
|
51
|
+
}
|
|
52
|
+
if (options.encoding) {
|
|
53
|
+
encoding = options.encoding;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
var parsedObj = parse(fs.readFileSync(path, { encoding }));
|
|
58
|
+
Object.keys(parsedObj).forEach(function(key) {
|
|
59
|
+
process.env[key] = process.env[key] || parsedObj[key];
|
|
60
|
+
});
|
|
61
|
+
return { parsed: parsedObj };
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return { error: e };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
module.exports.config = config;
|
|
67
|
+
module.exports.load = config;
|
|
68
|
+
module.exports.parse = parse;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/util/compile-vercel-config.ts
|
|
73
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
74
|
+
import { mkdir, readFile, writeFile, unlink, access } from "fs/promises";
|
|
75
|
+
import { join, basename } from "path";
|
|
76
|
+
import { fork } from "child_process";
|
|
77
|
+
import { parse as tomlParse } from "smol-toml";
|
|
78
|
+
import { getNodeExecPath, NowBuildError } from "@vercel/build-utils";
|
|
79
|
+
function toRouteFormat(item) {
|
|
80
|
+
if ("src" in item)
|
|
81
|
+
return item;
|
|
82
|
+
const { source, destination, headers, statusCode, permanent, ...rest } = item;
|
|
83
|
+
const route = {
|
|
84
|
+
src: source,
|
|
85
|
+
...rest
|
|
86
|
+
};
|
|
87
|
+
if (destination)
|
|
88
|
+
route.dest = destination;
|
|
89
|
+
if (headers)
|
|
90
|
+
route.headers = Object.fromEntries(headers.map((h) => [h.key, h.value]));
|
|
91
|
+
if (statusCode !== void 0) {
|
|
92
|
+
route.status = statusCode;
|
|
93
|
+
} else if (permanent !== void 0) {
|
|
94
|
+
route.status = permanent ? 308 : 307;
|
|
95
|
+
}
|
|
96
|
+
return route;
|
|
97
|
+
}
|
|
98
|
+
function normalizeConfig(config) {
|
|
99
|
+
const normalized = { ...config };
|
|
100
|
+
const { rewrites, redirects, headers } = normalized;
|
|
101
|
+
let allRoutes = normalized.routes || [];
|
|
102
|
+
const hasRoutes = allRoutes.length > 0;
|
|
103
|
+
const hasRewrites = (rewrites?.length ?? 0) > 0;
|
|
104
|
+
const hasRedirects = (redirects?.length ?? 0) > 0;
|
|
105
|
+
const hasHeaders = (headers?.length ?? 0) > 0;
|
|
106
|
+
function hasRouteFormat(items) {
|
|
107
|
+
return items?.some((item) => "src" in item) ?? false;
|
|
108
|
+
}
|
|
109
|
+
if (hasRoutes && (hasRewrites || hasRedirects || hasHeaders)) {
|
|
110
|
+
return normalized;
|
|
111
|
+
}
|
|
112
|
+
const shouldConvertRewrites = hasRewrites && hasRouteFormat(rewrites);
|
|
113
|
+
const shouldConvertRedirects = hasRedirects && hasRouteFormat(redirects);
|
|
114
|
+
const shouldConvertHeaders = hasHeaders && hasRouteFormat(headers);
|
|
115
|
+
const someWillConvert = shouldConvertRewrites || shouldConvertRedirects || shouldConvertHeaders;
|
|
116
|
+
const someWontConvert = hasRewrites && !shouldConvertRewrites || hasRedirects && !shouldConvertRedirects || hasHeaders && !shouldConvertHeaders;
|
|
117
|
+
if (someWillConvert && someWontConvert) {
|
|
118
|
+
throw new NowBuildError({
|
|
119
|
+
code: "INVALID_VERCEL_CONFIG",
|
|
120
|
+
message: "Transforms (e.g., requestHeaders) require the `routes` format, which cannot be used alongside `rewrites`, `redirects`, or `headers`. Move everything into the `routes` array instead.",
|
|
121
|
+
link: "https://vercel.com/docs/projects/project-configuration#routes"
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (rewrites && shouldConvertRewrites) {
|
|
125
|
+
allRoutes = [...allRoutes, ...rewrites.map(toRouteFormat)];
|
|
126
|
+
delete normalized.rewrites;
|
|
127
|
+
}
|
|
128
|
+
if (redirects && shouldConvertRedirects) {
|
|
129
|
+
allRoutes = [...allRoutes, ...redirects.map(toRouteFormat)];
|
|
130
|
+
delete normalized.redirects;
|
|
131
|
+
}
|
|
132
|
+
if (headers && shouldConvertHeaders) {
|
|
133
|
+
allRoutes = [...allRoutes, ...headers.map(toRouteFormat)];
|
|
134
|
+
delete normalized.headers;
|
|
135
|
+
}
|
|
136
|
+
if (allRoutes.length > 0) {
|
|
137
|
+
normalized.routes = allRoutes.map(toRouteFormat);
|
|
138
|
+
}
|
|
139
|
+
return normalized;
|
|
140
|
+
}
|
|
141
|
+
var VERCEL_CONFIG_EXTENSIONS = [
|
|
142
|
+
"ts",
|
|
143
|
+
"mts",
|
|
144
|
+
"js",
|
|
145
|
+
"mjs",
|
|
146
|
+
"cjs"
|
|
147
|
+
];
|
|
148
|
+
var DEFAULT_VERCEL_CONFIG_FILENAME = "Vercel config";
|
|
149
|
+
async function fileExists(filePath) {
|
|
150
|
+
try {
|
|
151
|
+
await access(filePath);
|
|
152
|
+
return true;
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function findAllVercelConfigFiles(workPath) {
|
|
158
|
+
const foundFiles = [];
|
|
159
|
+
for (const ext of VERCEL_CONFIG_EXTENSIONS) {
|
|
160
|
+
const configPath = join(workPath, `vercel.${ext}`);
|
|
161
|
+
if (await fileExists(configPath)) {
|
|
162
|
+
foundFiles.push(configPath);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return foundFiles;
|
|
166
|
+
}
|
|
167
|
+
async function findSourceVercelConfigFile(workPath) {
|
|
168
|
+
for (const ext of VERCEL_CONFIG_EXTENSIONS) {
|
|
169
|
+
const configPath = join(workPath, `vercel.${ext}`);
|
|
170
|
+
if (await fileExists(configPath)) {
|
|
171
|
+
return basename(configPath);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const tomlPath = join(workPath, "vercel.toml");
|
|
175
|
+
if (await fileExists(tomlPath)) {
|
|
176
|
+
return "vercel.toml";
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
async function findVercelConfigFile(workPath) {
|
|
181
|
+
const foundFiles = await findAllVercelConfigFiles(workPath);
|
|
182
|
+
if (foundFiles.length > 1) {
|
|
183
|
+
throw new ConflictingConfigFiles(
|
|
184
|
+
foundFiles,
|
|
185
|
+
"Multiple vercel config files found. Please use only one configuration file.",
|
|
186
|
+
"https://vercel.com/docs/projects/project-configuration"
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return foundFiles[0] || null;
|
|
190
|
+
}
|
|
191
|
+
function parseConfigLoaderError(stderr) {
|
|
192
|
+
if (!stderr.trim()) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
const moduleNotFoundMatch = stderr.match(
|
|
196
|
+
/Error \[ERR_MODULE_NOT_FOUND\]: Cannot find package '([^']+)'/
|
|
197
|
+
);
|
|
198
|
+
if (moduleNotFoundMatch) {
|
|
199
|
+
const packageName = moduleNotFoundMatch[1];
|
|
200
|
+
return `Cannot find package '${packageName}'. Make sure it's installed in your project dependencies.`;
|
|
201
|
+
}
|
|
202
|
+
const syntaxErrorMatch = stderr.match(/SyntaxError: (.+?)(?:\n|$)/);
|
|
203
|
+
if (syntaxErrorMatch) {
|
|
204
|
+
return `Syntax error: ${syntaxErrorMatch[1]}`;
|
|
205
|
+
}
|
|
206
|
+
const errorMatch = stderr.match(
|
|
207
|
+
/^(?:Error|TypeError|ReferenceError): (.+?)(?:\n|$)/m
|
|
208
|
+
);
|
|
209
|
+
if (errorMatch) {
|
|
210
|
+
return errorMatch[1];
|
|
211
|
+
}
|
|
212
|
+
return stderr.trim();
|
|
213
|
+
}
|
|
214
|
+
async function compileVercelConfig(workPath) {
|
|
215
|
+
const vercelJsonPath = join(workPath, "vercel.json");
|
|
216
|
+
const nowJsonPath = join(workPath, "now.json");
|
|
217
|
+
const vercelTomlPath = join(workPath, "vercel.toml");
|
|
218
|
+
const hasVercelJson = await fileExists(vercelJsonPath);
|
|
219
|
+
const hasNowJson = await fileExists(nowJsonPath);
|
|
220
|
+
const hasVercelToml = await fileExists(vercelTomlPath);
|
|
221
|
+
const vercelConfigPath = await findVercelConfigFile(workPath);
|
|
222
|
+
const vercelDir = join(workPath, VERCEL_DIR);
|
|
223
|
+
const compiledConfigPath = join(vercelDir, "vercel.json");
|
|
224
|
+
if (hasNowJson) {
|
|
225
|
+
throw new DeprecatedNowJson(nowJsonPath);
|
|
226
|
+
}
|
|
227
|
+
const foundConfigs = [];
|
|
228
|
+
if (hasVercelJson)
|
|
229
|
+
foundConfigs.push(vercelJsonPath);
|
|
230
|
+
if (hasVercelToml)
|
|
231
|
+
foundConfigs.push(vercelTomlPath);
|
|
232
|
+
if (vercelConfigPath)
|
|
233
|
+
foundConfigs.push(vercelConfigPath);
|
|
234
|
+
if (foundConfigs.length > 1) {
|
|
235
|
+
throw new ConflictingConfigFiles(
|
|
236
|
+
foundConfigs,
|
|
237
|
+
`Multiple config files found: ${foundConfigs.map((f) => basename(f)).join(", ")}. Please use only one configuration method.`,
|
|
238
|
+
"https://vercel.com/docs/projects/project-configuration"
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
if (!vercelConfigPath && !hasVercelToml) {
|
|
242
|
+
if (hasVercelJson) {
|
|
243
|
+
return {
|
|
244
|
+
configPath: vercelJsonPath,
|
|
245
|
+
wasCompiled: false
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (await fileExists(compiledConfigPath)) {
|
|
249
|
+
return {
|
|
250
|
+
configPath: compiledConfigPath,
|
|
251
|
+
wasCompiled: true,
|
|
252
|
+
sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
configPath: null,
|
|
257
|
+
wasCompiled: false
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (hasVercelToml) {
|
|
261
|
+
try {
|
|
262
|
+
const tomlContent = await readFile(vercelTomlPath, "utf8");
|
|
263
|
+
const config = tomlParse(tomlContent);
|
|
264
|
+
const normalizedConfig = normalizeConfig(config);
|
|
265
|
+
await mkdir(vercelDir, { recursive: true });
|
|
266
|
+
await writeFile(
|
|
267
|
+
compiledConfigPath,
|
|
268
|
+
JSON.stringify(normalizedConfig, null, 2),
|
|
269
|
+
"utf-8"
|
|
270
|
+
);
|
|
271
|
+
output_manager_default.debug(`Compiled ${vercelTomlPath} -> ${compiledConfigPath}`);
|
|
272
|
+
return {
|
|
273
|
+
configPath: compiledConfigPath,
|
|
274
|
+
wasCompiled: true,
|
|
275
|
+
sourceFile: "vercel.toml"
|
|
276
|
+
};
|
|
277
|
+
} catch (error) {
|
|
278
|
+
throw new NowBuildError({
|
|
279
|
+
code: error.code ?? "vercel_toml_parse_failed",
|
|
280
|
+
message: `Failed to parse vercel.toml: ${error.message}`,
|
|
281
|
+
link: error.link ?? "https://vercel.com/docs/projects/project-configuration"
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const sourceConfigPath = vercelConfigPath;
|
|
286
|
+
(0, import_dotenv.config)({ path: join(workPath, ".env") });
|
|
287
|
+
(0, import_dotenv.config)({ path: join(workPath, ".env.local") });
|
|
288
|
+
const tempOutPath = join(vercelDir, "vercel-temp.mjs");
|
|
289
|
+
const loaderPath = join(vercelDir, "vercel-loader.mjs");
|
|
290
|
+
try {
|
|
291
|
+
const { build } = await import("esbuild");
|
|
292
|
+
await mkdir(vercelDir, { recursive: true });
|
|
293
|
+
await build({
|
|
294
|
+
entryPoints: [sourceConfigPath],
|
|
295
|
+
bundle: true,
|
|
296
|
+
platform: "node",
|
|
297
|
+
format: "esm",
|
|
298
|
+
outfile: tempOutPath,
|
|
299
|
+
packages: "external",
|
|
300
|
+
target: "node20",
|
|
301
|
+
sourcemap: "inline"
|
|
302
|
+
});
|
|
303
|
+
const loaderScript = `
|
|
304
|
+
import { pathToFileURL } from 'url';
|
|
305
|
+
const configModule = await import(pathToFileURL(process.argv[2]).href);
|
|
306
|
+
const config = ('default' in configModule) ? configModule.default : ('config' in configModule) ? configModule.config : configModule;
|
|
307
|
+
process.send(config);
|
|
308
|
+
`;
|
|
309
|
+
await writeFile(loaderPath, loaderScript, "utf-8");
|
|
310
|
+
const config = await new Promise((resolve, reject) => {
|
|
311
|
+
const child = fork(loaderPath, [tempOutPath], {
|
|
312
|
+
execPath: getNodeExecPath(),
|
|
313
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"]
|
|
314
|
+
});
|
|
315
|
+
let stderrOutput = "";
|
|
316
|
+
let stdoutOutput = "";
|
|
317
|
+
if (child.stderr) {
|
|
318
|
+
child.stderr.on("data", (data) => {
|
|
319
|
+
stderrOutput += data.toString();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (child.stdout) {
|
|
323
|
+
child.stdout.on("data", (data) => {
|
|
324
|
+
stdoutOutput += data.toString();
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
const timeout = setTimeout(() => {
|
|
328
|
+
child.kill();
|
|
329
|
+
reject(new Error("Config loader timed out after 10 seconds"));
|
|
330
|
+
}, 1e4);
|
|
331
|
+
child.on("message", (message) => {
|
|
332
|
+
clearTimeout(timeout);
|
|
333
|
+
child.kill();
|
|
334
|
+
resolve(message);
|
|
335
|
+
});
|
|
336
|
+
child.on("error", (err) => {
|
|
337
|
+
clearTimeout(timeout);
|
|
338
|
+
reject(err);
|
|
339
|
+
});
|
|
340
|
+
child.on("exit", (code) => {
|
|
341
|
+
clearTimeout(timeout);
|
|
342
|
+
if (code !== 0) {
|
|
343
|
+
if (stderrOutput.trim()) {
|
|
344
|
+
output_manager_default.log(stderrOutput);
|
|
345
|
+
}
|
|
346
|
+
if (stdoutOutput.trim()) {
|
|
347
|
+
output_manager_default.log(stdoutOutput);
|
|
348
|
+
}
|
|
349
|
+
const parsedError = parseConfigLoaderError(stderrOutput);
|
|
350
|
+
if (parsedError) {
|
|
351
|
+
reject(new Error(parsedError));
|
|
352
|
+
} else if (stdoutOutput.trim()) {
|
|
353
|
+
reject(new Error(stdoutOutput.trim()));
|
|
354
|
+
} else {
|
|
355
|
+
reject(new Error(`Config loader exited with code ${code}`));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
const normalizedConfig = normalizeConfig(config);
|
|
361
|
+
await writeFile(
|
|
362
|
+
compiledConfigPath,
|
|
363
|
+
JSON.stringify(normalizedConfig, null, 2),
|
|
364
|
+
"utf-8"
|
|
365
|
+
);
|
|
366
|
+
output_manager_default.debug(`Compiled ${sourceConfigPath} -> ${compiledConfigPath}`);
|
|
367
|
+
return {
|
|
368
|
+
configPath: compiledConfigPath,
|
|
369
|
+
wasCompiled: true,
|
|
370
|
+
sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
|
|
371
|
+
};
|
|
372
|
+
} catch (error) {
|
|
373
|
+
throw new NowBuildError({
|
|
374
|
+
code: error.code ?? "vercel_ts_compilation_failed",
|
|
375
|
+
message: `Failed to compile ${basename(sourceConfigPath)}: ${error.message}`,
|
|
376
|
+
link: error.link ?? "https://vercel.com/docs/projects/project-configuration"
|
|
377
|
+
});
|
|
378
|
+
} finally {
|
|
379
|
+
await Promise.all([
|
|
380
|
+
unlink(tempOutPath).catch((err) => {
|
|
381
|
+
if (err.code !== "ENOENT") {
|
|
382
|
+
output_manager_default.debug(`Failed to cleanup temp file: ${err}`);
|
|
383
|
+
}
|
|
384
|
+
}),
|
|
385
|
+
unlink(loaderPath).catch((err) => {
|
|
386
|
+
if (err.code !== "ENOENT") {
|
|
387
|
+
output_manager_default.debug(`Failed to cleanup loader file: ${err}`);
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async function getVercelConfigPath(workPath) {
|
|
394
|
+
const vercelJsonPath = join(workPath, "vercel.json");
|
|
395
|
+
const vercelTomlPath = join(workPath, "vercel.toml");
|
|
396
|
+
const compiledConfigPath = join(workPath, VERCEL_DIR, "vercel.json");
|
|
397
|
+
if (await fileExists(vercelJsonPath)) {
|
|
398
|
+
return vercelJsonPath;
|
|
399
|
+
}
|
|
400
|
+
if (await fileExists(vercelTomlPath)) {
|
|
401
|
+
return vercelTomlPath;
|
|
402
|
+
}
|
|
403
|
+
if (await fileExists(compiledConfigPath)) {
|
|
404
|
+
return compiledConfigPath;
|
|
405
|
+
}
|
|
406
|
+
return vercelJsonPath;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export {
|
|
410
|
+
require_main,
|
|
411
|
+
normalizeConfig,
|
|
412
|
+
VERCEL_CONFIG_EXTENSIONS,
|
|
413
|
+
DEFAULT_VERCEL_CONFIG_FILENAME,
|
|
414
|
+
findSourceVercelConfigFile,
|
|
415
|
+
compileVercelConfig,
|
|
416
|
+
getVercelConfigPath
|
|
417
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
CertConfigurationError,
|
|
9
|
+
CertError,
|
|
10
|
+
DeploymentNotFound,
|
|
11
|
+
DeploymentPermissionDenied,
|
|
12
|
+
DomainNotFound,
|
|
13
|
+
InvalidDeploymentId,
|
|
14
|
+
TooManyRequests,
|
|
15
|
+
isAPIError
|
|
16
|
+
} from "./chunk-CV5YC2EN.js";
|
|
17
|
+
import {
|
|
18
|
+
output_manager_default
|
|
19
|
+
} from "./chunk-2JIX6UMI.js";
|
|
20
|
+
|
|
21
|
+
// src/util/parse-target.ts
|
|
22
|
+
function parseTarget({
|
|
23
|
+
flagName,
|
|
24
|
+
flags
|
|
25
|
+
}) {
|
|
26
|
+
const targetFlagName = `--${flagName}`;
|
|
27
|
+
const targetFlagValue = flags[targetFlagName];
|
|
28
|
+
const prodFlagValue = flags["--prod"];
|
|
29
|
+
if (prodFlagValue && targetFlagValue) {
|
|
30
|
+
output_manager_default.warn(
|
|
31
|
+
`Both \`--prod\` and \`${targetFlagName}\` detected. Ignoring \`--prod\`.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
if (typeof targetFlagValue === "string") {
|
|
35
|
+
output_manager_default.debug(`Setting target to ${targetFlagValue}`);
|
|
36
|
+
return targetFlagValue;
|
|
37
|
+
}
|
|
38
|
+
if (prodFlagValue) {
|
|
39
|
+
output_manager_default.debug("Setting target to production");
|
|
40
|
+
return "production";
|
|
41
|
+
}
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/util/to-host.ts
|
|
46
|
+
function toHost(url) {
|
|
47
|
+
return url.replace(/^(?:.*?\/\/)?([^/]+).*/, "$1");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/util/certs/map-cert-error.ts
|
|
51
|
+
function mapCertError(error, cns) {
|
|
52
|
+
const errorCode = error.code;
|
|
53
|
+
if (errorCode === "too_many_requests") {
|
|
54
|
+
const retryAfter = typeof error.retryAfterMs === "number" ? error.retryAfterMs : 0;
|
|
55
|
+
return new TooManyRequests("certificates", retryAfter);
|
|
56
|
+
}
|
|
57
|
+
if (errorCode === "not_found") {
|
|
58
|
+
return new DomainNotFound(error.domain);
|
|
59
|
+
}
|
|
60
|
+
if (errorCode === "configuration_error") {
|
|
61
|
+
return new CertConfigurationError({
|
|
62
|
+
cns: cns || error.cns || [],
|
|
63
|
+
message: error.message,
|
|
64
|
+
external: error.external,
|
|
65
|
+
helpUrl: error.helpUrl,
|
|
66
|
+
type: error.statusCode === 449 ? "http-01" : "dns-01"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (errorCode === "bad_domains" || errorCode === "challenge_still_pending" || errorCode === "common_name_domain_name_mismatch" || errorCode === "conflicting_caa_record" || errorCode === "domain_not_verified" || errorCode === "invalid_cn" || errorCode === "invalid_domain" || errorCode === "rate_limited" || errorCode === "should_share_root_domain" || errorCode === "unauthorized_request_error" || errorCode === "unsupported_challenge_priority" || errorCode === "wildcard_not_allowed" || errorCode === "validation_running" || errorCode === "dns_error" || errorCode === "challenge_error" || errorCode === "txt_record_not_found") {
|
|
70
|
+
return new CertError({
|
|
71
|
+
cns: cns || error.cns || [],
|
|
72
|
+
code: errorCode,
|
|
73
|
+
message: error.message,
|
|
74
|
+
helpUrl: error.helpUrl
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/util/get-deployment.ts
|
|
81
|
+
async function getDeployment(client, contextName, hostOrId) {
|
|
82
|
+
if (hostOrId.includes(".")) {
|
|
83
|
+
hostOrId = toHost(hostOrId);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return await client.fetch(
|
|
87
|
+
`/v13/deployments/${encodeURIComponent(hostOrId)}`
|
|
88
|
+
);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
if (isAPIError(err)) {
|
|
91
|
+
if (err.status === 404) {
|
|
92
|
+
throw new DeploymentNotFound({ id: hostOrId, context: contextName });
|
|
93
|
+
}
|
|
94
|
+
if (err.status === 403) {
|
|
95
|
+
throw new DeploymentPermissionDenied(hostOrId, contextName);
|
|
96
|
+
}
|
|
97
|
+
if (err.status === 400 && err.message.includes("`id`")) {
|
|
98
|
+
throw new InvalidDeploymentId(hostOrId);
|
|
99
|
+
}
|
|
100
|
+
const certError = mapCertError(err);
|
|
101
|
+
if (certError) {
|
|
102
|
+
throw certError;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
parseTarget,
|
|
111
|
+
mapCertError,
|
|
112
|
+
toHost,
|
|
113
|
+
getDeployment
|
|
114
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_dist2 as require_dist
|
|
9
|
+
} from "./chunk-332LMJLZ.js";
|
|
10
|
+
import {
|
|
11
|
+
require_frameworks
|
|
12
|
+
} from "./chunk-FRVG4OW3.js";
|
|
13
|
+
import {
|
|
14
|
+
__toESM
|
|
15
|
+
} from "./chunk-TZ2YI2VH.js";
|
|
16
|
+
|
|
17
|
+
// src/util/projects/detect-projects.ts
|
|
18
|
+
var import_frameworks = __toESM(require_frameworks(), 1);
|
|
19
|
+
var import_fs_detectors = __toESM(require_dist(), 1);
|
|
20
|
+
import { join } from "path";
|
|
21
|
+
async function detectProjects(cwd) {
|
|
22
|
+
const fs = new import_fs_detectors.LocalFileSystemDetector(cwd);
|
|
23
|
+
const workspaces = await (0, import_fs_detectors.getWorkspaces)({ fs });
|
|
24
|
+
const detectedProjects = /* @__PURE__ */ new Map();
|
|
25
|
+
const packagePaths = (await Promise.all(
|
|
26
|
+
workspaces.map(
|
|
27
|
+
(workspace) => (0, import_fs_detectors.getWorkspacePackagePaths)({
|
|
28
|
+
fs,
|
|
29
|
+
workspace
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
)).flat();
|
|
33
|
+
if (packagePaths.length === 0) {
|
|
34
|
+
packagePaths.push("/");
|
|
35
|
+
}
|
|
36
|
+
await Promise.all(
|
|
37
|
+
packagePaths.map(async (p) => {
|
|
38
|
+
const frameworks = await (0, import_fs_detectors.detectFrameworks)({
|
|
39
|
+
fs: fs.chdir(join(".", p)),
|
|
40
|
+
frameworkList: import_frameworks.frameworkList
|
|
41
|
+
});
|
|
42
|
+
if (frameworks.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
detectedProjects.set(p.slice(1), frameworks);
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
return detectedProjects;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
detectProjects
|
|
52
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_json_parse_better_errors
|
|
9
|
+
} from "./chunk-6E6KPBXY.js";
|
|
10
|
+
import {
|
|
11
|
+
require_lib
|
|
12
|
+
} from "./chunk-2TSBB22D.js";
|
|
13
|
+
import {
|
|
14
|
+
CantParseJSONFile
|
|
15
|
+
} from "./chunk-CV5YC2EN.js";
|
|
16
|
+
import {
|
|
17
|
+
require_dist
|
|
18
|
+
} from "./chunk-ZW6HETRE.js";
|
|
19
|
+
import {
|
|
20
|
+
__toESM
|
|
21
|
+
} from "./chunk-TZ2YI2VH.js";
|
|
22
|
+
|
|
23
|
+
// src/util/read-json-file.ts
|
|
24
|
+
var import_fs_extra = __toESM(require_lib(), 1);
|
|
25
|
+
var import_json_parse_better_errors = __toESM(require_json_parse_better_errors(), 1);
|
|
26
|
+
var import_error_utils = __toESM(require_dist(), 1);
|
|
27
|
+
async function readJSONFile(file) {
|
|
28
|
+
const content = await readFileSafe(file);
|
|
29
|
+
if (content === null) {
|
|
30
|
+
return content;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const json = (0, import_json_parse_better_errors.default)(content);
|
|
34
|
+
return json;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return new CantParseJSONFile(file, (0, import_error_utils.errorToString)(error));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function readFileSafe(file) {
|
|
40
|
+
try {
|
|
41
|
+
return await import_fs_extra.default.readFile(file, "utf8");
|
|
42
|
+
} catch (_) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
readJSONFile
|
|
49
|
+
};
|