@oodarun/cli 0.1.18 → 0.1.20

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/cli.js +28 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1304,9 +1304,9 @@ function failLogin(json, message) {
1304
1304
  }
1305
1305
  process.exitCode = 1;
1306
1306
  }
1307
- function whoamiCmd(opts) {
1307
+ async function whoamiCmd(opts) {
1308
1308
  const orgId = getOrgId();
1309
- const token = getAccessToken();
1309
+ const token = await ensureFreshAccessToken();
1310
1310
  if (!orgId || !token) {
1311
1311
  if (opts.json) {
1312
1312
  console.log(JSON.stringify({ ok: false, authenticated: false }));
@@ -5669,15 +5669,15 @@ function buildPublishBody(opts) {
5669
5669
  // src/cli/publish.ts
5670
5670
  var MAX_SLUG_ATTEMPTS = 5;
5671
5671
  async function publishLocalDir(opts) {
5672
- const { projectDir, slugOverride, json } = opts;
5672
+ const { projectDir, slugOverride, force, json } = opts;
5673
5673
  if (!isOrgMode()) {
5674
5674
  fail(json, "Publishing requires an organisation login. Run `ooda` and log in first.");
5675
5675
  return;
5676
5676
  }
5677
5677
  const orgId = getOrgId();
5678
- const jwt = getAccessToken();
5678
+ const jwt = await ensureFreshAccessToken();
5679
5679
  if (!orgId || !jwt) {
5680
- fail(json, "No active org session. Run `ooda` and log in first.");
5680
+ fail(json, "Not signed in (or your session expired). Run `ooda login` first.");
5681
5681
  return;
5682
5682
  }
5683
5683
  const apiBase = process.env.OODA_API_BASE || "https://api.ooda.run";
@@ -5705,11 +5705,21 @@ async function publishLocalDir(opts) {
5705
5705
  return;
5706
5706
  }
5707
5707
  let candidate = base;
5708
- if (allowSuffix) {
5709
- try {
5710
- const taken = new Set((await listSites(auth)).map((s) => s.slug));
5711
- if (taken.has(candidate)) candidate = appendSuffix(base, randomSlugSuffix());
5712
- } catch {
5708
+ let takenInOrg = /* @__PURE__ */ new Set();
5709
+ try {
5710
+ takenInOrg = new Set((await listSites(auth)).map((s) => s.slug));
5711
+ } catch {
5712
+ }
5713
+ const isOurs = (slug) => config.slug === slug;
5714
+ if (takenInOrg.has(candidate) && !isOurs(candidate) && !force) {
5715
+ if (allowSuffix) {
5716
+ candidate = appendSuffix(base, randomSlugSuffix());
5717
+ } else {
5718
+ fail(
5719
+ json,
5720
+ `A site "${candidate}" already exists in your org and isn't this project's. Publishing would overwrite it \u2014 choose a different --slug, or pass --force to overwrite on purpose.`
5721
+ );
5722
+ return;
5713
5723
  }
5714
5724
  }
5715
5725
  if (!json) {
@@ -5804,8 +5814,8 @@ var ACCESS_MODES = ["public", "password", "login"];
5804
5814
  async function runSitesCommand(args) {
5805
5815
  if (!isOrgMode()) return fail2(args.json, "Managing sites requires an organisation login. Run `ooda` and log in first.");
5806
5816
  const orgId = getOrgId();
5807
- const jwt = getAccessToken();
5808
- if (!orgId || !jwt) return fail2(args.json, "No active org session. Run `ooda` and log in first.");
5817
+ const jwt = await ensureFreshAccessToken();
5818
+ if (!orgId || !jwt) return fail2(args.json, "Not signed in (or your session expired). Run `ooda login` first.");
5809
5819
  const apiBase = process.env.OODA_API_BASE || "https://api.ooda.run";
5810
5820
  const auth = { apiBase, orgId, jwt };
5811
5821
  const sub = args.subcommand || "list";
@@ -5950,6 +5960,7 @@ publish [path]
5950
5960
  build folder. The CLI finds the build output inside it (dist, build, out,
5951
5961
  .output/public, .next/static). Requires an org login.
5952
5962
  --slug <slug> Override the slug (default: ooda.json name, else folder name)
5963
+ --force Overwrite an existing same-org site at this slug (otherwise refused)
5953
5964
  --json Machine-readable JSON output
5954
5965
 
5955
5966
  sites access <slug>
@@ -6052,7 +6063,7 @@ async function notifyIfOutdated(current, now = Date.now()) {
6052
6063
  }
6053
6064
 
6054
6065
  // src/cli/index.ts
6055
- var CLI_VERSION = "0.1.18";
6066
+ var CLI_VERSION = "0.1.20";
6056
6067
  function formatMutationError(result) {
6057
6068
  const parts = [];
6058
6069
  if (result.status !== void 0) parts.push(String(result.status));
@@ -6132,6 +6143,7 @@ function parseArgs(argv) {
6132
6143
  i++;
6133
6144
  } else if (arg === "--clear-password") flags.clearPassword = true;
6134
6145
  else if (arg === "--clear-mode") flags.clearMode = true;
6146
+ else if (arg === "--force") flags.force = true;
6135
6147
  else if (arg === "--json") flags.json = true;
6136
6148
  else if (!arg.startsWith("--")) positionals.push(arg);
6137
6149
  }
@@ -6143,6 +6155,7 @@ function parseArgs(argv) {
6143
6155
  } else if (command === "publish") {
6144
6156
  args.publishTarget = positionals[0];
6145
6157
  args.publishSlug = flags.slug;
6158
+ args.publishForce = Boolean(flags.force);
6146
6159
  } else if (command === "sites") {
6147
6160
  args.sites = {
6148
6161
  subcommand: positionals[0],
@@ -6605,7 +6618,7 @@ async function main() {
6605
6618
  if (args.command === "publish") {
6606
6619
  await ensureAuth({ requireClaudeToken: false });
6607
6620
  const dir = args.publishTarget ? path12.resolve(args.publishTarget) : cwd;
6608
- await publishLocalDir({ projectDir: dir, slugOverride: args.publishSlug, json: args.json });
6621
+ await publishLocalDir({ projectDir: dir, slugOverride: args.publishSlug, force: args.publishForce, json: args.json });
6609
6622
  process.exit(process.exitCode ?? 0);
6610
6623
  }
6611
6624
  if (args.command === "sites") {
@@ -6618,7 +6631,7 @@ async function main() {
6618
6631
  process.exit(process.exitCode ?? 0);
6619
6632
  }
6620
6633
  if (args.command === "whoami") {
6621
- whoamiCmd({ json: args.json });
6634
+ await whoamiCmd({ json: args.json });
6622
6635
  process.exit(process.exitCode ?? 0);
6623
6636
  }
6624
6637
  if (args.command === "logout") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oodarun/cli",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Launch Claude Code on cloud dev environments",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",