@sanity/cli-core 0.1.0-alpha.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SanityCommand.js +88 -5
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/request.d.ts +77 -0
- package/dist/_exports/request.js +7 -0
- package/dist/_exports/request.js.map +1 -0
- package/dist/_exports/ux.d.ts +75 -4
- package/dist/_exports/ux.js +2 -1
- package/dist/_exports/ux.js.map +1 -1
- package/dist/config/cli/getCliConfig.js +33 -33
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/getCliConfigSync.js +1 -1
- package/dist/config/cli/getCliConfigSync.js.map +1 -1
- package/dist/config/cli/schemas.js +7 -0
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/findProjectRoot.js +8 -4
- package/dist/config/findProjectRoot.js.map +1 -1
- package/dist/config/findProjectRootSync.js +7 -3
- package/dist/config/findProjectRootSync.js.map +1 -1
- package/dist/config/studio/getStudioConfig.js +0 -3
- package/dist/config/studio/getStudioConfig.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +63 -0
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -0
- package/dist/config/studio/isStudioConfig.js +19 -0
- package/dist/config/studio/isStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.worker.js +8 -34
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/config/util/findStudioConfigPath.js +24 -3
- package/dist/config/util/findStudioConfigPath.js.map +1 -1
- package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -1
- package/dist/errors/NonInteractiveError.js +18 -0
- package/dist/errors/NonInteractiveError.js.map +1 -0
- package/dist/{util → errors}/NotFoundError.js +1 -1
- package/dist/errors/NotFoundError.js.map +1 -0
- package/dist/errors/ProjectRootNotFoundError.js +35 -0
- package/dist/errors/ProjectRootNotFoundError.js.map +1 -0
- package/dist/index.d.ts +1247 -36
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/loaders/studio/studioWorkerLoader.worker.js +102 -23
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/studio/studioWorkerTask.js +55 -34
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js +3 -4
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/tsx/tsxWorkerTask.js +4 -31
- package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -1
- package/dist/request/createRequester.js +83 -0
- package/dist/request/createRequester.js.map +1 -0
- package/dist/services/apiClient.js +8 -4
- package/dist/services/apiClient.js.map +1 -1
- package/dist/services/cliUserConfig.js +5 -5
- package/dist/services/cliUserConfig.js.map +1 -1
- package/dist/services/getCliToken.js +2 -2
- package/dist/services/getCliToken.js.map +1 -1
- package/dist/telemetry/getTelemetryBaseInfo.js +33 -0
- package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -0
- package/dist/telemetry/types.js +5 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/util/doImport.js +2 -1
- package/dist/util/doImport.js.map +1 -1
- package/dist/util/environment/mockBrowserEnvironment.js +1 -0
- package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
- package/dist/util/getCliTelemetry.js +34 -0
- package/dist/util/getCliTelemetry.js.map +1 -0
- package/dist/util/getSanityUrl.js +4 -3
- package/dist/util/getSanityUrl.js.map +1 -1
- package/dist/util/importModule.js +32 -0
- package/dist/util/importModule.js.map +1 -0
- package/dist/util/isInteractive.js +1 -1
- package/dist/util/isInteractive.js.map +1 -1
- package/dist/util/isStaging.js +10 -0
- package/dist/util/isStaging.js.map +1 -0
- package/dist/util/normalizePath.js +12 -0
- package/dist/util/normalizePath.js.map +1 -0
- package/dist/util/promisifyWorker.js +72 -0
- package/dist/util/promisifyWorker.js.map +1 -0
- package/dist/util/readNDJSON.js +18 -0
- package/dist/util/readNDJSON.js.map +1 -0
- package/dist/util/readPackageJson.js +74 -0
- package/dist/util/readPackageJson.js.map +1 -0
- package/dist/ux/boxen.js +3 -0
- package/dist/ux/boxen.js.map +1 -0
- package/dist/ux/colorizeJson.js +6 -6
- package/dist/ux/colorizeJson.js.map +1 -1
- package/dist/ux/prompts.js +49 -1
- package/dist/ux/prompts.js.map +1 -1
- package/package.json +39 -31
- package/dist/SanityCommand.d.ts +0 -78
- package/dist/_exports/tree.d.ts +0 -1
- package/dist/_exports/tree.js +0 -3
- package/dist/_exports/tree.js.map +0 -1
- package/dist/config/cli/getCliConfig.d.ts +0 -16
- package/dist/config/cli/getCliConfig.worker.d.ts +0 -1
- package/dist/config/cli/getCliConfig.worker.js +0 -15
- package/dist/config/cli/getCliConfig.worker.js.map +0 -1
- package/dist/config/cli/getCliConfigSync.d.ts +0 -12
- package/dist/config/cli/schemas.d.ts +0 -104
- package/dist/config/cli/types/cliConfig.d.ts +0 -83
- package/dist/config/cli/types/userViteConfig.d.ts +0 -5
- package/dist/config/findProjectRoot.d.ts +0 -14
- package/dist/config/findProjectRootSync.d.ts +0 -27
- package/dist/config/studio/getStudioConfig.d.ts +0 -14
- package/dist/config/studio/readStudioConfig.d.ts +0 -96
- package/dist/config/studio/readStudioConfig.worker.d.ts +0 -1
- package/dist/config/util/configPathsSync.d.ts +0 -17
- package/dist/config/util/findAppConfigPath.d.ts +0 -8
- package/dist/config/util/findConfigsPaths.d.ts +0 -16
- package/dist/config/util/findStudioConfigPath.d.ts +0 -9
- package/dist/config/util/isSanityV2StudioRoot.d.ts +0 -8
- package/dist/config/util/recursivelyResolveProjectRoot.d.ts +0 -27
- package/dist/debug.d.ts +0 -15
- package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +0 -1
- package/dist/loaders/studio/studioWorkerTask.d.ts +0 -40
- package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +0 -1
- package/dist/loaders/tsx/tsxWorkerTask.d.ts +0 -28
- package/dist/services/apiClient.d.ts +0 -53
- package/dist/services/cliUserConfig.d.ts +0 -40
- package/dist/services/getCliToken.d.ts +0 -7
- package/dist/types.d.ts +0 -15
- package/dist/util/NotFoundError.d.ts +0 -20
- package/dist/util/NotFoundError.js.map +0 -1
- package/dist/util/createExpiringConfig.d.ts +0 -37
- package/dist/util/createExpiringConfig.js +0 -60
- package/dist/util/createExpiringConfig.js.map +0 -1
- package/dist/util/doImport.d.ts +0 -7
- package/dist/util/environment/getStudioEnvironmentVariables.d.ts +0 -12
- package/dist/util/environment/mockBrowserEnvironment.d.ts +0 -17
- package/dist/util/environment/setupBrowserStubs.d.ts +0 -10
- package/dist/util/environment/stubs.d.ts +0 -254
- package/dist/util/fileExists.d.ts +0 -9
- package/dist/util/generateHelpUrl.d.ts +0 -8
- package/dist/util/getEmptyAuth.d.ts +0 -5
- package/dist/util/getSanityEnvVar.d.ts +0 -19
- package/dist/util/getSanityUrl.d.ts +0 -5
- package/dist/util/getUserConfig.d.ts +0 -2
- package/dist/util/isCi.d.ts +0 -1
- package/dist/util/isInteractive.d.ts +0 -1
- package/dist/util/isRecord.d.ts +0 -8
- package/dist/util/isTrueish.d.ts +0 -1
- package/dist/util/parseStringFlag.d.ts +0 -10
- package/dist/util/parseStringFlag.js +0 -19
- package/dist/util/parseStringFlag.js.map +0 -1
- package/dist/util/readJsonFile.d.ts +0 -14
- package/dist/util/resolveLocalPackage.d.ts +0 -18
- package/dist/util/safeStructuredClone.d.ts +0 -8
- package/dist/util/tree.d.ts +0 -31
- package/dist/util/tree.js +0 -108
- package/dist/util/tree.js.map +0 -1
- package/dist/util/tryGetDefaultExport.d.ts +0 -5
- package/dist/util/writeJsonFile.d.ts +0 -9
- package/dist/ux/chalk.d.ts +0 -2
- package/dist/ux/chalk.js +0 -4
- package/dist/ux/chalk.js.map +0 -1
- package/dist/ux/colorizeJson.d.ts +0 -1
- package/dist/ux/formatObject.d.ts +0 -1
- package/dist/ux/formatObject.js +0 -9
- package/dist/ux/formatObject.js.map +0 -1
- package/dist/ux/logSymbols.d.ts +0 -1
- package/dist/ux/printKeyValue.d.ts +0 -1
- package/dist/ux/printKeyValue.js +0 -16
- package/dist/ux/printKeyValue.js.map +0 -1
- package/dist/ux/prompts.d.ts +0 -1
- package/dist/ux/spinner.d.ts +0 -1
- package/dist/ux/timer.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,1247 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import {ClientConfig} from '@sanity/client'
|
|
2
|
+
import {CLIError} from '@oclif/core/errors'
|
|
3
|
+
import {Command} from '@oclif/core'
|
|
4
|
+
import {ConfigEnv} from 'vite'
|
|
5
|
+
import ConfigStore from 'configstore'
|
|
6
|
+
import {ConsentStatus} from '@sanity/telemetry'
|
|
7
|
+
import debugIt from 'debug'
|
|
8
|
+
import {InlineConfig} from 'vite'
|
|
9
|
+
import {Interfaces} from '@oclif/core'
|
|
10
|
+
import {PluginOptions} from 'babel-plugin-react-compiler'
|
|
11
|
+
import {SanityClient} from '@sanity/client'
|
|
12
|
+
import {TelemetryLogger} from '@sanity/telemetry'
|
|
13
|
+
import {URL as URL_2} from 'node:url'
|
|
14
|
+
import {Worker as Worker_2} from 'node:worker_threads'
|
|
15
|
+
import {WorkerOptions as WorkerOptions_2} from 'node:worker_threads'
|
|
16
|
+
import {Workspace} from 'sanity'
|
|
17
|
+
import * as z from 'zod'
|
|
18
|
+
import {z as z_2} from 'zod'
|
|
19
|
+
|
|
20
|
+
declare type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Clears the global CLI telemetry store.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearCliTelemetry(): void
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
* Symbol used to store the CLI telemetry store on globalThis.
|
|
31
|
+
* Use `getCliTelemetry()` to access the store instead of accessing this directly.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CLI_TELEMETRY_SYMBOL: unique symbol
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare interface CliConfig {
|
|
39
|
+
/** The project ID and dataset the Sanity CLI should use to run its commands */
|
|
40
|
+
api?: {
|
|
41
|
+
dataset?: string
|
|
42
|
+
projectId?: string
|
|
43
|
+
}
|
|
44
|
+
/** Configuration for custom Sanity apps built with the App SDK */
|
|
45
|
+
app?: {
|
|
46
|
+
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
47
|
+
entry?: string
|
|
48
|
+
/** String encoding of an icon (typically an SVG) */
|
|
49
|
+
icon?: string
|
|
50
|
+
/** @deprecated Use deployment.appId */
|
|
51
|
+
id?: string
|
|
52
|
+
/** The ID for the Sanity organization that manages this application */
|
|
53
|
+
organizationId?: string
|
|
54
|
+
/** The title of the custom app. Used in Dashboard and in the browser tab */
|
|
55
|
+
title?: string
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated Use deployment.autoUpdates */
|
|
58
|
+
autoUpdates?: boolean
|
|
59
|
+
/** Options for custom app and Studio deployments */
|
|
60
|
+
deployment?: {
|
|
61
|
+
/**
|
|
62
|
+
* The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.
|
|
63
|
+
* Get your app ID by either:
|
|
64
|
+
* 1. Checking the output of `sanity deploy`, or
|
|
65
|
+
* 2. Checking your project’s Studio tab at https://sanity.io/manage
|
|
66
|
+
*
|
|
67
|
+
* @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.
|
|
68
|
+
* {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}
|
|
69
|
+
*/
|
|
70
|
+
appId?: string
|
|
71
|
+
/**
|
|
72
|
+
* Enable automatic updates for your Studio or custom app’s Sanity dependencies.
|
|
73
|
+
* {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}
|
|
74
|
+
*/
|
|
75
|
+
autoUpdates?: boolean
|
|
76
|
+
}
|
|
77
|
+
/** Define the GraphQL APIs that the CLI can deploy and interact with */
|
|
78
|
+
graphql?: Array<{
|
|
79
|
+
filterSuffix?: string
|
|
80
|
+
generation?: 'gen1' | 'gen2' | 'gen3'
|
|
81
|
+
id?: string
|
|
82
|
+
nonNullDocumentFields?: boolean
|
|
83
|
+
playground?: boolean
|
|
84
|
+
source?: string
|
|
85
|
+
tag?: string
|
|
86
|
+
workspace?: string
|
|
87
|
+
}>
|
|
88
|
+
/** Configuration for the Media Library */
|
|
89
|
+
mediaLibrary?: {
|
|
90
|
+
/** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */
|
|
91
|
+
aspectsPath?: string
|
|
92
|
+
}
|
|
93
|
+
/** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */
|
|
94
|
+
project?: {
|
|
95
|
+
basePath?: string
|
|
96
|
+
}
|
|
97
|
+
/** Configuration options for React Compiler */
|
|
98
|
+
reactCompiler?: PluginOptions
|
|
99
|
+
/** Wraps the Studio in \<React.StrictMode\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE="true"|"false". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to false. */
|
|
100
|
+
reactStrictMode?: boolean
|
|
101
|
+
/**
|
|
102
|
+
* Configuration for schema extraction (`sanity schema extract`)
|
|
103
|
+
*/
|
|
104
|
+
schemaExtraction?: {
|
|
105
|
+
/**
|
|
106
|
+
* Enable schema extraction as part of sanity dev and sanity build
|
|
107
|
+
*/
|
|
108
|
+
enabled?: boolean
|
|
109
|
+
/**
|
|
110
|
+
* When true, schema fields marked as required will be non-optional in the output.
|
|
111
|
+
* Defaults to `false`
|
|
112
|
+
*/
|
|
113
|
+
enforceRequiredFields?: boolean
|
|
114
|
+
/**
|
|
115
|
+
* Output path for the extracted schema file.
|
|
116
|
+
* Defaults to `schema.json` in the working directory.
|
|
117
|
+
*/
|
|
118
|
+
path?: string
|
|
119
|
+
/**
|
|
120
|
+
* Additional glob patterns to watch for schema changes in watch mode.
|
|
121
|
+
* These extend the default patterns:
|
|
122
|
+
* - `sanity.config.{js,jsx,ts,tsx,mjs}`
|
|
123
|
+
* - `schema*\/**\/*.{js,jsx,ts,tsx,mjs}`
|
|
124
|
+
*/
|
|
125
|
+
watchPatterns?: string[]
|
|
126
|
+
/**
|
|
127
|
+
* The name of the workspace to generate a schema for. Required if your Sanity project has more than one
|
|
128
|
+
* workspace.
|
|
129
|
+
*/
|
|
130
|
+
workspace?: string
|
|
131
|
+
}
|
|
132
|
+
/** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */
|
|
133
|
+
server?: {
|
|
134
|
+
hostname?: string
|
|
135
|
+
port?: number
|
|
136
|
+
}
|
|
137
|
+
/** @deprecated Use deployment.appId */
|
|
138
|
+
studioHost?: string
|
|
139
|
+
/**
|
|
140
|
+
* Configuration for Sanity typegen
|
|
141
|
+
*/
|
|
142
|
+
typegen?: Partial<TypeGenConfig> & {
|
|
143
|
+
/**
|
|
144
|
+
* Enable typegen as part of sanity dev and sanity build.
|
|
145
|
+
* When enabled, types are generated on startup and when files change.
|
|
146
|
+
* Defaults to `false`
|
|
147
|
+
*/
|
|
148
|
+
enabled?: boolean
|
|
149
|
+
}
|
|
150
|
+
/** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */
|
|
151
|
+
vite?: UserViteConfig
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare type CLITelemetryStore = TelemetryLogger<TelemetryUserProperties>
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The CLI user configuration schema.
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
declare type CliUserConfig = z_2.infer<z_2.ZodObject<typeof cliUserConfigSchema>>
|
|
165
|
+
|
|
166
|
+
declare const cliUserConfigSchema: {
|
|
167
|
+
authToken: z_2.ZodOptional<z_2.ZodString>
|
|
168
|
+
telemetryConsent: z_2.ZodOptional<
|
|
169
|
+
z_2.ZodObject<
|
|
170
|
+
{
|
|
171
|
+
updatedAt: z_2.ZodOptional<z_2.ZodNumber>
|
|
172
|
+
value: z_2.ZodObject<
|
|
173
|
+
{
|
|
174
|
+
status: z_2.ZodEnum<{
|
|
175
|
+
undetermined: 'undetermined'
|
|
176
|
+
unset: 'unset'
|
|
177
|
+
granted: 'granted'
|
|
178
|
+
denied: 'denied'
|
|
179
|
+
}>
|
|
180
|
+
type: z_2.ZodString
|
|
181
|
+
},
|
|
182
|
+
z_2.core.$loose
|
|
183
|
+
>
|
|
184
|
+
},
|
|
185
|
+
z_2.core.$strip
|
|
186
|
+
>
|
|
187
|
+
>
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export declare function colorizeJson(input: unknown): string
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
declare const configDefinition: z.ZodObject<
|
|
196
|
+
{
|
|
197
|
+
formatGeneratedCode: z.ZodDefault<z.ZodBoolean>
|
|
198
|
+
generates: z.ZodDefault<z.ZodString>
|
|
199
|
+
overloadClientMethods: z.ZodDefault<z.ZodBoolean>
|
|
200
|
+
path: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString>]>>
|
|
201
|
+
schema: z.ZodDefault<z.ZodString>
|
|
202
|
+
},
|
|
203
|
+
z.core.$strip
|
|
204
|
+
>
|
|
205
|
+
|
|
206
|
+
export declare type ConsentInformation =
|
|
207
|
+
| {
|
|
208
|
+
reason: 'fetchError' | 'unauthenticated'
|
|
209
|
+
status: Extract<ConsentStatus, 'undetermined'>
|
|
210
|
+
}
|
|
211
|
+
| {
|
|
212
|
+
reason?: 'localOverride'
|
|
213
|
+
status: Extract<ConsentStatus, 'denied'>
|
|
214
|
+
}
|
|
215
|
+
| {
|
|
216
|
+
reason?: never
|
|
217
|
+
status: Extract<ConsentStatus, 'granted'>
|
|
218
|
+
}
|
|
219
|
+
| {
|
|
220
|
+
reason?: never
|
|
221
|
+
status: Extract<ConsentStatus, 'unset'>
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Creates a new worker for a studio worker task.
|
|
226
|
+
*
|
|
227
|
+
* This uses a combination of vite for "bundling" + jsdom for emulating a browser
|
|
228
|
+
* environment under the hood, which means that the same thing that will work in vite
|
|
229
|
+
* _should_ work in the worker - to a degree. If the user has defined any typescript
|
|
230
|
+
* path aliases, these will have to be added as aliases to the vite config - the same
|
|
231
|
+
* behavior as you would see with regular vite. Other things that are accounted for:
|
|
232
|
+
*
|
|
233
|
+
* - TypeScript support (+JSX, enums and other "compilation needed" features)
|
|
234
|
+
* - CSS, font and other file imports will resolve to a file path
|
|
235
|
+
* - CSS module imports will resolve to a javascript object of class names
|
|
236
|
+
* - Environment variables are available both as `import.meta.env` and `process.env`,
|
|
237
|
+
* and `.env` files are loaded in the same way that they would in a Sanity studio.
|
|
238
|
+
* - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
|
|
239
|
+
* are defined directly to the Node environment as globals. While this polutes the
|
|
240
|
+
* global namespace, it is done only in the worker thread.
|
|
241
|
+
* - Certain browser globals that are _not_ available in JSDOM are also provided to the
|
|
242
|
+
* global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
|
|
243
|
+
* These are provided with a minimal stub implementation to make them not crash.
|
|
244
|
+
*
|
|
245
|
+
* @param filePath - Path to the worker file (`.ts` works and is encouraged)
|
|
246
|
+
* @param options - Options to pass to the worker
|
|
247
|
+
* @returns A promise that resolves with the message from the worker
|
|
248
|
+
* @throws If the file does not exist
|
|
249
|
+
* @throws If the worker exits with a non-zero code
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
export declare function createStudioWorker(
|
|
253
|
+
filePath: URL,
|
|
254
|
+
options: StudioWorkerTaskOptions,
|
|
255
|
+
): Worker_2
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* `debug` instance for the CLI
|
|
259
|
+
*
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
262
|
+
declare const debug_2: debugIt.Debugger
|
|
263
|
+
export {debug_2 as debug}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* This function is a replacement for built in dynamic import
|
|
267
|
+
* This handles the case for windows file paths especially for absolute paths.
|
|
268
|
+
*
|
|
269
|
+
* @param source - File path
|
|
270
|
+
*/
|
|
271
|
+
export declare function doImport(source: string): Promise<any>
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Finds the path for a given set of files.
|
|
275
|
+
*
|
|
276
|
+
* @param basePath - The base path to search for files.
|
|
277
|
+
* @param files - The files to search for.
|
|
278
|
+
* @internal
|
|
279
|
+
*/
|
|
280
|
+
export declare function findPathForFiles(basePath: string, files: string[]): Promise<PathResult[]>
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Resolve project root directory and type.
|
|
284
|
+
*
|
|
285
|
+
* Project root is:
|
|
286
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
287
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
288
|
+
*
|
|
289
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
290
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
291
|
+
*
|
|
292
|
+
* @internal
|
|
293
|
+
*/
|
|
294
|
+
export declare function findProjectRoot(cwd: string): Promise<ProjectRootResult>
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Resolve project root directory and type synchronously.
|
|
298
|
+
*
|
|
299
|
+
* Project root is:
|
|
300
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
301
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
302
|
+
*
|
|
303
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
304
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
305
|
+
*
|
|
306
|
+
* @param cwd - Current working directory to start searching from
|
|
307
|
+
* @returns Project root result
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
export declare function findProjectRootSync(cwd: string): ProjectRootResult
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Resolves to a string containing the found config path, otherwise throws an error.
|
|
314
|
+
* Also throws if Sanity v2 studio root is found.
|
|
315
|
+
*
|
|
316
|
+
* @param basePath - The base path to start searching from
|
|
317
|
+
* @returns A promise that resolves to a string containing the found config path
|
|
318
|
+
* @throws On multiple config files found, if v2 studio root found, or no config found
|
|
319
|
+
* @internal
|
|
320
|
+
*/
|
|
321
|
+
export declare function findStudioConfigPath(basePath: string): Promise<string>
|
|
322
|
+
|
|
323
|
+
declare type Flags<T extends typeof Command> = Interfaces.InferredFlags<
|
|
324
|
+
(typeof SanityCommand)['baseFlags'] & T['flags']
|
|
325
|
+
>
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Get the CLI config for a project, given the root path.
|
|
329
|
+
*
|
|
330
|
+
* Results are cached in-memory keyed by rootPath for the lifetime of the
|
|
331
|
+
* process. Since the CLI always runs from a single project root, the config
|
|
332
|
+
* won't change during a command's execution, so caching avoids redundant
|
|
333
|
+
* filesystem reads and jiti imports from the prerun hook, SanityCommand
|
|
334
|
+
* helpers, and action files.
|
|
335
|
+
*
|
|
336
|
+
* If loading fails the cached promise is evicted so the next call retries.
|
|
337
|
+
*
|
|
338
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
339
|
+
* @returns The CLI config
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
|
+
export declare function getCliConfig(rootPath: string): Promise<CliConfig>
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Get the CLI config for a project synchronously, given the root path.
|
|
346
|
+
*
|
|
347
|
+
* This loads the CLI config in the main thread using tsx/register for TypeScript support.
|
|
348
|
+
* Note: This is a synchronous operation and does not use worker threads like the async version.
|
|
349
|
+
*
|
|
350
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
351
|
+
* @returns The CLI config
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
export declare function getCliConfigSync(rootPath: string): CliConfig
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
export declare function getCliTelemetry(): CLITelemetryStore
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Get the CLI authentication token from the environment or the config file
|
|
363
|
+
*
|
|
364
|
+
* @returns A promise that resolves to a CLI token, or undefined if no token is found
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
export declare function getCliToken(): Promise<string | undefined>
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Get the config value for the given property
|
|
371
|
+
*
|
|
372
|
+
* @param prop - The property to get the value for
|
|
373
|
+
* @returns The value of the given property
|
|
374
|
+
* @internal
|
|
375
|
+
*/
|
|
376
|
+
export declare function getCliUserConfig<P extends keyof CliUserConfig>(
|
|
377
|
+
prop: P,
|
|
378
|
+
): Promise<CliUserConfig[P]>
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Create a "global" (unscoped) Sanity API client.
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
*
|
|
385
|
+
* @param options - The options to use for the client.
|
|
386
|
+
* @returns Promise that resolves to a configured Sanity API client.
|
|
387
|
+
*/
|
|
388
|
+
export declare function getGlobalCliClient({
|
|
389
|
+
requireUser,
|
|
390
|
+
token: providedToken,
|
|
391
|
+
unauthenticated,
|
|
392
|
+
...config
|
|
393
|
+
}: GlobalCliClientOptions): Promise<SanityClient>
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Create a "project" (scoped) Sanity API client.
|
|
397
|
+
*
|
|
398
|
+
* @public
|
|
399
|
+
*
|
|
400
|
+
* @param options - The options to use for the client.
|
|
401
|
+
* @returns Promise that resolves to a configured Sanity API client.
|
|
402
|
+
*/
|
|
403
|
+
export declare function getProjectCliClient({
|
|
404
|
+
requireUser,
|
|
405
|
+
token: providedToken,
|
|
406
|
+
...config
|
|
407
|
+
}: ProjectCliClientOptions): Promise<SanityClient>
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Gets an environment variable with the appropriate Sanity prefix based on whether it's an app or studio.
|
|
411
|
+
*
|
|
412
|
+
* @param suffix - The suffix for the environment variable (e.g., 'SERVER_HOSTNAME')
|
|
413
|
+
* @param isApp - Whether to use the app prefix (SANITY_APP_) or studio prefix (SANITY_STUDIO_)
|
|
414
|
+
* @returns The value of the environment variable, or undefined if not set
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* // For studio: SANITY_STUDIO_SERVER_HOSTNAME
|
|
419
|
+
* const studioHostname = getSanityEnvVar('SERVER_HOSTNAME', false)
|
|
420
|
+
*
|
|
421
|
+
* // For app: SANITY_APP_SERVER_HOSTNAME
|
|
422
|
+
* const appHostname = getSanityEnvVar('SERVER_HOSTNAME', true)
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @internal
|
|
426
|
+
*/
|
|
427
|
+
export declare function getSanityEnvVar(suffix: string, isApp: boolean): string | undefined
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @internal
|
|
431
|
+
* @returns The Sanity URL for the given path, using the correct domain based on the environment
|
|
432
|
+
*/
|
|
433
|
+
export declare function getSanityUrl(path?: string): string
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Get the studio config for a project, given the root path.
|
|
437
|
+
*
|
|
438
|
+
* @param rootPath - The root path for the project
|
|
439
|
+
* @returns The studio config (some properties may be missing)
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare function getStudioConfig(
|
|
443
|
+
rootPath: string,
|
|
444
|
+
options: {
|
|
445
|
+
resolvePlugins: true
|
|
446
|
+
},
|
|
447
|
+
): Promise<ResolvedStudioConfig>
|
|
448
|
+
|
|
449
|
+
export declare function getStudioConfig(
|
|
450
|
+
rootPath: string,
|
|
451
|
+
options: {
|
|
452
|
+
resolvePlugins: false
|
|
453
|
+
},
|
|
454
|
+
): Promise<RawStudioConfig>
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Resolves the workspaces from the studio config.
|
|
458
|
+
*
|
|
459
|
+
* NOTE: This function should only be called from a worker thread.
|
|
460
|
+
*
|
|
461
|
+
* @param configPath - The path to the studio config
|
|
462
|
+
* @returns The workspaces
|
|
463
|
+
* @internal
|
|
464
|
+
*/
|
|
465
|
+
export declare function getStudioWorkspaces(configPath: string): Promise<Workspace[]>
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Gets the base telemetry information needed for file operations.
|
|
469
|
+
*
|
|
470
|
+
* This shared utility extracts common logic used by:
|
|
471
|
+
* - `generateTelemetryFilePath` - for generating session-specific file paths
|
|
472
|
+
* - `findTelemetryFiles` - for discovering all telemetry files via glob patterns
|
|
473
|
+
*
|
|
474
|
+
* @returns Promise resolving to base telemetry information
|
|
475
|
+
* @throws Error if no auth token is found
|
|
476
|
+
* @internal
|
|
477
|
+
*/
|
|
478
|
+
export declare function getTelemetryBaseInfo(): Promise<TelemetryBaseInfo>
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Starts a terminal timer
|
|
482
|
+
*
|
|
483
|
+
* @internal
|
|
484
|
+
*/
|
|
485
|
+
export declare function getTimer(): TimeMeasurer
|
|
486
|
+
|
|
487
|
+
export declare const getUserConfig: () => ConfigStore
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* @public
|
|
491
|
+
*/
|
|
492
|
+
export declare interface GlobalCliClientOptions extends ClientConfig {
|
|
493
|
+
/**
|
|
494
|
+
* The API version to use for this client.
|
|
495
|
+
*/
|
|
496
|
+
apiVersion: string
|
|
497
|
+
/**
|
|
498
|
+
* Whether to require a user to be authenticated to use this client.
|
|
499
|
+
* Default: `false`.
|
|
500
|
+
* Throws an error if `true` and user is not authenticated.
|
|
501
|
+
*/
|
|
502
|
+
requireUser?: boolean
|
|
503
|
+
/**
|
|
504
|
+
* Whether to skip reading the stored CLI token. When `true`, the client will
|
|
505
|
+
* have no token unless one is explicitly provided.
|
|
506
|
+
* Default: `false`.
|
|
507
|
+
*/
|
|
508
|
+
unauthenticated?: boolean
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Imports a module using jiti and returns its exports.
|
|
513
|
+
* This is a thin wrapper around tsx to allow swapping out the underlying implementation in the future if needed.
|
|
514
|
+
*
|
|
515
|
+
* @param filePath - Path to the module to import.
|
|
516
|
+
* @param options - Options for the importModule function.
|
|
517
|
+
* @returns The exported module.
|
|
518
|
+
*
|
|
519
|
+
* @internal
|
|
520
|
+
*/
|
|
521
|
+
export declare function importModule<T = unknown>(
|
|
522
|
+
filePath: string | URL,
|
|
523
|
+
options?: ImportModuleOptions,
|
|
524
|
+
): Promise<T>
|
|
525
|
+
|
|
526
|
+
declare interface ImportModuleOptions {
|
|
527
|
+
/**
|
|
528
|
+
* Whether to return the default export of the module.
|
|
529
|
+
* Default: true
|
|
530
|
+
*/
|
|
531
|
+
default?: boolean
|
|
532
|
+
/**
|
|
533
|
+
* Path to the tsconfig file to use for the import. If not provided, the tsconfig
|
|
534
|
+
* will be inferred from the nearest `tsconfig.json` file.
|
|
535
|
+
*/
|
|
536
|
+
tsconfigPath?: string
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export declare const isCi: () => boolean
|
|
540
|
+
|
|
541
|
+
export declare function isInteractive(): boolean
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Returns whether or not the given error is a `NotFoundError`
|
|
545
|
+
*
|
|
546
|
+
* @param err - The error to check
|
|
547
|
+
* @returns `true` if the error is a `NotFoundError`, `false` otherwise
|
|
548
|
+
* @internal
|
|
549
|
+
*/
|
|
550
|
+
export declare function isNotFoundError(err: unknown): err is NotFoundError
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Returns whether or not the given error is a `ProjectRootNotFoundError`
|
|
554
|
+
*
|
|
555
|
+
* @param err - The error to check
|
|
556
|
+
* @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise
|
|
557
|
+
* @internal
|
|
558
|
+
*/
|
|
559
|
+
export declare function isProjectRootNotFoundError(err: unknown): err is ProjectRootNotFoundError
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Checks if the environment is staging.
|
|
563
|
+
*
|
|
564
|
+
* @returns True if the environment is staging, false otherwise
|
|
565
|
+
* @internal
|
|
566
|
+
*/
|
|
567
|
+
export declare function isStaging(): boolean
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Checks if the given value conforms to a minimum studio config shape.
|
|
571
|
+
*
|
|
572
|
+
* @param value - The value to check
|
|
573
|
+
* @returns Whether the value is a studio config
|
|
574
|
+
* @internal
|
|
575
|
+
*/
|
|
576
|
+
export declare function isStudioConfig(value: unknown): boolean
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Mocks a browser-like environment for processes in the main thread by:
|
|
580
|
+
* - Injecting browser globals (window, document, ResizeObserver, etc.)
|
|
581
|
+
* - Loading studio environment variables from the project's sanity installation into process.env
|
|
582
|
+
*
|
|
583
|
+
* This is useful for commands like `sanity exec` that have to run user scripts
|
|
584
|
+
* in the main thread of the process (but in a child process).
|
|
585
|
+
*
|
|
586
|
+
* Be cautious when using this, since it will pollute the global namespace with browser globals.
|
|
587
|
+
*
|
|
588
|
+
* If your code can run in a worker thread, you should use the `studioWorkerTask` function instead.
|
|
589
|
+
*
|
|
590
|
+
* @param basePath - The root path of the Sanity Studio project
|
|
591
|
+
* @returns A cleanup function that removes the injected globals and environment variables
|
|
592
|
+
* @internal
|
|
593
|
+
*/
|
|
594
|
+
export declare function mockBrowserEnvironment(basePath: string): Promise<() => void>
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Error thrown when a prompt is attempted in a non-interactive environment
|
|
598
|
+
* (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error
|
|
599
|
+
* to provide appropriate fallback behavior.
|
|
600
|
+
*
|
|
601
|
+
* Extends `CLIError` to suppress stack traces in user-facing output.
|
|
602
|
+
*/
|
|
603
|
+
export declare class NonInteractiveError extends CLIError {
|
|
604
|
+
constructor(promptName: string)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Normalizes a path for cross-platform comparison by converting backslashes to forward slashes.
|
|
609
|
+
* Useful for converting windows paths to unix paths.
|
|
610
|
+
*
|
|
611
|
+
* @param path - Path to normalize
|
|
612
|
+
* @returns Normalized path with forward slashes
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
export declare function normalizePath(path: string): string
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Error thrown when a file or directory is not found
|
|
619
|
+
*
|
|
620
|
+
* `code` is always `ENOENT` to mirror Node.js behavior when a file is not found
|
|
621
|
+
*
|
|
622
|
+
* @internal
|
|
623
|
+
*/
|
|
624
|
+
export declare class NotFoundError extends Error {
|
|
625
|
+
code: string
|
|
626
|
+
path?: string
|
|
627
|
+
constructor(message: string, path?: string)
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export declare interface Output {
|
|
631
|
+
error: Command['error']
|
|
632
|
+
log: Command['log']
|
|
633
|
+
warn: Command['warn']
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Comprehensive representation of a package.json file.
|
|
638
|
+
* Consolidates all properties from previous type definitions.
|
|
639
|
+
*
|
|
640
|
+
* @public
|
|
641
|
+
*/
|
|
642
|
+
export declare type PackageJson = z_2.infer<typeof packageJsonSchema>
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Comprehensive package.json schema including all common properties.
|
|
646
|
+
* Feel free to add properties to this,
|
|
647
|
+
* 🟠ℹ️ BUT ENSURE OPTIONAL STUFF IS ACTUALLY OPTIONAL ℹ️🟠
|
|
648
|
+
* 🟠ℹ️ SINCE THIS IS USED IN A NUMBER OF LOCATIONS WHERE ℹ️🟠
|
|
649
|
+
* 🟠ℹ️ WE CANNOT ENFORCE/GUARANTEE ANY PARTICULAR PROPS ℹ️🟠
|
|
650
|
+
*/
|
|
651
|
+
declare const packageJsonSchema: z_2.ZodObject<
|
|
652
|
+
{
|
|
653
|
+
name: z_2.ZodString
|
|
654
|
+
version: z_2.ZodString
|
|
655
|
+
dependencies: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodString>>
|
|
656
|
+
devDependencies: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodString>>
|
|
657
|
+
peerDependencies: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodString>>
|
|
658
|
+
exports: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodAny>>
|
|
659
|
+
main: z_2.ZodOptional<z_2.ZodString>
|
|
660
|
+
types: z_2.ZodOptional<z_2.ZodString>
|
|
661
|
+
author: z_2.ZodOptional<z_2.ZodString>
|
|
662
|
+
description: z_2.ZodOptional<z_2.ZodString>
|
|
663
|
+
engines: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodString>>
|
|
664
|
+
license: z_2.ZodOptional<z_2.ZodString>
|
|
665
|
+
private: z_2.ZodOptional<z_2.ZodBoolean>
|
|
666
|
+
repository: z_2.ZodOptional<
|
|
667
|
+
z_2.ZodObject<
|
|
668
|
+
{
|
|
669
|
+
type: z_2.ZodString
|
|
670
|
+
url: z_2.ZodString
|
|
671
|
+
},
|
|
672
|
+
z_2.core.$strip
|
|
673
|
+
>
|
|
674
|
+
>
|
|
675
|
+
scripts: z_2.ZodOptional<z_2.ZodRecord<z_2.ZodString, z_2.ZodString>>
|
|
676
|
+
type: z_2.ZodOptional<
|
|
677
|
+
z_2.ZodEnum<{
|
|
678
|
+
module: 'module'
|
|
679
|
+
commonjs: 'commonjs'
|
|
680
|
+
}>
|
|
681
|
+
>
|
|
682
|
+
},
|
|
683
|
+
z_2.core.$loose
|
|
684
|
+
>
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @internal
|
|
688
|
+
*/
|
|
689
|
+
declare interface PathResult {
|
|
690
|
+
exists: boolean
|
|
691
|
+
path: string
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* @public
|
|
696
|
+
*/
|
|
697
|
+
export declare interface ProjectCliClientOptions extends ClientConfig {
|
|
698
|
+
/**
|
|
699
|
+
* The API version to use for this client.
|
|
700
|
+
*/
|
|
701
|
+
apiVersion: string
|
|
702
|
+
/**
|
|
703
|
+
* The project ID to use for this client.
|
|
704
|
+
*/
|
|
705
|
+
projectId: string
|
|
706
|
+
/**
|
|
707
|
+
* The dataset to use for this client.
|
|
708
|
+
*/
|
|
709
|
+
dataset?: string
|
|
710
|
+
/**
|
|
711
|
+
* Whether to require a user to be authenticated to use this client.
|
|
712
|
+
* Default: `false`.
|
|
713
|
+
* Throws an error if `true` and user is not authenticated.
|
|
714
|
+
*/
|
|
715
|
+
requireUser?: boolean
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Error thrown when a project root directory cannot be found.
|
|
720
|
+
*
|
|
721
|
+
* This occurs when the CLI is run outside a Sanity project directory
|
|
722
|
+
* (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).
|
|
723
|
+
*
|
|
724
|
+
* Extends `CLIError` to suppress stack traces in user-facing output.
|
|
725
|
+
*
|
|
726
|
+
* @internal
|
|
727
|
+
*/
|
|
728
|
+
export declare class ProjectRootNotFoundError extends CLIError {
|
|
729
|
+
constructor(
|
|
730
|
+
message: string,
|
|
731
|
+
options?: {
|
|
732
|
+
cause?: Error
|
|
733
|
+
suggestions?: string[]
|
|
734
|
+
},
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Result of finding a project configuration
|
|
740
|
+
*
|
|
741
|
+
* @public
|
|
742
|
+
*/
|
|
743
|
+
export declare interface ProjectRootResult {
|
|
744
|
+
directory: string
|
|
745
|
+
/**
|
|
746
|
+
* Path to the project configuration file, if found.
|
|
747
|
+
*/
|
|
748
|
+
path: string
|
|
749
|
+
/**
|
|
750
|
+
* Type of project root.
|
|
751
|
+
*/
|
|
752
|
+
type: 'app' | 'studio'
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Creates a Node.js Worker from the given file path and options, and wraps it
|
|
757
|
+
* in a Promise that resolves with the first message the worker sends, and
|
|
758
|
+
* rejects on error, message deserialization failure, or non-zero exit code.
|
|
759
|
+
* The worker is terminated after a message or error is received.
|
|
760
|
+
*
|
|
761
|
+
* @param filePath - URL to the worker file
|
|
762
|
+
* @param options - Options to pass to the Worker constructor
|
|
763
|
+
* @returns A promise that resolves with the first message from the worker
|
|
764
|
+
* @throws If the worker emits an error, a message deserialization error, or exits with a non-zero code
|
|
765
|
+
* @internal
|
|
766
|
+
*/
|
|
767
|
+
export declare function promisifyWorker<T = unknown>(
|
|
768
|
+
filePath: URL,
|
|
769
|
+
options?: PromisifyWorkerOptions,
|
|
770
|
+
): Promise<T>
|
|
771
|
+
|
|
772
|
+
declare interface PromisifyWorkerOptions extends WorkerOptions_2 {
|
|
773
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, it will be terminated and the promise rejected. */
|
|
774
|
+
timeout?: number
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare const rawConfigSchema: z_2.ZodUnion<
|
|
778
|
+
readonly [
|
|
779
|
+
z_2.ZodArray<
|
|
780
|
+
z_2.ZodObject<
|
|
781
|
+
{
|
|
782
|
+
basePath: z_2.ZodString
|
|
783
|
+
name: z_2.ZodString
|
|
784
|
+
plugins: z_2.ZodOptional<z_2.ZodArray<z_2.ZodUnknown>>
|
|
785
|
+
title: z_2.ZodString
|
|
786
|
+
unstable_sources: z_2.ZodArray<
|
|
787
|
+
z_2.ZodObject<
|
|
788
|
+
{
|
|
789
|
+
dataset: z_2.ZodString
|
|
790
|
+
projectId: z_2.ZodString
|
|
791
|
+
schema: z_2.ZodObject<
|
|
792
|
+
{
|
|
793
|
+
_original: z_2.ZodObject<
|
|
794
|
+
{
|
|
795
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
796
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
797
|
+
},
|
|
798
|
+
z_2.core.$strip
|
|
799
|
+
>
|
|
800
|
+
},
|
|
801
|
+
z_2.core.$strip
|
|
802
|
+
>
|
|
803
|
+
},
|
|
804
|
+
z_2.core.$strip
|
|
805
|
+
>
|
|
806
|
+
>
|
|
807
|
+
dataset: z_2.ZodString
|
|
808
|
+
projectId: z_2.ZodString
|
|
809
|
+
schema: z_2.ZodObject<
|
|
810
|
+
{
|
|
811
|
+
_original: z_2.ZodObject<
|
|
812
|
+
{
|
|
813
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
814
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
815
|
+
},
|
|
816
|
+
z_2.core.$strip
|
|
817
|
+
>
|
|
818
|
+
},
|
|
819
|
+
z_2.core.$strip
|
|
820
|
+
>
|
|
821
|
+
},
|
|
822
|
+
z_2.core.$strip
|
|
823
|
+
>
|
|
824
|
+
>,
|
|
825
|
+
z_2.ZodObject<
|
|
826
|
+
{
|
|
827
|
+
basePath: z_2.ZodOptional<z_2.ZodString>
|
|
828
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
829
|
+
plugins: z_2.ZodOptional<z_2.ZodArray<z_2.ZodUnknown>>
|
|
830
|
+
schema: z_2.ZodOptional<
|
|
831
|
+
z_2.ZodObject<
|
|
832
|
+
{
|
|
833
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
834
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
835
|
+
},
|
|
836
|
+
z_2.core.$strip
|
|
837
|
+
>
|
|
838
|
+
>
|
|
839
|
+
title: z_2.ZodOptional<z_2.ZodString>
|
|
840
|
+
unstable_sources: z_2.ZodArray<
|
|
841
|
+
z_2.ZodObject<
|
|
842
|
+
{
|
|
843
|
+
dataset: z_2.ZodString
|
|
844
|
+
projectId: z_2.ZodString
|
|
845
|
+
schema: z_2.ZodObject<
|
|
846
|
+
{
|
|
847
|
+
_original: z_2.ZodObject<
|
|
848
|
+
{
|
|
849
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
850
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
851
|
+
},
|
|
852
|
+
z_2.core.$strip
|
|
853
|
+
>
|
|
854
|
+
},
|
|
855
|
+
z_2.core.$strip
|
|
856
|
+
>
|
|
857
|
+
},
|
|
858
|
+
z_2.core.$strip
|
|
859
|
+
>
|
|
860
|
+
>
|
|
861
|
+
dataset: z_2.ZodString
|
|
862
|
+
projectId: z_2.ZodString
|
|
863
|
+
},
|
|
864
|
+
z_2.core.$loose
|
|
865
|
+
>,
|
|
866
|
+
]
|
|
867
|
+
>
|
|
868
|
+
|
|
869
|
+
declare type RawStudioConfig = z_2.infer<typeof rawConfigSchema>
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Read the `package.json` file at the given path
|
|
873
|
+
*
|
|
874
|
+
* @param filePath - Path to package.json to read
|
|
875
|
+
* @param options - Options object for controlling read behavior
|
|
876
|
+
* @returns The parsed package.json
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
export declare function readPackageJson(
|
|
880
|
+
filePath: string | URL,
|
|
881
|
+
options?: ReadPackageJsonOptions,
|
|
882
|
+
): Promise<PackageJson>
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Options for reading package.json files
|
|
886
|
+
*
|
|
887
|
+
* @public
|
|
888
|
+
*/
|
|
889
|
+
export declare interface ReadPackageJsonOptions {
|
|
890
|
+
/**
|
|
891
|
+
* Default values to merge with the parsed package.json.
|
|
892
|
+
* Parsed values take precedence over defaults.
|
|
893
|
+
*/
|
|
894
|
+
defaults?: Partial<PackageJson>
|
|
895
|
+
/**
|
|
896
|
+
* Skip Zod schema validation. When true, the file is parsed but not validated.
|
|
897
|
+
* Defaults to false.
|
|
898
|
+
*/
|
|
899
|
+
skipSchemaValidation?: boolean
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
declare type RequireProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
|
|
903
|
+
|
|
904
|
+
declare const resolvedConfigSchema: z_2.ZodArray<
|
|
905
|
+
z_2.ZodObject<
|
|
906
|
+
{
|
|
907
|
+
basePath: z_2.ZodString
|
|
908
|
+
name: z_2.ZodString
|
|
909
|
+
plugins: z_2.ZodOptional<z_2.ZodArray<z_2.ZodUnknown>>
|
|
910
|
+
title: z_2.ZodString
|
|
911
|
+
unstable_sources: z_2.ZodArray<
|
|
912
|
+
z_2.ZodObject<
|
|
913
|
+
{
|
|
914
|
+
dataset: z_2.ZodString
|
|
915
|
+
projectId: z_2.ZodString
|
|
916
|
+
schema: z_2.ZodObject<
|
|
917
|
+
{
|
|
918
|
+
_original: z_2.ZodObject<
|
|
919
|
+
{
|
|
920
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
921
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
922
|
+
},
|
|
923
|
+
z_2.core.$strip
|
|
924
|
+
>
|
|
925
|
+
},
|
|
926
|
+
z_2.core.$strip
|
|
927
|
+
>
|
|
928
|
+
},
|
|
929
|
+
z_2.core.$strip
|
|
930
|
+
>
|
|
931
|
+
>
|
|
932
|
+
dataset: z_2.ZodString
|
|
933
|
+
projectId: z_2.ZodString
|
|
934
|
+
schema: z_2.ZodObject<
|
|
935
|
+
{
|
|
936
|
+
_original: z_2.ZodObject<
|
|
937
|
+
{
|
|
938
|
+
name: z_2.ZodOptional<z_2.ZodString>
|
|
939
|
+
types: z_2.ZodArray<z_2.ZodObject<{}, z_2.core.$loose>>
|
|
940
|
+
},
|
|
941
|
+
z_2.core.$strip
|
|
942
|
+
>
|
|
943
|
+
},
|
|
944
|
+
z_2.core.$strip
|
|
945
|
+
>
|
|
946
|
+
},
|
|
947
|
+
z_2.core.$strip
|
|
948
|
+
>
|
|
949
|
+
>
|
|
950
|
+
|
|
951
|
+
declare type ResolvedStudioConfig = z_2.infer<typeof resolvedConfigSchema>
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Resolves and imports a package from the local project's node_modules,
|
|
955
|
+
* relative to the given working directory. This avoids circular dependencies
|
|
956
|
+
* and ensures the correct version of the package is used.
|
|
957
|
+
*
|
|
958
|
+
* @param packageName - The name of the package to resolve (e.g., 'sanity')
|
|
959
|
+
* @param workDir - The working directory to resolve the package from
|
|
960
|
+
* @returns The imported module
|
|
961
|
+
* @throws If the package cannot be resolved or imported
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```ts
|
|
965
|
+
* const {createSchema} = await resolveLocalPackage('sanity', workDir)
|
|
966
|
+
* ```
|
|
967
|
+
*
|
|
968
|
+
* @internal
|
|
969
|
+
*/
|
|
970
|
+
export declare function resolveLocalPackage<T = unknown>(
|
|
971
|
+
packageName: string,
|
|
972
|
+
workDir: string,
|
|
973
|
+
): Promise<T>
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* `structuredClone()`, but doesn't throw on non-clonable values - instead it drops them.
|
|
977
|
+
*
|
|
978
|
+
* @param obj - The object to clone.
|
|
979
|
+
* @returns The cloned object.
|
|
980
|
+
* @internal
|
|
981
|
+
*/
|
|
982
|
+
export declare function safeStructuredClone<T>(obj: T): T
|
|
983
|
+
|
|
984
|
+
export declare abstract class SanityCommand<T extends typeof Command> extends Command {
|
|
985
|
+
protected args: Args<T>
|
|
986
|
+
protected flags: Flags<T>
|
|
987
|
+
/**
|
|
988
|
+
* Get the global API client.
|
|
989
|
+
*
|
|
990
|
+
* @param args - The global API client options.
|
|
991
|
+
* @returns The global API client.
|
|
992
|
+
*
|
|
993
|
+
* @deprecated use `getGlobalCliClient` function directly instead.
|
|
994
|
+
*/
|
|
995
|
+
protected getGlobalApiClient: (args: GlobalCliClientOptions) => Promise<SanityClient>
|
|
996
|
+
/**
|
|
997
|
+
* Get the project API client.
|
|
998
|
+
*
|
|
999
|
+
* @param args - The project API client options.
|
|
1000
|
+
* @returns The project API client.
|
|
1001
|
+
*
|
|
1002
|
+
* @deprecated use `getProjectCliClient` function directly instead.
|
|
1003
|
+
*/
|
|
1004
|
+
protected getProjectApiClient: (args: ProjectCliClientOptions) => Promise<SanityClient>
|
|
1005
|
+
/**
|
|
1006
|
+
* Helper for outputting to the console.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* this.output.log('Hello')
|
|
1011
|
+
* this.output.warn('Warning')
|
|
1012
|
+
* this.output.error('Error')
|
|
1013
|
+
* ```
|
|
1014
|
+
*/
|
|
1015
|
+
protected output: Output
|
|
1016
|
+
/**
|
|
1017
|
+
* The telemetry store.
|
|
1018
|
+
*
|
|
1019
|
+
* @returns The telemetry store.
|
|
1020
|
+
*/
|
|
1021
|
+
protected telemetry: CLITelemetryStore
|
|
1022
|
+
/**
|
|
1023
|
+
* Get the CLI config.
|
|
1024
|
+
*
|
|
1025
|
+
* @returns The CLI config.
|
|
1026
|
+
*/
|
|
1027
|
+
protected getCliConfig(): Promise<CliConfig>
|
|
1028
|
+
/**
|
|
1029
|
+
* Get the project ID from passed flags or (if not provided) the CLI config.
|
|
1030
|
+
*
|
|
1031
|
+
* Optionally accepts a `fallback` function that is called when no project ID
|
|
1032
|
+
* can be determined from flags or config. This allows commands to provide
|
|
1033
|
+
* interactive project selection while keeping the prompt logic in the CLI package.
|
|
1034
|
+
*
|
|
1035
|
+
* If the fallback throws a `NonInteractiveError` (e.g. because the terminal is
|
|
1036
|
+
* not interactive), it falls through to the standard error with suggestions.
|
|
1037
|
+
*
|
|
1038
|
+
* Optionally accepts a `deprecatedFlagName` for commands that have a deprecated
|
|
1039
|
+
* flag (e.g. `--project`) that should be checked after `--project-id` but before
|
|
1040
|
+
* the CLI config.
|
|
1041
|
+
*
|
|
1042
|
+
* @returns The project ID.
|
|
1043
|
+
*/
|
|
1044
|
+
protected getProjectId(options?: {
|
|
1045
|
+
deprecatedFlagName?: string
|
|
1046
|
+
fallback?: () => Promise<string>
|
|
1047
|
+
}): Promise<string>
|
|
1048
|
+
/**
|
|
1049
|
+
* Get the project's root directory by resolving the config
|
|
1050
|
+
*
|
|
1051
|
+
* @returns The project root result.
|
|
1052
|
+
*/
|
|
1053
|
+
protected getProjectRoot(): Promise<ProjectRootResult>
|
|
1054
|
+
init(): Promise<void>
|
|
1055
|
+
/**
|
|
1056
|
+
* Check if the command is running in unattended mode.
|
|
1057
|
+
*
|
|
1058
|
+
* This means the command should not ask for user input, instead using defaults where
|
|
1059
|
+
* possible, and if that does not make sense (eg there's missing information), then we
|
|
1060
|
+
* should error out (remember to exit with a non-zero code).
|
|
1061
|
+
*
|
|
1062
|
+
* Most commands should take an explicit `--yes` flag to enable unattended mode, but
|
|
1063
|
+
* some commands may also be run in unattended mode if `process.stdin` is not a TTY
|
|
1064
|
+
* (eg when running in a CI environment).
|
|
1065
|
+
*/
|
|
1066
|
+
protected isUnattended(): boolean
|
|
1067
|
+
/**
|
|
1068
|
+
* Resolver for checking if the terminal is interactive. Override in tests to provide mock values.
|
|
1069
|
+
*
|
|
1070
|
+
* @returns Whether the terminal is interactive.
|
|
1071
|
+
*/
|
|
1072
|
+
protected resolveIsInteractive(): boolean
|
|
1073
|
+
/**
|
|
1074
|
+
* Get the CLI config, returning an empty config if no project root is found.
|
|
1075
|
+
*
|
|
1076
|
+
* Use this instead of `getCliConfig()` in commands that can operate without a
|
|
1077
|
+
* project directory (e.g. when `--project-id` and `--dataset` flags are provided).
|
|
1078
|
+
*
|
|
1079
|
+
* @returns The CLI config, or an empty config object if no project root is found.
|
|
1080
|
+
*/
|
|
1081
|
+
protected tryGetCliConfig(): Promise<CliConfig>
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
export declare type SanityOrgUser = {
|
|
1085
|
+
email: string
|
|
1086
|
+
id: string
|
|
1087
|
+
name: string
|
|
1088
|
+
profileImage?: string
|
|
1089
|
+
provider: 'github' | 'google' | 'sanity' | `saml-${string}`
|
|
1090
|
+
tosAcceptedAt?: string
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Sets the global CLI telemetry store.
|
|
1095
|
+
* @internal
|
|
1096
|
+
*/
|
|
1097
|
+
export declare function setCliTelemetry(telemetry: CLITelemetryStore): void
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Set the config value for the given property.
|
|
1101
|
+
* Validates that the passed value adheres to the defined CLI config schema.
|
|
1102
|
+
*
|
|
1103
|
+
* @param prop - The property to set the value for
|
|
1104
|
+
* @param value - The value to set
|
|
1105
|
+
* @internal
|
|
1106
|
+
*/
|
|
1107
|
+
export declare function setCliUserConfig<P extends keyof CliUserConfig>(
|
|
1108
|
+
prop: P,
|
|
1109
|
+
value: CliUserConfig[P],
|
|
1110
|
+
): Promise<void>
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Executes a worker file in a Sanity Studio browser context.
|
|
1114
|
+
*
|
|
1115
|
+
* This uses a combination of vite for "bundling" + jsdom for emulating a browser
|
|
1116
|
+
* environment under the hood, which means that the same thing that will work in vite
|
|
1117
|
+
* _should_ work in the worker - to a degree. If the user has defined any typescript
|
|
1118
|
+
* path aliases, these will have to be added as aliases to the vite config - the same
|
|
1119
|
+
* behavior as you would see with regular vite. Other things that are accounted for:
|
|
1120
|
+
*
|
|
1121
|
+
* - TypeScript support (+JSX, enums and other "compilation needed" features)
|
|
1122
|
+
* - CSS, font and other file imports will resolve to a file path
|
|
1123
|
+
* - CSS module imports will resolve to a javascript object of class names
|
|
1124
|
+
* - Environment variables are available both as `import.meta.env` and `process.env`,
|
|
1125
|
+
* and `.env` files are loaded in the same way that they would in a Sanity studio.
|
|
1126
|
+
* - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
|
|
1127
|
+
* are defined directly to the Node environment as globals. While this polutes the
|
|
1128
|
+
* global namespace, it is done only in the worker thread.
|
|
1129
|
+
* - Certain browser globals that are _not_ available in JSDOM are also provided to the
|
|
1130
|
+
* global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
|
|
1131
|
+
* These are provided with a minimal stub implementation to make them not crash.
|
|
1132
|
+
*
|
|
1133
|
+
* @param filePath - Path to the worker file (`.ts` works and is encouraged)
|
|
1134
|
+
* @param options - Options to pass to the worker
|
|
1135
|
+
* @returns A promise that resolves with the message from the worker
|
|
1136
|
+
* @throws If the file does not exist
|
|
1137
|
+
* @throws If the worker exits with a non-zero code
|
|
1138
|
+
* @internal
|
|
1139
|
+
*/
|
|
1140
|
+
export declare function studioWorkerTask<T = unknown>(
|
|
1141
|
+
filePath: URL,
|
|
1142
|
+
options: StudioWorkerTaskOptions,
|
|
1143
|
+
): Promise<T>
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* Options for the studio worker task
|
|
1147
|
+
*
|
|
1148
|
+
* @internal
|
|
1149
|
+
*/
|
|
1150
|
+
declare interface StudioWorkerTaskOptions extends RequireProps<WorkerOptions_2, 'name'> {
|
|
1151
|
+
studioRootPath: string
|
|
1152
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, it will be terminated and the promise rejected. */
|
|
1153
|
+
timeout?: number
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Get a `debug` instance which extends the CLI debug instance with the given namespace,
|
|
1158
|
+
* eg namespace would be `sanity:cli:<providedNamespace>`
|
|
1159
|
+
*
|
|
1160
|
+
* @param namespace - The namespace to extend the CLI debug instance with
|
|
1161
|
+
* @returns The extended `debug` instance
|
|
1162
|
+
*/
|
|
1163
|
+
export declare const subdebug: (namespace: string) => debugIt.Debugger
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Base information needed for telemetry file operations.
|
|
1167
|
+
* Contains common data used by both file path generation and pattern matching.
|
|
1168
|
+
*/
|
|
1169
|
+
declare interface TelemetryBaseInfo {
|
|
1170
|
+
/** Base filename pattern without sessionId suffix */
|
|
1171
|
+
basePattern: string
|
|
1172
|
+
/** Base directory where telemetry files are stored */
|
|
1173
|
+
directory: string
|
|
1174
|
+
/** Environment: 'staging' or 'production' */
|
|
1175
|
+
environment: string
|
|
1176
|
+
/** Hashed token (first 8 chars of SHA256) for privacy */
|
|
1177
|
+
hashedToken: string
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* @public
|
|
1182
|
+
*/
|
|
1183
|
+
export declare interface TelemetryUserProperties {
|
|
1184
|
+
cliVersion: string
|
|
1185
|
+
cpuArchitecture: string
|
|
1186
|
+
machinePlatform: string
|
|
1187
|
+
runtime: string
|
|
1188
|
+
runtimeVersion: string
|
|
1189
|
+
dataset?: string
|
|
1190
|
+
projectId?: string
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
declare interface TimeMeasurer {
|
|
1194
|
+
end: (name: string) => number
|
|
1195
|
+
getTimings: () => Record<string, number>
|
|
1196
|
+
start: (name: string) => void
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Tries to find the studio config path, returning `undefined` if not found.
|
|
1201
|
+
*
|
|
1202
|
+
* @param basePath - The base path to start searching from
|
|
1203
|
+
* @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
|
|
1204
|
+
* @throws On errors other than config not found
|
|
1205
|
+
* @internal
|
|
1206
|
+
*/
|
|
1207
|
+
export declare function tryFindStudioConfigPath(basePath: string): Promise<string | undefined>
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Executes a worker file with tsx registered. This means you can import other
|
|
1211
|
+
* typescript with fairly rich syntax, and still have that only apply to the worker
|
|
1212
|
+
* thread instead of the full parent process. The worker should emit a message when
|
|
1213
|
+
* complete using `parentPort`. Once it has received a single message will resolve the
|
|
1214
|
+
* returned promise with that message. If you are expecting multiple messages, you will
|
|
1215
|
+
* have to implement another method ;)
|
|
1216
|
+
*
|
|
1217
|
+
* @param filePath - Path to the worker file
|
|
1218
|
+
* @param options - Options to pass to the worker
|
|
1219
|
+
* @returns A promise that resolves with the message from the worker
|
|
1220
|
+
* @throws If the file does not exist
|
|
1221
|
+
* @throws If the worker exits with a non-zero code
|
|
1222
|
+
* @internal
|
|
1223
|
+
*/
|
|
1224
|
+
export declare function tsxWorkerTask<T = unknown>(
|
|
1225
|
+
filePath: URL_2,
|
|
1226
|
+
options: TsxWorkerTaskOptions,
|
|
1227
|
+
): Promise<T>
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Options for the tsx worker task
|
|
1231
|
+
*
|
|
1232
|
+
* @internal
|
|
1233
|
+
*/
|
|
1234
|
+
declare interface TsxWorkerTaskOptions extends RequireProps<WorkerOptions_2, 'name'> {
|
|
1235
|
+
rootPath: string
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
declare type TypeGenConfig = z.infer<typeof configDefinition>
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* @public
|
|
1242
|
+
*/
|
|
1243
|
+
export declare type UserViteConfig =
|
|
1244
|
+
| ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>)
|
|
1245
|
+
| InlineConfig
|
|
1246
|
+
|
|
1247
|
+
export {}
|