@scarn/sdk 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-0y2fy5en.js +166 -0
- package/dist/chunk-3ctaaseb.js +1456 -0
- package/dist/chunk-4ggr8af6.js +30 -0
- package/dist/chunk-5zsavw98.js +91 -0
- package/dist/chunk-63f90zky.js +39 -0
- package/dist/chunk-700xe701.js +100 -0
- package/dist/chunk-ar6hcj1r.js +35 -0
- package/dist/chunk-cdanncng.js +74 -0
- package/dist/chunk-dp86pa6m.js +68 -0
- package/dist/chunk-e1h021kq.js +86 -0
- package/dist/chunk-gds7w7zh.js +330 -0
- package/dist/chunk-k4y5qt4y.js +14 -0
- package/dist/chunk-mz53r914.js +300 -0
- package/dist/chunk-ngy1fdcx.js +57 -0
- package/dist/chunk-p7yrcmqm.js +322 -0
- package/dist/chunk-rt9tq4j6.js +116 -0
- package/dist/chunk-skzxcba3.js +14282 -0
- package/dist/chunk-vfeytkqx.js +1687 -0
- package/dist/chunk-y2pv8d6a.js +162 -0
- package/dist/chunk-y64skrwp.js +17 -0
- package/dist/chunk-yjtaq94c.js +1094 -0
- package/dist/chunk-zm72ksz0.js +256 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +58 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +16 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +27 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
- package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
- package/dist/contracts/pipeline-document/index.d.ts +11 -0
- package/dist/contracts/pipeline-document/index.js +99 -0
- package/dist/contracts/pipeline-document/json.d.ts +35 -0
- package/dist/contracts/pipeline-document/routes.d.ts +16 -0
- package/dist/contracts/pipeline-document/schema.d.ts +780 -0
- package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
- package/dist/contracts/step-artifact-submissions.d.ts +71 -0
- package/dist/contracts/step-artifact-submissions.js +171 -0
- package/dist/defaults/atomic-json-file.d.ts +10 -0
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/config-file.d.ts +46 -0
- package/dist/defaults/home-dir.d.ts +3 -0
- package/dist/defaults/index.d.ts +12 -0
- package/dist/defaults/index.js +1240 -0
- package/dist/defaults/legacy-config-migration.d.ts +27 -0
- package/dist/defaults/load-push-defaults.d.ts +25 -0
- package/dist/defaults/project-config.d.ts +32 -0
- package/dist/defaults/project-ref.d.ts +34 -0
- package/dist/definitions/artifacts/artifact.d.ts +62 -0
- package/dist/definitions/artifacts/index.d.ts +1 -0
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
- package/dist/definitions/pipelines/index.d.ts +3 -0
- package/dist/definitions/pipelines/index.js +26 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
- package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
- package/dist/definitions/steps/compile-mcps.d.ts +34 -0
- package/dist/definitions/steps/define-code-step.d.ts +84 -0
- package/dist/definitions/steps/define-mcp.d.ts +79 -0
- package/dist/definitions/steps/define-step.d.ts +137 -0
- package/dist/definitions/steps/env.d.ts +136 -0
- package/dist/definitions/steps/index.d.ts +14 -0
- package/dist/definitions/steps/index.js +76 -0
- package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
- package/dist/definitions/steps/prompt-template.d.ts +24 -0
- package/dist/definitions/steps/repo.d.ts +67 -0
- package/dist/definitions/steps/runtime.d.ts +115 -0
- package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
- package/dist/definitions/steps/step-features.d.ts +109 -0
- package/dist/definitions/steps/step-handle.d.ts +25 -0
- package/dist/definitions/steps/step-ref.d.ts +19 -0
- package/dist/definitions/validation/index.d.ts +2 -0
- package/dist/definitions/validation/index.js +19 -0
- package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
- package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
- package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
- package/dist/definitions/validation/validate-env.d.ts +15 -0
- package/dist/definitions/validation/validate-repo.d.ts +13 -0
- package/dist/definitions/validation/validate-runtime.d.ts +12 -0
- package/dist/definitions/validation/validation-issue.d.ts +11 -0
- package/dist/devcontainer-config-path.d.ts +21 -0
- package/dist/devcontainer-config-path.js +15 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +37 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +127 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +8 -0
- package/dist/generated/client/types.gen.d.ts +117 -0
- package/dist/generated/client/utils.gen.d.ts +33 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +18 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +78 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +302 -0
- package/dist/generated/types.gen.d.ts +18375 -0
- package/dist/git-url/git-remote.d.ts +30 -0
- package/dist/git-url/git-repo-identity.d.ts +44 -0
- package/dist/git-url/git-repo-identity.js +161 -0
- package/dist/git-url/parse-git-host.d.ts +23 -0
- package/dist/health-checks.d.ts +169 -0
- package/dist/health-checks.js +21 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +296 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +12 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +15 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +31 -0
- package/dist/pipelines/chain.d.ts +7 -0
- package/dist/pipelines/compile-args.d.ts +12 -0
- package/dist/pipelines/compile-chain.d.ts +9 -0
- package/dist/pipelines/compile-checks.d.ts +16 -0
- package/dist/pipelines/compile-state.d.ts +30 -0
- package/dist/pipelines/condition-data.d.ts +78 -0
- package/dist/pipelines/conditions.d.ts +47 -0
- package/dist/pipelines/context.d.ts +16 -0
- package/dist/pipelines/define-pipeline.d.ts +32 -0
- package/dist/pipelines/each.d.ts +5 -0
- package/dist/pipelines/errors.d.ts +26 -0
- package/dist/pipelines/handles.d.ts +29 -0
- package/dist/pipelines/index.d.ts +18 -0
- package/dist/pipelines/index.js +83 -0
- package/dist/pipelines/model.d.ts +103 -0
- package/dist/pipelines/nodes.d.ts +54 -0
- package/dist/pipelines/ref-types.d.ts +54 -0
- package/dist/pipelines/refs.d.ts +80 -0
- package/dist/pipelines/registry.d.ts +12 -0
- package/dist/pipelines/source.d.ts +17 -0
- package/dist/pipelines/types.d.ts +160 -0
- package/dist/push/code-step-lookup.d.ts +32 -0
- package/dist/push/code-step-lookup.js +12 -0
- package/dist/push/collect-definitions.d.ts +70 -0
- package/dist/push/collect-pipeline-documents.d.ts +14 -0
- package/dist/push/index.d.ts +6 -0
- package/dist/push/index.js +327 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +25 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +10 -0
- package/dist/task-plane-client.d.ts +489 -0
- package/dist/z.d.ts +7 -0
- package/package.json +132 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
parseJsonc
|
|
4
|
+
} from "../chunk-rt9tq4j6.js";
|
|
5
|
+
import {
|
|
6
|
+
createScarnClient
|
|
7
|
+
} from "../chunk-700xe701.js";
|
|
8
|
+
import"../chunk-vfeytkqx.js";
|
|
9
|
+
import"../chunk-y64skrwp.js";
|
|
10
|
+
|
|
11
|
+
// src/defaults/auth-file.ts
|
|
12
|
+
import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync2, rmSync as rmSync2 } from "fs";
|
|
13
|
+
import { join as join2 } from "path";
|
|
14
|
+
|
|
15
|
+
// ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
16
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
17
|
+
const len = text.length;
|
|
18
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
19
|
+
function scanHexDigits(count, exact) {
|
|
20
|
+
let digits = 0;
|
|
21
|
+
let value2 = 0;
|
|
22
|
+
while (digits < count || !exact) {
|
|
23
|
+
let ch = text.charCodeAt(pos);
|
|
24
|
+
if (ch >= 48 && ch <= 57) {
|
|
25
|
+
value2 = value2 * 16 + ch - 48;
|
|
26
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
27
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
28
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
29
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
30
|
+
} else {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
pos++;
|
|
34
|
+
digits++;
|
|
35
|
+
}
|
|
36
|
+
if (digits < count) {
|
|
37
|
+
value2 = -1;
|
|
38
|
+
}
|
|
39
|
+
return value2;
|
|
40
|
+
}
|
|
41
|
+
function setPosition(newPosition) {
|
|
42
|
+
pos = newPosition;
|
|
43
|
+
value = "";
|
|
44
|
+
tokenOffset = 0;
|
|
45
|
+
token = 16;
|
|
46
|
+
scanError = 0;
|
|
47
|
+
}
|
|
48
|
+
function scanNumber() {
|
|
49
|
+
let start = pos;
|
|
50
|
+
if (text.charCodeAt(pos) === 48) {
|
|
51
|
+
pos++;
|
|
52
|
+
} else {
|
|
53
|
+
pos++;
|
|
54
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
55
|
+
pos++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
59
|
+
pos++;
|
|
60
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
61
|
+
pos++;
|
|
62
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
63
|
+
pos++;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
scanError = 3;
|
|
67
|
+
return text.substring(start, pos);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let end = pos;
|
|
71
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
72
|
+
pos++;
|
|
73
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
74
|
+
pos++;
|
|
75
|
+
}
|
|
76
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
77
|
+
pos++;
|
|
78
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
79
|
+
pos++;
|
|
80
|
+
}
|
|
81
|
+
end = pos;
|
|
82
|
+
} else {
|
|
83
|
+
scanError = 3;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return text.substring(start, end);
|
|
87
|
+
}
|
|
88
|
+
function scanString() {
|
|
89
|
+
let result = "", start = pos;
|
|
90
|
+
while (true) {
|
|
91
|
+
if (pos >= len) {
|
|
92
|
+
result += text.substring(start, pos);
|
|
93
|
+
scanError = 2;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
const ch = text.charCodeAt(pos);
|
|
97
|
+
if (ch === 34) {
|
|
98
|
+
result += text.substring(start, pos);
|
|
99
|
+
pos++;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (ch === 92) {
|
|
103
|
+
result += text.substring(start, pos);
|
|
104
|
+
pos++;
|
|
105
|
+
if (pos >= len) {
|
|
106
|
+
scanError = 2;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
const ch2 = text.charCodeAt(pos++);
|
|
110
|
+
switch (ch2) {
|
|
111
|
+
case 34:
|
|
112
|
+
result += '"';
|
|
113
|
+
break;
|
|
114
|
+
case 92:
|
|
115
|
+
result += "\\";
|
|
116
|
+
break;
|
|
117
|
+
case 47:
|
|
118
|
+
result += "/";
|
|
119
|
+
break;
|
|
120
|
+
case 98:
|
|
121
|
+
result += "\b";
|
|
122
|
+
break;
|
|
123
|
+
case 102:
|
|
124
|
+
result += "\f";
|
|
125
|
+
break;
|
|
126
|
+
case 110:
|
|
127
|
+
result += `
|
|
128
|
+
`;
|
|
129
|
+
break;
|
|
130
|
+
case 114:
|
|
131
|
+
result += "\r";
|
|
132
|
+
break;
|
|
133
|
+
case 116:
|
|
134
|
+
result += "\t";
|
|
135
|
+
break;
|
|
136
|
+
case 117:
|
|
137
|
+
const ch3 = scanHexDigits(4, true);
|
|
138
|
+
if (ch3 >= 0) {
|
|
139
|
+
result += String.fromCharCode(ch3);
|
|
140
|
+
} else {
|
|
141
|
+
scanError = 4;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
scanError = 5;
|
|
146
|
+
}
|
|
147
|
+
start = pos;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (ch >= 0 && ch <= 31) {
|
|
151
|
+
if (isLineBreak(ch)) {
|
|
152
|
+
result += text.substring(start, pos);
|
|
153
|
+
scanError = 2;
|
|
154
|
+
break;
|
|
155
|
+
} else {
|
|
156
|
+
scanError = 6;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
pos++;
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
function scanNext() {
|
|
164
|
+
value = "";
|
|
165
|
+
scanError = 0;
|
|
166
|
+
tokenOffset = pos;
|
|
167
|
+
lineStartOffset = lineNumber;
|
|
168
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
169
|
+
if (pos >= len) {
|
|
170
|
+
tokenOffset = len;
|
|
171
|
+
return token = 17;
|
|
172
|
+
}
|
|
173
|
+
let code = text.charCodeAt(pos);
|
|
174
|
+
if (isWhiteSpace(code)) {
|
|
175
|
+
do {
|
|
176
|
+
pos++;
|
|
177
|
+
value += String.fromCharCode(code);
|
|
178
|
+
code = text.charCodeAt(pos);
|
|
179
|
+
} while (isWhiteSpace(code));
|
|
180
|
+
return token = 15;
|
|
181
|
+
}
|
|
182
|
+
if (isLineBreak(code)) {
|
|
183
|
+
pos++;
|
|
184
|
+
value += String.fromCharCode(code);
|
|
185
|
+
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
186
|
+
pos++;
|
|
187
|
+
value += `
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
lineNumber++;
|
|
191
|
+
tokenLineStartOffset = pos;
|
|
192
|
+
return token = 14;
|
|
193
|
+
}
|
|
194
|
+
switch (code) {
|
|
195
|
+
case 123:
|
|
196
|
+
pos++;
|
|
197
|
+
return token = 1;
|
|
198
|
+
case 125:
|
|
199
|
+
pos++;
|
|
200
|
+
return token = 2;
|
|
201
|
+
case 91:
|
|
202
|
+
pos++;
|
|
203
|
+
return token = 3;
|
|
204
|
+
case 93:
|
|
205
|
+
pos++;
|
|
206
|
+
return token = 4;
|
|
207
|
+
case 58:
|
|
208
|
+
pos++;
|
|
209
|
+
return token = 6;
|
|
210
|
+
case 44:
|
|
211
|
+
pos++;
|
|
212
|
+
return token = 5;
|
|
213
|
+
case 34:
|
|
214
|
+
pos++;
|
|
215
|
+
value = scanString();
|
|
216
|
+
return token = 10;
|
|
217
|
+
case 47:
|
|
218
|
+
const start = pos - 1;
|
|
219
|
+
if (text.charCodeAt(pos + 1) === 47) {
|
|
220
|
+
pos += 2;
|
|
221
|
+
while (pos < len) {
|
|
222
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
pos++;
|
|
226
|
+
}
|
|
227
|
+
value = text.substring(start, pos);
|
|
228
|
+
return token = 12;
|
|
229
|
+
}
|
|
230
|
+
if (text.charCodeAt(pos + 1) === 42) {
|
|
231
|
+
pos += 2;
|
|
232
|
+
const safeLength = len - 1;
|
|
233
|
+
let commentClosed = false;
|
|
234
|
+
while (pos < safeLength) {
|
|
235
|
+
const ch = text.charCodeAt(pos);
|
|
236
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
237
|
+
pos += 2;
|
|
238
|
+
commentClosed = true;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
pos++;
|
|
242
|
+
if (isLineBreak(ch)) {
|
|
243
|
+
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
244
|
+
pos++;
|
|
245
|
+
}
|
|
246
|
+
lineNumber++;
|
|
247
|
+
tokenLineStartOffset = pos;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (!commentClosed) {
|
|
251
|
+
pos++;
|
|
252
|
+
scanError = 1;
|
|
253
|
+
}
|
|
254
|
+
value = text.substring(start, pos);
|
|
255
|
+
return token = 13;
|
|
256
|
+
}
|
|
257
|
+
value += String.fromCharCode(code);
|
|
258
|
+
pos++;
|
|
259
|
+
return token = 16;
|
|
260
|
+
case 45:
|
|
261
|
+
value += String.fromCharCode(code);
|
|
262
|
+
pos++;
|
|
263
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
264
|
+
return token = 16;
|
|
265
|
+
}
|
|
266
|
+
case 48:
|
|
267
|
+
case 49:
|
|
268
|
+
case 50:
|
|
269
|
+
case 51:
|
|
270
|
+
case 52:
|
|
271
|
+
case 53:
|
|
272
|
+
case 54:
|
|
273
|
+
case 55:
|
|
274
|
+
case 56:
|
|
275
|
+
case 57:
|
|
276
|
+
value += scanNumber();
|
|
277
|
+
return token = 11;
|
|
278
|
+
default:
|
|
279
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
280
|
+
pos++;
|
|
281
|
+
code = text.charCodeAt(pos);
|
|
282
|
+
}
|
|
283
|
+
if (tokenOffset !== pos) {
|
|
284
|
+
value = text.substring(tokenOffset, pos);
|
|
285
|
+
switch (value) {
|
|
286
|
+
case "true":
|
|
287
|
+
return token = 8;
|
|
288
|
+
case "false":
|
|
289
|
+
return token = 9;
|
|
290
|
+
case "null":
|
|
291
|
+
return token = 7;
|
|
292
|
+
}
|
|
293
|
+
return token = 16;
|
|
294
|
+
}
|
|
295
|
+
value += String.fromCharCode(code);
|
|
296
|
+
pos++;
|
|
297
|
+
return token = 16;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function isUnknownContentCharacter(code) {
|
|
301
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
switch (code) {
|
|
305
|
+
case 125:
|
|
306
|
+
case 93:
|
|
307
|
+
case 123:
|
|
308
|
+
case 91:
|
|
309
|
+
case 34:
|
|
310
|
+
case 58:
|
|
311
|
+
case 44:
|
|
312
|
+
case 47:
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
function scanNextNonTrivia() {
|
|
318
|
+
let result;
|
|
319
|
+
do {
|
|
320
|
+
result = scanNext();
|
|
321
|
+
} while (result >= 12 && result <= 15);
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
setPosition,
|
|
326
|
+
getPosition: () => pos,
|
|
327
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
328
|
+
getToken: () => token,
|
|
329
|
+
getTokenValue: () => value,
|
|
330
|
+
getTokenOffset: () => tokenOffset,
|
|
331
|
+
getTokenLength: () => pos - tokenOffset,
|
|
332
|
+
getTokenStartLine: () => lineStartOffset,
|
|
333
|
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
334
|
+
getTokenError: () => scanError
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function isWhiteSpace(ch) {
|
|
338
|
+
return ch === 32 || ch === 9;
|
|
339
|
+
}
|
|
340
|
+
function isLineBreak(ch) {
|
|
341
|
+
return ch === 10 || ch === 13;
|
|
342
|
+
}
|
|
343
|
+
function isDigit(ch) {
|
|
344
|
+
return ch >= 48 && ch <= 57;
|
|
345
|
+
}
|
|
346
|
+
var CharacterCodes;
|
|
347
|
+
(function(CharacterCodes2) {
|
|
348
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
349
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
350
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
351
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
352
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
353
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
354
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
355
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
356
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
357
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
358
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
359
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
360
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
361
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
362
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
363
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
364
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
365
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
366
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
367
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
368
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
369
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
370
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
371
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
372
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
373
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
374
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
375
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
376
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
377
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
378
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
379
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
380
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
381
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
382
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
383
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
384
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
385
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
386
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
387
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
388
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
389
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
390
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
391
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
392
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
393
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
394
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
395
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
396
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
397
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
398
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
399
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
400
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
401
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
402
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
403
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
404
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
405
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
406
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
407
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
408
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
409
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
410
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
411
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
412
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
413
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
414
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
415
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
416
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
417
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
418
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
419
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
420
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
421
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
422
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
423
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
424
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
425
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
426
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
427
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
428
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
429
|
+
|
|
430
|
+
// ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
431
|
+
var cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
432
|
+
return " ".repeat(index);
|
|
433
|
+
});
|
|
434
|
+
var maxCachedValues = 200;
|
|
435
|
+
var cachedBreakLinesWithSpaces = {
|
|
436
|
+
" ": {
|
|
437
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
438
|
+
return `
|
|
439
|
+
` + " ".repeat(index);
|
|
440
|
+
}),
|
|
441
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
442
|
+
return "\r" + " ".repeat(index);
|
|
443
|
+
}),
|
|
444
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
445
|
+
return `\r
|
|
446
|
+
` + " ".repeat(index);
|
|
447
|
+
})
|
|
448
|
+
},
|
|
449
|
+
"\t": {
|
|
450
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
451
|
+
return `
|
|
452
|
+
` + "\t".repeat(index);
|
|
453
|
+
}),
|
|
454
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
455
|
+
return "\r" + "\t".repeat(index);
|
|
456
|
+
}),
|
|
457
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
458
|
+
return `\r
|
|
459
|
+
` + "\t".repeat(index);
|
|
460
|
+
})
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
465
|
+
var ParseOptions;
|
|
466
|
+
(function(ParseOptions2) {
|
|
467
|
+
ParseOptions2.DEFAULT = {
|
|
468
|
+
allowTrailingComma: false
|
|
469
|
+
};
|
|
470
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
471
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
472
|
+
let currentProperty = null;
|
|
473
|
+
let currentParent = [];
|
|
474
|
+
const previousParents = [];
|
|
475
|
+
function onValue(value) {
|
|
476
|
+
if (Array.isArray(currentParent)) {
|
|
477
|
+
currentParent.push(value);
|
|
478
|
+
} else if (currentProperty !== null) {
|
|
479
|
+
currentParent[currentProperty] = value;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const visitor = {
|
|
483
|
+
onObjectBegin: () => {
|
|
484
|
+
const object = {};
|
|
485
|
+
onValue(object);
|
|
486
|
+
previousParents.push(currentParent);
|
|
487
|
+
currentParent = object;
|
|
488
|
+
currentProperty = null;
|
|
489
|
+
},
|
|
490
|
+
onObjectProperty: (name) => {
|
|
491
|
+
currentProperty = name;
|
|
492
|
+
},
|
|
493
|
+
onObjectEnd: () => {
|
|
494
|
+
currentParent = previousParents.pop();
|
|
495
|
+
},
|
|
496
|
+
onArrayBegin: () => {
|
|
497
|
+
const array = [];
|
|
498
|
+
onValue(array);
|
|
499
|
+
previousParents.push(currentParent);
|
|
500
|
+
currentParent = array;
|
|
501
|
+
currentProperty = null;
|
|
502
|
+
},
|
|
503
|
+
onArrayEnd: () => {
|
|
504
|
+
currentParent = previousParents.pop();
|
|
505
|
+
},
|
|
506
|
+
onLiteralValue: onValue,
|
|
507
|
+
onError: (error, offset, length) => {
|
|
508
|
+
errors.push({ error, offset, length });
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
visit(text, visitor, options);
|
|
512
|
+
return currentParent[0];
|
|
513
|
+
}
|
|
514
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
515
|
+
const _scanner = createScanner(text, false);
|
|
516
|
+
const _jsonPath = [];
|
|
517
|
+
let suppressedCallbacks = 0;
|
|
518
|
+
function toNoArgVisit(visitFunction) {
|
|
519
|
+
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
520
|
+
}
|
|
521
|
+
function toOneArgVisit(visitFunction) {
|
|
522
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
523
|
+
}
|
|
524
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
525
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
526
|
+
}
|
|
527
|
+
function toBeginVisit(visitFunction) {
|
|
528
|
+
return visitFunction ? () => {
|
|
529
|
+
if (suppressedCallbacks > 0) {
|
|
530
|
+
suppressedCallbacks++;
|
|
531
|
+
} else {
|
|
532
|
+
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
533
|
+
if (cbReturn === false) {
|
|
534
|
+
suppressedCallbacks = 1;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
} : () => true;
|
|
538
|
+
}
|
|
539
|
+
function toEndVisit(visitFunction) {
|
|
540
|
+
return visitFunction ? () => {
|
|
541
|
+
if (suppressedCallbacks > 0) {
|
|
542
|
+
suppressedCallbacks--;
|
|
543
|
+
}
|
|
544
|
+
if (suppressedCallbacks === 0) {
|
|
545
|
+
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
546
|
+
}
|
|
547
|
+
} : () => true;
|
|
548
|
+
}
|
|
549
|
+
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
550
|
+
const disallowComments = options && options.disallowComments;
|
|
551
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
552
|
+
function scanNext() {
|
|
553
|
+
while (true) {
|
|
554
|
+
const token = _scanner.scan();
|
|
555
|
+
switch (_scanner.getTokenError()) {
|
|
556
|
+
case 4:
|
|
557
|
+
handleError(14);
|
|
558
|
+
break;
|
|
559
|
+
case 5:
|
|
560
|
+
handleError(15);
|
|
561
|
+
break;
|
|
562
|
+
case 3:
|
|
563
|
+
handleError(13);
|
|
564
|
+
break;
|
|
565
|
+
case 1:
|
|
566
|
+
if (!disallowComments) {
|
|
567
|
+
handleError(11);
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
case 2:
|
|
571
|
+
handleError(12);
|
|
572
|
+
break;
|
|
573
|
+
case 6:
|
|
574
|
+
handleError(16);
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
switch (token) {
|
|
578
|
+
case 12:
|
|
579
|
+
case 13:
|
|
580
|
+
if (disallowComments) {
|
|
581
|
+
handleError(10);
|
|
582
|
+
} else {
|
|
583
|
+
onComment();
|
|
584
|
+
}
|
|
585
|
+
break;
|
|
586
|
+
case 16:
|
|
587
|
+
handleError(1);
|
|
588
|
+
break;
|
|
589
|
+
case 15:
|
|
590
|
+
case 14:
|
|
591
|
+
break;
|
|
592
|
+
default:
|
|
593
|
+
return token;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
598
|
+
onError(error);
|
|
599
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
600
|
+
let token = _scanner.getToken();
|
|
601
|
+
while (token !== 17) {
|
|
602
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
603
|
+
scanNext();
|
|
604
|
+
break;
|
|
605
|
+
} else if (skipUntil.indexOf(token) !== -1) {
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
token = scanNext();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function parseString(isValue) {
|
|
613
|
+
const value = _scanner.getTokenValue();
|
|
614
|
+
if (isValue) {
|
|
615
|
+
onLiteralValue(value);
|
|
616
|
+
} else {
|
|
617
|
+
onObjectProperty(value);
|
|
618
|
+
_jsonPath.push(value);
|
|
619
|
+
}
|
|
620
|
+
scanNext();
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
623
|
+
function parseLiteral() {
|
|
624
|
+
switch (_scanner.getToken()) {
|
|
625
|
+
case 11:
|
|
626
|
+
const tokenValue = _scanner.getTokenValue();
|
|
627
|
+
let value = Number(tokenValue);
|
|
628
|
+
if (isNaN(value)) {
|
|
629
|
+
handleError(2);
|
|
630
|
+
value = 0;
|
|
631
|
+
}
|
|
632
|
+
onLiteralValue(value);
|
|
633
|
+
break;
|
|
634
|
+
case 7:
|
|
635
|
+
onLiteralValue(null);
|
|
636
|
+
break;
|
|
637
|
+
case 8:
|
|
638
|
+
onLiteralValue(true);
|
|
639
|
+
break;
|
|
640
|
+
case 9:
|
|
641
|
+
onLiteralValue(false);
|
|
642
|
+
break;
|
|
643
|
+
default:
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
scanNext();
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
function parseProperty() {
|
|
650
|
+
if (_scanner.getToken() !== 10) {
|
|
651
|
+
handleError(3, [], [2, 5]);
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
parseString(false);
|
|
655
|
+
if (_scanner.getToken() === 6) {
|
|
656
|
+
onSeparator(":");
|
|
657
|
+
scanNext();
|
|
658
|
+
if (!parseValue()) {
|
|
659
|
+
handleError(4, [], [2, 5]);
|
|
660
|
+
}
|
|
661
|
+
} else {
|
|
662
|
+
handleError(5, [], [2, 5]);
|
|
663
|
+
}
|
|
664
|
+
_jsonPath.pop();
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
function parseObject() {
|
|
668
|
+
onObjectBegin();
|
|
669
|
+
scanNext();
|
|
670
|
+
let needsComma = false;
|
|
671
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
672
|
+
if (_scanner.getToken() === 5) {
|
|
673
|
+
if (!needsComma) {
|
|
674
|
+
handleError(4, [], []);
|
|
675
|
+
}
|
|
676
|
+
onSeparator(",");
|
|
677
|
+
scanNext();
|
|
678
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
} else if (needsComma) {
|
|
682
|
+
handleError(6, [], []);
|
|
683
|
+
}
|
|
684
|
+
if (!parseProperty()) {
|
|
685
|
+
handleError(4, [], [2, 5]);
|
|
686
|
+
}
|
|
687
|
+
needsComma = true;
|
|
688
|
+
}
|
|
689
|
+
onObjectEnd();
|
|
690
|
+
if (_scanner.getToken() !== 2) {
|
|
691
|
+
handleError(7, [2], []);
|
|
692
|
+
} else {
|
|
693
|
+
scanNext();
|
|
694
|
+
}
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
function parseArray() {
|
|
698
|
+
onArrayBegin();
|
|
699
|
+
scanNext();
|
|
700
|
+
let isFirstElement = true;
|
|
701
|
+
let needsComma = false;
|
|
702
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
703
|
+
if (_scanner.getToken() === 5) {
|
|
704
|
+
if (!needsComma) {
|
|
705
|
+
handleError(4, [], []);
|
|
706
|
+
}
|
|
707
|
+
onSeparator(",");
|
|
708
|
+
scanNext();
|
|
709
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
} else if (needsComma) {
|
|
713
|
+
handleError(6, [], []);
|
|
714
|
+
}
|
|
715
|
+
if (isFirstElement) {
|
|
716
|
+
_jsonPath.push(0);
|
|
717
|
+
isFirstElement = false;
|
|
718
|
+
} else {
|
|
719
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
720
|
+
}
|
|
721
|
+
if (!parseValue()) {
|
|
722
|
+
handleError(4, [], [4, 5]);
|
|
723
|
+
}
|
|
724
|
+
needsComma = true;
|
|
725
|
+
}
|
|
726
|
+
onArrayEnd();
|
|
727
|
+
if (!isFirstElement) {
|
|
728
|
+
_jsonPath.pop();
|
|
729
|
+
}
|
|
730
|
+
if (_scanner.getToken() !== 4) {
|
|
731
|
+
handleError(8, [4], []);
|
|
732
|
+
} else {
|
|
733
|
+
scanNext();
|
|
734
|
+
}
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
function parseValue() {
|
|
738
|
+
switch (_scanner.getToken()) {
|
|
739
|
+
case 3:
|
|
740
|
+
return parseArray();
|
|
741
|
+
case 1:
|
|
742
|
+
return parseObject();
|
|
743
|
+
case 10:
|
|
744
|
+
return parseString(true);
|
|
745
|
+
default:
|
|
746
|
+
return parseLiteral();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
scanNext();
|
|
750
|
+
if (_scanner.getToken() === 17) {
|
|
751
|
+
if (options.allowEmptyContent) {
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
handleError(4, [], []);
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
if (!parseValue()) {
|
|
758
|
+
handleError(4, [], []);
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
if (_scanner.getToken() !== 17) {
|
|
762
|
+
handleError(9, [], []);
|
|
763
|
+
}
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
|
|
768
|
+
var ScanError;
|
|
769
|
+
(function(ScanError2) {
|
|
770
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
771
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
772
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
773
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
774
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
775
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
776
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
777
|
+
})(ScanError || (ScanError = {}));
|
|
778
|
+
var SyntaxKind;
|
|
779
|
+
(function(SyntaxKind2) {
|
|
780
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
781
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
782
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
783
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
784
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
785
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
786
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
787
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
788
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
789
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
790
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
791
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
792
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
793
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
794
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
795
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
796
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
797
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
798
|
+
var parse2 = parse;
|
|
799
|
+
var ParseErrorCode;
|
|
800
|
+
(function(ParseErrorCode2) {
|
|
801
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
802
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
803
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
804
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
805
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
806
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
807
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
808
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
809
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
810
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
811
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
812
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
813
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
814
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
815
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
816
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
817
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
818
|
+
|
|
819
|
+
// src/defaults/atomic-json-file.ts
|
|
820
|
+
import {
|
|
821
|
+
chmodSync,
|
|
822
|
+
existsSync,
|
|
823
|
+
mkdirSync,
|
|
824
|
+
renameSync,
|
|
825
|
+
writeFileSync
|
|
826
|
+
} from "fs";
|
|
827
|
+
import { dirname } from "path";
|
|
828
|
+
var ensureFilePermissions = (filePath) => {
|
|
829
|
+
try {
|
|
830
|
+
chmodSync(filePath, 384);
|
|
831
|
+
} catch {}
|
|
832
|
+
};
|
|
833
|
+
function writeJsonFileAtomically(filePath, data) {
|
|
834
|
+
const parentDirectory = dirname(filePath);
|
|
835
|
+
if (!existsSync(parentDirectory)) {
|
|
836
|
+
mkdirSync(parentDirectory, { recursive: true });
|
|
837
|
+
}
|
|
838
|
+
const temporaryPath = `${filePath}.${String(process.pid)}.${String(Date.now())}.tmp`;
|
|
839
|
+
writeFileSync(temporaryPath, `${JSON.stringify(data, null, 2)}
|
|
840
|
+
`, {
|
|
841
|
+
encoding: "utf8",
|
|
842
|
+
mode: 384
|
|
843
|
+
});
|
|
844
|
+
ensureFilePermissions(temporaryPath);
|
|
845
|
+
renameSync(temporaryPath, filePath);
|
|
846
|
+
ensureFilePermissions(filePath);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/defaults/home-dir.ts
|
|
850
|
+
import { homedir } from "os";
|
|
851
|
+
var homeDirOverrideForTests;
|
|
852
|
+
function setHomeDirForTests(dir) {
|
|
853
|
+
homeDirOverrideForTests = dir;
|
|
854
|
+
}
|
|
855
|
+
function resolveHomeDir() {
|
|
856
|
+
return homeDirOverrideForTests ?? homedir();
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// src/defaults/legacy-config-migration.ts
|
|
860
|
+
import { existsSync as existsSync2, lstatSync, readFileSync, rmSync } from "fs";
|
|
861
|
+
import { join } from "path";
|
|
862
|
+
var legacyBareAuthFilePath = () => join(resolveHomeDir(), ".scarn");
|
|
863
|
+
var legacyJsonAuthFilePath = () => join(resolveHomeDir(), ".scarn.json");
|
|
864
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
865
|
+
function migrateLegacyConfigIfNeeded(input) {
|
|
866
|
+
if (input.authFileExists() && input.configFileExists())
|
|
867
|
+
return;
|
|
868
|
+
const legacyPath = existsSync2(legacyJsonAuthFilePath()) ? legacyJsonAuthFilePath() : legacyBareAuthFilePath();
|
|
869
|
+
if (!existsSync2(legacyPath) || !lstatSync(legacyPath).isFile())
|
|
870
|
+
return;
|
|
871
|
+
let parsed;
|
|
872
|
+
try {
|
|
873
|
+
parsed = JSON.parse(readFileSync(legacyPath, "utf8"));
|
|
874
|
+
} catch {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
if (!isPlainObject(parsed))
|
|
878
|
+
return;
|
|
879
|
+
rmSync(legacyPath, { force: true });
|
|
880
|
+
const otherLegacyPath = legacyPath === legacyJsonAuthFilePath() ? legacyBareAuthFilePath() : legacyJsonAuthFilePath();
|
|
881
|
+
if (existsSync2(otherLegacyPath) && lstatSync(otherLegacyPath).isFile()) {
|
|
882
|
+
rmSync(otherLegacyPath, { force: true });
|
|
883
|
+
}
|
|
884
|
+
if (!input.authFileExists()) {
|
|
885
|
+
const profiles = parsed["profiles"];
|
|
886
|
+
input.writeAuthFile(isPlainObject(profiles) ? profiles : {});
|
|
887
|
+
}
|
|
888
|
+
if (!input.configFileExists()) {
|
|
889
|
+
const anonymousId = parsed["anonymousId"];
|
|
890
|
+
const telemetryDisabled = parsed["telemetryDisabled"];
|
|
891
|
+
input.writeConfigFile({
|
|
892
|
+
anonymousId: typeof anonymousId === "string" ? anonymousId : undefined,
|
|
893
|
+
telemetryDisabled: typeof telemetryDisabled === "boolean" ? telemetryDisabled : undefined
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/defaults/auth-file.ts
|
|
899
|
+
var authFilePath = () => join2(resolveHomeDir(), ".scarn", "auth.jsonc");
|
|
900
|
+
var configFilePath = () => join2(resolveHomeDir(), ".scarn", "config.jsonc");
|
|
901
|
+
var MIGRATION_DEFAULT_ARTIFACT_RETENTION = {
|
|
902
|
+
localMaxBytes: 2 * 1024 ** 3,
|
|
903
|
+
localMaxAgeDays: 14
|
|
904
|
+
};
|
|
905
|
+
var emptyAuthFile = () => ({ profiles: {} });
|
|
906
|
+
function isAuthProfile(value) {
|
|
907
|
+
if (typeof value !== "object" || value === null)
|
|
908
|
+
return false;
|
|
909
|
+
const obj = value;
|
|
910
|
+
if (typeof obj["accessToken"] !== "string")
|
|
911
|
+
return false;
|
|
912
|
+
for (const key of ["userId", "email", "name"]) {
|
|
913
|
+
const v = obj[key];
|
|
914
|
+
if (v !== undefined && typeof v !== "string")
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
function isAuthFile(value) {
|
|
920
|
+
if (typeof value !== "object" || value === null)
|
|
921
|
+
return false;
|
|
922
|
+
const obj = value;
|
|
923
|
+
const profiles = obj["profiles"];
|
|
924
|
+
if (typeof profiles !== "object" || profiles === null)
|
|
925
|
+
return false;
|
|
926
|
+
for (const profile of Object.values(profiles)) {
|
|
927
|
+
if (!isAuthProfile(profile))
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
var getAuthFilePath = () => authFilePath();
|
|
933
|
+
var loadAuthFileFromPath = (filePath) => {
|
|
934
|
+
if (!existsSync3(filePath))
|
|
935
|
+
return emptyAuthFile();
|
|
936
|
+
if (!lstatSync2(filePath).isFile())
|
|
937
|
+
return emptyAuthFile();
|
|
938
|
+
const content = readFileSync2(filePath, "utf8");
|
|
939
|
+
if (content.trim().length === 0)
|
|
940
|
+
return emptyAuthFile();
|
|
941
|
+
const errors = [];
|
|
942
|
+
const parsed = parse2(content, errors, {
|
|
943
|
+
allowTrailingComma: true
|
|
944
|
+
});
|
|
945
|
+
if (errors.length > 0)
|
|
946
|
+
return emptyAuthFile();
|
|
947
|
+
if (!isAuthFile(parsed))
|
|
948
|
+
return emptyAuthFile();
|
|
949
|
+
return parsed;
|
|
950
|
+
};
|
|
951
|
+
var loadAuthFile = () => {
|
|
952
|
+
migrateLegacyConfigIfNeeded({
|
|
953
|
+
authFileExists: () => existsSync3(authFilePath()),
|
|
954
|
+
configFileExists: () => existsSync3(configFilePath()),
|
|
955
|
+
writeAuthFile: (profiles) => {
|
|
956
|
+
writeJsonFileAtomically(authFilePath(), { profiles });
|
|
957
|
+
},
|
|
958
|
+
writeConfigFile: (fields) => {
|
|
959
|
+
writeJsonFileAtomically(configFilePath(), {
|
|
960
|
+
...fields,
|
|
961
|
+
artifacts: MIGRATION_DEFAULT_ARTIFACT_RETENTION
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
return loadAuthFileFromPath(authFilePath());
|
|
966
|
+
};
|
|
967
|
+
var writeAuthFile = (data) => {
|
|
968
|
+
writeJsonFileAtomically(authFilePath(), data);
|
|
969
|
+
};
|
|
970
|
+
var loadAuthProfile = (baseUrl) => {
|
|
971
|
+
const authFile = loadAuthFile();
|
|
972
|
+
return authFile.profiles[baseUrl] ?? null;
|
|
973
|
+
};
|
|
974
|
+
var saveAuthProfile = (baseUrl, profile) => {
|
|
975
|
+
const authFile = loadAuthFile();
|
|
976
|
+
authFile.profiles[baseUrl] = profile;
|
|
977
|
+
writeAuthFile(authFile);
|
|
978
|
+
};
|
|
979
|
+
var deleteAuthProfile = (baseUrl) => {
|
|
980
|
+
const authFile = loadAuthFile();
|
|
981
|
+
if (!(baseUrl in authFile.profiles))
|
|
982
|
+
return;
|
|
983
|
+
const remainingProfiles = Object.fromEntries(Object.entries(authFile.profiles).filter(([profileBaseUrl]) => profileBaseUrl !== baseUrl));
|
|
984
|
+
if (Object.keys(remainingProfiles).length === 0) {
|
|
985
|
+
rmSync2(authFilePath(), { force: true });
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
writeAuthFile({ profiles: remainingProfiles });
|
|
989
|
+
};
|
|
990
|
+
// src/defaults/config-file.ts
|
|
991
|
+
import { existsSync as existsSync4, lstatSync as lstatSync3, readFileSync as readFileSync3 } from "fs";
|
|
992
|
+
import { randomUUID } from "crypto";
|
|
993
|
+
import { join as join3 } from "path";
|
|
994
|
+
var DEFAULT_ARTIFACT_LOCAL_MAX_BYTES = 2 * 1024 ** 3;
|
|
995
|
+
var DEFAULT_ARTIFACT_LOCAL_MAX_AGE_DAYS = 14;
|
|
996
|
+
var authFilePath2 = () => join3(resolveHomeDir(), ".scarn", "auth.jsonc");
|
|
997
|
+
var configFilePath2 = () => join3(resolveHomeDir(), ".scarn", "config.jsonc");
|
|
998
|
+
var getConfigFilePath = () => configFilePath2();
|
|
999
|
+
var defaultConfigFile = () => ({
|
|
1000
|
+
artifacts: {
|
|
1001
|
+
localMaxBytes: DEFAULT_ARTIFACT_LOCAL_MAX_BYTES,
|
|
1002
|
+
localMaxAgeDays: DEFAULT_ARTIFACT_LOCAL_MAX_AGE_DAYS
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
function isArtifactRetentionSettings(value) {
|
|
1006
|
+
if (typeof value !== "object" || value === null)
|
|
1007
|
+
return false;
|
|
1008
|
+
const obj = value;
|
|
1009
|
+
return typeof obj["localMaxBytes"] === "number" && typeof obj["localMaxAgeDays"] === "number";
|
|
1010
|
+
}
|
|
1011
|
+
function isConfigFile(value) {
|
|
1012
|
+
if (typeof value !== "object" || value === null)
|
|
1013
|
+
return false;
|
|
1014
|
+
const obj = value;
|
|
1015
|
+
if (obj["anonymousId"] !== undefined && typeof obj["anonymousId"] !== "string") {
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
if (obj["telemetryDisabled"] !== undefined && typeof obj["telemetryDisabled"] !== "boolean") {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
return isArtifactRetentionSettings(obj["artifacts"]);
|
|
1022
|
+
}
|
|
1023
|
+
var loadConfigFileFromPath = (filePath) => {
|
|
1024
|
+
if (!existsSync4(filePath))
|
|
1025
|
+
return defaultConfigFile();
|
|
1026
|
+
if (!lstatSync3(filePath).isFile())
|
|
1027
|
+
return defaultConfigFile();
|
|
1028
|
+
const content = readFileSync3(filePath, "utf8");
|
|
1029
|
+
if (content.trim().length === 0)
|
|
1030
|
+
return defaultConfigFile();
|
|
1031
|
+
const errors = [];
|
|
1032
|
+
const parsed = parse2(content, errors, {
|
|
1033
|
+
allowTrailingComma: true
|
|
1034
|
+
});
|
|
1035
|
+
if (errors.length > 0)
|
|
1036
|
+
return defaultConfigFile();
|
|
1037
|
+
if (!isConfigFile(parsed))
|
|
1038
|
+
return defaultConfigFile();
|
|
1039
|
+
return parsed;
|
|
1040
|
+
};
|
|
1041
|
+
var loadConfigFile = () => {
|
|
1042
|
+
migrateLegacyConfigIfNeeded({
|
|
1043
|
+
authFileExists: () => existsSync4(authFilePath2()),
|
|
1044
|
+
configFileExists: () => existsSync4(configFilePath2()),
|
|
1045
|
+
writeAuthFile: (profiles) => {
|
|
1046
|
+
writeJsonFileAtomically(authFilePath2(), { profiles });
|
|
1047
|
+
},
|
|
1048
|
+
writeConfigFile: (fields) => {
|
|
1049
|
+
writeJsonFileAtomically(configFilePath2(), {
|
|
1050
|
+
...fields,
|
|
1051
|
+
artifacts: defaultConfigFile().artifacts
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
return loadConfigFileFromPath(configFilePath2());
|
|
1056
|
+
};
|
|
1057
|
+
var writeConfigFile = (data) => {
|
|
1058
|
+
writeJsonFileAtomically(configFilePath2(), data);
|
|
1059
|
+
};
|
|
1060
|
+
var getOrCreateAnonymousId = () => {
|
|
1061
|
+
const configFile = loadConfigFile();
|
|
1062
|
+
if (configFile.anonymousId)
|
|
1063
|
+
return configFile.anonymousId;
|
|
1064
|
+
const anonymousId = randomUUID();
|
|
1065
|
+
writeConfigFile({ ...configFile, anonymousId });
|
|
1066
|
+
return anonymousId;
|
|
1067
|
+
};
|
|
1068
|
+
var isTelemetryDisabled = () => loadConfigFile().telemetryDisabled === true;
|
|
1069
|
+
var setTelemetryDisabled = (disabled) => {
|
|
1070
|
+
const configFile = loadConfigFile();
|
|
1071
|
+
writeConfigFile({ ...configFile, telemetryDisabled: disabled });
|
|
1072
|
+
};
|
|
1073
|
+
var getArtifactRetentionSettings = () => loadConfigFile().artifacts;
|
|
1074
|
+
// src/defaults/base-url.ts
|
|
1075
|
+
var DEFAULT_BASE_URL = "https://app.scarn.io";
|
|
1076
|
+
var trimTrailingSlashes = (value) => {
|
|
1077
|
+
let endIndex = value.length;
|
|
1078
|
+
while (endIndex > 0 && value.charAt(endIndex - 1) === "/") {
|
|
1079
|
+
endIndex -= 1;
|
|
1080
|
+
}
|
|
1081
|
+
return value.slice(0, endIndex);
|
|
1082
|
+
};
|
|
1083
|
+
var resolveScarnBaseUrl = (value) => {
|
|
1084
|
+
const trimmedValue = value?.trim();
|
|
1085
|
+
if (trimmedValue)
|
|
1086
|
+
return trimTrailingSlashes(trimmedValue);
|
|
1087
|
+
const envValue = process.env["SCARN_BASE_URL"]?.trim();
|
|
1088
|
+
if (envValue)
|
|
1089
|
+
return trimTrailingSlashes(envValue);
|
|
1090
|
+
return DEFAULT_BASE_URL;
|
|
1091
|
+
};
|
|
1092
|
+
// src/defaults/project-config.ts
|
|
1093
|
+
import { readFile } from "fs/promises";
|
|
1094
|
+
import path from "path";
|
|
1095
|
+
var REF_SEGMENT_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
1096
|
+
var OWNER_MIN_LENGTH = 3;
|
|
1097
|
+
var OWNER_MAX_LENGTH = 32;
|
|
1098
|
+
var SLUG_MAX_LENGTH = 64;
|
|
1099
|
+
function parseProjectRef(ref) {
|
|
1100
|
+
const parts = ref.split("/");
|
|
1101
|
+
if (parts.length !== 2)
|
|
1102
|
+
return null;
|
|
1103
|
+
const [owner = "", slug = ""] = parts;
|
|
1104
|
+
if (owner.length < OWNER_MIN_LENGTH || owner.length > OWNER_MAX_LENGTH || !REF_SEGMENT_PATTERN.test(owner)) {
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
if (slug.length > SLUG_MAX_LENGTH || !REF_SEGMENT_PATTERN.test(slug)) {
|
|
1108
|
+
return null;
|
|
1109
|
+
}
|
|
1110
|
+
return { owner, slug };
|
|
1111
|
+
}
|
|
1112
|
+
function isProjectRef(ref) {
|
|
1113
|
+
return parseProjectRef(ref) !== null;
|
|
1114
|
+
}
|
|
1115
|
+
function formatProjectRef(ref) {
|
|
1116
|
+
return `${ref.owner}/${ref.slug}`;
|
|
1117
|
+
}
|
|
1118
|
+
var SCARN_DIR = ".scarn";
|
|
1119
|
+
var CONFIG_FILENAME = "scarn.jsonc";
|
|
1120
|
+
var PROJECT_CONFIG_RELATIVE_PATH = path.join(SCARN_DIR, CONFIG_FILENAME);
|
|
1121
|
+
function getConfigPath(rootDir) {
|
|
1122
|
+
return path.join(rootDir, PROJECT_CONFIG_RELATIVE_PATH);
|
|
1123
|
+
}
|
|
1124
|
+
function isProjectConfig(value) {
|
|
1125
|
+
if (typeof value !== "object" || value === null)
|
|
1126
|
+
return false;
|
|
1127
|
+
const record = value;
|
|
1128
|
+
const project = record["project"];
|
|
1129
|
+
if (typeof project !== "string" || !isProjectRef(project))
|
|
1130
|
+
return false;
|
|
1131
|
+
if ("branchPrefix" in record && typeof record["branchPrefix"] !== "string") {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
if ("baseWorkBranch" in record && typeof record["baseWorkBranch"] !== "string") {
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
return true;
|
|
1138
|
+
}
|
|
1139
|
+
async function loadProjectConfig(rootDir = process.cwd()) {
|
|
1140
|
+
try {
|
|
1141
|
+
const content = await readFile(getConfigPath(rootDir), "utf8");
|
|
1142
|
+
const parsed = parseJsonc(content);
|
|
1143
|
+
return isProjectConfig(parsed) ? parsed : null;
|
|
1144
|
+
} catch {
|
|
1145
|
+
return null;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
// src/defaults/project-ref.ts
|
|
1149
|
+
class ProjectRefError extends Error {
|
|
1150
|
+
kind;
|
|
1151
|
+
ref;
|
|
1152
|
+
constructor(kind, ref, message) {
|
|
1153
|
+
super(message);
|
|
1154
|
+
this.kind = kind;
|
|
1155
|
+
this.ref = ref;
|
|
1156
|
+
this.name = "ProjectRefError";
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
var PROJECT_REF_FORMAT_HINT = 'Expected "<owner>/<project-slug>", e.g. "acme/web-app".';
|
|
1160
|
+
async function resolveProjectRef(client, ref, { headers, action = "view" }) {
|
|
1161
|
+
const parsed = parseProjectRef(ref);
|
|
1162
|
+
if (!parsed) {
|
|
1163
|
+
throw new ProjectRefError("invalid", ref, `"${ref}" is not a valid project. ${PROJECT_REF_FORMAT_HINT}`);
|
|
1164
|
+
}
|
|
1165
|
+
const { data, error, response } = await client.projects.resolveProjectBySlug({
|
|
1166
|
+
query: { username: parsed.owner, slug: parsed.slug },
|
|
1167
|
+
headers
|
|
1168
|
+
});
|
|
1169
|
+
if (data) {
|
|
1170
|
+
return { id: data.id, owner: parsed.owner, slug: parsed.slug };
|
|
1171
|
+
}
|
|
1172
|
+
const status = response.status;
|
|
1173
|
+
if (status === 404) {
|
|
1174
|
+
throw new ProjectRefError("not_found", ref, `No project ${ref}. Check "project" in .scarn/scarn.jsonc \u2014 the owner may have renamed their username.`);
|
|
1175
|
+
}
|
|
1176
|
+
if (status === 403) {
|
|
1177
|
+
throw new ProjectRefError("forbidden", ref, `You don't have permission to ${action} ${ref}.`);
|
|
1178
|
+
}
|
|
1179
|
+
if (status === 401) {
|
|
1180
|
+
throw new ProjectRefError("unauthenticated", ref, `Not signed in, so ${ref} can't be looked up. Run \`scarn auth login\` first.`);
|
|
1181
|
+
}
|
|
1182
|
+
const detail = error?.detail ?? error?.title ?? `HTTP ${String(status)}`;
|
|
1183
|
+
throw new ProjectRefError("failed", ref, `Could not look up project ${ref}: ${detail}`);
|
|
1184
|
+
}
|
|
1185
|
+
// src/defaults/load-push-defaults.ts
|
|
1186
|
+
import path2 from "path";
|
|
1187
|
+
async function findProjectConfigUpwards(startDir) {
|
|
1188
|
+
let current = path2.resolve(startDir);
|
|
1189
|
+
for (;; ) {
|
|
1190
|
+
const found = await loadProjectConfig(current);
|
|
1191
|
+
if (found)
|
|
1192
|
+
return found;
|
|
1193
|
+
const parent = path2.dirname(current);
|
|
1194
|
+
if (parent === current)
|
|
1195
|
+
return null;
|
|
1196
|
+
current = parent;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
async function loadPushDefaults(opts) {
|
|
1200
|
+
const baseUrl = resolveScarnBaseUrl();
|
|
1201
|
+
const envAccessToken = process.env["SCARN_ACCESS_TOKEN"]?.trim();
|
|
1202
|
+
const accessToken = envAccessToken ? envAccessToken : loadAuthProfile(baseUrl)?.accessToken;
|
|
1203
|
+
const envProjectId = process.env["SCARN_PROJECT_ID"]?.trim();
|
|
1204
|
+
if (envProjectId) {
|
|
1205
|
+
return { baseUrl, projectId: envProjectId, accessToken };
|
|
1206
|
+
}
|
|
1207
|
+
const config = await findProjectConfigUpwards(opts.dir);
|
|
1208
|
+
if (!config || !accessToken) {
|
|
1209
|
+
return { baseUrl, projectId: undefined, accessToken };
|
|
1210
|
+
}
|
|
1211
|
+
const resolved = await resolveProjectRef(createScarnClient(baseUrl), config.project, {
|
|
1212
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
1213
|
+
action: "push pipelines to"
|
|
1214
|
+
});
|
|
1215
|
+
return { baseUrl, projectId: resolved.id, accessToken };
|
|
1216
|
+
}
|
|
1217
|
+
export {
|
|
1218
|
+
PROJECT_CONFIG_RELATIVE_PATH,
|
|
1219
|
+
PROJECT_REF_FORMAT_HINT,
|
|
1220
|
+
ProjectRefError,
|
|
1221
|
+
deleteAuthProfile,
|
|
1222
|
+
formatProjectRef,
|
|
1223
|
+
getArtifactRetentionSettings,
|
|
1224
|
+
getAuthFilePath,
|
|
1225
|
+
getConfigFilePath,
|
|
1226
|
+
getOrCreateAnonymousId,
|
|
1227
|
+
isProjectRef,
|
|
1228
|
+
isTelemetryDisabled,
|
|
1229
|
+
loadAuthFile,
|
|
1230
|
+
loadAuthProfile,
|
|
1231
|
+
loadConfigFile,
|
|
1232
|
+
loadProjectConfig,
|
|
1233
|
+
loadPushDefaults,
|
|
1234
|
+
parseProjectRef,
|
|
1235
|
+
resolveProjectRef,
|
|
1236
|
+
resolveScarnBaseUrl,
|
|
1237
|
+
saveAuthProfile,
|
|
1238
|
+
setHomeDirForTests,
|
|
1239
|
+
setTelemetryDisabled
|
|
1240
|
+
};
|