@sanity/cli 3.42.2-canary.38 → 3.42.2-canary.47
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 +15 -33
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +0 -1
- package/lib/index.d.ts +0 -1
- package/package.json +5 -5
- package/src/actions/init-project/initProject.ts +8 -14
- package/src/actions/init-project/prompts/nextjs.ts +0 -8
- package/src/actions/init-project/templates/nextjs/index.ts +11 -26
- package/src/types.ts +0 -2
- package/bin/xdg-open +0 -1066
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.42.2-canary.
|
3
|
+
"version": "3.42.2-canary.47+efe8bcae60",
|
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.18.2",
|
61
|
-
"@sanity/codegen": "3.42.2-canary.
|
61
|
+
"@sanity/codegen": "3.42.2-canary.47+efe8bcae60",
|
62
62
|
"@sanity/telemetry": "^0.7.6",
|
63
|
-
"@sanity/util": "3.42.2-canary.
|
63
|
+
"@sanity/util": "3.42.2-canary.47+efe8bcae60",
|
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.42.2-canary.
|
85
|
+
"@sanity/types": "3.42.2-canary.47+efe8bcae60",
|
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": "
|
138
|
+
"gitHead": "efe8bcae60fd92c1624252e05811dfd85f3474c1"
|
139
139
|
}
|
@@ -48,7 +48,6 @@ import {tryGitInit} from './git'
|
|
48
48
|
import {promptForDatasetName} from './promptForDatasetName'
|
49
49
|
import {promptForAclMode, promptForDefaultConfig, promptForTypeScript} from './prompts'
|
50
50
|
import {
|
51
|
-
promptForAppDir,
|
52
51
|
promptForAppendEnv,
|
53
52
|
promptForEmbeddedStudio,
|
54
53
|
promptForNextTemplate,
|
@@ -60,8 +59,7 @@ import {
|
|
60
59
|
sanityCliTemplate,
|
61
60
|
sanityConfigTemplate,
|
62
61
|
sanityFolder,
|
63
|
-
|
64
|
-
sanityStudioPagesTemplate,
|
62
|
+
sanityStudioTemplate,
|
65
63
|
} from './templates/nextjs'
|
66
64
|
|
67
65
|
// eslint-disable-next-line no-process-env
|
@@ -330,12 +328,8 @@ export default async function initSanity(
|
|
330
328
|
const embeddedStudio = unattended ? true : await promptForEmbeddedStudio(prompt)
|
331
329
|
|
332
330
|
if (embeddedStudio) {
|
333
|
-
//
|
334
|
-
|
335
|
-
const useAppDir = unattended ? false : await promptForAppDir(prompt)
|
336
|
-
|
337
|
-
// find source path (app or pages dir)
|
338
|
-
const srcDir = useAppDir ? 'app' : 'pages'
|
331
|
+
// find source path (app or src/app)
|
332
|
+
const srcDir = 'app'
|
339
333
|
let srcPath = path.join(workDir, srcDir)
|
340
334
|
|
341
335
|
if (!existsSync(srcPath)) {
|
@@ -352,7 +346,7 @@ export default async function initSanity(
|
|
352
346
|
const embeddedStudioRouteFilePath = path.join(
|
353
347
|
srcPath,
|
354
348
|
`${studioPath}/`,
|
355
|
-
|
349
|
+
`[[...tool]]/page.${fileExtension}x`,
|
356
350
|
)
|
357
351
|
|
358
352
|
// this selects the correct template string based on whether the user is using the app or pages directory and
|
@@ -361,7 +355,7 @@ export default async function initSanity(
|
|
361
355
|
// relative paths to reach the root level of the project
|
362
356
|
await writeOrOverwrite(
|
363
357
|
embeddedStudioRouteFilePath,
|
364
|
-
|
358
|
+
sanityStudioTemplate.replace(
|
365
359
|
':configPath:',
|
366
360
|
new Array(countNestedFolders(embeddedStudioRouteFilePath.slice(workDir.length)))
|
367
361
|
.join('../')
|
@@ -451,11 +445,11 @@ export default async function initSanity(
|
|
451
445
|
}
|
452
446
|
|
453
447
|
if (chosen === 'npm') {
|
454
|
-
await execa('npm', ['install', 'next-sanity@
|
448
|
+
await execa('npm', ['install', 'next-sanity@9'], execOptions)
|
455
449
|
} else if (chosen === 'yarn') {
|
456
|
-
await execa('npx', ['install-peerdeps', '--yarn', 'next-sanity@
|
450
|
+
await execa('npx', ['install-peerdeps', '--yarn', 'next-sanity@9'], execOptions)
|
457
451
|
} else if (chosen === 'pnpm') {
|
458
|
-
await execa('pnpm', ['install', 'next-sanity@
|
452
|
+
await execa('pnpm', ['install', 'next-sanity@9'], execOptions)
|
459
453
|
}
|
460
454
|
|
461
455
|
print(
|
@@ -8,14 +8,6 @@ export function promptForEmbeddedStudio(prompt: CliPrompter): Promise<string> {
|
|
8
8
|
})
|
9
9
|
}
|
10
10
|
|
11
|
-
export function promptForAppDir(prompt: CliPrompter): Promise<string> {
|
12
|
-
return prompt.single({
|
13
|
-
type: 'confirm',
|
14
|
-
message: `Would you like to use the Next.js app directory for routes?`,
|
15
|
-
default: false,
|
16
|
-
})
|
17
|
-
}
|
18
|
-
|
19
11
|
export function promptForStudioPath(prompt: CliPrompter): Promise<string> {
|
20
12
|
return prompt.single({
|
21
13
|
type: 'input',
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import {blogSchemaFolder, blogSchemaJS, blogSchemaTS} from './schemaTypes/blog'
|
2
2
|
|
3
|
-
export const sanityConfigTemplate =
|
3
|
+
export const sanityConfigTemplate = `'use client'
|
4
|
+
|
5
|
+
/**
|
4
6
|
* This configuration is used to for the Sanity Studio that’s mounted on the \`:route:\` route
|
5
7
|
*/
|
6
8
|
|
@@ -39,27 +41,7 @@ const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET
|
|
39
41
|
export default defineCliConfig({ api: { projectId, dataset } })
|
40
42
|
`
|
41
43
|
|
42
|
-
export const
|
43
|
-
import { NextStudio } from 'next-sanity/studio'
|
44
|
-
import { metadata } from 'next-sanity/studio/metadata'
|
45
|
-
import config from ':configPath:'
|
46
|
-
|
47
|
-
export default function StudioPage() {
|
48
|
-
return (
|
49
|
-
<>
|
50
|
-
<Head>
|
51
|
-
{Object.entries(metadata).map(([key, value]) => (
|
52
|
-
<meta key={key} name={key} content={value} />
|
53
|
-
))}
|
54
|
-
</Head>
|
55
|
-
<NextStudio config={config} />
|
56
|
-
</>
|
57
|
-
)
|
58
|
-
}`
|
59
|
-
|
60
|
-
export const sanityStudioAppTemplate = `'use client'
|
61
|
-
|
62
|
-
/**
|
44
|
+
export const sanityStudioTemplate = `/**
|
63
45
|
* This route is responsible for the built-in authoring environment using Sanity Studio.
|
64
46
|
* All routes under your studio path is handled by this file using Next.js' catch-all routes:
|
65
47
|
* https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
|
@@ -71,12 +53,14 @@ export const sanityStudioAppTemplate = `'use client'
|
|
71
53
|
import { NextStudio } from 'next-sanity/studio'
|
72
54
|
import config from ':configPath:'
|
73
55
|
|
56
|
+
export const dynamic = 'force-static'
|
57
|
+
|
58
|
+
export { metadata, viewport } from 'next-sanity/studio'
|
59
|
+
|
74
60
|
export default function StudioPage() {
|
75
61
|
return <NextStudio config={config} />
|
76
62
|
}`
|
77
63
|
|
78
|
-
export const sanityStudioAppLayoutTemplate = `export {metadata} from 'next-sanity/studio'`
|
79
|
-
|
80
64
|
// Format today's date like YYYY-MM-DD
|
81
65
|
const envTS = `export const apiVersion =
|
82
66
|
process.env.NEXT_PUBLIC_SANITY_API_VERSION || '${new Date().toISOString().split('T')[0]}'
|
@@ -127,10 +111,11 @@ const client = `import { createClient } from 'next-sanity'
|
|
127
111
|
import { apiVersion, dataset, projectId, useCdn } from '../env'
|
128
112
|
|
129
113
|
export const client = createClient({
|
130
|
-
apiVersion,
|
131
|
-
dataset,
|
132
114
|
projectId,
|
115
|
+
dataset,
|
116
|
+
apiVersion,
|
133
117
|
useCdn,
|
118
|
+
perspective: 'published',
|
134
119
|
})
|
135
120
|
`
|
136
121
|
|