clawnify 0.11.5 → 0.11.6

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.
@@ -316,6 +316,42 @@ async function uploadRedeploy(appId, archive, orgId) {
316
316
  const err = await res.json().catch(() => ({}));
317
317
  return { ok: false, error: err.error || res.statusText };
318
318
  }
319
+ async function repoDeploy(opts) {
320
+ const res = await api.post(
321
+ "/v1/apps/deploy",
322
+ {
323
+ repo: opts.repo,
324
+ branch: "main",
325
+ subdir: opts.subdir,
326
+ name: opts.name,
327
+ create_new: opts.createNew
328
+ },
329
+ { orgId: opts.orgId }
330
+ );
331
+ if (res.ok) {
332
+ const data = await res.json();
333
+ return { ok: true, data };
334
+ }
335
+ if (res.status === 409) {
336
+ const conflict = await res.json();
337
+ return { ok: false, conflict };
338
+ }
339
+ const err = await res.json().catch(() => ({}));
340
+ return { ok: false, error: err.error || res.statusText };
341
+ }
342
+ async function repoRedeploy(appId, opts, orgId) {
343
+ const res = await api.post(
344
+ `/v1/apps/${appId}/redeploy`,
345
+ { repo: opts.repo, branch: "main", subdir: opts.subdir },
346
+ { orgId }
347
+ );
348
+ if (res.ok) {
349
+ const data = await res.json();
350
+ return { ok: true, data };
351
+ }
352
+ const err = await res.json().catch(() => ({}));
353
+ return { ok: false, error: err.error || res.statusText };
354
+ }
319
355
  function assertNodeVersion() {
320
356
  const [major] = process.versions.node.split(".").map(Number);
321
357
  if (major < 22) {
@@ -374,6 +410,10 @@ async function workspaceOrgId(resolvedDir) {
374
410
  }
375
411
  return match.id;
376
412
  }
413
+ function describeConflict(conflict) {
414
+ const existing = conflict.existing_app_slug ? `'${conflict.existing_app_name}' (${conflict.existing_app_slug})` : `'${conflict.existing_app_name}'`;
415
+ return conflict.error === "app_from_repo_exists_in_org" ? `This organization already has an app deployed from this repo: ${existing}.` : `Slug '${conflict.slug}' is taken in this organization (currently held by an app named ${existing}).`;
416
+ }
377
417
  async function resolveConflictDecision(options, conflict) {
378
418
  if (options.updateExisting) return "update";
379
419
  if (options.createNew) return "create";
@@ -381,7 +421,7 @@ async function resolveConflictDecision(options, conflict) {
381
421
  if (!process.stdin.isTTY) {
382
422
  console.error(
383
423
  `
384
- Slug '${conflict.slug}' is taken in this organization.
424
+ ${describeConflict(conflict)}
385
425
  Pass one of:
386
426
  --update-existing overwrite the existing app
387
427
  --create-new deploy as '${conflict.suggested_slug}'
@@ -390,11 +430,9 @@ async function resolveConflictDecision(options, conflict) {
390
430
  );
391
431
  process.exit(EXIT_CONFLICT_NEEDS_DECISION);
392
432
  }
393
- console.log(
394
- `
395
- Slug '${conflict.slug}' is taken in this organization (currently held by an app named '${conflict.existing_app_name}').
396
- `
397
- );
433
+ console.log(`
434
+ ${describeConflict(conflict)}
435
+ `);
398
436
  console.log(` 1) Update that app \u2014 deploy this source over it`);
399
437
  console.log(` 2) Create a new app at slug '${conflict.suggested_slug}'
400
438
  `);
@@ -654,23 +692,45 @@ async function deployCommand(dir, options = {}) {
654
692
  if (options.dryRun) {
655
693
  console.log(
656
694
  `
657
- Dry run \u2014 would deploy from GitHub repo '${repo}' (branch: main${subdir ? `, path: ${subdir}` : ""})
695
+ Dry run \u2014 would deploy from GitHub repo '${repo}' (branch: main${subdir ? `, path: ${subdir}` : ""}${options.name ? `, name: ${options.name}` : ""})
658
696
  `
659
697
  );
660
698
  return;
661
699
  }
662
700
  console.log(`Deploying from ${repo}${subdir ? `/${subdir}` : ""}...`);
663
701
  const orgId = options.org ? await resolveOrgId(options, null) : void 0;
664
- const res = await api.post("/v1/apps/deploy", { repo, branch: "main", subdir }, { orgId });
665
- if (!res.ok) {
666
- const err = await res.json().catch(() => ({}));
667
- console.error(`Deploy failed: ${err.error || res.statusText}`);
702
+ let result2 = await repoDeploy({ repo, subdir, name: options.name, orgId });
703
+ if (!result2.ok && "conflict" in result2) {
704
+ const decision = await resolveConflictDecision(options, result2.conflict);
705
+ if (decision === "update") {
706
+ const existingSlug = result2.conflict.existing_app_slug ?? result2.conflict.slug;
707
+ console.log(`Updating ${result2.conflict.existing_app_name} (${existingSlug})...`);
708
+ const redeployed = await repoRedeploy(result2.conflict.existing_app_id, { repo, subdir }, orgId);
709
+ if (!redeployed.ok) {
710
+ console.error(`Deploy failed: ${redeployed.error}`);
711
+ process.exit(1);
712
+ }
713
+ result2 = { ok: true, data: redeployed.data };
714
+ } else if (decision === "create") {
715
+ result2 = await repoDeploy({
716
+ repo,
717
+ subdir,
718
+ name: result2.conflict.suggested_slug,
719
+ createNew: true,
720
+ orgId
721
+ });
722
+ } else {
723
+ process.exit(EXIT_CONFLICT_NEEDS_DECISION);
724
+ }
725
+ }
726
+ if (!result2.ok) {
727
+ const errMsg = "conflict" in result2 ? "Slug still conflicts" : result2.error;
728
+ console.error(`Deploy failed: ${errMsg}`);
668
729
  process.exit(1);
669
730
  }
670
- const data = await res.json();
671
- appId = data.app_id;
672
- slug = data.slug;
673
- appToken = data.app_token;
731
+ appId = result2.data.app_id;
732
+ slug = result2.data.slug;
733
+ appToken = result2.data.app_token;
674
734
  resolvedOrgId = orgId;
675
735
  } else {
676
736
  const resolvedDir = dir ? path2.resolve(dir) : process.cwd();
@@ -1341,7 +1401,7 @@ function agentByName(name) {
1341
1401
  var ALL_AGENTS = DETECTORS.map((d) => d.agent);
1342
1402
 
1343
1403
  // src/lib/skills/content.gen.ts
1344
- var CLI_VERSION = "0.11.5";
1404
+ var CLI_VERSION = "0.11.6";
1345
1405
  var BUNDLED_SKILLS = [
1346
1406
  {
1347
1407
  name: "build-a-clawnify-app",
@@ -3676,7 +3736,7 @@ async function runCli() {
3676
3736
  program.command("init [dir]").description("Scaffold a new Clawnify project (app, website, or agent)").option("--type <type>", "Project type: app, website, or agent (skips prompt)").option("--name <name>", "Project name (skips prompt)").option("--template <template>", "App template: blank or crud (apps only)").option("--storage", "Enable file uploads (R2) \u2014 apps only").option("-y, --yes", "Non-interactive: use all defaults (app, blank, no storage)").option("--no-ai-files", "Skip installing AI files (rules + skills + MCP) after scaffolding").action(initCommand);
3677
3737
  program.command("dev [dir]").description("Start local dev server").option("--port <port>", "API server port (default: 8787)").action(devCommand);
3678
3738
  program.command("login").description("Authenticate with Clawnify").action(loginCommand);
3679
- program.command("deploy [dir]").description("Deploy an app, website, or agent to Clawnify").option("--from <repo>", "Deploy from a GitHub repo (owner/repo)").option("--server <server-id>", "Agent deploy: the server hosting the target agent (saved as a link)").option("--agent <name>", "Agent deploy: the named agent to push to (default: main)").option("--path <subdir>", "Subdirectory within the --from repo that holds the app (monorepo)").option("--name <name>", "Override app name").option("--org <slug-or-id>", "Deploy to a specific org (overrides active org)").option("-y, --yes", "Non-interactive: on slug conflict, update existing app").option("--update-existing", "Non-interactive: on slug conflict, overwrite existing app").option("--create-new", "Non-interactive: on slug conflict, create a new app with the suggested slug").option("--dry-run", "List files that would be uploaded; do not deploy").option("--no-sync", "Skip the post-deploy schema.sql sync into the local working directory").action(deployCommand);
3739
+ program.command("deploy [dir]").description("Deploy an app, website, or agent to Clawnify").option("--from <repo>", "Deploy from a GitHub repo (owner/repo)").option("--server <server-id>", "Agent deploy: the server hosting the target agent (saved as a link)").option("--agent <name>", "Agent deploy: the named agent to push to (default: main)").option("--path <subdir>", "Subdirectory within the --from repo that holds the app (monorepo)").option("--name <name>", "Override app name").option("--org <slug-or-id>", "Deploy to a specific org (overrides active org)").option("-y, --yes", "Non-interactive: on conflict, update the existing app").option("--update-existing", "Non-interactive: on conflict, overwrite the existing app").option("--create-new", "Non-interactive: on conflict, create a new app with the suggested slug").option("--dry-run", "List files that would be uploaded; do not deploy").option("--no-sync", "Skip the post-deploy schema.sql sync into the local working directory").action(deployCommand);
3680
3740
  program.command("link <app-id-or-slug>").description("Link the current directory to an existing Clawnify app (accepts id or slug)").option("--dir <dir>", "Directory to link (default: cwd)").option("--org <slug-or-id>", "Restrict the app lookup to a specific org").action(linkCommand);
3681
3741
  const pull = program.command("pull").description("Pull artifacts from a deployed app into the current directory");
3682
3742
  pull.command("schema").description("Fetch the deployed app's current schema.sql snapshot into the local repo").option("--from <app-id-or-slug>", "App to fetch from (required)").option("--out <path>", "Where to write (default: ./schema.sql)").option("--force", "Overwrite a locally-modified or uncommitted schema.sql").option("--org <slug-or-id>", "Restrict the app lookup to a specific org").action(pullSchemaCommand);
@@ -3736,4 +3796,4 @@ async function runCli() {
3736
3796
  export {
3737
3797
  runCli
3738
3798
  };
3739
- //# sourceMappingURL=cli-ON2IFJMD.js.map
3799
+ //# sourceMappingURL=cli-UFUSSG3S.js.map