@kryd/cli 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +68 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15489,6 +15489,37 @@ async function removeDomain(apiUrl, token, projectId, host) {
15489
15489
  throw new ApiError(`Domain removal failed (${res.status})`, await parseEnvelope(res), res.status);
15490
15490
  }
15491
15491
  }
15492
+ function deployHookUrl(apiUrl, projectId) {
15493
+ return `${apiUrl}/projects/${encodeURIComponent(projectId)}/deploy-hook`;
15494
+ }
15495
+ async function createDeployHook(apiUrl, token, projectId) {
15496
+ const res = await fetch(deployHookUrl(apiUrl, projectId), {
15497
+ method: "PUT",
15498
+ headers: { authorization: `Bearer ${token}` }
15499
+ });
15500
+ if (!res.ok) {
15501
+ throw new ApiError(`Deploy hook creation failed (${res.status})`, await parseEnvelope(res), res.status);
15502
+ }
15503
+ const body = await res.json().catch(() => void 0);
15504
+ if (typeof body?.url !== "string" || typeof body.replaced !== "boolean") {
15505
+ throw new Error("Unexpected response from the API (deploy-hook create).");
15506
+ }
15507
+ return { url: body.url, replaced: body.replaced };
15508
+ }
15509
+ async function removeDeployHook(apiUrl, token, projectId) {
15510
+ const res = await fetch(deployHookUrl(apiUrl, projectId), {
15511
+ method: "DELETE",
15512
+ headers: { authorization: `Bearer ${token}` }
15513
+ });
15514
+ if (!res.ok) {
15515
+ throw new ApiError(`Deploy hook removal failed (${res.status})`, await parseEnvelope(res), res.status);
15516
+ }
15517
+ const body = await res.json().catch(() => void 0);
15518
+ if (typeof body?.removed !== "boolean") {
15519
+ throw new Error("Unexpected response from the API (deploy-hook rm).");
15520
+ }
15521
+ return { removed: body.removed };
15522
+ }
15492
15523
  async function fetchResourceStatus(apiUrl, token, path) {
15493
15524
  const res = await fetch(`${apiUrl}${path}`, {
15494
15525
  headers: { authorization: `Bearer ${token}` }
@@ -18623,6 +18654,37 @@ Kryd checks every minute; once they are right it issues a certificate and serves
18623
18654
  await reportError(err);
18624
18655
  }
18625
18656
  }
18657
+ async function runDeployHookCreate(opts) {
18658
+ const ctx = domainContext(opts, "kryd project deploy-hook create --project <projectId>");
18659
+ if (!ctx) return;
18660
+ try {
18661
+ const { url: url2, replaced } = await createDeployHook(ctx.apiUrl, ctx.token, ctx.project);
18662
+ process.stdout.write(
18663
+ `Deploy hook for ${ctx.project}${replaced ? " \u2014 replaces the previous one, which no longer works" : ""}:
18664
+
18665
+ ${url2}
18666
+
18667
+ A POST to this URL rebuilds production from the latest commit, without cache. It is shown only now: anyone with it can start a rebuild, so keep it secret. Lost or leaked? Run this command again to replace it, or \`kryd project deploy-hook rm\` to remove it.
18668
+ `
18669
+ );
18670
+ } catch (err) {
18671
+ await reportError(err);
18672
+ }
18673
+ }
18674
+ async function runDeployHookRemove(opts) {
18675
+ const ctx = domainContext(opts, "kryd project deploy-hook rm --project <projectId>");
18676
+ if (!ctx) return;
18677
+ try {
18678
+ const { removed } = await removeDeployHook(ctx.apiUrl, ctx.token, ctx.project);
18679
+ process.stdout.write(
18680
+ removed ? `Deploy hook of ${ctx.project} removed \u2014 its URL no longer works.
18681
+ ` : `${ctx.project} has no deploy hook \u2014 nothing to remove.
18682
+ `
18683
+ );
18684
+ } catch (err) {
18685
+ await reportError(err);
18686
+ }
18687
+ }
18626
18688
  function appSuffix(app) {
18627
18689
  return app && app !== "web" ? ` (app ${app})` : "";
18628
18690
  }
@@ -19437,7 +19499,7 @@ Run \`kryd env list\` to see what is set. (If you meant the runtime variable of
19437
19499
  await reportError(err);
19438
19500
  }
19439
19501
  }
19440
- var CLI_VERSION = true ? "0.10.0" : "0.0.0-dev";
19502
+ var CLI_VERSION = true ? "0.11.0" : "0.0.0-dev";
19441
19503
  var program = new Command();
19442
19504
  program.name("kryd").description("Kryd CLI").version(CLI_VERSION);
19443
19505
  program.hook("postAction", async () => {
@@ -19511,6 +19573,9 @@ project.command("list").description("List your projects \u2014 name, subdomain,
19511
19573
  project.command("rm [project]").description(
19512
19574
  "Permanently delete a project and everything Kryd created for it (by name or id; asks you to type its name)"
19513
19575
  ).option("--yes", "skip the confirmation (for non-interactive use)").option("--api-url <url>", "control-plane API base URL").action((projectArg, opts) => runProjectRemove({ ...opts, project: projectArg }));
19576
+ var deployHook = project.command("deploy-hook").description("A secret URL that rebuilds production on a POST \u2014 for a CMS webhook (e.g. Sanity on publish)");
19577
+ deployHook.command("create").description("Create the deploy hook and print its URL once (replaces an existing one)").option("--project <projectId>", "the project (default: the one linked here)").option("--api-url <url>", "control-plane API base URL").action((opts) => runDeployHookCreate(opts));
19578
+ deployHook.command("rm").description("Remove the deploy hook \u2014 its URL stops working").option("--project <projectId>", "the project (default: the one linked here)").option("--api-url <url>", "control-plane API base URL").action((opts) => runDeployHookRemove(opts));
19514
19579
  var db = program.command("db").description("Manage project databases");
19515
19580
  db.command("add [project]").description("Attach a shared or bring-your-own Postgres database to a project").option("--shared", "attach a shared managed database (the default)").option(
19516
19581
  "--connection-string <url>",
@@ -19598,6 +19663,8 @@ export {
19598
19663
  runDbRemove,
19599
19664
  runDbStatus,
19600
19665
  runDeploy,
19666
+ runDeployHookCreate,
19667
+ runDeployHookRemove,
19601
19668
  runDomainAdd,
19602
19669
  runDomainRemove,
19603
19670
  runDomainStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kryd/cli",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Kryd CLI — push a React / Vite / Next.js app to the European cloud for your AI: git push → live with SSL, one-click managed Postgres & object storage, and an EU-hosted AI gateway already wired in. Your code and your model calls stay in the EU.",
5
5
  "keywords": [
6
6
  "kryd",