@hyprcart/cli 1.0.2 → 1.0.3
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/README.md +1 -1
- package/dist/index.js +299 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
Command line interface for building, validating, deploying, and privately installing Hyprcart apps.
|
|
4
4
|
|
|
5
|
-
The `hyprcart` binary supports app scaffolding, project linking, local preview, validation, contract generation, development deploys, private install links, logs, status, rollback, docs, and schema export.
|
|
5
|
+
The `hyprcart` binary supports app scaffolding, registered-app selection, project linking, creating a Developer Console app from `hyprcart.app.config.ts`, local preview, validation, contract generation, development deploys, private install links, logs, status, rollback, docs, and schema export.
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
// src/commands/app-contracts.ts
|
|
4
4
|
import { generateContracts } from "@hyprcart/app-manifest";
|
|
5
5
|
|
|
6
|
+
// src/config/manifest.ts
|
|
7
|
+
import { readFile } from "fs/promises";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var manifestCandidates = ["hyprcart.app.config.ts", "hyprcart.app.config.mjs", "hyprcart.app.config.js", "hyprcart.app.json"];
|
|
10
|
+
async function loadProjectManifest(cwd = process.cwd()) {
|
|
11
|
+
for (const candidate of manifestCandidates) {
|
|
12
|
+
const path = join(cwd, candidate);
|
|
13
|
+
try {
|
|
14
|
+
const source = await readFile(path, "utf8");
|
|
15
|
+
if (candidate.endsWith(".json")) return JSON.parse(source);
|
|
16
|
+
return evaluateConfigModule(source);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (isMissingFileError(error)) continue;
|
|
19
|
+
throw new Error(`Unable to read ${candidate}: ${error instanceof Error ? error.message : "invalid manifest"}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function fallbackManifest(name = "Local app") {
|
|
25
|
+
return {
|
|
26
|
+
name,
|
|
27
|
+
version: "0.1.0",
|
|
28
|
+
manifestVersion: "2026-06",
|
|
29
|
+
sdkVersion: "1.0.0",
|
|
30
|
+
platformCompatibility: "2026-06",
|
|
31
|
+
scopes: ["product:read"],
|
|
32
|
+
surfaces: [{ id: "reviews", type: "storefront_block", entry: "src/storefront/reviews.tsx", label: { en: "Reviews", de: "Bewertungen" } }],
|
|
33
|
+
translations: { en: { "reviews.label": "Reviews" }, de: { "reviews.label": "Bewertungen" } }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function evaluateConfigModule(source) {
|
|
37
|
+
const expression = source.replace(/^\s*export\s+default\s+/m, "return ").replace(/;\s*$/, "");
|
|
38
|
+
if (!/^\s*return\s+/.test(expression)) {
|
|
39
|
+
throw new Error("expected a default-exported manifest object");
|
|
40
|
+
}
|
|
41
|
+
return new Function(expression)();
|
|
42
|
+
}
|
|
43
|
+
function isMissingFileError(error) {
|
|
44
|
+
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
45
|
+
}
|
|
46
|
+
|
|
6
47
|
// src/output/envelope.ts
|
|
7
48
|
function success(command, data, requestId = createRequestId()) {
|
|
8
49
|
return { ok: true, command, requestId, data };
|
|
@@ -24,18 +65,7 @@ function redactMessage(message) {
|
|
|
24
65
|
|
|
25
66
|
// src/commands/app-contracts.ts
|
|
26
67
|
async function appContracts(manifest) {
|
|
27
|
-
const result = generateContracts(
|
|
28
|
-
manifest ?? {
|
|
29
|
-
name: "Local app",
|
|
30
|
-
version: "0.1.0",
|
|
31
|
-
manifestVersion: "2026-06",
|
|
32
|
-
sdkVersion: "1.0.0",
|
|
33
|
-
platformCompatibility: "2026-06",
|
|
34
|
-
scopes: ["product:read"],
|
|
35
|
-
surfaces: [{ id: "reviews", type: "storefront_block", entry: "src/storefront/reviews.tsx", label: { en: "Reviews", de: "Bewertungen" } }],
|
|
36
|
-
translations: { en: { "reviews.label": "Reviews" }, de: { "reviews.label": "Bewertungen" } }
|
|
37
|
-
}
|
|
38
|
-
);
|
|
68
|
+
const result = generateContracts(manifest ?? await loadProjectManifest() ?? fallbackManifest());
|
|
39
69
|
return success("app.contracts.generate", result);
|
|
40
70
|
}
|
|
41
71
|
|
|
@@ -75,11 +105,11 @@ function readFlag2(args, name) {
|
|
|
75
105
|
|
|
76
106
|
// src/commands/app-init.ts
|
|
77
107
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
78
|
-
import { join as
|
|
108
|
+
import { join as join3 } from "path";
|
|
79
109
|
|
|
80
110
|
// src/templates/materialize.ts
|
|
81
111
|
import { mkdir, writeFile } from "fs/promises";
|
|
82
|
-
import { dirname, join } from "path";
|
|
112
|
+
import { dirname, join as join2 } from "path";
|
|
83
113
|
function starterTemplate(appName, kind = "storefront-block") {
|
|
84
114
|
const surface = surfaceForTemplate(kind);
|
|
85
115
|
return [
|
|
@@ -155,6 +185,8 @@ test("preview renders a page", async ({ page }) => {
|
|
|
155
185
|
path: "README.md",
|
|
156
186
|
content: `# ${appName}
|
|
157
187
|
|
|
188
|
+
Edit \`hyprcart.app.config.ts\` in your IDE, then run \`npx hyprcart login\` and \`npx hyprcart app link\` to choose an existing app, or \`npx hyprcart app link --create\` to create one from this project.
|
|
189
|
+
|
|
158
190
|
Run \`npm run dev\`, \`npm run validate\`, and \`npm run deploy:dev\`.
|
|
159
191
|
|
|
160
192
|
For one-off CLI commands, use \`npx hyprcart <command>\` unless you installed \`@hyprcart/cli\` globally.
|
|
@@ -183,7 +215,7 @@ function surfaceForTemplate(kind) {
|
|
|
183
215
|
async function materializeTemplate(files, cwd) {
|
|
184
216
|
const written = [];
|
|
185
217
|
for (const file of files) {
|
|
186
|
-
const fullPath =
|
|
218
|
+
const fullPath = join2(cwd, file.path);
|
|
187
219
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
188
220
|
await writeFile(fullPath, file.content, { flag: "wx" });
|
|
189
221
|
written.push(file.path);
|
|
@@ -198,7 +230,7 @@ async function appInit(args, cwd = process.cwd()) {
|
|
|
198
230
|
if (!isStarterTemplateKind(template)) {
|
|
199
231
|
return failure("app.init", "template.unsupported", `Unsupported template: ${template}.`);
|
|
200
232
|
}
|
|
201
|
-
const target =
|
|
233
|
+
const target = join3(cwd, name);
|
|
202
234
|
await mkdir2(target, { recursive: true });
|
|
203
235
|
const files = await materializeTemplate(starterTemplate(name, template), target);
|
|
204
236
|
return success("app.init", { projectPath: target, template, files });
|
|
@@ -243,13 +275,13 @@ function readFlag4(args, name) {
|
|
|
243
275
|
}
|
|
244
276
|
|
|
245
277
|
// src/config/project-link.ts
|
|
246
|
-
import { mkdir as mkdir3, readFile, rename, writeFile as writeFile2 } from "fs/promises";
|
|
247
|
-
import { join as
|
|
278
|
+
import { mkdir as mkdir3, readFile as readFile2, rename, writeFile as writeFile2 } from "fs/promises";
|
|
279
|
+
import { join as join4 } from "path";
|
|
248
280
|
var linkDirectory = ".hyprcart";
|
|
249
281
|
var linkFile = "project.json";
|
|
250
282
|
async function readProjectLink(cwd = process.cwd()) {
|
|
251
283
|
try {
|
|
252
|
-
const raw = await
|
|
284
|
+
const raw = await readFile2(join4(cwd, linkDirectory, linkFile), "utf8");
|
|
253
285
|
return JSON.parse(raw);
|
|
254
286
|
} catch {
|
|
255
287
|
return null;
|
|
@@ -260,35 +292,262 @@ async function writeProjectLink(link, cwd = process.cwd(), force = false) {
|
|
|
260
292
|
if (existing && existing.appId !== link.appId && !force) {
|
|
261
293
|
throw new Error("Project is already linked to another app. Re-run with --force to relink.");
|
|
262
294
|
}
|
|
263
|
-
await mkdir3(
|
|
295
|
+
await mkdir3(join4(cwd, linkDirectory), { recursive: true });
|
|
264
296
|
if (existing && existing.appId !== link.appId) {
|
|
265
|
-
await rename(
|
|
297
|
+
await rename(join4(cwd, linkDirectory, linkFile), join4(cwd, linkDirectory, `project.${Date.now()}.previous.json`));
|
|
266
298
|
}
|
|
267
299
|
const next = {
|
|
268
300
|
...link,
|
|
269
301
|
previousLinks: existing && existing.appId !== link.appId ? [existing, ...existing.previousLinks ?? []] : existing?.previousLinks
|
|
270
302
|
};
|
|
271
|
-
await writeFile2(
|
|
303
|
+
await writeFile2(join4(cwd, linkDirectory, linkFile), `${JSON.stringify(next, null, 2)}
|
|
272
304
|
`);
|
|
273
305
|
return next;
|
|
274
306
|
}
|
|
275
307
|
|
|
276
|
-
// src/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
308
|
+
// src/auth/credentials.ts
|
|
309
|
+
import { mkdir as mkdir4, readFile as readFile3, rm, writeFile as writeFile3 } from "fs/promises";
|
|
310
|
+
import { homedir } from "os";
|
|
311
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
312
|
+
function credentialsPath(env = process.env) {
|
|
313
|
+
const base = env.HYPRCART_CONFIG_HOME ?? join5(homedir(), ".hyprcart");
|
|
314
|
+
return join5(base, "credentials.json");
|
|
315
|
+
}
|
|
316
|
+
async function readDeveloperCredentials(env = process.env) {
|
|
317
|
+
try {
|
|
318
|
+
const parsed = JSON.parse(await readFile3(credentialsPath(env), "utf8"));
|
|
319
|
+
if (parsed.realm !== "developer" || !parsed.token) return null;
|
|
320
|
+
return parsed;
|
|
321
|
+
} catch {
|
|
322
|
+
return null;
|
|
281
323
|
}
|
|
282
|
-
|
|
324
|
+
}
|
|
325
|
+
async function writeDeveloperCredentials(credentials, env = process.env) {
|
|
326
|
+
const path = credentialsPath(env);
|
|
327
|
+
await mkdir4(dirname2(path), { recursive: true });
|
|
328
|
+
await writeFile3(path, `${JSON.stringify(credentials, null, 2)}
|
|
329
|
+
`, { mode: 384 });
|
|
330
|
+
}
|
|
331
|
+
async function clearDeveloperCredentials(env = process.env) {
|
|
332
|
+
await rm(credentialsPath(env), { force: true });
|
|
333
|
+
}
|
|
334
|
+
function credentialsExpired(credentials, now = /* @__PURE__ */ new Date()) {
|
|
335
|
+
return new Date(credentials.expiresAt).getTime() <= now.getTime();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/api/developer-apps.ts
|
|
339
|
+
async function listDeveloperApps(options) {
|
|
340
|
+
const response = await callCliAppsApi(`${developerOrigin(options)}/cli/apps`, {
|
|
341
|
+
method: "GET",
|
|
342
|
+
token: options.token,
|
|
343
|
+
fetchImpl: options.fetchImpl
|
|
344
|
+
});
|
|
345
|
+
return response.data;
|
|
346
|
+
}
|
|
347
|
+
async function createDeveloperApp(input, options) {
|
|
348
|
+
const response = await callCliAppsApi(`${developerOrigin(options)}/cli/apps`, {
|
|
349
|
+
method: "POST",
|
|
350
|
+
token: options.token,
|
|
351
|
+
fetchImpl: options.fetchImpl,
|
|
352
|
+
body: JSON.stringify(input)
|
|
353
|
+
});
|
|
354
|
+
return response.data;
|
|
355
|
+
}
|
|
356
|
+
async function callCliAppsApi(url, options) {
|
|
357
|
+
const response = await (options.fetchImpl ?? fetch)(url, {
|
|
358
|
+
method: options.method,
|
|
359
|
+
headers: {
|
|
360
|
+
Authorization: `Bearer ${options.token}`,
|
|
361
|
+
...options.body ? { "content-type": "application/json" } : {}
|
|
362
|
+
},
|
|
363
|
+
body: options.body
|
|
364
|
+
});
|
|
365
|
+
const payload = await response.json().catch(() => null);
|
|
366
|
+
if (!response.ok || !payload?.ok) {
|
|
367
|
+
const error = payload?.error;
|
|
368
|
+
throw new DeveloperCliApiError(error?.code ?? "developer_api.failed", error?.message ?? "Developer API request failed.", payload?.data);
|
|
369
|
+
}
|
|
370
|
+
return { data: payload.data };
|
|
371
|
+
}
|
|
372
|
+
function developerOrigin(options) {
|
|
373
|
+
return (options.origin ?? "https://developer.hyprcart.com").replace(/\/$/, "");
|
|
374
|
+
}
|
|
375
|
+
var DeveloperCliApiError = class extends Error {
|
|
376
|
+
constructor(code, message, data) {
|
|
377
|
+
super(message);
|
|
378
|
+
this.code = code;
|
|
379
|
+
this.data = data;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/commands/app-link.ts
|
|
384
|
+
import { createInterface } from "readline/promises";
|
|
385
|
+
async function appLink(args, cwd = process.cwd(), options = {}) {
|
|
283
386
|
const environment = readFlag5(args, "--env") ?? "development";
|
|
284
387
|
const developerApiUrl = readFlag5(args, "--api") ?? "https://developer.hyprcart.com/api/graphql";
|
|
388
|
+
const developerOrigin2 = readFlag5(args, "--developer-origin") ?? "https://developer.hyprcart.com";
|
|
285
389
|
const force = args.includes("--force");
|
|
390
|
+
const yes = args.includes("--yes") || args.includes("-y");
|
|
391
|
+
const appId = readFlag5(args, "--app");
|
|
392
|
+
const explicitTeamId = readFlag5(args, "--team");
|
|
393
|
+
if (appId) {
|
|
394
|
+
const resolved = await resolveExplicitApp(appId, explicitTeamId, developerOrigin2, options);
|
|
395
|
+
return writeResolvedProjectLink(resolved.app, environment, developerApiUrl, cwd, force);
|
|
396
|
+
}
|
|
397
|
+
const token = await resolveDeveloperToken(options.env);
|
|
398
|
+
if (!token) {
|
|
399
|
+
return failure("app.link", "auth.missing", "Run npx hyprcart login, then rerun npx hyprcart app link.");
|
|
400
|
+
}
|
|
401
|
+
const manifest = await loadProjectManifest(cwd).catch((error) => {
|
|
402
|
+
throw error;
|
|
403
|
+
}) ?? fallbackManifest();
|
|
404
|
+
try {
|
|
405
|
+
if (args.includes("--list")) {
|
|
406
|
+
const payload2 = await listDeveloperApps({ token, origin: developerOrigin2, fetchImpl: options.fetchImpl });
|
|
407
|
+
return success("app.link.list", payload2);
|
|
408
|
+
}
|
|
409
|
+
const payload = await listDeveloperApps({ token, origin: developerOrigin2, fetchImpl: options.fetchImpl });
|
|
410
|
+
const selected = args.includes("--create") ? await createAppFromProject({
|
|
411
|
+
args,
|
|
412
|
+
manifest,
|
|
413
|
+
payload,
|
|
414
|
+
token,
|
|
415
|
+
developerOrigin: developerOrigin2,
|
|
416
|
+
fetchImpl: options.fetchImpl
|
|
417
|
+
}) : await selectAppOrCreate({
|
|
418
|
+
args,
|
|
419
|
+
manifest,
|
|
420
|
+
payload,
|
|
421
|
+
token,
|
|
422
|
+
developerOrigin: developerOrigin2,
|
|
423
|
+
fetchImpl: options.fetchImpl,
|
|
424
|
+
input: options.input,
|
|
425
|
+
output: options.output,
|
|
426
|
+
isTTY: options.isTTY ?? Boolean(process.stdin.isTTY)
|
|
427
|
+
});
|
|
428
|
+
if (!selected.ok) return selected.result;
|
|
429
|
+
const confirmed = await confirmLink({
|
|
430
|
+
app: selected.app,
|
|
431
|
+
accountEmail: selected.accountEmail,
|
|
432
|
+
yes,
|
|
433
|
+
input: options.input,
|
|
434
|
+
output: options.output,
|
|
435
|
+
isTTY: options.isTTY ?? Boolean(process.stdin.isTTY)
|
|
436
|
+
});
|
|
437
|
+
if (!confirmed.ok) return confirmed.result;
|
|
438
|
+
return writeResolvedProjectLink(selected.app, environment, developerApiUrl, cwd, force);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
if (error instanceof DeveloperCliApiError) return failure("app.link", error.code, error.message);
|
|
441
|
+
return failure("app.link", "project.link.failed", error instanceof Error ? error.message : "Project link failed.");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function readFlag5(args, name) {
|
|
445
|
+
const index = args.indexOf(name);
|
|
446
|
+
const value = index >= 0 ? args[index + 1] : void 0;
|
|
447
|
+
return value && !value.startsWith("--") ? value : void 0;
|
|
448
|
+
}
|
|
449
|
+
async function resolveDeveloperToken(env = process.env) {
|
|
450
|
+
if (env.HYPRCART_DEVELOPER_TOKEN) return env.HYPRCART_DEVELOPER_TOKEN;
|
|
451
|
+
const credentials = await readDeveloperCredentials(env);
|
|
452
|
+
return credentials && !credentialsExpired(credentials) ? credentials.token : null;
|
|
453
|
+
}
|
|
454
|
+
async function resolveExplicitApp(appId, explicitTeamId, developerOrigin2, options) {
|
|
455
|
+
const token = await resolveDeveloperToken(options.env);
|
|
456
|
+
if (token) {
|
|
457
|
+
const payload = await listDeveloperApps({ token, origin: developerOrigin2, fetchImpl: options.fetchImpl }).catch(() => null);
|
|
458
|
+
const app = payload ? flattenApps(payload.teams).find((candidate) => candidate.id === appId) : null;
|
|
459
|
+
if (app) return { ok: true, app };
|
|
460
|
+
}
|
|
461
|
+
const teamId = explicitTeamId ?? "devteam_local";
|
|
462
|
+
return {
|
|
463
|
+
ok: true,
|
|
464
|
+
app: {
|
|
465
|
+
id: appId,
|
|
466
|
+
teamId,
|
|
467
|
+
teamName: teamId,
|
|
468
|
+
slug: appId,
|
|
469
|
+
displayName: appId,
|
|
470
|
+
status: "draft",
|
|
471
|
+
latestDraftVersionId: null,
|
|
472
|
+
latestValidatedVersionId: null
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
async function selectAppOrCreate(input) {
|
|
477
|
+
const apps = flattenApps(input.payload.teams);
|
|
478
|
+
if (!input.isTTY) {
|
|
479
|
+
return {
|
|
480
|
+
ok: false,
|
|
481
|
+
result: failure(
|
|
482
|
+
"app.link",
|
|
483
|
+
"app.selection_required",
|
|
484
|
+
apps.length > 0 ? "Choose an app with --app <appId>, or run interactively to select from your registered apps." : "No registered apps found. Run npx hyprcart app link --create --yes to create one from this project."
|
|
485
|
+
)
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
const rl = createInterface({
|
|
489
|
+
input: input.input ?? process.stdin,
|
|
490
|
+
output: input.output ?? process.stderr
|
|
491
|
+
});
|
|
492
|
+
try {
|
|
493
|
+
const choices = apps.map((app, index) => `${index + 1}. ${app.displayName} (${app.id}) - ${app.teamName}`);
|
|
494
|
+
const createIndex = apps.length + 1;
|
|
495
|
+
writeLine(input.output, `
|
|
496
|
+
Hyprcart app link for ${input.payload.account.email}`);
|
|
497
|
+
if (choices.length > 0) writeLine(input.output, choices.join("\n"));
|
|
498
|
+
writeLine(input.output, `${createIndex}. Create new app from ${input.manifest.name}`);
|
|
499
|
+
const answer = (await rl.question(`Choose an app [1-${createIndex}]: `)).trim();
|
|
500
|
+
const selectedIndex = Number.parseInt(answer, 10);
|
|
501
|
+
if (selectedIndex >= 1 && selectedIndex <= apps.length) {
|
|
502
|
+
return { ok: true, app: apps[selectedIndex - 1], accountEmail: input.payload.account.email };
|
|
503
|
+
}
|
|
504
|
+
if (selectedIndex === createIndex) {
|
|
505
|
+
return createAppFromProject(input);
|
|
506
|
+
}
|
|
507
|
+
return { ok: false, result: failure("app.link", "app.selection_invalid", "Choose a listed app number.") };
|
|
508
|
+
} finally {
|
|
509
|
+
rl.close();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
async function createAppFromProject(input) {
|
|
513
|
+
const name = readFlag5(input.args, "--name") ?? input.manifest.name;
|
|
514
|
+
const slug = readFlag5(input.args, "--slug");
|
|
515
|
+
const teamId = readFlag5(input.args, "--team");
|
|
516
|
+
const created = await createDeveloperApp(
|
|
517
|
+
{
|
|
518
|
+
teamId,
|
|
519
|
+
name,
|
|
520
|
+
slug,
|
|
521
|
+
manifest: input.manifest
|
|
522
|
+
},
|
|
523
|
+
{ token: input.token, origin: input.developerOrigin, fetchImpl: input.fetchImpl }
|
|
524
|
+
);
|
|
525
|
+
return { ok: true, app: created.app, accountEmail: created.account.email };
|
|
526
|
+
}
|
|
527
|
+
async function confirmLink(input) {
|
|
528
|
+
if (input.yes) return { ok: true };
|
|
529
|
+
if (!input.isTTY) {
|
|
530
|
+
return { ok: false, result: failure("app.link", "confirmation.required", "Re-run with --yes to confirm linking this project to your Developer Console account.") };
|
|
531
|
+
}
|
|
532
|
+
const rl = createInterface({
|
|
533
|
+
input: input.input ?? process.stdin,
|
|
534
|
+
output: input.output ?? process.stderr
|
|
535
|
+
});
|
|
536
|
+
try {
|
|
537
|
+
const answer = (await rl.question(`Link this project as ${input.accountEmail} to ${input.app.displayName} (${input.app.id})? [y/N] `)).trim().toLowerCase();
|
|
538
|
+
if (answer === "y" || answer === "yes") return { ok: true };
|
|
539
|
+
return { ok: false, result: failure("app.link", "confirmation.declined", "Project link cancelled.") };
|
|
540
|
+
} finally {
|
|
541
|
+
rl.close();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
async function writeResolvedProjectLink(app, environment, developerApiUrl, cwd, force) {
|
|
286
545
|
try {
|
|
287
546
|
const link = await writeProjectLink(
|
|
288
547
|
{
|
|
289
|
-
appId,
|
|
290
|
-
teamId,
|
|
291
|
-
appSlug:
|
|
548
|
+
appId: app.id,
|
|
549
|
+
teamId: app.teamId,
|
|
550
|
+
appSlug: app.slug,
|
|
292
551
|
environment,
|
|
293
552
|
developerApiUrl,
|
|
294
553
|
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -296,14 +555,17 @@ async function appLink(args, cwd = process.cwd()) {
|
|
|
296
555
|
cwd,
|
|
297
556
|
force
|
|
298
557
|
);
|
|
299
|
-
return success("app.link", link);
|
|
558
|
+
return success("app.link", { ...link, appName: app.displayName, teamName: app.teamName });
|
|
300
559
|
} catch (error) {
|
|
301
560
|
return failure("app.link", "project.link.conflict", error instanceof Error ? error.message : "Project link failed.");
|
|
302
561
|
}
|
|
303
562
|
}
|
|
304
|
-
function
|
|
305
|
-
|
|
306
|
-
|
|
563
|
+
function flattenApps(teams) {
|
|
564
|
+
return teams.flatMap((team) => team.apps);
|
|
565
|
+
}
|
|
566
|
+
function writeLine(output, line) {
|
|
567
|
+
(output ?? process.stderr).write(`${line}
|
|
568
|
+
`);
|
|
307
569
|
}
|
|
308
570
|
|
|
309
571
|
// src/commands/app-logs.ts
|
|
@@ -341,18 +603,7 @@ async function appStatus() {
|
|
|
341
603
|
// src/commands/app-validate.ts
|
|
342
604
|
import { validateManifest } from "@hyprcart/app-manifest";
|
|
343
605
|
async function appValidate(manifest) {
|
|
344
|
-
const result = validateManifest(
|
|
345
|
-
manifest ?? {
|
|
346
|
-
name: "Local app",
|
|
347
|
-
version: "0.1.0",
|
|
348
|
-
manifestVersion: "2026-06",
|
|
349
|
-
sdkVersion: "1.0.0",
|
|
350
|
-
platformCompatibility: "2026-06",
|
|
351
|
-
scopes: ["product:read"],
|
|
352
|
-
surfaces: [{ id: "reviews", type: "storefront_block", entry: "src/storefront/reviews.tsx", label: { en: "Reviews", de: "Bewertungen" } }],
|
|
353
|
-
translations: { en: { "reviews.label": "Reviews" }, de: { "reviews.label": "Bewertungen" } }
|
|
354
|
-
}
|
|
355
|
-
);
|
|
606
|
+
const result = validateManifest(manifest ?? await loadProjectManifest() ?? fallbackManifest());
|
|
356
607
|
return success("app.validate", result);
|
|
357
608
|
}
|
|
358
609
|
|
|
@@ -365,36 +616,6 @@ async function appVersionCreate() {
|
|
|
365
616
|
});
|
|
366
617
|
}
|
|
367
618
|
|
|
368
|
-
// src/auth/credentials.ts
|
|
369
|
-
import { mkdir as mkdir4, readFile as readFile2, rm, writeFile as writeFile3 } from "fs/promises";
|
|
370
|
-
import { homedir } from "os";
|
|
371
|
-
import { dirname as dirname2, join as join4 } from "path";
|
|
372
|
-
function credentialsPath(env = process.env) {
|
|
373
|
-
const base = env.HYPRCART_CONFIG_HOME ?? join4(homedir(), ".hyprcart");
|
|
374
|
-
return join4(base, "credentials.json");
|
|
375
|
-
}
|
|
376
|
-
async function readDeveloperCredentials(env = process.env) {
|
|
377
|
-
try {
|
|
378
|
-
const parsed = JSON.parse(await readFile2(credentialsPath(env), "utf8"));
|
|
379
|
-
if (parsed.realm !== "developer" || !parsed.token) return null;
|
|
380
|
-
return parsed;
|
|
381
|
-
} catch {
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
async function writeDeveloperCredentials(credentials, env = process.env) {
|
|
386
|
-
const path = credentialsPath(env);
|
|
387
|
-
await mkdir4(dirname2(path), { recursive: true });
|
|
388
|
-
await writeFile3(path, `${JSON.stringify(credentials, null, 2)}
|
|
389
|
-
`, { mode: 384 });
|
|
390
|
-
}
|
|
391
|
-
async function clearDeveloperCredentials(env = process.env) {
|
|
392
|
-
await rm(credentialsPath(env), { force: true });
|
|
393
|
-
}
|
|
394
|
-
function credentialsExpired(credentials, now = /* @__PURE__ */ new Date()) {
|
|
395
|
-
return new Date(credentials.expiresAt).getTime() <= now.getTime();
|
|
396
|
-
}
|
|
397
|
-
|
|
398
619
|
// src/auth/browser-login.ts
|
|
399
620
|
import { spawn } from "child_process";
|
|
400
621
|
import { createServer } from "http";
|
|
@@ -562,6 +783,7 @@ async function runCli(argv = process.argv.slice(2)) {
|
|
|
562
783
|
return failure("unknown", "command.unknown", "Unknown command.");
|
|
563
784
|
}
|
|
564
785
|
if (second === "init") return appInit(commandArgs(third, rest));
|
|
786
|
+
if (second === "list") return appLink(["--list", ...commandArgs(third, rest)]);
|
|
565
787
|
if (second === "link") return appLink(commandArgs(third, rest));
|
|
566
788
|
if (second === "dev") return appDev(commandArgs(third, rest));
|
|
567
789
|
if (second === "validate") return appValidate();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/app-contracts.ts","../src/output/envelope.ts","../src/commands/app-deploy.ts","../src/commands/app-dev.ts","../src/commands/app-init.ts","../src/templates/materialize.ts","../src/commands/app-install-link.ts","../src/config/project-link.ts","../src/commands/app-link.ts","../src/commands/app-logs.ts","../src/commands/app-rollback.ts","../src/commands/app-status.ts","../src/commands/app-validate.ts","../src/commands/app-version-create.ts","../src/auth/credentials.ts","../src/auth/browser-login.ts","../src/commands/auth.ts","../src/commands/docs-open.ts","../src/commands/schema-export.ts","../src/index.ts"],"sourcesContent":["import { generateContracts, type AppManifest } from \"@hyprcart/app-manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function appContracts(manifest?: AppManifest) {\n const result = generateContracts(\n manifest ?? {\n name: \"Local app\",\n version: \"0.1.0\",\n manifestVersion: \"2026-06\",\n sdkVersion: \"1.0.0\",\n platformCompatibility: \"2026-06\",\n scopes: [\"product:read\"],\n surfaces: [{ id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } }],\n translations: { en: { \"reviews.label\": \"Reviews\" }, de: { \"reviews.label\": \"Bewertungen\" } },\n },\n );\n return success(\"app.contracts.generate\", result);\n}\n","export interface CommandEnvelope<TData = unknown> {\n ok: boolean;\n requestId: string;\n command: string;\n data?: TData;\n error?: {\n code: string;\n message: string;\n path?: string;\n docsUrl?: string;\n };\n}\n\nexport function success<TData>(command: string, data: TData, requestId = createRequestId()): CommandEnvelope<TData> {\n return { ok: true, command, requestId, data };\n}\n\nexport function failure(command: string, code: string, message: string, requestId = createRequestId(), docsUrl?: string): CommandEnvelope {\n return {\n ok: false,\n command,\n requestId,\n error: { code, message: redactMessage(message), docsUrl },\n };\n}\n\nexport function createRequestId(): string {\n return `req_cli_${Date.now().toString(36)}`;\n}\n\nfunction redactMessage(message: string): string {\n return message\n .replace(/hcdev_[a-z0-9_]+/gi, \"[redacted]\")\n .replace(/Bearer\\s+[a-z0-9._-]+/gi, \"[redacted]\")\n .replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}/gi, \"[redacted]\");\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appDeploy(args: string[]) {\n const env = readFlag(args, \"--env\") ?? \"development\";\n return success(\"app.deploy\", {\n environment: env,\n appVersionId: `devver_${Date.now().toString(36)}`,\n runtimeDeploymentId: `rtdep_${Date.now().toString(36)}`,\n status: \"deployed\",\n healthChecked: args.includes(\"--wait\"),\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { createPreviewServer, previewSurface } from \"@hyprcart/app-testing\";\nimport { success } from \"../output/envelope\";\n\nexport async function appDev(args: string[]) {\n const fixtureId = readFlag(args, \"--fixture\");\n const state = createPreviewServer();\n const preview = await previewSurface(state, \"storefront_block\", fixtureId);\n return success(\"app.dev\", {\n previewUrl: \"http://localhost:8788\",\n html: preview.html,\n diagnostics: state.diagnostics,\n remoteVersionCreated: state.remoteVersionCreated,\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { failure, success } from \"../output/envelope\";\nimport { isStarterTemplateKind, materializeTemplate, starterTemplate } from \"../templates/materialize\";\n\nexport async function appInit(args: string[], cwd = process.cwd()) {\n const name = positionalArgs(args)[0] ?? \"my-hyprcart-app\";\n const template = readFlag(args, \"--template\") ?? \"storefront-block\";\n if (!isStarterTemplateKind(template)) {\n return failure(\"app.init\", \"template.unsupported\", `Unsupported template: ${template}.`);\n }\n const target = join(cwd, name);\n await mkdir(target, { recursive: true });\n const files = await materializeTemplate(starterTemplate(name, template), target);\n return success(\"app.init\", { projectPath: target, template, files });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction positionalArgs(args: string[]): string[] {\n return args.filter((arg, index) => !arg.startsWith(\"--\") && !args[index - 1]?.startsWith(\"--\"));\n}\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nexport interface TemplateFile {\n path: string;\n content: string;\n}\n\nexport type StarterTemplateKind =\n | \"storefront-block\"\n | \"admin-surface\"\n | \"checkout-function\"\n | \"pixel-event\"\n | \"multi-surface\";\n\nexport function starterTemplate(appName: string, kind: StarterTemplateKind = \"storefront-block\"): TemplateFile[] {\n const surface = surfaceForTemplate(kind);\n return [\n {\n path: \"hyprcart.app.config.ts\",\n content: `export default {\n name: ${JSON.stringify(appName)},\n version: \"0.1.0\",\n manifestVersion: \"2026-06\",\n sdkVersion: \"1.0.0\",\n platformCompatibility: \"2026-06\",\n scopes: [\"product:read\"],\n surfaces: [${JSON.stringify(surface)}],\n translations: { en: { \"reviews.label\": \"Reviews\" }, de: { \"reviews.label\": \"Bewertungen\" } },\n resources: { bundleSizeBytes: 42000 }\n};\n`,\n },\n {\n path: \"package.json\",\n content: `${JSON.stringify(\n {\n name: appName,\n version: \"0.1.0\",\n type: \"module\",\n scripts: {\n dev: \"hyprcart app dev\",\n validate: \"hyprcart app validate\",\n contracts: \"hyprcart app contracts generate\",\n test: \"vitest run tests\",\n \"test:preview\": \"playwright test playwright/app-preview.spec.ts\",\n \"deploy:dev\": \"hyprcart app deploy --env development\",\n \"install-link\": \"hyprcart app install-link create\",\n },\n dependencies: {\n \"@hyprcart/app-sdk\": \"^1.0.0\",\n },\n devDependencies: {\n \"@hyprcart/cli\": \"^1.0.0\",\n \"@hyprcart/app-testing\": \"^1.0.0\",\n \"@playwright/test\": \"^1.60.0\",\n vitest: \"^4.0.18\",\n typescript: \"^5.7.2\",\n },\n },\n null,\n 2,\n )}\\n`,\n },\n { path: surface.entry, content: `export function HyprcartSurface() { return \"<section>${kind}</section>\"; }\\n` },\n { path: \"locales/en.json\", content: `${JSON.stringify({ \"reviews.label\": \"Reviews\" }, null, 2)}\\n` },\n { path: \"locales/de.json\", content: `${JSON.stringify({ \"reviews.label\": \"Bewertungen\" }, null, 2)}\\n` },\n { path: \"fixtures/product.basic.json\", content: `${JSON.stringify({ id: \"prod_1\", title: \"Deep Moisture\" }, null, 2)}\\n` },\n { path: \"tests/validation.test.ts\", content: `import { describe, expect, it } from \"vitest\";\\ndescribe(\"app\", () => { it(\"has tests\", () => expect(true).toBe(true)); });\\n` },\n {\n path: \"playwright/app-preview.spec.ts\",\n content: `import { expect, test } from \"@playwright/test\";\\n\\ntest(\"preview renders a page\", async ({ page }) => {\\n await page.goto(process.env.HYPRCART_PREVIEW_URL ?? \"http://localhost:8788\");\\n await expect(page.locator(\"body\")).toBeVisible();\\n});\\n`,\n },\n {\n path: \"README.md\",\n content: `# ${appName}\\n\\nRun \\`npm run dev\\`, \\`npm run validate\\`, and \\`npm run deploy:dev\\`.\\n\\nFor one-off CLI commands, use \\`npx hyprcart <command>\\` unless you installed \\`@hyprcart/cli\\` globally.\\n`,\n },\n ];\n}\n\nexport function isStarterTemplateKind(value: string): value is StarterTemplateKind {\n return [\"storefront-block\", \"admin-surface\", \"checkout-function\", \"pixel-event\", \"multi-surface\"].includes(value);\n}\n\nfunction surfaceForTemplate(kind: StarterTemplateKind) {\n if (kind === \"admin-surface\") {\n return { id: \"reviews\", type: \"admin_surface\", entry: \"src/admin/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"checkout-function\") {\n return { id: \"reviews\", type: \"checkout_function\", entry: \"src/checkout/reviews.ts\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"pixel-event\") {\n return { id: \"reviews\", type: \"pixel\", entry: \"src/pixel/reviews.ts\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"multi-surface\") {\n return { id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n return { id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n}\n\nexport async function materializeTemplate(files: TemplateFile[], cwd: string): Promise<string[]> {\n const written: string[] = [];\n for (const file of files) {\n const fullPath = join(cwd, file.path);\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, file.content, { flag: \"wx\" });\n written.push(file.path);\n }\n return written;\n}\n","import { failure, success } from \"../output/envelope\";\n\nexport async function appInstallLink(args: string[]) {\n const subcommand = args[0];\n if (subcommand === \"revoke\") {\n return success(\"app.install-link.revoke\", { privateInstallUrlId: args[1], status: \"revoked\" });\n }\n\n const orgId = readFlag(args, \"--org\");\n if (!orgId) {\n return failure(\"app.install-link.create\", \"organization.missing\", \"Provide --org <orgId>.\");\n }\n\n const token = `hcdev_${Date.now().toString(36)}`;\n const privateInstallUrlId = `hcil_${Date.now().toString(36)}`;\n const installUrl = new URL(\"https://hyprcart.com/apps/install/private\");\n installUrl.searchParams.set(\"hcil\", privateInstallUrlId);\n installUrl.searchParams.set(\"token\", token);\n\n return success(\"app.install-link.create\", {\n privateInstallUrlId,\n installUrl: installUrl.toString(),\n appVersionId: readFlag(args, \"--version\") ?? \"devver_local\",\n environment: readFlag(args, \"--env\") ?? \"development\",\n allowedOrganizationId: orgId,\n allowedUserEmail: readFlag(args, \"--user\"),\n expiresAt: readFlag(args, \"--expires-at\") ?? null,\n maxUses: Number(readFlag(args, \"--max-uses\") ?? 1),\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface ProjectLink {\n appId: string;\n teamId: string;\n appSlug: string;\n environment: string;\n developerApiUrl: string;\n linkedAt: string;\n previousLinks?: ProjectLink[];\n}\n\nconst linkDirectory = \".hyprcart\";\nconst linkFile = \"project.json\";\n\nexport async function readProjectLink(cwd = process.cwd()): Promise<ProjectLink | null> {\n try {\n const raw = await readFile(join(cwd, linkDirectory, linkFile), \"utf8\");\n return JSON.parse(raw) as ProjectLink;\n } catch {\n return null;\n }\n}\n\nexport async function writeProjectLink(link: ProjectLink, cwd = process.cwd(), force = false): Promise<ProjectLink> {\n const existing = await readProjectLink(cwd);\n if (existing && existing.appId !== link.appId && !force) {\n throw new Error(\"Project is already linked to another app. Re-run with --force to relink.\");\n }\n\n await mkdir(join(cwd, linkDirectory), { recursive: true });\n\n if (existing && existing.appId !== link.appId) {\n await rename(join(cwd, linkDirectory, linkFile), join(cwd, linkDirectory, `project.${Date.now()}.previous.json`));\n }\n\n const next = {\n ...link,\n previousLinks: existing && existing.appId !== link.appId ? [existing, ...(existing.previousLinks ?? [])] : existing?.previousLinks,\n };\n await writeFile(join(cwd, linkDirectory, linkFile), `${JSON.stringify(next, null, 2)}\\n`);\n return next;\n}\n","import { failure, success } from \"../output/envelope\";\nimport { writeProjectLink } from \"../config/project-link\";\n\nexport async function appLink(args: string[], cwd = process.cwd()) {\n const appId = readFlag(args, \"--app\");\n if (!appId) {\n return failure(\"app.link\", \"app.id.missing\", \"Provide --app <appId>.\");\n }\n\n const teamId = readFlag(args, \"--team\") ?? \"devteam_local\";\n const environment = readFlag(args, \"--env\") ?? \"development\";\n const developerApiUrl = readFlag(args, \"--api\") ?? \"https://developer.hyprcart.com/api/graphql\";\n const force = args.includes(\"--force\");\n\n try {\n const link = await writeProjectLink(\n {\n appId,\n teamId,\n appSlug: appId,\n environment,\n developerApiUrl,\n linkedAt: new Date().toISOString(),\n },\n cwd,\n force,\n );\n return success(\"app.link\", link);\n } catch (error) {\n return failure(\"app.link\", \"project.link.conflict\", error instanceof Error ? error.message : \"Project link failed.\");\n }\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appLogs() {\n return success(\"app.logs\", {\n nodes: [\n {\n requestId: \"req_local\",\n level: \"info\",\n message: \"No production logs in local CLI stub.\",\n redacted: true,\n },\n ],\n });\n}\n","import { failure, success } from \"../output/envelope\";\n\nexport async function appRollback(args: string[]) {\n const version = readFlag(args, \"--to\");\n if (!version) {\n return failure(\"app.rollback\", \"version.missing\", \"Provide --to <versionId>.\");\n }\n return success(\"app.rollback\", { status: \"rolled_back\", appVersionId: version });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appStatus() {\n return success(\"app.status\", { environment: \"development\", status: \"deployed\" });\n}\n","import { validateManifest, type AppManifest } from \"@hyprcart/app-manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function appValidate(manifest?: AppManifest) {\n const result = validateManifest(\n manifest ?? {\n name: \"Local app\",\n version: \"0.1.0\",\n manifestVersion: \"2026-06\",\n sdkVersion: \"1.0.0\",\n platformCompatibility: \"2026-06\",\n scopes: [\"product:read\"],\n surfaces: [{ id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } }],\n translations: { en: { \"reviews.label\": \"Reviews\" }, de: { \"reviews.label\": \"Bewertungen\" } },\n },\n );\n return success(\"app.validate\", result);\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appVersionCreate() {\n return success(\"app.version.create\", {\n appVersionId: `devver_${Date.now().toString(36)}`,\n state: \"draft\",\n runtimeDeploymentRequested: false,\n });\n}\n","import { mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nexport interface StoredDeveloperCredentials {\n realm: \"developer\";\n email: string | null;\n token: string;\n expiresAt: string;\n savedAt: string;\n}\n\nexport function credentialsPath(env: Record<string, string | undefined> = process.env): string {\n const base = env.HYPRCART_CONFIG_HOME ?? join(homedir(), \".hyprcart\");\n return join(base, \"credentials.json\");\n}\n\nexport async function readDeveloperCredentials(env: Record<string, string | undefined> = process.env): Promise<StoredDeveloperCredentials | null> {\n try {\n const parsed = JSON.parse(await readFile(credentialsPath(env), \"utf8\")) as StoredDeveloperCredentials;\n if (parsed.realm !== \"developer\" || !parsed.token) return null;\n return parsed;\n } catch {\n return null;\n }\n}\n\nexport async function writeDeveloperCredentials(credentials: StoredDeveloperCredentials, env: Record<string, string | undefined> = process.env): Promise<void> {\n const path = credentialsPath(env);\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, `${JSON.stringify(credentials, null, 2)}\\n`, { mode: 0o600 });\n}\n\nexport async function clearDeveloperCredentials(env: Record<string, string | undefined> = process.env): Promise<void> {\n await rm(credentialsPath(env), { force: true });\n}\n\nexport function credentialsExpired(credentials: StoredDeveloperCredentials, now = new Date()): boolean {\n return new Date(credentials.expiresAt).getTime() <= now.getTime();\n}\n","import { spawn } from \"node:child_process\";\nimport { createServer, type Server } from \"node:http\";\nimport { randomBytes } from \"node:crypto\";\nimport { writeDeveloperCredentials, type StoredDeveloperCredentials } from \"./credentials\";\n\nexport interface BrowserLoginResult {\n email: string | null;\n expiresAt: string;\n loginUrl: string;\n credentialsPathWritten: boolean;\n}\n\nexport async function runBrowserLogin(options: {\n openBrowser?: boolean;\n timeoutMs?: number;\n developerOrigin?: string;\n env?: Record<string, string | undefined>;\n onMessage?: (message: string) => void;\n} = {}): Promise<BrowserLoginResult> {\n const server = createServer();\n const state = randomBytes(24).toString(\"base64url\");\n const callback = await listenOnLoopback(server);\n const loginUrl = new URL(\"/cli/auth/start\", options.developerOrigin ?? \"https://developer.hyprcart.com\");\n loginUrl.searchParams.set(\"redirect_uri\", callback.redirectUri);\n loginUrl.searchParams.set(\"state\", state);\n\n const waitForCallback = waitForLoginCallback(server, state, options.timeoutMs ?? 180_000);\n options.onMessage?.(`Open ${loginUrl.toString()} to finish Hyprcart CLI login.`);\n if (options.openBrowser !== false) {\n openBrowser(loginUrl.toString(), options.onMessage);\n }\n\n try {\n const credentials = await waitForCallback;\n await writeDeveloperCredentials(credentials, options.env);\n return {\n email: credentials.email,\n expiresAt: credentials.expiresAt,\n loginUrl: loginUrl.toString(),\n credentialsPathWritten: true,\n };\n } finally {\n await closeServer(server);\n }\n}\n\nasync function listenOnLoopback(server: Server): Promise<{ redirectUri: string }> {\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject);\n server.listen(0, \"127.0.0.1\", () => resolve());\n });\n const address = server.address();\n if (!address || typeof address === \"string\") throw new Error(\"Failed to start local login callback server.\");\n return { redirectUri: `http://127.0.0.1:${address.port}/callback` };\n}\n\nfunction waitForLoginCallback(server: Server, expectedState: string, timeoutMs: number): Promise<StoredDeveloperCredentials> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => reject(new Error(\"Timed out waiting for Hyprcart login callback.\")), timeoutMs);\n server.on(\"request\", (request, response) => {\n const url = new URL(request.url ?? \"/\", \"http://127.0.0.1\");\n if (url.pathname !== \"/callback\") {\n response.writeHead(404).end(\"Not found\");\n return;\n }\n\n const state = url.searchParams.get(\"state\");\n const token = url.searchParams.get(\"token\");\n const email = url.searchParams.get(\"email\");\n const expiresAt = url.searchParams.get(\"expires_at\");\n const realm = url.searchParams.get(\"realm\");\n if (state !== expectedState || !token || !expiresAt || realm !== \"developer\") {\n response.writeHead(400, { \"content-type\": \"text/html; charset=utf-8\" }).end(\"<h1>Hyprcart CLI login failed</h1><p>Invalid callback.</p>\");\n clearTimeout(timeout);\n reject(new Error(\"Invalid Hyprcart login callback.\"));\n return;\n }\n\n response\n .writeHead(200, { \"content-type\": \"text/html; charset=utf-8\" })\n .end(\"<h1>Hyprcart CLI login complete</h1><p>You can close this tab and return to your terminal.</p>\");\n clearTimeout(timeout);\n resolve({\n realm: \"developer\",\n email,\n token,\n expiresAt,\n savedAt: new Date().toISOString(),\n });\n });\n });\n}\n\nfunction openBrowser(url: string, onMessage?: (message: string) => void): void {\n const command =\n process.platform === \"win32\"\n ? { file: \"rundll32.exe\", args: [\"url.dll,FileProtocolHandler\", url] }\n : process.platform === \"darwin\"\n ? { file: \"open\", args: [url] }\n : { file: \"xdg-open\", args: [url] };\n\n const child = spawn(command.file, command.args, { stdio: \"ignore\", detached: true });\n child.on(\"error\", () => onMessage?.(`Could not open browser automatically. Open ${url} manually.`));\n child.unref();\n}\n\nasync function closeServer(server: Server): Promise<void> {\n await new Promise<void>((resolve) => server.close(() => resolve()));\n}\n","import { clearDeveloperCredentials, credentialsExpired, readDeveloperCredentials, writeDeveloperCredentials } from \"../auth/credentials\";\nimport { runBrowserLogin } from \"../auth/browser-login\";\nimport { failure, success } from \"../output/envelope\";\n\nexport async function authCommand(command: \"login\" | \"logout\" | \"whoami\", args: string[] = []) {\n if (command === \"logout\") {\n await clearDeveloperCredentials();\n return success(\"logout\", { status: \"logged_out\" });\n }\n\n if (command === \"whoami\") {\n const stored = await readDeveloperCredentials();\n const envToken = process.env.HYPRCART_DEVELOPER_TOKEN;\n const tokenConfigured = Boolean(envToken || (stored && !credentialsExpired(stored)));\n return success(\"whoami\", {\n realm: \"developer\",\n email: process.env.HYPRCART_DEVELOPER_EMAIL ?? stored?.email ?? null,\n tokenConfigured,\n source: envToken ? \"env\" : stored ? \"credentials_file\" : \"none\",\n expiresAt: stored?.expiresAt ?? null,\n status: stored && credentialsExpired(stored) ? \"expired\" : tokenConfigured ? \"authenticated\" : \"anonymous\",\n });\n }\n\n const token = readFlag(args, \"--token\");\n if (token) {\n const email = readFlag(args, \"--email\") ?? null;\n const expiresAt = readFlag(args, \"--expires-at\") ?? new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();\n await writeDeveloperCredentials({ realm: \"developer\", token, email, expiresAt, savedAt: new Date().toISOString() });\n return success(\"login\", { realm: \"developer\", email, tokenConfigured: true, expiresAt, mode: \"token\" });\n }\n\n try {\n const result = await runBrowserLogin({\n openBrowser: !args.includes(\"--no-open\"),\n timeoutMs: Number(readFlag(args, \"--timeout-ms\") ?? 180_000),\n onMessage: (message) => process.stderr.write(`${message}\\n`),\n });\n return success(\"login\", {\n realm: \"developer\",\n email: result.email,\n tokenConfigured: true,\n expiresAt: result.expiresAt,\n loginUrl: result.loginUrl,\n mode: \"browser_callback\",\n });\n } catch (error) {\n return failure(\"login\", \"auth.login_failed\", error instanceof Error ? error.message : \"Hyprcart login failed.\");\n }\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n const value = index >= 0 ? args[index + 1] : undefined;\n return value && !value.startsWith(\"--\") ? value : undefined;\n}\n","import { success } from \"../output/envelope\";\n\nconst docsBaseUrl = \"https://developer.hyprcart.com/docs/app-platform\";\n\nexport async function docsOpen(args: string[]) {\n const topic = args[0] ?? \"overview\";\n return success(\"docs.open\", { topic, url: `${docsBaseUrl}/${topic}` });\n}\n","import { developerToolingOperationMetadata } from \"@hyprcart/app-manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function schemaExport() {\n return success(\"schema.export\", {\n schemaVersion: \"2026-06\",\n platformVersion: \"2026-06\",\n operationMetadata: developerToolingOperationMetadata,\n docsUrls: [\"https://developer.hyprcart.com/docs/app-platform\"],\n });\n}\n","import { appContracts } from \"./commands/app-contracts\";\nimport { appDeploy } from \"./commands/app-deploy\";\nimport { appDev } from \"./commands/app-dev\";\nimport { appInit } from \"./commands/app-init\";\nimport { appInstallLink } from \"./commands/app-install-link\";\nimport { appLink } from \"./commands/app-link\";\nimport { appLogs } from \"./commands/app-logs\";\nimport { appRollback } from \"./commands/app-rollback\";\nimport { appStatus } from \"./commands/app-status\";\nimport { appValidate } from \"./commands/app-validate\";\nimport { appVersionCreate } from \"./commands/app-version-create\";\nimport { authCommand } from \"./commands/auth\";\nimport { docsOpen } from \"./commands/docs-open\";\nimport { schemaExport } from \"./commands/schema-export\";\nimport { failure, type CommandEnvelope } from \"./output/envelope\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\nexport async function runCli(argv = process.argv.slice(2)): Promise<CommandEnvelope> {\n const [root, second, third, ...rest] = argv;\n\n if (root === \"login\" || root === \"logout\" || root === \"whoami\") {\n return authCommand(root, commandArgs(second, third ? [third, ...rest] : rest));\n }\n\n if (root === \"docs\" && second === \"open\") {\n return docsOpen(commandArgs(third, rest));\n }\n\n if (root === \"schema\" && second === \"export\") {\n return schemaExport();\n }\n\n if (root !== \"app\") {\n return failure(\"unknown\", \"command.unknown\", \"Unknown command.\");\n }\n\n if (second === \"init\") return appInit(commandArgs(third, rest));\n if (second === \"link\") return appLink(commandArgs(third, rest));\n if (second === \"dev\") return appDev(commandArgs(third, rest));\n if (second === \"validate\") return appValidate();\n if (second === \"contracts\" && third === \"generate\") return appContracts();\n if (second === \"version\" && third === \"create\") return appVersionCreate();\n if (second === \"deploy\") return appDeploy(commandArgs(third, rest));\n if (second === \"install-link\") return appInstallLink(commandArgs(third, rest));\n if (second === \"status\") return appStatus();\n if (second === \"logs\") return appLogs();\n if (second === \"rollback\") return appRollback(commandArgs(third, rest));\n\n return failure(\"app\", \"command.unknown\", \"Unknown app command.\");\n}\n\nfunction commandArgs(first: string | undefined, rest: string[]): string[] {\n return first ? [first, ...rest] : rest;\n}\n\nif (isCliEntryPoint()) {\n const result = await runCli();\n process.stdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n process.exit(result.ok ? 0 : result.error?.code.startsWith(\"auth.\") ? 3 : 1);\n}\n\nexport type { CommandEnvelope };\n\nfunction isCliEntryPoint() {\n try {\n return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1] ?? \"\");\n } catch {\n return false;\n }\n}\n"],"mappings":";;;AAAA,SAAS,yBAA2C;;;ACa7C,SAAS,QAAe,SAAiB,MAAa,YAAY,gBAAgB,GAA2B;AAClH,SAAO,EAAE,IAAI,MAAM,SAAS,WAAW,KAAK;AAC9C;AAEO,SAAS,QAAQ,SAAiB,MAAc,SAAiB,YAAY,gBAAgB,GAAG,SAAmC;AACxI,SAAO;AAAA,IACL,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,MAAM,SAAS,cAAc,OAAO,GAAG,QAAQ;AAAA,EAC1D;AACF;AAEO,SAAS,kBAA0B;AACxC,SAAO,WAAW,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC;AAC3C;AAEA,SAAS,cAAc,SAAyB;AAC9C,SAAO,QACJ,QAAQ,sBAAsB,YAAY,EAC1C,QAAQ,2BAA2B,YAAY,EAC/C,QAAQ,2CAA2C,YAAY;AACpE;;;ADhCA,eAAsB,aAAa,UAAwB;AACzD,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,uBAAuB;AAAA,MACvB,QAAQ,CAAC,cAAc;AAAA,MACvB,UAAU,CAAC,EAAE,IAAI,WAAW,MAAM,oBAAoB,OAAO,8BAA8B,OAAO,EAAE,IAAI,WAAW,IAAI,cAAc,EAAE,CAAC;AAAA,MACxI,cAAc,EAAE,IAAI,EAAE,iBAAiB,UAAU,GAAG,IAAI,EAAE,iBAAiB,cAAc,EAAE;AAAA,IAC7F;AAAA,EACF;AACA,SAAO,QAAQ,0BAA0B,MAAM;AACj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","join","readFlag"]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/app-contracts.ts","../src/config/manifest.ts","../src/output/envelope.ts","../src/commands/app-deploy.ts","../src/commands/app-dev.ts","../src/commands/app-init.ts","../src/templates/materialize.ts","../src/commands/app-install-link.ts","../src/config/project-link.ts","../src/auth/credentials.ts","../src/api/developer-apps.ts","../src/commands/app-link.ts","../src/commands/app-logs.ts","../src/commands/app-rollback.ts","../src/commands/app-status.ts","../src/commands/app-validate.ts","../src/commands/app-version-create.ts","../src/auth/browser-login.ts","../src/commands/auth.ts","../src/commands/docs-open.ts","../src/commands/schema-export.ts","../src/index.ts"],"sourcesContent":["import { generateContracts, type AppManifest } from \"@hyprcart/app-manifest\";\nimport { fallbackManifest, loadProjectManifest } from \"../config/manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function appContracts(manifest?: AppManifest) {\n const result = generateContracts(manifest ?? (await loadProjectManifest()) ?? fallbackManifest());\n return success(\"app.contracts.generate\", result);\n}\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { AppManifest } from \"@hyprcart/app-manifest\";\n\nconst manifestCandidates = [\"hyprcart.app.config.ts\", \"hyprcart.app.config.mjs\", \"hyprcart.app.config.js\", \"hyprcart.app.json\"];\n\nexport async function loadProjectManifest(cwd = process.cwd()): Promise<AppManifest | null> {\n for (const candidate of manifestCandidates) {\n const path = join(cwd, candidate);\n try {\n const source = await readFile(path, \"utf8\");\n if (candidate.endsWith(\".json\")) return JSON.parse(source) as AppManifest;\n return evaluateConfigModule(source) as AppManifest;\n } catch (error) {\n if (isMissingFileError(error)) continue;\n throw new Error(`Unable to read ${candidate}: ${error instanceof Error ? error.message : \"invalid manifest\"}`);\n }\n }\n return null;\n}\n\nexport function fallbackManifest(name = \"Local app\"): AppManifest {\n return {\n name,\n version: \"0.1.0\",\n manifestVersion: \"2026-06\",\n sdkVersion: \"1.0.0\",\n platformCompatibility: \"2026-06\",\n scopes: [\"product:read\"],\n surfaces: [{ id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } }],\n translations: { en: { \"reviews.label\": \"Reviews\" }, de: { \"reviews.label\": \"Bewertungen\" } },\n };\n}\n\nfunction evaluateConfigModule(source: string): unknown {\n const expression = source\n .replace(/^\\s*export\\s+default\\s+/m, \"return \")\n .replace(/;\\s*$/, \"\");\n if (!/^\\s*return\\s+/.test(expression)) {\n throw new Error(\"expected a default-exported manifest object\");\n }\n return new Function(expression)();\n}\n\nfunction isMissingFileError(error: unknown): boolean {\n return Boolean(error && typeof error === \"object\" && \"code\" in error && (error as { code: string }).code === \"ENOENT\");\n}\n","export interface CommandEnvelope<TData = unknown> {\n ok: boolean;\n requestId: string;\n command: string;\n data?: TData;\n error?: {\n code: string;\n message: string;\n path?: string;\n docsUrl?: string;\n };\n}\n\nexport function success<TData>(command: string, data: TData, requestId = createRequestId()): CommandEnvelope<TData> {\n return { ok: true, command, requestId, data };\n}\n\nexport function failure(command: string, code: string, message: string, requestId = createRequestId(), docsUrl?: string): CommandEnvelope {\n return {\n ok: false,\n command,\n requestId,\n error: { code, message: redactMessage(message), docsUrl },\n };\n}\n\nexport function createRequestId(): string {\n return `req_cli_${Date.now().toString(36)}`;\n}\n\nfunction redactMessage(message: string): string {\n return message\n .replace(/hcdev_[a-z0-9_]+/gi, \"[redacted]\")\n .replace(/Bearer\\s+[a-z0-9._-]+/gi, \"[redacted]\")\n .replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}/gi, \"[redacted]\");\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appDeploy(args: string[]) {\n const env = readFlag(args, \"--env\") ?? \"development\";\n return success(\"app.deploy\", {\n environment: env,\n appVersionId: `devver_${Date.now().toString(36)}`,\n runtimeDeploymentId: `rtdep_${Date.now().toString(36)}`,\n status: \"deployed\",\n healthChecked: args.includes(\"--wait\"),\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { createPreviewServer, previewSurface } from \"@hyprcart/app-testing\";\nimport { success } from \"../output/envelope\";\n\nexport async function appDev(args: string[]) {\n const fixtureId = readFlag(args, \"--fixture\");\n const state = createPreviewServer();\n const preview = await previewSurface(state, \"storefront_block\", fixtureId);\n return success(\"app.dev\", {\n previewUrl: \"http://localhost:8788\",\n html: preview.html,\n diagnostics: state.diagnostics,\n remoteVersionCreated: state.remoteVersionCreated,\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { failure, success } from \"../output/envelope\";\nimport { isStarterTemplateKind, materializeTemplate, starterTemplate } from \"../templates/materialize\";\n\nexport async function appInit(args: string[], cwd = process.cwd()) {\n const name = positionalArgs(args)[0] ?? \"my-hyprcart-app\";\n const template = readFlag(args, \"--template\") ?? \"storefront-block\";\n if (!isStarterTemplateKind(template)) {\n return failure(\"app.init\", \"template.unsupported\", `Unsupported template: ${template}.`);\n }\n const target = join(cwd, name);\n await mkdir(target, { recursive: true });\n const files = await materializeTemplate(starterTemplate(name, template), target);\n return success(\"app.init\", { projectPath: target, template, files });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction positionalArgs(args: string[]): string[] {\n return args.filter((arg, index) => !arg.startsWith(\"--\") && !args[index - 1]?.startsWith(\"--\"));\n}\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nexport interface TemplateFile {\n path: string;\n content: string;\n}\n\nexport type StarterTemplateKind =\n | \"storefront-block\"\n | \"admin-surface\"\n | \"checkout-function\"\n | \"pixel-event\"\n | \"multi-surface\";\n\nexport function starterTemplate(appName: string, kind: StarterTemplateKind = \"storefront-block\"): TemplateFile[] {\n const surface = surfaceForTemplate(kind);\n return [\n {\n path: \"hyprcart.app.config.ts\",\n content: `export default {\n name: ${JSON.stringify(appName)},\n version: \"0.1.0\",\n manifestVersion: \"2026-06\",\n sdkVersion: \"1.0.0\",\n platformCompatibility: \"2026-06\",\n scopes: [\"product:read\"],\n surfaces: [${JSON.stringify(surface)}],\n translations: { en: { \"reviews.label\": \"Reviews\" }, de: { \"reviews.label\": \"Bewertungen\" } },\n resources: { bundleSizeBytes: 42000 }\n};\n`,\n },\n {\n path: \"package.json\",\n content: `${JSON.stringify(\n {\n name: appName,\n version: \"0.1.0\",\n type: \"module\",\n scripts: {\n dev: \"hyprcart app dev\",\n validate: \"hyprcart app validate\",\n contracts: \"hyprcart app contracts generate\",\n test: \"vitest run tests\",\n \"test:preview\": \"playwright test playwright/app-preview.spec.ts\",\n \"deploy:dev\": \"hyprcart app deploy --env development\",\n \"install-link\": \"hyprcart app install-link create\",\n },\n dependencies: {\n \"@hyprcart/app-sdk\": \"^1.0.0\",\n },\n devDependencies: {\n \"@hyprcart/cli\": \"^1.0.0\",\n \"@hyprcart/app-testing\": \"^1.0.0\",\n \"@playwright/test\": \"^1.60.0\",\n vitest: \"^4.0.18\",\n typescript: \"^5.7.2\",\n },\n },\n null,\n 2,\n )}\\n`,\n },\n { path: surface.entry, content: `export function HyprcartSurface() { return \"<section>${kind}</section>\"; }\\n` },\n { path: \"locales/en.json\", content: `${JSON.stringify({ \"reviews.label\": \"Reviews\" }, null, 2)}\\n` },\n { path: \"locales/de.json\", content: `${JSON.stringify({ \"reviews.label\": \"Bewertungen\" }, null, 2)}\\n` },\n { path: \"fixtures/product.basic.json\", content: `${JSON.stringify({ id: \"prod_1\", title: \"Deep Moisture\" }, null, 2)}\\n` },\n { path: \"tests/validation.test.ts\", content: `import { describe, expect, it } from \"vitest\";\\ndescribe(\"app\", () => { it(\"has tests\", () => expect(true).toBe(true)); });\\n` },\n {\n path: \"playwright/app-preview.spec.ts\",\n content: `import { expect, test } from \"@playwright/test\";\\n\\ntest(\"preview renders a page\", async ({ page }) => {\\n await page.goto(process.env.HYPRCART_PREVIEW_URL ?? \"http://localhost:8788\");\\n await expect(page.locator(\"body\")).toBeVisible();\\n});\\n`,\n },\n {\n path: \"README.md\",\n content: `# ${appName}\\n\\nEdit \\`hyprcart.app.config.ts\\` in your IDE, then run \\`npx hyprcart login\\` and \\`npx hyprcart app link\\` to choose an existing app, or \\`npx hyprcart app link --create\\` to create one from this project.\\n\\nRun \\`npm run dev\\`, \\`npm run validate\\`, and \\`npm run deploy:dev\\`.\\n\\nFor one-off CLI commands, use \\`npx hyprcart <command>\\` unless you installed \\`@hyprcart/cli\\` globally.\\n`,\n },\n ];\n}\n\nexport function isStarterTemplateKind(value: string): value is StarterTemplateKind {\n return [\"storefront-block\", \"admin-surface\", \"checkout-function\", \"pixel-event\", \"multi-surface\"].includes(value);\n}\n\nfunction surfaceForTemplate(kind: StarterTemplateKind) {\n if (kind === \"admin-surface\") {\n return { id: \"reviews\", type: \"admin_surface\", entry: \"src/admin/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"checkout-function\") {\n return { id: \"reviews\", type: \"checkout_function\", entry: \"src/checkout/reviews.ts\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"pixel-event\") {\n return { id: \"reviews\", type: \"pixel\", entry: \"src/pixel/reviews.ts\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n if (kind === \"multi-surface\") {\n return { id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n }\n return { id: \"reviews\", type: \"storefront_block\", entry: \"src/storefront/reviews.tsx\", label: { en: \"Reviews\", de: \"Bewertungen\" } };\n}\n\nexport async function materializeTemplate(files: TemplateFile[], cwd: string): Promise<string[]> {\n const written: string[] = [];\n for (const file of files) {\n const fullPath = join(cwd, file.path);\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, file.content, { flag: \"wx\" });\n written.push(file.path);\n }\n return written;\n}\n","import { failure, success } from \"../output/envelope\";\n\nexport async function appInstallLink(args: string[]) {\n const subcommand = args[0];\n if (subcommand === \"revoke\") {\n return success(\"app.install-link.revoke\", { privateInstallUrlId: args[1], status: \"revoked\" });\n }\n\n const orgId = readFlag(args, \"--org\");\n if (!orgId) {\n return failure(\"app.install-link.create\", \"organization.missing\", \"Provide --org <orgId>.\");\n }\n\n const token = `hcdev_${Date.now().toString(36)}`;\n const privateInstallUrlId = `hcil_${Date.now().toString(36)}`;\n const installUrl = new URL(\"https://hyprcart.com/apps/install/private\");\n installUrl.searchParams.set(\"hcil\", privateInstallUrlId);\n installUrl.searchParams.set(\"token\", token);\n\n return success(\"app.install-link.create\", {\n privateInstallUrlId,\n installUrl: installUrl.toString(),\n appVersionId: readFlag(args, \"--version\") ?? \"devver_local\",\n environment: readFlag(args, \"--env\") ?? \"development\",\n allowedOrganizationId: orgId,\n allowedUserEmail: readFlag(args, \"--user\"),\n expiresAt: readFlag(args, \"--expires-at\") ?? null,\n maxUses: Number(readFlag(args, \"--max-uses\") ?? 1),\n });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface ProjectLink {\n appId: string;\n teamId: string;\n appSlug: string;\n environment: string;\n developerApiUrl: string;\n linkedAt: string;\n previousLinks?: ProjectLink[];\n}\n\nconst linkDirectory = \".hyprcart\";\nconst linkFile = \"project.json\";\n\nexport async function readProjectLink(cwd = process.cwd()): Promise<ProjectLink | null> {\n try {\n const raw = await readFile(join(cwd, linkDirectory, linkFile), \"utf8\");\n return JSON.parse(raw) as ProjectLink;\n } catch {\n return null;\n }\n}\n\nexport async function writeProjectLink(link: ProjectLink, cwd = process.cwd(), force = false): Promise<ProjectLink> {\n const existing = await readProjectLink(cwd);\n if (existing && existing.appId !== link.appId && !force) {\n throw new Error(\"Project is already linked to another app. Re-run with --force to relink.\");\n }\n\n await mkdir(join(cwd, linkDirectory), { recursive: true });\n\n if (existing && existing.appId !== link.appId) {\n await rename(join(cwd, linkDirectory, linkFile), join(cwd, linkDirectory, `project.${Date.now()}.previous.json`));\n }\n\n const next = {\n ...link,\n previousLinks: existing && existing.appId !== link.appId ? [existing, ...(existing.previousLinks ?? [])] : existing?.previousLinks,\n };\n await writeFile(join(cwd, linkDirectory, linkFile), `${JSON.stringify(next, null, 2)}\\n`);\n return next;\n}\n","import { mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nexport interface StoredDeveloperCredentials {\n realm: \"developer\";\n email: string | null;\n token: string;\n expiresAt: string;\n savedAt: string;\n}\n\nexport function credentialsPath(env: Record<string, string | undefined> = process.env): string {\n const base = env.HYPRCART_CONFIG_HOME ?? join(homedir(), \".hyprcart\");\n return join(base, \"credentials.json\");\n}\n\nexport async function readDeveloperCredentials(env: Record<string, string | undefined> = process.env): Promise<StoredDeveloperCredentials | null> {\n try {\n const parsed = JSON.parse(await readFile(credentialsPath(env), \"utf8\")) as StoredDeveloperCredentials;\n if (parsed.realm !== \"developer\" || !parsed.token) return null;\n return parsed;\n } catch {\n return null;\n }\n}\n\nexport async function writeDeveloperCredentials(credentials: StoredDeveloperCredentials, env: Record<string, string | undefined> = process.env): Promise<void> {\n const path = credentialsPath(env);\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, `${JSON.stringify(credentials, null, 2)}\\n`, { mode: 0o600 });\n}\n\nexport async function clearDeveloperCredentials(env: Record<string, string | undefined> = process.env): Promise<void> {\n await rm(credentialsPath(env), { force: true });\n}\n\nexport function credentialsExpired(credentials: StoredDeveloperCredentials, now = new Date()): boolean {\n return new Date(credentials.expiresAt).getTime() <= now.getTime();\n}\n","import type { AppManifest } from \"@hyprcart/app-manifest\";\n\nexport interface DeveloperCliApp {\n id: string;\n teamId: string;\n teamName: string;\n slug: string;\n displayName: string;\n status: string;\n latestDraftVersionId: string | null;\n latestValidatedVersionId: string | null;\n}\n\nexport interface DeveloperCliTeam {\n id: string;\n slug: string;\n name: string;\n role: string;\n apps: DeveloperCliApp[];\n}\n\nexport interface DeveloperCliAppsPayload {\n account: { id: string; email: string };\n teams: DeveloperCliTeam[];\n}\n\nexport async function listDeveloperApps(options: DeveloperCliApiOptions): Promise<DeveloperCliAppsPayload> {\n const response = await callCliAppsApi(`${developerOrigin(options)}/cli/apps`, {\n method: \"GET\",\n token: options.token,\n fetchImpl: options.fetchImpl,\n });\n return response.data as DeveloperCliAppsPayload;\n}\n\nexport async function createDeveloperApp(\n input: { teamId?: string; name: string; slug?: string; description?: string; manifest: AppManifest },\n options: DeveloperCliApiOptions,\n): Promise<DeveloperCliAppsPayload & { app: DeveloperCliApp }> {\n const response = await callCliAppsApi(`${developerOrigin(options)}/cli/apps`, {\n method: \"POST\",\n token: options.token,\n fetchImpl: options.fetchImpl,\n body: JSON.stringify(input),\n });\n return response.data as DeveloperCliAppsPayload & { app: DeveloperCliApp };\n}\n\nasync function callCliAppsApi(\n url: string,\n options: { method: \"GET\" | \"POST\"; token: string; fetchImpl?: typeof fetch; body?: string },\n): Promise<{ data: unknown }> {\n const response = await (options.fetchImpl ?? fetch)(url, {\n method: options.method,\n headers: {\n Authorization: `Bearer ${options.token}`,\n ...(options.body ? { \"content-type\": \"application/json\" } : {}),\n },\n body: options.body,\n });\n const payload = (await response.json().catch(() => null)) as ApiPayload | null;\n if (!response.ok || !payload?.ok) {\n const error = payload?.error;\n throw new DeveloperCliApiError(error?.code ?? \"developer_api.failed\", error?.message ?? \"Developer API request failed.\", payload?.data);\n }\n return { data: payload.data };\n}\n\nfunction developerOrigin(options: DeveloperCliApiOptions): string {\n return (options.origin ?? \"https://developer.hyprcart.com\").replace(/\\/$/, \"\");\n}\n\nexport class DeveloperCliApiError extends Error {\n constructor(\n public code: string,\n message: string,\n public data?: unknown,\n ) {\n super(message);\n }\n}\n\ntype DeveloperCliApiOptions = {\n token: string;\n origin?: string;\n fetchImpl?: typeof fetch;\n};\n\ntype ApiPayload = {\n ok: boolean;\n data?: unknown;\n error?: { code: string; message: string };\n};\n","import { failure, success } from \"../output/envelope\";\nimport { writeProjectLink } from \"../config/project-link\";\nimport { credentialsExpired, readDeveloperCredentials } from \"../auth/credentials\";\nimport { fallbackManifest, loadProjectManifest } from \"../config/manifest\";\nimport { createDeveloperApp, DeveloperCliApiError, listDeveloperApps, type DeveloperCliApp, type DeveloperCliAppsPayload, type DeveloperCliTeam } from \"../api/developer-apps\";\nimport { createInterface } from \"node:readline/promises\";\nimport type { Readable, Writable } from \"node:stream\";\n\nexport async function appLink(args: string[], cwd = process.cwd(), options: AppLinkOptions = {}) {\n const environment = readFlag(args, \"--env\") ?? \"development\";\n const developerApiUrl = readFlag(args, \"--api\") ?? \"https://developer.hyprcart.com/api/graphql\";\n const developerOrigin = readFlag(args, \"--developer-origin\") ?? \"https://developer.hyprcart.com\";\n const force = args.includes(\"--force\");\n const yes = args.includes(\"--yes\") || args.includes(\"-y\");\n const appId = readFlag(args, \"--app\");\n const explicitTeamId = readFlag(args, \"--team\");\n\n if (appId) {\n const resolved = await resolveExplicitApp(appId, explicitTeamId, developerOrigin, options);\n return writeResolvedProjectLink(resolved.app, environment, developerApiUrl, cwd, force);\n }\n\n const token = await resolveDeveloperToken(options.env);\n if (!token) {\n return failure(\"app.link\", \"auth.missing\", \"Run npx hyprcart login, then rerun npx hyprcart app link.\");\n }\n\n const manifest = (await loadProjectManifest(cwd).catch((error) => {\n throw error;\n })) ?? fallbackManifest();\n\n try {\n if (args.includes(\"--list\")) {\n const payload = await listDeveloperApps({ token, origin: developerOrigin, fetchImpl: options.fetchImpl });\n return success(\"app.link.list\", payload);\n }\n\n const payload = await listDeveloperApps({ token, origin: developerOrigin, fetchImpl: options.fetchImpl });\n const selected = args.includes(\"--create\")\n ? await createAppFromProject({\n args,\n manifest,\n payload,\n token,\n developerOrigin,\n fetchImpl: options.fetchImpl,\n })\n : await selectAppOrCreate({\n args,\n manifest,\n payload,\n token,\n developerOrigin,\n fetchImpl: options.fetchImpl,\n input: options.input,\n output: options.output,\n isTTY: options.isTTY ?? Boolean(process.stdin.isTTY),\n });\n\n if (!selected.ok) return selected.result;\n const confirmed = await confirmLink({\n app: selected.app,\n accountEmail: selected.accountEmail,\n yes,\n input: options.input,\n output: options.output,\n isTTY: options.isTTY ?? Boolean(process.stdin.isTTY),\n });\n if (!confirmed.ok) return confirmed.result;\n return writeResolvedProjectLink(selected.app, environment, developerApiUrl, cwd, force);\n } catch (error) {\n if (error instanceof DeveloperCliApiError) return failure(\"app.link\", error.code, error.message);\n return failure(\"app.link\", \"project.link.failed\", error instanceof Error ? error.message : \"Project link failed.\");\n }\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n const value = index >= 0 ? args[index + 1] : undefined;\n return value && !value.startsWith(\"--\") ? value : undefined;\n}\n\nasync function resolveDeveloperToken(env: Record<string, string | undefined> = process.env): Promise<string | null> {\n if (env.HYPRCART_DEVELOPER_TOKEN) return env.HYPRCART_DEVELOPER_TOKEN;\n const credentials = await readDeveloperCredentials(env);\n return credentials && !credentialsExpired(credentials) ? credentials.token : null;\n}\n\nasync function resolveExplicitApp(appId: string, explicitTeamId: string | undefined, developerOrigin: string, options: AppLinkOptions) {\n const token = await resolveDeveloperToken(options.env);\n if (token) {\n const payload = await listDeveloperApps({ token, origin: developerOrigin, fetchImpl: options.fetchImpl }).catch(() => null);\n const app = payload ? flattenApps(payload.teams).find((candidate) => candidate.id === appId) : null;\n if (app) return { ok: true as const, app };\n }\n\n const teamId = explicitTeamId ?? \"devteam_local\";\n return {\n ok: true as const,\n app: {\n id: appId,\n teamId,\n teamName: teamId,\n slug: appId,\n displayName: appId,\n status: \"draft\",\n latestDraftVersionId: null,\n latestValidatedVersionId: null,\n },\n };\n}\n\nasync function selectAppOrCreate(input: {\n args: string[];\n manifest: ReturnType<typeof fallbackManifest>;\n payload: DeveloperCliAppsPayload;\n token: string;\n developerOrigin: string;\n fetchImpl?: typeof fetch;\n input?: Readable;\n output?: Writable;\n isTTY: boolean;\n}): Promise<SelectedAppResult> {\n const apps = flattenApps(input.payload.teams);\n if (!input.isTTY) {\n return {\n ok: false,\n result: failure(\n \"app.link\",\n \"app.selection_required\",\n apps.length > 0\n ? \"Choose an app with --app <appId>, or run interactively to select from your registered apps.\"\n : \"No registered apps found. Run npx hyprcart app link --create --yes to create one from this project.\",\n ),\n };\n }\n\n const rl = createInterface({\n input: input.input ?? process.stdin,\n output: input.output ?? process.stderr,\n });\n try {\n const choices = apps.map((app, index) => `${index + 1}. ${app.displayName} (${app.id}) - ${app.teamName}`);\n const createIndex = apps.length + 1;\n writeLine(input.output, `\\nHyprcart app link for ${input.payload.account.email}`);\n if (choices.length > 0) writeLine(input.output, choices.join(\"\\n\"));\n writeLine(input.output, `${createIndex}. Create new app from ${input.manifest.name}`);\n const answer = (await rl.question(`Choose an app [1-${createIndex}]: `)).trim();\n const selectedIndex = Number.parseInt(answer, 10);\n if (selectedIndex >= 1 && selectedIndex <= apps.length) {\n return { ok: true, app: apps[selectedIndex - 1]!, accountEmail: input.payload.account.email };\n }\n if (selectedIndex === createIndex) {\n return createAppFromProject(input);\n }\n return { ok: false, result: failure(\"app.link\", \"app.selection_invalid\", \"Choose a listed app number.\") };\n } finally {\n rl.close();\n }\n}\n\nasync function createAppFromProject(input: {\n args: string[];\n manifest: ReturnType<typeof fallbackManifest>;\n payload: DeveloperCliAppsPayload;\n token: string;\n developerOrigin: string;\n fetchImpl?: typeof fetch;\n}): Promise<SelectedAppResult> {\n const name = readFlag(input.args, \"--name\") ?? input.manifest.name;\n const slug = readFlag(input.args, \"--slug\");\n const teamId = readFlag(input.args, \"--team\");\n const created = await createDeveloperApp(\n {\n teamId,\n name,\n slug,\n manifest: input.manifest,\n },\n { token: input.token, origin: input.developerOrigin, fetchImpl: input.fetchImpl },\n );\n return { ok: true, app: created.app, accountEmail: created.account.email };\n}\n\nasync function confirmLink(input: {\n app: DeveloperCliApp;\n accountEmail: string;\n yes: boolean;\n input?: Readable;\n output?: Writable;\n isTTY: boolean;\n}) {\n if (input.yes) return { ok: true as const };\n if (!input.isTTY) {\n return { ok: false as const, result: failure(\"app.link\", \"confirmation.required\", \"Re-run with --yes to confirm linking this project to your Developer Console account.\") };\n }\n\n const rl = createInterface({\n input: input.input ?? process.stdin,\n output: input.output ?? process.stderr,\n });\n try {\n const answer = (\n await rl.question(`Link this project as ${input.accountEmail} to ${input.app.displayName} (${input.app.id})? [y/N] `)\n )\n .trim()\n .toLowerCase();\n if (answer === \"y\" || answer === \"yes\") return { ok: true as const };\n return { ok: false as const, result: failure(\"app.link\", \"confirmation.declined\", \"Project link cancelled.\") };\n } finally {\n rl.close();\n }\n}\n\nasync function writeResolvedProjectLink(app: DeveloperCliApp, environment: string, developerApiUrl: string, cwd: string, force: boolean) {\n try {\n const link = await writeProjectLink(\n {\n appId: app.id,\n teamId: app.teamId,\n appSlug: app.slug,\n environment,\n developerApiUrl,\n linkedAt: new Date().toISOString(),\n },\n cwd,\n force,\n );\n return success(\"app.link\", { ...link, appName: app.displayName, teamName: app.teamName });\n } catch (error) {\n return failure(\"app.link\", \"project.link.conflict\", error instanceof Error ? error.message : \"Project link failed.\");\n }\n}\n\nfunction flattenApps(teams: DeveloperCliTeam[]): DeveloperCliApp[] {\n return teams.flatMap((team) => team.apps);\n}\n\nfunction writeLine(output: Writable | undefined, line: string): void {\n (output ?? process.stderr).write(`${line}\\n`);\n}\n\ntype SelectedAppResult =\n | { ok: true; app: DeveloperCliApp; accountEmail: string }\n | { ok: false; result: ReturnType<typeof failure> };\n\ntype AppLinkOptions = {\n env?: Record<string, string | undefined>;\n fetchImpl?: typeof fetch;\n input?: Readable;\n output?: Writable;\n isTTY?: boolean;\n};\n","import { success } from \"../output/envelope\";\n\nexport async function appLogs() {\n return success(\"app.logs\", {\n nodes: [\n {\n requestId: \"req_local\",\n level: \"info\",\n message: \"No production logs in local CLI stub.\",\n redacted: true,\n },\n ],\n });\n}\n","import { failure, success } from \"../output/envelope\";\n\nexport async function appRollback(args: string[]) {\n const version = readFlag(args, \"--to\");\n if (!version) {\n return failure(\"app.rollback\", \"version.missing\", \"Provide --to <versionId>.\");\n }\n return success(\"app.rollback\", { status: \"rolled_back\", appVersionId: version });\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appStatus() {\n return success(\"app.status\", { environment: \"development\", status: \"deployed\" });\n}\n","import { validateManifest, type AppManifest } from \"@hyprcart/app-manifest\";\nimport { fallbackManifest, loadProjectManifest } from \"../config/manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function appValidate(manifest?: AppManifest) {\n const result = validateManifest(manifest ?? (await loadProjectManifest()) ?? fallbackManifest());\n return success(\"app.validate\", result);\n}\n","import { success } from \"../output/envelope\";\n\nexport async function appVersionCreate() {\n return success(\"app.version.create\", {\n appVersionId: `devver_${Date.now().toString(36)}`,\n state: \"draft\",\n runtimeDeploymentRequested: false,\n });\n}\n","import { spawn } from \"node:child_process\";\nimport { createServer, type Server } from \"node:http\";\nimport { randomBytes } from \"node:crypto\";\nimport { writeDeveloperCredentials, type StoredDeveloperCredentials } from \"./credentials\";\n\nexport interface BrowserLoginResult {\n email: string | null;\n expiresAt: string;\n loginUrl: string;\n credentialsPathWritten: boolean;\n}\n\nexport async function runBrowserLogin(options: {\n openBrowser?: boolean;\n timeoutMs?: number;\n developerOrigin?: string;\n env?: Record<string, string | undefined>;\n onMessage?: (message: string) => void;\n} = {}): Promise<BrowserLoginResult> {\n const server = createServer();\n const state = randomBytes(24).toString(\"base64url\");\n const callback = await listenOnLoopback(server);\n const loginUrl = new URL(\"/cli/auth/start\", options.developerOrigin ?? \"https://developer.hyprcart.com\");\n loginUrl.searchParams.set(\"redirect_uri\", callback.redirectUri);\n loginUrl.searchParams.set(\"state\", state);\n\n const waitForCallback = waitForLoginCallback(server, state, options.timeoutMs ?? 180_000);\n options.onMessage?.(`Open ${loginUrl.toString()} to finish Hyprcart CLI login.`);\n if (options.openBrowser !== false) {\n openBrowser(loginUrl.toString(), options.onMessage);\n }\n\n try {\n const credentials = await waitForCallback;\n await writeDeveloperCredentials(credentials, options.env);\n return {\n email: credentials.email,\n expiresAt: credentials.expiresAt,\n loginUrl: loginUrl.toString(),\n credentialsPathWritten: true,\n };\n } finally {\n await closeServer(server);\n }\n}\n\nasync function listenOnLoopback(server: Server): Promise<{ redirectUri: string }> {\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject);\n server.listen(0, \"127.0.0.1\", () => resolve());\n });\n const address = server.address();\n if (!address || typeof address === \"string\") throw new Error(\"Failed to start local login callback server.\");\n return { redirectUri: `http://127.0.0.1:${address.port}/callback` };\n}\n\nfunction waitForLoginCallback(server: Server, expectedState: string, timeoutMs: number): Promise<StoredDeveloperCredentials> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => reject(new Error(\"Timed out waiting for Hyprcart login callback.\")), timeoutMs);\n server.on(\"request\", (request, response) => {\n const url = new URL(request.url ?? \"/\", \"http://127.0.0.1\");\n if (url.pathname !== \"/callback\") {\n response.writeHead(404).end(\"Not found\");\n return;\n }\n\n const state = url.searchParams.get(\"state\");\n const token = url.searchParams.get(\"token\");\n const email = url.searchParams.get(\"email\");\n const expiresAt = url.searchParams.get(\"expires_at\");\n const realm = url.searchParams.get(\"realm\");\n if (state !== expectedState || !token || !expiresAt || realm !== \"developer\") {\n response.writeHead(400, { \"content-type\": \"text/html; charset=utf-8\" }).end(\"<h1>Hyprcart CLI login failed</h1><p>Invalid callback.</p>\");\n clearTimeout(timeout);\n reject(new Error(\"Invalid Hyprcart login callback.\"));\n return;\n }\n\n response\n .writeHead(200, { \"content-type\": \"text/html; charset=utf-8\" })\n .end(\"<h1>Hyprcart CLI login complete</h1><p>You can close this tab and return to your terminal.</p>\");\n clearTimeout(timeout);\n resolve({\n realm: \"developer\",\n email,\n token,\n expiresAt,\n savedAt: new Date().toISOString(),\n });\n });\n });\n}\n\nfunction openBrowser(url: string, onMessage?: (message: string) => void): void {\n const command =\n process.platform === \"win32\"\n ? { file: \"rundll32.exe\", args: [\"url.dll,FileProtocolHandler\", url] }\n : process.platform === \"darwin\"\n ? { file: \"open\", args: [url] }\n : { file: \"xdg-open\", args: [url] };\n\n const child = spawn(command.file, command.args, { stdio: \"ignore\", detached: true });\n child.on(\"error\", () => onMessage?.(`Could not open browser automatically. Open ${url} manually.`));\n child.unref();\n}\n\nasync function closeServer(server: Server): Promise<void> {\n await new Promise<void>((resolve) => server.close(() => resolve()));\n}\n","import { clearDeveloperCredentials, credentialsExpired, readDeveloperCredentials, writeDeveloperCredentials } from \"../auth/credentials\";\nimport { runBrowserLogin } from \"../auth/browser-login\";\nimport { failure, success } from \"../output/envelope\";\n\nexport async function authCommand(command: \"login\" | \"logout\" | \"whoami\", args: string[] = []) {\n if (command === \"logout\") {\n await clearDeveloperCredentials();\n return success(\"logout\", { status: \"logged_out\" });\n }\n\n if (command === \"whoami\") {\n const stored = await readDeveloperCredentials();\n const envToken = process.env.HYPRCART_DEVELOPER_TOKEN;\n const tokenConfigured = Boolean(envToken || (stored && !credentialsExpired(stored)));\n return success(\"whoami\", {\n realm: \"developer\",\n email: process.env.HYPRCART_DEVELOPER_EMAIL ?? stored?.email ?? null,\n tokenConfigured,\n source: envToken ? \"env\" : stored ? \"credentials_file\" : \"none\",\n expiresAt: stored?.expiresAt ?? null,\n status: stored && credentialsExpired(stored) ? \"expired\" : tokenConfigured ? \"authenticated\" : \"anonymous\",\n });\n }\n\n const token = readFlag(args, \"--token\");\n if (token) {\n const email = readFlag(args, \"--email\") ?? null;\n const expiresAt = readFlag(args, \"--expires-at\") ?? new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();\n await writeDeveloperCredentials({ realm: \"developer\", token, email, expiresAt, savedAt: new Date().toISOString() });\n return success(\"login\", { realm: \"developer\", email, tokenConfigured: true, expiresAt, mode: \"token\" });\n }\n\n try {\n const result = await runBrowserLogin({\n openBrowser: !args.includes(\"--no-open\"),\n timeoutMs: Number(readFlag(args, \"--timeout-ms\") ?? 180_000),\n onMessage: (message) => process.stderr.write(`${message}\\n`),\n });\n return success(\"login\", {\n realm: \"developer\",\n email: result.email,\n tokenConfigured: true,\n expiresAt: result.expiresAt,\n loginUrl: result.loginUrl,\n mode: \"browser_callback\",\n });\n } catch (error) {\n return failure(\"login\", \"auth.login_failed\", error instanceof Error ? error.message : \"Hyprcart login failed.\");\n }\n}\n\nfunction readFlag(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n const value = index >= 0 ? args[index + 1] : undefined;\n return value && !value.startsWith(\"--\") ? value : undefined;\n}\n","import { success } from \"../output/envelope\";\n\nconst docsBaseUrl = \"https://developer.hyprcart.com/docs/app-platform\";\n\nexport async function docsOpen(args: string[]) {\n const topic = args[0] ?? \"overview\";\n return success(\"docs.open\", { topic, url: `${docsBaseUrl}/${topic}` });\n}\n","import { developerToolingOperationMetadata } from \"@hyprcart/app-manifest\";\nimport { success } from \"../output/envelope\";\n\nexport async function schemaExport() {\n return success(\"schema.export\", {\n schemaVersion: \"2026-06\",\n platformVersion: \"2026-06\",\n operationMetadata: developerToolingOperationMetadata,\n docsUrls: [\"https://developer.hyprcart.com/docs/app-platform\"],\n });\n}\n","import { appContracts } from \"./commands/app-contracts\";\nimport { appDeploy } from \"./commands/app-deploy\";\nimport { appDev } from \"./commands/app-dev\";\nimport { appInit } from \"./commands/app-init\";\nimport { appInstallLink } from \"./commands/app-install-link\";\nimport { appLink } from \"./commands/app-link\";\nimport { appLogs } from \"./commands/app-logs\";\nimport { appRollback } from \"./commands/app-rollback\";\nimport { appStatus } from \"./commands/app-status\";\nimport { appValidate } from \"./commands/app-validate\";\nimport { appVersionCreate } from \"./commands/app-version-create\";\nimport { authCommand } from \"./commands/auth\";\nimport { docsOpen } from \"./commands/docs-open\";\nimport { schemaExport } from \"./commands/schema-export\";\nimport { failure, type CommandEnvelope } from \"./output/envelope\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\nexport async function runCli(argv = process.argv.slice(2)): Promise<CommandEnvelope> {\n const [root, second, third, ...rest] = argv;\n\n if (root === \"login\" || root === \"logout\" || root === \"whoami\") {\n return authCommand(root, commandArgs(second, third ? [third, ...rest] : rest));\n }\n\n if (root === \"docs\" && second === \"open\") {\n return docsOpen(commandArgs(third, rest));\n }\n\n if (root === \"schema\" && second === \"export\") {\n return schemaExport();\n }\n\n if (root !== \"app\") {\n return failure(\"unknown\", \"command.unknown\", \"Unknown command.\");\n }\n\n if (second === \"init\") return appInit(commandArgs(third, rest));\n if (second === \"list\") return appLink([\"--list\", ...commandArgs(third, rest)]);\n if (second === \"link\") return appLink(commandArgs(third, rest));\n if (second === \"dev\") return appDev(commandArgs(third, rest));\n if (second === \"validate\") return appValidate();\n if (second === \"contracts\" && third === \"generate\") return appContracts();\n if (second === \"version\" && third === \"create\") return appVersionCreate();\n if (second === \"deploy\") return appDeploy(commandArgs(third, rest));\n if (second === \"install-link\") return appInstallLink(commandArgs(third, rest));\n if (second === \"status\") return appStatus();\n if (second === \"logs\") return appLogs();\n if (second === \"rollback\") return appRollback(commandArgs(third, rest));\n\n return failure(\"app\", \"command.unknown\", \"Unknown app command.\");\n}\n\nfunction commandArgs(first: string | undefined, rest: string[]): string[] {\n return first ? [first, ...rest] : rest;\n}\n\nif (isCliEntryPoint()) {\n const result = await runCli();\n process.stdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n process.exit(result.ok ? 0 : result.error?.code.startsWith(\"auth.\") ? 3 : 1);\n}\n\nexport type { CommandEnvelope };\n\nfunction isCliEntryPoint() {\n try {\n return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1] ?? \"\");\n } catch {\n return false;\n }\n}\n"],"mappings":";;;AA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AAQ,QAAO,QAAQ;AACtC,MAAI,WAAW,WAAY,QAAO,YAAY,YAAY,OAAO,IAAI,CAAC;AAEtE,SAAO,QAAQ,OAAO,mBAAmB,sBAAsB;AACjE;AAEA,SAAS,YAAY,OAA2B,MAA0B;AACxE,SAAO,QAAQ,CAAC,OAAO,GAAG,IAAI,IAAI;AACpC;AAEA,IAAI,gBAAgB,GAAG;AACrB,QAAM,SAAS,MAAM,OAAO;AAC5B,UAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,CAAI;AAC3D,UAAQ,KAAK,OAAO,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,OAAO,IAAI,IAAI,CAAC;AAC7E;AAIA,SAAS,kBAAkB;AACzB,MAAI;AACF,WAAO,aAAa,cAAc,YAAY,GAAG,CAAC,MAAM,aAAa,QAAQ,KAAK,CAAC,KAAK,EAAE;AAAA,EAC5F,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["readFlag","mkdir","join","join","readFlag","join","mkdir","readFlag","mkdir","readFile","writeFile","join","mkdir","readFile","writeFile","dirname","join","readFlag","developerOrigin","payload","readFlag","readFlag"]}
|