@sanity/cli 6.0.0-alpha.7 → 6.0.0-alpha.8

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.
Files changed (144) hide show
  1. package/README.md +75 -75
  2. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +2 -1
  3. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +1 -1
  4. package/dist/actions/init/bootstrapLocalTemplate.d.ts +13 -0
  5. package/dist/actions/init/bootstrapLocalTemplate.js +136 -0
  6. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -0
  7. package/dist/actions/init/bootstrapRemoteTemplate.d.ts +12 -0
  8. package/dist/actions/init/bootstrapRemoteTemplate.js +109 -0
  9. package/dist/actions/init/bootstrapRemoteTemplate.js.map +1 -0
  10. package/dist/actions/init/bootstrapTemplate.d.ts +18 -0
  11. package/dist/actions/init/bootstrapTemplate.js +32 -0
  12. package/dist/actions/init/bootstrapTemplate.js.map +1 -0
  13. package/dist/actions/init/checkNextJsReactCompatibility.d.ts +9 -0
  14. package/dist/actions/init/checkNextJsReactCompatibility.js +21 -0
  15. package/dist/actions/init/checkNextJsReactCompatibility.js.map +1 -0
  16. package/dist/actions/init/countNestedFolders.d.ts +1 -0
  17. package/dist/actions/init/countNestedFolders.js +6 -0
  18. package/dist/actions/init/countNestedFolders.js.map +1 -0
  19. package/dist/actions/init/createAppCliConfig.d.ts +5 -0
  20. package/dist/actions/init/createAppCliConfig.js +19 -0
  21. package/dist/actions/init/createAppCliConfig.js.map +1 -0
  22. package/dist/actions/init/createCliConfig.d.ts +6 -0
  23. package/dist/actions/init/createCliConfig.js +27 -0
  24. package/dist/actions/init/createCliConfig.js.map +1 -0
  25. package/dist/actions/init/createPackageManifest.d.ts +6 -0
  26. package/dist/actions/init/createPackageManifest.js +86 -0
  27. package/dist/actions/init/createPackageManifest.js.map +1 -0
  28. package/dist/actions/init/createStudioConfig.d.ts +13 -0
  29. package/dist/actions/init/createStudioConfig.js +41 -0
  30. package/dist/actions/init/createStudioConfig.js.map +1 -0
  31. package/dist/actions/init/env/createOrAppendEnvVars.d.ts +12 -0
  32. package/dist/actions/init/env/createOrAppendEnvVars.js +25 -0
  33. package/dist/actions/init/env/createOrAppendEnvVars.js.map +1 -0
  34. package/dist/actions/init/env/parseAndUpdateEnvVars.d.ts +9 -0
  35. package/dist/actions/init/env/parseAndUpdateEnvVars.js +42 -0
  36. package/dist/actions/init/env/parseAndUpdateEnvVars.js.map +1 -0
  37. package/dist/actions/init/env/writeEnvVarsToFile.d.ts +12 -0
  38. package/dist/actions/init/env/writeEnvVarsToFile.js +49 -0
  39. package/dist/actions/init/env/writeEnvVarsToFile.js.map +1 -0
  40. package/dist/actions/init/fetchPostInitPrompt.d.ts +6 -0
  41. package/dist/actions/init/fetchPostInitPrompt.js +30 -0
  42. package/dist/actions/init/fetchPostInitPrompt.js.map +1 -0
  43. package/dist/actions/init/git.d.ts +1 -0
  44. package/dist/actions/init/git.js +65 -0
  45. package/dist/actions/init/git.js.map +1 -0
  46. package/dist/actions/init/processTemplate.d.ts +7 -0
  47. package/dist/actions/init/processTemplate.js +56 -0
  48. package/dist/actions/init/processTemplate.js.map +1 -0
  49. package/dist/actions/init/remoteTemplate.d.ts +0 -3
  50. package/dist/actions/init/remoteTemplate.js +2 -40
  51. package/dist/actions/init/remoteTemplate.js.map +1 -1
  52. package/dist/actions/init/resolvePackageManager.d.ts +10 -0
  53. package/dist/actions/init/resolvePackageManager.js +20 -0
  54. package/dist/actions/init/resolvePackageManager.js.map +1 -0
  55. package/dist/actions/init/setupMCP.d.ts +21 -0
  56. package/dist/actions/init/setupMCP.js +258 -0
  57. package/dist/actions/init/setupMCP.js.map +1 -0
  58. package/dist/actions/init/templates/appQuickstart.d.ts +3 -0
  59. package/dist/actions/init/templates/appQuickstart.js +28 -0
  60. package/dist/actions/init/templates/appQuickstart.js.map +1 -0
  61. package/dist/actions/init/templates/appSanityUi.d.ts +3 -0
  62. package/dist/actions/init/templates/appSanityUi.js +30 -0
  63. package/dist/actions/init/templates/appSanityUi.js.map +1 -0
  64. package/dist/actions/init/templates/blog.d.ts +3 -0
  65. package/dist/actions/init/templates/blog.js +4 -0
  66. package/dist/actions/init/templates/blog.js.map +1 -0
  67. package/dist/actions/init/templates/clean.d.ts +3 -0
  68. package/dist/actions/init/templates/clean.js +4 -0
  69. package/dist/actions/init/templates/clean.js.map +1 -0
  70. package/dist/actions/init/templates/getStarted.d.ts +3 -0
  71. package/dist/actions/init/templates/getStarted.js +35 -0
  72. package/dist/actions/init/templates/getStarted.js.map +1 -0
  73. package/dist/actions/init/templates/index.d.ts +3 -0
  74. package/dist/actions/init/templates/index.js +23 -0
  75. package/dist/actions/init/templates/index.js.map +1 -0
  76. package/dist/actions/init/templates/moviedb.d.ts +3 -0
  77. package/dist/actions/init/templates/moviedb.js +34 -0
  78. package/dist/actions/init/templates/moviedb.js.map +1 -0
  79. package/dist/actions/init/templates/nextjs/index.d.ts +6 -0
  80. package/dist/actions/init/templates/nextjs/index.js +213 -0
  81. package/dist/actions/init/templates/nextjs/index.js.map +1 -0
  82. package/dist/actions/init/templates/nextjs/schemaTypes/blog.d.ts +3 -0
  83. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js +247 -0
  84. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js.map +1 -0
  85. package/dist/actions/init/templates/quickstart.d.ts +3 -0
  86. package/dist/actions/init/templates/quickstart.js +4 -0
  87. package/dist/actions/init/templates/quickstart.js.map +1 -0
  88. package/dist/actions/init/templates/shopify.d.ts +3 -0
  89. package/dist/actions/init/templates/shopify.js +77 -0
  90. package/dist/actions/init/templates/shopify.js.map +1 -0
  91. package/dist/actions/init/templates/shopifyOnline.d.ts +3 -0
  92. package/dist/actions/init/templates/shopifyOnline.js +49 -0
  93. package/dist/actions/init/templates/shopifyOnline.js.map +1 -0
  94. package/dist/actions/init/types.d.ts +15 -0
  95. package/dist/actions/init/types.js +3 -0
  96. package/dist/actions/init/types.js.map +1 -0
  97. package/dist/actions/init/updateInitialTemplateMetadata.d.ts +1 -0
  98. package/dist/actions/init/updateInitialTemplateMetadata.js +17 -0
  99. package/dist/actions/init/updateInitialTemplateMetadata.js.map +1 -0
  100. package/dist/commands/init.d.ts +24 -14
  101. package/dist/commands/init.js +544 -26
  102. package/dist/commands/init.js.map +1 -1
  103. package/dist/prompts/init/nextjs.d.ts +5 -0
  104. package/dist/prompts/init/nextjs.js +56 -0
  105. package/dist/prompts/init/nextjs.js.map +1 -0
  106. package/dist/prompts/init/promptForTypescript.d.ts +0 -1
  107. package/dist/prompts/init/promptForTypescript.js +0 -6
  108. package/dist/prompts/init/promptForTypescript.js.map +1 -1
  109. package/dist/services/mcp.d.ts +10 -0
  110. package/dist/services/mcp.js +16 -0
  111. package/dist/services/mcp.js.map +1 -1
  112. package/dist/services/projects.d.ts +5 -2
  113. package/dist/services/projects.js +37 -0
  114. package/dist/services/projects.js.map +1 -1
  115. package/dist/studioDependencies.d.ts +16 -0
  116. package/dist/studioDependencies.js +24 -0
  117. package/dist/studioDependencies.js.map +1 -0
  118. package/dist/types.d.ts +33 -0
  119. package/dist/types.js.map +1 -1
  120. package/dist/typings/deepSortObject.d.js +2 -0
  121. package/dist/typings/deepSortObject.d.js.map +1 -0
  122. package/dist/util/copy.d.ts +5 -0
  123. package/dist/util/copy.js +37 -0
  124. package/dist/util/copy.js.map +1 -0
  125. package/dist/util/frameworkPort.d.ts +12 -0
  126. package/dist/util/frameworkPort.js +61 -0
  127. package/dist/util/frameworkPort.js.map +1 -0
  128. package/dist/util/fsUtils.d.ts +2 -0
  129. package/dist/util/fsUtils.js +34 -0
  130. package/dist/util/fsUtils.js.map +1 -0
  131. package/dist/util/getProjectDefaults.d.ts +11 -0
  132. package/dist/util/getProjectDefaults.js +77 -0
  133. package/dist/util/getProjectDefaults.js.map +1 -0
  134. package/dist/util/packageManager/packageManagerChoice.d.ts +2 -0
  135. package/dist/util/packageManager/packageManagerChoice.js +8 -0
  136. package/dist/util/packageManager/packageManagerChoice.js.map +1 -1
  137. package/dist/util/readdirRecursive.d.ts +5 -0
  138. package/dist/util/readdirRecursive.js +24 -0
  139. package/dist/util/readdirRecursive.js.map +1 -0
  140. package/dist/util/resolveLatestVersions.d.ts +7 -0
  141. package/dist/util/resolveLatestVersions.js +21 -0
  142. package/dist/util/resolveLatestVersions.js.map +1 -0
  143. package/oclif.manifest.json +36 -29
  144. package/package.json +17 -8
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/index.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\nimport appTemplate from './appQuickstart.js'\nimport appSanityUiTemplate from './appSanityUi.js'\nimport blog from './blog.js'\nimport clean from './clean.js'\nimport getStartedTemplate from './getStarted.js'\nimport moviedb from './moviedb.js'\nimport quickstart from './quickstart.js'\nimport shopify from './shopify.js'\nimport shopifyOnline from './shopifyOnline.js'\n\nconst templates: Record<string, ProjectTemplate | undefined> = {\n 'app-quickstart': appTemplate,\n 'app-sanity-ui': appSanityUiTemplate,\n blog,\n clean,\n 'get-started': getStartedTemplate,\n moviedb,\n quickstart, // empty project that dynamically imports its own schema\n shopify,\n 'shopify-online-storefront': shopifyOnline,\n}\n\nexport default templates\n"],"names":["appTemplate","appSanityUiTemplate","blog","clean","getStartedTemplate","moviedb","quickstart","shopify","shopifyOnline","templates"],"mappings":"AACA,OAAOA,iBAAiB,qBAAoB;AAC5C,OAAOC,yBAAyB,mBAAkB;AAClD,OAAOC,UAAU,YAAW;AAC5B,OAAOC,WAAW,aAAY;AAC9B,OAAOC,wBAAwB,kBAAiB;AAChD,OAAOC,aAAa,eAAc;AAClC,OAAOC,gBAAgB,kBAAiB;AACxC,OAAOC,aAAa,eAAc;AAClC,OAAOC,mBAAmB,qBAAoB;AAE9C,MAAMC,YAAyD;IAC7D,kBAAkBT;IAClB,iBAAiBC;IACjBC;IACAC;IACA,eAAeC;IACfC;IACAC;IACAC;IACA,6BAA6BC;AAC/B;AAEA,eAAeC,UAAS"}
@@ -0,0 +1,3 @@
1
+ import { type ProjectTemplate } from '../types.js';
2
+ declare const movieTemplate: ProjectTemplate;
3
+ export default movieTemplate;
@@ -0,0 +1,34 @@
1
+ const configTemplate = `
2
+ import {defineConfig} from 'sanity'
3
+ import {structureTool} from 'sanity/structure'
4
+ import {visionTool} from '@sanity/vision'
5
+ import {schemaTypes} from './schemaTypes'
6
+
7
+ export default defineConfig({
8
+ name: '%sourceName%',
9
+ title: '%projectName%',
10
+
11
+ projectId: '%projectId%',
12
+ dataset: '%dataset%',
13
+
14
+ plugins: [
15
+ structureTool(),
16
+ visionTool(),
17
+ ],
18
+
19
+ schema: {
20
+ types: schemaTypes,
21
+ },
22
+ })
23
+ `;
24
+ const movieTemplate = {
25
+ configTemplate,
26
+ datasetUrl: 'https://public.sanity.io/moviesdb-2018-03-06.tar.gz',
27
+ dependencies: {
28
+ 'react-icons': '^3.11.0'
29
+ },
30
+ importPrompt: 'Add a sampling of sci-fi movies to your dataset on the hosted backend?'
31
+ };
32
+ export default movieTemplate;
33
+
34
+ //# sourceMappingURL=moviedb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/moviedb.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig} from 'sanity'\nimport {structureTool} from 'sanity/structure'\nimport {visionTool} from '@sanity/vision'\nimport {schemaTypes} from './schemaTypes'\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool(),\n visionTool(),\n ],\n\n schema: {\n types: schemaTypes,\n },\n})\n`\n\nconst movieTemplate: ProjectTemplate = {\n configTemplate,\n datasetUrl: 'https://public.sanity.io/moviesdb-2018-03-06.tar.gz',\n dependencies: {\n 'react-icons': '^3.11.0',\n },\n importPrompt: 'Add a sampling of sci-fi movies to your dataset on the hosted backend?',\n}\nexport default movieTemplate\n"],"names":["configTemplate","movieTemplate","datasetUrl","dependencies","importPrompt"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBxB,CAAC;AAED,MAAMC,gBAAiC;IACrCD;IACAE,YAAY;IACZC,cAAc;QACZ,eAAe;IACjB;IACAC,cAAc;AAChB;AACA,eAAeH,cAAa"}
@@ -0,0 +1,6 @@
1
+ export declare const sanityConfigTemplate: (hasSrcFolder?: boolean) => string;
2
+ export declare const sanityCliTemplate = "/**\n* This configuration file lets you run `$ sanity [command]` in this folder\n* Go to https://www.sanity.io/docs/cli to learn more.\n**/\nimport { defineCliConfig } from 'sanity/cli'\n\nconst projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID\nconst dataset = process.env.NEXT_PUBLIC_SANITY_DATASET\n\nexport default defineCliConfig({ api: { projectId, dataset } })\n";
3
+ export declare const sanityStudioTemplate = "/**\n * This route is responsible for the built-in authoring environment using Sanity Studio.\n * All routes under your studio path is handled by this file using Next.js' catch-all routes:\n * https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes\n *\n * You can learn more about the next-sanity package here:\n * https://github.com/sanity-io/next-sanity\n */\n\nimport { NextStudio } from 'next-sanity/studio'\nimport config from ':configPath:'\n\nexport const dynamic = 'force-static'\n\nexport { metadata, viewport } from 'next-sanity/studio'\n\nexport default function StudioPage() {\n return <NextStudio config={config} />\n}\n";
4
+ type FolderStructure = Record<string, Record<string, string> | string>;
5
+ export declare const sanityFolder: (useTypeScript: boolean, template?: "blog" | "clean") => FolderStructure;
6
+ export {};
@@ -0,0 +1,213 @@
1
+ import { blogSchemaFolder, blogSchemaJS, blogSchemaTS } from './schemaTypes/blog.js';
2
+ export const sanityConfigTemplate = (hasSrcFolder = false)=>`'use client'
3
+
4
+ /**
5
+ * This configuration is used to for the Sanity Studio that’s mounted on the \`:route:\` route
6
+ */
7
+
8
+ import {visionTool} from '@sanity/vision'
9
+ import {defineConfig} from 'sanity'
10
+ import {structureTool} from 'sanity/structure'
11
+
12
+ // Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
13
+ import {apiVersion, dataset, projectId} from ${hasSrcFolder ? "'./src/sanity/env'" : "'./sanity/env'"}
14
+ import {schema} from ${hasSrcFolder ? "'./src/sanity/schemaTypes'" : "'./sanity/schemaTypes'"}
15
+ import {structure} from ${hasSrcFolder ? "'./src/sanity/structure'" : "'./sanity/structure'"}
16
+
17
+ export default defineConfig({
18
+ basePath: ':basePath:',
19
+ projectId,
20
+ dataset,
21
+ // Add and edit the content schema in the './sanity/schemaTypes' folder
22
+ schema,
23
+ plugins: [
24
+ structureTool({structure}),
25
+ // Vision is for querying with GROQ from inside the Studio
26
+ // https://www.sanity.io/docs/the-vision-plugin
27
+ visionTool({defaultApiVersion: apiVersion}),
28
+ ],
29
+ })
30
+ `;
31
+ export const sanityCliTemplate = `/**
32
+ * This configuration file lets you run \`$ sanity [command]\` in this folder
33
+ * Go to https://www.sanity.io/docs/cli to learn more.
34
+ **/
35
+ import { defineCliConfig } from 'sanity/cli'
36
+
37
+ const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID
38
+ const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET
39
+
40
+ export default defineCliConfig({ api: { projectId, dataset } })
41
+ `;
42
+ export const sanityStudioTemplate = `/**
43
+ * This route is responsible for the built-in authoring environment using Sanity Studio.
44
+ * All routes under your studio path is handled by this file using Next.js' catch-all routes:
45
+ * https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
46
+ *
47
+ * You can learn more about the next-sanity package here:
48
+ * https://github.com/sanity-io/next-sanity
49
+ */
50
+
51
+ import { NextStudio } from 'next-sanity/studio'
52
+ import config from ':configPath:'
53
+
54
+ export const dynamic = 'force-static'
55
+
56
+ export { metadata, viewport } from 'next-sanity/studio'
57
+
58
+ export default function StudioPage() {
59
+ return <NextStudio config={config} />
60
+ }
61
+ `;
62
+ // Format today's date like YYYY-MM-DD
63
+ const envTS = `export const apiVersion =
64
+ process.env.NEXT_PUBLIC_SANITY_API_VERSION || '${new Date().toISOString().split('T')[0]}'
65
+
66
+ export const dataset = assertValue(
67
+ process.env.NEXT_PUBLIC_SANITY_DATASET,
68
+ 'Missing environment variable: NEXT_PUBLIC_SANITY_DATASET'
69
+ )
70
+
71
+ export const projectId = assertValue(
72
+ process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
73
+ 'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID'
74
+ )
75
+
76
+ function assertValue<T>(v: T | undefined, errorMessage: string): T {
77
+ if (v === undefined) {
78
+ throw new Error(errorMessage)
79
+ }
80
+
81
+ return v
82
+ }
83
+ `;
84
+ const envJS = `export const apiVersion =
85
+ process.env.NEXT_PUBLIC_SANITY_API_VERSION || '${new Date().toISOString().split('T')[0]}'
86
+
87
+ export const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;
88
+ export const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
89
+ `;
90
+ const schemaTS = `import { type SchemaTypeDefinition } from 'sanity'
91
+
92
+ export const schema: { types: SchemaTypeDefinition[] } = {
93
+ types: [],
94
+ }
95
+ `;
96
+ const schemaJS = `export const schema = {
97
+ types: [],
98
+ }
99
+ `;
100
+ const blogStructureTS = `import type {StructureResolver} from 'sanity/structure'
101
+
102
+ // https://www.sanity.io/docs/structure-builder-cheat-sheet
103
+ export const structure: StructureResolver = (S) =>
104
+ S.list()
105
+ .title('Blog')
106
+ .items([
107
+ S.documentTypeListItem('post').title('Posts'),
108
+ S.documentTypeListItem('category').title('Categories'),
109
+ S.documentTypeListItem('author').title('Authors'),
110
+ S.divider(),
111
+ ...S.documentTypeListItems().filter(
112
+ (item) => item.getId() && !['post', 'category', 'author'].includes(item.getId()!),
113
+ ),
114
+ ])
115
+ `;
116
+ const blogStructureJS = `// https://www.sanity.io/docs/structure-builder-cheat-sheet
117
+ export const structure = (S) =>
118
+ S.list()
119
+ .title('Blog')
120
+ .items([
121
+ S.documentTypeListItem('post').title('Posts'),
122
+ S.documentTypeListItem('category').title('Categories'),
123
+ S.documentTypeListItem('author').title('Authors'),
124
+ S.divider(),
125
+ ...S.documentTypeListItems().filter(
126
+ (item) => item.getId() && !['post', 'category', 'author'].includes(item.getId()),
127
+ ),
128
+ ])
129
+ `;
130
+ const structureTS = `import type {StructureResolver} from 'sanity/structure'
131
+
132
+ // https://www.sanity.io/docs/structure-builder-cheat-sheet
133
+ export const structure: StructureResolver = (S) =>
134
+ S.list()
135
+ .title('Content')
136
+ .items(S.documentTypeListItems())
137
+ `;
138
+ const structureJS = `// https://www.sanity.io/docs/structure-builder-cheat-sheet
139
+ export const structure = (S) =>
140
+ S.list()
141
+ .title('Content')
142
+ .items(S.documentTypeListItems())
143
+ `;
144
+ const client = `import { createClient } from 'next-sanity'
145
+
146
+ import { apiVersion, dataset, projectId } from '../env'
147
+
148
+ export const client = createClient({
149
+ projectId,
150
+ dataset,
151
+ apiVersion,
152
+ useCdn: true, // Set to false if statically generating pages, using ISR or tag-based revalidation
153
+ })
154
+ `;
155
+ const live = `// Querying with "sanityFetch" will keep content automatically updated
156
+ // Before using it, import and render "<SanityLive />" in your layout, see
157
+ // https://github.com/sanity-io/next-sanity#live-content-api for more information.
158
+ import { defineLive } from "next-sanity/live";
159
+ import { client } from './client'
160
+
161
+ export const { sanityFetch, SanityLive } = defineLive({
162
+ client,
163
+ });
164
+ `;
165
+ const imageTS = `import createImageUrlBuilder from '@sanity/image-url'
166
+ import { SanityImageSource } from "@sanity/image-url/lib/types/types";
167
+
168
+ import { dataset, projectId } from '../env'
169
+
170
+ // https://www.sanity.io/docs/image-url
171
+ const builder = createImageUrlBuilder({ projectId, dataset })
172
+
173
+ export const urlFor = (source: SanityImageSource) => {
174
+ return builder.image(source)
175
+ }
176
+ `;
177
+ const imageJS = `import createImageUrlBuilder from '@sanity/image-url'
178
+
179
+ import { dataset, projectId } from '../env'
180
+
181
+ // https://www.sanity.io/docs/image-url
182
+ const builder = createImageUrlBuilder({ projectId, dataset })
183
+
184
+ export const urlFor = (source) => {
185
+ return builder.image(source)
186
+ }
187
+ `;
188
+ export const sanityFolder = (useTypeScript, template)=>{
189
+ // Files used in both templates
190
+ const structure = {
191
+ 'env.': useTypeScript ? envTS : envJS,
192
+ lib: {
193
+ 'client.': client,
194
+ 'image.': useTypeScript ? imageTS : imageJS,
195
+ 'live.': live
196
+ }
197
+ };
198
+ if (template === 'blog') {
199
+ structure.schemaTypes = {
200
+ ...blogSchemaFolder,
201
+ 'index.': useTypeScript ? blogSchemaTS : blogSchemaJS
202
+ };
203
+ structure['structure.'] = useTypeScript ? blogStructureTS : blogStructureJS;
204
+ } else {
205
+ structure.schemaTypes = {
206
+ 'index.': useTypeScript ? schemaTS : schemaJS
207
+ };
208
+ structure['structure.'] = useTypeScript ? structureTS : structureJS;
209
+ }
210
+ return structure;
211
+ };
212
+
213
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/actions/init/templates/nextjs/index.ts"],"sourcesContent":["import {blogSchemaFolder, blogSchemaJS, blogSchemaTS} from './schemaTypes/blog.js'\n\nexport const sanityConfigTemplate = (hasSrcFolder = false): string => `'use client'\n\n/**\n * This configuration is used to for the Sanity Studio that’s mounted on the \\`:route:\\` route\n */\n\nimport {visionTool} from '@sanity/vision'\nimport {defineConfig} from 'sanity'\nimport {structureTool} from 'sanity/structure'\n\n// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works\nimport {apiVersion, dataset, projectId} from ${hasSrcFolder ? \"'./src/sanity/env'\" : \"'./sanity/env'\"}\nimport {schema} from ${hasSrcFolder ? \"'./src/sanity/schemaTypes'\" : \"'./sanity/schemaTypes'\"}\nimport {structure} from ${hasSrcFolder ? \"'./src/sanity/structure'\" : \"'./sanity/structure'\"}\n\nexport default defineConfig({\n basePath: ':basePath:',\n projectId,\n dataset,\n // Add and edit the content schema in the './sanity/schemaTypes' folder\n schema,\n plugins: [\n structureTool({structure}),\n // Vision is for querying with GROQ from inside the Studio\n // https://www.sanity.io/docs/the-vision-plugin\n visionTool({defaultApiVersion: apiVersion}),\n ],\n})\n`\n\nexport const sanityCliTemplate = `/**\n* This configuration file lets you run \\`$ sanity [command]\\` in this folder\n* Go to https://www.sanity.io/docs/cli to learn more.\n**/\nimport { defineCliConfig } from 'sanity/cli'\n\nconst projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID\nconst dataset = process.env.NEXT_PUBLIC_SANITY_DATASET\n\nexport default defineCliConfig({ api: { projectId, dataset } })\n`\n\nexport const sanityStudioTemplate = `/**\n * This route is responsible for the built-in authoring environment using Sanity Studio.\n * All routes under your studio path is handled by this file using Next.js' catch-all routes:\n * https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes\n *\n * You can learn more about the next-sanity package here:\n * https://github.com/sanity-io/next-sanity\n */\n\nimport { NextStudio } from 'next-sanity/studio'\nimport config from ':configPath:'\n\nexport const dynamic = 'force-static'\n\nexport { metadata, viewport } from 'next-sanity/studio'\n\nexport default function StudioPage() {\n return <NextStudio config={config} />\n}\n`\n\n// Format today's date like YYYY-MM-DD\nconst envTS = `export const apiVersion =\n process.env.NEXT_PUBLIC_SANITY_API_VERSION || '${new Date().toISOString().split('T')[0]}'\n\nexport const dataset = assertValue(\n process.env.NEXT_PUBLIC_SANITY_DATASET,\n 'Missing environment variable: NEXT_PUBLIC_SANITY_DATASET'\n)\n\nexport const projectId = assertValue(\n process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,\n 'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID'\n)\n\nfunction assertValue<T>(v: T | undefined, errorMessage: string): T {\n if (v === undefined) {\n throw new Error(errorMessage)\n }\n\n return v\n}\n`\n\nconst envJS = `export const apiVersion =\n process.env.NEXT_PUBLIC_SANITY_API_VERSION || '${new Date().toISOString().split('T')[0]}'\n\nexport const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;\nexport const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;\n`\n\nconst schemaTS = `import { type SchemaTypeDefinition } from 'sanity'\n\nexport const schema: { types: SchemaTypeDefinition[] } = {\n types: [],\n}\n`\n\nconst schemaJS = `export const schema = {\n types: [],\n}\n`\n\nconst blogStructureTS = `import type {StructureResolver} from 'sanity/structure'\n\n// https://www.sanity.io/docs/structure-builder-cheat-sheet\nexport const structure: StructureResolver = (S) =>\n S.list()\n .title('Blog')\n .items([\n S.documentTypeListItem('post').title('Posts'),\n S.documentTypeListItem('category').title('Categories'),\n S.documentTypeListItem('author').title('Authors'),\n S.divider(),\n ...S.documentTypeListItems().filter(\n (item) => item.getId() && !['post', 'category', 'author'].includes(item.getId()!),\n ),\n ])\n`\n\nconst blogStructureJS = `// https://www.sanity.io/docs/structure-builder-cheat-sheet\nexport const structure = (S) =>\n S.list()\n .title('Blog')\n .items([\n S.documentTypeListItem('post').title('Posts'),\n S.documentTypeListItem('category').title('Categories'),\n S.documentTypeListItem('author').title('Authors'),\n S.divider(),\n ...S.documentTypeListItems().filter(\n (item) => item.getId() && !['post', 'category', 'author'].includes(item.getId()),\n ),\n ])\n`\n\nconst structureTS = `import type {StructureResolver} from 'sanity/structure'\n\n// https://www.sanity.io/docs/structure-builder-cheat-sheet\nexport const structure: StructureResolver = (S) =>\n S.list()\n .title('Content')\n .items(S.documentTypeListItems())\n`\n\nconst structureJS = `// https://www.sanity.io/docs/structure-builder-cheat-sheet\nexport const structure = (S) =>\n S.list()\n .title('Content')\n .items(S.documentTypeListItems())\n`\n\nconst client = `import { createClient } from 'next-sanity'\n\nimport { apiVersion, dataset, projectId } from '../env'\n\nexport const client = createClient({\n projectId,\n dataset,\n apiVersion,\n useCdn: true, // Set to false if statically generating pages, using ISR or tag-based revalidation\n})\n`\n\nconst live = `// Querying with \"sanityFetch\" will keep content automatically updated\n// Before using it, import and render \"<SanityLive />\" in your layout, see\n// https://github.com/sanity-io/next-sanity#live-content-api for more information.\nimport { defineLive } from \"next-sanity/live\";\nimport { client } from './client'\n\nexport const { sanityFetch, SanityLive } = defineLive({\n client,\n});\n`\n\nconst imageTS = `import createImageUrlBuilder from '@sanity/image-url'\nimport { SanityImageSource } from \"@sanity/image-url/lib/types/types\";\n\nimport { dataset, projectId } from '../env'\n\n// https://www.sanity.io/docs/image-url\nconst builder = createImageUrlBuilder({ projectId, dataset })\n\nexport const urlFor = (source: SanityImageSource) => {\n return builder.image(source)\n}\n`\n\nconst imageJS = `import createImageUrlBuilder from '@sanity/image-url'\n\nimport { dataset, projectId } from '../env'\n\n// https://www.sanity.io/docs/image-url\nconst builder = createImageUrlBuilder({ projectId, dataset })\n\nexport const urlFor = (source) => {\n return builder.image(source)\n}\n`\n\ntype FolderStructure = Record<string, Record<string, string> | string>\n\nexport const sanityFolder = (\n useTypeScript: boolean,\n template?: 'blog' | 'clean',\n): FolderStructure => {\n // Files used in both templates\n const structure: FolderStructure = {\n 'env.': useTypeScript ? envTS : envJS,\n lib: {\n 'client.': client,\n 'image.': useTypeScript ? imageTS : imageJS,\n 'live.': live,\n },\n }\n\n if (template === 'blog') {\n structure.schemaTypes = {\n ...blogSchemaFolder,\n 'index.': useTypeScript ? blogSchemaTS : blogSchemaJS,\n }\n structure['structure.'] = useTypeScript ? blogStructureTS : blogStructureJS\n } else {\n structure.schemaTypes = {\n 'index.': useTypeScript ? schemaTS : schemaJS,\n }\n structure['structure.'] = useTypeScript ? structureTS : structureJS\n }\n\n return structure\n}\n"],"names":["blogSchemaFolder","blogSchemaJS","blogSchemaTS","sanityConfigTemplate","hasSrcFolder","sanityCliTemplate","sanityStudioTemplate","envTS","Date","toISOString","split","envJS","schemaTS","schemaJS","blogStructureTS","blogStructureJS","structureTS","structureJS","client","live","imageTS","imageJS","sanityFolder","useTypeScript","template","structure","lib","schemaTypes"],"mappings":"AAAA,SAAQA,gBAAgB,EAAEC,YAAY,EAAEC,YAAY,QAAO,wBAAuB;AAElF,OAAO,MAAMC,uBAAuB,CAACC,eAAe,KAAK,GAAa,CAAC;;;;;;;;;;;6CAW1B,EAAEA,eAAe,uBAAuB,iBAAiB;qBACjF,EAAEA,eAAe,+BAA+B,yBAAyB;wBACtE,EAAEA,eAAe,6BAA6B,uBAAuB;;;;;;;;;;;;;;;AAe7F,CAAC,CAAA;AAED,OAAO,MAAMC,oBAAoB,CAAC;;;;;;;;;;AAUlC,CAAC,CAAA;AAED,OAAO,MAAMC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;AAmBrC,CAAC,CAAA;AAED,sCAAsC;AACtC,MAAMC,QAAQ,CAAC;iDACkC,EAAE,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;AAmB1F,CAAC;AAED,MAAMC,QAAQ,CAAC;iDACkC,EAAE,IAAIH,OAAOC,WAAW,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;;;;AAI1F,CAAC;AAED,MAAME,WAAW,CAAC;;;;;AAKlB,CAAC;AAED,MAAMC,WAAW,CAAC;;;AAGlB,CAAC;AAED,MAAMC,kBAAkB,CAAC;;;;;;;;;;;;;;;AAezB,CAAC;AAED,MAAMC,kBAAkB,CAAC;;;;;;;;;;;;;AAazB,CAAC;AAED,MAAMC,cAAc,CAAC;;;;;;;AAOrB,CAAC;AAED,MAAMC,cAAc,CAAC;;;;;AAKrB,CAAC;AAED,MAAMC,SAAS,CAAC;;;;;;;;;;AAUhB,CAAC;AAED,MAAMC,OAAO,CAAC;;;;;;;;;AASd,CAAC;AAED,MAAMC,UAAU,CAAC;;;;;;;;;;;AAWjB,CAAC;AAED,MAAMC,UAAU,CAAC;;;;;;;;;;AAUjB,CAAC;AAID,OAAO,MAAMC,eAAe,CAC1BC,eACAC;IAEA,+BAA+B;IAC/B,MAAMC,YAA6B;QACjC,QAAQF,gBAAgBhB,QAAQI;QAChCe,KAAK;YACH,WAAWR;YACX,UAAUK,gBAAgBH,UAAUC;YACpC,SAASF;QACX;IACF;IAEA,IAAIK,aAAa,QAAQ;QACvBC,UAAUE,WAAW,GAAG;YACtB,GAAG3B,gBAAgB;YACnB,UAAUuB,gBAAgBrB,eAAeD;QAC3C;QACAwB,SAAS,CAAC,aAAa,GAAGF,gBAAgBT,kBAAkBC;IAC9D,OAAO;QACLU,UAAUE,WAAW,GAAG;YACtB,UAAUJ,gBAAgBX,WAAWC;QACvC;QACAY,SAAS,CAAC,aAAa,GAAGF,gBAAgBP,cAAcC;IAC1D;IAEA,OAAOQ;AACT,EAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const blogSchemaTS = "import { type SchemaTypeDefinition } from 'sanity'\n\nimport {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema: { types: SchemaTypeDefinition[] } = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n";
2
+ export declare const blogSchemaJS = "import {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n";
3
+ export declare const blogSchemaFolder: Record<string, string>;
@@ -0,0 +1,247 @@
1
+ // Types
2
+ const authorType = `import {UserIcon} from '@sanity/icons'
3
+ import {defineArrayMember, defineField, defineType} from 'sanity'
4
+
5
+ export const authorType = defineType({
6
+ name: 'author',
7
+ title: 'Author',
8
+ type: 'document',
9
+ icon: UserIcon,
10
+ fields: [
11
+ defineField({
12
+ name: 'name',
13
+ type: 'string',
14
+ }),
15
+ defineField({
16
+ name: 'slug',
17
+ type: 'slug',
18
+ options: {
19
+ source: 'name',
20
+ },
21
+ }),
22
+ defineField({
23
+ name: 'image',
24
+ type: 'image',
25
+ options: {
26
+ hotspot: true,
27
+ },
28
+ }),
29
+ defineField({
30
+ name: 'bio',
31
+ type: 'array',
32
+ of: [
33
+ defineArrayMember({
34
+ type: 'block',
35
+ styles: [{title: 'Normal', value: 'normal'}],
36
+ lists: [],
37
+ }),
38
+ ],
39
+ }),
40
+ ],
41
+ preview: {
42
+ select: {
43
+ title: 'name',
44
+ media: 'image',
45
+ },
46
+ },
47
+ })
48
+ `;
49
+ const blockContentType = `import {defineType, defineArrayMember} from 'sanity'
50
+ import {ImageIcon} from '@sanity/icons'
51
+
52
+ /**
53
+ * This is the schema type for block content used in the post document type
54
+ * Importing this type into the studio configuration's \`schema\` property
55
+ * lets you reuse it in other document types with:
56
+ * {
57
+ * name: 'someName',
58
+ * title: 'Some title',
59
+ * type: 'blockContent'
60
+ * }
61
+ */
62
+
63
+ export const blockContentType = defineType({
64
+ title: 'Block Content',
65
+ name: 'blockContent',
66
+ type: 'array',
67
+ of: [
68
+ defineArrayMember({
69
+ type: 'block',
70
+ // Styles let you define what blocks can be marked up as. The default
71
+ // set corresponds with HTML tags, but you can set any title or value
72
+ // you want, and decide how you want to deal with it where you want to
73
+ // use your content.
74
+ styles: [
75
+ {title: 'Normal', value: 'normal'},
76
+ {title: 'H1', value: 'h1'},
77
+ {title: 'H2', value: 'h2'},
78
+ {title: 'H3', value: 'h3'},
79
+ {title: 'H4', value: 'h4'},
80
+ {title: 'Quote', value: 'blockquote'},
81
+ ],
82
+ lists: [{title: 'Bullet', value: 'bullet'}],
83
+ // Marks let you mark up inline text in the Portable Text Editor
84
+ marks: {
85
+ // Decorators usually describe a single property – e.g. a typographic
86
+ // preference or highlighting
87
+ decorators: [
88
+ {title: 'Strong', value: 'strong'},
89
+ {title: 'Emphasis', value: 'em'},
90
+ ],
91
+ // Annotations can be any object structure – e.g. a link or a footnote.
92
+ annotations: [
93
+ {
94
+ title: 'URL',
95
+ name: 'link',
96
+ type: 'object',
97
+ fields: [
98
+ {
99
+ title: 'URL',
100
+ name: 'href',
101
+ type: 'url',
102
+ },
103
+ ],
104
+ },
105
+ ],
106
+ },
107
+ }),
108
+ // You can add additional types here. Note that you can't use
109
+ // primitive types such as 'string' and 'number' in the same array
110
+ // as a block type.
111
+ defineArrayMember({
112
+ type: 'image',
113
+ icon: ImageIcon,
114
+ options: {hotspot: true},
115
+ fields: [
116
+ {
117
+ name: 'alt',
118
+ type: 'string',
119
+ title: 'Alternative Text',
120
+ }
121
+ ]
122
+ }),
123
+ ],
124
+ })
125
+ `;
126
+ const categoryType = `import {TagIcon} from '@sanity/icons'
127
+ import {defineField, defineType} from 'sanity'
128
+
129
+ export const categoryType = defineType({
130
+ name: 'category',
131
+ title: 'Category',
132
+ type: 'document',
133
+ icon: TagIcon,
134
+ fields: [
135
+ defineField({
136
+ name: 'title',
137
+ type: 'string',
138
+ }),
139
+ defineField({
140
+ name: 'slug',
141
+ type: 'slug',
142
+ options: {
143
+ source: 'title',
144
+ },
145
+ }),
146
+ defineField({
147
+ name: 'description',
148
+ type: 'text',
149
+ }),
150
+ ],
151
+ })
152
+ `;
153
+ const postType = `import {DocumentTextIcon} from '@sanity/icons'
154
+ import {defineArrayMember, defineField, defineType} from 'sanity'
155
+
156
+ export const postType = defineType({
157
+ name: 'post',
158
+ title: 'Post',
159
+ type: 'document',
160
+ icon: DocumentTextIcon,
161
+ fields: [
162
+ defineField({
163
+ name: 'title',
164
+ type: 'string',
165
+ }),
166
+ defineField({
167
+ name: 'slug',
168
+ type: 'slug',
169
+ options: {
170
+ source: 'title',
171
+ },
172
+ }),
173
+ defineField({
174
+ name: 'author',
175
+ type: 'reference',
176
+ to: {type: 'author'},
177
+ }),
178
+ defineField({
179
+ name: 'mainImage',
180
+ type: 'image',
181
+ options: {
182
+ hotspot: true,
183
+ },
184
+ fields: [
185
+ defineField({
186
+ name: 'alt',
187
+ type: 'string',
188
+ title: 'Alternative text',
189
+ })
190
+ ]
191
+ }),
192
+ defineField({
193
+ name: 'categories',
194
+ type: 'array',
195
+ of: [defineArrayMember({type: 'reference', to: {type: 'category'}})],
196
+ }),
197
+ defineField({
198
+ name: 'publishedAt',
199
+ type: 'datetime',
200
+ }),
201
+ defineField({
202
+ name: 'body',
203
+ type: 'blockContent',
204
+ }),
205
+ ],
206
+ preview: {
207
+ select: {
208
+ title: 'title',
209
+ author: 'author.name',
210
+ media: 'mainImage',
211
+ },
212
+ prepare(selection) {
213
+ const {author} = selection
214
+ return {...selection, subtitle: author && \`by \${author}\`}
215
+ },
216
+ },
217
+ })
218
+ `;
219
+ // Schema definition
220
+ export const blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'
221
+
222
+ import {blockContentType} from './blockContentType'
223
+ import {categoryType} from './categoryType'
224
+ import {postType} from './postType'
225
+ import {authorType} from './authorType'
226
+
227
+ export const schema: { types: SchemaTypeDefinition[] } = {
228
+ types: [blockContentType, categoryType, postType, authorType],
229
+ }
230
+ `;
231
+ export const blogSchemaJS = `import {blockContentType} from './blockContentType'
232
+ import {categoryType} from './categoryType'
233
+ import {postType} from './postType'
234
+ import {authorType} from './authorType'
235
+
236
+ export const schema = {
237
+ types: [blockContentType, categoryType, postType, authorType],
238
+ }
239
+ `;
240
+ export const blogSchemaFolder = {
241
+ 'authorType.': authorType,
242
+ 'blockContentType.': blockContentType,
243
+ 'categoryType.': categoryType,
244
+ 'postType.': postType
245
+ };
246
+
247
+ //# sourceMappingURL=blog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/actions/init/templates/nextjs/schemaTypes/blog.ts"],"sourcesContent":["// Types\n\nconst authorType = `import {UserIcon} from '@sanity/icons'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const authorType = defineType({\n name: 'author',\n title: 'Author',\n type: 'document',\n icon: UserIcon,\n fields: [\n defineField({\n name: 'name',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'name',\n },\n }),\n defineField({\n name: 'image',\n type: 'image',\n options: {\n hotspot: true,\n },\n }),\n defineField({\n name: 'bio',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n styles: [{title: 'Normal', value: 'normal'}],\n lists: [],\n }),\n ],\n }),\n ],\n preview: {\n select: {\n title: 'name',\n media: 'image',\n },\n },\n})\n`\n\nconst blockContentType = `import {defineType, defineArrayMember} from 'sanity'\nimport {ImageIcon} from '@sanity/icons'\n\n/**\n * This is the schema type for block content used in the post document type\n * Importing this type into the studio configuration's \\`schema\\` property\n * lets you reuse it in other document types with:\n * {\n * name: 'someName',\n * title: 'Some title',\n * type: 'blockContent'\n * }\n */\n\nexport const blockContentType = defineType({\n title: 'Block Content',\n name: 'blockContent',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n // Styles let you define what blocks can be marked up as. The default\n // set corresponds with HTML tags, but you can set any title or value\n // you want, and decide how you want to deal with it where you want to\n // use your content.\n styles: [\n {title: 'Normal', value: 'normal'},\n {title: 'H1', value: 'h1'},\n {title: 'H2', value: 'h2'},\n {title: 'H3', value: 'h3'},\n {title: 'H4', value: 'h4'},\n {title: 'Quote', value: 'blockquote'},\n ],\n lists: [{title: 'Bullet', value: 'bullet'}],\n // Marks let you mark up inline text in the Portable Text Editor\n marks: {\n // Decorators usually describe a single property – e.g. a typographic\n // preference or highlighting\n decorators: [\n {title: 'Strong', value: 'strong'},\n {title: 'Emphasis', value: 'em'},\n ],\n // Annotations can be any object structure – e.g. a link or a footnote.\n annotations: [\n {\n title: 'URL',\n name: 'link',\n type: 'object',\n fields: [\n {\n title: 'URL',\n name: 'href',\n type: 'url',\n },\n ],\n },\n ],\n },\n }),\n // You can add additional types here. Note that you can't use\n // primitive types such as 'string' and 'number' in the same array\n // as a block type.\n defineArrayMember({\n type: 'image',\n icon: ImageIcon,\n options: {hotspot: true},\n fields: [\n {\n name: 'alt',\n type: 'string',\n title: 'Alternative Text',\n }\n ]\n }),\n ],\n})\n`\n\nconst categoryType = `import {TagIcon} from '@sanity/icons'\nimport {defineField, defineType} from 'sanity'\n\nexport const categoryType = defineType({\n name: 'category',\n title: 'Category',\n type: 'document',\n icon: TagIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'description',\n type: 'text',\n }),\n ],\n})\n`\n\nconst postType = `import {DocumentTextIcon} from '@sanity/icons'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const postType = defineType({\n name: 'post',\n title: 'Post',\n type: 'document',\n icon: DocumentTextIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'author',\n type: 'reference',\n to: {type: 'author'},\n }),\n defineField({\n name: 'mainImage',\n type: 'image',\n options: {\n hotspot: true,\n },\n fields: [\n defineField({\n name: 'alt',\n type: 'string',\n title: 'Alternative text',\n })\n ]\n }),\n defineField({\n name: 'categories',\n type: 'array',\n of: [defineArrayMember({type: 'reference', to: {type: 'category'}})],\n }),\n defineField({\n name: 'publishedAt',\n type: 'datetime',\n }),\n defineField({\n name: 'body',\n type: 'blockContent',\n }),\n ],\n preview: {\n select: {\n title: 'title',\n author: 'author.name',\n media: 'mainImage',\n },\n prepare(selection) {\n const {author} = selection\n return {...selection, subtitle: author && \\`by \\${author}\\`}\n },\n },\n})\n`\n\n// Schema definition\nexport const blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'\n\nimport {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema: { types: SchemaTypeDefinition[] } = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaJS = `import {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaFolder: Record<string, string> = {\n 'authorType.': authorType,\n 'blockContentType.': blockContentType,\n 'categoryType.': categoryType,\n 'postType.': postType,\n}\n"],"names":["authorType","blockContentType","categoryType","postType","blogSchemaTS","blogSchemaJS","blogSchemaFolder"],"mappings":"AAAA,QAAQ;AAER,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CpB,CAAC;AAED,MAAMC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4E1B,CAAC;AAED,MAAMC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BtB,CAAC;AAED,MAAMC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiElB,CAAC;AAED,oBAAoB;AACpB,OAAO,MAAMC,eAAe,CAAC;;;;;;;;;;AAU7B,CAAC,CAAA;AAED,OAAO,MAAMC,eAAe,CAAC;;;;;;;;AAQ7B,CAAC,CAAA;AAED,OAAO,MAAMC,mBAA2C;IACtD,eAAeN;IACf,qBAAqBC;IACrB,iBAAiBC;IACjB,aAAaC;AACf,EAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ProjectTemplate } from '../types.js';
2
+ declare const quickStartTemplate: ProjectTemplate;
3
+ export default quickStartTemplate;
@@ -0,0 +1,4 @@
1
+ const quickStartTemplate = {};
2
+ export default quickStartTemplate;
3
+
4
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/quickstart.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst quickStartTemplate: ProjectTemplate = {}\n\nexport default quickStartTemplate\n"],"names":["quickStartTemplate"],"mappings":"AAEA,MAAMA,qBAAsC,CAAC;AAE7C,eAAeA,mBAAkB"}
@@ -0,0 +1,3 @@
1
+ import { type ProjectTemplate } from '../types.js';
2
+ declare const shopifyTemplate: ProjectTemplate;
3
+ export default shopifyTemplate;
@@ -0,0 +1,77 @@
1
+ const configTemplate = `
2
+ import {defineConfig, isDev} from 'sanity'
3
+
4
+ import {structureTool} from 'sanity/structure'
5
+ import {schemaTypes} from './schemaTypes'
6
+ import {structure} from './structure'
7
+
8
+ import {visionTool} from '@sanity/vision'
9
+ import {colorInput} from '@sanity/color-input'
10
+ import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'
11
+ import {media, mediaAssetSource} from 'sanity-plugin-media'
12
+ import {customDocumentActions} from './plugins/customDocumentActions'
13
+ import Navbar from './components/studio/Navbar'
14
+
15
+ const devOnlyPlugins = [visionTool()]
16
+
17
+ export default defineConfig({
18
+ name: '%sourceName%',
19
+ title: '%projectName%',
20
+
21
+ projectId: '%projectId%',
22
+ dataset: '%dataset%',
23
+
24
+ plugins: [
25
+ structureTool({structure}),
26
+ colorInput(),
27
+ imageHotspotArrayPlugin(),
28
+ customDocumentActions(),
29
+ media(),
30
+ ...(isDev ? devOnlyPlugins : []),
31
+ ],
32
+
33
+ schema: {
34
+ types: schemaTypes,
35
+ },
36
+
37
+ form: {
38
+ file: {
39
+ assetSources: (previousAssetSources) => {
40
+ return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)
41
+ },
42
+ },
43
+ image: {
44
+ assetSources: (previousAssetSources) => {
45
+ return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)
46
+ },
47
+ },
48
+ },
49
+
50
+ studio: {
51
+ components: {
52
+ navbar: Navbar,
53
+ },
54
+ },
55
+ })`;
56
+ const shopifyTemplate = {
57
+ configTemplate,
58
+ dependencies: {
59
+ '@sanity/asset-utils': '^1.3.0',
60
+ '@sanity/color-input': '^3.0.2',
61
+ '@sanity/icons': '^2.11.0',
62
+ '@sanity/ui': '^2.0.0',
63
+ 'lodash.get': '^4.4.2',
64
+ 'pluralize-esm': '^9.0.2',
65
+ 'sanity-plugin-hotspot-array': '^1.0.1',
66
+ 'sanity-plugin-media': '^2.0.5',
67
+ slug: '^8.2.2'
68
+ },
69
+ devDependencies: {
70
+ '@portabletext/types': '^2.0.2',
71
+ '@types/lodash.get': '^4.4.7',
72
+ '@types/slug': '^5.0.3'
73
+ }
74
+ };
75
+ export default shopifyTemplate;
76
+
77
+ //# sourceMappingURL=shopify.js.map