@kodycodes/cli 3.45.0 → 3.45.2
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/{auth-KYEYWPJC.js → auth-L5NDLZUF.js} +4 -5
- package/dist/bin.js +5 -6
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-DD2JGPDQ.js → chunk-2RRDYVW3.js} +5 -7
- package/dist/chunk-2RRDYVW3.js.map +6 -0
- package/dist/{chunk-YS6Z7JVP.js → chunk-CBFPAQOZ.js} +4 -6
- package/dist/chunk-CBFPAQOZ.js.map +6 -0
- package/dist/{chunk-YCJTZL7G.js → chunk-DUS7SBZT.js} +41 -43
- package/dist/chunk-DUS7SBZT.js.map +6 -0
- package/dist/{chunk-LXYTANRJ.js → chunk-FZ67GC66.js} +46 -14
- package/dist/chunk-FZ67GC66.js.map +6 -0
- package/dist/{chunk-EHGFMAHV.js → chunk-GGHTMLFJ.js} +2 -2
- package/dist/{chunk-5XG7DKFK.js → chunk-HVFE4XCI.js} +2 -2
- package/dist/{chunk-V7EVS6AD.js → chunk-L6VBRGS6.js} +14 -4
- package/dist/chunk-L6VBRGS6.js.map +6 -0
- package/dist/{chunk-66BF6YCZ.js → chunk-M6JCNIX6.js} +3 -3
- package/dist/chunk-TB7NX637.js +868 -0
- package/dist/chunk-TB7NX637.js.map +6 -0
- package/dist/{chunk-4J5XVKTW.js → chunk-TIN6KMVQ.js} +5 -7
- package/dist/chunk-TIN6KMVQ.js.map +6 -0
- package/dist/{chunk-ELBWKUTY.js → chunk-UC2OBYKG.js} +22 -7
- package/dist/chunk-UC2OBYKG.js.map +6 -0
- package/dist/{chunk-2DIHJVLK.js → chunk-Z5EBUX3U.js} +6 -6
- package/dist/cli.js +5 -6
- package/dist/{commands-BU3XAQUF.js → commands-BMIGLU7X.js} +2 -2
- package/dist/dev/dev-watcher.d.ts +5 -0
- package/dist/{dev-command-RP4IY5TL.js → dev-command-TEJPQEPO.js} +142 -761
- package/dist/dev-command-TEJPQEPO.js.map +6 -0
- package/dist/fetch-body-package-scan.d.ts +1 -0
- package/dist/{git-credential-GFUWDRRV.js → git-credential-6MV6GGR5.js} +5 -6
- package/dist/git-credential-6MV6GGR5.js.map +6 -0
- package/dist/{local-execute-XO65HZAX.js → local-execute-TL2JIRBK.js} +4 -5
- package/dist/local-execute-TL2JIRBK.js.map +6 -0
- package/dist/{local-kody-RYKBNHAP.js → local-kody-UP6W2YSF.js} +128 -29
- package/dist/local-kody-UP6W2YSF.js.map +6 -0
- package/dist/{local-package-graph-JSWSRB3S.js → local-package-graph-VN53AG4I.js} +3 -4
- package/dist/{local-package-run-QCKYALIQ.js → local-package-run-BXFC2HQE.js} +7 -8
- package/dist/{local-secrets-563FQE2A.js → local-secrets-WUAERJHG.js} +3 -4
- package/dist/local-secrets-WUAERJHG.js.map +6 -0
- package/dist/{mock-dep-resolve-7FJ6P6PE.js → mock-dep-resolve-EMFQ6ANZ.js} +2 -2
- package/dist/{mock-local-deps-KTMRYDRZ.js → mock-local-deps-2G5NX4MR.js} +8 -5
- package/dist/mock-local-deps.d.ts +18 -0
- package/dist/{mock-server-KTBYHEPH.js → mock-server-NM6XOOS3.js} +2 -2
- package/dist/{open-api-client-ITRRSEXW.js → open-api-client-QI5I3NFE.js} +3 -4
- package/dist/package-app-dev.d.ts +6 -1
- package/dist/publish-builder.js +101 -15
- package/dist/{remote-execute-CLWEHTAF.js → remote-execute-K5T677LE.js} +3 -4
- package/dist/remote-execute-K5T677LE.js.map +6 -0
- package/dist/{run-executor-3UIWBJGZ.js → run-executor-WN6W7JKN.js} +2 -2
- package/dist/{setup-git-IWA34U2C.js → setup-git-Q3TZZEGS.js} +4 -5
- package/dist/{whoami-G42DDVJW.js → whoami-WZNTBYDS.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-3IYBIEX6.js +0 -225
- package/dist/chunk-3IYBIEX6.js.map +0 -6
- package/dist/chunk-4J5XVKTW.js.map +0 -6
- package/dist/chunk-DD2JGPDQ.js.map +0 -6
- package/dist/chunk-ELBWKUTY.js.map +0 -6
- package/dist/chunk-G6LJWROP.js +0 -18
- package/dist/chunk-G6LJWROP.js.map +0 -6
- package/dist/chunk-LXYTANRJ.js.map +0 -6
- package/dist/chunk-V7EVS6AD.js.map +0 -6
- package/dist/chunk-YCJTZL7G.js.map +0 -6
- package/dist/chunk-YS6Z7JVP.js.map +0 -6
- package/dist/dev-command-RP4IY5TL.js.map +0 -6
- package/dist/git-credential-GFUWDRRV.js.map +0 -6
- package/dist/local-execute-XO65HZAX.js.map +0 -6
- package/dist/local-kody-RYKBNHAP.js.map +0 -6
- package/dist/local-secrets-563FQE2A.js.map +0 -6
- package/dist/remote-execute-CLWEHTAF.js.map +0 -6
- /package/dist/{auth-KYEYWPJC.js.map → auth-L5NDLZUF.js.map} +0 -0
- /package/dist/{chunk-EHGFMAHV.js.map → chunk-GGHTMLFJ.js.map} +0 -0
- /package/dist/{chunk-5XG7DKFK.js.map → chunk-HVFE4XCI.js.map} +0 -0
- /package/dist/{chunk-66BF6YCZ.js.map → chunk-M6JCNIX6.js.map} +0 -0
- /package/dist/{chunk-2DIHJVLK.js.map → chunk-Z5EBUX3U.js.map} +0 -0
- /package/dist/{commands-BU3XAQUF.js.map → commands-BMIGLU7X.js.map} +0 -0
- /package/dist/{local-package-graph-JSWSRB3S.js.map → local-package-graph-VN53AG4I.js.map} +0 -0
- /package/dist/{local-package-run-QCKYALIQ.js.map → local-package-run-BXFC2HQE.js.map} +0 -0
- /package/dist/{mock-dep-resolve-7FJ6P6PE.js.map → mock-dep-resolve-EMFQ6ANZ.js.map} +0 -0
- /package/dist/{mock-local-deps-KTMRYDRZ.js.map → mock-local-deps-2G5NX4MR.js.map} +0 -0
- /package/dist/{mock-server-KTBYHEPH.js.map → mock-server-NM6XOOS3.js.map} +0 -0
- /package/dist/{open-api-client-ITRRSEXW.js.map → open-api-client-QI5I3NFE.js.map} +0 -0
- /package/dist/{run-executor-3UIWBJGZ.js.map → run-executor-WN6W7JKN.js.map} +0 -0
- /package/dist/{setup-git-IWA34U2C.js.map → setup-git-Q3TZZEGS.js.map} +0 -0
- /package/dist/{whoami-G42DDVJW.js.map → whoami-WZNTBYDS.js.map} +0 -0
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init,
|
|
4
|
+
parse
|
|
5
|
+
} from "./chunk-2RRDYVW3.js";
|
|
6
|
+
|
|
7
|
+
// src/fetch-body-secret-resolution.ts
|
|
8
|
+
var fetchBodySecretResolutionWarningLead = 'WARNING: a fetch sends a body without x-kody-secret-resolution. The gateway fills {{secret:name}} anywhere in that body, so text this package did not write can fail with Secret "name" was not found, or a saved secret can be sent to a host the credential allows. Set x-kody-secret-resolution: headers-only on that fetch (headers still resolve). This does not block publish.';
|
|
9
|
+
var secretResolutionHeaderName = "x-kody-secret-resolution";
|
|
10
|
+
var maxWarningSites = 8;
|
|
11
|
+
function findFetchBodiesMissingSecretResolution(source) {
|
|
12
|
+
const hits = [];
|
|
13
|
+
for (const call of findFetchLikeCalls(source)) {
|
|
14
|
+
if (callSendsUnresolvedDynamicBody(call.args)) {
|
|
15
|
+
hits.push({ line: lineAt(source, call.index) });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return hits;
|
|
19
|
+
}
|
|
20
|
+
function formatFetchBodySecretResolutionWarning(hits) {
|
|
21
|
+
if (hits.length === 0) return null;
|
|
22
|
+
const ordered = [...hits].sort((left, right) => {
|
|
23
|
+
const byPath = left.path.localeCompare(right.path);
|
|
24
|
+
return byPath === 0 ? left.line - right.line : byPath;
|
|
25
|
+
});
|
|
26
|
+
const shown = ordered.slice(0, maxWarningSites);
|
|
27
|
+
const extra = ordered.length - shown.length;
|
|
28
|
+
return [
|
|
29
|
+
fetchBodySecretResolutionWarningLead,
|
|
30
|
+
...shown.map((hit) => `- ${hit.path}:${hit.line}`),
|
|
31
|
+
...extra > 0 ? [`- ${extra} more`] : []
|
|
32
|
+
].join("\n");
|
|
33
|
+
}
|
|
34
|
+
function findFetchLikeCalls(source) {
|
|
35
|
+
const calls = [];
|
|
36
|
+
scanCode(source, 0, "eof", calls);
|
|
37
|
+
return calls;
|
|
38
|
+
}
|
|
39
|
+
function scanCode(source, start, stop, calls) {
|
|
40
|
+
let index = start;
|
|
41
|
+
let lastWord = "";
|
|
42
|
+
let braceDepth = 0;
|
|
43
|
+
while (index < source.length) {
|
|
44
|
+
const char = source[index];
|
|
45
|
+
if (isWhitespace(char)) {
|
|
46
|
+
index += 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
50
|
+
index = skipLineComment(source, index);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
54
|
+
index = skipBlockComment(source, index);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (char === "'" || char === '"') {
|
|
58
|
+
index = skipQuotedString(source, index);
|
|
59
|
+
lastWord = "";
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (char === "`") {
|
|
63
|
+
index = skipTemplate(source, index, calls);
|
|
64
|
+
lastWord = "";
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (isIdentStart(char)) {
|
|
68
|
+
const wordStart = index;
|
|
69
|
+
index += 1;
|
|
70
|
+
while (index < source.length && isIdentPart(source[index])) index += 1;
|
|
71
|
+
const word = source.slice(wordStart, index);
|
|
72
|
+
const openParen = skipWhitespaceAndComments(source, index);
|
|
73
|
+
const isFetch = word === "fetch" && lastWord !== "function" && lastWord !== "async";
|
|
74
|
+
const isRequest = word === "Request" && lastWord === "new";
|
|
75
|
+
if ((isFetch || isRequest) && source[openParen] === "(") {
|
|
76
|
+
const call = readCallArguments(source, openParen);
|
|
77
|
+
if (call) calls.push({ index: wordStart, args: call.args });
|
|
78
|
+
}
|
|
79
|
+
lastWord = word;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (char === "{") {
|
|
83
|
+
braceDepth += 1;
|
|
84
|
+
lastWord = "";
|
|
85
|
+
index += 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (char === "}") {
|
|
89
|
+
if (stop === "brace" && braceDepth === 0) return index + 1;
|
|
90
|
+
braceDepth -= 1;
|
|
91
|
+
lastWord = "";
|
|
92
|
+
index += 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
lastWord = "";
|
|
96
|
+
index += 1;
|
|
97
|
+
}
|
|
98
|
+
return index;
|
|
99
|
+
}
|
|
100
|
+
function callSendsUnresolvedDynamicBody(args) {
|
|
101
|
+
const init2 = args[1]?.trim();
|
|
102
|
+
if (init2 == null || !init2.startsWith("{")) return false;
|
|
103
|
+
const properties = readObjectProperties(init2);
|
|
104
|
+
if (properties == null) return false;
|
|
105
|
+
const body = lastProperty(properties, "body");
|
|
106
|
+
if (body == null || body.spread || body.method) return false;
|
|
107
|
+
if (isStaticExpression(body.value)) return false;
|
|
108
|
+
const headers = lastProperty(properties, "headers");
|
|
109
|
+
if (headers == null) return true;
|
|
110
|
+
if (headers.spread || headers.method) return true;
|
|
111
|
+
return headersLeaveBodyResolutionOn(headers.value);
|
|
112
|
+
}
|
|
113
|
+
function headersLeaveBodyResolutionOn(headersValue) {
|
|
114
|
+
const text = headersValue.trim();
|
|
115
|
+
if (!text.startsWith("{")) return true;
|
|
116
|
+
const properties = readObjectProperties(text);
|
|
117
|
+
if (properties == null) return true;
|
|
118
|
+
if (properties.some((property) => property.spread)) return true;
|
|
119
|
+
const resolution = lastProperty(properties, secretResolutionHeaderName, {
|
|
120
|
+
caseInsensitive: true
|
|
121
|
+
});
|
|
122
|
+
if (resolution == null || resolution.method) return true;
|
|
123
|
+
const mode = staticStringValue(resolution.value);
|
|
124
|
+
if (mode == null) return false;
|
|
125
|
+
return mode.trim().toLowerCase() === "on";
|
|
126
|
+
}
|
|
127
|
+
function lastProperty(properties, key, options) {
|
|
128
|
+
const needle = options?.caseInsensitive ? key.toLowerCase() : key;
|
|
129
|
+
for (let index = properties.length - 1; index >= 0; index -= 1) {
|
|
130
|
+
const property = properties[index];
|
|
131
|
+
const name = property.key;
|
|
132
|
+
if (name == null) continue;
|
|
133
|
+
const match = options?.caseInsensitive ? name.toLowerCase() : name;
|
|
134
|
+
if (match === needle) return property;
|
|
135
|
+
}
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
function readObjectProperties(source) {
|
|
139
|
+
const text = source.trim();
|
|
140
|
+
if (!text.startsWith("{")) return null;
|
|
141
|
+
const properties = [];
|
|
142
|
+
let index = 1;
|
|
143
|
+
while (index < text.length) {
|
|
144
|
+
index = skipWhitespaceAndComments(text, index);
|
|
145
|
+
if (index >= text.length) return null;
|
|
146
|
+
if (text[index] === "}") return properties;
|
|
147
|
+
if (text[index] === ",") {
|
|
148
|
+
index += 1;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (text.startsWith("...", index)) {
|
|
152
|
+
const spread = readExpression(text, index + 3);
|
|
153
|
+
if (spread == null) return null;
|
|
154
|
+
properties.push({
|
|
155
|
+
key: null,
|
|
156
|
+
value: spread.text,
|
|
157
|
+
spread: true,
|
|
158
|
+
method: false
|
|
159
|
+
});
|
|
160
|
+
index = spread.end;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const key = readPropertyKey(text, index);
|
|
164
|
+
if (key == null) return null;
|
|
165
|
+
index = skipWhitespaceAndComments(text, key.end);
|
|
166
|
+
if (text[index] === "(" || text.startsWith("async ", key.start)) {
|
|
167
|
+
const method = skipMethod(text, index);
|
|
168
|
+
if (method == null) return null;
|
|
169
|
+
properties.push({
|
|
170
|
+
key: key.name,
|
|
171
|
+
value: "",
|
|
172
|
+
spread: false,
|
|
173
|
+
method: true
|
|
174
|
+
});
|
|
175
|
+
index = method;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (text[index] !== ":") {
|
|
179
|
+
properties.push({
|
|
180
|
+
key: key.name,
|
|
181
|
+
value: key.raw,
|
|
182
|
+
spread: false,
|
|
183
|
+
method: false
|
|
184
|
+
});
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const value = readExpression(text, index + 1);
|
|
188
|
+
if (value == null) return null;
|
|
189
|
+
properties.push({
|
|
190
|
+
key: key.name,
|
|
191
|
+
value: value.text,
|
|
192
|
+
spread: false,
|
|
193
|
+
method: false
|
|
194
|
+
});
|
|
195
|
+
index = value.end;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
function readPropertyKey(source, start) {
|
|
200
|
+
const index = skipWhitespaceAndComments(source, start);
|
|
201
|
+
const char = source[index];
|
|
202
|
+
if (char === "'" || char === '"') {
|
|
203
|
+
const end = skipQuotedString(source, index);
|
|
204
|
+
const raw = source.slice(index, end);
|
|
205
|
+
return { name: staticStringValue(raw), raw, start: index, end };
|
|
206
|
+
}
|
|
207
|
+
if (char === "[") {
|
|
208
|
+
const computed = readBalanced(source, index, "[", "]");
|
|
209
|
+
if (computed == null) return null;
|
|
210
|
+
return { name: null, raw: computed.text, start: index, end: computed.end };
|
|
211
|
+
}
|
|
212
|
+
if (char != null && isIdentStart(char)) {
|
|
213
|
+
let end = index + 1;
|
|
214
|
+
while (end < source.length && isIdentPart(source[end])) end += 1;
|
|
215
|
+
const raw = source.slice(index, end);
|
|
216
|
+
return { name: raw, raw, start: index, end };
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
function readExpression(source, start) {
|
|
221
|
+
const index = skipWhitespaceAndComments(source, start);
|
|
222
|
+
const balanced = readUntilSeparator(source, index);
|
|
223
|
+
if (balanced == null) return null;
|
|
224
|
+
return { text: source.slice(index, balanced), end: balanced };
|
|
225
|
+
}
|
|
226
|
+
function readUntilSeparator(source, start) {
|
|
227
|
+
let index = start;
|
|
228
|
+
let paren = 0;
|
|
229
|
+
let brace = 0;
|
|
230
|
+
let bracket = 0;
|
|
231
|
+
while (index < source.length) {
|
|
232
|
+
const char = source[index];
|
|
233
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
234
|
+
index = skipLineComment(source, index);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
238
|
+
index = skipBlockComment(source, index);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (char === "'" || char === '"') {
|
|
242
|
+
index = skipQuotedString(source, index);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (char === "`") {
|
|
246
|
+
index = skipTemplate(source, index, []);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (char === "(") paren += 1;
|
|
250
|
+
else if (char === ")") {
|
|
251
|
+
if (paren === 0) return index;
|
|
252
|
+
paren -= 1;
|
|
253
|
+
} else if (char === "{") brace += 1;
|
|
254
|
+
else if (char === "}") {
|
|
255
|
+
if (brace === 0 && paren === 0 && bracket === 0) return index;
|
|
256
|
+
brace -= 1;
|
|
257
|
+
} else if (char === "[") bracket += 1;
|
|
258
|
+
else if (char === "]") {
|
|
259
|
+
if (bracket === 0) return index;
|
|
260
|
+
bracket -= 1;
|
|
261
|
+
} else if (char === "," && paren === 0 && brace === 0 && bracket === 0) {
|
|
262
|
+
return index;
|
|
263
|
+
}
|
|
264
|
+
index += 1;
|
|
265
|
+
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
function skipMethod(source, openParen) {
|
|
269
|
+
const params = readBalanced(source, openParen, "(", ")");
|
|
270
|
+
if (params == null) return null;
|
|
271
|
+
const bodyAt = skipWhitespaceAndComments(source, params.end);
|
|
272
|
+
if (source[bodyAt] !== "{") return null;
|
|
273
|
+
const body = readBalanced(source, bodyAt, "{", "}");
|
|
274
|
+
return body?.end ?? null;
|
|
275
|
+
}
|
|
276
|
+
function readCallArguments(source, openParen) {
|
|
277
|
+
const args = [];
|
|
278
|
+
let index = openParen + 1;
|
|
279
|
+
let argStart = index;
|
|
280
|
+
let paren = 1;
|
|
281
|
+
let brace = 0;
|
|
282
|
+
let bracket = 0;
|
|
283
|
+
while (index < source.length) {
|
|
284
|
+
const char = source[index];
|
|
285
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
286
|
+
index = skipLineComment(source, index);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
290
|
+
index = skipBlockComment(source, index);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (char === "'" || char === '"') {
|
|
294
|
+
index = skipQuotedString(source, index);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (char === "`") {
|
|
298
|
+
index = skipTemplate(source, index, []);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (char === "(") paren += 1;
|
|
302
|
+
else if (char === ")") {
|
|
303
|
+
paren -= 1;
|
|
304
|
+
if (paren === 0) {
|
|
305
|
+
args.push(source.slice(argStart, index));
|
|
306
|
+
return { args };
|
|
307
|
+
}
|
|
308
|
+
} else if (char === "{") brace += 1;
|
|
309
|
+
else if (char === "}") brace -= 1;
|
|
310
|
+
else if (char === "[") bracket += 1;
|
|
311
|
+
else if (char === "]") bracket -= 1;
|
|
312
|
+
else if (char === "," && paren === 1 && brace === 0 && bracket === 0) {
|
|
313
|
+
args.push(source.slice(argStart, index));
|
|
314
|
+
argStart = index + 1;
|
|
315
|
+
}
|
|
316
|
+
index += 1;
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
function readBalanced(source, openIndex, open, close) {
|
|
321
|
+
let depth = 0;
|
|
322
|
+
let index = openIndex;
|
|
323
|
+
while (index < source.length) {
|
|
324
|
+
const char = source[index];
|
|
325
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
326
|
+
index = skipLineComment(source, index);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
330
|
+
index = skipBlockComment(source, index);
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (char === "'" || char === '"') {
|
|
334
|
+
index = skipQuotedString(source, index);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (char === "`") {
|
|
338
|
+
index = skipTemplate(source, index, []);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (char === open) depth += 1;
|
|
342
|
+
else if (char === close) {
|
|
343
|
+
depth -= 1;
|
|
344
|
+
if (depth === 0) {
|
|
345
|
+
return { text: source.slice(openIndex, index + 1), end: index + 1 };
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
index += 1;
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
function isStaticExpression(expression) {
|
|
353
|
+
const text = expression.trim();
|
|
354
|
+
if (isLiteral(text)) return true;
|
|
355
|
+
const stringify = matchCallee(text, "JSON.stringify");
|
|
356
|
+
if (stringify != null) {
|
|
357
|
+
const data = stringify.args[0];
|
|
358
|
+
return data != null && stringify.args.slice(1).every((arg) => isLiteral(arg.trim())) && isStaticData(data);
|
|
359
|
+
}
|
|
360
|
+
const params = matchNewCallee(text, "URLSearchParams");
|
|
361
|
+
if (params != null) {
|
|
362
|
+
if (params.args.length === 0) return true;
|
|
363
|
+
const data = params.args[0];
|
|
364
|
+
return data != null && params.args.length === 1 && isStaticData(data);
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
function isStaticData(expression) {
|
|
369
|
+
const text = expression.trim();
|
|
370
|
+
if (isLiteral(text)) return true;
|
|
371
|
+
if (text.startsWith("{")) {
|
|
372
|
+
const closed = readBalanced(text, 0, "{", "}");
|
|
373
|
+
if (closed == null || closed.end !== text.length) return false;
|
|
374
|
+
const properties = readObjectProperties(text);
|
|
375
|
+
if (properties == null) return false;
|
|
376
|
+
return properties.every(
|
|
377
|
+
(property) => !property.spread && !property.method && property.key != null && isStaticData(property.value)
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
if (text.startsWith("[")) {
|
|
381
|
+
const closed = readBalanced(text, 0, "[", "]");
|
|
382
|
+
if (closed == null || closed.end !== text.length) return false;
|
|
383
|
+
const elements = readArrayElements(text);
|
|
384
|
+
if (elements == null) return false;
|
|
385
|
+
return elements.every((element) => isStaticData(element));
|
|
386
|
+
}
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
function readArrayElements(source) {
|
|
390
|
+
const text = source.trim();
|
|
391
|
+
if (!text.startsWith("[")) return null;
|
|
392
|
+
const elements = [];
|
|
393
|
+
let index = 1;
|
|
394
|
+
while (index < text.length) {
|
|
395
|
+
index = skipWhitespaceAndComments(text, index);
|
|
396
|
+
if (text[index] === "]") return elements;
|
|
397
|
+
if (text[index] === ",") {
|
|
398
|
+
index += 1;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (text.startsWith("...", index)) return null;
|
|
402
|
+
const value = readExpression(text, index);
|
|
403
|
+
if (value == null) return null;
|
|
404
|
+
elements.push(value.text);
|
|
405
|
+
index = value.end;
|
|
406
|
+
}
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
function isLiteral(expression) {
|
|
410
|
+
const text = expression.trim();
|
|
411
|
+
if (/^(?:null|undefined|true|false|-?\d+(?:\.\d+)?)$/.test(text)) return true;
|
|
412
|
+
if (isPlainTemplate(text)) return true;
|
|
413
|
+
return staticStringValue(text) != null && (text.startsWith("'") || text.startsWith('"'));
|
|
414
|
+
}
|
|
415
|
+
function staticStringValue(expression) {
|
|
416
|
+
const text = expression.trim();
|
|
417
|
+
if (isPlainTemplate(text)) return text.slice(1, -1);
|
|
418
|
+
if (text.startsWith("'") && text.endsWith("'") || text.startsWith('"') && text.endsWith('"')) {
|
|
419
|
+
if (text.length < 2) return null;
|
|
420
|
+
const body = text.slice(1, -1);
|
|
421
|
+
if (body.includes(text[0]) || body.includes("\n")) return null;
|
|
422
|
+
return body.replace(/\\(.)/g, "$1");
|
|
423
|
+
}
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
function isPlainTemplate(expression) {
|
|
427
|
+
const text = expression.trim();
|
|
428
|
+
return text.startsWith("`") && text.endsWith("`") && !text.slice(1, -1).includes("${");
|
|
429
|
+
}
|
|
430
|
+
function matchCallee(expression, callee) {
|
|
431
|
+
const text = expression.trim();
|
|
432
|
+
if (!text.startsWith(callee)) return null;
|
|
433
|
+
const open = skipWhitespaceAndComments(text, callee.length);
|
|
434
|
+
if (text[open] !== "(") return null;
|
|
435
|
+
const call = readCallArguments(text, open);
|
|
436
|
+
if (call == null) return null;
|
|
437
|
+
const end = skipWhitespaceAndComments(text, endOfCall(text, open));
|
|
438
|
+
if (end !== text.length) return null;
|
|
439
|
+
return call;
|
|
440
|
+
}
|
|
441
|
+
function matchNewCallee(expression, name) {
|
|
442
|
+
const text = expression.trim();
|
|
443
|
+
if (!text.startsWith("new")) return null;
|
|
444
|
+
const nameAt = skipWhitespaceAndComments(text, "new".length);
|
|
445
|
+
if (!text.startsWith(name, nameAt)) return null;
|
|
446
|
+
return matchCallee(text.slice(nameAt), name);
|
|
447
|
+
}
|
|
448
|
+
function endOfCall(source, openParen) {
|
|
449
|
+
const args = readCallArguments(source, openParen);
|
|
450
|
+
if (args == null) return openParen;
|
|
451
|
+
let index = openParen;
|
|
452
|
+
let paren = 0;
|
|
453
|
+
while (index < source.length) {
|
|
454
|
+
const char = source[index];
|
|
455
|
+
if (char === "'" || char === '"') {
|
|
456
|
+
index = skipQuotedString(source, index);
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (char === "`") {
|
|
460
|
+
index = skipTemplate(source, index, []);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (char === "(") paren += 1;
|
|
464
|
+
else if (char === ")") {
|
|
465
|
+
paren -= 1;
|
|
466
|
+
if (paren === 0) return index + 1;
|
|
467
|
+
}
|
|
468
|
+
index += 1;
|
|
469
|
+
}
|
|
470
|
+
return source.length;
|
|
471
|
+
}
|
|
472
|
+
function skipTemplate(source, start, calls) {
|
|
473
|
+
let index = start + 1;
|
|
474
|
+
while (index < source.length) {
|
|
475
|
+
const char = source[index];
|
|
476
|
+
if (char === "\\") {
|
|
477
|
+
index += 2;
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (char === "`") return index + 1;
|
|
481
|
+
if (char === "$" && source[index + 1] === "{") {
|
|
482
|
+
index = scanCode(source, index + 2, "brace", calls);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
index += 1;
|
|
486
|
+
}
|
|
487
|
+
return index;
|
|
488
|
+
}
|
|
489
|
+
function skipQuotedString(source, start) {
|
|
490
|
+
const quote = source[start];
|
|
491
|
+
let index = start + 1;
|
|
492
|
+
while (index < source.length) {
|
|
493
|
+
const char = source[index];
|
|
494
|
+
if (char === "\\") {
|
|
495
|
+
index += 2;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (char === quote) return index + 1;
|
|
499
|
+
if (char === "\n") return index;
|
|
500
|
+
index += 1;
|
|
501
|
+
}
|
|
502
|
+
return index;
|
|
503
|
+
}
|
|
504
|
+
function skipLineComment(source, start) {
|
|
505
|
+
const newline = source.indexOf("\n", start);
|
|
506
|
+
return newline === -1 ? source.length : newline + 1;
|
|
507
|
+
}
|
|
508
|
+
function skipBlockComment(source, start) {
|
|
509
|
+
const end = source.indexOf("*/", start + 2);
|
|
510
|
+
return end === -1 ? source.length : end + 2;
|
|
511
|
+
}
|
|
512
|
+
function skipWhitespaceAndComments(source, start) {
|
|
513
|
+
let index = start;
|
|
514
|
+
while (index < source.length) {
|
|
515
|
+
const char = source[index];
|
|
516
|
+
if (isWhitespace(char)) {
|
|
517
|
+
index += 1;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
521
|
+
index = skipLineComment(source, index);
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
525
|
+
index = skipBlockComment(source, index);
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
return index;
|
|
531
|
+
}
|
|
532
|
+
function lineAt(source, index) {
|
|
533
|
+
let line = 1;
|
|
534
|
+
for (let cursor = 0; cursor < index && cursor < source.length; cursor += 1) {
|
|
535
|
+
if (source[cursor] === "\n") line += 1;
|
|
536
|
+
}
|
|
537
|
+
return line;
|
|
538
|
+
}
|
|
539
|
+
function isWhitespace(char) {
|
|
540
|
+
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
541
|
+
}
|
|
542
|
+
function isIdentStart(char) {
|
|
543
|
+
return /[A-Za-z_$]/.test(char);
|
|
544
|
+
}
|
|
545
|
+
function isIdentPart(char) {
|
|
546
|
+
return /[A-Za-z0-9_$]/.test(char);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/fetch-body-package-scan.ts
|
|
550
|
+
import { readFile, stat } from "node:fs/promises";
|
|
551
|
+
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
552
|
+
import { transform } from "esbuild";
|
|
553
|
+
var esModuleLexerReady = init();
|
|
554
|
+
var sourceExtensions = [
|
|
555
|
+
".ts",
|
|
556
|
+
".tsx",
|
|
557
|
+
".mts",
|
|
558
|
+
".cts",
|
|
559
|
+
".js",
|
|
560
|
+
".mjs",
|
|
561
|
+
".cjs",
|
|
562
|
+
".jsx"
|
|
563
|
+
];
|
|
564
|
+
var maxModules = 200;
|
|
565
|
+
async function findPackageFetchBodyWarnings(input) {
|
|
566
|
+
await esModuleLexerReady;
|
|
567
|
+
const hits = [];
|
|
568
|
+
const seen = /* @__PURE__ */ new Set();
|
|
569
|
+
const queue = [input.entryPath];
|
|
570
|
+
while (queue.length > 0 && seen.size < maxModules) {
|
|
571
|
+
const resolved = await resolveSourceFile(queue.pop());
|
|
572
|
+
if (resolved == null || seen.has(resolved)) continue;
|
|
573
|
+
const rel = relative(input.packageRoot, resolved).split("\\").join("/");
|
|
574
|
+
if (rel.startsWith("..") || rel.split("/").includes("node_modules") || isTestModule(rel)) {
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
seen.add(resolved);
|
|
578
|
+
let source;
|
|
579
|
+
try {
|
|
580
|
+
source = await readFile(resolved, "utf8");
|
|
581
|
+
} catch {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
for (const hit of findFetchBodiesMissingSecretResolution(source)) {
|
|
585
|
+
hits.push({ path: rel, line: hit.line });
|
|
586
|
+
}
|
|
587
|
+
let imports;
|
|
588
|
+
try {
|
|
589
|
+
imports = parse(await lexableModuleSource(resolved, source))[0];
|
|
590
|
+
} catch {
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
for (const im of imports) {
|
|
594
|
+
if (im.type === "dynamic" || im.typeOnly === true) continue;
|
|
595
|
+
const specifier = im.specifier;
|
|
596
|
+
if (typeof specifier !== "string" || !specifier.startsWith(".")) continue;
|
|
597
|
+
queue.push(resolve(dirname(resolved), specifier));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return hits;
|
|
601
|
+
}
|
|
602
|
+
function moduleLoaderForPath(path) {
|
|
603
|
+
switch (extname(path).toLowerCase()) {
|
|
604
|
+
case ".ts":
|
|
605
|
+
case ".mts":
|
|
606
|
+
case ".cts":
|
|
607
|
+
return "ts";
|
|
608
|
+
case ".tsx":
|
|
609
|
+
return "tsx";
|
|
610
|
+
case ".jsx":
|
|
611
|
+
return "jsx";
|
|
612
|
+
default:
|
|
613
|
+
return "js";
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async function lexableModuleSource(path, source) {
|
|
617
|
+
const loader = moduleLoaderForPath(path);
|
|
618
|
+
if (loader === "js") return source;
|
|
619
|
+
const result = await transform(source, { loader, format: "esm" });
|
|
620
|
+
return result.code;
|
|
621
|
+
}
|
|
622
|
+
function isTestModule(path) {
|
|
623
|
+
return /\.(?:test|spec)\.[cm]?[jt]sx?$/.test(path);
|
|
624
|
+
}
|
|
625
|
+
async function resolveSourceFile(absPath) {
|
|
626
|
+
const candidates = [absPath];
|
|
627
|
+
if (extname(absPath) === "") {
|
|
628
|
+
for (const ext of sourceExtensions) {
|
|
629
|
+
candidates.push(`${absPath}${ext}`);
|
|
630
|
+
candidates.push(join(absPath, `index${ext}`));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
for (const candidate of candidates) {
|
|
634
|
+
try {
|
|
635
|
+
const info = await stat(candidate);
|
|
636
|
+
if (info.isFile()) return candidate;
|
|
637
|
+
} catch {
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// ../shared/src/package-app-host-label.ts
|
|
644
|
+
var packageAppHostLabelSeparator = "--";
|
|
645
|
+
var packageAppHostLabelMaxLength = 63;
|
|
646
|
+
var packageAppHostLabelReservedLeaves = /* @__PURE__ */ new Set(["xn"]);
|
|
647
|
+
function isPackageAppHostLabelReservedPackageLeaf(leaf) {
|
|
648
|
+
return packageAppHostLabelReservedLeaves.has(leaf.trim().toLowerCase());
|
|
649
|
+
}
|
|
650
|
+
function buildPackageAppHostLabel(input) {
|
|
651
|
+
return `${input.leaf.trim().toLowerCase()}${packageAppHostLabelSeparator}${input.handle.trim().toLowerCase()}`;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// ../shared/src/public-urls.ts
|
|
655
|
+
function buildUsernamePathPrefix(username) {
|
|
656
|
+
return `/@${encodeURIComponent(username.trim())}`;
|
|
657
|
+
}
|
|
658
|
+
function buildRestPathSuffix(restPath) {
|
|
659
|
+
const trimmed = restPath?.trim();
|
|
660
|
+
return trimmed ? `/${trimmed.replace(/^\/+/, "")}` : "";
|
|
661
|
+
}
|
|
662
|
+
function buildPackageAppPath(input) {
|
|
663
|
+
return `${buildUsernamePathPrefix(input.username)}/packages/${encodeURIComponent(
|
|
664
|
+
input.kodyId.trim()
|
|
665
|
+
)}${buildRestPathSuffix(input.restPath)}`;
|
|
666
|
+
}
|
|
667
|
+
var packageAppOpenPathSegment = "open";
|
|
668
|
+
var packageAppHostEntryQueryParam = "__kody_app_host";
|
|
669
|
+
function buildPackageAppOpenPath(input) {
|
|
670
|
+
const afterOpen = buildRestPathSuffix(input.restPath);
|
|
671
|
+
return `${buildPackageAppPath({
|
|
672
|
+
username: input.username,
|
|
673
|
+
kodyId: input.kodyId
|
|
674
|
+
})}/${packageAppOpenPathSegment}${afterOpen}`;
|
|
675
|
+
}
|
|
676
|
+
var dnsSafeUsernamePattern = /^(?![a-z0-9-]*--)[a-z0-9](?:[a-z0-9-]{1,30}[a-z0-9])$/;
|
|
677
|
+
var dnsSafeUsernamePatternSource = dnsSafeUsernamePattern.source.slice(
|
|
678
|
+
1,
|
|
679
|
+
-1
|
|
680
|
+
);
|
|
681
|
+
function isDnsSafeUsername(username) {
|
|
682
|
+
return dnsSafeUsernamePattern.test(username.trim());
|
|
683
|
+
}
|
|
684
|
+
function buildPackageAppSubdomainOrigin(input) {
|
|
685
|
+
const username = input.username.trim().toLowerCase();
|
|
686
|
+
if (!username) {
|
|
687
|
+
throw new Error("Username is required to build a package-app subdomain.");
|
|
688
|
+
}
|
|
689
|
+
const url = new URL(input.packageAppOrigin);
|
|
690
|
+
url.hostname = `${username}.${url.hostname}`;
|
|
691
|
+
return url.origin;
|
|
692
|
+
}
|
|
693
|
+
var packageAppHostLabelLeafPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
694
|
+
function parsePackageAppHostLabel(label) {
|
|
695
|
+
if (label.length > packageAppHostLabelMaxLength) return null;
|
|
696
|
+
const separatorIndex = label.indexOf(packageAppHostLabelSeparator);
|
|
697
|
+
if (separatorIndex <= 0) return null;
|
|
698
|
+
const leaf = label.slice(0, separatorIndex);
|
|
699
|
+
const handle = label.slice(
|
|
700
|
+
separatorIndex + packageAppHostLabelSeparator.length
|
|
701
|
+
);
|
|
702
|
+
if (!packageAppHostLabelLeafPattern.test(leaf)) return null;
|
|
703
|
+
if (isPackageAppHostLabelReservedPackageLeaf(leaf)) return null;
|
|
704
|
+
if (!dnsSafeUsernamePattern.test(handle)) return null;
|
|
705
|
+
return { leaf, handle };
|
|
706
|
+
}
|
|
707
|
+
function isProfilePackage(input) {
|
|
708
|
+
const username = input.username.trim().toLowerCase();
|
|
709
|
+
return username !== "" && input.kodyId === username;
|
|
710
|
+
}
|
|
711
|
+
function buildPackageAppRootOrigin(input) {
|
|
712
|
+
if (!isProfilePackage(input)) return buildPackageAppHostOrigin(input);
|
|
713
|
+
if (!isDnsSafeUsername(input.username.toLowerCase())) return null;
|
|
714
|
+
return buildPackageAppSubdomainOrigin(input);
|
|
715
|
+
}
|
|
716
|
+
function buildPackageAppHostOrigin(input) {
|
|
717
|
+
const label = buildPackageAppHostLabel({
|
|
718
|
+
leaf: input.kodyId,
|
|
719
|
+
handle: input.username
|
|
720
|
+
});
|
|
721
|
+
if (!parsePackageAppHostLabel(label)) return null;
|
|
722
|
+
const url = new URL(input.packageAppOrigin);
|
|
723
|
+
url.hostname = `${label}.${url.hostname}`;
|
|
724
|
+
return url.origin;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/dev/dev-app-origin.ts
|
|
728
|
+
function localUsernameFor(manifest) {
|
|
729
|
+
const scope = /^@([a-z0-9][a-z0-9-]*)\//i.exec(manifest.name)?.[1];
|
|
730
|
+
return (scope ?? "dev").toLowerCase();
|
|
731
|
+
}
|
|
732
|
+
function devPackageAppOrigin(input) {
|
|
733
|
+
const packageAppOrigin = `http://localhost:${input.port}`;
|
|
734
|
+
if (!input.appBasePath) {
|
|
735
|
+
return buildPackageAppRootOrigin({
|
|
736
|
+
packageAppOrigin,
|
|
737
|
+
username: input.username,
|
|
738
|
+
kodyId: input.kodyId
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
if (!isDnsSafeUsername(input.username)) return null;
|
|
742
|
+
return buildPackageAppSubdomainOrigin({
|
|
743
|
+
packageAppOrigin,
|
|
744
|
+
username: input.username
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// src/package-check-files.ts
|
|
749
|
+
import { execFile } from "node:child_process";
|
|
750
|
+
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
751
|
+
import { isAbsolute, join as join2, relative as relative2, sep } from "node:path";
|
|
752
|
+
import { promisify } from "node:util";
|
|
753
|
+
import ignore from "ignore";
|
|
754
|
+
var execFileAsync = promisify(execFile);
|
|
755
|
+
var skippedDirectories = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
756
|
+
async function listGitFiles(root) {
|
|
757
|
+
try {
|
|
758
|
+
const { stdout } = await execFileAsync(
|
|
759
|
+
"git",
|
|
760
|
+
["ls-files", "-z", "--cached", "--others", "--exclude-standard"],
|
|
761
|
+
{ cwd: root, maxBuffer: 64 * 1024 * 1024 }
|
|
762
|
+
);
|
|
763
|
+
return stdout.split("\0").filter((path) => path.length > 0);
|
|
764
|
+
} catch {
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
async function walkFiles(root, dir = root) {
|
|
769
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
770
|
+
const files = [];
|
|
771
|
+
for (const entry of entries) {
|
|
772
|
+
if (entry.isDirectory()) {
|
|
773
|
+
if (skippedDirectories.has(entry.name)) continue;
|
|
774
|
+
files.push(...await walkFiles(root, join2(dir, entry.name)));
|
|
775
|
+
} else if (entry.isFile()) {
|
|
776
|
+
files.push(relative2(root, join2(dir, entry.name)).split(sep).join("/"));
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return files;
|
|
780
|
+
}
|
|
781
|
+
var kodyIgnoreFileName = ".kodyignore";
|
|
782
|
+
var neverKodyIgnored = /* @__PURE__ */ new Set(["package.json", kodyIgnoreFileName]);
|
|
783
|
+
function createKodyIgnoreMatcher(content) {
|
|
784
|
+
if (content == null || content.trim() === "") return null;
|
|
785
|
+
const matcher = ignore().add(content);
|
|
786
|
+
return (relativePath) => {
|
|
787
|
+
const path = relativePath.replace(/^\/+/, "");
|
|
788
|
+
if (path === "" || neverKodyIgnored.has(path)) return false;
|
|
789
|
+
try {
|
|
790
|
+
return matcher.ignores(path);
|
|
791
|
+
} catch {
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
async function readKodyIgnore(root) {
|
|
797
|
+
try {
|
|
798
|
+
return await readFile2(join2(root, kodyIgnoreFileName), "utf8");
|
|
799
|
+
} catch {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async function listPackageCheckPaths(root) {
|
|
804
|
+
const paths = await listGitFiles(root) ?? await walkFiles(root);
|
|
805
|
+
const isKodyIgnored = createKodyIgnoreMatcher(await readKodyIgnore(root));
|
|
806
|
+
return paths.filter(
|
|
807
|
+
(path) => !path.split("/").some((segment) => skippedDirectories.has(segment)) && !isKodyIgnored?.(path)
|
|
808
|
+
).sort();
|
|
809
|
+
}
|
|
810
|
+
function unpublishedBundleInputPaths(input) {
|
|
811
|
+
const missing = [];
|
|
812
|
+
for (const absolute of input.absoluteInputs) {
|
|
813
|
+
const rel = relative2(input.packageRoot, absolute);
|
|
814
|
+
if (!rel || rel.startsWith(`..${sep}`) || rel === ".." || isAbsolute(rel)) {
|
|
815
|
+
missing.push(rel.split(sep).join("/") || absolute);
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
const posix = rel.split(sep).join("/");
|
|
819
|
+
if (!input.snapshotPaths.has(posix)) {
|
|
820
|
+
missing.push(posix);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return missing;
|
|
824
|
+
}
|
|
825
|
+
function formatUnpublishedBundleInputMessage(relativePath, options) {
|
|
826
|
+
const base = `${relativePath} is imported but will not be in the published snapshot (gitignored, untracked, or matched by .kodyignore). Commit it and keep it out of .kodyignore, or generate it somewhere publish can see.`;
|
|
827
|
+
if (options?.hasPrebuild === true) {
|
|
828
|
+
return `${base} Note: kody.dev.prebuild runs only in \`kody dev\`; publish builds the git snapshot, so commit generated output.`;
|
|
829
|
+
}
|
|
830
|
+
return base;
|
|
831
|
+
}
|
|
832
|
+
var utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
833
|
+
async function collectPackageCheckFiles(root) {
|
|
834
|
+
const paths = await listPackageCheckPaths(root);
|
|
835
|
+
const files = {};
|
|
836
|
+
const binaryFiles = {};
|
|
837
|
+
const binaryContents = {};
|
|
838
|
+
for (const path of paths) {
|
|
839
|
+
let bytes;
|
|
840
|
+
try {
|
|
841
|
+
bytes = await readFile2(join2(root, path));
|
|
842
|
+
} catch {
|
|
843
|
+
continue;
|
|
844
|
+
}
|
|
845
|
+
try {
|
|
846
|
+
files[path] = utf8.decode(bytes);
|
|
847
|
+
} catch {
|
|
848
|
+
binaryFiles[path] = bytes.byteLength;
|
|
849
|
+
binaryContents[path] = bytes.toString("base64");
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return { files, binaryFiles, binaryContents };
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
export {
|
|
856
|
+
formatFetchBodySecretResolutionWarning,
|
|
857
|
+
findPackageFetchBodyWarnings,
|
|
858
|
+
lexableModuleSource,
|
|
859
|
+
packageAppHostEntryQueryParam,
|
|
860
|
+
buildPackageAppOpenPath,
|
|
861
|
+
localUsernameFor,
|
|
862
|
+
devPackageAppOrigin,
|
|
863
|
+
listPackageCheckPaths,
|
|
864
|
+
unpublishedBundleInputPaths,
|
|
865
|
+
formatUnpublishedBundleInputMessage,
|
|
866
|
+
collectPackageCheckFiles
|
|
867
|
+
};
|
|
868
|
+
//# sourceMappingURL=chunk-TB7NX637.js.map
|