@sanity/cli-core 2.7.1 → 2.8.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.
@@ -34,8 +34,6 @@ declare interface CliConfig {
34
34
  app?: {
35
35
  /** The entrypoint for your custom app. By default, `src/App.tsx` */
36
36
  entry?: string;
37
- /** Dock group the app renders in. Defaults to `dock.applications`. */
38
- group?: "dock.applications" | "dock.system" | "dock.user";
39
37
  /**
40
38
  * Path to an icon file relative to project root.
41
39
  * The file must be an SVG.
@@ -45,8 +43,6 @@ declare interface CliConfig {
45
43
  id?: string;
46
44
  /** The ID for the Sanity organization that manages this application */
47
45
  organizationId?: string;
48
- /** Sort position within the dock group, ascending. Defaults to `100`. */
49
- priority?: number;
50
46
  /** The title of the custom app, as it is seen in Dashboard UI */
51
47
  title?: string;
52
48
  /** Dashboard visibility of the application. Defaults to `default`. */
@@ -37,8 +37,6 @@ export declare interface CliConfig {
37
37
  app?: {
38
38
  /** The entrypoint for your custom app. By default, `src/App.tsx` */
39
39
  entry?: string;
40
- /** Dock group the app renders in. Defaults to `dock.applications`. */
41
- group?: "dock.applications" | "dock.system" | "dock.user";
42
40
  /**
43
41
  * Path to an icon file relative to project root.
44
42
  * The file must be an SVG.
@@ -48,8 +46,6 @@ export declare interface CliConfig {
48
46
  id?: string;
49
47
  /** The ID for the Sanity organization that manages this application */
50
48
  organizationId?: string;
51
- /** Sort position within the dock group, ascending. Defaults to `100`. */
52
- priority?: number;
53
49
  /** The title of the custom app, as it is seen in Dashboard UI */
54
50
  title?: string;
55
51
  /** Dashboard visibility of the application. Defaults to `default`. */
@@ -80,8 +80,6 @@ export declare interface CliConfig {
80
80
  app?: {
81
81
  /** The entrypoint for your custom app. By default, `src/App.tsx` */
82
82
  entry?: string;
83
- /** Dock group the app renders in. Defaults to `dock.applications`. */
84
- group?: "dock.applications" | "dock.system" | "dock.user";
85
83
  /**
86
84
  * Path to an icon file relative to project root.
87
85
  * The file must be an SVG.
@@ -91,8 +89,6 @@ export declare interface CliConfig {
91
89
  id?: string;
92
90
  /** The ID for the Sanity organization that manages this application */
93
91
  organizationId?: string;
94
- /** Sort position within the dock group, ascending. Defaults to `100`. */
95
- priority?: number;
96
92
  /** The title of the custom app, as it is seen in Dashboard UI */
97
93
  title?: string;
98
94
  /** Dashboard visibility of the application. Defaults to `default`. */
@@ -38,8 +38,6 @@ export declare interface CliConfig {
38
38
  app?: {
39
39
  /** The entrypoint for your custom app. By default, `src/App.tsx` */
40
40
  entry?: string;
41
- /** Dock group the app renders in. Defaults to `dock.applications`. */
42
- group?: "dock.applications" | "dock.system" | "dock.user";
43
41
  /**
44
42
  * Path to an icon file relative to project root.
45
43
  * The file must be an SVG.
@@ -49,8 +47,6 @@ export declare interface CliConfig {
49
47
  id?: string;
50
48
  /** The ID for the Sanity organization that manages this application */
51
49
  organizationId?: string;
52
- /** Sort position within the dock group, ascending. Defaults to `100`. */
53
- priority?: number;
54
50
  /** The title of the custom app, as it is seen in Dashboard UI */
55
51
  title?: string;
56
52
  /** Dashboard visibility of the application. Defaults to `default`. */
@@ -24,12 +24,50 @@ export declare function colorizeJson(input: unknown): string;
24
24
 
25
25
  export declare const confirm: typeof inquirer.confirm;
26
26
 
27
+ /** Create a {@link Flow} that writes rail lines through `log`. */
28
+ export declare function createFlow(log: LogFn): Flow;
29
+
27
30
  export { CustomBorderStyle };
28
31
 
29
32
  export declare const editor: typeof inquirer.editor;
30
33
 
31
34
  export declare const expand: typeof inquirer.expand;
32
35
 
36
+ export declare interface Flow {
37
+ /** A copyable command belonging to the preceding action. */
38
+ command(command: string): void;
39
+ /** `│` — a blank rail line separating steps. */
40
+ gap(): void;
41
+ /** `◆` — an outcome the user should act on or remember. */
42
+ highlight(text: string): void;
43
+ /** `┌` — opening line of the story. */
44
+ intro(text: string): void;
45
+ /** `│ <text>` — a continuation line belonging to the previous step. */
46
+ line(text: string): void;
47
+ /** A copy-safe URL. Long URLs are never hard-wrapped. */
48
+ link(
49
+ url: string,
50
+ options?: {
51
+ label?: string;
52
+ outro?: boolean;
53
+ },
54
+ ): void;
55
+ /** `●` — a step happening behind the scenes, or a tip. */
56
+ note(text: string): void;
57
+ /** `└` — closing line of the story. */
58
+ outro(text: string): void;
59
+ /** `◇` — a completed step or produced value. */
60
+ result(text: string): void;
61
+ /**
62
+ * An in-flight step. Resolve it with `succeed(text)` (persists as a `◇` line) or `fail(text)`;
63
+ * renders on stderr so machine-readable stdout is never corrupted.
64
+ */
65
+ spin(text: string): {
66
+ fail(text: string): void;
67
+ succeed(text: string): void;
68
+ };
69
+ }
70
+
33
71
  /**
34
72
  * Starts a terminal timer
35
73
  *
@@ -39,6 +77,8 @@ export declare function getTimer(): TimeMeasurer;
39
77
 
40
78
  export declare const input: typeof inquirer.input;
41
79
 
80
+ declare type LogFn = (message?: string) => void;
81
+
42
82
  export { logSymbols };
43
83
 
44
84
  /**
@@ -1,6 +1,7 @@
1
1
  export { NonInteractiveError } from '../errors/NonInteractiveError.js';
2
2
  export { boxen } from '../ux/boxen.js';
3
3
  export { colorizeJson } from '../ux/colorizeJson.js';
4
+ export { createFlow } from '../ux/flowOutput.js';
4
5
  export { logSymbols } from '../ux/logSymbols.js';
5
6
  export { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select, Separator } from '../ux/prompts.js';
6
7
  export { spinner, spinnerPromise } from '../ux/spinner.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AACzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
1
+ {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {createFlow, type Flow} from '../ux/flowOutput.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","createFlow","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAkB,sBAAqB;AACzD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AACzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /** Dock group the app renders in. Defaults to `dock.applications`. */\n group?: 'dock.applications' | 'dock.system' | 'dock.user'\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** Sort position within the dock group, ascending. Defaults to `100`. */\n priority?: number\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAYA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
1
+ {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAYA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
@@ -0,0 +1,128 @@
1
+ import { styleText } from 'node:util';
2
+ import wrapAnsi from 'wrap-ansi';
3
+ import { isInteractive } from '../util/isInteractive.js';
4
+ import { spinner } from './spinner.js';
5
+ const SPINNER_FRAMES = [
6
+ '◐ ',
7
+ '◓ ',
8
+ '◑ ',
9
+ '◒ '
10
+ ];
11
+ const RAIL_PREFIX_WIDTH = 3;
12
+ const MAX_RENDERED_LINE_WIDTH = 79;
13
+ function rail(glyph) {
14
+ return styleText('gray', glyph);
15
+ }
16
+ function wrapText(text) {
17
+ const terminalWidth = process.stdout.isTTY && Number.isFinite(process.stdout.columns) && process.stdout.columns > 0 ? process.stdout.columns : MAX_RENDERED_LINE_WIDTH + 1;
18
+ const renderedWidth = Math.min(terminalWidth - 1, MAX_RENDERED_LINE_WIDTH);
19
+ const width = Math.max(renderedWidth - RAIL_PREFIX_WIDTH, 1);
20
+ return wrapAnsi(text, width, {
21
+ hard: false,
22
+ wordWrap: true
23
+ }).split('\n');
24
+ }
25
+ function writeRailed(log, glyph, text) {
26
+ for (const [index, line] of wrapText(text).entries()){
27
+ const marker = index === 0 && glyph === '◆' ? styleText('green', glyph) : rail(index === 0 ? glyph : '│');
28
+ log(`${marker} ${line}`);
29
+ }
30
+ }
31
+ function writeStderr(message = '') {
32
+ process.stderr.write(`${message}\n`);
33
+ }
34
+ function isTerminalControl(character) {
35
+ const codePoint = character.codePointAt(0);
36
+ return codePoint !== undefined && (codePoint <= 0x1f || codePoint >= 0x7f && codePoint <= 0x9f);
37
+ }
38
+ function isSafeTerminalLink(url) {
39
+ if ([
40
+ ...url
41
+ ].some((character)=>isTerminalControl(character))) return false;
42
+ try {
43
+ const protocol = new URL(url).protocol;
44
+ return protocol === 'http:' || protocol === 'https:';
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+ function encodeTerminalControls(value) {
50
+ return [
51
+ ...value
52
+ ].map((character)=>isTerminalControl(character) ? encodeURIComponent(character) : character).join('');
53
+ }
54
+ function terminalLink(url) {
55
+ const sanitizedUrl = encodeTerminalControls(url);
56
+ if (!process.stdout.isTTY || sanitizedUrl !== url || !isSafeTerminalLink(url)) {
57
+ return sanitizedUrl;
58
+ }
59
+ return `\u001B]8;;${url}\u0007${styleText([
60
+ 'cyan',
61
+ 'underline'
62
+ ], url)}\u001B]8;;\u0007`;
63
+ }
64
+ /** Create a {@link Flow} that writes rail lines through `log`. */ export function createFlow(log) {
65
+ return {
66
+ command (command) {
67
+ log(`${rail('│')} ${styleText('cyan', encodeTerminalControls(command))}`);
68
+ },
69
+ gap () {
70
+ log(rail('│'));
71
+ },
72
+ highlight (text) {
73
+ writeRailed(log, '◆', text);
74
+ },
75
+ intro (text) {
76
+ writeRailed(log, '┌', text);
77
+ },
78
+ line (text) {
79
+ writeRailed(log, '│', text);
80
+ },
81
+ link (url, options = {}) {
82
+ const label = options.label ? `${options.label} ` : '';
83
+ log(`${rail(options.outro ? '└' : '│')} ${label}${terminalLink(url)}`);
84
+ },
85
+ note (text) {
86
+ writeRailed(log, '●', text);
87
+ },
88
+ outro (text) {
89
+ writeRailed(log, '└', text);
90
+ },
91
+ result (text) {
92
+ writeRailed(log, '◇', text);
93
+ },
94
+ spin (text) {
95
+ const sanitizedText = encodeTerminalControls(text);
96
+ if (!isInteractive() || !process.stderr.isTTY || !process.stderr.columns) {
97
+ writeRailed(writeStderr, '●', sanitizedText);
98
+ return {
99
+ fail: (failText)=>writeStderr(`${styleText('red', '✖')} ${encodeTerminalControls(failText)}`),
100
+ succeed: (successText)=>writeStderr(`${rail('◇')} ${encodeTerminalControls(successText)}`)
101
+ };
102
+ }
103
+ const spin = spinner({
104
+ spinner: {
105
+ frames: SPINNER_FRAMES,
106
+ interval: 120
107
+ },
108
+ text: sanitizedText
109
+ }).start();
110
+ return {
111
+ fail (failText) {
112
+ spin.stopAndPersist({
113
+ symbol: `${styleText('red', '✖')} `,
114
+ text: encodeTerminalControls(failText)
115
+ });
116
+ },
117
+ succeed (successText) {
118
+ spin.stopAndPersist({
119
+ symbol: `${rail('◇')} `,
120
+ text: encodeTerminalControls(successText)
121
+ });
122
+ }
123
+ };
124
+ }
125
+ };
126
+ }
127
+
128
+ //# sourceMappingURL=flowOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ux/flowOutput.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport wrapAnsi from 'wrap-ansi'\n\nimport {isInteractive} from '../util/isInteractive.js'\nimport {spinner, type SpinnerInstance} from './spinner.js'\n\ntype LogFn = (message?: string) => void\n\nconst SPINNER_FRAMES = ['◐ ', '◓ ', '◑ ', '◒ ']\nconst RAIL_PREFIX_WIDTH = 3\nconst MAX_RENDERED_LINE_WIDTH = 79\n\nfunction rail(glyph: string): string {\n return styleText('gray', glyph)\n}\n\nfunction wrapText(text: string): string[] {\n const terminalWidth =\n process.stdout.isTTY && Number.isFinite(process.stdout.columns) && process.stdout.columns > 0\n ? process.stdout.columns\n : MAX_RENDERED_LINE_WIDTH + 1\n const renderedWidth = Math.min(terminalWidth - 1, MAX_RENDERED_LINE_WIDTH)\n const width = Math.max(renderedWidth - RAIL_PREFIX_WIDTH, 1)\n return wrapAnsi(text, width, {hard: false, wordWrap: true}).split('\\n')\n}\n\nfunction writeRailed(log: LogFn, glyph: string, text: string): void {\n for (const [index, line] of wrapText(text).entries()) {\n const marker =\n index === 0 && glyph === '◆' ? styleText('green', glyph) : rail(index === 0 ? glyph : '│')\n log(`${marker} ${line}`)\n }\n}\n\nfunction writeStderr(message = ''): void {\n process.stderr.write(`${message}\\n`)\n}\n\nfunction isTerminalControl(character: string): boolean {\n const codePoint = character.codePointAt(0)\n return codePoint !== undefined && (codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f))\n}\n\nfunction isSafeTerminalLink(url: string): boolean {\n if ([...url].some((character) => isTerminalControl(character))) return false\n try {\n const protocol = new URL(url).protocol\n return protocol === 'http:' || protocol === 'https:'\n } catch {\n return false\n }\n}\n\nfunction encodeTerminalControls(value: string): string {\n return [...value]\n .map((character) => (isTerminalControl(character) ? encodeURIComponent(character) : character))\n .join('')\n}\n\nfunction terminalLink(url: string): string {\n const sanitizedUrl = encodeTerminalControls(url)\n if (!process.stdout.isTTY || sanitizedUrl !== url || !isSafeTerminalLink(url)) {\n return sanitizedUrl\n }\n return `\\u001B]8;;${url}\\u0007${styleText(['cyan', 'underline'], url)}\\u001B]8;;\\u0007`\n}\n\nexport interface Flow {\n /** A copyable command belonging to the preceding action. */\n command(command: string): void\n /** `│` — a blank rail line separating steps. */\n gap(): void\n /** `◆` — an outcome the user should act on or remember. */\n highlight(text: string): void\n /** `┌` — opening line of the story. */\n intro(text: string): void\n /** `│ <text>` — a continuation line belonging to the previous step. */\n line(text: string): void\n /** A copy-safe URL. Long URLs are never hard-wrapped. */\n link(url: string, options?: {label?: string; outro?: boolean}): void\n /** `●` — a step happening behind the scenes, or a tip. */\n note(text: string): void\n /** `└` — closing line of the story. */\n outro(text: string): void\n /** `◇` — a completed step or produced value. */\n result(text: string): void\n /**\n * An in-flight step. Resolve it with `succeed(text)` (persists as a `◇` line) or `fail(text)`;\n * renders on stderr so machine-readable stdout is never corrupted.\n */\n spin(text: string): {fail(text: string): void; succeed(text: string): void}\n}\n\n/** Create a {@link Flow} that writes rail lines through `log`. */\nexport function createFlow(log: LogFn): Flow {\n return {\n command(command: string) {\n log(`${rail('│')} ${styleText('cyan', encodeTerminalControls(command))}`)\n },\n gap() {\n log(rail('│'))\n },\n highlight(text: string) {\n writeRailed(log, '◆', text)\n },\n intro(text: string) {\n writeRailed(log, '┌', text)\n },\n line(text: string) {\n writeRailed(log, '│', text)\n },\n link(url: string, options = {}) {\n const label = options.label ? `${options.label} ` : ''\n log(`${rail(options.outro ? '└' : '│')} ${label}${terminalLink(url)}`)\n },\n note(text: string) {\n writeRailed(log, '●', text)\n },\n outro(text: string) {\n writeRailed(log, '└', text)\n },\n result(text: string) {\n writeRailed(log, '◇', text)\n },\n spin(text: string) {\n const sanitizedText = encodeTerminalControls(text)\n if (!isInteractive() || !process.stderr.isTTY || !process.stderr.columns) {\n writeRailed(writeStderr, '●', sanitizedText)\n return {\n fail: (failText: string) =>\n writeStderr(`${styleText('red', '✖')} ${encodeTerminalControls(failText)}`),\n succeed: (successText: string) =>\n writeStderr(`${rail('◇')} ${encodeTerminalControls(successText)}`),\n }\n }\n\n const spin: SpinnerInstance = spinner({\n spinner: {frames: SPINNER_FRAMES, interval: 120},\n text: sanitizedText,\n }).start()\n return {\n fail(failText: string) {\n spin.stopAndPersist({\n symbol: `${styleText('red', '✖')} `,\n text: encodeTerminalControls(failText),\n })\n },\n succeed(successText: string) {\n spin.stopAndPersist({symbol: `${rail('◇')} `, text: encodeTerminalControls(successText)})\n },\n }\n },\n }\n}\n"],"names":["styleText","wrapAnsi","isInteractive","spinner","SPINNER_FRAMES","RAIL_PREFIX_WIDTH","MAX_RENDERED_LINE_WIDTH","rail","glyph","wrapText","text","terminalWidth","process","stdout","isTTY","Number","isFinite","columns","renderedWidth","Math","min","width","max","hard","wordWrap","split","writeRailed","log","index","line","entries","marker","writeStderr","message","stderr","write","isTerminalControl","character","codePoint","codePointAt","undefined","isSafeTerminalLink","url","some","protocol","URL","encodeTerminalControls","value","map","encodeURIComponent","join","terminalLink","sanitizedUrl","createFlow","command","gap","highlight","intro","link","options","label","outro","note","result","spin","sanitizedText","fail","failText","succeed","successText","frames","interval","start","stopAndPersist","symbol"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,OAAOC,cAAc,YAAW;AAEhC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,OAAO,QAA6B,eAAc;AAI1D,MAAMC,iBAAiB;IAAC;IAAM;IAAM;IAAM;CAAK;AAC/C,MAAMC,oBAAoB;AAC1B,MAAMC,0BAA0B;AAEhC,SAASC,KAAKC,KAAa;IACzB,OAAOR,UAAU,QAAQQ;AAC3B;AAEA,SAASC,SAASC,IAAY;IAC5B,MAAMC,gBACJC,QAAQC,MAAM,CAACC,KAAK,IAAIC,OAAOC,QAAQ,CAACJ,QAAQC,MAAM,CAACI,OAAO,KAAKL,QAAQC,MAAM,CAACI,OAAO,GAAG,IACxFL,QAAQC,MAAM,CAACI,OAAO,GACtBX,0BAA0B;IAChC,MAAMY,gBAAgBC,KAAKC,GAAG,CAACT,gBAAgB,GAAGL;IAClD,MAAMe,QAAQF,KAAKG,GAAG,CAACJ,gBAAgBb,mBAAmB;IAC1D,OAAOJ,SAASS,MAAMW,OAAO;QAACE,MAAM;QAAOC,UAAU;IAAI,GAAGC,KAAK,CAAC;AACpE;AAEA,SAASC,YAAYC,GAAU,EAAEnB,KAAa,EAAEE,IAAY;IAC1D,KAAK,MAAM,CAACkB,OAAOC,KAAK,IAAIpB,SAASC,MAAMoB,OAAO,GAAI;QACpD,MAAMC,SACJH,UAAU,KAAKpB,UAAU,MAAMR,UAAU,SAASQ,SAASD,KAAKqB,UAAU,IAAIpB,QAAQ;QACxFmB,IAAI,GAAGI,OAAO,EAAE,EAAEF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K,KAAK,CAAC,CAAC;wBAAEG,MAAMoC,uBAAuBuB;oBAAY;gBACzF;YACF;QACF;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",
@@ -125,6 +125,7 @@
125
125
  "tsx": "^4.23.1",
126
126
  "vite": "^8.1.5",
127
127
  "vite-node": "^6.0.0",
128
+ "wrap-ansi": "^9.0.2",
128
129
  "zod": "^4.4.3"
129
130
  },
130
131
  "devDependencies": {