@sanity/cli 3.44.1-canary.21 → 3.44.1-canary.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "3.44.1-canary.21+755294d534",
3
+ "version": "3.44.1-canary.30+a154d9ea75",
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.19.1",
61
- "@sanity/codegen": "3.44.1-canary.21+755294d534",
61
+ "@sanity/codegen": "3.44.1-canary.30+a154d9ea75",
62
62
  "@sanity/telemetry": "^0.7.7",
63
- "@sanity/util": "3.44.1-canary.21+755294d534",
63
+ "@sanity/util": "3.44.1-canary.30+a154d9ea75",
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.44.1-canary.21+755294d534",
85
+ "@sanity/types": "3.44.1-canary.30+a154d9ea75",
86
86
  "@types/babel__traverse": "^7.20.5",
87
87
  "@types/configstore": "^5.0.1",
88
88
  "@types/cpx": "^1.5.2",
@@ -135,5 +135,5 @@
135
135
  "engines": {
136
136
  "node": ">=18"
137
137
  },
138
- "gitHead": "755294d53490488afc37f19100b00172bf48a3f6"
138
+ "gitHead": "a154d9ea757f553d108217bb3dfe76af4bda4e19"
139
139
  }
@@ -21,6 +21,8 @@ import {
21
21
  installNewPackages,
22
22
  } from '../../packageManager'
23
23
  import {
24
+ ALLOWED_PACKAGE_MANAGERS,
25
+ allowedPackageManagersString,
24
26
  getPartialEnvWithNpmPath,
25
27
  type PackageManager,
26
28
  } from '../../packageManager/packageManagerChoice'
@@ -133,6 +135,7 @@ export default async function initSanity(
133
135
  const useGit = typeof commitMessage === 'undefined' ? true : Boolean(commitMessage)
134
136
  const bareOutput = cliFlags.bare
135
137
  const env = cliFlags.env
138
+ const packageManager = cliFlags['package-manager']
136
139
 
137
140
  let defaultConfig = cliFlags['dataset-default']
138
141
  let showDefaultConfigPrompt = !defaultConfig
@@ -458,8 +461,6 @@ export default async function initSanity(
458
461
 
459
462
  // eslint-disable-next-line no-process-exit
460
463
  process.exit(0)
461
-
462
- return
463
464
  }
464
465
 
465
466
  // eslint-disable-next-line @typescript-eslint/no-shadow
@@ -542,15 +543,35 @@ export default async function initSanity(
542
543
  // Bootstrap Sanity, creating required project files, manifests etc
543
544
  await bootstrapTemplate(templateOptions, context)
544
545
 
545
- // Now for the slow part... installing dependencies
546
- const pkgManager = await getPackageManagerChoice(outputPath, {
547
- prompt,
548
- interactive: unattended ? false : isInteractive,
549
- })
546
+ let pkgManager: PackageManager
547
+
548
+ // If the user has specified a package manager, and it's allowed use that
549
+ if (packageManager && ALLOWED_PACKAGE_MANAGERS.includes(packageManager)) {
550
+ pkgManager = packageManager
551
+ } else {
552
+ // Otherwise, try to find the most optimal package manager to use
553
+ pkgManager = (
554
+ await getPackageManagerChoice(outputPath, {
555
+ prompt,
556
+ interactive: unattended ? false : isInteractive,
557
+ })
558
+ ).chosen
550
559
 
551
- trace.log({step: 'selectPackageManager', selectedOption: pkgManager.chosen})
560
+ // only log warning if a package manager flag is passed
561
+ if (packageManager) {
562
+ output.warn(
563
+ chalk.yellow(
564
+ `Given package manager "${packageManager}" is not supported. Supported package managers are ${allowedPackageManagersString}.`,
565
+ ),
566
+ )
567
+ output.print(`Using ${pkgManager} as package manager`)
568
+ }
569
+ }
570
+
571
+ trace.log({step: 'selectPackageManager', selectedOption: pkgManager})
552
572
 
553
- await installDeclaredPackages(outputPath, pkgManager.chosen, context)
573
+ // Now for the slow part... installing dependencies
574
+ await installDeclaredPackages(outputPath, pkgManager, context)
554
575
 
555
576
  // Try initializing a git repository
556
577
  if (useGit) {
@@ -585,7 +606,7 @@ export default async function initSanity(
585
606
  bun: 'bun dev',
586
607
  manual: 'npm run dev',
587
608
  }
588
- const devCommand = devCommandMap[pkgManager.chosen]
609
+ const devCommand = devCommandMap[pkgManager]
589
610
 
590
611
  const isCurrentDir = outputPath === process.cwd()
591
612
  if (isCurrentDir) {
@@ -3,6 +3,10 @@ import {detectFrameworkRecord, LocalFileSystemDetector} from '@vercel/fs-detecto
3
3
 
4
4
  import initPlugin from '../../actions/init-plugin/initPlugin'
5
5
  import initProject from '../../actions/init-project/initProject'
6
+ import {
7
+ allowedPackageManagersString,
8
+ type PackageManager,
9
+ } from '../../packageManager/packageManagerChoice'
6
10
  import {type CliCommandDefinition} from '../../types'
7
11
 
8
12
  const helpText = `
@@ -22,6 +26,7 @@ Options
22
26
  --project-plan <name> Optionally select a plan for a new project
23
27
  --coupon <name> Optionally select a coupon for a new project (cannot be used with --project-plan)
24
28
  --no-typescript Do not use TypeScript for template files
29
+ --package-manager <name> Specify which package manager to use [allowed: ${allowedPackageManagersString}]
25
30
 
26
31
  Examples
27
32
  # Initialize a new project, prompt for required information along the way
@@ -80,6 +85,8 @@ export interface InitFlags {
80
85
  'reconfigure'?: boolean
81
86
 
82
87
  'organization'?: string
88
+
89
+ 'package-manager'?: PackageManager
83
90
  }
84
91
 
85
92
  export const initCommand: CliCommandDefinition<InitFlags> = {
@@ -9,6 +9,11 @@ import {isInteractive} from '../util/isInteractive'
9
9
 
10
10
  export type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'manual'
11
11
 
12
+ export const ALLOWED_PACKAGE_MANAGERS: PackageManager[] = ['npm', 'yarn', 'pnpm', 'bun', 'manual']
13
+ export const allowedPackageManagersString = ALLOWED_PACKAGE_MANAGERS.map((pm) => `"${pm}"`).join(
14
+ ' | ',
15
+ )
16
+
12
17
  const EXPERIMENTAL = ['bun']
13
18
 
14
19
  /**