@sanity/cli 5.8.1-next.9 → 5.8.2-next.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 };