@sanity/cli 3.68.4-corel.527 → 3.69.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 +21 -20
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/workers/getCliConfig.js.map +1 -1
- package/package.json +7 -7
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +16 -4
- package/src/actions/init-project/initProject.ts +1 -1
- package/src/util/remoteTemplate.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getCliConfig.js","sources":["../../src/workers/getCliConfig.ts"],"sourcesContent":["import {parentPort, workerData} from 'node:worker_threads'\n\nimport {getCliConfig} from '../util/getCliConfig'\n\n// We're communicating with a parent process through a message channel\ngetCliConfig(workerData, {forked: false})\n .then((config) => parentPort?.postMessage({type: 'config', config}))\n .catch((error) =>\n parentPort?.postMessage({\n type: 'error',\n error: error instanceof Error ? error.stack : error,\n errorType: error && (error.type || error.name),\n }),\n )\n"],"names":["getCliConfig","workerData","parentPort"],"mappings":";;AAKAA,aAAAA,aAAaC,oBAAAA,YAAY,EAAC,QAAQ,
|
1
|
+
{"version":3,"file":"getCliConfig.js","sources":["../../src/workers/getCliConfig.ts"],"sourcesContent":["import {parentPort, workerData} from 'node:worker_threads'\n\nimport {getCliConfig} from '../util/getCliConfig'\n\n// We're communicating with a parent process through a message channel\ngetCliConfig(workerData, {forked: false})\n .then((config) => parentPort?.postMessage({type: 'config', config}))\n .catch((error) =>\n parentPort?.postMessage({\n type: 'error',\n error: error instanceof Error ? error.stack : error,\n errorType: error && (error.type || error.name),\n }),\n )\n"],"names":["getCliConfig","workerData","parentPort"],"mappings":";;AAKAA,aAAAA,aAAaC,oBAAAA,YAAY,EAAC,QAAQ,GAAK,CAAC,EACrC,KAAK,CAAC,WAAWC,oBAAAA,YAAY,YAAY,EAAC,MAAM,UAAU,OAAM,CAAC,CAAC,EAClE;AAAA,EAAM,CAAC,UACNA,oBAAA,YAAY,YAAY;AAAA,IACtB,MAAM;AAAA,IACN,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,IAC9C,WAAW,UAAU,MAAM,QAAQ,MAAM;AAAA,EAC1C,CAAA;AACH;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.69.0",
|
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.
|
61
|
+
"@sanity/codegen": "3.69.0",
|
62
62
|
"@sanity/telemetry": "^0.7.7",
|
63
63
|
"@sanity/template-validator": "^2.0.0",
|
64
|
-
"@sanity/util": "3.
|
64
|
+
"@sanity/util": "3.69.0",
|
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.
|
79
|
-
"@repo/test-config": "3.
|
78
|
+
"@repo/package.config": "3.69.0",
|
79
|
+
"@repo/test-config": "3.69.0",
|
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.
|
84
|
+
"@sanity/types": "3.69.0",
|
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": "
|
136
|
+
"gitHead": "55aff5d4304c8dd5f32aadd54d86718afe2fc63b"
|
137
137
|
}
|
@@ -30,6 +30,8 @@ export interface BootstrapRemoteOptions {
|
|
30
30
|
variables: GenerateConfigOptions['variables']
|
31
31
|
}
|
32
32
|
|
33
|
+
const SANITY_DEFAULT_PORT = 3333
|
34
|
+
const READ_TOKEN_LABEL = 'Live Preview API'
|
33
35
|
const INITIAL_COMMIT_MESSAGE = 'Initial commit from Sanity CLI'
|
34
36
|
|
35
37
|
export async function bootstrapRemoteTemplate(
|
@@ -45,6 +47,7 @@ export async function bootstrapRemoteTemplate(
|
|
45
47
|
headers.Authorization = `Bearer ${bearerToken}`
|
46
48
|
}
|
47
49
|
const spinner = output.spinner(`Bootstrapping files from template "${name}"`).start()
|
50
|
+
const corsAdded: number[] = [SANITY_DEFAULT_PORT]
|
48
51
|
|
49
52
|
debug('Validating remote template')
|
50
53
|
const fileReader = new GitHubFileReader(contentsUrl, headers)
|
@@ -67,7 +70,7 @@ export async function bootstrapRemoteTemplate(
|
|
67
70
|
|
68
71
|
debug('Applying environment variables')
|
69
72
|
const readToken = needsReadToken
|
70
|
-
? await generateSanityApiReadToken(
|
73
|
+
? await generateSanityApiReadToken(READ_TOKEN_LABEL, variables.projectId, apiClient)
|
71
74
|
: undefined
|
72
75
|
|
73
76
|
for (const pkg of packages ?? ['']) {
|
@@ -76,10 +79,13 @@ export async function bootstrapRemoteTemplate(
|
|
76
79
|
fs: new LocalFileSystemDetector(packagePath),
|
77
80
|
frameworkList: frameworks as readonly Framework[],
|
78
81
|
})
|
79
|
-
const port = getDefaultPortForFramework(packageFramework?.slug)
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
+
const port = getDefaultPortForFramework(packageFramework?.slug)
|
84
|
+
if (corsAdded.includes(port) === false) {
|
85
|
+
debug('Setting CORS origin to http://localhost:%d', port)
|
86
|
+
await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient)
|
87
|
+
corsAdded.push(port)
|
88
|
+
}
|
83
89
|
|
84
90
|
debug('Applying environment variables to %s', pkg)
|
85
91
|
// Next.js uses `.env.local` for local environment variables
|
@@ -97,4 +103,10 @@ export async function bootstrapRemoteTemplate(
|
|
97
103
|
await updateInitialTemplateMetadata(apiClient, variables.projectId, `external-${name}`)
|
98
104
|
|
99
105
|
spinner.succeed()
|
106
|
+
if (corsAdded.length) {
|
107
|
+
output.success(`CORS origins added (${corsAdded.map((p) => `localhost:${p}`).join(', ')})`)
|
108
|
+
}
|
109
|
+
if (readToken) {
|
110
|
+
output.success(`API token generated (${READ_TOKEN_LABEL})`)
|
111
|
+
}
|
100
112
|
}
|
@@ -846,7 +846,7 @@ export default async function initSanity(
|
|
846
846
|
|
847
847
|
const projectChoices = projects.map((project) => ({
|
848
848
|
value: project.id,
|
849
|
-
name: `${project.displayName}
|
849
|
+
name: `${project.displayName} (${project.id})`,
|
850
850
|
}))
|
851
851
|
|
852
852
|
const selected = await prompt.single({
|
@@ -301,7 +301,7 @@ export async function setCorsOrigin(
|
|
301
301
|
await apiClient({api: {projectId}}).request({
|
302
302
|
method: 'POST',
|
303
303
|
url: '/cors',
|
304
|
-
body: {origin: origin, allowCredentials:
|
304
|
+
body: {origin: origin, allowCredentials: true}, // allowCredentials is true to allow for embedded studios if needed
|
305
305
|
})
|
306
306
|
} catch (error) {
|
307
307
|
// Silent fail, it most likely means that the origin is already set
|