@sanity/cli 5.8.1-next.8 → 5.8.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.
@@ -0,0 +1,428 @@
1
+ import { SanityClient } from "@sanity/client";
2
+ import { TypeGenConfig } from "@sanity/codegen";
3
+ import { TelemetryLogger } from "@sanity/telemetry";
4
+ import { PluginOptions } from "babel-plugin-react-compiler";
5
+ import chalk from "chalk";
6
+ import { Answers, ChoiceCollection, DistinctQuestion, Separator } from "inquirer";
7
+ import { Options, Ora } from "ora";
8
+ import { ConfigEnv, InlineConfig } from "vite";
9
+ declare function getInstallCommand(options: {
10
+ workDir: string;
11
+ pkgNames?: string[];
12
+ depType?: 'dev' | 'prod' | 'peer';
13
+ }): Promise<string>;
14
+ type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'manual';
15
+ /**
16
+ * Attempts to resolve the most optimal package manager to use to install/upgrade
17
+ * packages/dependencies at a given path. It does so by looking for package manager
18
+ * specific lockfiles. If it finds a lockfile belonging to a certain package manager,
19
+ * it prioritizes this one. However, if that package manager is not installed, it will
20
+ * prompt the user for which one they want to use and hint at the most optimal one
21
+ * not being installed.
22
+ *
23
+ * Note that this function also takes local npm binary paths into account - for instance,
24
+ * `yarn` can be installed as a dependency of the project instead of globally, and it
25
+ * will use that is available.
26
+ *
27
+ * The user can also select 'manual' to skip the process and run their preferred package
28
+ * manager manually. Commands using this function must take this `manual` choice into
29
+ * account and act accordingly if chosen.
30
+ *
31
+ * @param workDir - The working directory where a lockfile is most likely to be present
32
+ * @param options - Pass `interactive: false` to fall back to npm if most optimal is
33
+ * not available, instead of prompting
34
+ * @returns Object of `chosen` and, if a lockfile is found, the `mostOptimal` choice
35
+ */
36
+ declare function getPackageManagerChoice(workDir: string, options: {
37
+ interactive: false;
38
+ } | {
39
+ interactive?: true;
40
+ prompt: CliPrompter;
41
+ }): Promise<{
42
+ chosen: PackageManager;
43
+ mostOptimal?: PackageManager;
44
+ }>;
45
+ interface InstallOptions {
46
+ packageManager: PackageManager;
47
+ packages: string[];
48
+ }
49
+ declare function installNewPackages(options: InstallOptions, context: Pick<CliCommandContext, 'output' | 'workDir'>): Promise<void>;
50
+ /**
51
+ * @internal
52
+ */
53
+ declare const cliPackageManager: {
54
+ getInstallCommand: typeof getInstallCommand;
55
+ getPackageManagerChoice: typeof getPackageManagerChoice;
56
+ installNewPackages: typeof installNewPackages;
57
+ };
58
+ /**
59
+ * @internal
60
+ */
61
+ type CliPackageManager = typeof cliPackageManager;
62
+ interface ClientRequirements {
63
+ requireUser?: boolean;
64
+ requireProject?: boolean;
65
+ api?: {
66
+ projectId?: string;
67
+ dataset?: string;
68
+ apiHost?: string;
69
+ apiVersion?: string;
70
+ requestTagPrefix?: string;
71
+ };
72
+ }
73
+ type CliConfigResult = {
74
+ config: CliConfig;
75
+ path: string;
76
+ } | {
77
+ config: null;
78
+ path: string;
79
+ };
80
+ interface SanityCore {
81
+ requiredCliVersionRange: string;
82
+ commands: (CliCommandDefinition | CliCommandGroupDefinition)[];
83
+ }
84
+ interface SanityModuleInternal {
85
+ cliProjectCommands: {
86
+ requiredCliVersionRange: string;
87
+ commands: (CliCommandDefinition | CliCommandGroupDefinition)[];
88
+ };
89
+ }
90
+ interface PackageJson {
91
+ name: string;
92
+ version: string;
93
+ scripts?: Record<string, string>;
94
+ description?: string;
95
+ author?: string;
96
+ license?: string;
97
+ private?: boolean;
98
+ dependencies?: Record<string, string>;
99
+ devDependencies?: Record<string, string>;
100
+ peerDependencies?: Record<string, string>;
101
+ repository?: {
102
+ type: string;
103
+ url: string;
104
+ };
105
+ engines?: Record<string, string>;
106
+ }
107
+ interface CliCommandGroupDefinition {
108
+ name: string;
109
+ signature: string;
110
+ isGroupRoot: boolean;
111
+ description: string;
112
+ hideFromHelp?: boolean;
113
+ }
114
+ interface ResolvedCliCommand {
115
+ command: CliCommandDefinition | CliCommandGroupDefinition;
116
+ commandName: string;
117
+ parentName?: string;
118
+ isGroup: boolean;
119
+ isCommand: boolean;
120
+ }
121
+ type CliCommandAction<F = Record<string, unknown>> = (args: CliCommandArguments<F>, context: CliCommandContext) => Promise<unknown>;
122
+ interface CliCommandDefinition<F = Record<string, unknown>> {
123
+ name: string;
124
+ group?: string;
125
+ signature: string;
126
+ description: string;
127
+ helpText: string;
128
+ action: CliCommandAction<F>;
129
+ hideFromHelp?: boolean;
130
+ }
131
+ interface CliCommandArguments<F = Record<string, unknown>> {
132
+ groupOrCommand: string;
133
+ argv: string[];
134
+ extOptions: F;
135
+ argsWithoutOptions: string[];
136
+ extraArguments: string[];
137
+ }
138
+ interface TelemetryUserProperties {
139
+ runtime: string;
140
+ runtimeVersion: string;
141
+ cliVersion: string;
142
+ machinePlatform: string;
143
+ cpuArchitecture: string;
144
+ projectId?: string;
145
+ dataset?: string;
146
+ }
147
+ interface CliCommandContext {
148
+ output: CliOutputter;
149
+ prompt: CliPrompter;
150
+ apiClient: CliApiClient;
151
+ cliConfigPath?: string;
152
+ cliRoot: string;
153
+ workDir: string;
154
+ corePath?: string;
155
+ chalk: typeof chalk;
156
+ commandRunner: CliCommandRunner;
157
+ fromInitCommand?: boolean;
158
+ cliConfig?: CliConfig;
159
+ cliPackageManager: CliPackageManager;
160
+ telemetry: TelemetryLogger<TelemetryUserProperties>;
161
+ }
162
+ interface CliCommandRunner {
163
+ commands: Readonly<(CliCommandDefinition | CliCommandGroupDefinition)[]>;
164
+ commandGroups: Readonly<Record<string, (CliCommandDefinition | CliCommandGroupDefinition)[]>>;
165
+ runCommand(commandOrGroup: string, args: CliCommandArguments, options: CommandRunnerOptions): Promise<unknown>;
166
+ resolveSubcommand(group: (CliCommandDefinition | CliCommandGroupDefinition)[], subCommandName: string, parentGroupName: string): ResolvedCliCommand | null;
167
+ }
168
+ interface CliUserConfig {
169
+ cliLastUpdateCheck?: number;
170
+ cliLastUpdateNag?: number;
171
+ authToken?: string;
172
+ authType?: string;
173
+ }
174
+ interface CommandRunnerOptions {
175
+ cliConfig: CliConfigResult | null;
176
+ cliRoot: string;
177
+ workDir: string;
178
+ corePath: string | undefined;
179
+ telemetry: TelemetryLogger<TelemetryUserProperties>;
180
+ }
181
+ interface CliOutputter {
182
+ print: (...args: unknown[]) => void;
183
+ success: (...args: unknown[]) => void;
184
+ warn: (...args: unknown[]) => void;
185
+ error: (...args: unknown[]) => void;
186
+ clear: () => void;
187
+ spinner(options: Options | string): Ora;
188
+ }
189
+ type SinglePrompt = (Omit<DistinctQuestion, 'name'> & {
190
+ type: 'list';
191
+ choices: ChoiceCollection;
192
+ }) | (Omit<DistinctQuestion, 'name'> & {
193
+ type: 'confirm';
194
+ }) | (Omit<DistinctQuestion, 'name'> & {
195
+ type: 'input';
196
+ });
197
+ type CliPrompter = (<T extends Answers = Answers>(questions: DistinctQuestion<T>[]) => Promise<T>) & {
198
+ Separator: typeof Separator;
199
+ single: <T = string>(question: SinglePrompt) => Promise<T>;
200
+ };
201
+ type CliApiClient = (options?: ClientRequirements) => SanityClient;
202
+ interface CliYarnOptions {
203
+ print?: CliOutputter['print'];
204
+ error?: CliOutputter['error'];
205
+ rootDir?: string;
206
+ }
207
+ type CliStubbedYarn = (args: string[], options?: CliYarnOptions) => Promise<void>;
208
+ interface CliApiConfig {
209
+ projectId?: string;
210
+ dataset?: string;
211
+ }
212
+ interface SanityJson {
213
+ root?: boolean;
214
+ project?: {
215
+ name?: string;
216
+ basePath?: string;
217
+ };
218
+ api?: CliApiConfig;
219
+ __experimental_spaces?: {
220
+ name: string;
221
+ title: string;
222
+ default?: true;
223
+ api: {
224
+ projectId?: string;
225
+ dataset?: string;
226
+ };
227
+ }[];
228
+ plugins?: string[];
229
+ parts?: {
230
+ name?: string;
231
+ path?: string;
232
+ implements?: string;
233
+ description?: string;
234
+ }[];
235
+ env?: {
236
+ production?: SanityJson;
237
+ staging?: SanityJson;
238
+ development?: SanityJson;
239
+ };
240
+ }
241
+ interface GraphQLAPIConfig {
242
+ /**
243
+ * ID of GraphQL API. Only (currently) required when using the `--api` flag
244
+ * for `sanity graphql deploy`, in order to only deploy a specific API.
245
+ */
246
+ id?: string;
247
+ /**
248
+ * Name of workspace containing the schema to deploy
249
+ *
250
+ * Optional, defaults to `default` (eg the one used if no `name` is defined)
251
+ */
252
+ workspace?: string;
253
+ /**
254
+ * Name of source containing the schema to deploy, within the configured workspace
255
+ *
256
+ * Optional, defaults to `default` (eg the one used if no `name` is defined)
257
+ */
258
+ source?: string;
259
+ /**
260
+ * API tag for this API - allows deploying multiple different APIs to a single dataset
261
+ *
262
+ * Optional, defaults to `default`
263
+ */
264
+ tag?: string;
265
+ /**
266
+ * Whether or not to deploy a "GraphQL Playground" to the API url - an HTML interface that allows
267
+ * running queries and introspecting the schema from the browser. Note that this interface is not
268
+ * secured in any way, but as the schema definition and API route is generally open, this does not
269
+ * expose any more information than is otherwise available - it only makes it more discoverable.
270
+ *
271
+ * Optional, defaults to `true`
272
+ */
273
+ playground?: boolean;
274
+ /**
275
+ * Generation of API to auto-generate from schema. New APIs should use the latest (`gen3`).
276
+ *
277
+ * Optional, defaults to `gen3`
278
+ */
279
+ generation?: 'gen3' | 'gen2' | 'gen1';
280
+ /**
281
+ * Define document interface fields (`_id`, `_type` etc) as non-nullable.
282
+ * If you never use a document type as an object (within other documents) in your schema types,
283
+ * you can (and probably should) set this to `true`. Because a document type _could_ be used
284
+ * inside other documents, it is by default set to `false`, as in these cases these fields
285
+ * _can_ be null.
286
+ *
287
+ * Optional, defaults to `false`
288
+ */
289
+ nonNullDocumentFields?: boolean;
290
+ /**
291
+ * Suffix to use for generated filter types.
292
+ *
293
+ * Optional, Defaults to `Filter`.
294
+ *
295
+ */
296
+ filterSuffix?: string;
297
+ }
298
+ /**
299
+ * @beta
300
+ */
301
+ type ReactCompilerConfig = Partial<PluginOptions>;
302
+ interface AppConfig {
303
+ /**
304
+ * The ID of your Sanity organization
305
+ */
306
+ organizationId: string;
307
+ /**
308
+ * The entrypoint for your Sanity app. Defaults to './src/App'.
309
+ */
310
+ entry?: string;
311
+ /**
312
+ * @deprecated - Moved to `deployment.appId`
313
+ */
314
+ id?: string;
315
+ }
316
+ interface CliConfig {
317
+ api?: CliApiConfig;
318
+ project?: {
319
+ basePath?: string;
320
+ };
321
+ /**
322
+ * Wraps the Studio in `<React.StrictMode>` root to aid flagging potential problems related to concurrent features (`startTransition`, `useTransition`, `useDeferredValue`, `Suspense`)
323
+ * Can also be enabled by setting `SANITY_STUDIO_REACT_STRICT_MODE="true"|"false"`.
324
+ * It only applies to `sanity dev` in dev mode, it's ignored in `sanity build` and in production.
325
+ * Defaults to `false`
326
+ */
327
+ reactStrictMode?: boolean;
328
+ /**
329
+ * The React Compiler is currently in beta, and is disabled by default.
330
+ * @see https://react.dev/learn/react-compiler
331
+ * @beta
332
+ */
333
+ reactCompiler?: ReactCompilerConfig;
334
+ server?: {
335
+ hostname?: string;
336
+ port?: number;
337
+ };
338
+ graphql?: GraphQLAPIConfig[];
339
+ vite?: UserViteConfig;
340
+ /**
341
+ * @deprecated - Moved to deployment.autoUpdates
342
+ */
343
+ autoUpdates?: boolean;
344
+ /**
345
+ * @deprecated - Replaced by deployment.appId
346
+ */
347
+ studioHost?: string;
348
+ /**
349
+ * Parameter used to configure other kinds of applications.
350
+ * Signals to `sanity` commands that this is not a studio.
351
+ */
352
+ app?: AppConfig;
353
+ /**
354
+ * Deployment configuration
355
+ */
356
+ deployment?: {
357
+ /**
358
+ * The ID of your Sanity studio or app. Generated when deploying your studio or app for the first time.
359
+ * Get the appId either by
360
+ * - Checking the output of `sanity deploy`.
361
+ * - Get it from your project's Studio tab in https://www.sanity.io/manage
362
+ */
363
+ appId?: string;
364
+ /**
365
+ * Enable auto-updates for studios.
366
+ * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k47faf43faf56}
367
+ */
368
+ autoUpdates?: boolean;
369
+ };
370
+ /**
371
+ * Configuration for Sanity media libraries.
372
+ */
373
+ mediaLibrary?: {
374
+ /**
375
+ * The path to the Media Library aspects directory. When using the CLI to manage aspects, this
376
+ * is the directory they will be read from and written to.
377
+ */
378
+ aspectsPath: string;
379
+ };
380
+ /**
381
+ * Configuration for Sanity typegen
382
+ */
383
+ typegen?: Partial<TypeGenConfig> & {
384
+ /**
385
+ * Enable typegen as part of sanity dev and sanity build.
386
+ * When enabled, types are generated on startup and when files change.
387
+ * Defaults to `false`
388
+ */
389
+ enabled?: boolean;
390
+ };
391
+ /**
392
+ * Configuration for schema extraction (`sanity schema extract`)
393
+ */
394
+ schemaExtraction?: {
395
+ /**
396
+ * Output path for the extracted schema file.
397
+ * Defaults to `schema.json` in the working directory.
398
+ */
399
+ path?: string;
400
+ /**
401
+ * When true, schema fields marked as required will be non-optional in the output.
402
+ * Defaults to `false`
403
+ */
404
+ enforceRequiredFields?: boolean;
405
+ /**
406
+ * Additional glob patterns to watch for schema changes in watch mode.
407
+ * These extend the default patterns:
408
+ * - `sanity.config.{js,jsx,ts,tsx,mjs}`
409
+ * - `schema*\/**\/*.{js,jsx,ts,tsx,mjs}`
410
+ */
411
+ watchPatterns?: string[];
412
+ /**
413
+ * The name of the workspace to generate a schema for. Required if your Sanity project has more than one
414
+ * workspace.
415
+ */
416
+ workspace?: string;
417
+ };
418
+ }
419
+ type UserViteConfig = InlineConfig | ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>);
420
+ type SanityUser = {
421
+ id: string;
422
+ name: string;
423
+ email: string;
424
+ profileImage?: string;
425
+ tosAcceptedAt?: string;
426
+ provider: 'google' | 'github' | 'sanity' | `saml-${string}`;
427
+ };
428
+ export { SanityUser as C, UserViteConfig as E, SanityModuleInternal as S, TelemetryUserProperties as T, PackageJson as _, CliCommandContext as a, SanityCore as b, CliCommandRunner as c, CliPrompter as d, CliStubbedYarn as f, GraphQLAPIConfig as g, CommandRunnerOptions as h, CliCommandArguments as i, CliConfig as l, CliYarnOptions as m, CliApiConfig as n, CliCommandDefinition as o, CliUserConfig as p, CliCommandAction as r, CliCommandGroupDefinition as s, CliApiClient as t, CliOutputter as u, ReactCompilerConfig as v, SinglePrompt as w, SanityJson as x, ResolvedCliCommand as y };
package/lib/cli.d.ts CHANGED
@@ -1,28 +1,7 @@
1
- declare interface PackageJson {
2
- name: string;
3
- version: string;
4
- scripts?: Record<string, string>;
5
- description?: string;
6
- author?: string;
7
- license?: string;
8
- private?: boolean;
9
- dependencies?: Record<string, string>;
10
- devDependencies?: Record<string, string>;
11
- peerDependencies?: Record<string, string>;
12
- repository?: {
13
- type: string;
14
- url: string;
15
- };
16
- engines?: Record<string, string>;
17
- }
18
-
19
- export declare function runCli(
20
- cliRoot: string,
21
- {
22
- cliPkg,
23
- }: {
24
- cliPkg: PackageJson;
25
- },
26
- ): Promise<void>;
27
-
28
- export {};
1
+ import { _ as PackageJson } from "./_chunks-dts/types.js";
2
+ declare function runCli(cliRoot: string, {
3
+ cliPkg
4
+ }: {
5
+ cliPkg: PackageJson;
6
+ }): Promise<void>;
7
+ export { runCli };
package/lib/index.d.ts CHANGED
@@ -1,48 +1,11 @@
1
- import { Answers } from "inquirer";
2
- import type chalk from "chalk";
3
- import { ChoiceCollection } from "inquirer";
4
- import { ClientConfig } from "@sanity/client";
5
- import { ConfigEnv } from "vite";
6
- import { DistinctQuestion } from "inquirer";
7
- import { InlineConfig } from "vite";
8
- import { Options } from "ora";
9
- import { Ora } from "ora";
10
- import { PluginOptions } from "babel-plugin-react-compiler";
11
- import { SanityClient } from "@sanity/client";
12
- import { Separator } from "inquirer";
13
- import { TelemetryLogger } from "@sanity/telemetry";
14
- import { TypeGenConfig } from "@sanity/codegen";
15
-
16
- declare interface AppConfig {
17
- /**
18
- * The ID of your Sanity organization
19
- */
20
- organizationId: string;
21
- /**
22
- * The entrypoint for your Sanity app. Defaults to './src/App'.
23
- */
24
- entry?: string;
25
- /**
26
- * @deprecated - Moved to `deployment.appId`
27
- */
28
- id?: string;
29
- }
30
-
31
- export declare type CliApiClient = (
32
- options?: ClientRequirements,
33
- ) => SanityClient;
34
-
35
- export declare interface CliApiConfig {
36
- projectId?: string;
37
- dataset?: string;
38
- }
39
-
1
+ import { C as SanityUser, E as UserViteConfig, S as SanityModuleInternal, T as TelemetryUserProperties, _ as PackageJson, a as CliCommandContext, b as SanityCore, c as CliCommandRunner, d as CliPrompter, f as CliStubbedYarn, g as GraphQLAPIConfig, h as CommandRunnerOptions, i as CliCommandArguments, l as CliConfig, m as CliYarnOptions, n as CliApiConfig, o as CliCommandDefinition, p as CliUserConfig, r as CliCommandAction, s as CliCommandGroupDefinition, t as CliApiClient, u as CliOutputter, v as ReactCompilerConfig, w as SinglePrompt, x as SanityJson, y as ResolvedCliCommand } from "./_chunks-dts/types.js";
2
+ import { ClientConfig, SanityClient, SanityClient as SanityClient$1 } from "@sanity/client";
40
3
  /**
41
4
  * `getCliClient` accepts all options the `ClientConfig` does but provides
42
5
  * `projectId` and `dataset` from the `sanity.cli.ts` configuration file along
43
6
  * with a token in certain scenarios (e.g. `sanity exec SCRIPT --with-user-token`)
44
7
  */
45
- export declare interface CliClientOptions extends ClientConfig {
8
+ interface CliClientOptions extends ClientConfig {
46
9
  /**
47
10
  * If no `projectId` or `dataset` is provided, `getCliClient` will try to
48
11
  * resolve these from the `sanity.cli.ts` configuration file. Use this option
@@ -50,264 +13,8 @@ export declare interface CliClientOptions extends ClientConfig {
50
13
  */
51
14
  cwd?: string;
52
15
  }
53
-
54
- export declare type CliCommandAction<F = Record<string, unknown>> = (
55
- args: CliCommandArguments<F>,
56
- context: CliCommandContext,
57
- ) => Promise<unknown>;
58
-
59
- export declare interface CliCommandArguments<F = Record<string, unknown>> {
60
- groupOrCommand: string;
61
- argv: string[];
62
- extOptions: F;
63
- argsWithoutOptions: string[];
64
- extraArguments: string[];
65
- }
66
-
67
- export declare interface CliCommandContext {
68
- output: CliOutputter;
69
- prompt: CliPrompter;
70
- apiClient: CliApiClient;
71
- cliConfigPath?: string;
72
- cliRoot: string;
73
- workDir: string;
74
- corePath?: string;
75
- chalk: typeof chalk;
76
- commandRunner: CliCommandRunner;
77
- fromInitCommand?: boolean;
78
- cliConfig?: CliConfig;
79
- cliPackageManager: CliPackageManager;
80
- telemetry: TelemetryLogger<TelemetryUserProperties>;
81
- }
82
-
83
- export declare interface CliCommandDefinition<F = Record<string, unknown>> {
84
- name: string;
85
- group?: string;
86
- signature: string;
87
- description: string;
88
- helpText: string;
89
- action: CliCommandAction<F>;
90
- hideFromHelp?: boolean;
91
- }
92
-
93
- export declare interface CliCommandGroupDefinition {
94
- name: string;
95
- signature: string;
96
- isGroupRoot: boolean;
97
- description: string;
98
- hideFromHelp?: boolean;
99
- }
100
-
101
- export declare interface CliCommandRunner {
102
- commands: Readonly<(CliCommandDefinition | CliCommandGroupDefinition)[]>;
103
- commandGroups: Readonly<
104
- Record<string, (CliCommandDefinition | CliCommandGroupDefinition)[]>
105
- >;
106
- runCommand(
107
- commandOrGroup: string,
108
- args: CliCommandArguments,
109
- options: CommandRunnerOptions,
110
- ): Promise<unknown>;
111
- resolveSubcommand(
112
- group: (CliCommandDefinition | CliCommandGroupDefinition)[],
113
- subCommandName: string,
114
- parentGroupName: string,
115
- ): ResolvedCliCommand | null;
116
- }
117
-
118
- export declare interface CliConfig {
119
- api?: CliApiConfig;
120
- project?: {
121
- basePath?: string;
122
- };
123
- /**
124
- * Wraps the Studio in `<React.StrictMode>` root to aid flagging potential problems related to concurrent features (`startTransition`, `useTransition`, `useDeferredValue`, `Suspense`)
125
- * Can also be enabled by setting `SANITY_STUDIO_REACT_STRICT_MODE="true"|"false"`.
126
- * It only applies to `sanity dev` in dev mode, it's ignored in `sanity build` and in production.
127
- * Defaults to `false`
128
- */
129
- reactStrictMode?: boolean;
130
- /**
131
- * The React Compiler is currently in beta, and is disabled by default.
132
- * @see https://react.dev/learn/react-compiler
133
- * @beta
134
- */
135
- reactCompiler?: ReactCompilerConfig;
136
- server?: {
137
- hostname?: string;
138
- port?: number;
139
- };
140
- graphql?: GraphQLAPIConfig[];
141
- vite?: UserViteConfig;
142
- /**
143
- * @deprecated - Moved to deployment.autoUpdates
144
- */
145
- autoUpdates?: boolean;
146
- /**
147
- * @deprecated - Replaced by deployment.appId
148
- */
149
- studioHost?: string;
150
- /**
151
- * Parameter used to configure other kinds of applications.
152
- * Signals to `sanity` commands that this is not a studio.
153
- */
154
- app?: AppConfig;
155
- /**
156
- * Deployment configuration
157
- */
158
- deployment?: {
159
- /**
160
- * The ID of your Sanity studio or app. Generated when deploying your studio or app for the first time.
161
- * Get the appId either by
162
- * - Checking the output of `sanity deploy`.
163
- * - Get it from your project's Studio tab in https://www.sanity.io/manage
164
- */
165
- appId?: string;
166
- /**
167
- * Enable auto-updates for studios.
168
- * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k47faf43faf56}
169
- */
170
- autoUpdates?: boolean;
171
- };
172
- /**
173
- * Configuration for Sanity media libraries.
174
- */
175
- mediaLibrary?: {
176
- /**
177
- * The path to the Media Library aspects directory. When using the CLI to manage aspects, this
178
- * is the directory they will be read from and written to.
179
- */
180
- aspectsPath: string;
181
- };
182
- /**
183
- * Configuration for Sanity typegen
184
- */
185
- typegen?: Partial<TypeGenConfig> & {
186
- /**
187
- * Enable typegen as part of sanity dev and sanity build.
188
- * When enabled, types are generated on startup and when files change.
189
- * Defaults to `false`
190
- */
191
- enabled?: boolean;
192
- };
193
- /**
194
- * Configuration for schema extraction (`sanity schema extract`)
195
- */
196
- schemaExtraction?: {
197
- /**
198
- * Output path for the extracted schema file.
199
- * Defaults to `schema.json` in the working directory.
200
- */
201
- path?: string;
202
- /**
203
- * When true, schema fields marked as required will be non-optional in the output.
204
- * Defaults to `false`
205
- */
206
- enforceRequiredFields?: boolean;
207
- /**
208
- * Additional glob patterns to watch for schema changes in watch mode.
209
- * These extend the default patterns:
210
- * - `sanity.config.{js,jsx,ts,tsx,mjs}`
211
- * - `schema*\/**\/*.{js,jsx,ts,tsx,mjs}`
212
- */
213
- watchPatterns?: string[];
214
- /**
215
- * The name of the workspace to generate a schema for. Required if your Sanity project has more than one
216
- * workspace.
217
- */
218
- workspace?: string;
219
- };
220
- }
221
-
222
- declare type CliConfigResult =
223
- | {
224
- config: CliConfig;
225
- path: string;
226
- }
227
- | {
228
- config: null;
229
- path: string;
230
- };
231
-
232
- declare interface ClientRequirements {
233
- requireUser?: boolean;
234
- requireProject?: boolean;
235
- api?: {
236
- projectId?: string;
237
- dataset?: string;
238
- apiHost?: string;
239
- apiVersion?: string;
240
- requestTagPrefix?: string;
241
- };
242
- }
243
-
244
- export declare interface CliOutputter {
245
- print: (...args: unknown[]) => void;
246
- success: (...args: unknown[]) => void;
247
- warn: (...args: unknown[]) => void;
248
- error: (...args: unknown[]) => void;
249
- clear: () => void;
250
- spinner(options: Options | string): Ora;
251
- }
252
-
253
- /**
254
- * @internal
255
- */
256
- declare type CliPackageManager = typeof cliPackageManager;
257
-
258
- /**
259
- * @internal
260
- */
261
- declare const cliPackageManager: {
262
- getInstallCommand: typeof getInstallCommand;
263
- getPackageManagerChoice: typeof getPackageManagerChoice;
264
- installNewPackages: typeof installNewPackages;
265
- };
266
-
267
- export declare type CliPrompter = (<T extends Answers = Answers>(
268
- questions: DistinctQuestion<T>[],
269
- ) => Promise<T>) & {
270
- Separator: typeof Separator;
271
- single: <T = string>(question: SinglePrompt) => Promise<T>;
272
- };
273
-
274
- export declare type CliStubbedYarn = (
275
- args: string[],
276
- options?: CliYarnOptions,
277
- ) => Promise<void>;
278
-
279
- export declare interface CliUserConfig {
280
- cliLastUpdateCheck?: number;
281
- cliLastUpdateNag?: number;
282
- authToken?: string;
283
- authType?: string;
284
- }
285
-
286
- export declare interface CliYarnOptions {
287
- print?: CliOutputter["print"];
288
- error?: CliOutputter["error"];
289
- rootDir?: string;
290
- }
291
-
292
- export declare interface CommandRunnerOptions {
293
- cliConfig: CliConfigResult | null;
294
- cliRoot: string;
295
- workDir: string;
296
- corePath: string | undefined;
297
- telemetry: TelemetryLogger<TelemetryUserProperties>;
298
- }
299
-
300
- /**
301
- * @deprecated Use `defineCliConfig` instead
302
- * @beta
303
- */
304
- export declare function createCliConfig(config: CliConfig): CliConfig;
305
-
306
- /** @beta */
307
- export declare function defineCliConfig(config: CliConfig): CliConfig;
308
-
309
- declare interface GetCliClient {
310
- (options?: CliClientOptions): SanityClient;
16
+ interface GetCliClient {
17
+ (options?: CliClientOptions): SanityClient$1;
311
18
  /**
312
19
  * @internal
313
20
  * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules
@@ -315,120 +22,15 @@ declare interface GetCliClient {
315
22
  */
316
23
  __internal__getToken: () => string | undefined;
317
24
  }
318
-
319
25
  /** @internal */
320
- export declare const getCliClient: GetCliClient;
321
-
322
- declare function getInstallCommand(options: {
323
- workDir: string;
324
- pkgNames?: string[];
325
- depType?: "dev" | "prod" | "peer";
326
- }): Promise<string>;
327
-
26
+ declare const getCliClient: GetCliClient;
27
+ /** @beta */
28
+ declare function defineCliConfig(config: CliConfig): CliConfig;
328
29
  /**
329
- * Attempts to resolve the most optimal package manager to use to install/upgrade
330
- * packages/dependencies at a given path. It does so by looking for package manager
331
- * specific lockfiles. If it finds a lockfile belonging to a certain package manager,
332
- * it prioritizes this one. However, if that package manager is not installed, it will
333
- * prompt the user for which one they want to use and hint at the most optimal one
334
- * not being installed.
335
- *
336
- * Note that this function also takes local npm binary paths into account - for instance,
337
- * `yarn` can be installed as a dependency of the project instead of globally, and it
338
- * will use that is available.
339
- *
340
- * The user can also select 'manual' to skip the process and run their preferred package
341
- * manager manually. Commands using this function must take this `manual` choice into
342
- * account and act accordingly if chosen.
343
- *
344
- * @param workDir - The working directory where a lockfile is most likely to be present
345
- * @param options - Pass `interactive: false` to fall back to npm if most optimal is
346
- * not available, instead of prompting
347
- * @returns Object of `chosen` and, if a lockfile is found, the `mostOptimal` choice
30
+ * @deprecated Use `defineCliConfig` instead
31
+ * @beta
348
32
  */
349
- declare function getPackageManagerChoice(
350
- workDir: string,
351
- options:
352
- | {
353
- interactive: false;
354
- }
355
- | {
356
- interactive?: true;
357
- prompt: CliPrompter;
358
- },
359
- ): Promise<{
360
- chosen: PackageManager;
361
- mostOptimal?: PackageManager;
362
- }>;
363
-
364
- export declare interface GraphQLAPIConfig {
365
- /**
366
- * ID of GraphQL API. Only (currently) required when using the `--api` flag
367
- * for `sanity graphql deploy`, in order to only deploy a specific API.
368
- */
369
- id?: string;
370
- /**
371
- * Name of workspace containing the schema to deploy
372
- *
373
- * Optional, defaults to `default` (eg the one used if no `name` is defined)
374
- */
375
- workspace?: string;
376
- /**
377
- * Name of source containing the schema to deploy, within the configured workspace
378
- *
379
- * Optional, defaults to `default` (eg the one used if no `name` is defined)
380
- */
381
- source?: string;
382
- /**
383
- * API tag for this API - allows deploying multiple different APIs to a single dataset
384
- *
385
- * Optional, defaults to `default`
386
- */
387
- tag?: string;
388
- /**
389
- * Whether or not to deploy a "GraphQL Playground" to the API url - an HTML interface that allows
390
- * running queries and introspecting the schema from the browser. Note that this interface is not
391
- * secured in any way, but as the schema definition and API route is generally open, this does not
392
- * expose any more information than is otherwise available - it only makes it more discoverable.
393
- *
394
- * Optional, defaults to `true`
395
- */
396
- playground?: boolean;
397
- /**
398
- * Generation of API to auto-generate from schema. New APIs should use the latest (`gen3`).
399
- *
400
- * Optional, defaults to `gen3`
401
- */
402
- generation?: "gen3" | "gen2" | "gen1";
403
- /**
404
- * Define document interface fields (`_id`, `_type` etc) as non-nullable.
405
- * If you never use a document type as an object (within other documents) in your schema types,
406
- * you can (and probably should) set this to `true`. Because a document type _could_ be used
407
- * inside other documents, it is by default set to `false`, as in these cases these fields
408
- * _can_ be null.
409
- *
410
- * Optional, defaults to `false`
411
- */
412
- nonNullDocumentFields?: boolean;
413
- /**
414
- * Suffix to use for generated filter types.
415
- *
416
- * Optional, Defaults to `Filter`.
417
- *
418
- */
419
- filterSuffix?: string;
420
- }
421
-
422
- declare function installNewPackages(
423
- options: InstallOptions,
424
- context: Pick<CliCommandContext, "output" | "workDir">,
425
- ): Promise<void>;
426
-
427
- declare interface InstallOptions {
428
- packageManager: PackageManager;
429
- packages: string[];
430
- }
431
-
33
+ declare function createCliConfig(config: CliConfig): CliConfig;
432
34
  /**
433
35
  * This is an "inlined" version of Vite's `loadEnv` function,
434
36
  * simplified somewhat to only support our use case.
@@ -438,125 +40,5 @@ declare interface InstallOptions {
438
40
  *
439
41
  * Vite is MIT licensed, copyright (c) Yuxi (Evan) You and Vite contributors.
440
42
  */
441
- export declare function loadEnv(
442
- mode: string,
443
- envDir: string,
444
- prefixes?: string[],
445
- ): Record<string, string>;
446
-
447
- export declare interface PackageJson {
448
- name: string;
449
- version: string;
450
- scripts?: Record<string, string>;
451
- description?: string;
452
- author?: string;
453
- license?: string;
454
- private?: boolean;
455
- dependencies?: Record<string, string>;
456
- devDependencies?: Record<string, string>;
457
- peerDependencies?: Record<string, string>;
458
- repository?: {
459
- type: string;
460
- url: string;
461
- };
462
- engines?: Record<string, string>;
463
- }
464
-
465
- declare type PackageManager = "npm" | "yarn" | "pnpm" | "bun" | "manual";
466
-
467
- /**
468
- * @beta
469
- */
470
- export declare type ReactCompilerConfig = Partial<PluginOptions>;
471
-
472
- export declare interface ResolvedCliCommand {
473
- command: CliCommandDefinition | CliCommandGroupDefinition;
474
- commandName: string;
475
- parentName?: string;
476
- isGroup: boolean;
477
- isCommand: boolean;
478
- }
479
-
480
- export { SanityClient };
481
-
482
- export declare interface SanityCore {
483
- requiredCliVersionRange: string;
484
- commands: (CliCommandDefinition | CliCommandGroupDefinition)[];
485
- }
486
-
487
- export declare interface SanityJson {
488
- root?: boolean;
489
- project?: {
490
- name?: string;
491
- basePath?: string;
492
- };
493
- api?: CliApiConfig;
494
- __experimental_spaces?: {
495
- name: string;
496
- title: string;
497
- default?: true;
498
- api: {
499
- projectId?: string;
500
- dataset?: string;
501
- };
502
- }[];
503
- plugins?: string[];
504
- parts?: {
505
- name?: string;
506
- path?: string;
507
- implements?: string;
508
- description?: string;
509
- }[];
510
- env?: {
511
- production?: SanityJson;
512
- staging?: SanityJson;
513
- development?: SanityJson;
514
- };
515
- }
516
-
517
- export declare interface SanityModuleInternal {
518
- cliProjectCommands: {
519
- requiredCliVersionRange: string;
520
- commands: (CliCommandDefinition | CliCommandGroupDefinition)[];
521
- };
522
- }
523
-
524
- export declare type SanityUser = {
525
- id: string;
526
- name: string;
527
- email: string;
528
- profileImage?: string;
529
- tosAcceptedAt?: string;
530
- provider: "google" | "github" | "sanity" | `saml-${string}`;
531
- };
532
-
533
- export declare type SinglePrompt =
534
- | (Omit<DistinctQuestion, "name"> & {
535
- type: "list";
536
- choices: ChoiceCollection;
537
- })
538
- | (Omit<DistinctQuestion, "name"> & {
539
- type: "confirm";
540
- })
541
- | (Omit<DistinctQuestion, "name"> & {
542
- type: "input";
543
- });
544
-
545
- export declare interface TelemetryUserProperties {
546
- runtime: string;
547
- runtimeVersion: string;
548
- cliVersion: string;
549
- machinePlatform: string;
550
- cpuArchitecture: string;
551
- projectId?: string;
552
- dataset?: string;
553
- }
554
-
555
- export declare type UserViteConfig =
556
- | InlineConfig
557
- | ((
558
- config: InlineConfig,
559
- env: ConfigEnv,
560
- ) => InlineConfig | Promise<InlineConfig>);
561
-
562
- export {};
43
+ declare function loadEnv(mode: string, envDir: string, prefixes?: string[]): Record<string, string>;
44
+ export { CliApiClient, CliApiConfig, type CliClientOptions, CliCommandAction, CliCommandArguments, CliCommandContext, CliCommandDefinition, CliCommandGroupDefinition, CliCommandRunner, CliConfig, CliOutputter, CliPrompter, CliStubbedYarn, CliUserConfig, CliYarnOptions, CommandRunnerOptions, GraphQLAPIConfig, PackageJson, ReactCompilerConfig, ResolvedCliCommand, type SanityClient, SanityCore, SanityJson, SanityModuleInternal, SanityUser, SinglePrompt, TelemetryUserProperties, UserViteConfig, createCliConfig, defineCliConfig, getCliClient, loadEnv };
package/lib/run.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { };
@@ -1 +1 @@
1
- export {};
1
+ export { };
@@ -1 +1 @@
1
- export {};
1
+ export { };
@@ -1,23 +1,18 @@
1
- import { TypegenWorkerChannel as TypegenWorkerChannel_2 } from "@sanity/codegen";
1
+ import { TypegenWorkerChannel as TypegenWorkerChannel$1 } from "@sanity/codegen";
2
2
  import { WorkerChannel } from "@sanity/worker-channels";
3
-
4
- export declare interface TypegenGenerateTypesWorkerData {
3
+ interface TypegenGenerateTypesWorkerData {
5
4
  workDir: string;
6
5
  schemaPath: string;
7
6
  searchPath: string | string[];
8
7
  overloadClientMethods?: boolean;
9
8
  }
10
-
11
- export declare type TypegenWorkerChannel = WorkerChannel.Definition<
12
- {
13
- loadedSchema: WorkerChannel.Event;
14
- typegenStarted: WorkerChannel.Event<{
15
- expectedFileCount: number;
16
- }>;
17
- typegenComplete: WorkerChannel.Event<{
18
- code: string;
19
- }>;
20
- } & TypegenWorkerChannel_2["__definition"]
21
- >;
22
-
23
- export {};
9
+ type TypegenWorkerChannel = WorkerChannel.Definition<{
10
+ loadedSchema: WorkerChannel.Event;
11
+ typegenStarted: WorkerChannel.Event<{
12
+ expectedFileCount: number;
13
+ }>;
14
+ typegenComplete: WorkerChannel.Event<{
15
+ code: string;
16
+ }>;
17
+ } & TypegenWorkerChannel$1['__definition']>;
18
+ export { TypegenGenerateTypesWorkerData, TypegenWorkerChannel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "5.8.1-next.8+936e9574e1",
3
+ "version": "5.8.1",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "cli",
@@ -46,7 +46,7 @@
46
46
  "@sanity/codegen": "^5.9.1",
47
47
  "@sanity/runtime-cli": "^13.1.0",
48
48
  "@sanity/telemetry": "^0.8.1",
49
- "@sanity/template-validator": "^2.4.5",
49
+ "@sanity/template-validator": "^3.0.0",
50
50
  "@sanity/worker-channels": "^1.1.0",
51
51
  "chalk": "^4.1.2",
52
52
  "debug": "^4.4.3",
@@ -112,11 +112,11 @@
112
112
  "vitest": "^4.0.18",
113
113
  "which": "^2.0.2",
114
114
  "xdg-basedir": "^4.0.0",
115
- "@repo/tsconfig": "5.8.1-next.8+936e9574e1",
116
- "@repo/test-config": "5.8.1-next.8+936e9574e1",
117
- "@repo/package.config": "5.8.1-next.8+936e9574e1",
118
- "@repo/eslint-config": "5.8.1-next.8+936e9574e1",
119
- "@sanity/types": "5.8.0"
115
+ "@repo/package.config": "5.8.1",
116
+ "@repo/eslint-config": "5.8.1",
117
+ "@repo/test-config": "5.8.1",
118
+ "@repo/tsconfig": "5.8.1",
119
+ "@sanity/types": "5.8.1"
120
120
  },
121
121
  "peerDependencies": {
122
122
  "babel-plugin-react-compiler": "*"