@sanity/cli-core 1.2.1 → 1.3.1
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.
- package/dist/SanityCommand.js +3 -3
- package/dist/SanityCommand.js.map +1 -1
- package/dist/{index.d.ts → _exports/index.d.ts} +247 -124
- package/dist/_exports/index.js +40 -0
- package/dist/_exports/index.js.map +1 -0
- package/dist/config/cli/schemas.js +50 -50
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/findProjectRoot.js +3 -1
- package/dist/config/findProjectRoot.js.map +1 -1
- package/dist/config/findProjectRootSync.js +3 -1
- package/dist/config/findProjectRootSync.js.map +1 -1
- package/dist/config/studio/readStudioConfig.js +13 -11
- package/dist/config/studio/readStudioConfig.js.map +1 -1
- package/dist/config/studio/readStudioConfig.worker.js +1 -1
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/exitCodes.js +17 -0
- package/dist/exitCodes.js.map +1 -0
- package/dist/services/apiClient.js +2 -2
- package/dist/services/apiClient.js.map +1 -1
- package/dist/services/cliTokenCache.js +25 -0
- package/dist/services/cliTokenCache.js.map +1 -0
- package/dist/services/cliUserConfig.js +89 -48
- package/dist/services/cliUserConfig.js.map +1 -1
- package/dist/services/getCliToken.js +12 -7
- package/dist/services/getCliToken.js.map +1 -1
- package/dist/{util → telemetry}/getCliTelemetry.js +1 -1
- package/dist/telemetry/getCliTelemetry.js.map +1 -0
- package/dist/telemetry/noopTelemetry.js +23 -0
- package/dist/telemetry/noopTelemetry.js.map +1 -0
- package/dist/telemetry/readNDJSON.js.map +1 -0
- package/dist/util/environment/getStudioEnvironmentVariables.js +3 -1
- package/dist/util/environment/getStudioEnvironmentVariables.js.map +1 -1
- package/dist/util/readJsonFileSync.js +26 -0
- package/dist/util/readJsonFileSync.js.map +1 -0
- package/dist/util/readPackageJson.js +17 -17
- package/dist/util/readPackageJson.js.map +1 -1
- package/dist/util/resolveLocalPackage.js +6 -2
- package/dist/util/resolveLocalPackage.js.map +1 -1
- package/dist/util/writeJsonFileSync.js +19 -0
- package/dist/util/writeJsonFileSync.js.map +1 -0
- package/package.json +22 -25
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
- package/dist/util/getCliTelemetry.js.map +0 -1
- package/dist/util/getUserConfig.js +0 -15
- package/dist/util/getUserConfig.js.map +0 -1
- package/dist/util/readNDJSON.js.map +0 -1
- package/dist/util/writeJsonFile.js +0 -19
- package/dist/util/writeJsonFile.js.map +0 -1
- /package/dist/{util → telemetry}/readNDJSON.js +0 -0
package/dist/SanityCommand.js
CHANGED
|
@@ -5,8 +5,9 @@ import { findProjectRoot } from './config/findProjectRoot.js';
|
|
|
5
5
|
import { subdebug } from './debug.js';
|
|
6
6
|
import { NonInteractiveError } from './errors/NonInteractiveError.js';
|
|
7
7
|
import { ProjectRootNotFoundError } from './errors/ProjectRootNotFoundError.js';
|
|
8
|
+
import { exitCodes } from './exitCodes.js';
|
|
8
9
|
import { getGlobalCliClient, getProjectCliClient } from './services/apiClient.js';
|
|
9
|
-
import { getCliTelemetry, reportCliTraceError } from './
|
|
10
|
+
import { getCliTelemetry, reportCliTraceError } from './telemetry/getCliTelemetry.js';
|
|
10
11
|
import { isInteractive } from './util/isInteractive.js';
|
|
11
12
|
const debug = subdebug('sanityCommand');
|
|
12
13
|
export class SanityCommand extends Command {
|
|
@@ -55,9 +56,8 @@ export class SanityCommand extends Command {
|
|
|
55
56
|
// ExitPromptError is thrown by `@inquirer/prompts` when the user cancels a prompt
|
|
56
57
|
// The `message === 'SIGINT'` check matches oclif's own convention (see handle.js in @oclif/core)
|
|
57
58
|
if (err.name === 'ExitPromptError' || err.message === 'SIGINT') {
|
|
58
|
-
// 130 is the standard exit code for script termination by Ctrl+C
|
|
59
59
|
this.logToStderr(styleText('yellow', '\u{203A}') + ' Aborted by user');
|
|
60
|
-
return this.exit(
|
|
60
|
+
return this.exit(exitCodes.SIGINT);
|
|
61
61
|
}
|
|
62
62
|
// In other cases, we _do_ want to report the error
|
|
63
63
|
reportCliTraceError(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Command, Interfaces} from '@oclif/core'\nimport {type CommandError} from '@oclif/core/interfaces'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {subdebug} from './debug.js'\nimport {NonInteractiveError} from './errors/NonInteractiveError.js'\nimport {ProjectRootNotFoundError} from './errors/ProjectRootNotFoundError.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {type CLITelemetryStore} from './telemetry/types.js'\nimport {type Output} from './types.js'\nimport {getCliTelemetry, reportCliTraceError} from './util/getCliTelemetry.js'\nimport {isInteractive} from './util/isInteractive.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nconst debug = subdebug('sanityCommand')\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n *\n * @deprecated use `getGlobalCliClient` function directly instead.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n *\n * @deprecated use `getProjectCliClient` function directly instead.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * The telemetry store.\n *\n * @returns The telemetry store.\n */\n protected telemetry!: CLITelemetryStore\n\n /**\n * Report real command errors to the CLI command trace.\n * User aborts (SIGINT, ExitPromptError) are not reported — the trace is left\n * incomplete, which accurately represents that the command was interrupted.\n */\n protected override async catch(err: CommandError): Promise<void> {\n // ExitPromptError is thrown by `@inquirer/prompts` when the user cancels a prompt\n // The `message === 'SIGINT'` check matches oclif's own convention (see handle.js in @oclif/core)\n if (err.name === 'ExitPromptError' || err.message === 'SIGINT') {\n // 130 is the standard exit code for script termination by Ctrl+C\n this.logToStderr(styleText('yellow', '\\u{203A}') + ' Aborted by user')\n return this.exit(130)\n }\n\n // In other cases, we _do_ want to report the error\n reportCliTraceError(err)\n return super.catch(err)\n }\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n\n debug(`Using project root`, root)\n return getCliConfig(root.directory)\n }\n\n /**\n * Get the project ID from passed flags or (if not provided) the CLI config.\n *\n * Optionally accepts a `fallback` function that is called when no project ID\n * can be determined from flags or config. This allows commands to provide\n * interactive project selection while keeping the prompt logic in the CLI package.\n *\n * If the fallback throws a `NonInteractiveError` (e.g. because the terminal is\n * not interactive), it falls through to the standard error with suggestions.\n *\n * Optionally accepts a `deprecatedFlagName` for commands that have a deprecated\n * flag (e.g. `--project`) that should be checked after `--project-id` but before\n * the CLI config.\n *\n * @returns The project ID.\n */\n protected async getProjectId(options?: {\n deprecatedFlagName?: string\n fallback?: () => Promise<string>\n }): Promise<string> {\n const hasProjectFlag = this.ctor.flags != null && 'project-id' in this.ctor.flags\n\n // Check --project-id flag first\n if (hasProjectFlag) {\n const flagProjectId =\n 'project-id' in this.flags && typeof this.flags['project-id'] === 'string'\n ? this.flags['project-id']\n : undefined\n\n if (flagProjectId) return flagProjectId\n }\n\n // Check deprecated flag (e.g. --project) before CLI config\n if (options?.deprecatedFlagName) {\n const deprecatedValue =\n options.deprecatedFlagName in this.flags &&\n typeof this.flags[options.deprecatedFlagName] === 'string'\n ? (this.flags[options.deprecatedFlagName] as string)\n : undefined\n\n if (deprecatedValue) return deprecatedValue\n }\n\n // Fall back to CLI config\n try {\n const config = await this.getCliConfig()\n const configProjectId = config.api?.projectId\n if (configProjectId) return configProjectId\n } catch (err) {\n if (!(err instanceof ProjectRootNotFoundError)) throw err\n // No project root — fall through to fallback/error\n }\n\n // Offer interactive selection if a fallback was provided\n if (options?.fallback) {\n try {\n return await options.fallback()\n } catch (err) {\n if (!(err instanceof NonInteractiveError)) throw err\n // Non-interactive: throw with actionable suggestions\n throw new ProjectRootNotFoundError('Unable to determine project ID', {\n cause: err,\n suggestions: [\n ...(hasProjectFlag ? ['Providing a project ID: --project-id <project-id>'] : []),\n 'Running this command from within a Sanity project directory',\n 'Running in an interactive terminal to get a project selection prompt',\n ],\n })\n }\n }\n\n throw new ProjectRootNotFoundError('Unable to determine project ID', {\n suggestions: [\n ...(hasProjectFlag ? ['Providing a project ID: --project-id <project-id>'] : []),\n 'Running this command from within a Sanity project directory',\n ],\n })\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The project root result.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n this.telemetry = getCliTelemetry()\n\n await super.init()\n }\n\n /**\n * Check if the command is running in unattended mode.\n *\n * This means the command should not ask for user input, instead using defaults where\n * possible, and if that does not make sense (eg there's missing information), then we\n * should error out (remember to exit with a non-zero code).\n *\n * Most commands should take an explicit `--yes` flag to enable unattended mode, but\n * some commands may also be run in unattended mode if `process.stdin` is not a TTY\n * (eg when running in a CI environment).\n */\n protected isUnattended(): boolean {\n return this.flags.yes || !this.resolveIsInteractive()\n }\n\n /**\n * Resolver for checking if the terminal is interactive. Override in tests to provide mock values.\n *\n * @returns Whether the terminal is interactive.\n */\n protected resolveIsInteractive(): boolean {\n return isInteractive()\n }\n\n /**\n * Get the CLI config, returning an empty config if no project root is found.\n *\n * Use this instead of `getCliConfig()` in commands that can operate without a\n * project directory (e.g. when `--project-id` and `--dataset` flags are provided).\n *\n * @returns The CLI config, or an empty config object if no project root is found.\n */\n protected async tryGetCliConfig(): Promise<CliConfig> {\n try {\n return await this.getCliConfig()\n } catch (err) {\n if (!(err instanceof ProjectRootNotFoundError)) throw err\n return {}\n }\n }\n}\n"],"names":["styleText","Command","getCliConfig","findProjectRoot","subdebug","NonInteractiveError","ProjectRootNotFoundError","getGlobalCliClient","getProjectCliClient","getCliTelemetry","reportCliTraceError","isInteractive","debug","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","telemetry","catch","err","name","message","logToStderr","exit","root","getProjectRoot","directory","getProjectId","options","hasProjectFlag","ctor","flagProjectId","undefined","deprecatedFlagName","deprecatedValue","config","configProjectId","api","projectId","fallback","cause","suggestions","process","cwd","init","parse","baseFlags","enableJsonFlag","strict","isUnattended","yes","resolveIsInteractive","tryGetCliConfig"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,OAAO,QAAmB,cAAa;AAG/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SAAQC,QAAQ,QAAO,aAAY;AACnC,SAAQC,mBAAmB,QAAO,kCAAiC;AACnE,SAAQC,wBAAwB,QAAO,uCAAsC;AAC7E,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAGhC,SAAQC,eAAe,EAAEC,mBAAmB,QAAO,4BAA2B;AAC9E,SAAQC,aA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C,MAAM,EAACpC,IAAI,EAAEC,KAAK,EAAC,GAAG,MAAM,IAAI,CAACoC,KAAK,CAAC;YACrCrC,MAAM,IAAI,CAACsB,IAAI,CAACtB,IAAI;YACpBsC,WAAW,AAAC,KAAK,CAAChB,KAA8BgB,SAAS;YACzDC,gBAAgB,IAAI,CAACjB,IAAI,CAACiB,cAAc;YACxCtC,OAAO,IAAI,CAACqB,IAAI,CAACrB,KAAK;YACtBuC,QAAQ,IAAI,CAAClB,IAAI,CAACkB,MAAM;QAC1B;QAEA,IAAI,CAACxC,IAAI,GAAGA;QACZ,IAAI,CAACC,KAAK,GAAGA;QACb,IAAI,CAACQ,SAAS,GAAGd;QAEjB,MAAM,KAAK,CAACyC;IACd;IAEA;;;;;;;;;;GAUC,GACD,AAAUK,eAAwB;QAChC,OAAO,IAAI,CAACxC,KAAK,CAACyC,GAAG,IAAI,CAAC,IAAI,CAACC,oBAAoB;IACrD;IAEA;;;;GAIC,GACD,AAAUA,uBAAgC;QACxC,OAAO9C;IACT;IAEA;;;;;;;GAOC,GACD,MAAgB+C,kBAAsC;QACpD,IAAI;YACF,OAAO,MAAM,IAAI,CAACxD,YAAY;QAChC,EAAE,OAAOuB,KAAK;YACZ,IAAI,CAAEA,CAAAA,eAAenB,wBAAuB,GAAI,MAAMmB;YACtD,OAAO,CAAC;QACV;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Command, Interfaces} from '@oclif/core'\nimport {type CommandError} from '@oclif/core/interfaces'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {subdebug} from './debug.js'\nimport {NonInteractiveError} from './errors/NonInteractiveError.js'\nimport {ProjectRootNotFoundError} from './errors/ProjectRootNotFoundError.js'\nimport {exitCodes} from './exitCodes.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {getCliTelemetry, reportCliTraceError} from './telemetry/getCliTelemetry.js'\nimport {type CLITelemetryStore} from './telemetry/types.js'\nimport {type Output} from './types.js'\nimport {isInteractive} from './util/isInteractive.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nconst debug = subdebug('sanityCommand')\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n *\n * @deprecated use `getGlobalCliClient` function directly instead.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n *\n * @deprecated use `getProjectCliClient` function directly instead.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * The telemetry store.\n *\n * @returns The telemetry store.\n */\n protected telemetry!: CLITelemetryStore\n\n /**\n * Report real command errors to the CLI command trace.\n * User aborts (SIGINT, ExitPromptError) are not reported — the trace is left\n * incomplete, which accurately represents that the command was interrupted.\n */\n protected override async catch(err: CommandError): Promise<void> {\n // ExitPromptError is thrown by `@inquirer/prompts` when the user cancels a prompt\n // The `message === 'SIGINT'` check matches oclif's own convention (see handle.js in @oclif/core)\n if (err.name === 'ExitPromptError' || err.message === 'SIGINT') {\n this.logToStderr(styleText('yellow', '\\u{203A}') + ' Aborted by user')\n return this.exit(exitCodes.SIGINT)\n }\n\n // In other cases, we _do_ want to report the error\n reportCliTraceError(err)\n return super.catch(err)\n }\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n\n debug(`Using project root`, root)\n return getCliConfig(root.directory)\n }\n\n /**\n * Get the project ID from passed flags or (if not provided) the CLI config.\n *\n * Optionally accepts a `fallback` function that is called when no project ID\n * can be determined from flags or config. This allows commands to provide\n * interactive project selection while keeping the prompt logic in the CLI package.\n *\n * If the fallback throws a `NonInteractiveError` (e.g. because the terminal is\n * not interactive), it falls through to the standard error with suggestions.\n *\n * Optionally accepts a `deprecatedFlagName` for commands that have a deprecated\n * flag (e.g. `--project`) that should be checked after `--project-id` but before\n * the CLI config.\n *\n * @returns The project ID.\n */\n protected async getProjectId(options?: {\n deprecatedFlagName?: string\n fallback?: () => Promise<string>\n }): Promise<string> {\n const hasProjectFlag = this.ctor.flags != null && 'project-id' in this.ctor.flags\n\n // Check --project-id flag first\n if (hasProjectFlag) {\n const flagProjectId =\n 'project-id' in this.flags && typeof this.flags['project-id'] === 'string'\n ? this.flags['project-id']\n : undefined\n\n if (flagProjectId) return flagProjectId\n }\n\n // Check deprecated flag (e.g. --project) before CLI config\n if (options?.deprecatedFlagName) {\n const deprecatedValue =\n options.deprecatedFlagName in this.flags &&\n typeof this.flags[options.deprecatedFlagName] === 'string'\n ? (this.flags[options.deprecatedFlagName] as string)\n : undefined\n\n if (deprecatedValue) return deprecatedValue\n }\n\n // Fall back to CLI config\n try {\n const config = await this.getCliConfig()\n const configProjectId = config.api?.projectId\n if (configProjectId) return configProjectId\n } catch (err) {\n if (!(err instanceof ProjectRootNotFoundError)) throw err\n // No project root — fall through to fallback/error\n }\n\n // Offer interactive selection if a fallback was provided\n if (options?.fallback) {\n try {\n return await options.fallback()\n } catch (err) {\n if (!(err instanceof NonInteractiveError)) throw err\n // Non-interactive: throw with actionable suggestions\n throw new ProjectRootNotFoundError('Unable to determine project ID', {\n cause: err,\n suggestions: [\n ...(hasProjectFlag ? ['Providing a project ID: --project-id <project-id>'] : []),\n 'Running this command from within a Sanity project directory',\n 'Running in an interactive terminal to get a project selection prompt',\n ],\n })\n }\n }\n\n throw new ProjectRootNotFoundError('Unable to determine project ID', {\n suggestions: [\n ...(hasProjectFlag ? ['Providing a project ID: --project-id <project-id>'] : []),\n 'Running this command from within a Sanity project directory',\n ],\n })\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The project root result.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n this.telemetry = getCliTelemetry()\n\n await super.init()\n }\n\n /**\n * Check if the command is running in unattended mode.\n *\n * This means the command should not ask for user input, instead using defaults where\n * possible, and if that does not make sense (eg there's missing information), then we\n * should error out (remember to exit with a non-zero code).\n *\n * Most commands should take an explicit `--yes` flag to enable unattended mode, but\n * some commands may also be run in unattended mode if `process.stdin` is not a TTY\n * (eg when running in a CI environment).\n */\n protected isUnattended(): boolean {\n return this.flags.yes || !this.resolveIsInteractive()\n }\n\n /**\n * Resolver for checking if the terminal is interactive. Override in tests to provide mock values.\n *\n * @returns Whether the terminal is interactive.\n */\n protected resolveIsInteractive(): boolean {\n return isInteractive()\n }\n\n /**\n * Get the CLI config, returning an empty config if no project root is found.\n *\n * Use this instead of `getCliConfig()` in commands that can operate without a\n * project directory (e.g. when `--project-id` and `--dataset` flags are provided).\n *\n * @returns The CLI config, or an empty config object if no project root is found.\n */\n protected async tryGetCliConfig(): Promise<CliConfig> {\n try {\n return await this.getCliConfig()\n } catch (err) {\n if (!(err instanceof ProjectRootNotFoundError)) throw err\n return {}\n }\n }\n}\n"],"names":["styleText","Command","getCliConfig","findProjectRoot","subdebug","NonInteractiveError","ProjectRootNotFoundError","exitCodes","getGlobalCliClient","getProjectCliClient","getCliTelemetry","reportCliTraceError","isInteractive","debug","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","telemetry","catch","err","name","message","logToStderr","exit","SIGINT","root","getProjectRoot","directory","getProjectId","options","hasProjectFlag","ctor","flagProjectId","undefined","deprecatedFlagName","deprecatedValue","config","configProjectId","api","projectId","fallback","cause","suggestions","process","cwd","init","parse","baseFlags","enableJsonFlag","strict","isUnattended","yes","resolveIsInteractive","tryGetCliConfig"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,OAAO,QAAmB,cAAa;AAG/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SAAQC,QAAQ,QAAO,aAAY;AACnC,SAAQC,mBAAmB,QAAO,kCAAiC;AACnE,SAAQC,wBAAwB,QAAO,uCAAsC;AAC7E,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAChC,SAAQC,eAAe,EAAEC,mBAAmB,QAAO,iCAAgC;AAGnF,SAAQC,aAAa,QAAO,0BAAyB;AAQrD,MAAMC,QAAQT,SAAS;AAEvB,OAAO,MAAeU,sBAAgDb;IAC1Dc,KAAc;IACdC,MAAgB;IAE1B;;;;;;;GAOC,GACD,AAAUC,qBAAqB,CAACF,OAAiCP,mBAAmBO,MAAK;IAEzF;;;;;;;GAOC,GACD,AAAUG,sBAAsB,CAACH,OAAkCN,oBAAoBM,MAAK;IAE5F;;;;;;;;;GASC,GACD,AAAUI,SAAiB;QACzBC,OAAO,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI;QAC3BC,KAAK,IAAI,CAACA,GAAG,CAACD,IAAI,CAAC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ACb,IAAI,CAACQ,SAAS,GAAGd;QAEjB,MAAM,KAAK,CAAC0C;IACd;IAEA;;;;;;;;;;GAUC,GACD,AAAUK,eAAwB;QAChC,OAAO,IAAI,CAACzC,KAAK,CAAC0C,GAAG,IAAI,CAAC,IAAI,CAACC,oBAAoB;IACrD;IAEA;;;;GAIC,GACD,AAAUA,uBAAgC;QACxC,OAAO/C;IACT;IAEA;;;;;;;GAOC,GACD,MAAgBgD,kBAAsC;QACpD,IAAI;YACF,OAAO,MAAM,IAAI,CAAC1D,YAAY;QAChC,EAAE,OAAOwB,KAAK;YACZ,IAAI,CAAEA,CAAAA,eAAepB,wBAAuB,GAAI,MAAMoB;YACtD,OAAO,CAAC;QACV;IACF;AACF"}
|
|
@@ -3,20 +3,17 @@ import { CLIError } from "@oclif/core/errors";
|
|
|
3
3
|
import { Command } from "@oclif/core";
|
|
4
4
|
import { CommandError } from "@oclif/core/interfaces";
|
|
5
5
|
import { ConfigEnv } from "vite";
|
|
6
|
-
import ConfigStore from "configstore";
|
|
7
|
-
import { ConsentStatus } from "@sanity/telemetry";
|
|
8
6
|
import debugIt from "debug";
|
|
9
7
|
import { InlineConfig } from "vite";
|
|
10
8
|
import { Interfaces } from "@oclif/core";
|
|
11
9
|
import { PluginOptions } from "babel-plugin-react-compiler";
|
|
12
10
|
import { SanityClient } from "sanity";
|
|
13
11
|
import { SanityClient as SanityClient_2 } from "@sanity/client";
|
|
14
|
-
import { TelemetryLogger } from "@sanity/telemetry";
|
|
15
12
|
import { URL as URL_2 } from "node:url";
|
|
16
13
|
import { Worker as Worker_2 } from "node:worker_threads";
|
|
17
14
|
import { WorkerOptions as WorkerOptions_2 } from "node:worker_threads";
|
|
18
15
|
import { Workspace } from "sanity";
|
|
19
|
-
import { z } from "zod";
|
|
16
|
+
import { z } from "zod/mini";
|
|
20
17
|
|
|
21
18
|
declare type Args<T extends typeof Command> = Interfaces.InferredArgs<
|
|
22
19
|
T["args"]
|
|
@@ -28,6 +25,16 @@ declare type Args<T extends typeof Command> = Interfaces.InferredArgs<
|
|
|
28
25
|
*/
|
|
29
26
|
export declare function clearCliTelemetry(): void;
|
|
30
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Clear the in-process token cache so the next `getCliToken()` call
|
|
30
|
+
* re-reads from disk or the environment.
|
|
31
|
+
*
|
|
32
|
+
* Called automatically by `setCliUserConfig('authToken', ...)`.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function clearCliTokenCache(): void;
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* @public
|
|
33
40
|
* Symbol used to store CLI telemetry state on globalThis.
|
|
@@ -163,38 +170,23 @@ export declare interface CliConfig {
|
|
|
163
170
|
export declare type CLITelemetryStore =
|
|
164
171
|
TelemetryLogger<TelemetryUserProperties>;
|
|
165
172
|
|
|
173
|
+
export declare function colorizeJson(input: unknown): string;
|
|
174
|
+
|
|
166
175
|
/**
|
|
167
|
-
*
|
|
176
|
+
* A raw key-value store for CLI user configuration.
|
|
177
|
+
* Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on
|
|
178
|
+
* arbitrary keys without schema validation.
|
|
168
179
|
*
|
|
169
|
-
* @
|
|
180
|
+
* @public
|
|
170
181
|
*/
|
|
171
|
-
declare
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
value: z.ZodObject<
|
|
180
|
-
{
|
|
181
|
-
status: z.ZodEnum<{
|
|
182
|
-
undetermined: "undetermined";
|
|
183
|
-
unset: "unset";
|
|
184
|
-
granted: "granted";
|
|
185
|
-
denied: "denied";
|
|
186
|
-
}>;
|
|
187
|
-
type: z.ZodString;
|
|
188
|
-
},
|
|
189
|
-
z.core.$loose
|
|
190
|
-
>;
|
|
191
|
-
},
|
|
192
|
-
z.core.$strip
|
|
193
|
-
>
|
|
194
|
-
>;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export declare function colorizeJson(input: unknown): string;
|
|
182
|
+
export declare interface ConfigStore {
|
|
183
|
+
/** Remove a key from the config file. */
|
|
184
|
+
delete: (key: string) => void;
|
|
185
|
+
/** Read a value by key. Returns `undefined` if the key does not exist. */
|
|
186
|
+
get: (key: string) => unknown;
|
|
187
|
+
/** Write a value by key, merging it into the existing config. */
|
|
188
|
+
set: (key: string, value: unknown) => void;
|
|
189
|
+
}
|
|
198
190
|
|
|
199
191
|
export declare type ConsentInformation =
|
|
200
192
|
| {
|
|
@@ -214,6 +206,14 @@ export declare type ConsentInformation =
|
|
|
214
206
|
status: Extract<ConsentStatus, "unset">;
|
|
215
207
|
};
|
|
216
208
|
|
|
209
|
+
/**
|
|
210
|
+
* 'unknown' - we don't know if the user has consented or not (e.g. something went wrong)
|
|
211
|
+
* 'unset' - the user has not yet been asked for consent
|
|
212
|
+
* 'granted' - the user has consented
|
|
213
|
+
* 'denied' - the user has denied consent
|
|
214
|
+
*/
|
|
215
|
+
declare type ConsentStatus = "undetermined" | "unset" | "granted" | "denied";
|
|
216
|
+
|
|
217
217
|
/**
|
|
218
218
|
* Creates a new worker for a studio worker task.
|
|
219
219
|
*
|
|
@@ -255,6 +255,46 @@ export declare function createStudioWorker(
|
|
|
255
255
|
declare const debug_2: debugIt.Debugger;
|
|
256
256
|
export { debug_2 as debug };
|
|
257
257
|
|
|
258
|
+
declare interface DeferredEvent<
|
|
259
|
+
Data = unknown,
|
|
260
|
+
Event extends DefinedTelemetryLog<Data> = DefinedTelemetryLog<Data>,
|
|
261
|
+
> {
|
|
262
|
+
createdAt: string;
|
|
263
|
+
event: Event;
|
|
264
|
+
data: Data;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare interface DefinedTelemetryLog<Schema> {
|
|
268
|
+
type: "log";
|
|
269
|
+
/** Unique name of the event */
|
|
270
|
+
name: string;
|
|
271
|
+
/** Event version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
|
|
272
|
+
version: number;
|
|
273
|
+
/** Description of log event */
|
|
274
|
+
description?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Max sample rate of this event.
|
|
277
|
+
* Calling telemetry.log(EventDefinition, data) repeatedly will submit at most one event every specified time interval (in milliseconds)
|
|
278
|
+
* */
|
|
279
|
+
maxSampleRate?: number;
|
|
280
|
+
/** Data schema. Will not be accessible at runtime */
|
|
281
|
+
schema: Schema;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare interface DefinedTelemetryTrace<Data = void, Context = void> {
|
|
285
|
+
type: "trace";
|
|
286
|
+
/** Unique name of the trace */
|
|
287
|
+
name: string;
|
|
288
|
+
/** Trace version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
|
|
289
|
+
version: number;
|
|
290
|
+
/** Description of trace */
|
|
291
|
+
description?: string;
|
|
292
|
+
/** Data schema. Will not be accessible at runtime */
|
|
293
|
+
schema: Data;
|
|
294
|
+
/** Contextual data schema. Will not be accessible at runtime */
|
|
295
|
+
context: Context;
|
|
296
|
+
}
|
|
297
|
+
|
|
258
298
|
/**
|
|
259
299
|
* This function is a replacement for built in dynamic import
|
|
260
300
|
* This handles the case for windows file paths especially for absolute paths.
|
|
@@ -263,6 +303,28 @@ export { debug_2 as debug };
|
|
|
263
303
|
*/
|
|
264
304
|
export declare function doImport(source: string): Promise<any>;
|
|
265
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Standard exit codes for CLI commands.
|
|
308
|
+
*
|
|
309
|
+
* - 0, 1, 2 align with oclif defaults and Unix convention.
|
|
310
|
+
* - 3 is application-defined (oclif does not use it).
|
|
311
|
+
* - 130 follows the Unix convention of 128 + signal number (SIGINT = 2).
|
|
312
|
+
*
|
|
313
|
+
* @see CLAUDE.md "Exit Code Convention" for usage guidance and examples.
|
|
314
|
+
*/
|
|
315
|
+
export declare const exitCodes: {
|
|
316
|
+
/** Something went wrong that is not the user's fault (API errors, network, missing config, etc.). */
|
|
317
|
+
readonly RUNTIME_ERROR: 1;
|
|
318
|
+
/** The user interrupted via Ctrl+C (128 + SIGINT). Handled by SanityCommand.catch(). */
|
|
319
|
+
readonly SIGINT: 130;
|
|
320
|
+
/** Command completed normally. */
|
|
321
|
+
readonly SUCCESS: 0;
|
|
322
|
+
/** The user provided invalid input (bad args, unknown flags, validation failures). */
|
|
323
|
+
readonly USAGE_ERROR: 2;
|
|
324
|
+
/** The user declined a confirmation or chose not to proceed. */
|
|
325
|
+
readonly USER_ABORT: 3;
|
|
326
|
+
};
|
|
327
|
+
|
|
266
328
|
/**
|
|
267
329
|
* Finds the path for a given set of files.
|
|
268
330
|
*
|
|
@@ -371,9 +433,7 @@ export declare function getCliToken(): Promise<string | undefined>;
|
|
|
371
433
|
* @returns The value of the given property
|
|
372
434
|
* @internal
|
|
373
435
|
*/
|
|
374
|
-
export declare function getCliUserConfig
|
|
375
|
-
prop: P,
|
|
376
|
-
): Promise<CliUserConfig[P]>;
|
|
436
|
+
export declare function getCliUserConfig(prop: "authToken"): string | undefined;
|
|
377
437
|
|
|
378
438
|
/**
|
|
379
439
|
* Create a "global" (unscoped) Sanity API client.
|
|
@@ -487,7 +547,23 @@ export declare function getTelemetryBaseInfo(): Promise<TelemetryBaseInfo>;
|
|
|
487
547
|
*/
|
|
488
548
|
export declare function getTimer(): TimeMeasurer;
|
|
489
549
|
|
|
490
|
-
|
|
550
|
+
/**
|
|
551
|
+
* Get a key-value store backed by the CLI user configuration file
|
|
552
|
+
* (`~/.config/sanity/config.json`).
|
|
553
|
+
*
|
|
554
|
+
* Each call to `get`, `set`, or `delete` performs a full synchronous
|
|
555
|
+
* read-modify-write cycle. This is intentional: sync I/O prevents
|
|
556
|
+
* intra-process race conditions that occurred with the previous async
|
|
557
|
+
* (configstore-backed) implementation.
|
|
558
|
+
*
|
|
559
|
+
* Note: there is no file-level locking, so concurrent writes from
|
|
560
|
+
* separate CLI processes could still conflict. In practice this is
|
|
561
|
+
* unlikely since CLI config writes are rare and user-initiated.
|
|
562
|
+
*
|
|
563
|
+
* @returns A {@link ConfigStore} for the CLI config file
|
|
564
|
+
* @public
|
|
565
|
+
*/
|
|
566
|
+
export declare function getUserConfig(): ConfigStore;
|
|
491
567
|
|
|
492
568
|
/**
|
|
493
569
|
* @public
|
|
@@ -611,6 +687,13 @@ export declare class NonInteractiveError extends CLIError {
|
|
|
611
687
|
constructor(promptName: string);
|
|
612
688
|
}
|
|
613
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Fallback logger used when telemetry has not been initialized.
|
|
692
|
+
* Exported for use in tests only — do not use in plugins or external code.
|
|
693
|
+
* @internal
|
|
694
|
+
*/
|
|
695
|
+
export declare const noopLogger: CLITelemetryStore;
|
|
696
|
+
|
|
614
697
|
/**
|
|
615
698
|
* Normalizes a path for cross-platform comparison by converting backslashes to forward slashes.
|
|
616
699
|
* Useful for converting windows paths to unix paths.
|
|
@@ -655,33 +738,45 @@ export declare type PackageJson = z.infer<typeof packageJsonSchema>;
|
|
|
655
738
|
* 🟠ℹ️ SINCE THIS IS USED IN A NUMBER OF LOCATIONS WHERE ℹ️🟠
|
|
656
739
|
* 🟠ℹ️ WE CANNOT ENFORCE/GUARANTEE ANY PARTICULAR PROPS ℹ️🟠
|
|
657
740
|
*/
|
|
658
|
-
declare const packageJsonSchema: z.
|
|
741
|
+
declare const packageJsonSchema: z.ZodMiniObject<
|
|
659
742
|
{
|
|
660
|
-
name: z.
|
|
661
|
-
version: z.
|
|
662
|
-
dependencies: z.
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
743
|
+
name: z.ZodMiniString<string>;
|
|
744
|
+
version: z.ZodMiniString<string>;
|
|
745
|
+
dependencies: z.ZodMiniOptional<
|
|
746
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
|
|
747
|
+
>;
|
|
748
|
+
devDependencies: z.ZodMiniOptional<
|
|
749
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
|
|
750
|
+
>;
|
|
751
|
+
peerDependencies: z.ZodMiniOptional<
|
|
752
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
|
|
753
|
+
>;
|
|
754
|
+
exports: z.ZodMiniOptional<
|
|
755
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>
|
|
756
|
+
>;
|
|
757
|
+
main: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
758
|
+
types: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
759
|
+
author: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
760
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
761
|
+
engines: z.ZodMiniOptional<
|
|
762
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
|
|
763
|
+
>;
|
|
764
|
+
license: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
765
|
+
private: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
766
|
+
repository: z.ZodMiniOptional<
|
|
767
|
+
z.ZodMiniObject<
|
|
675
768
|
{
|
|
676
|
-
type: z.
|
|
677
|
-
url: z.
|
|
769
|
+
type: z.ZodMiniString<string>;
|
|
770
|
+
url: z.ZodMiniString<string>;
|
|
678
771
|
},
|
|
679
772
|
z.core.$strip
|
|
680
773
|
>
|
|
681
774
|
>;
|
|
682
|
-
scripts: z.
|
|
683
|
-
|
|
684
|
-
|
|
775
|
+
scripts: z.ZodMiniOptional<
|
|
776
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
|
|
777
|
+
>;
|
|
778
|
+
type: z.ZodMiniOptional<
|
|
779
|
+
z.ZodMiniEnum<{
|
|
685
780
|
module: "module";
|
|
686
781
|
commonjs: "commonjs";
|
|
687
782
|
}>
|
|
@@ -781,36 +876,38 @@ declare interface PromisifyWorkerOptions extends WorkerOptions_2 {
|
|
|
781
876
|
timeout?: number;
|
|
782
877
|
}
|
|
783
878
|
|
|
784
|
-
declare const rawConfigSchema: z.
|
|
879
|
+
declare const rawConfigSchema: z.ZodMiniUnion<
|
|
785
880
|
readonly [
|
|
786
|
-
z.
|
|
787
|
-
z.
|
|
881
|
+
z.ZodMiniArray<
|
|
882
|
+
z.ZodMiniObject<
|
|
788
883
|
{
|
|
789
|
-
basePath: z.
|
|
790
|
-
name: z.
|
|
791
|
-
plugins: z.
|
|
792
|
-
schema: z.
|
|
793
|
-
z.
|
|
884
|
+
basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
885
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
886
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
887
|
+
schema: z.ZodMiniOptional<
|
|
888
|
+
z.ZodMiniObject<
|
|
794
889
|
{
|
|
795
|
-
name: z.
|
|
796
|
-
types: z.
|
|
890
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
891
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
797
892
|
},
|
|
798
893
|
z.core.$loose
|
|
799
894
|
>
|
|
800
895
|
>;
|
|
801
|
-
title: z.
|
|
802
|
-
unstable_sources: z.
|
|
803
|
-
z.
|
|
804
|
-
z.
|
|
896
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
897
|
+
unstable_sources: z.ZodMiniOptional<
|
|
898
|
+
z.ZodMiniArray<
|
|
899
|
+
z.ZodMiniObject<
|
|
805
900
|
{
|
|
806
|
-
dataset: z.
|
|
807
|
-
projectId: z.
|
|
808
|
-
schema: z.
|
|
901
|
+
dataset: z.ZodMiniString<string>;
|
|
902
|
+
projectId: z.ZodMiniString<string>;
|
|
903
|
+
schema: z.ZodMiniObject<
|
|
809
904
|
{
|
|
810
|
-
_original: z.
|
|
905
|
+
_original: z.ZodMiniObject<
|
|
811
906
|
{
|
|
812
|
-
name: z.
|
|
813
|
-
types: z.
|
|
907
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
908
|
+
types: z.ZodMiniArray<
|
|
909
|
+
z.ZodMiniObject<{}, z.core.$loose>
|
|
910
|
+
>;
|
|
814
911
|
},
|
|
815
912
|
z.core.$loose
|
|
816
913
|
>;
|
|
@@ -822,39 +919,41 @@ declare const rawConfigSchema: z.ZodUnion<
|
|
|
822
919
|
>
|
|
823
920
|
>
|
|
824
921
|
>;
|
|
825
|
-
dataset: z.
|
|
826
|
-
projectId: z.
|
|
922
|
+
dataset: z.ZodMiniString<string>;
|
|
923
|
+
projectId: z.ZodMiniString<string>;
|
|
827
924
|
},
|
|
828
925
|
z.core.$loose
|
|
829
926
|
>
|
|
830
927
|
>,
|
|
831
|
-
z.
|
|
928
|
+
z.ZodMiniObject<
|
|
832
929
|
{
|
|
833
|
-
basePath: z.
|
|
834
|
-
name: z.
|
|
835
|
-
plugins: z.
|
|
836
|
-
schema: z.
|
|
837
|
-
z.
|
|
930
|
+
basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
931
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
932
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
933
|
+
schema: z.ZodMiniOptional<
|
|
934
|
+
z.ZodMiniObject<
|
|
838
935
|
{
|
|
839
|
-
name: z.
|
|
840
|
-
types: z.
|
|
936
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
937
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
841
938
|
},
|
|
842
939
|
z.core.$loose
|
|
843
940
|
>
|
|
844
941
|
>;
|
|
845
|
-
title: z.
|
|
846
|
-
unstable_sources: z.
|
|
847
|
-
z.
|
|
848
|
-
z.
|
|
942
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
943
|
+
unstable_sources: z.ZodMiniOptional<
|
|
944
|
+
z.ZodMiniArray<
|
|
945
|
+
z.ZodMiniObject<
|
|
849
946
|
{
|
|
850
|
-
dataset: z.
|
|
851
|
-
projectId: z.
|
|
852
|
-
schema: z.
|
|
947
|
+
dataset: z.ZodMiniString<string>;
|
|
948
|
+
projectId: z.ZodMiniString<string>;
|
|
949
|
+
schema: z.ZodMiniObject<
|
|
853
950
|
{
|
|
854
|
-
_original: z.
|
|
951
|
+
_original: z.ZodMiniObject<
|
|
855
952
|
{
|
|
856
|
-
name: z.
|
|
857
|
-
types: z.
|
|
953
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
954
|
+
types: z.ZodMiniArray<
|
|
955
|
+
z.ZodMiniObject<{}, z.core.$loose>
|
|
956
|
+
>;
|
|
858
957
|
},
|
|
859
958
|
z.core.$loose
|
|
860
959
|
>;
|
|
@@ -866,8 +965,8 @@ declare const rawConfigSchema: z.ZodUnion<
|
|
|
866
965
|
>
|
|
867
966
|
>
|
|
868
967
|
>;
|
|
869
|
-
dataset: z.
|
|
870
|
-
projectId: z.
|
|
968
|
+
dataset: z.ZodMiniString<string>;
|
|
969
|
+
projectId: z.ZodMiniString<string>;
|
|
871
970
|
},
|
|
872
971
|
z.core.$loose
|
|
873
972
|
>,
|
|
@@ -910,24 +1009,24 @@ export declare interface ReadPackageJsonOptions {
|
|
|
910
1009
|
declare type RequireProps<T, K extends keyof T> = Omit<T, K> &
|
|
911
1010
|
Required<Pick<T, K>>;
|
|
912
1011
|
|
|
913
|
-
declare const resolvedConfigSchema: z.
|
|
914
|
-
z.
|
|
1012
|
+
declare const resolvedConfigSchema: z.ZodMiniArray<
|
|
1013
|
+
z.ZodMiniObject<
|
|
915
1014
|
{
|
|
916
|
-
basePath: z.
|
|
917
|
-
name: z.
|
|
918
|
-
plugins: z.
|
|
919
|
-
title: z.
|
|
920
|
-
unstable_sources: z.
|
|
921
|
-
z.
|
|
1015
|
+
basePath: z.ZodMiniString<string>;
|
|
1016
|
+
name: z.ZodMiniString<string>;
|
|
1017
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
1018
|
+
title: z.ZodMiniString<string>;
|
|
1019
|
+
unstable_sources: z.ZodMiniArray<
|
|
1020
|
+
z.ZodMiniObject<
|
|
922
1021
|
{
|
|
923
|
-
dataset: z.
|
|
924
|
-
projectId: z.
|
|
925
|
-
schema: z.
|
|
1022
|
+
dataset: z.ZodMiniString<string>;
|
|
1023
|
+
projectId: z.ZodMiniString<string>;
|
|
1024
|
+
schema: z.ZodMiniObject<
|
|
926
1025
|
{
|
|
927
|
-
_original: z.
|
|
1026
|
+
_original: z.ZodMiniObject<
|
|
928
1027
|
{
|
|
929
|
-
name: z.
|
|
930
|
-
types: z.
|
|
1028
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1029
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
931
1030
|
},
|
|
932
1031
|
z.core.$loose
|
|
933
1032
|
>;
|
|
@@ -938,14 +1037,14 @@ declare const resolvedConfigSchema: z.ZodArray<
|
|
|
938
1037
|
z.core.$loose
|
|
939
1038
|
>
|
|
940
1039
|
>;
|
|
941
|
-
dataset: z.
|
|
942
|
-
projectId: z.
|
|
943
|
-
schema: z.
|
|
1040
|
+
dataset: z.ZodMiniString<string>;
|
|
1041
|
+
projectId: z.ZodMiniString<string>;
|
|
1042
|
+
schema: z.ZodMiniObject<
|
|
944
1043
|
{
|
|
945
|
-
_original: z.
|
|
1044
|
+
_original: z.ZodMiniObject<
|
|
946
1045
|
{
|
|
947
|
-
name: z.
|
|
948
|
-
types: z.
|
|
1046
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1047
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
949
1048
|
},
|
|
950
1049
|
z.core.$loose
|
|
951
1050
|
>;
|
|
@@ -1176,10 +1275,10 @@ export declare function setCliTelemetry(
|
|
|
1176
1275
|
* @param value - The value to set
|
|
1177
1276
|
* @internal
|
|
1178
1277
|
*/
|
|
1179
|
-
export declare function setCliUserConfig
|
|
1180
|
-
prop:
|
|
1181
|
-
value:
|
|
1182
|
-
):
|
|
1278
|
+
export declare function setCliUserConfig(
|
|
1279
|
+
prop: "authToken",
|
|
1280
|
+
value: string | undefined,
|
|
1281
|
+
): void;
|
|
1183
1282
|
|
|
1184
1283
|
/**
|
|
1185
1284
|
* Executes a worker file in a Sanity Studio browser context.
|
|
@@ -1252,6 +1351,30 @@ declare interface TelemetryBaseInfo {
|
|
|
1252
1351
|
hashedToken: string;
|
|
1253
1352
|
}
|
|
1254
1353
|
|
|
1354
|
+
/**
|
|
1355
|
+
* Note that `sessionId` is removed from the signature of these functions
|
|
1356
|
+
*/
|
|
1357
|
+
declare interface TelemetryLogger<UserProperties> {
|
|
1358
|
+
updateUserProperties(properties: UserProperties): void;
|
|
1359
|
+
resume(events: DeferredEvent[]): void;
|
|
1360
|
+
log<Data>(event: DefinedTelemetryLog<Data>, data: Data): void;
|
|
1361
|
+
log<Data extends void>(event: DefinedTelemetryLog<Data>): void;
|
|
1362
|
+
trace<Data>(
|
|
1363
|
+
event: DefinedTelemetryTrace<Data>,
|
|
1364
|
+
context?: unknown,
|
|
1365
|
+
): TelemetryTrace<UserProperties, Data>;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
declare interface TelemetryTrace<UserProperties, Data> {
|
|
1369
|
+
start(): void;
|
|
1370
|
+
log(data: Data): void;
|
|
1371
|
+
error(error: Error): void;
|
|
1372
|
+
complete(): void;
|
|
1373
|
+
newContext(name: string): TelemetryLogger<UserProperties>;
|
|
1374
|
+
await<P extends Promise<Data>>(promise: P): P;
|
|
1375
|
+
await<P extends Promise<unknown>>(promise: P, finalData: Data): P;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1255
1378
|
/**
|
|
1256
1379
|
* @public
|
|
1257
1380
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export * from '../config/cli/getCliConfig.js';
|
|
2
|
+
export * from '../config/cli/getCliConfigSync.js';
|
|
3
|
+
export * from '../config/findProjectRoot.js';
|
|
4
|
+
export * from '../config/findProjectRootSync.js';
|
|
5
|
+
export * from '../config/studio/getStudioConfig.js';
|
|
6
|
+
export * from '../config/studio/getStudioWorkspaces.js';
|
|
7
|
+
export * from '../config/studio/isStudioConfig.js';
|
|
8
|
+
export * from '../config/util/findConfigsPaths.js';
|
|
9
|
+
export * from '../config/util/findStudioConfigPath.js';
|
|
10
|
+
export * from '../debug.js';
|
|
11
|
+
export * from '../errors/NonInteractiveError.js';
|
|
12
|
+
export * from '../errors/NotFoundError.js';
|
|
13
|
+
export * from '../errors/ProjectRootNotFoundError.js';
|
|
14
|
+
export * from '../exitCodes.js';
|
|
15
|
+
export * from '../loaders/studio/studioWorkerTask.js';
|
|
16
|
+
export * from '../loaders/tsx/tsxWorkerTask.js';
|
|
17
|
+
export * from '../SanityCommand.js';
|
|
18
|
+
export * from '../services/apiClient.js';
|
|
19
|
+
export * from '../services/cliUserConfig.js';
|
|
20
|
+
export * from '../services/getCliToken.js';
|
|
21
|
+
export { clearCliTelemetry, CLI_TELEMETRY_SYMBOL, getCliTelemetry, setCliTelemetry } from '../telemetry/getCliTelemetry.js';
|
|
22
|
+
export { getTelemetryBaseInfo } from '../telemetry/getTelemetryBaseInfo.js';
|
|
23
|
+
export { noopLogger } from '../telemetry/noopTelemetry.js';
|
|
24
|
+
export { doImport } from '../util/doImport.js';
|
|
25
|
+
export * from '../util/environment/mockBrowserEnvironment.js';
|
|
26
|
+
export * from '../util/getSanityEnvVar.js';
|
|
27
|
+
export * from '../util/getSanityUrl.js';
|
|
28
|
+
export * from '../util/importModule.js';
|
|
29
|
+
export * from '../util/isCi.js';
|
|
30
|
+
export * from '../util/isInteractive.js';
|
|
31
|
+
export * from '../util/isStaging.js';
|
|
32
|
+
export * from '../util/normalizePath.js';
|
|
33
|
+
export * from '../util/promisifyWorker.js';
|
|
34
|
+
export * from '../util/readPackageJson.js';
|
|
35
|
+
export * from '../util/resolveLocalPackage.js';
|
|
36
|
+
export * from '../util/safeStructuredClone.js';
|
|
37
|
+
export * from '../ux/colorizeJson.js';
|
|
38
|
+
export * from '../ux/timer.js';
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|