@sanity/cli 3.67.1 → 3.67.2-corel.454

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/index.d.mts CHANGED
@@ -149,6 +149,7 @@ declare type CliMajorVersion = 2 | 3
149
149
 
150
150
  export declare interface CliOutputter {
151
151
  print: (...args: unknown[]) => void
152
+ success: (...args: unknown[]) => void
152
153
  warn: (...args: unknown[]) => void
153
154
  error: (...args: unknown[]) => void
154
155
  clear: () => void
package/lib/index.d.ts CHANGED
@@ -149,6 +149,7 @@ declare type CliMajorVersion = 2 | 3
149
149
 
150
150
  export declare interface CliOutputter {
151
151
  print: (...args: unknown[]) => void
152
+ success: (...args: unknown[]) => void
152
153
  warn: (...args: unknown[]) => void
153
154
  error: (...args: unknown[]) => void
154
155
  clear: () => void
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "3.67.1",
3
+ "version": "3.67.2-corel.454+ea86580c76",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -58,9 +58,9 @@
58
58
  "dependencies": {
59
59
  "@babel/traverse": "^7.23.5",
60
60
  "@sanity/client": "^6.24.1",
61
- "@sanity/codegen": "3.67.1",
61
+ "@sanity/codegen": "3.67.2-corel.454+ea86580c76",
62
62
  "@sanity/telemetry": "^0.7.7",
63
- "@sanity/util": "3.67.1",
63
+ "@sanity/util": "3.67.2-corel.454+ea86580c76",
64
64
  "chalk": "^4.1.2",
65
65
  "debug": "^4.3.4",
66
66
  "decompress": "^4.2.0",
@@ -82,7 +82,7 @@
82
82
  "@rollup/plugin-node-resolve": "^15.2.3",
83
83
  "@sanity/eslint-config-studio": "^4.0.0",
84
84
  "@sanity/generate-help-url": "^3.0.0",
85
- "@sanity/types": "3.67.1",
85
+ "@sanity/types": "3.67.2-corel.454+ea86580c76",
86
86
  "@types/babel__traverse": "^7.20.5",
87
87
  "@types/configstore": "^5.0.1",
88
88
  "@types/cpx": "^1.5.2",
@@ -110,7 +110,6 @@
110
110
  "get-latest-version": "^5.0.0",
111
111
  "git-user-info": "^2.0.3",
112
112
  "inquirer": "^6.0.0",
113
- "is-builtin-module": "^3.2.0",
114
113
  "is-installed-globally": "^0.4.0",
115
114
  "leven": "^3.1.0",
116
115
  "lodash": "^4.17.21",
@@ -135,5 +134,5 @@
135
134
  "engines": {
136
135
  "node": ">=18"
137
136
  },
138
- "gitHead": "a643239229a3fb8fc3a50b0dbd0ccc8fb9cd5888"
137
+ "gitHead": "ea86580c76aa4b5f2fefda043afed3168c6a7d82"
139
138
  }
@@ -12,7 +12,6 @@ import pFilter from 'p-filter'
12
12
  import resolveFrom from 'resolve-from'
13
13
  import semver from 'semver'
14
14
  import {evaluate, patch} from 'silver-fleece'
15
- import which from 'which'
16
15
 
17
16
  import {CLIInitStepCompleted} from '../../__telemetry__/init.telemetry'
18
17
  import {type InitFlags} from '../../commands/init/initCommand'
@@ -121,7 +120,8 @@ export default async function initSanity(
121
120
  const cliFlags = args.extOptions
122
121
  const unattended = cliFlags.y || cliFlags.yes
123
122
  const print = unattended ? noop : output.print
124
- const warn = (msg: string) => output.warn(chalk.yellow.bgBlack(msg))
123
+ const success = output.success
124
+ const warn = output.warn
125
125
 
126
126
  const intendedPlan = cliFlags['project-plan']
127
127
  const intendedCoupon = cliFlags.coupon
@@ -258,25 +258,17 @@ export default async function initSanity(
258
258
  if (hasToken) {
259
259
  trace.log({step: 'login', alreadyLoggedIn: true})
260
260
  const user = await getUserData(apiClient)
261
- print('')
262
- print(
263
- `${chalk.gray(" 👤 You're logged in as %s using %s")}`,
264
- user.name,
265
- getProviderName(user.provider),
266
- )
267
- print('')
261
+ success('You are logged in as %s using %s', user.email, getProviderName(user.provider))
268
262
  } else if (!unattended) {
269
263
  trace.log({step: 'login'})
270
264
  await getOrCreateUser()
271
265
  }
272
266
 
273
- let introMessage = "Let's get you started with a new project"
267
+ let introMessage = 'Fetching existing projects'
274
268
  if (cliFlags.quickstart) {
275
- introMessage = "Let's get you started with remote Sanity project"
276
- } else if (remoteTemplateInfo) {
277
- introMessage = "Let's get you started with a remote Sanity template"
269
+ introMessage = "Eject your existing project's Sanity configuration"
278
270
  }
279
- print(` ➡️ ${chalk.gray(introMessage)}`)
271
+ success(introMessage)
280
272
  print('')
281
273
 
282
274
  const flags = await prepareFlags()
@@ -289,7 +281,8 @@ export default async function initSanity(
289
281
 
290
282
  // If user doesn't want to output any template code
291
283
  if (bareOutput) {
292
- print(`\n${chalk.green('Success!')} Below are your project details:\n`)
284
+ success('Below are your project details')
285
+ print('')
293
286
  print(`Project ID: ${chalk.cyan(projectId)}`)
294
287
  print(`Dataset: ${chalk.cyan(datasetName)}`)
295
288
  print(
@@ -659,13 +652,11 @@ export default async function initSanity(
659
652
  context,
660
653
  })
661
654
 
662
- if (await hasGlobalCli()) {
663
- print('')
664
- print('If you want to delete the imported data, use')
665
- print(` ${chalk.cyan(`sanity dataset delete ${datasetName}`)}`)
666
- print('and create a new clean dataset with')
667
- print(` ${chalk.cyan(`sanity dataset create <name>`)}\n`)
668
- }
655
+ print('')
656
+ print('If you want to delete the imported data, use')
657
+ print(` ${chalk.cyan(`npx sanity dataset delete ${datasetName}`)}`)
658
+ print('and create a new clean dataset with')
659
+ print(` ${chalk.cyan(`npx sanity dataset create <name>`)}\n`)
669
660
  }
670
661
 
671
662
  const devCommandMap: Record<PackageManager, string> = {
@@ -687,12 +678,10 @@ export default async function initSanity(
687
678
  print(`Then: ${chalk.cyan(devCommand)} - to run Sanity Studio\n`)
688
679
  }
689
680
 
690
- if (await hasGlobalCli()) {
691
- print(`Other helpful commands`)
692
- print(`sanity docs - to open the documentation in a browser`)
693
- print(`sanity manage - to open the project settings in a browser`)
694
- print(`sanity help - to explore the CLI manual`)
695
- }
681
+ print(`Other helpful commands`)
682
+ print(`npx sanity docs - to open the documentation in a browser`)
683
+ print(`npx sanity manage - to open the project settings in a browser`)
684
+ print(`npx sanity help - to explore the CLI manual`)
696
685
 
697
686
  const sendInvite =
698
687
  isFirstProject &&
@@ -717,16 +706,13 @@ export default async function initSanity(
717
706
  trace.complete()
718
707
 
719
708
  async function getOrCreateUser() {
720
- print(`We can't find any auth credentials in your Sanity config`)
721
- print('- log in or create a new account\n')
709
+ warn('No authentication credentials found in your Sanity config')
710
+ print('')
722
711
 
723
712
  // Provide login options (`sanity login`)
724
713
  const {extOptions, ...otherArgs} = args
725
714
  const loginArgs: CliCommandArguments<LoginFlags> = {...otherArgs, extOptions: {}}
726
715
  await login(loginArgs, {...context, telemetry: trace.newContext('login')})
727
-
728
- print("Good stuff, you're now authenticated. You'll need a project to keep your")
729
- print('datasets and collaborators safe and snug.')
730
716
  }
731
717
 
732
718
  async function getProjectDetails(): Promise<{
@@ -880,7 +866,7 @@ export default async function initSanity(
880
866
  }))
881
867
 
882
868
  const selected = await prompt.single({
883
- message: 'Select project to use',
869
+ message: 'Create a new project or select an existing one',
884
870
  type: 'list',
885
871
  choices: [
886
872
  {value: 'new', name: 'Create new project'},
@@ -1059,20 +1045,20 @@ export default async function initSanity(
1059
1045
  type: 'list',
1060
1046
  choices: [
1061
1047
  {
1062
- value: 'moviedb',
1063
- name: 'Movie project (schema + sample data)',
1064
- },
1065
- {
1066
- value: 'shopify',
1067
- name: 'E-commerce (Shopify)',
1048
+ value: 'clean',
1049
+ name: 'Clean project with no predefined schema types',
1068
1050
  },
1069
1051
  {
1070
1052
  value: 'blog',
1071
1053
  name: 'Blog (schema)',
1072
1054
  },
1073
1055
  {
1074
- value: 'clean',
1075
- name: 'Clean project with no predefined schema types',
1056
+ value: 'shopify',
1057
+ name: 'E-commerce (Shopify)',
1058
+ },
1059
+ {
1060
+ value: 'moviedb',
1061
+ name: 'Movie project (schema + sample data)',
1076
1062
  },
1077
1063
  ],
1078
1064
  })
@@ -1560,12 +1546,3 @@ function getImportCommand(
1560
1546
  !isCommandGroup(cmd) && cmd.name === 'import' && cmd.group === 'dataset',
1561
1547
  )
1562
1548
  }
1563
-
1564
- async function hasGlobalCli(): Promise<boolean> {
1565
- try {
1566
- const globalCliPath = await which('sanity')
1567
- return Boolean(globalCliPath)
1568
- } catch (err) {
1569
- return false
1570
- }
1571
- }
@@ -2,7 +2,6 @@ import http, {type Server} from 'node:http'
2
2
  import os from 'node:os'
3
3
 
4
4
  import {type SanityClient} from '@sanity/client'
5
- import chalk from 'chalk'
6
5
  import open from 'open'
7
6
 
8
7
  import {debug as debugIt} from '../../debug'
@@ -146,7 +145,7 @@ export async function login(
146
145
  })
147
146
  }
148
147
 
149
- output.print(chalk.green('Login successful'))
148
+ output.success('Login successful')
150
149
  trace.complete()
151
150
  }
152
151
 
@@ -335,7 +334,7 @@ async function promptProviders(
335
334
 
336
335
  const provider = await prompt.single({
337
336
  type: 'list',
338
- message: 'Login type',
337
+ message: 'Please log in or create a new account',
339
338
  choices: providers.map((choice) => choice.title),
340
339
  })
341
340
 
@@ -45,7 +45,7 @@ const logoutCommand: CliCommandDefinition = {
45
45
  // Clear cached telemetry consent
46
46
  cfg.delete(TELEMETRY_CONSENT_CONFIG_KEY)
47
47
 
48
- output.print(chalk.green('Logged out'))
48
+ output.success('Logged out')
49
49
  },
50
50
  }
51
51
 
@@ -2,6 +2,10 @@
2
2
  import chalk from 'chalk'
3
3
  import ora, {type Options, type Ora} from 'ora'
4
4
 
5
+ const SYMBOL_CHECK = chalk.green('✓')
6
+ const SYMBOL_WARN = chalk.yellow('⚠')
7
+ const SYMBOL_FAIL = chalk.red('✗')
8
+
5
9
  let isFirstClear = true
6
10
 
7
11
  export default {
@@ -9,15 +13,19 @@ export default {
9
13
  console.log(...args)
10
14
  },
11
15
 
16
+ success(...args: unknown[]): void {
17
+ console.log(`${SYMBOL_CHECK} ${args.join(' ')}`)
18
+ },
19
+
12
20
  warn(...args: unknown[]): void {
13
- console.warn(...args)
21
+ console.warn(`${SYMBOL_WARN} ${args.join(' ')}`)
14
22
  },
15
23
 
16
24
  error(...args: unknown[]): void {
17
25
  if (args[0] instanceof Error) {
18
- console.error(chalk.red(args[0].stack))
26
+ console.error(`${SYMBOL_FAIL} ${chalk.red(args[0].stack)}`)
19
27
  } else {
20
- console.error(...args)
28
+ console.error(`${SYMBOL_FAIL} ${args.join(' ')}`)
21
29
  }
22
30
  },
23
31
 
@@ -28,7 +36,12 @@ export default {
28
36
  isFirstClear = false
29
37
  },
30
38
 
31
- spinner(options: Options | string): Ora {
32
- return ora(options)
39
+ spinner(options: Options): Ora {
40
+ const spinner = ora({...options, spinner: 'dots'})
41
+ // Override the default status methods to use custom symbols instead of emojis
42
+ spinner.succeed = (text?: string) => spinner.stopAndPersist({text, symbol: SYMBOL_CHECK})
43
+ spinner.warn = (text?: string) => spinner.stopAndPersist({text, symbol: SYMBOL_WARN})
44
+ spinner.fail = (text?: string) => spinner.stopAndPersist({text, symbol: SYMBOL_FAIL})
45
+ return spinner
33
46
  },
34
47
  }
package/src/types.ts CHANGED
@@ -150,6 +150,7 @@ export interface CommandRunnerOptions {
150
150
 
151
151
  export interface CliOutputter {
152
152
  print: (...args: unknown[]) => void
153
+ success: (...args: unknown[]) => void
153
154
  warn: (...args: unknown[]) => void
154
155
  error: (...args: unknown[]) => void
155
156
  clear: () => void
@@ -22,12 +22,15 @@ export function generateCommandsDocumentation(
22
22
  const prefix = group === 'default' ? '' : ` ${group}`
23
23
 
24
24
  const rows = [
25
- `usage: sanity${prefix} [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]`,
25
+ `usage: npx sanity${prefix} [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]`,
26
26
  '',
27
27
  'Commands:',
28
28
  ]
29
29
  .concat(commands.map((cmd) => ` ${padEnd(cmd.name, cmdLength + 1)} ${cmd.description}`))
30
- .concat(['', `See 'sanity help${prefix} <command>' for specific information on a subcommand.`])
30
+ .concat([
31
+ '',
32
+ `See 'npx sanity help${prefix} <command>' for specific information on a subcommand.`,
33
+ ])
31
34
 
32
35
  return rows.join('\n')
33
36
  }
@@ -43,14 +46,14 @@ export function generateCommandDocumentation(
43
46
  if (!command) {
44
47
  throw new Error(
45
48
  subCommand
46
- ? `"${subCommand}" is not a subcommand of "${group}". See 'sanity help ${group}'`
49
+ ? `"${subCommand}" is not a subcommand of "${group}". See 'npx sanity help ${group}'`
47
50
  : getNoSuchCommandText(group || command),
48
51
  )
49
52
  }
50
53
 
51
54
  const cmdParts = [group || command.name, subCommand].filter(Boolean).join(' ')
52
55
  return [
53
- `usage: sanity ${cmdParts} ${command.signature}`,
56
+ `usage: npx sanity ${cmdParts} ${command.signature}`,
54
57
  '',
55
58
  ` ${command.description}`,
56
59
  '',