@rakay-technology/kraft 0.7.4 → 0.7.5

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.
Files changed (48) hide show
  1. package/README.md +1 -11
  2. package/dist/bare-JM3EX7S4.js +27 -0
  3. package/dist/{chunk-EW4PHKB2.js → chunk-2UQFOUSZ.js} +8 -8
  4. package/dist/{chunk-WYNM7L22.js → chunk-2Y62WP2D.js} +2 -2
  5. package/dist/{chunk-N4OALTFK.js → chunk-3RCXJZJD.js} +1 -1
  6. package/dist/{chunk-PZVKPCKE.js → chunk-4UITBYUK.js} +5 -5
  7. package/dist/{chunk-DM3PKWDC.js → chunk-7UKBMDUF.js} +9 -9
  8. package/dist/{chunk-MNV2QFHW.js → chunk-BN23UUSF.js} +1 -1
  9. package/dist/{chunk-I2TOOF2A.js → chunk-CO6FAYLO.js} +1 -1
  10. package/dist/{chunk-AJ4QZLZ2.js → chunk-DFVWR6JM.js} +2 -2
  11. package/dist/{chunk-S3QBGGVP.js → chunk-DI54Y66N.js} +3 -3
  12. package/dist/{chunk-HMJUFZK7.js → chunk-DJNKEVZ7.js} +1 -1
  13. package/dist/{chunk-XVKUFMIB.js → chunk-HFOE2IXZ.js} +1 -1
  14. package/dist/{chunk-RFOBMHQ7.js → chunk-JK7KKBXI.js} +4 -4
  15. package/dist/{chunk-XGCG4MD5.js → chunk-K24SBFI2.js} +1 -1
  16. package/dist/{chunk-TAML5WMA.js → chunk-MC4X55BW.js} +3 -3
  17. package/dist/chunk-ND23EK7Y.js +81645 -0
  18. package/dist/{chunk-YZUKHG3S.js → chunk-PCOTSRS4.js} +3 -3
  19. package/dist/{chunk-MOLPYPVH.js → chunk-SPKRI7MF.js} +6 -6
  20. package/dist/{chunk-JSCZT76F.js → chunk-TCB6MMZZ.js} +10 -8
  21. package/dist/{chunk-PNNXWA2A.js → chunk-TSDJJP6M.js} +227 -100
  22. package/dist/{chunk-THTEUDBC.js → chunk-TVURAFJ5.js} +13 -13
  23. package/dist/{chunk-Y7PVJUXJ.js → chunk-VFPLICBX.js} +6 -6
  24. package/dist/{chunk-BQMFIXHI.js → chunk-XBGSR22I.js} +5 -5
  25. package/dist/{chunk-OFXBNFNL.js → chunk-YY5DEAZI.js} +2 -2
  26. package/dist/{chunk-PNRPKRJU.js → chunk-ZNVAHQRY.js} +6 -6
  27. package/dist/{chunk-YRSZPVMB.js → chunk-ZQJU5CTZ.js} +1 -1
  28. package/dist/{detect-676SNZK4.js → detect-N4HFQZ6Y.js} +4 -4
  29. package/dist/{docker-GOT3Q7DJ.js → docker-DU7JA2AK.js} +8 -8
  30. package/dist/{docker-edge-executor-VO6JHHW2.js → docker-edge-executor-MPIPQHNF.js} +7 -7
  31. package/dist/{edge-import-NFCHIW7G.js → edge-import-YDPEIQDU.js} +22 -22
  32. package/dist/{edge-preflight-QUJ757C6.js → edge-preflight-TT2777R5.js} +13 -13
  33. package/dist/{ensure-container-edge-Q7IZXHGM.js → ensure-container-edge-T5WRCJSE.js} +11 -11
  34. package/dist/{executor-GKXKN52K.js → executor-ZWF2J7GS.js} +6 -6
  35. package/dist/{host-channel-preflight-Z6HYSPKO.js → host-channel-preflight-625L6RNO.js} +22 -22
  36. package/dist/index.js +310 -86
  37. package/dist/{local-executor-OMMDKXCM.js → local-executor-W3O5HDLM.js} +3 -3
  38. package/dist/{nginx-VITTWZZU.js → nginx-XLDZIG4E.js} +9 -9
  39. package/dist/node-bootstrap.js +66 -32
  40. package/dist/{openresty-lua-6I3Z6PEQ.js → openresty-lua-ZNE6IBYU.js} +7 -7
  41. package/dist/{privilege-UQAI2HV4.js → privilege-IMARWVU2.js} +5 -5
  42. package/dist/server/index.js +58785 -770
  43. package/dist/{setup-JWKZIECM.js → setup-I3MTOIPW.js} +12 -12
  44. package/dist/{ssh-client-NWQVRCV7.js → ssh-client-LOCZTEUC.js} +2 -2
  45. package/dist/{up-P5DMQ5YO.js → up-G7ASYVWR.js} +25 -25
  46. package/package.json +1 -1
  47. package/dist/bare-HL2GUYE2.js +0 -27
  48. package/dist/chunk-PVOWHIND.js +0 -26781
@@ -9,14 +9,14 @@ import {
9
9
  internalPost,
10
10
  mintBareInternalToken,
11
11
  waitHealthy
12
- } from "./chunk-RFOBMHQ7.js";
12
+ } from "./chunk-JK7KKBXI.js";
13
13
  import {
14
14
  completeHostEdge,
15
15
  markStoppedProxyImported,
16
16
  planAndApplyHostEdge,
17
17
  previewHostEdge,
18
18
  rollbackHostEdge
19
- } from "./chunk-PZVKPCKE.js";
19
+ } from "./chunk-4UITBYUK.js";
20
20
  import {
21
21
  DEFAULT_REPO,
22
22
  PORTS_FILE,
@@ -43,11 +43,11 @@ import {
43
43
  resolvePorts,
44
44
  sourceBuildDir,
45
45
  verifyHostChannel
46
- } from "./chunk-JSCZT76F.js";
46
+ } from "./chunk-TCB6MMZZ.js";
47
47
  import {
48
48
  startUnitHint,
49
49
  thisHost
50
- } from "./chunk-EW4PHKB2.js";
50
+ } from "./chunk-2UQFOUSZ.js";
51
51
  import {
52
52
  AUTH_SECRET_FILE,
53
53
  DATA_DIR,
@@ -59,16 +59,16 @@ import {
59
59
  import {
60
60
  edgeCrashReason,
61
61
  edgeIsBroken
62
- } from "./chunk-YZUKHG3S.js";
62
+ } from "./chunk-PCOTSRS4.js";
63
63
  import {
64
64
  LocalExecutor
65
- } from "./chunk-XVKUFMIB.js";
65
+ } from "./chunk-HFOE2IXZ.js";
66
66
  import {
67
67
  EDGE_CONTAINER_NAME
68
- } from "./chunk-N4OALTFK.js";
68
+ } from "./chunk-3RCXJZJD.js";
69
69
  import {
70
70
  isValidEmail
71
- } from "./chunk-PVOWHIND.js";
71
+ } from "./chunk-ND23EK7Y.js";
72
72
 
73
73
  // src/commands/up.ts
74
74
  import { Command } from "commander";
@@ -78,27 +78,129 @@ import { spawn } from "child_process";
78
78
  import { randomBytes } from "crypto";
79
79
  import {
80
80
  createWriteStream as createWriteStream2,
81
- existsSync as existsSync4,
82
- mkdirSync as mkdirSync5,
83
- readFileSync as readFileSync3,
84
- writeFileSync as writeFileSync4
81
+ existsSync as existsSync5,
82
+ mkdirSync as mkdirSync6,
83
+ readFileSync as readFileSync4,
84
+ writeFileSync as writeFileSync5
85
85
  } from "fs";
86
- import { dirname as dirname2, join as join5 } from "path";
86
+ import { dirname as dirname2, join as join6 } from "path";
87
87
  import { fileURLToPath } from "url";
88
88
 
89
89
  // src/lib/dashboard.ts
90
90
  import { spawnSync } from "child_process";
91
- import { existsSync, mkdirSync as mkdirSync2, rmSync, writeFileSync } from "fs";
92
- import { join as join2 } from "path";
91
+ import { existsSync as existsSync2, mkdirSync as mkdirSync3, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
92
+ import { join as join3 } from "path";
93
93
 
94
94
  // src/lib/cache.ts
95
95
  import { createHash } from "crypto";
96
- import { createReadStream, createWriteStream, mkdirSync } from "fs";
97
- import { dirname, join } from "path";
98
- var CACHE_DIR = join(OS_DIR, "cache");
99
- var RELEASES_DIR = join(CACHE_DIR, "releases");
96
+ import { createReadStream, createWriteStream, mkdirSync as mkdirSync2 } from "fs";
97
+ import { dirname, join as join2 } from "path";
98
+
99
+ // src/lib/github-auth.ts
100
+ import {
101
+ mkdirSync,
102
+ readFileSync,
103
+ rmSync,
104
+ writeFileSync
105
+ } from "fs";
106
+ import { homedir } from "os";
107
+ import { join } from "path";
108
+ var GITHUB_TOKEN_FILENAME = ".github-token";
109
+ function githubTokenFile(dir = OS_DIR) {
110
+ return join(dir, GITHUB_TOKEN_FILENAME);
111
+ }
112
+ function envGithubToken() {
113
+ return process.env.GITHUB_TOKEN?.trim() || process.env.GH_TOKEN?.trim() || void 0;
114
+ }
115
+ function readStoredGithubToken(dir = OS_DIR) {
116
+ try {
117
+ const raw = readFileSync(githubTokenFile(dir), "utf8").trim();
118
+ return raw || null;
119
+ } catch {
120
+ return null;
121
+ }
122
+ }
123
+ function githubToken(dir = OS_DIR) {
124
+ return envGithubToken() ?? readStoredGithubToken(dir) ?? void 0;
125
+ }
126
+ function githubAuthHeaders(dir) {
127
+ const token = dir === void 0 ? githubToken() : githubToken(dir);
128
+ return token ? { Authorization: `Bearer ${token}` } : {};
129
+ }
130
+ function githubTokenSource(dir = OS_DIR) {
131
+ if (envGithubToken()) return "env";
132
+ if (readStoredGithubToken(dir)) return "stored";
133
+ return null;
134
+ }
135
+ function storeGithubToken(token, dir = OS_DIR) {
136
+ mkdirSync(dir, { recursive: true, mode: 448 });
137
+ writeFileSync(githubTokenFile(dir), `${token.trim()}
138
+ `, { mode: 384 });
139
+ }
140
+ function clearGithubToken(dir = OS_DIR) {
141
+ try {
142
+ rmSync(githubTokenFile(dir), { force: true });
143
+ return true;
144
+ } catch {
145
+ return false;
146
+ }
147
+ }
148
+ function maskToken(token) {
149
+ const t = token.trim();
150
+ if (t.length <= 8) return `${t.slice(0, 2)}\u2026`;
151
+ const prefix = t.split("_")[0];
152
+ return `${prefix}_\u2026${t.slice(-4)}`;
153
+ }
154
+ async function validateGithubToken(token) {
155
+ try {
156
+ const res = await fetch("https://api.github.com/rate_limit", {
157
+ headers: {
158
+ Accept: "application/vnd.github+json",
159
+ "User-Agent": "kraft-cli",
160
+ Authorization: `Bearer ${token.trim()}`
161
+ },
162
+ signal: AbortSignal.timeout(1e4)
163
+ });
164
+ return { valid: res.ok, status: res.status };
165
+ } catch {
166
+ return { valid: false, status: 0 };
167
+ }
168
+ }
169
+ async function checkRepoReleases(token, repo) {
170
+ try {
171
+ const res = await fetch(
172
+ `https://api.github.com/repos/${repo}/releases/latest`,
173
+ {
174
+ headers: {
175
+ Accept: "application/vnd.github+json",
176
+ "User-Agent": "kraft-cli",
177
+ Authorization: `Bearer ${token.trim()}`
178
+ },
179
+ signal: AbortSignal.timeout(1e4)
180
+ }
181
+ );
182
+ if (!res.ok) return { reachable: false, tag: null, status: res.status };
183
+ const data = await res.json();
184
+ return { reachable: true, tag: data.tag_name ?? null, status: res.status };
185
+ } catch {
186
+ return { reachable: false, tag: null, status: 0 };
187
+ }
188
+ }
189
+ function dockerHasAuthFor(host) {
190
+ try {
191
+ const raw = readFileSync(join(homedir(), ".docker", "config.json"), "utf8");
192
+ const cfg = JSON.parse(raw);
193
+ return !!cfg.auths?.[host];
194
+ } catch {
195
+ return false;
196
+ }
197
+ }
198
+
199
+ // src/lib/cache.ts
200
+ var CACHE_DIR = join2(OS_DIR, "cache");
201
+ var RELEASES_DIR = join2(CACHE_DIR, "releases");
100
202
  function releaseDir(tag) {
101
- return join(RELEASES_DIR, tag);
203
+ return join2(RELEASES_DIR, tag);
102
204
  }
103
205
  function parseSha256(content) {
104
206
  const token = content.trim().split(/\s+/)[0]?.toLowerCase();
@@ -111,9 +213,11 @@ async function hashFile(path) {
111
213
  return hash.digest("hex");
112
214
  }
113
215
  async function downloadToFile(url, dest, onProgress) {
114
- const res = await fetch(url, { headers: { "User-Agent": "kraft-cli" } });
216
+ const res = await fetch(url, {
217
+ headers: { "User-Agent": "kraft-cli", ...githubAuthHeaders() }
218
+ });
115
219
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} for ${url}`);
116
- mkdirSync(dirname(dest), { recursive: true });
220
+ mkdirSync2(dirname(dest), { recursive: true });
117
221
  const total = Number(res.headers.get("content-length")) || 0;
118
222
  const hash = createHash("sha256");
119
223
  const file = createWriteStream(dest);
@@ -152,29 +256,43 @@ function formatBytes(n) {
152
256
  }
153
257
 
154
258
  // src/lib/github-releases.ts
155
- var REPO = "rakay-technology/kraft";
156
- var RELEASES = `https://github.com/${REPO}/releases`;
157
- var LATEST_API = `https://api.github.com/repos/${REPO}/releases/latest`;
259
+ var DEFAULT_GITHUB_REPO = "rakay-technology/kraft";
260
+ function githubRepo() {
261
+ return process.env.KRAFT_GITHUB_REPO?.trim() || DEFAULT_GITHUB_REPO;
262
+ }
263
+ var RELEASES = `https://github.com/${DEFAULT_GITHUB_REPO}/releases`;
264
+ function releasesPage() {
265
+ return `https://github.com/${githubRepo()}/releases`;
266
+ }
267
+ function latestApiUrl() {
268
+ return `https://api.github.com/repos/${githubRepo()}/releases/latest`;
269
+ }
270
+ function privateRepoHint(status) {
271
+ return ` (HTTP ${status} \u2014 for a PRIVATE repo set KRAFT_GITHUB_REPO=<owner/repo> and GITHUB_TOKEN (or GH_TOKEN) with Contents:read, then re-run)`;
272
+ }
158
273
  async function resolveLatestTag() {
159
- const res = await fetch(LATEST_API, {
274
+ const res = await fetch(latestApiUrl(), {
160
275
  headers: {
161
276
  Accept: "application/vnd.github+json",
162
- "User-Agent": "kraft-cli"
277
+ "User-Agent": "kraft-cli",
278
+ ...githubAuthHeaders()
163
279
  },
164
280
  signal: AbortSignal.timeout(1e4)
165
281
  });
166
282
  if (!res.ok)
167
- throw new Error(`GitHub latest-release lookup failed: HTTP ${res.status}`);
283
+ throw new Error(
284
+ `GitHub latest-release lookup failed for ${githubRepo()}` + (res.status === 401 || res.status === 403 || res.status === 404 ? privateRepoHint(res.status) : `: HTTP ${res.status}`)
285
+ );
168
286
  const data = await res.json();
169
287
  if (!data.tag_name) throw new Error("Latest release has no tag_name");
170
288
  return data.tag_name;
171
289
  }
172
290
  function assetUrl(tag, name) {
173
- return `${RELEASES}/download/${tag}/${name}`;
291
+ return `${releasesPage()}/download/${tag}/${name}`;
174
292
  }
175
293
  async function fetchSidecar(url) {
176
294
  const res = await fetch(url, {
177
- headers: { "User-Agent": "kraft-cli" },
295
+ headers: { "User-Agent": "kraft-cli", ...githubAuthHeaders() },
178
296
  signal: AbortSignal.timeout(15e3)
179
297
  });
180
298
  if (res.status === 404) return null;
@@ -187,20 +305,20 @@ async function expectedSha256(tag, name) {
187
305
  }
188
306
 
189
307
  // src/lib/dashboard.ts
190
- var DASHBOARD_CACHE = join2(CACHE_DIR, "dashboard");
308
+ var DASHBOARD_CACHE = join3(CACHE_DIR, "dashboard");
191
309
  function assetName(tag) {
192
310
  return `kraft-dashboard-${tag}.tar.gz`;
193
311
  }
194
312
  function resolveDashboardEntry(cwd) {
195
- const wrapped = join2(cwd, "standalone-server.mjs");
196
- return existsSync(wrapped) ? wrapped : join2(cwd, "server.js");
313
+ const wrapped = join3(cwd, "standalone-server.mjs");
314
+ return existsSync2(wrapped) ? wrapped : join3(cwd, "server.js");
197
315
  }
198
316
  async function ensureDashboard(opts = {}) {
199
317
  const override = process.env.KRAFT_DASHBOARD_DIR?.trim();
200
318
  if (override) {
201
- const cwd = join2(override, "apps", "dashboard");
202
- const serverJs = join2(cwd, "server.js");
203
- if (!existsSync(serverJs)) {
319
+ const cwd = join3(override, "apps", "dashboard");
320
+ const serverJs = join3(cwd, "server.js");
321
+ if (!existsSync2(serverJs)) {
204
322
  throw new Error(
205
323
  `KRAFT_DASHBOARD_DIR=${override} but ${serverJs} is missing \u2014 build the dashboard standalone first (see docs).`
206
324
  );
@@ -221,17 +339,17 @@ async function ensureDashboard(opts = {}) {
221
339
  }
222
340
  }
223
341
  async function fetchBundle(tag, onProgress) {
224
- const dir = join2(DASHBOARD_CACHE, tag);
225
- const cwd = join2(dir, "apps", "dashboard");
226
- const serverJs = join2(cwd, "server.js");
227
- const marker = join2(dir, ".extracted");
228
- if (existsSync(marker) && existsSync(serverJs)) {
342
+ const dir = join3(DASHBOARD_CACHE, tag);
343
+ const cwd = join3(dir, "apps", "dashboard");
344
+ const serverJs = join3(cwd, "server.js");
345
+ const marker = join3(dir, ".extracted");
346
+ if (existsSync2(marker) && existsSync2(serverJs)) {
229
347
  return { tag, entry: resolveDashboardEntry(cwd), cwd };
230
348
  }
231
- rmSync(dir, { recursive: true, force: true });
232
- mkdirSync2(dir, { recursive: true });
349
+ rmSync2(dir, { recursive: true, force: true });
350
+ mkdirSync3(dir, { recursive: true });
233
351
  const name = assetName(tag);
234
- const tarball = join2(dir, name);
352
+ const tarball = join3(dir, name);
235
353
  const { sha256 } = await downloadToFile(
236
354
  assetUrl(tag, name),
237
355
  tarball,
@@ -244,7 +362,7 @@ async function fetchBundle(tag, onProgress) {
244
362
  );
245
363
  }
246
364
  if (expected !== sha256) {
247
- rmSync(dir, { recursive: true, force: true });
365
+ rmSync2(dir, { recursive: true, force: true });
248
366
  throw new Error(
249
367
  `Dashboard bundle checksum mismatch (expected ${expected}, got ${sha256}).`
250
368
  );
@@ -257,13 +375,13 @@ async function fetchBundle(tag, onProgress) {
257
375
  "Failed to extract the dashboard bundle (is `tar` available?)."
258
376
  );
259
377
  }
260
- rmSync(tarball, { force: true });
261
- if (!existsSync(serverJs)) {
378
+ rmSync2(tarball, { force: true });
379
+ if (!existsSync2(serverJs)) {
262
380
  throw new Error(
263
381
  `Dashboard bundle extracted but ${serverJs} is missing (unexpected layout).`
264
382
  );
265
383
  }
266
- writeFileSync(marker, `${tag}
384
+ writeFileSync2(marker, `${tag}
267
385
  `);
268
386
  return { tag, entry: resolveDashboardEntry(cwd), cwd };
269
387
  }
@@ -271,18 +389,18 @@ async function fetchBundle(tag, onProgress) {
271
389
  // src/lib/service.ts
272
390
  import { spawnSync as spawnSync2 } from "child_process";
273
391
  import {
274
- existsSync as existsSync3,
275
- mkdirSync as mkdirSync4,
276
- writeFileSync as writeFileSync3,
277
- rmSync as rmSync2
392
+ existsSync as existsSync4,
393
+ mkdirSync as mkdirSync5,
394
+ writeFileSync as writeFileSync4,
395
+ rmSync as rmSync3
278
396
  } from "fs";
279
- import { homedir } from "os";
280
- import { join as join4, resolve } from "path";
397
+ import { homedir as homedir2 } from "os";
398
+ import { join as join5, resolve } from "path";
281
399
 
282
400
  // src/lib/cli-install.ts
283
- import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync, writeFileSync as writeFileSync2 } from "fs";
284
- import { join as join3 } from "path";
285
- var MARKER = join3(OS_DIR, "cli-install.json");
401
+ import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
402
+ import { join as join4 } from "path";
403
+ var MARKER = join4(OS_DIR, "cli-install.json");
286
404
  function parseCliInstall(raw) {
287
405
  try {
288
406
  const obj = JSON.parse(raw);
@@ -291,7 +409,7 @@ function parseCliInstall(raw) {
291
409
  return {
292
410
  method: "tarball",
293
411
  tag: obj.tag,
294
- launcher: typeof obj.launcher === "string" ? obj.launcher : join3(OS_DIR, "bin", "kraft"),
412
+ launcher: typeof obj.launcher === "string" ? obj.launcher : join4(OS_DIR, "bin", "kraft"),
295
413
  runtime: obj.runtime === "vendored" ? "vendored" : "system"
296
414
  };
297
415
  } catch {
@@ -299,29 +417,29 @@ function parseCliInstall(raw) {
299
417
  }
300
418
  }
301
419
  function readCliInstall() {
302
- if (!existsSync2(MARKER)) return null;
420
+ if (!existsSync3(MARKER)) return null;
303
421
  try {
304
- return parseCliInstall(readFileSync(MARKER, "utf8"));
422
+ return parseCliInstall(readFileSync2(MARKER, "utf8"));
305
423
  } catch {
306
424
  return null;
307
425
  }
308
426
  }
309
427
  function writeCliInstall(info) {
310
- mkdirSync3(OS_DIR, { recursive: true });
311
- writeFileSync2(MARKER, `${JSON.stringify(info, null, 2)}
428
+ mkdirSync4(OS_DIR, { recursive: true });
429
+ writeFileSync3(MARKER, `${JSON.stringify(info, null, 2)}
312
430
  `);
313
431
  }
314
432
 
315
433
  // src/lib/service.ts
316
- var HOME = homedir();
317
- var KRAFT_BIN = join4(OS_DIR, "bin");
434
+ var HOME = homedir2();
435
+ var KRAFT_BIN = join5(OS_DIR, "bin");
318
436
  var MAC_LABEL = IS_ALT_HOME ? "io.kraft-dev.up" : "io.kraft.up";
319
- var MAC_PLIST = join4(HOME, "Library", "LaunchAgents", `${MAC_LABEL}.plist`);
437
+ var MAC_PLIST = join5(HOME, "Library", "LaunchAgents", `${MAC_LABEL}.plist`);
320
438
  var SYSTEMD_NAME = IS_ALT_HOME ? "kraft-dev" : "kraft";
321
439
  var WIN_TASK = IS_ALT_HOME ? "KraftDev" : "Kraft";
322
440
  function selfInvocation() {
323
441
  const cli = readCliInstall();
324
- if (cli?.method === "tarball" && existsSync3(cli.launcher)) {
442
+ if (cli?.method === "tarball" && existsSync4(cli.launcher)) {
325
443
  return { runtime: cli.launcher, args: [] };
326
444
  }
327
445
  const runtime = process.execPath;
@@ -395,7 +513,7 @@ function serviceEnv() {
395
513
  function plist(flags) {
396
514
  const argv = runArgv(flags);
397
515
  const items = argv.map((a) => ` <string>${xmlEscape(a)}</string>`).join("\n");
398
- const runtimeBin = readCliInstall()?.method === "tarball" ? KRAFT_BIN : join4(HOME, ".bun/bin");
516
+ const runtimeBin = readCliInstall()?.method === "tarball" ? KRAFT_BIN : join5(HOME, ".bun/bin");
399
517
  const path = [
400
518
  "/opt/homebrew/bin",
401
519
  "/usr/local/bin",
@@ -417,8 +535,8 @@ ${items}
417
535
  </array>
418
536
  <key>RunAtLoad</key><true/>
419
537
  <key>KeepAlive</key><true/>
420
- <key>StandardOutPath</key><string>${join4(LOG_DIR, "up.log")}</string>
421
- <key>StandardErrorPath</key><string>${join4(LOG_DIR, "up.err.log")}</string>
538
+ <key>StandardOutPath</key><string>${join5(LOG_DIR, "up.log")}</string>
539
+ <key>StandardErrorPath</key><string>${join5(LOG_DIR, "up.err.log")}</string>
422
540
  <key>EnvironmentVariables</key>
423
541
  <dict><key>PATH</key><string>${path}</string>${extraEnv}</dict>
424
542
  </dict>
@@ -469,7 +587,7 @@ function preview(flags) {
469
587
  if (kind === "systemd-user")
470
588
  return {
471
589
  kind,
472
- path: join4(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`),
590
+ path: join5(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`),
473
591
  content: systemdUnit(flags)
474
592
  };
475
593
  if (kind === "systemd-system")
@@ -483,15 +601,15 @@ function preview(flags) {
483
601
  return { kind, path: "", content: "" };
484
602
  }
485
603
  function installAndStart(flags) {
486
- mkdirSync4(LOG_DIR, { recursive: true });
604
+ mkdirSync5(LOG_DIR, { recursive: true });
487
605
  const kind = detectKind();
488
606
  if (kind === "launchd") {
489
- mkdirSync4(join4(HOME, "Library", "LaunchAgents"), { recursive: true });
607
+ mkdirSync5(join5(HOME, "Library", "LaunchAgents"), { recursive: true });
490
608
  run("launchctl", [
491
609
  "bootout",
492
610
  `gui/${process.getuid?.() ?? ""}/${MAC_LABEL}`
493
611
  ]);
494
- writeFileSync3(MAC_PLIST, plist(flags));
612
+ writeFileSync4(MAC_PLIST, plist(flags));
495
613
  const uid = String(process.getuid?.() ?? "");
496
614
  let r = run("launchctl", ["bootstrap", `gui/${uid}`, MAC_PLIST]);
497
615
  if (!r.ok) r = run("launchctl", ["load", "-w", MAC_PLIST]);
@@ -500,11 +618,11 @@ function installAndStart(flags) {
500
618
  }
501
619
  if (kind === "systemd-user" || kind === "systemd-system") {
502
620
  const sysArgs = kind === "systemd-user" ? ["--user"] : [];
503
- const unitPath = kind === "systemd-user" ? join4(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
504
- mkdirSync4(unitPath.slice(0, unitPath.lastIndexOf("/")), {
621
+ const unitPath = kind === "systemd-user" ? join5(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
622
+ mkdirSync5(unitPath.slice(0, unitPath.lastIndexOf("/")), {
505
623
  recursive: true
506
624
  });
507
- writeFileSync3(unitPath, systemdUnit(flags));
625
+ writeFileSync4(unitPath, systemdUnit(flags));
508
626
  run("systemctl", [...sysArgs, "daemon-reload"]);
509
627
  const r = run("systemctl", [...sysArgs, "enable", "--now", SYSTEMD_NAME]);
510
628
  if (!r.ok) throw new Error(`systemctl enable failed: ${r.out}`);
@@ -544,7 +662,7 @@ function installAndStart(flags) {
544
662
  function restart() {
545
663
  const kind = detectKind();
546
664
  if (kind === "launchd") {
547
- if (!existsSync3(MAC_PLIST))
665
+ if (!existsSync4(MAC_PLIST))
548
666
  return { restarted: false, detail: "no launchd agent installed" };
549
667
  const uid = String(process.getuid?.() ?? "");
550
668
  const r = run("launchctl", ["kickstart", "-k", `gui/${uid}/${MAC_LABEL}`]);
@@ -566,8 +684,8 @@ function restart() {
566
684
  }
567
685
  if (kind === "systemd-user" || kind === "systemd-system") {
568
686
  const sysArgs = kind === "systemd-user" ? ["--user"] : [];
569
- const unitPath = kind === "systemd-user" ? join4(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
570
- if (!existsSync3(unitPath))
687
+ const unitPath = kind === "systemd-user" ? join5(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
688
+ if (!existsSync4(unitPath))
571
689
  return { restarted: false, detail: "no systemd unit installed" };
572
690
  const r = run("systemctl", [...sysArgs, "restart", SYSTEMD_NAME]);
573
691
  return {
@@ -587,16 +705,16 @@ function serviceStatus() {
587
705
  if (kind === "launchd") {
588
706
  return {
589
707
  kind,
590
- installed: existsSync3(MAC_PLIST),
708
+ installed: existsSync4(MAC_PLIST),
591
709
  running: launchdPid() != null
592
710
  };
593
711
  }
594
712
  if (kind === "systemd-user" || kind === "systemd-system") {
595
713
  const sysArgs = kind === "systemd-user" ? ["--user"] : [];
596
- const unitPath = kind === "systemd-user" ? join4(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
714
+ const unitPath = kind === "systemd-user" ? join5(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
597
715
  return {
598
716
  kind,
599
- installed: existsSync3(unitPath),
717
+ installed: existsSync4(unitPath),
600
718
  running: run("systemctl", [...sysArgs, "is-active", SYSTEMD_NAME]).out.trim() === "active"
601
719
  };
602
720
  }
@@ -636,13 +754,13 @@ function stop() {
636
754
  "bootout",
637
755
  `gui/${process.getuid?.() ?? ""}/${MAC_LABEL}`
638
756
  ]);
639
- if (existsSync3(MAC_PLIST)) rmSync2(MAC_PLIST, { force: true });
757
+ if (existsSync4(MAC_PLIST)) rmSync3(MAC_PLIST, { force: true });
640
758
  result = { kind, detail: `launchd agent ${MAC_LABEL} stopped + removed` };
641
759
  } else if (kind === "systemd-user" || kind === "systemd-system") {
642
760
  const sysArgs = kind === "systemd-user" ? ["--user"] : [];
643
761
  run("systemctl", [...sysArgs, "disable", "--now", SYSTEMD_NAME]);
644
- const unitPath = kind === "systemd-user" ? join4(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
645
- if (existsSync3(unitPath)) rmSync2(unitPath, { force: true });
762
+ const unitPath = kind === "systemd-user" ? join5(HOME, ".config/systemd/user", `${SYSTEMD_NAME}.service`) : `/etc/systemd/system/${SYSTEMD_NAME}.service`;
763
+ if (existsSync4(unitPath)) rmSync3(unitPath, { force: true });
646
764
  run("systemctl", [...sysArgs, "daemon-reload"]);
647
765
  result = {
648
766
  kind,
@@ -1150,13 +1268,13 @@ function normalizePublicUrl(raw) {
1150
1268
  return url;
1151
1269
  }
1152
1270
  var DIST_DIR = dirname2(fileURLToPath(import.meta.url));
1153
- var SERVER_DIR = join5(DIST_DIR, "server");
1271
+ var SERVER_DIR = join6(DIST_DIR, "server");
1154
1272
  function ensureAuthSecret() {
1155
1273
  const path = AUTH_SECRET_FILE;
1156
- if (existsSync4(path)) return readFileSync3(path, "utf8").trim();
1157
- mkdirSync5(OS_DIR, { recursive: true, mode: 448 });
1274
+ if (existsSync5(path)) return readFileSync4(path, "utf8").trim();
1275
+ mkdirSync6(OS_DIR, { recursive: true, mode: 448 });
1158
1276
  const secret = randomBytes(32).toString("hex");
1159
- writeFileSync4(path, secret, { mode: 384 });
1277
+ writeFileSync5(path, secret, { mode: 384 });
1160
1278
  return secret;
1161
1279
  }
1162
1280
  var upCommand = new Command("up").description(
@@ -1657,8 +1775,8 @@ async function runForeground(opts, source) {
1657
1775
  apiArgs = ["run", "src/index.ts"];
1658
1776
  apiCwd = source.apiDir;
1659
1777
  } else {
1660
- const serverEntry = join5(SERVER_DIR, "index.js");
1661
- if (!existsSync4(serverEntry)) {
1778
+ const serverEntry = join6(SERVER_DIR, "index.js");
1779
+ if (!existsSync5(serverEntry)) {
1662
1780
  console.error(
1663
1781
  chalk2.red("\n Bundled server not found in this install.") + chalk2.dim(
1664
1782
  "\n Reinstall with `kraft update` (or `npm i -g @rakay-technology/kraft`).\n"
@@ -1677,9 +1795,9 @@ async function runForeground(opts, source) {
1677
1795
  const publicUrl = effectivePublicUrl(opts.publicUrl);
1678
1796
  const managedEdge = Boolean(opts.managedEdge && publicUrl);
1679
1797
  const dataDir = opts.dataDir || DATA_DIR;
1680
- mkdirSync5(dataDir, { recursive: true });
1681
- mkdirSync5(LOG_DIR, { recursive: true });
1682
- const instanceLogPath = join5(LOG_DIR, "instance.log");
1798
+ mkdirSync6(dataDir, { recursive: true });
1799
+ mkdirSync6(LOG_DIR, { recursive: true });
1800
+ const instanceLogPath = join6(LOG_DIR, "instance.log");
1683
1801
  const instanceLog = createWriteStream2(instanceLogPath, { flags: "w" });
1684
1802
  const env = {
1685
1803
  ...process.env,
@@ -1707,10 +1825,10 @@ async function runForeground(opts, source) {
1707
1825
  BETTER_AUTH_SECRET: ensureAuthSecret()
1708
1826
  };
1709
1827
  if (!source) {
1710
- env.KRAFT_MIGRATIONS_DIR = join5(SERVER_DIR, "migrations");
1711
- env.KRAFT_PGLITE_ASSETS_DIR = join5(SERVER_DIR, "pglite");
1712
- const engineDir = join5(SERVER_DIR, "engine");
1713
- if (existsSync4(engineDir)) env.MAIL_SERVER_ENGINE_DIR = engineDir;
1828
+ env.KRAFT_MIGRATIONS_DIR = join6(SERVER_DIR, "migrations");
1829
+ env.KRAFT_PGLITE_ASSETS_DIR = join6(SERVER_DIR, "pglite");
1830
+ const engineDir = join6(SERVER_DIR, "engine");
1831
+ if (existsSync5(engineDir)) env.MAIL_SERVER_ENGINE_DIR = engineDir;
1714
1832
  }
1715
1833
  env.KRAFT_REQUIRE_AUTH = "true";
1716
1834
  env.INTERNAL_TOKEN = mintBareInternalToken();
@@ -1803,7 +1921,7 @@ async function runForeground(opts, source) {
1803
1921
  const uiSpinner = ora("Preparing the dashboard\u2026").start();
1804
1922
  try {
1805
1923
  const bundle = await ensureDashboard({
1806
- tag: source ? "local" : opts.uiVersion || `v${"0.7.4"}`,
1924
+ tag: source ? "local" : opts.uiVersion || `v${"0.7.5"}`,
1807
1925
  onProgress: (received, total) => {
1808
1926
  if (total) {
1809
1927
  uiSpinner.text = `Downloading dashboard\u2026 ${Math.round(received / total * 100)}%`;
@@ -1920,6 +2038,14 @@ async function runForeground(opts, source) {
1920
2038
  }
1921
2039
 
1922
2040
  export {
2041
+ githubToken,
2042
+ githubTokenSource,
2043
+ storeGithubToken,
2044
+ clearGithubToken,
2045
+ maskToken,
2046
+ validateGithubToken,
2047
+ checkRepoReleases,
2048
+ dockerHasAuthFor,
1923
2049
  CACHE_DIR,
1924
2050
  RELEASES_DIR,
1925
2051
  releaseDir,
@@ -1927,7 +2053,8 @@ export {
1927
2053
  hashFile,
1928
2054
  downloadToFile,
1929
2055
  formatBytes,
1930
- RELEASES,
2056
+ githubRepo,
2057
+ releasesPage,
1931
2058
  resolveLatestTag,
1932
2059
  assetUrl,
1933
2060
  fetchSidecar,