@sanity/cli 3.42.2-canary.47 → 3.42.2-sdx-1339.35
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
CHANGED
@@ -43314,6 +43314,13 @@ function promptForEmbeddedStudio(prompt2) {
|
|
43314
43314
|
default: !0
|
43315
43315
|
});
|
43316
43316
|
}
|
43317
|
+
function promptForAppDir(prompt2) {
|
43318
|
+
return prompt2.single({
|
43319
|
+
type: "confirm",
|
43320
|
+
message: "Would you like to use the Next.js app directory for routes?",
|
43321
|
+
default: !1
|
43322
|
+
});
|
43323
|
+
}
|
43317
43324
|
function promptForStudioPath(prompt2) {
|
43318
43325
|
return prompt2.single({
|
43319
43326
|
type: "input",
|
@@ -44039,9 +44046,7 @@ export const schema = {
|
|
44039
44046
|
"blockContent.": useTypeScript ? blockContentTS : blockContentJS,
|
44040
44047
|
"category.": useTypeScript ? categoryTS : categoryJS,
|
44041
44048
|
"post.": useTypeScript ? postTS : postJS
|
44042
|
-
}), sanityConfigTemplate =
|
44043
|
-
|
44044
|
-
/**
|
44049
|
+
}), sanityConfigTemplate = `/**
|
44045
44050
|
* This configuration is used to for the Sanity Studio that\u2019s mounted on the \`:route:\` route
|
44046
44051
|
*/
|
44047
44052
|
|
@@ -44076,7 +44081,25 @@ const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID
|
|
44076
44081
|
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET
|
44077
44082
|
|
44078
44083
|
export default defineCliConfig({ api: { projectId, dataset } })
|
44079
|
-
`,
|
44084
|
+
`, sanityStudioPagesTemplate = `import Head from 'next/head'
|
44085
|
+
import { NextStudio } from 'next-sanity/studio'
|
44086
|
+
import { metadata } from 'next-sanity/studio/metadata'
|
44087
|
+
import config from ':configPath:'
|
44088
|
+
|
44089
|
+
export default function StudioPage() {
|
44090
|
+
return (
|
44091
|
+
<>
|
44092
|
+
<Head>
|
44093
|
+
{Object.entries(metadata).map(([key, value]) => (
|
44094
|
+
<meta key={key} name={key} content={value} />
|
44095
|
+
))}
|
44096
|
+
</Head>
|
44097
|
+
<NextStudio config={config} />
|
44098
|
+
</>
|
44099
|
+
)
|
44100
|
+
}`, sanityStudioAppTemplate = `'use client'
|
44101
|
+
|
44102
|
+
/**
|
44080
44103
|
* This route is responsible for the built-in authoring environment using Sanity Studio.
|
44081
44104
|
* All routes under your studio path is handled by this file using Next.js' catch-all routes:
|
44082
44105
|
* https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
|
@@ -44088,10 +44111,6 @@ export default defineCliConfig({ api: { projectId, dataset } })
|
|
44088
44111
|
import { NextStudio } from 'next-sanity/studio'
|
44089
44112
|
import config from ':configPath:'
|
44090
44113
|
|
44091
|
-
export const dynamic = 'force-static'
|
44092
|
-
|
44093
|
-
export { metadata, viewport } from 'next-sanity/studio'
|
44094
|
-
|
44095
44114
|
export default function StudioPage() {
|
44096
44115
|
return <NextStudio config={config} />
|
44097
44116
|
}`, envTS = `export const apiVersion =
|
@@ -44135,11 +44154,10 @@ export const schema: { types: SchemaTypeDefinition[] } = {
|
|
44135
44154
|
import { apiVersion, dataset, projectId, useCdn } from '../env'
|
44136
44155
|
|
44137
44156
|
export const client = createClient({
|
44138
|
-
projectId,
|
44139
|
-
dataset,
|
44140
44157
|
apiVersion,
|
44158
|
+
dataset,
|
44159
|
+
projectId,
|
44141
44160
|
useCdn,
|
44142
|
-
perspective: 'published',
|
44143
44161
|
})
|
44144
44162
|
`, imageTS = `import createImageUrlBuilder from '@sanity/image-url'
|
44145
44163
|
import type { Image } from 'sanity'
|
@@ -44306,17 +44324,17 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
44306
44324
|
trace.log({ step: "useTypeScript", selectedOption: useTypeScript2 ? "yes" : "no" });
|
44307
44325
|
const fileExtension = useTypeScript2 ? "ts" : "js";
|
44308
44326
|
if (unattended || await promptForEmbeddedStudio(prompt2)) {
|
44309
|
-
const srcDir = "app";
|
44327
|
+
const useAppDir = unattended ? !1 : await promptForAppDir(prompt2), srcDir = useAppDir ? "app" : "pages";
|
44310
44328
|
let srcPath = path__default.default.join(workDir, srcDir);
|
44311
44329
|
fs$r.existsSync(srcPath) || (srcPath = path__default.default.join(workDir, "src", srcDir), fs$r.existsSync(srcPath) || await fs__default$1.default.mkdir(srcPath, { recursive: !0 }).catch(() => loadEnv.debug("Error creating folder %s", srcPath)));
|
44312
44330
|
const studioPath = unattended ? "/studio" : await promptForStudioPath(prompt2), embeddedStudioRouteFilePath = path__default.default.join(
|
44313
44331
|
srcPath,
|
44314
44332
|
`${studioPath}/`,
|
44315
|
-
`[[...
|
44333
|
+
useAppDir ? `[[...index]]/page.${fileExtension}x` : `[[...index]].${fileExtension}x`
|
44316
44334
|
);
|
44317
44335
|
await writeOrOverwrite(
|
44318
44336
|
embeddedStudioRouteFilePath,
|
44319
|
-
|
44337
|
+
(useAppDir ? sanityStudioAppTemplate : sanityStudioPagesTemplate).replace(
|
44320
44338
|
":configPath:",
|
44321
44339
|
new Array(countNestedFolders(embeddedStudioRouteFilePath.slice(workDir.length))).join("../").concat("sanity.config")
|
44322
44340
|
)
|
@@ -44366,7 +44384,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
44366
44384
|
cwd: workDir,
|
44367
44385
|
stdio: "inherit"
|
44368
44386
|
};
|
44369
|
-
chosen === "npm" ? await execa$1("npm", ["install", "next-sanity@
|
44387
|
+
chosen === "npm" ? await execa$1("npm", ["install", "next-sanity@7"], execOptions) : chosen === "yarn" ? await execa$1("npx", ["install-peerdeps", "--yarn", "next-sanity@7"], execOptions) : chosen === "pnpm" && await execa$1("pnpm", ["install", "next-sanity@7"], execOptions), print(
|
44370
44388
|
`
|
44371
44389
|
${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
|
44372
44390
|
), process.exit(0);
|