@yolo-labs/yolo-cli 0.23.0 → 0.24.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.
@@ -32,7 +32,7 @@ function defaultStatPath(p) {
32
32
  }
33
33
  }
34
34
  import { runDeployShip, exitCodeForFailure, formatShipSuccess, formatPending, formatFail, } from './deploy-ship.js';
35
- import { resolveDeployContext, createProject, getProjectStatus, listProjects, rollbackProject, renameProject, addAlias, removeAlias, setRedirect, deleteProject, cloneProject, getLogs, pollTail, queryD1, } from './deploy-client.js';
35
+ import { resolveDeployContext, createProject, getProjectStatus, listProjects, rollbackProject, unpublishProject, republishProject, renameProject, addAlias, removeAlias, setRedirect, deleteProject, cloneProject, getLogs, pollTail, queryD1, } from './deploy-client.js';
36
36
  import { readDeployConfig, writeDeployConfig } from './deploy-config.js';
37
37
  import { adaptWrangler, detectProjectShape } from './deploy-detect.js';
38
38
  import { defaultReadFile } from './auth-context.js';
@@ -44,6 +44,8 @@ const USAGE = [
44
44
  ' yolo deploy status [--json]',
45
45
  ' yolo deploy logs [--tail] [--since <dur>] [--json]',
46
46
  ' yolo deploy rollback [releaseId] [--json]',
47
+ ' yolo deploy offline [--json]',
48
+ ' yolo deploy publish [--json]',
47
49
  ' yolo deploy rename <newslug> [--no-redirect] [--json]',
48
50
  ' yolo deploy alias <slug> [--json]',
49
51
  ' yolo deploy alias rm <slug> [--json]',
@@ -73,6 +75,10 @@ export async function runDeployCmd(args, deps = {}) {
73
75
  return runLogsCmd(args.slice(1), deps, io);
74
76
  if (sub === 'rollback')
75
77
  return runRollbackCmd(args.slice(1), deps, io);
78
+ if (sub === 'offline')
79
+ return runOfflineCmd(args.slice(1), deps, io);
80
+ if (sub === 'publish')
81
+ return runPublishCmd(args.slice(1), deps, io);
76
82
  if (sub === 'rename')
77
83
  return runRenameCmd(args.slice(1), deps, io);
78
84
  if (sub === 'alias')
@@ -825,6 +831,75 @@ async function runRollbackCmd(args, deps, io) {
825
831
  io.out(`OK: rolled back ${linked.slug ?? linked.projectId} to release ${releaseId}${url ? ` → ${url}` : ''}\n`);
826
832
  return 0;
827
833
  }
834
+ /** Shared parser for the no-positional-arg deploy subcommands (offline/publish): only `--json`. */
835
+ function parseJsonOnlyArgs(args) {
836
+ let jsonOutput = false;
837
+ for (const a of args) {
838
+ if (a === '--json')
839
+ jsonOutput = true;
840
+ else if (a.startsWith('--'))
841
+ return { ok: false, message: `unknown option: ${a}` };
842
+ else
843
+ return { ok: false, message: `unexpected positional argument: ${a}` };
844
+ }
845
+ return { ok: true, jsonOutput };
846
+ }
847
+ async function runOfflineCmd(args, deps, io) {
848
+ const parsed = parseJsonOnlyArgs(args);
849
+ if (!parsed.ok) {
850
+ io.err(`yolo deploy offline: ${parsed.message}\nUsage: yolo deploy offline [--json]\n`);
851
+ return 64;
852
+ }
853
+ const linked = requireLink(deps, io);
854
+ if (!linked.ok)
855
+ return linked.exitCode;
856
+ const auth = resolveAuth(deps);
857
+ if (!auth.ok) {
858
+ io.err(`${formatFail({ kind: 'auth', message: auth.message })}\n`);
859
+ return 78;
860
+ }
861
+ const unpublish = deps.unpublishProjectImpl ?? unpublishProject;
862
+ const result = await unpublish(auth.context, linked.projectId);
863
+ if (!result.ok) {
864
+ io.err(`${formatFail(result)}\n`);
865
+ return exitCodeForFailure(result.kind);
866
+ }
867
+ if (parsed.jsonOutput) {
868
+ io.out(`${JSON.stringify(result.value, null, 2)}\n`);
869
+ return 0;
870
+ }
871
+ io.out(`OK: took ${linked.slug ?? linked.projectId} offline (release kept — run 'yolo deploy publish' to bring it back)\n`);
872
+ return 0;
873
+ }
874
+ async function runPublishCmd(args, deps, io) {
875
+ const parsed = parseJsonOnlyArgs(args);
876
+ if (!parsed.ok) {
877
+ io.err(`yolo deploy publish: ${parsed.message}\nUsage: yolo deploy publish [--json]\n`);
878
+ return 64;
879
+ }
880
+ const linked = requireLink(deps, io);
881
+ if (!linked.ok)
882
+ return linked.exitCode;
883
+ const auth = resolveAuth(deps);
884
+ if (!auth.ok) {
885
+ io.err(`${formatFail({ kind: 'auth', message: auth.message })}\n`);
886
+ return 78;
887
+ }
888
+ const republish = deps.republishProjectImpl ?? republishProject;
889
+ const result = await republish(auth.context, linked.projectId);
890
+ if (!result.ok) {
891
+ io.err(`${formatFail(result)}\n`);
892
+ return exitCodeForFailure(result.kind);
893
+ }
894
+ if (parsed.jsonOutput) {
895
+ io.out(`${JSON.stringify(result.value, null, 2)}\n`);
896
+ return 0;
897
+ }
898
+ const raw = (result.value && typeof result.value === 'object' ? result.value : {});
899
+ const url = str(raw.url);
900
+ io.out(`OK: published ${linked.slug ?? linked.projectId}${url ? ` → ${url}` : ''}\n`);
901
+ return 0;
902
+ }
828
903
  export function parseRenameArgs(args) {
829
904
  let slug;
830
905
  let keepOldAsRedirect = true;
@@ -207,6 +207,14 @@ export async function listProjects(ctx) {
207
207
  export async function rollbackProject(ctx, projectId, request = {}) {
208
208
  return jsonLeg(ctx, `/deploy/projects/${enc(projectId)}/rollback`, { method: 'POST', jsonBody: request });
209
209
  }
210
+ /** POST /v1/deploy/projects/:id/unpublish — take a live project offline (reversible). */
211
+ export async function unpublishProject(ctx, projectId) {
212
+ return jsonLeg(ctx, `/deploy/projects/${enc(projectId)}/unpublish`, { method: 'POST' });
213
+ }
214
+ /** POST /v1/deploy/projects/:id/republish — bring an offline project back online. */
215
+ export async function republishProject(ctx, projectId) {
216
+ return jsonLeg(ctx, `/deploy/projects/${enc(projectId)}/republish`, { method: 'POST' });
217
+ }
210
218
  /**
211
219
  * POST /v1/deploy/projects/:id/resources/:rid/query (Phase 2).
212
220
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-labs/yolo-cli",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "YOLO Studio substrate CLI — owns yolo plan/workspace/artifact substrate-tooling commands. Distinct from yolo-code (the agent CLI) and yolo-router (the LLM gateway client).",
5
5
  "license": "MIT",
6
6
  "type": "module",