@sanity/cli-core 2.8.1 → 3.0.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.
@@ -25,36 +25,32 @@ export declare interface UndeployConfigTarget extends UndeployTargetDetails {
25
25
  id: null;
26
26
  }
27
27
 
28
+ /** Collected locally, so a dry run reports it too. */
29
+ export declare interface UndeployPayload {
30
+ /** The configured `deployment.appId`; `null` when none is set. */
31
+ appId: string | null;
32
+ type: "coreApp" | "studio";
33
+ /** Media-library config summary. */
34
+ config?: string;
35
+ services?: object[];
36
+ views?: object[];
37
+ }
38
+
28
39
  /**
29
40
  * What an undeploy deletes, resolved once and read by every report — the
30
41
  * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —
31
- * so the human and machine outputs can't drift. Adapters may extend the
32
- * variants with backend-specific fields; they serialize into `--json` as-is,
33
- * except the report-only `summary`.
42
+ * so the human and machine outputs can't drift.
34
43
  */
35
44
  export declare type UndeployTarget =
36
45
  UndeployApplicationTarget | UndeployConfigTarget;
37
46
 
38
47
  declare interface UndeployTargetDetails {
39
- /** Details of the deployment currently being served; `null` when none is live. */
40
- activeDeployment: {
41
- deployedAt: string;
42
- deployedBy: string;
43
- } | null;
44
- /** Hostname the application is served from; freed for anyone to claim after undeploy. */
45
- appHost: string | null;
46
- createdAt: string | null;
47
- organizationId: string | null;
48
- projectId: string | null;
49
48
  title: string | null;
50
49
  type: "coreApp" | "studio";
51
- /** Where the deployed studio/app is currently reachable. */
52
50
  url: string | null;
53
- /**
54
- * Adapter-authored report lines about what gets deleted (interfaces, config
55
- * snapshots, …), rendered under the target details. Built from the same data
56
- * the adapter puts on its target, so the report can't drift from the payload.
57
- */
51
+ application?: object;
52
+ payload?: UndeployPayload;
53
+ /** Human-report lines only; never serialized. */
58
54
  summary?: string[];
59
55
  }
60
56
 
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * What an undeploy deletes, resolved once and read by every report — the
3
3
  * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —
4
- * so the human and machine outputs can't drift. Adapters may extend the
5
- * variants with backend-specific fields; they serialize into `--json` as-is,
6
- * except the report-only `summary`.
4
+ * so the human and machine outputs can't drift.
7
5
  */ /**
8
6
  * The parts of an undeploy that differ per application backend. The shared
9
7
  * sequence — mode selection, target reporting, confirmation, error handling —
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift. Adapters may extend the\n * variants with backend-specific fields; they serialize into `--json` as-is,\n * except the report-only `summary`.\n */\nexport type UndeployTarget = UndeployApplicationTarget | UndeployConfigTarget\n\n/** An undeploy that deletes the application, along with all its deployments. */\nexport interface UndeployApplicationTarget extends UndeployTargetDetails {\n deletes: 'application'\n id: string\n}\n\n/** An undeploy that deletes an installation's deployed config; the installation stays installed. */\nexport interface UndeployConfigTarget extends UndeployTargetDetails {\n deletes: 'config'\n id: null\n}\n\ninterface UndeployTargetDetails {\n /** Details of the deployment currently being served; `null` when none is live. */\n activeDeployment: {deployedAt: string; deployedBy: string} | null\n /** Hostname the application is served from; freed for anyone to claim after undeploy. */\n appHost: string | null\n createdAt: string | null\n organizationId: string | null\n projectId: string | null\n title: string | null\n type: 'coreApp' | 'studio'\n /** Where the deployed studio/app is currently reachable. */\n url: string | null\n\n /**\n * Adapter-authored report lines about what gets deleted (interfaces, config\n * snapshots, …), rendered under the target details. Built from the same data\n * the adapter puts on its target, so the report can't drift from the payload.\n */\n summary?: string[]\n}\n\nexport type UndeployTargetResolution<TTarget extends UndeployTarget = UndeployTarget> =\n | {message: string; solution?: string; type: 'none'}\n | {target: TTarget; type: 'found'}\n\n/**\n * The parts of an undeploy that differ per application backend. The shared\n * sequence — mode selection, target reporting, confirmation, error handling —\n * lives in the host CLI's runner; adapters only resolve and delete.\n */\nexport interface UndeployAdapter<TTarget extends UndeployTarget = UndeployTarget> {\n /** Resolves what an undeploy would delete; read-only. */\n resolveTarget(): Promise<UndeployTargetResolution<TTarget>>\n type: 'coreApp' | 'studio'\n /** Deletes the target — the only mutating step, never run on a dry run. */\n undeploy(target: TTarget): Promise<void>\n}\n"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAwCD;;;;CAIC,GACD,WAMC"}
1
+ {"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift.\n */\nexport type UndeployTarget = UndeployApplicationTarget | UndeployConfigTarget\n\n/** An undeploy that deletes the application, along with all its deployments. */\nexport interface UndeployApplicationTarget extends UndeployTargetDetails {\n deletes: 'application'\n id: string\n}\n\n/** An undeploy that deletes an installation's deployed config; the installation stays installed. */\nexport interface UndeployConfigTarget extends UndeployTargetDetails {\n deletes: 'config'\n id: null\n}\n\ninterface UndeployTargetDetails {\n title: string | null\n type: 'coreApp' | 'studio'\n url: string | null\n\n application?: object\n payload?: UndeployPayload\n /** Human-report lines only; never serialized. */\n summary?: string[]\n}\n\n/** Collected locally, so a dry run reports it too. */\nexport interface UndeployPayload {\n /** The configured `deployment.appId`; `null` when none is set. */\n appId: string | null\n type: 'coreApp' | 'studio'\n\n /** Media-library config summary. */\n config?: string\n services?: object[]\n views?: object[]\n}\n\nexport type UndeployTargetResolution<TTarget extends UndeployTarget = UndeployTarget> =\n | {message: string; solution?: string; type: 'none'}\n | {target: TTarget; type: 'found'}\n\n/**\n * The parts of an undeploy that differ per application backend. The shared\n * sequence — mode selection, target reporting, confirmation, error handling —\n * lives in the host CLI's runner; adapters only resolve and delete.\n */\nexport interface UndeployAdapter<TTarget extends UndeployTarget = UndeployTarget> {\n /** Resolves what an undeploy would delete; read-only. */\n resolveTarget(): Promise<UndeployTargetResolution<TTarget>>\n type: 'coreApp' | 'studio'\n /** Deletes the target — the only mutating step, never run on a dry run. */\n undeploy(target: TTarget): Promise<void>\n}\n"],"names":[],"mappings":"AAAA;;;;CAIC,GA0CD;;;;CAIC,GACD,WAMC"}
@@ -1,21 +1,82 @@
1
1
  import ora, { oraPromise } from 'ora';
2
2
  import { getCliExecutionContext } from '../executionContext.js';
3
- function silentSpinner(options) {
3
+ /**
4
+ * Uncolored counterparts of the `log-symbols` glyphs a real spinner persists
5
+ * with. Lines forwarded to an execution context are handed to the embedding
6
+ * host verbatim, so they should not carry ANSI codes the host has to strip.
7
+ */ const persistSymbols = {
8
+ error: '✖',
9
+ info: 'ℹ',
10
+ success: '✔',
11
+ warning: '⚠'
12
+ };
13
+ function resolveAffix(value1) {
14
+ const resolved = typeof value1 === 'function' ? value1() : value1;
15
+ return typeof resolved === 'string' ? resolved : '';
16
+ }
17
+ /**
18
+ * Stand-in for a real spinner, used when a CLI execution context is active.
19
+ *
20
+ * Frame animation and transient text updates have nowhere useful to go, so they
21
+ * are dropped. The lines a spinner *persists* (`succeed`, `fail`, `warn`,
22
+ * `info`, `stopAndPersist`) are the command's actual output rather than
23
+ * progress, so they are forwarded to the context's sink instead of being
24
+ * swallowed. Ora writes to `process.stderr` by default, so the `stderr` sink is
25
+ * preferred, falling back to `stdout`.
26
+ */ function silentSpinner(options) {
27
+ const resolved = typeof options === 'string' ? {
28
+ text: options
29
+ } : options ?? {};
30
+ const context = getCliExecutionContext();
31
+ const emit = resolved.isSilent ? undefined : context?.stderr ?? context?.stdout;
32
+ const prefixText = resolveAffix(resolved.prefixText);
33
+ const suffixText = resolveAffix(resolved.suffixText);
34
+ const state = {
35
+ text: resolved.text ?? ''
36
+ };
37
+ const persist = (symbol, text)=>{
38
+ if (!emit) return;
39
+ // Mirrors ora's own line layout, minus the trailing whitespace it leaves
40
+ // behind when only one of the symbol and the text is present.
41
+ const body = text ?? state.text;
42
+ const line = (prefixText ? `${prefixText} ` : '') + symbol + (symbol && body ? ` ${body}` : body) + (suffixText ? ` ${suffixText}` : '');
43
+ if (line.trim() !== '') emit(line);
44
+ };
4
45
  const instance = {
5
46
  clear: ()=>instance,
6
- fail: ()=>instance,
47
+ fail: (text)=>{
48
+ persist(persistSymbols.error, text);
49
+ return instance;
50
+ },
7
51
  frame: ()=>'',
8
- info: ()=>instance,
52
+ info: (text)=>{
53
+ persist(persistSymbols.info, text);
54
+ return instance;
55
+ },
9
56
  isSpinning: false,
10
- prefixText: typeof options === 'object' ? options.prefixText ?? '' : '',
57
+ prefixText,
11
58
  render: ()=>instance,
12
59
  start: ()=>instance,
13
60
  stop: ()=>instance,
14
- stopAndPersist: ()=>instance,
15
- succeed: ()=>instance,
16
- suffixText: typeof options === 'object' ? options.suffixText ?? '' : '',
17
- text: typeof options === 'string' ? options : options?.text ?? '',
18
- warn: ()=>instance
61
+ stopAndPersist: (persistOptions = {})=>{
62
+ persist(persistOptions.symbol ?? '', persistOptions.text);
63
+ return instance;
64
+ },
65
+ succeed: (text)=>{
66
+ persist(persistSymbols.success, text);
67
+ return instance;
68
+ },
69
+ suffixText,
70
+ get text () {
71
+ return state.text;
72
+ },
73
+ set text (value){
74
+ state.text = value;
75
+ },
76
+ warn: (text)=>{
77
+ persist(persistSymbols.warning, text);
78
+ return instance;
79
+ }
19
80
  };
20
81
  return instance;
21
82
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["import ora, {\n type Options,\n type Ora,\n oraPromise,\n type Spinner as OraSpinner,\n type PromiseOptions,\n} from 'ora'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\nfunction silentSpinner(options?: Options | string): Ora {\n const instance = {\n clear: () => instance,\n fail: () => instance,\n frame: () => '',\n info: () => instance,\n isSpinning: false,\n prefixText: typeof options === 'object' ? (options.prefixText ?? '') : '',\n render: () => instance,\n start: () => instance,\n stop: () => instance,\n stopAndPersist: () => instance,\n succeed: () => instance,\n suffixText: typeof options === 'object' ? (options.suffixText ?? '') : '',\n text: typeof options === 'string' ? options : (options?.text ?? ''),\n warn: () => instance,\n }\n return instance as unknown as Ora\n}\n\nexport function spinner(options?: Options | string): Ora {\n return getCliExecutionContext() ? silentSpinner(options) : ora(options)\n}\n\nexport function spinnerPromise<T>(\n action: ((instance: Ora) => PromiseLike<T>) | PromiseLike<T>,\n options?: PromiseOptions<T> | string,\n): Promise<T> {\n if (!getCliExecutionContext()) return oraPromise(action, options)\n return Promise.resolve(typeof action === 'function' ? action(silentSpinner(options)) : action)\n}\n\nexport type Spinner = OraSpinner\nexport type SpinnerInstance = Ora\nexport type SpinnerOptions = Options\nexport type SpinnerPromiseOptions<T> = PromiseOptions<T>\n"],"names":["ora","oraPromise","getCliExecutionContext","silentSpinner","options","instance","clear","fail","frame","info","isSpinning","prefixText","render","start","stop","stopAndPersist","succeed","suffixText","text","warn","spinner","spinnerPromise","action","Promise","resolve"],"mappings":"AAAA,OAAOA,OAGLC,UAAU,QAGL,MAAK;AAEZ,SAAQC,sBAAsB,QAAO,yBAAwB;AAE7D,SAASC,cAAcC,OAA0B;IAC/C,MAAMC,WAAW;QACfC,OAAO,IAAMD;QACbE,MAAM,IAAMF;QACZG,OAAO,IAAM;QACbC,MAAM,IAAMJ;QACZK,YAAY;QACZC,YAAY,OAAOP,YAAY,WAAYA,QAAQO,UAAU,IAAI,KAAM;QACvEC,QAAQ,IAAMP;QACdQ,OAAO,IAAMR;QACbS,MAAM,IAAMT;QACZU,gBAAgB,IAAMV;QACtBW,SAAS,IAAMX;QACfY,YAAY,OAAOb,YAAY,WAAYA,QAAQa,UAAU,IAAI,KAAM;QACvEC,MAAM,OAAOd,YAAY,WAAWA,UAAWA,SAASc,QAAQ;QAChEC,MAAM,IAAMd;IACd;IACA,OAAOA;AACT;AAEA,OAAO,SAASe,QAAQhB,OAA0B;IAChD,OAAOF,2BAA2BC,cAAcC,WAAWJ,IAAII;AACjE;AAEA,OAAO,SAASiB,eACdC,MAA4D,EAC5DlB,OAAoC;IAEpC,IAAI,CAACF,0BAA0B,OAAOD,WAAWqB,QAAQlB;IACzD,OAAOmB,QAAQC,OAAO,CAAC,OAAOF,WAAW,aAAaA,OAAOnB,cAAcC,YAAYkB;AACzF"}
1
+ {"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["import ora, {\n type Options,\n type Ora,\n oraPromise,\n type Spinner as OraSpinner,\n type PersistOptions,\n type PromiseOptions,\n} from 'ora'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\n/**\n * Uncolored counterparts of the `log-symbols` glyphs a real spinner persists\n * with. Lines forwarded to an execution context are handed to the embedding\n * host verbatim, so they should not carry ANSI codes the host has to strip.\n */\nconst persistSymbols = {\n error: '✖',\n info: 'ℹ',\n success: '✔',\n warning: '⚠',\n}\n\nfunction resolveAffix(value: Options['prefixText'] | Options['suffixText']): string {\n const resolved = typeof value === 'function' ? value() : value\n return typeof resolved === 'string' ? resolved : ''\n}\n\n/**\n * Stand-in for a real spinner, used when a CLI execution context is active.\n *\n * Frame animation and transient text updates have nowhere useful to go, so they\n * are dropped. The lines a spinner *persists* (`succeed`, `fail`, `warn`,\n * `info`, `stopAndPersist`) are the command's actual output rather than\n * progress, so they are forwarded to the context's sink instead of being\n * swallowed. Ora writes to `process.stderr` by default, so the `stderr` sink is\n * preferred, falling back to `stdout`.\n */\nfunction silentSpinner(options?: Options | string): Ora {\n const resolved = typeof options === 'string' ? {text: options} : (options ?? {})\n const context = getCliExecutionContext()\n const emit = resolved.isSilent ? undefined : (context?.stderr ?? context?.stdout)\n\n const prefixText = resolveAffix(resolved.prefixText)\n const suffixText = resolveAffix(resolved.suffixText)\n const state = {text: resolved.text ?? ''}\n\n const persist = (symbol: string, text?: string): void => {\n if (!emit) return\n\n // Mirrors ora's own line layout, minus the trailing whitespace it leaves\n // behind when only one of the symbol and the text is present.\n const body = text ?? state.text\n const line =\n (prefixText ? `${prefixText} ` : '') +\n symbol +\n (symbol && body ? ` ${body}` : body) +\n (suffixText ? ` ${suffixText}` : '')\n\n if (line.trim() !== '') emit(line)\n }\n\n const instance = {\n clear: () => instance,\n fail: (text?: string) => {\n persist(persistSymbols.error, text)\n return instance\n },\n frame: () => '',\n info: (text?: string) => {\n persist(persistSymbols.info, text)\n return instance\n },\n isSpinning: false,\n prefixText,\n render: () => instance,\n start: () => instance,\n stop: () => instance,\n stopAndPersist: (persistOptions: PersistOptions = {}) => {\n persist(persistOptions.symbol ?? '', persistOptions.text)\n return instance\n },\n succeed: (text?: string) => {\n persist(persistSymbols.success, text)\n return instance\n },\n suffixText,\n get text(): string {\n return state.text\n },\n set text(value: string) {\n state.text = value\n },\n warn: (text?: string) => {\n persist(persistSymbols.warning, text)\n return instance\n },\n }\n return instance as unknown as Ora\n}\n\nexport function spinner(options?: Options | string): Ora {\n return getCliExecutionContext() ? silentSpinner(options) : ora(options)\n}\n\nexport function spinnerPromise<T>(\n action: ((instance: Ora) => PromiseLike<T>) | PromiseLike<T>,\n options?: PromiseOptions<T> | string,\n): Promise<T> {\n if (!getCliExecutionContext()) return oraPromise(action, options)\n return Promise.resolve(typeof action === 'function' ? action(silentSpinner(options)) : action)\n}\n\nexport type Spinner = OraSpinner\nexport type SpinnerInstance = Ora\nexport type SpinnerOptions = Options\nexport type SpinnerPromiseOptions<T> = PromiseOptions<T>\n"],"names":["ora","oraPromise","getCliExecutionContext","persistSymbols","error","info","success","warning","resolveAffix","value","resolved","silentSpinner","options","text","context","emit","isSilent","undefined","stderr","stdout","prefixText","suffixText","state","persist","symbol","body","line","trim","instance","clear","fail","frame","isSpinning","render","start","stop","stopAndPersist","persistOptions","succeed","warn","spinner","spinnerPromise","action","Promise","resolve"],"mappings":"AAAA,OAAOA,OAGLC,UAAU,QAIL,MAAK;AAEZ,SAAQC,sBAAsB,QAAO,yBAAwB;AAE7D;;;;CAIC,GACD,MAAMC,iBAAiB;IACrBC,OAAO;IACPC,MAAM;IACNC,SAAS;IACTC,SAAS;AACX;AAEA,SAASC,aAAaC,MAAoD;IACxE,MAAMC,WAAW,OAAOD,WAAU,aAAaA,WAAUA;IACzD,OAAO,OAAOC,aAAa,WAAWA,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;QACA,IAAIR,QAAe;YACjB,OAAOS,MAAMT,IAAI;QACnB;QACA,IAAIA,MAAKJ,MAAe;YACtBa,MAAMT,IAAI,GAAGJ;QACf;QACA8B,MAAM,CAAC1B;YACLU,QAAQpB,eAAeI,OAAO,EAAEM;YAChC,OAAOe;QACT;IACF;IACA,OAAOA;AACT;AAEA,OAAO,SAASY,QAAQ5B,OAA0B;IAChD,OAAOV,2BAA2BS,cAAcC,WAAWZ,IAAIY;AACjE;AAEA,OAAO,SAAS6B,eACdC,MAA4D,EAC5D9B,OAAoC;IAEpC,IAAI,CAACV,0BAA0B,OAAOD,WAAWyC,QAAQ9B;IACzD,OAAO+B,QAAQC,OAAO,CAAC,OAAOF,WAAW,aAAaA,OAAO/B,cAAcC,YAAY8B;AACzF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "2.8.1",
3
+ "version": "3.0.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",
@@ -144,8 +144,8 @@
144
144
  "typescript": "^6.0.3",
145
145
  "vitest": "^4.1.10",
146
146
  "@repo/package.config": "0.0.1",
147
- "@repo/tsconfig": "3.70.0",
148
- "@sanity/eslint-config-cli": "1.1.3"
147
+ "@sanity/eslint-config-cli": "1.1.3",
148
+ "@repo/tsconfig": "3.70.0"
149
149
  },
150
150
  "peerDependencies": {
151
151
  "babel-plugin-react-compiler": "*"