@sanity/cli 4.19.1-next.9 → 4.20.0-next.40

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.
@@ -21,12 +21,15 @@ async function getCliConfig(cwd, { forked } = {}) {
21
21
  }
22
22
  const { unregister } = (
23
23
  // eslint-disable-next-line @typescript-eslint/no-require-imports
24
- require("esbuild-register/dist/node").register({ supported: { "dynamic-import": !0 } })
24
+ require("esbuild-register/dist/node").register({
25
+ target: `node${process.version.slice(1)}`,
26
+ supported: { "dynamic-import": !0 },
27
+ // Force CJS output since we use require() to load the config
28
+ format: "cjs"
29
+ })
25
30
  );
26
31
  try {
27
32
  return getSanityCliConfig(cwd, clearCache);
28
- } catch (err) {
29
- throw err;
30
33
  } finally {
31
34
  unregister();
32
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getCliConfig.js","sources":["../../src/debug.ts","../../src/util/dynamicRequire.ts","../../src/util/getCliConfig.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig} from '../types'\nimport {getCliWorkerPath} from './cliWorker'\nimport {dynamicRequire} from './dynamicRequire'\n\nexport type CliConfigResult = {config: CliConfig; path: string} | {config: null; path: string}\n\nexport async function getCliConfig(\n cwd: string,\n {forked}: {forked?: boolean} = {},\n): Promise<CliConfigResult | null> {\n let clearCache = false\n if (forked) {\n try {\n return await getCliConfigForked(cwd)\n } catch (err) {\n debug('Error in getCliConfigForked', err)\n clearCache = true\n // Intentional noop - try unforked variant\n }\n }\n\n const {unregister} = __DEV__\n ? {unregister: () => undefined}\n : // eslint-disable-next-line @typescript-eslint/no-require-imports\n require('esbuild-register/dist/node').register({supported: {'dynamic-import': true}})\n\n try {\n // If forked execution failed, we need to clear the cache to reload the env vars\n return getSanityCliConfig(cwd, clearCache)\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n\nasync function getCliConfigForked(cwd: string): Promise<CliConfigResult | null> {\n const workerPath = await getCliWorkerPath('getCliConfig')\n return new Promise((resolve, reject) => {\n const worker = new Worker(workerPath, {\n workerData: cwd,\n env: process.env,\n })\n worker.on('message', (message) => {\n if (message.type === 'config') {\n resolve(message.config)\n } else {\n const error = new Error(message.error)\n ;(error as any).type = message.errorType\n reject(new Error(message.error))\n }\n })\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) {\n reject(new Error(`Worker stopped with exit code ${code}`))\n }\n })\n })\n}\n\nexport function getSanityCliConfig(cwd: string, clearCache = false): CliConfigResult | null {\n let configName = 'sanity.cli'\n\n if (process.env.SANITY_CLI_TEST_CONFIG_NAME && process.env.TEST === 'true') {\n configName = process.env.SANITY_CLI_TEST_CONFIG_NAME\n }\n\n const jsConfigPath = path.join(cwd, `${configName}.js`)\n const tsConfigPath = path.join(cwd, `${configName}.ts`)\n\n const [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)]\n\n if (!js && !ts) {\n return null\n }\n\n if (!js && ts) {\n return {\n config: importConfig(tsConfigPath, clearCache),\n path: tsConfigPath,\n }\n }\n\n if (js && ts) {\n warn(`Found both \\`${configName}.js\\` and \\`${configName}.ts\\` - using ${configName}.js`)\n }\n\n return {\n config: importConfig(jsConfigPath, clearCache),\n path: jsConfigPath,\n }\n}\n\nfunction importConfig(filePath: string, clearCache: boolean): CliConfig | null {\n try {\n // Clear module cache if requested (needed for env var reload)\n if (clearCache) {\n const resolvedPath = dynamicRequire.resolve(filePath)\n delete dynamicRequire.cache[resolvedPath]\n }\n\n const config = dynamicRequire<CliConfig | {default: CliConfig} | null>(filePath)\n if (config === null || typeof config !== 'object') {\n throw new Error('Module export is not a configuration object')\n }\n\n return 'default' in config ? config.default : config\n } catch (err) {\n // If attempting to import `defineCliConfig` or similar from `sanity/cli`,\n // accept the fact that it might not be installed. Instead, let the CLI\n // give a warning about the `sanity` module not being installed\n if (err.code === 'MODULE_NOT_FOUND' && err.message.includes('sanity/cli')) {\n return null\n }\n\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction warn(warning: string) {\n if (typeof process.send === 'function') {\n process.send({type: 'warning', warning})\n } else {\n console.warn(warning)\n }\n}\n"],"names":["debugIt","getCliWorkerPath","Worker","path","fs"],"mappings":";;;;;;AAEO,MAAM,QAAQA,iBAAAA,QAAQ,YAAY,GCKnC,cACJ,OAAO,uBAAwB,aAAa,0BAA0B;AAGjE,SAAS,eAAwB,SAAoB;AAC1D,QAAM,MAAM,YAAY,OAAO;AAC/B,SAAO,IAAI,cAAc,IAAI,UAAU,IAAI,UAAU;AACvD;AAEA,eAAe,UAAU,YAAY;AACrC,eAAe,QAAQ,YAAY;ACOnC,eAAsB,aACpB,KACA,EAAC,OAAA,IAA8B,CAAA,GACE;AACjC,MAAI,aAAa;AACjB,MAAI;AACF,QAAI;AACF,aAAO,MAAM,mBAAmB,GAAG;AAAA,IACrC,SAAS,KAAK;AACZ,YAAM,+BAA+B,GAAG,G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CAAC;AAE1E,SAAI,CAAC,MAAM,CAAC,KACH,OAGL,CAAC,MAAM,KACF;AAAA,IACL,QAAQ,aAAa,cAAc,UAAU;AAAA,IAC7C,MAAM;AAAA,EAAA,KAIN,MAAM,MACR,KAAK,gBAAgB,UAAU,eAAe,UAAU,iBAAiB,UAAU,KAAK,GAGnF;AAAA,IACL,QAAQ,aAAa,cAAc,UAAU;AAAA,IAC7C,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,aAAa,UAAkB,YAAuC;AAC7E,MAAI;AAEF,QAAI,YAAY;AACd,YAAM,eAAe,eAAe,QAAQ,QAAQ;AACpD,aAAO,eAAe,MAAM,YAAY;AAAA,IAC1C;AAEA,UAAM,SAAS,eAAwD,QAAQ;AAC/E,QAAI,WAAW,QAAQ,OAAO,UAAW;AACvC,YAAM,IAAI,MAAM,6CAA6C;AAG/D,WAAO,aAAa,SAAS,OAAO,UAAU;AAAA,EAChD,SAAS,KAAK;AAIZ,WAAI,IAAI,SAAS,sBAAsB,IAAI,QAAQ,SAAS,YAAY,KAIxE,QAAQ,MAAM,kBAAkB,QAAQ,MAAM,IAAI,OAAO,EAAE,GACpD;AAAA,EACT;AACF;AAEA,SAAS,KAAK,SAAiB;AACzB,SAAO,QAAQ,QAAS,aAC1B,QAAQ,KAAK,EAAC,MAAM,WAAW,QAAA,CAAQ,IAEvC,QAAQ,KAAK,OAAO;AAExB;;;;;"}
1
+ {"version":3,"file":"getCliConfig.js","sources":["../../src/debug.ts","../../src/util/dynamicRequire.ts","../../src/util/getCliConfig.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig} from '../types'\nimport {getCliWorkerPath} from './cliWorker'\nimport {dynamicRequire} from './dynamicRequire'\n\nexport type CliConfigResult = {config: CliConfig; path: string} | {config: null; path: string}\n\nexport async function getCliConfig(\n cwd: string,\n {forked}: {forked?: boolean} = {},\n): Promise<CliConfigResult | null> {\n let clearCache = false\n if (forked) {\n try {\n return await getCliConfigForked(cwd)\n } catch (err) {\n debug('Error in getCliConfigForked', err)\n clearCache = true\n // Intentional noop - try unforked variant\n }\n }\n\n const {unregister} = __DEV__\n ? {unregister: () => undefined}\n : // eslint-disable-next-line @typescript-eslint/no-require-imports\n require('esbuild-register/dist/node').register({\n target: `node${process.version.slice(1)}`,\n supported: {'dynamic-import': true},\n // Force CJS output since we use require() to load the config\n format: 'cjs',\n })\n\n try {\n // If forked execution failed, we need to clear the cache to reload the env vars\n return getSanityCliConfig(cwd, clearCache)\n } finally {\n unregister()\n }\n}\n\nasync function getCliConfigForked(cwd: string): Promise<CliConfigResult | null> {\n const workerPath = await getCliWorkerPath('getCliConfig')\n return new Promise((resolve, reject) => {\n const worker = new Worker(workerPath, {\n workerData: cwd,\n env: process.env,\n })\n worker.on('message', (message) => {\n if (message.type === 'config') {\n resolve(message.config)\n } else {\n const error = new Error(message.error)\n ;(error as any).type = message.errorType\n reject(new Error(message.error))\n }\n })\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) {\n reject(new Error(`Worker stopped with exit code ${code}`))\n }\n })\n })\n}\n\nexport function getSanityCliConfig(cwd: string, clearCache = false): CliConfigResult | null {\n let configName = 'sanity.cli'\n\n if (process.env.SANITY_CLI_TEST_CONFIG_NAME && process.env.TEST === 'true') {\n configName = process.env.SANITY_CLI_TEST_CONFIG_NAME\n }\n\n const jsConfigPath = path.join(cwd, `${configName}.js`)\n const tsConfigPath = path.join(cwd, `${configName}.ts`)\n\n const [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)]\n\n if (!js && !ts) {\n return null\n }\n\n if (!js && ts) {\n return {\n config: importConfig(tsConfigPath, clearCache),\n path: tsConfigPath,\n }\n }\n\n if (js && ts) {\n warn(`Found both \\`${configName}.js\\` and \\`${configName}.ts\\` - using ${configName}.js`)\n }\n\n return {\n config: importConfig(jsConfigPath, clearCache),\n path: jsConfigPath,\n }\n}\n\nfunction importConfig(filePath: string, clearCache: boolean): CliConfig | null {\n try {\n // Clear module cache if requested (needed for env var reload)\n if (clearCache) {\n const resolvedPath = dynamicRequire.resolve(filePath)\n delete dynamicRequire.cache[resolvedPath]\n }\n\n const config = dynamicRequire<CliConfig | {default: CliConfig} | null>(filePath)\n if (config === null || typeof config !== 'object') {\n throw new Error('Module export is not a configuration object')\n }\n\n return 'default' in config ? config.default : config\n } catch (err) {\n // If attempting to import `defineCliConfig` or similar from `sanity/cli`,\n // accept the fact that it might not be installed. Instead, let the CLI\n // give a warning about the `sanity` module not being installed\n if (err.code === 'MODULE_NOT_FOUND' && err.message.includes('sanity/cli')) {\n return null\n }\n\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction warn(warning: string) {\n if (typeof process.send === 'function') {\n process.send({type: 'warning', warning})\n } else {\n console.warn(warning)\n }\n}\n"],"names":["debugIt","getCliWorkerPath","Worker","path","fs"],"mappings":";;;;;;AAEO,MAAM,QAAQA,iBA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B,SAAO,QAAQ,QAAS,aAC1B,QAAQ,KAAK,EAAC,MAAM,WAAW,QAAA,CAAQ,IAEvC,QAAQ,KAAK,OAAO;AAExB;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "4.19.1-next.9+4fe55a3663",
3
+ "version": "4.20.0-next.40+721e6d2b96",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -27,14 +27,11 @@
27
27
  "exports": {
28
28
  ".": {
29
29
  "source": "./src/index.ts",
30
- "import": "./lib/index.mjs",
31
- "require": "./lib/index.js",
32
30
  "default": "./lib/index.js"
33
31
  },
34
32
  "./package.json": "./package.json"
35
33
  },
36
34
  "main": "./lib/index.js",
37
- "module": "./lib/index.mjs",
38
35
  "types": "./lib/index.d.ts",
39
36
  "bin": {
40
37
  "sanity": "./bin/sanity"
@@ -48,8 +45,8 @@
48
45
  "dependencies": {
49
46
  "@babel/parser": "^7.28.5",
50
47
  "@babel/traverse": "^7.28.5",
51
- "@sanity/client": "^7.12.1",
52
- "@sanity/runtime-cli": "^11.1.3",
48
+ "@sanity/client": "^7.13.1",
49
+ "@sanity/runtime-cli": "^11.1.4",
53
50
  "@sanity/telemetry": "^0.8.0",
54
51
  "@sanity/template-validator": "^2.4.3",
55
52
  "chalk": "^4.1.2",
@@ -57,17 +54,18 @@
57
54
  "esbuild": "0.27.0",
58
55
  "esbuild-register": "^3.6.0",
59
56
  "get-it": "^8.6.10",
57
+ "get-latest-version": "^5.1.0",
60
58
  "groq-js": "^1.21.0",
61
59
  "pkg-dir": "^5.0.0",
62
60
  "prettier": "^3.6.2",
63
61
  "semver": "^7.7.2",
64
- "@sanity/codegen": "4.19.1-next.9+4fe55a3663"
62
+ "@sanity/codegen": "4.20.0-next.40+721e6d2b96"
65
63
  },
66
64
  "devDependencies": {
67
65
  "@rexxars/gitconfiglocal": "^3.0.1",
68
- "@rollup/plugin-node-resolve": "^16.0.1",
66
+ "@rollup/plugin-node-resolve": "^16.0.3",
69
67
  "@sanity/generate-help-url": "^3.0.0",
70
- "@sanity/pkg-utils": "^8.1.13",
68
+ "@sanity/pkg-utils": "^9.2.0",
71
69
  "@types/babel__traverse": "^7.28.0",
72
70
  "@types/configstore": "^5.0.1",
73
71
  "@types/cpx": "^1.5.5",
@@ -92,7 +90,6 @@
92
90
  "dotenv-expand": "^9.0.0",
93
91
  "eslint": "^9.37.0",
94
92
  "execa": "^2.1.0",
95
- "get-latest-version": "^5.1.0",
96
93
  "git-user-info": "^2.0.3",
97
94
  "globals": "^16.2.0",
98
95
  "inquirer": "^6.5.2",
@@ -116,11 +113,11 @@
116
113
  "vitest": "^3.2.4",
117
114
  "which": "^2.0.2",
118
115
  "xdg-basedir": "^4.0.0",
119
- "@repo/eslint-config": "4.19.1-next.9+4fe55a3663",
120
- "@repo/package.config": "4.19.1-next.9+4fe55a3663",
121
- "@sanity/types": "4.19.1-next.9+4fe55a3663",
122
- "@repo/test-config": "4.19.1-next.9+4fe55a3663",
123
- "@repo/tsconfig": "4.19.1-next.9+4fe55a3663"
116
+ "@repo/eslint-config": "4.20.0-next.40+721e6d2b96",
117
+ "@repo/test-config": "4.20.0-next.40+721e6d2b96",
118
+ "@repo/package.config": "4.20.0-next.40+721e6d2b96",
119
+ "@repo/tsconfig": "4.20.0-next.40+721e6d2b96",
120
+ "@sanity/types": "4.20.0-next.40+721e6d2b96"
124
121
  },
125
122
  "peerDependencies": {
126
123
  "babel-plugin-react-compiler": "*"
package/lib/index.d.mts DELETED
@@ -1,512 +0,0 @@
1
- import {Answers} from 'inquirer'
2
- import type chalk from 'chalk'
3
- import {ChoiceCollection} from 'inquirer'
4
- import {ConfigEnv} from 'vite'
5
- import {DistinctQuestion} from 'inquirer'
6
- import {InlineConfig} from 'vite'
7
- import {Options} from 'ora'
8
- import {Ora} from 'ora'
9
- import {PluginOptions} from 'babel-plugin-react-compiler'
10
- import {SanityClient} from '@sanity/client'
11
- import {Separator} from 'inquirer'
12
- import {TelemetryLogger} from '@sanity/telemetry'
13
- import {TypeGenConfig} from '@sanity/codegen'
14
-
15
- declare interface AppConfig {
16
- /**
17
- * The ID of your Sanity organization
18
- */
19
- organizationId: string
20
- /**
21
- * The entrypoint for your Sanity app. Defaults to './src/App'.
22
- */
23
- entry?: string
24
- /**
25
- * @deprecated - Moved to `deployment.appId`
26
- */
27
- id?: string
28
- }
29
-
30
- export declare type CliApiClient = (options?: ClientRequirements) => SanityClient
31
-
32
- export declare interface CliApiConfig {
33
- projectId?: string
34
- dataset?: string
35
- }
36
-
37
- export declare interface CliClientOptions {
38
- cwd?: string
39
- projectId?: string
40
- dataset?: string
41
- useCdn?: boolean
42
- token?: string
43
- apiVersion?: string
44
- }
45
-
46
- export declare type CliCommandAction<F = Record<string, unknown>> = (
47
- args: CliCommandArguments<F>,
48
- context: CliCommandContext,
49
- ) => Promise<unknown>
50
-
51
- export declare interface CliCommandArguments<F = Record<string, unknown>> {
52
- groupOrCommand: string
53
- argv: string[]
54
- extOptions: F
55
- argsWithoutOptions: string[]
56
- extraArguments: string[]
57
- }
58
-
59
- export declare interface CliCommandContext {
60
- output: CliOutputter
61
- prompt: CliPrompter
62
- apiClient: CliApiClient
63
- cliConfigPath?: string
64
- cliRoot: string
65
- workDir: string
66
- corePath?: string
67
- chalk: typeof chalk
68
- commandRunner: CliCommandRunner
69
- fromInitCommand?: boolean
70
- cliConfig?: CliConfig
71
- cliPackageManager: CliPackageManager
72
- telemetry: TelemetryLogger<TelemetryUserProperties>
73
- }
74
-
75
- export declare interface CliCommandDefinition<F = Record<string, unknown>> {
76
- name: string
77
- group?: string
78
- signature: string
79
- description: string
80
- helpText: string
81
- action: CliCommandAction<F>
82
- hideFromHelp?: boolean
83
- }
84
-
85
- export declare interface CliCommandGroupDefinition {
86
- name: string
87
- signature: string
88
- isGroupRoot: boolean
89
- description: string
90
- hideFromHelp?: boolean
91
- }
92
-
93
- export declare interface CliCommandRunner {
94
- commands: Readonly<(CliCommandDefinition | CliCommandGroupDefinition)[]>
95
- commandGroups: Readonly<Record<string, (CliCommandDefinition | CliCommandGroupDefinition)[]>>
96
- runCommand(
97
- commandOrGroup: string,
98
- args: CliCommandArguments,
99
- options: CommandRunnerOptions,
100
- ): Promise<unknown>
101
- resolveSubcommand(
102
- group: (CliCommandDefinition | CliCommandGroupDefinition)[],
103
- subCommandName: string,
104
- parentGroupName: string,
105
- ): ResolvedCliCommand | null
106
- }
107
-
108
- export declare interface CliConfig {
109
- api?: CliApiConfig
110
- project?: {
111
- basePath?: string
112
- }
113
- /**
114
- * Wraps the Studio in `<React.StrictMode>` root to aid flagging potential problems related to concurrent features (`startTransition`, `useTransition`, `useDeferredValue`, `Suspense`)
115
- * Can also be enabled by setting `SANITY_STUDIO_REACT_STRICT_MODE="true"|"false"`.
116
- * It only applies to `sanity dev` in dev mode, it's ignored in `sanity build` and in production.
117
- * Defaults to `false`
118
- */
119
- reactStrictMode?: boolean
120
- /**
121
- * The React Compiler is currently in beta, and is disabled by default.
122
- * @see https://react.dev/learn/react-compiler
123
- * @beta
124
- */
125
- reactCompiler?: ReactCompilerConfig
126
- server?: {
127
- hostname?: string
128
- port?: number
129
- }
130
- graphql?: GraphQLAPIConfig[]
131
- vite?: UserViteConfig
132
- /**
133
- * @deprecated - Moved to deployment.autoUpdates
134
- */
135
- autoUpdates?: boolean
136
- /**
137
- * @deprecated - Replaced by deployment.appId
138
- */
139
- studioHost?: string
140
- /**
141
- * Parameter used to configure other kinds of applications.
142
- * Signals to `sanity` commands that this is not a studio.
143
- */
144
- app?: AppConfig
145
- /**
146
- * Deployment configuration
147
- */
148
- deployment?: {
149
- /**
150
- * The ID of your Sanity studio or app. Generated when deploying your studio or app for the first time.
151
- * Get the appId either by
152
- * - Checking the output of `sanity deploy`.
153
- * - Get it from your project's Studio tab in https://www.sanity.io/manage
154
- */
155
- appId?: string
156
- /**
157
- * Enable auto-updates for studios.
158
- * {@link https://www.sanity.io/docs/cli#auto-updates}
159
- */
160
- autoUpdates?: boolean
161
- }
162
- /**
163
- * Configuration for Sanity media libraries.
164
- */
165
- mediaLibrary?: {
166
- /**
167
- * The path to the Media Library aspects directory. When using the CLI to manage aspects, this
168
- * is the directory they will be read from and written to.
169
- */
170
- aspectsPath: string
171
- }
172
- /**
173
- * Configuration for Sanity typegen
174
- */
175
- typegen?: Partial<TypeGenConfig>
176
- }
177
-
178
- declare type CliConfigResult =
179
- | {
180
- config: CliConfig
181
- path: string
182
- }
183
- | {
184
- config: null
185
- path: string
186
- }
187
-
188
- declare interface ClientRequirements {
189
- requireUser?: boolean
190
- requireProject?: boolean
191
- api?: {
192
- projectId?: string
193
- dataset?: string
194
- apiHost?: string
195
- apiVersion?: string
196
- requestTagPrefix?: string
197
- }
198
- }
199
-
200
- export declare interface CliOutputter {
201
- print: (...args: unknown[]) => void
202
- success: (...args: unknown[]) => void
203
- warn: (...args: unknown[]) => void
204
- error: (...args: unknown[]) => void
205
- clear: () => void
206
- spinner(options: Options | string): Ora
207
- }
208
-
209
- /**
210
- * @internal
211
- */
212
- declare type CliPackageManager = typeof cliPackageManager
213
-
214
- /**
215
- * @internal
216
- */
217
- declare const cliPackageManager: {
218
- getInstallCommand: typeof getInstallCommand
219
- getPackageManagerChoice: typeof getPackageManagerChoice
220
- installNewPackages: typeof installNewPackages
221
- }
222
-
223
- export declare type CliPrompter = (<T extends Answers = Answers>(
224
- questions: DistinctQuestion<T>[],
225
- ) => Promise<T>) & {
226
- Separator: typeof Separator
227
- single: <T = string>(question: SinglePrompt) => Promise<T>
228
- }
229
-
230
- export declare type CliStubbedYarn = (args: string[], options?: CliYarnOptions) => Promise<void>
231
-
232
- export declare interface CliUserConfig {
233
- cliLastUpdateCheck?: number
234
- cliLastUpdateNag?: number
235
- authToken?: string
236
- authType?: string
237
- }
238
-
239
- export declare interface CliYarnOptions {
240
- print?: CliOutputter['print']
241
- error?: CliOutputter['error']
242
- rootDir?: string
243
- }
244
-
245
- export declare interface CommandRunnerOptions {
246
- cliConfig: CliConfigResult | null
247
- cliRoot: string
248
- workDir: string
249
- corePath: string | undefined
250
- telemetry: TelemetryLogger<TelemetryUserProperties>
251
- }
252
-
253
- /**
254
- * @deprecated Use `defineCliConfig` instead
255
- * @beta
256
- */
257
- export declare function createCliConfig(config: CliConfig): CliConfig
258
-
259
- /** @beta */
260
- export declare function defineCliConfig(config: CliConfig): CliConfig
261
-
262
- declare interface GetCliClient {
263
- (options?: CliClientOptions): SanityClient
264
- /**
265
- * @internal
266
- * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules
267
- * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined
268
- */
269
- __internal__getToken: () => string | undefined
270
- }
271
-
272
- /** @internal */
273
- export declare const getCliClient: GetCliClient
274
-
275
- declare function getInstallCommand(options: {
276
- workDir: string
277
- pkgNames?: string[]
278
- depType?: 'dev' | 'prod' | 'peer'
279
- }): Promise<string>
280
-
281
- /**
282
- * Attempts to resolve the most optimal package manager to use to install/upgrade
283
- * packages/dependencies at a given path. It does so by looking for package manager
284
- * specific lockfiles. If it finds a lockfile belonging to a certain package manager,
285
- * it prioritizes this one. However, if that package manager is not installed, it will
286
- * prompt the user for which one they want to use and hint at the most optimal one
287
- * not being installed.
288
- *
289
- * Note that this function also takes local npm binary paths into account - for instance,
290
- * `yarn` can be installed as a dependency of the project instead of globally, and it
291
- * will use that is available.
292
- *
293
- * The user can also select 'manual' to skip the process and run their preferred package
294
- * manager manually. Commands using this function must take this `manual` choice into
295
- * account and act accordingly if chosen.
296
- *
297
- * @param workDir - The working directory where a lockfile is most likely to be present
298
- * @param options - Pass `interactive: false` to fall back to npm if most optimal is
299
- * not available, instead of prompting
300
- * @returns Object of `chosen` and, if a lockfile is found, the `mostOptimal` choice
301
- */
302
- declare function getPackageManagerChoice(
303
- workDir: string,
304
- options:
305
- | {
306
- interactive: false
307
- }
308
- | {
309
- interactive?: true
310
- prompt: CliPrompter
311
- },
312
- ): Promise<{
313
- chosen: PackageManager
314
- mostOptimal?: PackageManager
315
- }>
316
-
317
- export declare interface GraphQLAPIConfig {
318
- /**
319
- * ID of GraphQL API. Only (currently) required when using the `--api` flag
320
- * for `sanity graphql deploy`, in order to only deploy a specific API.
321
- */
322
- id?: string
323
- /**
324
- * Name of workspace containing the schema to deploy
325
- *
326
- * Optional, defaults to `default` (eg the one used if no `name` is defined)
327
- */
328
- workspace?: string
329
- /**
330
- * Name of source containing the schema to deploy, within the configured workspace
331
- *
332
- * Optional, defaults to `default` (eg the one used if no `name` is defined)
333
- */
334
- source?: string
335
- /**
336
- * API tag for this API - allows deploying multiple different APIs to a single dataset
337
- *
338
- * Optional, defaults to `default`
339
- */
340
- tag?: string
341
- /**
342
- * Whether or not to deploy a "GraphQL Playground" to the API url - an HTML interface that allows
343
- * running queries and introspecting the schema from the browser. Note that this interface is not
344
- * secured in any way, but as the schema definition and API route is generally open, this does not
345
- * expose any more information than is otherwise available - it only makes it more discoverable.
346
- *
347
- * Optional, defaults to `true`
348
- */
349
- playground?: boolean
350
- /**
351
- * Generation of API to auto-generate from schema. New APIs should use the latest (`gen3`).
352
- *
353
- * Optional, defaults to `gen3`
354
- */
355
- generation?: 'gen3' | 'gen2' | 'gen1'
356
- /**
357
- * Define document interface fields (`_id`, `_type` etc) as non-nullable.
358
- * If you never use a document type as an object (within other documents) in your schema types,
359
- * you can (and probably should) set this to `true`. Because a document type _could_ be used
360
- * inside other documents, it is by default set to `false`, as in these cases these fields
361
- * _can_ be null.
362
- *
363
- * Optional, defaults to `false`
364
- */
365
- nonNullDocumentFields?: boolean
366
- /**
367
- * Suffix to use for generated filter types.
368
- *
369
- * Optional, Defaults to `Filter`.
370
- *
371
- */
372
- filterSuffix?: string
373
- }
374
-
375
- declare function installNewPackages(
376
- options: InstallOptions,
377
- context: Pick<CliCommandContext, 'output' | 'workDir'>,
378
- ): Promise<void>
379
-
380
- declare interface InstallOptions {
381
- packageManager: PackageManager
382
- packages: string[]
383
- }
384
-
385
- /**
386
- * This is an "inlined" version of Vite's `loadEnv` function,
387
- * simplified somewhat to only support our use case.
388
- *
389
- * Ideally we'd just use `loadEnv` from Vite, but importing it
390
- * causes bundling issues due to node APIs and downstream dependencies.
391
- *
392
- * Vite is MIT licensed, copyright (c) Yuxi (Evan) You and Vite contributors.
393
- */
394
- export declare function loadEnv(
395
- mode: string,
396
- envDir: string,
397
- prefixes?: string[],
398
- ): Record<string, string>
399
-
400
- export declare interface PackageJson {
401
- name: string
402
- version: string
403
- scripts?: Record<string, string>
404
- description?: string
405
- author?: string
406
- license?: string
407
- private?: boolean
408
- dependencies?: Record<string, string>
409
- devDependencies?: Record<string, string>
410
- peerDependencies?: Record<string, string>
411
- repository?: {
412
- type: string
413
- url: string
414
- }
415
- engines?: Record<string, string>
416
- }
417
-
418
- declare type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'manual'
419
-
420
- /**
421
- * @beta
422
- */
423
- export declare type ReactCompilerConfig = Partial<PluginOptions>
424
-
425
- export declare interface ResolvedCliCommand {
426
- command: CliCommandDefinition | CliCommandGroupDefinition
427
- commandName: string
428
- parentName?: string
429
- isGroup: boolean
430
- isCommand: boolean
431
- }
432
-
433
- export {SanityClient}
434
-
435
- export declare interface SanityCore {
436
- requiredCliVersionRange: string
437
- commands: (CliCommandDefinition | CliCommandGroupDefinition)[]
438
- }
439
-
440
- export declare interface SanityJson {
441
- root?: boolean
442
- project?: {
443
- name?: string
444
- basePath?: string
445
- }
446
- api?: CliApiConfig
447
- __experimental_spaces?: {
448
- name: string
449
- title: string
450
- default?: true
451
- api: {
452
- projectId?: string
453
- dataset?: string
454
- }
455
- }[]
456
- plugins?: string[]
457
- parts?: {
458
- name?: string
459
- path?: string
460
- implements?: string
461
- description?: string
462
- }[]
463
- env?: {
464
- production?: SanityJson
465
- staging?: SanityJson
466
- development?: SanityJson
467
- }
468
- }
469
-
470
- export declare interface SanityModuleInternal {
471
- cliProjectCommands: {
472
- requiredCliVersionRange: string
473
- commands: (CliCommandDefinition | CliCommandGroupDefinition)[]
474
- }
475
- }
476
-
477
- export declare type SanityUser = {
478
- id: string
479
- name: string
480
- email: string
481
- profileImage?: string
482
- tosAcceptedAt?: string
483
- provider: 'google' | 'github' | 'sanity' | `saml-${string}`
484
- }
485
-
486
- export declare type SinglePrompt =
487
- | (Omit<DistinctQuestion, 'name'> & {
488
- type: 'list'
489
- choices: ChoiceCollection
490
- })
491
- | (Omit<DistinctQuestion, 'name'> & {
492
- type: 'confirm'
493
- })
494
- | (Omit<DistinctQuestion, 'name'> & {
495
- type: 'input'
496
- })
497
-
498
- export declare interface TelemetryUserProperties {
499
- runtime: string
500
- runtimeVersion: string
501
- cliVersion: string
502
- machinePlatform: string
503
- cpuArchitecture: string
504
- projectId?: string
505
- dataset?: string
506
- }
507
-
508
- export declare type UserViteConfig =
509
- | InlineConfig
510
- | ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>)
511
-
512
- export {}