@sanity/cli 3.93.1-next.9.198ab74452 → 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,58 +0,0 @@
|
|
|
1
|
-
import {debug} from '../../debug'
|
|
2
|
-
import {type CliCommandDefinition} from '../../types'
|
|
3
|
-
import {
|
|
4
|
-
generateCommandDocumentation,
|
|
5
|
-
generateCommandsDocumentation,
|
|
6
|
-
} from '../../util/generateCommandsDocumentation'
|
|
7
|
-
import {isCommandGroup} from '../../util/isCommandGroup'
|
|
8
|
-
import {getNoSuchCommandText} from '../../util/noSuchCommandText'
|
|
9
|
-
|
|
10
|
-
const showHelpAction: CliCommandDefinition['action'] = async (args, context) => {
|
|
11
|
-
const [commandName, subCommandName] = args.argsWithoutOptions
|
|
12
|
-
const {commandGroups} = context.commandRunner
|
|
13
|
-
|
|
14
|
-
if (!commandName) {
|
|
15
|
-
debug('No command given to "help", showing generate Sanity CLI help')
|
|
16
|
-
context.output.print(generateCommandsDocumentation(commandGroups))
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const defaultCommand = commandGroups.default.find((cmd) => cmd.name === commandName)
|
|
21
|
-
if (defaultCommand && !isCommandGroup(defaultCommand)) {
|
|
22
|
-
debug(`Found command in default group with name "${commandName}"`)
|
|
23
|
-
context.output.print(generateCommandDocumentation(defaultCommand))
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const group = commandGroups[commandName]
|
|
28
|
-
if (!subCommandName && !group) {
|
|
29
|
-
debug(`No subcommand given, and we couldn't find a group with name "${group}"`)
|
|
30
|
-
throw new Error(getNoSuchCommandText(commandName, null, commandGroups))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!subCommandName && group) {
|
|
34
|
-
debug(`No subcommand given, but found group with name "${commandName}"`)
|
|
35
|
-
context.output.print(generateCommandsDocumentation(commandGroups, commandName))
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (subCommandName && !group) {
|
|
40
|
-
debug(`Subcommand given, but couldn't find group with name "${commandName}"`)
|
|
41
|
-
throw new Error(getNoSuchCommandText(subCommandName, commandName, commandGroups))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const subCommand = context.commandRunner.resolveSubcommand(group, subCommandName, commandName)
|
|
45
|
-
if (!subCommand) {
|
|
46
|
-
debug(`Subcommand given, but not found in group "${commandName}"`)
|
|
47
|
-
throw new Error(getNoSuchCommandText(subCommandName, commandName, commandGroups))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
debug('Subcommand "%s" for group "%s" found, showing help', subCommandName, commandName)
|
|
51
|
-
if (!isCommandGroup(subCommand.command)) {
|
|
52
|
-
context.output.print(
|
|
53
|
-
generateCommandDocumentation(subCommand.command, commandName, subCommandName),
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default showHelpAction
|
package/src/commands/index.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {type CliCommandDefinition, type CliCommandGroupDefinition} from '../types'
|
|
2
|
-
import addBlueprintsCommand from './blueprints/addBlueprintsCommand'
|
|
3
|
-
import blueprintsGroup from './blueprints/blueprintsGroup'
|
|
4
|
-
import configBlueprintsCommand from './blueprints/configBlueprintsCommand'
|
|
5
|
-
import deployBlueprintsCommand from './blueprints/deployBlueprintsCommand'
|
|
6
|
-
import destroyBlueprintsCommand from './blueprints/destroyBlueprintsCommand'
|
|
7
|
-
import infoBlueprintsCommand from './blueprints/infoBlueprintsCommand'
|
|
8
|
-
import initBlueprintsCommand from './blueprints/initBlueprintsCommand'
|
|
9
|
-
import logsBlueprintsCommand from './blueprints/logsBlueprintsCommand'
|
|
10
|
-
import planBlueprintsCommand from './blueprints/planBlueprintsCommand'
|
|
11
|
-
import listBlueprintsCommand from './blueprints/stacksBlueprintsCommand'
|
|
12
|
-
import codemodCommand from './codemod/codemodCommand'
|
|
13
|
-
import debugCommand from './debug/debugCommand'
|
|
14
|
-
import docsCommand from './docs/docsCommand'
|
|
15
|
-
import devfunctionsCommand from './functions/devFunctionsCommand'
|
|
16
|
-
import envFunctionsCommand from './functions/envFunctionsCommand'
|
|
17
|
-
import functionsGroup from './functions/functionsGroup'
|
|
18
|
-
import logsfunctionsCommand from './functions/logsFunctionsCommand'
|
|
19
|
-
import testfunctionsCommand from './functions/testFunctionsCommand'
|
|
20
|
-
import helpCommand from './help/helpCommand'
|
|
21
|
-
import initCommand from './init/initCommand'
|
|
22
|
-
import installCommand from './install/installCommand'
|
|
23
|
-
import learnCommand from './learn/learnCommand'
|
|
24
|
-
import loginCommand from './login/loginCommand'
|
|
25
|
-
import logoutCommand from './logout/logoutCommand'
|
|
26
|
-
import manageCommand from './manage/manageCommand'
|
|
27
|
-
import listProjectsCommand from './projects/listProjectsCommand'
|
|
28
|
-
import projectsGroup from './projects/projectsGroup'
|
|
29
|
-
import disableTelemetryCommand from './telemetry/disableTelemetryCommand'
|
|
30
|
-
import enableTelemetryCommand from './telemetry/enableTelemetryCommand'
|
|
31
|
-
import telemetryGroup from './telemetry/telemetryGroup'
|
|
32
|
-
import telemetryStatusCommand from './telemetry/telemetryStatusCommand'
|
|
33
|
-
import generateTypegenCommand from './typegen/generateTypesCommand'
|
|
34
|
-
import typegenGroup from './typegen/typegenGroup'
|
|
35
|
-
import versionsCommand from './versions/versionsCommand'
|
|
36
|
-
|
|
37
|
-
export const baseCommands: (CliCommandDefinition | CliCommandGroupDefinition)[] = [
|
|
38
|
-
initCommand,
|
|
39
|
-
loginCommand,
|
|
40
|
-
logoutCommand,
|
|
41
|
-
installCommand,
|
|
42
|
-
versionsCommand,
|
|
43
|
-
docsCommand,
|
|
44
|
-
manageCommand,
|
|
45
|
-
debugCommand,
|
|
46
|
-
helpCommand,
|
|
47
|
-
projectsGroup,
|
|
48
|
-
learnCommand,
|
|
49
|
-
listProjectsCommand,
|
|
50
|
-
codemodCommand,
|
|
51
|
-
telemetryGroup,
|
|
52
|
-
disableTelemetryCommand,
|
|
53
|
-
enableTelemetryCommand,
|
|
54
|
-
telemetryStatusCommand,
|
|
55
|
-
generateTypegenCommand,
|
|
56
|
-
typegenGroup,
|
|
57
|
-
functionsGroup,
|
|
58
|
-
devfunctionsCommand,
|
|
59
|
-
logsfunctionsCommand,
|
|
60
|
-
testfunctionsCommand,
|
|
61
|
-
envFunctionsCommand,
|
|
62
|
-
blueprintsGroup,
|
|
63
|
-
addBlueprintsCommand,
|
|
64
|
-
configBlueprintsCommand,
|
|
65
|
-
deployBlueprintsCommand,
|
|
66
|
-
destroyBlueprintsCommand,
|
|
67
|
-
infoBlueprintsCommand,
|
|
68
|
-
initBlueprintsCommand,
|
|
69
|
-
listBlueprintsCommand,
|
|
70
|
-
logsBlueprintsCommand,
|
|
71
|
-
planBlueprintsCommand,
|
|
72
|
-
]
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {type Framework, frameworks} from '@vercel/frameworks'
|
|
2
|
-
import {detectFrameworkRecord, LocalFileSystemDetector} from '@vercel/fs-detectors'
|
|
3
|
-
|
|
4
|
-
import initProject from '../../actions/init-project/initProject'
|
|
5
|
-
import {
|
|
6
|
-
allowedPackageManagersString,
|
|
7
|
-
type PackageManager,
|
|
8
|
-
} from '../../packageManager/packageManagerChoice'
|
|
9
|
-
import {type CliCommandDefinition} from '../../types'
|
|
10
|
-
|
|
11
|
-
const helpText = `
|
|
12
|
-
Options
|
|
13
|
-
-y, --yes Use unattended mode, accepting defaults and using only flags for choices
|
|
14
|
-
--project <projectId> Project ID to use for the studio
|
|
15
|
-
--organization <organizationId> Organization ID to use for the project
|
|
16
|
-
--dataset <dataset> Dataset name for the studio
|
|
17
|
-
--dataset-default Set up a project with a public dataset named "production"
|
|
18
|
-
--output-path <path> Path to write studio project to
|
|
19
|
-
--template <template> Project template to use [default: "clean"]
|
|
20
|
-
--bare Skip the Studio initialization and only print the selected project ID and dataset name to stdout
|
|
21
|
-
--env <filename> Write environment variables to file [default: ".env"]
|
|
22
|
-
--provider <provider> Login provider to use
|
|
23
|
-
--visibility <mode> Visibility mode for dataset (public/private)
|
|
24
|
-
--create-project <name> Create a new project with the given name
|
|
25
|
-
--project-plan <name> Optionally select a plan for a new project
|
|
26
|
-
--coupon <name> Optionally select a coupon for a new project (cannot be used with --project-plan)
|
|
27
|
-
--no-typescript Do not use TypeScript for template files
|
|
28
|
-
--package-manager <name> Specify which package manager to use [allowed: ${allowedPackageManagersString}]
|
|
29
|
-
--no-auto-updates Disable auto updates of studio versions
|
|
30
|
-
|
|
31
|
-
Examples
|
|
32
|
-
# Initialize a new project, prompt for required information along the way
|
|
33
|
-
sanity init
|
|
34
|
-
|
|
35
|
-
# Initialize a new project with a public dataset named "production"
|
|
36
|
-
sanity init --dataset-default
|
|
37
|
-
|
|
38
|
-
# Initialize a project with the given project ID and dataset to the given path
|
|
39
|
-
sanity init -y --project abc123 --dataset production --output-path ~/myproj
|
|
40
|
-
|
|
41
|
-
# Initialize a project with the given project ID and dataset using the moviedb
|
|
42
|
-
# template to the given path
|
|
43
|
-
sanity init -y --project abc123 --dataset staging --template moviedb --output-path .
|
|
44
|
-
|
|
45
|
-
# Create a brand new project with name "Movies Unlimited"
|
|
46
|
-
sanity init -y \\
|
|
47
|
-
--create-project "Movies Unlimited" \\
|
|
48
|
-
--dataset moviedb \\
|
|
49
|
-
--visibility private \\
|
|
50
|
-
--template moviedb \\
|
|
51
|
-
--output-path /Users/espenh/movies-unlimited
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
export interface InitFlags {
|
|
55
|
-
'y'?: boolean
|
|
56
|
-
'yes'?: boolean
|
|
57
|
-
'project'?: string
|
|
58
|
-
'dataset'?: string
|
|
59
|
-
'template'?: string
|
|
60
|
-
/**
|
|
61
|
-
* Used for accessing private GitHub repo templates
|
|
62
|
-
* @beta
|
|
63
|
-
*/
|
|
64
|
-
'template-token'?: string
|
|
65
|
-
|
|
66
|
-
'visibility'?: string
|
|
67
|
-
'typescript'?: boolean
|
|
68
|
-
'auto-updates'?: boolean
|
|
69
|
-
/**
|
|
70
|
-
* Used for initializing a project from a server schema that is saved in the Journey API
|
|
71
|
-
* Overrides `project` option.
|
|
72
|
-
* Overrides `dataset` option.
|
|
73
|
-
* Overrides `template` option.
|
|
74
|
-
* Overrides `visibility` option.
|
|
75
|
-
* @beta
|
|
76
|
-
*/
|
|
77
|
-
'quickstart'?: string
|
|
78
|
-
'bare'?: boolean
|
|
79
|
-
'env'?: boolean | string
|
|
80
|
-
'git'?: boolean | string
|
|
81
|
-
|
|
82
|
-
'output-path'?: string
|
|
83
|
-
'project-plan'?: string
|
|
84
|
-
'create-project'?: boolean | string
|
|
85
|
-
'dataset-default'?: boolean
|
|
86
|
-
|
|
87
|
-
'coupon'?: string
|
|
88
|
-
/**
|
|
89
|
-
* @deprecated `--reconfigure` is deprecated - manual configuration is now required
|
|
90
|
-
*/
|
|
91
|
-
'reconfigure'?: boolean
|
|
92
|
-
|
|
93
|
-
'organization'?: string
|
|
94
|
-
|
|
95
|
-
'package-manager'?: PackageManager
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const initCommand: CliCommandDefinition<InitFlags> = {
|
|
99
|
-
name: 'init',
|
|
100
|
-
signature: '',
|
|
101
|
-
description: 'Initializes a new Sanity Studio and/or project',
|
|
102
|
-
helpText,
|
|
103
|
-
action: async (args, context) => {
|
|
104
|
-
const [type] = args.argsWithoutOptions
|
|
105
|
-
|
|
106
|
-
// `sanity init whatever`
|
|
107
|
-
if (type) {
|
|
108
|
-
return Promise.reject(new Error(`Unknown init type "${type}"`))
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const detectedFramework: Framework | null = await detectFrameworkRecord({
|
|
112
|
-
fs: new LocalFileSystemDetector(process.cwd()),
|
|
113
|
-
frameworkList: frameworks as readonly Framework[],
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
return initProject(args, {
|
|
117
|
-
...context,
|
|
118
|
-
detectedFramework,
|
|
119
|
-
})
|
|
120
|
-
},
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export default initCommand
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getPackageManagerChoice,
|
|
3
|
-
installDeclaredPackages,
|
|
4
|
-
installNewPackages,
|
|
5
|
-
} from '../../packageManager'
|
|
6
|
-
import {type CliCommandDefinition} from '../../types'
|
|
7
|
-
|
|
8
|
-
const installCommand: CliCommandDefinition = {
|
|
9
|
-
name: 'install',
|
|
10
|
-
signature: '',
|
|
11
|
-
helpText: '',
|
|
12
|
-
description: 'Installs dependencies for Sanity Studio project',
|
|
13
|
-
action: async (args, context) => {
|
|
14
|
-
const {workDir, prompt, sanityMajorVersion} = context
|
|
15
|
-
const packages = args.argsWithoutOptions
|
|
16
|
-
if (packages.length > 0 && sanityMajorVersion === 2) {
|
|
17
|
-
/**
|
|
18
|
-
* Note: `@sanity/core` (only used in v2) takes over the `sanity install`
|
|
19
|
-
* command and provides the ability to install plugins. In v3, we don't
|
|
20
|
-
* want this, which is why this error differs based on major version.
|
|
21
|
-
**/
|
|
22
|
-
throw new Error('Re-run this command with `@sanity/core` installed')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const pkgManager = await getPackageManagerChoice(workDir, {prompt})
|
|
26
|
-
|
|
27
|
-
if (packages.length > 0) {
|
|
28
|
-
await installNewPackages(
|
|
29
|
-
{packageManager: pkgManager.chosen, packages: args.argsWithoutOptions},
|
|
30
|
-
context,
|
|
31
|
-
)
|
|
32
|
-
} else {
|
|
33
|
-
await installDeclaredPackages(workDir, pkgManager.chosen, context)
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default installCommand
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import open from 'open'
|
|
2
|
-
|
|
3
|
-
import {type CliCommandDefinition} from '../../types'
|
|
4
|
-
|
|
5
|
-
const learnCommand: CliCommandDefinition = {
|
|
6
|
-
name: 'learn',
|
|
7
|
-
helpText: '',
|
|
8
|
-
signature: 'learn',
|
|
9
|
-
description: 'Opens Sanity Learn in your web browser',
|
|
10
|
-
async action(args, context) {
|
|
11
|
-
const {output} = context
|
|
12
|
-
const {print} = output
|
|
13
|
-
const url = 'https://www.sanity.io/learn'
|
|
14
|
-
|
|
15
|
-
print(`Opening ${url}`)
|
|
16
|
-
await open(url)
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default learnCommand
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {login} from '../../actions/login/login'
|
|
2
|
-
import {type CliCommandDefinition} from '../../types'
|
|
3
|
-
|
|
4
|
-
const helpText = `
|
|
5
|
-
Options
|
|
6
|
-
--sso <slug> Log in using Single Sign On, using the given slug
|
|
7
|
-
--provider <providerId> Authenticate against a specific provider
|
|
8
|
-
--no-open Do not open a browser window to log in, only print URL
|
|
9
|
-
|
|
10
|
-
Examples
|
|
11
|
-
# Log in using default settings
|
|
12
|
-
sanity login
|
|
13
|
-
|
|
14
|
-
# Log in using Single Sign-On with the "my-organization" slug
|
|
15
|
-
sanity login --sso my-organization
|
|
16
|
-
|
|
17
|
-
# Login with GitHub provider, but do not open a browser window automatically
|
|
18
|
-
sanity login --provider github --no-open
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
const loginCommand: CliCommandDefinition = {
|
|
22
|
-
name: 'login',
|
|
23
|
-
signature: '[--sso <slug>] [--provider <providerId>] [--no-open]',
|
|
24
|
-
helpText,
|
|
25
|
-
description: 'Authenticates the CLI for access to Sanity projects',
|
|
26
|
-
action: login,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default loginCommand
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import {type CliCommandDefinition} from '../../types'
|
|
4
|
-
import {TELEMETRY_CONSENT_CONFIG_KEY} from '../../util/createTelemetryStore'
|
|
5
|
-
import {getUserConfig} from '../../util/getUserConfig'
|
|
6
|
-
|
|
7
|
-
const helpText = `
|
|
8
|
-
Examples
|
|
9
|
-
# Log out of the CLI
|
|
10
|
-
sanity logout
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
const logoutCommand: CliCommandDefinition = {
|
|
14
|
-
name: 'logout',
|
|
15
|
-
helpText,
|
|
16
|
-
signature: 'logout',
|
|
17
|
-
description: 'Logs out the CLI from the current user session',
|
|
18
|
-
async action(args, {output, apiClient}) {
|
|
19
|
-
const cfg = getUserConfig()
|
|
20
|
-
|
|
21
|
-
const token = cfg.get('authToken')
|
|
22
|
-
if (!token) {
|
|
23
|
-
output.print(chalk.red('No login credentials found'))
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const client = apiClient({requireUser: true, requireProject: false})
|
|
28
|
-
try {
|
|
29
|
-
await client.request({uri: '/auth/logout', method: 'POST'})
|
|
30
|
-
} catch (err) {
|
|
31
|
-
const statusCode = err && err.response && err.response.statusCode
|
|
32
|
-
|
|
33
|
-
// In the case of session timeouts or missing sessions, we'll get a 401
|
|
34
|
-
// This is an acceptable situation seen from a logout perspective - all we
|
|
35
|
-
// need to do in this case is clear the session from the view of the CLI
|
|
36
|
-
if (statusCode !== 401) {
|
|
37
|
-
output.error(chalk.red(`Failed to communicate with the Sanity API:\n${err.message}`))
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
cfg.delete('authType')
|
|
43
|
-
cfg.delete('authToken')
|
|
44
|
-
|
|
45
|
-
// Clear cached telemetry consent
|
|
46
|
-
cfg.delete(TELEMETRY_CONSENT_CONFIG_KEY)
|
|
47
|
-
|
|
48
|
-
output.success('Logged out')
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default logoutCommand
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import open from 'open'
|
|
2
|
-
|
|
3
|
-
import {type CliCommandDefinition} from '../../types'
|
|
4
|
-
|
|
5
|
-
const manageCommand: CliCommandDefinition = {
|
|
6
|
-
name: 'manage',
|
|
7
|
-
signature: 'manage',
|
|
8
|
-
helpText: '',
|
|
9
|
-
description: 'Opens project management interface in your web browser',
|
|
10
|
-
async action(args, context) {
|
|
11
|
-
const {output, cliConfig} = context
|
|
12
|
-
const {print} = output
|
|
13
|
-
const projectId = cliConfig?.api?.projectId
|
|
14
|
-
|
|
15
|
-
const url = projectId
|
|
16
|
-
? `https://www.sanity.io/manage/project/${projectId}`
|
|
17
|
-
: 'https://www.sanity.io/manage/'
|
|
18
|
-
|
|
19
|
-
print(`Opening ${url}`)
|
|
20
|
-
await open(url)
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default manageCommand
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {size, sortBy} from 'lodash'
|
|
2
|
-
|
|
3
|
-
import {type CliCommandDefinition} from '../../types'
|
|
4
|
-
|
|
5
|
-
const headings = ['id', 'members', 'name', 'url', 'created']
|
|
6
|
-
const helpText = `
|
|
7
|
-
Options
|
|
8
|
-
--sort <field> Sort output by specified column
|
|
9
|
-
--order <asc/desc> Sort output ascending/descending
|
|
10
|
-
|
|
11
|
-
Examples
|
|
12
|
-
# List projects
|
|
13
|
-
sanity projects list
|
|
14
|
-
|
|
15
|
-
# List projects sorted by member count, ascending
|
|
16
|
-
sanity projects list --sort=members --order=asc
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
const defaultFlags = {
|
|
20
|
-
sort: 'created',
|
|
21
|
-
order: 'desc',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const listProjectsCommand: CliCommandDefinition = {
|
|
25
|
-
name: 'list',
|
|
26
|
-
group: 'projects',
|
|
27
|
-
signature: '',
|
|
28
|
-
helpText,
|
|
29
|
-
description: 'Lists projects connected to your user',
|
|
30
|
-
action: async (args, context) => {
|
|
31
|
-
const {apiClient, output, chalk} = context
|
|
32
|
-
const flags = {...defaultFlags, ...args.extOptions}
|
|
33
|
-
const client = apiClient({
|
|
34
|
-
requireUser: true,
|
|
35
|
-
requireProject: false,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const projects = await client.projects.list()
|
|
39
|
-
const ordered = sortBy(
|
|
40
|
-
projects.map(({displayName, id, members = [], createdAt}) => {
|
|
41
|
-
const manage = `https://www.sanity.io/manage/project/${id}`
|
|
42
|
-
return [id, members.length, displayName, manage, createdAt].map(String)
|
|
43
|
-
}),
|
|
44
|
-
[headings.indexOf(flags.sort)],
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
const rows = flags.order === 'asc' ? ordered : ordered.reverse()
|
|
48
|
-
|
|
49
|
-
const maxWidths = rows.reduce(
|
|
50
|
-
(max, row) => row.map((current, index) => Math.max(size(current), max[index])),
|
|
51
|
-
headings.map((str) => size(str)),
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
const printRow = (row: string[]) =>
|
|
55
|
-
row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(' ')
|
|
56
|
-
|
|
57
|
-
output.print(chalk.cyan(printRow(headings)))
|
|
58
|
-
rows.forEach((row) => output.print(printRow(row)))
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default listProjectsCommand
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {type CliCommandGroupDefinition} from '../../types'
|
|
2
|
-
|
|
3
|
-
const projectGroup: CliCommandGroupDefinition = {
|
|
4
|
-
name: 'projects',
|
|
5
|
-
signature: '[COMMAND]',
|
|
6
|
-
isGroupRoot: true,
|
|
7
|
-
description: 'Lists all projects associated with your logged-in account',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default projectGroup
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {createSetTelemetryConsentAction} from '../../actions/telemetry/setTelemetryConsent'
|
|
2
|
-
import {type CliCommandDefinition} from '../../types'
|
|
3
|
-
|
|
4
|
-
const helpText = `
|
|
5
|
-
Examples
|
|
6
|
-
# Disable telemetry for your logged in user
|
|
7
|
-
sanity telemetry disable
|
|
8
|
-
`
|
|
9
|
-
|
|
10
|
-
const disableTelemetryCommand: CliCommandDefinition = {
|
|
11
|
-
name: 'disable',
|
|
12
|
-
group: 'telemetry',
|
|
13
|
-
helpText,
|
|
14
|
-
signature: '',
|
|
15
|
-
description: 'Disable telemetry for your logged in user',
|
|
16
|
-
action: createSetTelemetryConsentAction('denied'),
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default disableTelemetryCommand
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {createSetTelemetryConsentAction} from '../../actions/telemetry/setTelemetryConsent'
|
|
2
|
-
import {type CliCommandDefinition} from '../../types'
|
|
3
|
-
|
|
4
|
-
const helpText = `
|
|
5
|
-
Examples
|
|
6
|
-
# Enable telemetry for your logged in user
|
|
7
|
-
sanity telemetry enable
|
|
8
|
-
`
|
|
9
|
-
|
|
10
|
-
const enableTelemetryCommand: CliCommandDefinition = {
|
|
11
|
-
name: 'enable',
|
|
12
|
-
group: 'telemetry',
|
|
13
|
-
helpText,
|
|
14
|
-
signature: '',
|
|
15
|
-
description: 'Enable telemetry for your logged in user',
|
|
16
|
-
action: createSetTelemetryConsentAction('granted'),
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default enableTelemetryCommand
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {type CliCommandGroupDefinition} from '../../types'
|
|
2
|
-
|
|
3
|
-
const telemetryGroup: CliCommandGroupDefinition = {
|
|
4
|
-
name: 'telemetry',
|
|
5
|
-
signature: '[COMMAND]',
|
|
6
|
-
isGroupRoot: true,
|
|
7
|
-
description: 'Manages telemetry settings, opting in or out of data collection',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default telemetryGroup
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {type ConsentStatus} from '@sanity/telemetry'
|
|
2
|
-
|
|
3
|
-
import {type CliCommandContext, type CliCommandDefinition} from '../../types'
|
|
4
|
-
import {resolveConsent} from '../../util/createTelemetryStore'
|
|
5
|
-
|
|
6
|
-
const helpText = `
|
|
7
|
-
Examples
|
|
8
|
-
# Check telemetry consent status for your logged in user
|
|
9
|
-
sanity telemetry status
|
|
10
|
-
`
|
|
11
|
-
|
|
12
|
-
export function telemetryStatusMessage(status: ConsentStatus, {chalk}: CliCommandContext): string {
|
|
13
|
-
switch (status) {
|
|
14
|
-
case 'granted':
|
|
15
|
-
return `Status: ${chalk.green('Enabled')}`
|
|
16
|
-
case 'denied':
|
|
17
|
-
return `Status: ${chalk.red('Disabled')}`
|
|
18
|
-
case 'unset':
|
|
19
|
-
return `Status: ${chalk.yellow('Not set')}`
|
|
20
|
-
default:
|
|
21
|
-
return ''
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function telemetryLearnMoreMessage(status: ConsentStatus): string {
|
|
26
|
-
const url = 'https://www.sanity.io/telemetry'
|
|
27
|
-
|
|
28
|
-
switch (status) {
|
|
29
|
-
case 'granted':
|
|
30
|
-
return `Learn more about the data being collected here:\n${url}`
|
|
31
|
-
default:
|
|
32
|
-
return `Learn more here:\n${url}`
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const telemetryStatusCommand: CliCommandDefinition = {
|
|
37
|
-
name: 'status',
|
|
38
|
-
group: 'telemetry',
|
|
39
|
-
helpText,
|
|
40
|
-
signature: '',
|
|
41
|
-
description: 'Check telemetry consent status for your logged in user',
|
|
42
|
-
action: async (_, context) => {
|
|
43
|
-
const {chalk, output} = context
|
|
44
|
-
// eslint-disable-next-line no-process-env
|
|
45
|
-
const {status, reason} = await resolveConsent({env: process.env})
|
|
46
|
-
|
|
47
|
-
switch (true) {
|
|
48
|
-
case status === 'undetermined' && reason === 'unauthenticated':
|
|
49
|
-
output.print('You need to log in first to see telemetry status.')
|
|
50
|
-
break
|
|
51
|
-
case status === 'undetermined' && reason === 'fetchError':
|
|
52
|
-
output.print(chalk.yellow('Could not fetch telemetry consent status.'))
|
|
53
|
-
break
|
|
54
|
-
case status === 'denied' && reason === 'localOverride':
|
|
55
|
-
output.print(`${telemetryStatusMessage(status, context)}\n`)
|
|
56
|
-
output.print(
|
|
57
|
-
`You've opted out of telemetry data collection.\nNo data will be collected from your machine.\n`,
|
|
58
|
-
)
|
|
59
|
-
output.print(`Using ${chalk.cyan('DO_NOT_TRACK')} environment variable.`)
|
|
60
|
-
break
|
|
61
|
-
case status === 'denied':
|
|
62
|
-
output.print(`${telemetryStatusMessage(status, context)}\n`)
|
|
63
|
-
output.print(
|
|
64
|
-
`You've opted out of telemetry data collection.\nNo data will be collected from your Sanity account.`,
|
|
65
|
-
)
|
|
66
|
-
break
|
|
67
|
-
case status === 'granted':
|
|
68
|
-
output.print(`${telemetryStatusMessage(status, context)}\n`)
|
|
69
|
-
output.print(
|
|
70
|
-
'Telemetry data on general usage and errors is collected to help us improve Sanity.',
|
|
71
|
-
)
|
|
72
|
-
break
|
|
73
|
-
case status === 'unset':
|
|
74
|
-
output.print(`${telemetryStatusMessage(status, context)}\n`)
|
|
75
|
-
output.print(`You've not set your preference for telemetry collection.\n`)
|
|
76
|
-
output.print(`Run ${chalk.cyan('npx sanity telemetry enable/disable')} to opt in or out.`)
|
|
77
|
-
output.print(
|
|
78
|
-
`You can also use the ${chalk.cyan('DO_NOT_TRACK')} environment variable to opt out.`,
|
|
79
|
-
)
|
|
80
|
-
break
|
|
81
|
-
default:
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
output.print(`\n${telemetryLearnMoreMessage(status)}`)
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default telemetryStatusCommand
|