@sanity/cli 3.68.2 → 3.68.4-export-comments.33

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.68.2",
3
+ "version": "3.68.4-export-comments.33+b03c9e8c9a",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -58,10 +58,10 @@
58
58
  "dependencies": {
59
59
  "@babel/traverse": "^7.23.5",
60
60
  "@sanity/client": "^6.24.1",
61
- "@sanity/codegen": "3.68.2",
61
+ "@sanity/codegen": "3.68.4-export-comments.33+b03c9e8c9a",
62
62
  "@sanity/telemetry": "^0.7.7",
63
- "@sanity/template-validator": "^1.0.2",
64
- "@sanity/util": "3.68.2",
63
+ "@sanity/template-validator": "^1.2.1",
64
+ "@sanity/util": "3.68.4-export-comments.33+b03c9e8c9a",
65
65
  "chalk": "^4.1.2",
66
66
  "debug": "^4.3.4",
67
67
  "decompress": "^4.2.0",
@@ -75,13 +75,13 @@
75
75
  "validate-npm-package-name": "^3.0.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@repo/package.config": "3.68.2",
79
- "@repo/test-config": "3.68.2",
78
+ "@repo/package.config": "3.68.3",
79
+ "@repo/test-config": "3.68.3",
80
80
  "@rexxars/gitconfiglocal": "^3.0.1",
81
81
  "@rollup/plugin-node-resolve": "^15.2.3",
82
82
  "@sanity/eslint-config-studio": "^4.0.0",
83
83
  "@sanity/generate-help-url": "^3.0.0",
84
- "@sanity/types": "3.68.2",
84
+ "@sanity/types": "3.68.4-export-comments.33+b03c9e8c9a",
85
85
  "@types/babel__traverse": "^7.20.5",
86
86
  "@types/configstore": "^5.0.1",
87
87
  "@types/cpx": "^1.5.2",
@@ -133,5 +133,5 @@
133
133
  "engines": {
134
134
  "node": ">=18"
135
135
  },
136
- "gitHead": "a28a9cf41a5d393d90f750471225fcfe36301f28"
136
+ "gitHead": "b03c9e8c9acbf9ba9dc79bb3c81241101ec3d09d"
137
137
  }
@@ -1,6 +1,7 @@
1
1
  import {mkdir} from 'node:fs/promises'
2
2
  import {join} from 'node:path'
3
3
 
4
+ import {getMonoRepo, GitHubFileReader, validateTemplate} from '@sanity/template-validator'
4
5
  import {type Framework, frameworks} from '@vercel/frameworks'
5
6
  import {detectFrameworkRecord, LocalFileSystemDetector} from '@vercel/fs-detectors'
6
7
 
@@ -12,11 +13,10 @@ import {
12
13
  checkNeedsReadToken,
13
14
  downloadAndExtractRepo,
14
15
  generateSanityApiReadToken,
15
- getPackages,
16
+ getGitHubRawContentUrl,
16
17
  type RepoInfo,
17
18
  setCorsOrigin,
18
19
  tryApplyPackageName,
19
- validateRemoteTemplate,
20
20
  } from '../../util/remoteTemplate'
21
21
  import {type GenerateConfigOptions} from './createStudioConfig'
22
22
  import {tryGitInit} from './git'
@@ -39,11 +39,20 @@ export async function bootstrapRemoteTemplate(
39
39
  const {outputPath, repoInfo, bearerToken, variables, packageName} = opts
40
40
  const {output, apiClient} = context
41
41
  const name = [repoInfo.username, repoInfo.name, repoInfo.filePath].filter(Boolean).join('/')
42
+ const contentsUrl = getGitHubRawContentUrl(repoInfo)
43
+ const headers: Record<string, string> = {}
44
+ if (bearerToken) {
45
+ headers.Authorization = `Bearer ${bearerToken}`
46
+ }
42
47
  const spinner = output.spinner(`Bootstrapping files from template "${name}"`).start()
43
48
 
44
49
  debug('Validating remote template')
45
- const packages = await getPackages(repoInfo, bearerToken)
46
- await validateRemoteTemplate(repoInfo, packages, bearerToken)
50
+ const fileReader = new GitHubFileReader(contentsUrl, headers)
51
+ const packages = await getMonoRepo(fileReader)
52
+ const validation = await validateTemplate(fileReader, packages)
53
+ if (!validation.isValid) {
54
+ throw new Error(validation.errors.join('\n'))
55
+ }
47
56
 
48
57
  debug('Create new directory "%s"', outputPath)
49
58
  await mkdir(outputPath, {recursive: true})
@@ -4,12 +4,7 @@ import {Readable} from 'node:stream'
4
4
  import {pipeline} from 'node:stream/promises'
5
5
  import {type ReadableStream} from 'node:stream/web'
6
6
 
7
- import {
8
- ENV_TEMPLATE_FILES,
9
- getMonoRepo,
10
- REQUIRED_ENV_VAR,
11
- validateSanityTemplate,
12
- } from '@sanity/template-validator'
7
+ import {ENV_TEMPLATE_FILES, REQUIRED_ENV_VAR} from '@sanity/template-validator'
13
8
  import {x} from 'tar'
14
9
 
15
10
  import {debug} from '../debug'
@@ -42,7 +37,7 @@ export type RepoInfo = {
42
37
  filePath: string
43
38
  }
44
39
 
45
- function getGitHubRawContentUrl(repoInfo: RepoInfo): string {
40
+ export function getGitHubRawContentUrl(repoInfo: RepoInfo): string {
46
41
  const {username, name, branch, filePath} = repoInfo
47
42
  return `https://raw.githubusercontent.com/${username}/${name}/${branch}/${filePath}`
48
43
  }
@@ -196,37 +191,6 @@ export async function downloadAndExtractRepo(
196
191
  )
197
192
  }
198
193
 
199
- /**
200
- * Checks if a GitHub repository is a monorepo by examining common monorepo configuration files.
201
- * Supports pnpm workspaces, Lerna, Rush, and npm workspaces (package.json).
202
- * @returns Promise that resolves to an array of package paths/names if monorepo is detected, undefined otherwise
203
- */
204
- export async function getPackages(
205
- repoInfo: RepoInfo,
206
- bearerToken?: string,
207
- ): Promise<string[] | undefined> {
208
- const headers: Record<string, string> = {}
209
- if (bearerToken) {
210
- headers.Authorization = `Bearer ${bearerToken}`
211
- }
212
- return getMonoRepo(getGitHubRawContentUrl(repoInfo), headers)
213
- }
214
-
215
- export async function validateRemoteTemplate(
216
- repoInfo: RepoInfo,
217
- packages: string[] = [''],
218
- bearerToken?: string,
219
- ): Promise<void> {
220
- const headers: Record<string, string> = {}
221
- if (bearerToken) {
222
- headers.Authorization = `Bearer ${bearerToken}`
223
- }
224
- const result = await validateSanityTemplate(getGitHubRawContentUrl(repoInfo), packages, headers)
225
- if (!result.isValid) {
226
- throw new Error(result.errors.join('\n'))
227
- }
228
- }
229
-
230
194
  export async function checkNeedsReadToken(root: string): Promise<boolean> {
231
195
  try {
232
196
  const templatePath = await Promise.any(