@sanity/cli 3.93.1-next.8.cf0bf8550a → 3.94.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/lib/_chunks-cjs/cli.js +1 -1
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +10 -11
- package/templates/blog/README.md +1 -1
- package/templates/clean/README.md +1 -1
- package/templates/ecommerce/README.md +1 -1
- package/templates/get-started/README.md +1 -1
- package/templates/moviedb/README.md +1 -1
- package/templates/quickstart/README.md +1 -1
- package/src/CommandRunner.ts +0 -219
- package/src/__telemetry__/cli.telemetry.ts +0 -29
- package/src/__telemetry__/init.telemetry.ts +0 -95
- package/src/actions/codemod/codemodAction.ts +0 -109
- package/src/actions/codemod/mods/deskRename.ts +0 -19
- package/src/actions/codemod/mods/index.ts +0 -9
- package/src/actions/codemod/mods/partsTypeDirective.ts +0 -28
- package/src/actions/codemod/mods/reactIconsV3.ts +0 -54
- package/src/actions/codemod/types.ts +0 -10
- package/src/actions/init-plugin/bootstrapFromTemplate.ts +0 -196
- package/src/actions/init-project/bootstrapLocalTemplate.ts +0 -201
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +0 -118
- package/src/actions/init-project/createAppCliConfig.ts +0 -24
- package/src/actions/init-project/createCliConfig.ts +0 -31
- package/src/actions/init-project/createPackageManifest.ts +0 -102
- package/src/actions/init-project/createStudioConfig.ts +0 -53
- package/src/actions/init-project/determineAppTemplate.ts +0 -13
- package/src/actions/init-project/fsUtils.ts +0 -40
- package/src/actions/init-project/git.ts +0 -59
- package/src/actions/init-project/initProject.ts +0 -1708
- package/src/actions/init-project/processTemplate.ts +0 -55
- package/src/actions/init-project/promptForDatasetName.ts +0 -68
- package/src/actions/init-project/prompts/index.ts +0 -51
- package/src/actions/init-project/prompts/nextjs.ts +0 -59
- package/src/actions/init-project/readPackageJson.ts +0 -17
- package/src/actions/init-project/templates/appQuickstart.ts +0 -23
- package/src/actions/init-project/templates/appSanityUi.ts +0 -25
- package/src/actions/init-project/templates/blog.ts +0 -5
- package/src/actions/init-project/templates/clean.ts +0 -5
- package/src/actions/init-project/templates/getStarted.ts +0 -37
- package/src/actions/init-project/templates/index.ts +0 -24
- package/src/actions/init-project/templates/moviedb.ts +0 -35
- package/src/actions/init-project/templates/nextjs/index.ts +0 -238
- package/src/actions/init-project/templates/nextjs/schemaTypes/blog.ts +0 -252
- package/src/actions/init-project/templates/quickstart.ts +0 -5
- package/src/actions/init-project/templates/shopify.ts +0 -78
- package/src/actions/init-project/templates/shopifyOnline.ts +0 -50
- package/src/actions/init-project/updateInitialTemplateMetadata.ts +0 -24
- package/src/actions/login/login.telemetry.ts +0 -18
- package/src/actions/login/login.ts +0 -350
- package/src/actions/login/types.ts +0 -19
- package/src/actions/project/createProject.ts +0 -36
- package/src/actions/telemetry/setTelemetryConsent.ts +0 -101
- package/src/actions/typegen/generate.telemetry.ts +0 -20
- package/src/actions/typegen/generateAction.ts +0 -210
- package/src/actions/versions/findSanityModuleVersions.ts +0 -185
- package/src/actions/yarn/events.ts +0 -73
- package/src/cli.ts +0 -350
- package/src/cliClient.ts +0 -62
- package/src/commands/blueprints/addBlueprintsCommand.ts +0 -155
- package/src/commands/blueprints/blueprintsGroup.ts +0 -10
- package/src/commands/blueprints/configBlueprintsCommand.ts +0 -86
- package/src/commands/blueprints/deployBlueprintsCommand.ts +0 -63
- package/src/commands/blueprints/destroyBlueprintsCommand.ts +0 -78
- package/src/commands/blueprints/infoBlueprintsCommand.ts +0 -55
- package/src/commands/blueprints/initBlueprintsCommand.ts +0 -99
- package/src/commands/blueprints/logsBlueprintsCommand.ts +0 -66
- package/src/commands/blueprints/planBlueprintsCommand.ts +0 -51
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +0 -66
- package/src/commands/codemod/codemodCommand.ts +0 -32
- package/src/commands/debug/debugCommand.ts +0 -26
- package/src/commands/debug/printDebugInfo.ts +0 -243
- package/src/commands/docs/docsCommand.ts +0 -20
- package/src/commands/functions/devFunctionsCommand.ts +0 -73
- package/src/commands/functions/envFunctionsCommand.ts +0 -105
- package/src/commands/functions/functionsGroup.ts +0 -10
- package/src/commands/functions/logsFunctionsCommand.ts +0 -94
- package/src/commands/functions/testFunctionsCommand.ts +0 -93
- package/src/commands/help/helpCommand.ts +0 -21
- package/src/commands/help/showHelp.ts +0 -58
- package/src/commands/index.ts +0 -72
- package/src/commands/init/initCommand.ts +0 -123
- package/src/commands/install/installCommand.ts +0 -38
- package/src/commands/learn/learnCommand.ts +0 -20
- package/src/commands/login/loginCommand.ts +0 -29
- package/src/commands/logout/logoutCommand.ts +0 -52
- package/src/commands/manage/manageCommand.ts +0 -24
- package/src/commands/projects/listProjectsCommand.ts +0 -62
- package/src/commands/projects/projectsGroup.ts +0 -10
- package/src/commands/telemetry/disableTelemetryCommand.ts +0 -19
- package/src/commands/telemetry/enableTelemetryCommand.ts +0 -19
- package/src/commands/telemetry/telemetryGroup.ts +0 -10
- package/src/commands/telemetry/telemetryStatusCommand.ts +0 -89
- package/src/commands/typegen/generateTypesCommand.ts +0 -56
- package/src/commands/typegen/typegenGroup.ts +0 -10
- package/src/commands/versions/printVersionResult.ts +0 -51
- package/src/commands/versions/versionsCommand.ts +0 -13
- package/src/config.ts +0 -14
- package/src/debug.ts +0 -3
- package/src/index.ts +0 -6
- package/src/outputters/cliOutputter.ts +0 -47
- package/src/packageManager/getInstallCommand.ts +0 -26
- package/src/packageManager/getUpgradeCommand.ts +0 -52
- package/src/packageManager/index.ts +0 -33
- package/src/packageManager/installPackages.ts +0 -99
- package/src/packageManager/packageManagerChoice.ts +0 -204
- package/src/packageManager/uninstallPackages.ts +0 -44
- package/src/packageManager/yarnStub.ts +0 -22
- package/src/prompters/cliPrompter.ts +0 -9
- package/src/run.ts +0 -8
- package/src/studioDependencies.ts +0 -25
- package/src/types.ts +0 -387
- package/src/util/canLaunchBrowser.ts +0 -12
- package/src/util/cliWorker.ts +0 -34
- package/src/util/clientWrapper.ts +0 -119
- package/src/util/copy.ts +0 -50
- package/src/util/createExpiringConfig.ts +0 -80
- package/src/util/createTelemetryStore.ts +0 -204
- package/src/util/detectRuntime.ts +0 -12
- package/src/util/dynamicRequire.ts +0 -17
- package/src/util/frameworkPort.ts +0 -63
- package/src/util/generateCommandsDocumentation.ts +0 -62
- package/src/util/getCliConfig.ts +0 -172
- package/src/util/getCliVersion.ts +0 -22
- package/src/util/getLocalVersion.ts +0 -35
- package/src/util/getProjectDefaults.ts +0 -103
- package/src/util/getProviderName.ts +0 -9
- package/src/util/getUserConfig.ts +0 -15
- package/src/util/isCi.ts +0 -7
- package/src/util/isCommandGroup.ts +0 -7
- package/src/util/isInteractive.ts +0 -3
- package/src/util/isTrueish.ts +0 -8
- package/src/util/journeyConfig.ts +0 -280
- package/src/util/loadEnv.ts +0 -110
- package/src/util/mergeCommands.ts +0 -78
- package/src/util/neatStack.ts +0 -30
- package/src/util/noSuchCommandText.ts +0 -91
- package/src/util/parseArguments.ts +0 -76
- package/src/util/pathExists.ts +0 -14
- package/src/util/readJson.ts +0 -6
- package/src/util/readdirRecursive.ts +0 -26
- package/src/util/remoteTemplate.ts +0 -320
- package/src/util/resolveLatestVersions.ts +0 -24
- package/src/util/resolveRootDir.ts +0 -59
- package/src/util/telemetryDisclosure.ts +0 -45
- package/src/util/updateNotifier.ts +0 -158
- package/src/util/writeJson.ts +0 -6
- package/src/workers/getAndWriteJourneySchema.ts +0 -7
- package/src/workers/getCliConfig.ts +0 -14
- package/src/workers/typegenGenerate.ts +0 -228
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {type CliCommandContext, type CliYarnOptions} from '../types'
|
|
2
|
-
import {installDeclaredPackages, installNewPackages} from './installPackages'
|
|
3
|
-
import {getPackageManagerChoice} from './packageManagerChoice'
|
|
4
|
-
import {uninstallPackages} from './uninstallPackages'
|
|
5
|
-
|
|
6
|
-
export function getYarnStub(context: Pick<CliCommandContext, 'output' | 'workDir'>) {
|
|
7
|
-
return async function yarnStub(args: string[], options?: CliYarnOptions): Promise<void> {
|
|
8
|
-
const workDir = options?.rootDir || context.workDir
|
|
9
|
-
const yarnContext = {workDir, output: context.output}
|
|
10
|
-
const {chosen} = await getPackageManagerChoice(workDir, {interactive: false})
|
|
11
|
-
const [command, ...packages] = args
|
|
12
|
-
if (command === 'add') {
|
|
13
|
-
await installNewPackages({packageManager: chosen, packages}, yarnContext)
|
|
14
|
-
} else if (command === 'remove') {
|
|
15
|
-
await uninstallPackages({packageManager: chosen, packages}, yarnContext)
|
|
16
|
-
} else if (command === 'install') {
|
|
17
|
-
await installDeclaredPackages(workDir, chosen, yarnContext)
|
|
18
|
-
} else {
|
|
19
|
-
throw new Error(`Unsupported package manager command "${command}"`)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import inquirer, {type Answers, type DistinctQuestion} from 'inquirer'
|
|
2
|
-
|
|
3
|
-
export function prompt<T extends Answers = Answers>(questions: DistinctQuestion<T>[]): Promise<T> {
|
|
4
|
-
return inquirer.prompt(questions)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
prompt.Separator = inquirer.Separator
|
|
8
|
-
prompt.single = <T = string>(question: DistinctQuestion) =>
|
|
9
|
-
prompt<{value: T}>([{...question, name: 'value'}]).then((answers) => answers.value)
|
package/src/run.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const studioDependencies = {
|
|
2
|
-
// Dependencies for a default Sanity installation
|
|
3
|
-
dependencies: {
|
|
4
|
-
// Official studio dependencies
|
|
5
|
-
'sanity': 'latest',
|
|
6
|
-
|
|
7
|
-
// Official studio plugin dependencies
|
|
8
|
-
'@sanity/vision': 'latest',
|
|
9
|
-
|
|
10
|
-
// Non-Sanity dependencies
|
|
11
|
-
'react': '^19.1',
|
|
12
|
-
'react-dom': '^19.1',
|
|
13
|
-
'styled-components': '^6.1.18',
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
devDependencies: {
|
|
17
|
-
// Linting/tooling
|
|
18
|
-
'@sanity/eslint-config-studio': 'latest',
|
|
19
|
-
// When using typescript, we'll want the these types too, so might as well install them
|
|
20
|
-
'@types/react': '^19.1',
|
|
21
|
-
'eslint': '^9.28',
|
|
22
|
-
'prettier': '^3.5',
|
|
23
|
-
'typescript': '^5.8', // Peer dependency of eslint-config-studio (implicitly)
|
|
24
|
-
},
|
|
25
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import {type SanityClient} from '@sanity/client'
|
|
2
|
-
import {type TelemetryLogger} from '@sanity/telemetry'
|
|
3
|
-
import type chalk from 'chalk'
|
|
4
|
-
import {type Answers, type ChoiceCollection, type DistinctQuestion, type Separator} from 'inquirer'
|
|
5
|
-
import {type Options, type Ora} from 'ora'
|
|
6
|
-
import {type ConfigEnv, type InlineConfig} from 'vite'
|
|
7
|
-
|
|
8
|
-
import {type CliPackageManager} from './packageManager'
|
|
9
|
-
import {type ClientRequirements} from './util/clientWrapper'
|
|
10
|
-
import {type CliConfigResult} from './util/getCliConfig'
|
|
11
|
-
|
|
12
|
-
export interface SanityCore {
|
|
13
|
-
requiredCliVersionRange: string
|
|
14
|
-
commands: (CliCommandDefinition | CliCommandGroupDefinition)[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SanityModuleInternal {
|
|
18
|
-
cliProjectCommands: {
|
|
19
|
-
requiredCliVersionRange: string
|
|
20
|
-
commands: (CliCommandDefinition | CliCommandGroupDefinition)[]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface PackageJson {
|
|
25
|
-
name: string
|
|
26
|
-
version: string
|
|
27
|
-
scripts?: Record<string, string>
|
|
28
|
-
|
|
29
|
-
description?: string
|
|
30
|
-
author?: string
|
|
31
|
-
license?: string
|
|
32
|
-
private?: boolean
|
|
33
|
-
|
|
34
|
-
dependencies?: Record<string, string>
|
|
35
|
-
devDependencies?: Record<string, string>
|
|
36
|
-
peerDependencies?: Record<string, string>
|
|
37
|
-
|
|
38
|
-
repository?: {type: string; url: string}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface CliCommandGroupDefinition {
|
|
42
|
-
name: string
|
|
43
|
-
signature: string
|
|
44
|
-
isGroupRoot: boolean
|
|
45
|
-
description: string
|
|
46
|
-
hideFromHelp?: boolean
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface ResolvedCliCommand {
|
|
50
|
-
command: CliCommandDefinition | CliCommandGroupDefinition
|
|
51
|
-
commandName: string
|
|
52
|
-
parentName?: string
|
|
53
|
-
isGroup: boolean
|
|
54
|
-
isCommand: boolean
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type CliCommandAction<F = Record<string, unknown>> = (
|
|
58
|
-
args: CliCommandArguments<F>,
|
|
59
|
-
context: CliCommandContext,
|
|
60
|
-
) => Promise<unknown>
|
|
61
|
-
|
|
62
|
-
export interface CliCommandDefinition<F = Record<string, unknown>> {
|
|
63
|
-
name: string
|
|
64
|
-
group?: string
|
|
65
|
-
signature: string
|
|
66
|
-
description: string
|
|
67
|
-
helpText: string
|
|
68
|
-
action: CliCommandAction<F>
|
|
69
|
-
hideFromHelp?: boolean
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface CliCommandArguments<F = Record<string, unknown>> {
|
|
73
|
-
groupOrCommand: string
|
|
74
|
-
argv: string[]
|
|
75
|
-
extOptions: F
|
|
76
|
-
argsWithoutOptions: string[]
|
|
77
|
-
extraArguments: string[]
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type CliCommandContext = CliV2CommandContext | CliV3CommandContext
|
|
81
|
-
|
|
82
|
-
export interface CliBaseCommandContext {
|
|
83
|
-
output: CliOutputter
|
|
84
|
-
prompt: CliPrompter
|
|
85
|
-
apiClient: CliApiClient
|
|
86
|
-
sanityMajorVersion: 2 | 3
|
|
87
|
-
cliConfigPath?: string
|
|
88
|
-
cliRoot: string
|
|
89
|
-
workDir: string
|
|
90
|
-
corePath?: string
|
|
91
|
-
chalk: typeof chalk
|
|
92
|
-
commandRunner: CliCommandRunner
|
|
93
|
-
fromInitCommand?: boolean
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface TelemetryUserProperties {
|
|
97
|
-
runtime: string
|
|
98
|
-
runtimeVersion: string
|
|
99
|
-
cliVersion: string
|
|
100
|
-
machinePlatform: string
|
|
101
|
-
cpuArchitecture: string
|
|
102
|
-
projectId?: string
|
|
103
|
-
dataset?: string
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface CliV2CommandContext extends CliBaseCommandContext {
|
|
107
|
-
sanityMajorVersion: 2
|
|
108
|
-
cliConfig?: SanityJson
|
|
109
|
-
cliPackageManager?: CliPackageManager
|
|
110
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface CliV3CommandContext extends CliBaseCommandContext {
|
|
114
|
-
sanityMajorVersion: 3
|
|
115
|
-
cliConfig?: CliConfig
|
|
116
|
-
cliPackageManager: CliPackageManager
|
|
117
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface CliCommandRunner {
|
|
121
|
-
commands: Readonly<(CliCommandDefinition | CliCommandGroupDefinition)[]>
|
|
122
|
-
commandGroups: Readonly<Record<string, (CliCommandDefinition | CliCommandGroupDefinition)[]>>
|
|
123
|
-
|
|
124
|
-
runCommand(
|
|
125
|
-
commandOrGroup: string,
|
|
126
|
-
args: CliCommandArguments,
|
|
127
|
-
options: CommandRunnerOptions,
|
|
128
|
-
): Promise<unknown>
|
|
129
|
-
|
|
130
|
-
resolveSubcommand(
|
|
131
|
-
group: (CliCommandDefinition | CliCommandGroupDefinition)[],
|
|
132
|
-
subCommandName: string,
|
|
133
|
-
parentGroupName: string,
|
|
134
|
-
): ResolvedCliCommand | null
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export interface CliUserConfig {
|
|
138
|
-
cliLastUpdateCheck?: number
|
|
139
|
-
cliLastUpdateNag?: number
|
|
140
|
-
authToken?: string
|
|
141
|
-
authType?: string
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface CommandRunnerOptions {
|
|
145
|
-
cliConfig: CliConfigResult | null
|
|
146
|
-
cliRoot: string
|
|
147
|
-
workDir: string
|
|
148
|
-
corePath: string | undefined
|
|
149
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface CliOutputter {
|
|
153
|
-
print: (...args: unknown[]) => void
|
|
154
|
-
success: (...args: unknown[]) => void
|
|
155
|
-
warn: (...args: unknown[]) => void
|
|
156
|
-
error: (...args: unknown[]) => void
|
|
157
|
-
clear: () => void
|
|
158
|
-
spinner(options: Options | string): Ora
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export type SinglePrompt =
|
|
162
|
-
| (Omit<DistinctQuestion, 'name'> & {type: 'list'; choices: ChoiceCollection})
|
|
163
|
-
| (Omit<DistinctQuestion, 'name'> & {type: 'confirm'})
|
|
164
|
-
| (Omit<DistinctQuestion, 'name'> & {type: 'input'})
|
|
165
|
-
|
|
166
|
-
export type CliPrompter = (<T extends Answers = Answers>(
|
|
167
|
-
questions: DistinctQuestion<T>[],
|
|
168
|
-
) => Promise<T>) & {
|
|
169
|
-
Separator: typeof Separator
|
|
170
|
-
single: <T = string>(question: SinglePrompt) => Promise<T>
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export type CliApiClient = (options?: ClientRequirements) => SanityClient
|
|
174
|
-
|
|
175
|
-
export interface CliYarnOptions {
|
|
176
|
-
print?: CliOutputter['print']
|
|
177
|
-
error?: CliOutputter['error']
|
|
178
|
-
rootDir?: string
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export type CliStubbedYarn = (args: string[], options?: CliYarnOptions) => Promise<void>
|
|
182
|
-
|
|
183
|
-
export interface CliApiConfig {
|
|
184
|
-
projectId?: string
|
|
185
|
-
dataset?: string
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface SanityJson {
|
|
189
|
-
root?: boolean
|
|
190
|
-
|
|
191
|
-
project?: {
|
|
192
|
-
name?: string
|
|
193
|
-
basePath?: string
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
api?: CliApiConfig
|
|
197
|
-
|
|
198
|
-
// eslint-disable-next-line camelcase
|
|
199
|
-
__experimental_spaces?: {
|
|
200
|
-
name: string
|
|
201
|
-
title: string
|
|
202
|
-
default?: true
|
|
203
|
-
api: {
|
|
204
|
-
projectId?: string
|
|
205
|
-
dataset?: string
|
|
206
|
-
}
|
|
207
|
-
}[]
|
|
208
|
-
|
|
209
|
-
plugins?: string[]
|
|
210
|
-
|
|
211
|
-
parts?: {
|
|
212
|
-
name?: string
|
|
213
|
-
path?: string
|
|
214
|
-
implements?: string
|
|
215
|
-
description?: string
|
|
216
|
-
}[]
|
|
217
|
-
|
|
218
|
-
env?: {
|
|
219
|
-
production?: SanityJson
|
|
220
|
-
staging?: SanityJson
|
|
221
|
-
development?: SanityJson
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export interface GraphQLAPIConfig {
|
|
226
|
-
/**
|
|
227
|
-
* ID of GraphQL API. Only (currently) required when using the `--api` flag
|
|
228
|
-
* for `sanity graphql deploy`, in order to only deploy a specific API.
|
|
229
|
-
*/
|
|
230
|
-
id?: string
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Name of workspace containing the schema to deploy
|
|
234
|
-
*
|
|
235
|
-
* Optional, defaults to `default` (eg the one used if no `name` is defined)
|
|
236
|
-
*/
|
|
237
|
-
workspace?: string
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Name of source containing the schema to deploy, within the configured workspace
|
|
241
|
-
*
|
|
242
|
-
* Optional, defaults to `default` (eg the one used if no `name` is defined)
|
|
243
|
-
*/
|
|
244
|
-
source?: string
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* API tag for this API - allows deploying multiple different APIs to a single dataset
|
|
248
|
-
*
|
|
249
|
-
* Optional, defaults to `default`
|
|
250
|
-
*/
|
|
251
|
-
tag?: string
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Whether or not to deploy a "GraphQL Playground" to the API url - an HTML interface that allows
|
|
255
|
-
* running queries and introspecting the schema from the browser. Note that this interface is not
|
|
256
|
-
* secured in any way, but as the schema definition and API route is generally open, this does not
|
|
257
|
-
* expose any more information than is otherwise available - it only makes it more discoverable.
|
|
258
|
-
*
|
|
259
|
-
* Optional, defaults to `true`
|
|
260
|
-
*/
|
|
261
|
-
playground?: boolean
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Generation of API to auto-generate from schema. New APIs should use the latest (`gen3`).
|
|
265
|
-
*
|
|
266
|
-
* Optional, defaults to `gen3`
|
|
267
|
-
*/
|
|
268
|
-
generation?: 'gen3' | 'gen2' | 'gen1'
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Define document interface fields (`_id`, `_type` etc) as non-nullable.
|
|
272
|
-
* If you never use a document type as an object (within other documents) in your schema types,
|
|
273
|
-
* you can (and probably should) set this to `true`. Because a document type _could_ be used
|
|
274
|
-
* inside other documents, it is by default set to `false`, as in these cases these fields
|
|
275
|
-
* _can_ be null.
|
|
276
|
-
*
|
|
277
|
-
* Optional, defaults to `false`
|
|
278
|
-
*/
|
|
279
|
-
nonNullDocumentFields?: boolean
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Suffix to use for generated filter types.
|
|
283
|
-
*
|
|
284
|
-
* Optional, Defaults to `Filter`.
|
|
285
|
-
*
|
|
286
|
-
*/
|
|
287
|
-
filterSuffix?: string
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
|
|
292
|
-
* @beta
|
|
293
|
-
*/
|
|
294
|
-
export interface ReactCompilerConfig {
|
|
295
|
-
/**
|
|
296
|
-
* @see https://react.dev/learn/react-compiler#existing-projects
|
|
297
|
-
*/
|
|
298
|
-
sources?: Array<string> | ((filename: string) => boolean) | null
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* The minimum major version of React that the compiler should emit code for. If the target is 19
|
|
302
|
-
* or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
|
|
303
|
-
* versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
|
|
304
|
-
* a userspace approximation of runtime APIs.
|
|
305
|
-
* @see https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18
|
|
306
|
-
*/
|
|
307
|
-
target: '18' | '19'
|
|
308
|
-
|
|
309
|
-
panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE'
|
|
310
|
-
|
|
311
|
-
compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all'
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
interface AppConfig {
|
|
315
|
-
organizationId: string
|
|
316
|
-
/**
|
|
317
|
-
* Defaults to './src/App'
|
|
318
|
-
*/
|
|
319
|
-
entry?: string
|
|
320
|
-
id?: string
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export interface CliConfig {
|
|
324
|
-
api?: CliApiConfig
|
|
325
|
-
|
|
326
|
-
project?: {
|
|
327
|
-
basePath?: string
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Wraps the Studio in `<React.StrictMode>` root to aid flagging potential problems related to concurrent features (`startTransition`, `useTransition`, `useDeferredValue`, `Suspense`)
|
|
332
|
-
* Can also be enabled by setting `SANITY_STUDIO_REACT_STRICT_MODE="true"|"false"`.
|
|
333
|
-
* It only applies to `sanity dev` in dev mode, it's ignored in `sanity build` and in production.
|
|
334
|
-
* Defaults to `false`
|
|
335
|
-
*/
|
|
336
|
-
reactStrictMode?: boolean
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* The React Compiler is currently in beta, and is disabled by default.
|
|
340
|
-
* @see https://react.dev/learn/react-compiler
|
|
341
|
-
* @beta
|
|
342
|
-
*/
|
|
343
|
-
reactCompiler?: ReactCompilerConfig
|
|
344
|
-
|
|
345
|
-
server?: {
|
|
346
|
-
hostname?: string
|
|
347
|
-
port?: number
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
graphql?: GraphQLAPIConfig[]
|
|
351
|
-
|
|
352
|
-
vite?: UserViteConfig
|
|
353
|
-
|
|
354
|
-
autoUpdates?: boolean
|
|
355
|
-
|
|
356
|
-
studioHost?: string
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Parameter used to configure other kinds of applications.
|
|
360
|
-
* Signals to `sanity` commands that this is not a studio.
|
|
361
|
-
*/
|
|
362
|
-
app?: AppConfig
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Configuration for Sanity media libraries.
|
|
366
|
-
*/
|
|
367
|
-
mediaLibrary?: {
|
|
368
|
-
/**
|
|
369
|
-
* The path to the Media Library aspects directory. When using the CLI to manage aspects, this
|
|
370
|
-
* is the directory they will be read from and written to.
|
|
371
|
-
*/
|
|
372
|
-
aspectsPath: string
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export type UserViteConfig =
|
|
377
|
-
| InlineConfig
|
|
378
|
-
| ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>)
|
|
379
|
-
|
|
380
|
-
export type SanityUser = {
|
|
381
|
-
id: string
|
|
382
|
-
name: string
|
|
383
|
-
email: string
|
|
384
|
-
profileImage?: string
|
|
385
|
-
tosAcceptedAt?: string
|
|
386
|
-
provider: 'google' | 'github' | 'sanity' | `saml-${string}`
|
|
387
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import os from 'node:os'
|
|
2
|
-
|
|
3
|
-
export function canLaunchBrowser(): boolean {
|
|
4
|
-
const isWindowsOrMac = ['win32', 'darwin'].includes(os.platform())
|
|
5
|
-
if (isWindowsOrMac) {
|
|
6
|
-
return true
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line no-process-env
|
|
10
|
-
const hasWM = Boolean(process.env.XDG_CURRENT_DESKTOP || process.env.GDMSESSION)
|
|
11
|
-
return hasWM
|
|
12
|
-
}
|
package/src/util/cliWorker.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import pkgDir from 'pkg-dir'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Because we're bundling the CLI into a single file, the classic approach of
|
|
7
|
-
* checking `isMainThread()` and spawning a thread on `__dirname` does not work,
|
|
8
|
-
* as it leads to the entire CLI being re-executed in the worker thread.
|
|
9
|
-
*
|
|
10
|
-
* To make things worse, the built CLI makes it difficult to resolve paths to
|
|
11
|
-
* built source files (that contains the unpackaged worker).
|
|
12
|
-
*
|
|
13
|
-
* This function takes a path relative to the `src/workers` folder, resolves
|
|
14
|
-
* the location of that within the installed location (eg global Sanity CLI)
|
|
15
|
-
* and ensures we can resolve the actual module before trying to spawn the
|
|
16
|
-
* worker thread.
|
|
17
|
-
*
|
|
18
|
-
* @param workerPath - _RELATIVE_ path (relative to `src/workers`) to the worker
|
|
19
|
-
* @returns Full, absolute path to the worker
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export async function getCliWorkerPath(workerPath: string): Promise<string> {
|
|
23
|
-
const cliDir = await pkgDir(__dirname)
|
|
24
|
-
if (!cliDir) {
|
|
25
|
-
throw new Error('Failed to find root @sanity/cli module directory')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const resolvedPath = path.resolve(cliDir, 'lib', 'workers', workerPath)
|
|
29
|
-
try {
|
|
30
|
-
return require.resolve(resolvedPath)
|
|
31
|
-
} catch {
|
|
32
|
-
throw new Error(`Unable to resolve path for worker: ${workerPath}`)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type ClientError,
|
|
5
|
-
createClient,
|
|
6
|
-
requester as defaultRequester,
|
|
7
|
-
type SanityClient,
|
|
8
|
-
type ServerError,
|
|
9
|
-
} from '@sanity/client'
|
|
10
|
-
import {generateHelpUrl} from '@sanity/generate-help-url'
|
|
11
|
-
import chalk from 'chalk'
|
|
12
|
-
|
|
13
|
-
import {type CliApiConfig} from '../types'
|
|
14
|
-
import {getUserConfig} from './getUserConfig'
|
|
15
|
-
|
|
16
|
-
const apiHosts: Record<string, string | undefined> = {
|
|
17
|
-
staging: 'https://api.sanity.work',
|
|
18
|
-
development: 'http://api.sanity.local',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Creates a wrapper/getter function to retrieve a Sanity API client.
|
|
23
|
-
* Instead of spreading the error checking logic around the project,
|
|
24
|
-
* we call it here when (and only when) a command needs to use the API
|
|
25
|
-
*/
|
|
26
|
-
const defaults = {
|
|
27
|
-
requireUser: true,
|
|
28
|
-
requireProject: true,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const authErrors = () => ({
|
|
32
|
-
onError: (err: Error | null) => {
|
|
33
|
-
if (!err || !isReqResError(err)) {
|
|
34
|
-
return err
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const statusCode = err.response && err.response.body && err.response.body.statusCode
|
|
38
|
-
if (statusCode === 401) {
|
|
39
|
-
err.message = `${err.message}. You may need to login again with ${chalk.cyan(
|
|
40
|
-
'sanity login',
|
|
41
|
-
)}.\nFor more information, see ${generateHelpUrl('cli-errors')}.`
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return err
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
function isReqResError(err: Error): err is ClientError | ServerError {
|
|
49
|
-
return err.hasOwnProperty('response')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function getCliToken(): string | undefined {
|
|
53
|
-
// eslint-disable-next-line no-process-env
|
|
54
|
-
const envAuthToken = process.env.SANITY_AUTH_TOKEN
|
|
55
|
-
const userConfig = getUserConfig()
|
|
56
|
-
return envAuthToken || userConfig.get('authToken')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface ClientRequirements {
|
|
60
|
-
requireUser?: boolean
|
|
61
|
-
requireProject?: boolean
|
|
62
|
-
api?: {
|
|
63
|
-
projectId?: string
|
|
64
|
-
dataset?: string
|
|
65
|
-
apiHost?: string
|
|
66
|
-
apiVersion?: string
|
|
67
|
-
requestTagPrefix?: string
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getClientWrapper(
|
|
72
|
-
cliApiConfig: CliApiConfig | null,
|
|
73
|
-
configPath: string,
|
|
74
|
-
): (options?: ClientRequirements) => SanityClient {
|
|
75
|
-
const requester = defaultRequester.clone()
|
|
76
|
-
requester.use(authErrors())
|
|
77
|
-
|
|
78
|
-
return function (opts?: ClientRequirements) {
|
|
79
|
-
// Read these environment variables "late" to allow `.env` files
|
|
80
|
-
|
|
81
|
-
/* eslint-disable no-process-env */
|
|
82
|
-
const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'
|
|
83
|
-
/* eslint-enable no-process-env */
|
|
84
|
-
|
|
85
|
-
const {requireUser, requireProject, api} = {...defaults, ...opts}
|
|
86
|
-
const token = getCliToken()
|
|
87
|
-
const apiHost = apiHosts[sanityEnv]
|
|
88
|
-
const apiConfig = {
|
|
89
|
-
...cliApiConfig,
|
|
90
|
-
...api,
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (apiHost) {
|
|
94
|
-
apiConfig.apiHost = apiHost
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (requireUser && !token) {
|
|
98
|
-
throw new Error('You must login first - run "sanity login"')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (requireProject && !apiConfig.projectId) {
|
|
102
|
-
const relativeConfigPath = path.relative(process.cwd(), configPath)
|
|
103
|
-
throw new Error(
|
|
104
|
-
`${relativeConfigPath} does not contain a project identifier ("api.projectId"), ` +
|
|
105
|
-
'which is required for the Sanity CLI to communicate with the Sanity API',
|
|
106
|
-
)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return createClient({
|
|
110
|
-
...apiConfig,
|
|
111
|
-
apiVersion: '1',
|
|
112
|
-
dataset: apiConfig.dataset || '~dummy-placeholder-dataset-',
|
|
113
|
-
token: requireUser ? token : undefined,
|
|
114
|
-
useProjectHostname: requireProject,
|
|
115
|
-
requester,
|
|
116
|
-
useCdn: false,
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/util/copy.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
|
|
4
|
-
import {readdirRecursive} from './readdirRecursive'
|
|
5
|
-
|
|
6
|
-
interface CopyOptions {
|
|
7
|
-
rename?: (originalName: string) => string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function copy(
|
|
11
|
-
srcPath: string,
|
|
12
|
-
dstPath: string,
|
|
13
|
-
options?: CopyOptions,
|
|
14
|
-
): Promise<number> {
|
|
15
|
-
const rename = options?.rename
|
|
16
|
-
const content = (await fs.stat(srcPath)).isDirectory()
|
|
17
|
-
? await readdirRecursive(srcPath)
|
|
18
|
-
: [{path: srcPath, isDir: false}]
|
|
19
|
-
|
|
20
|
-
const directories = content
|
|
21
|
-
.filter((entry) => entry.isDir)
|
|
22
|
-
.sort((a, b) => b.path.length - a.path.length)
|
|
23
|
-
.sort((a, b) => a.path.localeCompare(b.path))
|
|
24
|
-
.map((entry) => entry.path)
|
|
25
|
-
|
|
26
|
-
for (const subDir of directories) {
|
|
27
|
-
const relativePath = path.relative(srcPath, subDir)
|
|
28
|
-
const fullDstPath = path.join(dstPath, relativePath)
|
|
29
|
-
await fs.mkdir(fullDstPath, {recursive: true})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const files = content
|
|
33
|
-
.filter((entry) => !entry.isDir)
|
|
34
|
-
.sort((a, b) => b.path.length - a.path.length)
|
|
35
|
-
.sort((a, b) => a.path.localeCompare(b.path))
|
|
36
|
-
.map((entry) => {
|
|
37
|
-
const relativePath = path.relative(srcPath, entry.path)
|
|
38
|
-
const baseName = path.basename(relativePath)
|
|
39
|
-
const dirName = path.dirname(relativePath)
|
|
40
|
-
const dstName = rename ? rename(baseName) : baseName
|
|
41
|
-
const fullDstPath = path.join(dstPath, dirName, dstName)
|
|
42
|
-
return {from: entry.path, to: fullDstPath}
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
for (const file of files) {
|
|
46
|
-
await fs.copyFile(file.from, file.to)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return files.length
|
|
50
|
-
}
|