@sanity/cli 3.93.1-next.60.e1dbdccb42 → 3.93.1-next.8.cf0bf8550a
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 +1 -1
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +11 -10
- package/src/CommandRunner.ts +219 -0
- package/src/__telemetry__/cli.telemetry.ts +29 -0
- package/src/__telemetry__/init.telemetry.ts +95 -0
- package/src/actions/codemod/codemodAction.ts +109 -0
- package/src/actions/codemod/mods/deskRename.ts +19 -0
- package/src/actions/codemod/mods/index.ts +9 -0
- package/src/actions/codemod/mods/partsTypeDirective.ts +28 -0
- package/src/actions/codemod/mods/reactIconsV3.ts +54 -0
- package/src/actions/codemod/types.ts +10 -0
- package/src/actions/init-plugin/bootstrapFromTemplate.ts +196 -0
- package/src/actions/init-project/bootstrapLocalTemplate.ts +201 -0
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +118 -0
- package/src/actions/init-project/createAppCliConfig.ts +24 -0
- package/src/actions/init-project/createCliConfig.ts +31 -0
- package/src/actions/init-project/createPackageManifest.ts +102 -0
- package/src/actions/init-project/createStudioConfig.ts +53 -0
- package/src/actions/init-project/determineAppTemplate.ts +13 -0
- package/src/actions/init-project/fsUtils.ts +40 -0
- package/src/actions/init-project/git.ts +59 -0
- package/src/actions/init-project/initProject.ts +1708 -0
- package/src/actions/init-project/processTemplate.ts +55 -0
- package/src/actions/init-project/promptForDatasetName.ts +68 -0
- package/src/actions/init-project/prompts/index.ts +51 -0
- package/src/actions/init-project/prompts/nextjs.ts +59 -0
- package/src/actions/init-project/readPackageJson.ts +17 -0
- package/src/actions/init-project/templates/appQuickstart.ts +23 -0
- package/src/actions/init-project/templates/appSanityUi.ts +25 -0
- package/src/actions/init-project/templates/blog.ts +5 -0
- package/src/actions/init-project/templates/clean.ts +5 -0
- package/src/actions/init-project/templates/getStarted.ts +37 -0
- package/src/actions/init-project/templates/index.ts +24 -0
- package/src/actions/init-project/templates/moviedb.ts +35 -0
- package/src/actions/init-project/templates/nextjs/index.ts +238 -0
- package/src/actions/init-project/templates/nextjs/schemaTypes/blog.ts +252 -0
- package/src/actions/init-project/templates/quickstart.ts +5 -0
- package/src/actions/init-project/templates/shopify.ts +78 -0
- package/src/actions/init-project/templates/shopifyOnline.ts +50 -0
- package/src/actions/init-project/updateInitialTemplateMetadata.ts +24 -0
- package/src/actions/login/login.telemetry.ts +18 -0
- package/src/actions/login/login.ts +350 -0
- package/src/actions/login/types.ts +19 -0
- package/src/actions/project/createProject.ts +36 -0
- package/src/actions/telemetry/setTelemetryConsent.ts +101 -0
- package/src/actions/typegen/generate.telemetry.ts +20 -0
- package/src/actions/typegen/generateAction.ts +210 -0
- package/src/actions/versions/findSanityModuleVersions.ts +185 -0
- package/src/actions/yarn/events.ts +73 -0
- package/src/cli.ts +350 -0
- package/src/cliClient.ts +62 -0
- package/src/commands/blueprints/addBlueprintsCommand.ts +155 -0
- package/src/commands/blueprints/blueprintsGroup.ts +10 -0
- package/src/commands/blueprints/configBlueprintsCommand.ts +86 -0
- package/src/commands/blueprints/deployBlueprintsCommand.ts +63 -0
- package/src/commands/blueprints/destroyBlueprintsCommand.ts +78 -0
- package/src/commands/blueprints/infoBlueprintsCommand.ts +55 -0
- package/src/commands/blueprints/initBlueprintsCommand.ts +99 -0
- package/src/commands/blueprints/logsBlueprintsCommand.ts +66 -0
- package/src/commands/blueprints/planBlueprintsCommand.ts +51 -0
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +66 -0
- package/src/commands/codemod/codemodCommand.ts +32 -0
- package/src/commands/debug/debugCommand.ts +26 -0
- package/src/commands/debug/printDebugInfo.ts +243 -0
- package/src/commands/docs/docsCommand.ts +20 -0
- package/src/commands/functions/devFunctionsCommand.ts +73 -0
- package/src/commands/functions/envFunctionsCommand.ts +105 -0
- package/src/commands/functions/functionsGroup.ts +10 -0
- package/src/commands/functions/logsFunctionsCommand.ts +94 -0
- package/src/commands/functions/testFunctionsCommand.ts +93 -0
- package/src/commands/help/helpCommand.ts +21 -0
- package/src/commands/help/showHelp.ts +58 -0
- package/src/commands/index.ts +72 -0
- package/src/commands/init/initCommand.ts +123 -0
- package/src/commands/install/installCommand.ts +38 -0
- package/src/commands/learn/learnCommand.ts +20 -0
- package/src/commands/login/loginCommand.ts +29 -0
- package/src/commands/logout/logoutCommand.ts +52 -0
- package/src/commands/manage/manageCommand.ts +24 -0
- package/src/commands/projects/listProjectsCommand.ts +62 -0
- package/src/commands/projects/projectsGroup.ts +10 -0
- package/src/commands/telemetry/disableTelemetryCommand.ts +19 -0
- package/src/commands/telemetry/enableTelemetryCommand.ts +19 -0
- package/src/commands/telemetry/telemetryGroup.ts +10 -0
- package/src/commands/telemetry/telemetryStatusCommand.ts +89 -0
- package/src/commands/typegen/generateTypesCommand.ts +56 -0
- package/src/commands/typegen/typegenGroup.ts +10 -0
- package/src/commands/versions/printVersionResult.ts +51 -0
- package/src/commands/versions/versionsCommand.ts +13 -0
- package/src/config.ts +14 -0
- package/src/debug.ts +3 -0
- package/src/index.ts +6 -0
- package/src/outputters/cliOutputter.ts +47 -0
- package/src/packageManager/getInstallCommand.ts +26 -0
- package/src/packageManager/getUpgradeCommand.ts +52 -0
- package/src/packageManager/index.ts +33 -0
- package/src/packageManager/installPackages.ts +99 -0
- package/src/packageManager/packageManagerChoice.ts +204 -0
- package/src/packageManager/uninstallPackages.ts +44 -0
- package/src/packageManager/yarnStub.ts +22 -0
- package/src/prompters/cliPrompter.ts +9 -0
- package/src/run.ts +8 -0
- package/src/studioDependencies.ts +25 -0
- package/src/types.ts +387 -0
- package/src/util/canLaunchBrowser.ts +12 -0
- package/src/util/cliWorker.ts +34 -0
- package/src/util/clientWrapper.ts +119 -0
- package/src/util/copy.ts +50 -0
- package/src/util/createExpiringConfig.ts +80 -0
- package/src/util/createTelemetryStore.ts +204 -0
- package/src/util/detectRuntime.ts +12 -0
- package/src/util/dynamicRequire.ts +17 -0
- package/src/util/frameworkPort.ts +63 -0
- package/src/util/generateCommandsDocumentation.ts +62 -0
- package/src/util/getCliConfig.ts +172 -0
- package/src/util/getCliVersion.ts +22 -0
- package/src/util/getLocalVersion.ts +35 -0
- package/src/util/getProjectDefaults.ts +103 -0
- package/src/util/getProviderName.ts +9 -0
- package/src/util/getUserConfig.ts +15 -0
- package/src/util/isCi.ts +7 -0
- package/src/util/isCommandGroup.ts +7 -0
- package/src/util/isInteractive.ts +3 -0
- package/src/util/isTrueish.ts +8 -0
- package/src/util/journeyConfig.ts +280 -0
- package/src/util/loadEnv.ts +110 -0
- package/src/util/mergeCommands.ts +78 -0
- package/src/util/neatStack.ts +30 -0
- package/src/util/noSuchCommandText.ts +91 -0
- package/src/util/parseArguments.ts +76 -0
- package/src/util/pathExists.ts +14 -0
- package/src/util/readJson.ts +6 -0
- package/src/util/readdirRecursive.ts +26 -0
- package/src/util/remoteTemplate.ts +320 -0
- package/src/util/resolveLatestVersions.ts +24 -0
- package/src/util/resolveRootDir.ts +59 -0
- package/src/util/telemetryDisclosure.ts +45 -0
- package/src/util/updateNotifier.ts +158 -0
- package/src/util/writeJson.ts +6 -0
- package/src/workers/getAndWriteJourneySchema.ts +7 -0
- package/src/workers/getCliConfig.ts +14 -0
- package/src/workers/typegenGenerate.ts +228 -0
- package/templates/blog/README.md +1 -1
- package/templates/clean/README.md +1 -1
- package/templates/ecommerce/README.md +1 -1
- package/templates/get-started/README.md +1 -1
- package/templates/moviedb/README.md +1 -1
- package/templates/quickstart/README.md +1 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
|
|
3
|
+
const authorType = `import {UserIcon} from '@sanity/icons'
|
|
4
|
+
import {defineArrayMember, defineField, defineType} from 'sanity'
|
|
5
|
+
|
|
6
|
+
export const authorType = defineType({
|
|
7
|
+
name: 'author',
|
|
8
|
+
title: 'Author',
|
|
9
|
+
type: 'document',
|
|
10
|
+
icon: UserIcon,
|
|
11
|
+
fields: [
|
|
12
|
+
defineField({
|
|
13
|
+
name: 'name',
|
|
14
|
+
type: 'string',
|
|
15
|
+
}),
|
|
16
|
+
defineField({
|
|
17
|
+
name: 'slug',
|
|
18
|
+
type: 'slug',
|
|
19
|
+
options: {
|
|
20
|
+
source: 'name',
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
defineField({
|
|
24
|
+
name: 'image',
|
|
25
|
+
type: 'image',
|
|
26
|
+
options: {
|
|
27
|
+
hotspot: true,
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
defineField({
|
|
31
|
+
name: 'bio',
|
|
32
|
+
type: 'array',
|
|
33
|
+
of: [
|
|
34
|
+
defineArrayMember({
|
|
35
|
+
type: 'block',
|
|
36
|
+
styles: [{title: 'Normal', value: 'normal'}],
|
|
37
|
+
lists: [],
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
preview: {
|
|
43
|
+
select: {
|
|
44
|
+
title: 'name',
|
|
45
|
+
media: 'image',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
const blockContentType = `import {defineType, defineArrayMember} from 'sanity'
|
|
52
|
+
import {ImageIcon} from '@sanity/icons'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This is the schema type for block content used in the post document type
|
|
56
|
+
* Importing this type into the studio configuration's \`schema\` property
|
|
57
|
+
* lets you reuse it in other document types with:
|
|
58
|
+
* {
|
|
59
|
+
* name: 'someName',
|
|
60
|
+
* title: 'Some title',
|
|
61
|
+
* type: 'blockContent'
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
export const blockContentType = defineType({
|
|
66
|
+
title: 'Block Content',
|
|
67
|
+
name: 'blockContent',
|
|
68
|
+
type: 'array',
|
|
69
|
+
of: [
|
|
70
|
+
defineArrayMember({
|
|
71
|
+
type: 'block',
|
|
72
|
+
// Styles let you define what blocks can be marked up as. The default
|
|
73
|
+
// set corresponds with HTML tags, but you can set any title or value
|
|
74
|
+
// you want, and decide how you want to deal with it where you want to
|
|
75
|
+
// use your content.
|
|
76
|
+
styles: [
|
|
77
|
+
{title: 'Normal', value: 'normal'},
|
|
78
|
+
{title: 'H1', value: 'h1'},
|
|
79
|
+
{title: 'H2', value: 'h2'},
|
|
80
|
+
{title: 'H3', value: 'h3'},
|
|
81
|
+
{title: 'H4', value: 'h4'},
|
|
82
|
+
{title: 'Quote', value: 'blockquote'},
|
|
83
|
+
],
|
|
84
|
+
lists: [{title: 'Bullet', value: 'bullet'}],
|
|
85
|
+
// Marks let you mark up inline text in the Portable Text Editor
|
|
86
|
+
marks: {
|
|
87
|
+
// Decorators usually describe a single property – e.g. a typographic
|
|
88
|
+
// preference or highlighting
|
|
89
|
+
decorators: [
|
|
90
|
+
{title: 'Strong', value: 'strong'},
|
|
91
|
+
{title: 'Emphasis', value: 'em'},
|
|
92
|
+
],
|
|
93
|
+
// Annotations can be any object structure – e.g. a link or a footnote.
|
|
94
|
+
annotations: [
|
|
95
|
+
{
|
|
96
|
+
title: 'URL',
|
|
97
|
+
name: 'link',
|
|
98
|
+
type: 'object',
|
|
99
|
+
fields: [
|
|
100
|
+
{
|
|
101
|
+
title: 'URL',
|
|
102
|
+
name: 'href',
|
|
103
|
+
type: 'url',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
// You can add additional types here. Note that you can't use
|
|
111
|
+
// primitive types such as 'string' and 'number' in the same array
|
|
112
|
+
// as a block type.
|
|
113
|
+
defineArrayMember({
|
|
114
|
+
type: 'image',
|
|
115
|
+
icon: ImageIcon,
|
|
116
|
+
options: {hotspot: true},
|
|
117
|
+
fields: [
|
|
118
|
+
{
|
|
119
|
+
name: 'alt',
|
|
120
|
+
type: 'string',
|
|
121
|
+
title: 'Alternative Text',
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
})
|
|
127
|
+
`
|
|
128
|
+
|
|
129
|
+
const categoryType = `import {TagIcon} from '@sanity/icons'
|
|
130
|
+
import {defineField, defineType} from 'sanity'
|
|
131
|
+
|
|
132
|
+
export const categoryType = defineType({
|
|
133
|
+
name: 'category',
|
|
134
|
+
title: 'Category',
|
|
135
|
+
type: 'document',
|
|
136
|
+
icon: TagIcon,
|
|
137
|
+
fields: [
|
|
138
|
+
defineField({
|
|
139
|
+
name: 'title',
|
|
140
|
+
type: 'string',
|
|
141
|
+
}),
|
|
142
|
+
defineField({
|
|
143
|
+
name: 'slug',
|
|
144
|
+
type: 'slug',
|
|
145
|
+
options: {
|
|
146
|
+
source: 'title',
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
defineField({
|
|
150
|
+
name: 'description',
|
|
151
|
+
type: 'text',
|
|
152
|
+
}),
|
|
153
|
+
],
|
|
154
|
+
})
|
|
155
|
+
`
|
|
156
|
+
|
|
157
|
+
const postType = `import {DocumentTextIcon} from '@sanity/icons'
|
|
158
|
+
import {defineArrayMember, defineField, defineType} from 'sanity'
|
|
159
|
+
|
|
160
|
+
export const postType = defineType({
|
|
161
|
+
name: 'post',
|
|
162
|
+
title: 'Post',
|
|
163
|
+
type: 'document',
|
|
164
|
+
icon: DocumentTextIcon,
|
|
165
|
+
fields: [
|
|
166
|
+
defineField({
|
|
167
|
+
name: 'title',
|
|
168
|
+
type: 'string',
|
|
169
|
+
}),
|
|
170
|
+
defineField({
|
|
171
|
+
name: 'slug',
|
|
172
|
+
type: 'slug',
|
|
173
|
+
options: {
|
|
174
|
+
source: 'title',
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
defineField({
|
|
178
|
+
name: 'author',
|
|
179
|
+
type: 'reference',
|
|
180
|
+
to: {type: 'author'},
|
|
181
|
+
}),
|
|
182
|
+
defineField({
|
|
183
|
+
name: 'mainImage',
|
|
184
|
+
type: 'image',
|
|
185
|
+
options: {
|
|
186
|
+
hotspot: true,
|
|
187
|
+
},
|
|
188
|
+
fields: [
|
|
189
|
+
defineField({
|
|
190
|
+
name: 'alt',
|
|
191
|
+
type: 'string',
|
|
192
|
+
title: 'Alternative text',
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
}),
|
|
196
|
+
defineField({
|
|
197
|
+
name: 'categories',
|
|
198
|
+
type: 'array',
|
|
199
|
+
of: [defineArrayMember({type: 'reference', to: {type: 'category'}})],
|
|
200
|
+
}),
|
|
201
|
+
defineField({
|
|
202
|
+
name: 'publishedAt',
|
|
203
|
+
type: 'datetime',
|
|
204
|
+
}),
|
|
205
|
+
defineField({
|
|
206
|
+
name: 'body',
|
|
207
|
+
type: 'blockContent',
|
|
208
|
+
}),
|
|
209
|
+
],
|
|
210
|
+
preview: {
|
|
211
|
+
select: {
|
|
212
|
+
title: 'title',
|
|
213
|
+
author: 'author.name',
|
|
214
|
+
media: 'mainImage',
|
|
215
|
+
},
|
|
216
|
+
prepare(selection) {
|
|
217
|
+
const {author} = selection
|
|
218
|
+
return {...selection, subtitle: author && \`by \${author}\`}
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
})
|
|
222
|
+
`
|
|
223
|
+
|
|
224
|
+
// Schema definition
|
|
225
|
+
export const blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'
|
|
226
|
+
|
|
227
|
+
import {blockContentType} from './blockContentType'
|
|
228
|
+
import {categoryType} from './categoryType'
|
|
229
|
+
import {postType} from './postType'
|
|
230
|
+
import {authorType} from './authorType'
|
|
231
|
+
|
|
232
|
+
export const schema: { types: SchemaTypeDefinition[] } = {
|
|
233
|
+
types: [blockContentType, categoryType, postType, authorType],
|
|
234
|
+
}
|
|
235
|
+
`
|
|
236
|
+
|
|
237
|
+
export const blogSchemaJS = `import {blockContentType} from './blockContentType'
|
|
238
|
+
import {categoryType} from './categoryType'
|
|
239
|
+
import {postType} from './postType'
|
|
240
|
+
import {authorType} from './authorType'
|
|
241
|
+
|
|
242
|
+
export const schema = {
|
|
243
|
+
types: [blockContentType, categoryType, postType, authorType],
|
|
244
|
+
}
|
|
245
|
+
`
|
|
246
|
+
|
|
247
|
+
export const blogSchemaFolder: Record<string, string> = {
|
|
248
|
+
'authorType.': authorType,
|
|
249
|
+
'blockContentType.': blockContentType,
|
|
250
|
+
'categoryType.': categoryType,
|
|
251
|
+
'postType.': postType,
|
|
252
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {type ProjectTemplate} from '../initProject'
|
|
2
|
+
|
|
3
|
+
const configTemplate = `
|
|
4
|
+
import {defineConfig, isDev} from 'sanity'
|
|
5
|
+
|
|
6
|
+
import {structureTool} from 'sanity/structure'
|
|
7
|
+
import {schemaTypes} from './schemaTypes'
|
|
8
|
+
import {structure} from './structure'
|
|
9
|
+
|
|
10
|
+
import {visionTool} from '@sanity/vision'
|
|
11
|
+
import {colorInput} from '@sanity/color-input'
|
|
12
|
+
import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'
|
|
13
|
+
import {media, mediaAssetSource} from 'sanity-plugin-media'
|
|
14
|
+
import {customDocumentActions} from './plugins/customDocumentActions'
|
|
15
|
+
import Navbar from './components/studio/Navbar'
|
|
16
|
+
|
|
17
|
+
const devOnlyPlugins = [visionTool()]
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
name: '%sourceName%',
|
|
21
|
+
title: '%projectName%',
|
|
22
|
+
|
|
23
|
+
projectId: '%projectId%',
|
|
24
|
+
dataset: '%dataset%',
|
|
25
|
+
|
|
26
|
+
plugins: [
|
|
27
|
+
structureTool({structure}),
|
|
28
|
+
colorInput(),
|
|
29
|
+
imageHotspotArrayPlugin(),
|
|
30
|
+
customDocumentActions(),
|
|
31
|
+
media(),
|
|
32
|
+
...(isDev ? devOnlyPlugins : []),
|
|
33
|
+
],
|
|
34
|
+
|
|
35
|
+
schema: {
|
|
36
|
+
types: schemaTypes,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
form: {
|
|
40
|
+
file: {
|
|
41
|
+
assetSources: (previousAssetSources) => {
|
|
42
|
+
return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
image: {
|
|
46
|
+
assetSources: (previousAssetSources) => {
|
|
47
|
+
return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
studio: {
|
|
53
|
+
components: {
|
|
54
|
+
navbar: Navbar,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
})`
|
|
58
|
+
|
|
59
|
+
const shopifyTemplate: ProjectTemplate = {
|
|
60
|
+
configTemplate,
|
|
61
|
+
dependencies: {
|
|
62
|
+
'@sanity/asset-utils': '^1.3.0',
|
|
63
|
+
'@sanity/color-input': '^3.0.2',
|
|
64
|
+
'@sanity/icons': '^2.11.0',
|
|
65
|
+
'@sanity/ui': '^2.0.0',
|
|
66
|
+
'lodash.get': '^4.4.2',
|
|
67
|
+
'pluralize-esm': '^9.0.2',
|
|
68
|
+
'sanity-plugin-hotspot-array': '^1.0.1',
|
|
69
|
+
'sanity-plugin-media': '^2.0.5',
|
|
70
|
+
'slug': '^8.2.2',
|
|
71
|
+
},
|
|
72
|
+
devDependencies: {
|
|
73
|
+
'@portabletext/types': '^2.0.2',
|
|
74
|
+
'@types/lodash.get': '^4.4.7',
|
|
75
|
+
'@types/slug': '^5.0.3',
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
export default shopifyTemplate
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {type ProjectTemplate} from '../initProject'
|
|
2
|
+
|
|
3
|
+
const configTemplate = `
|
|
4
|
+
import {shopifyAssets} from 'sanity-plugin-shopify-assets'
|
|
5
|
+
import {defineConfig, isDev} from 'sanity'
|
|
6
|
+
import {structureTool} from 'sanity/structure'
|
|
7
|
+
import {visionTool} from '@sanity/vision'
|
|
8
|
+
import {shopifyDocumentActions} from './plugins/shopifyDocumentActions'
|
|
9
|
+
import {schemaTypes} from './schemaTypes'
|
|
10
|
+
import {structure} from './structure'
|
|
11
|
+
import {SHOPIFY_STORE_ID} from './constants'
|
|
12
|
+
|
|
13
|
+
const devOnlyPlugins = [visionTool()]
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
name: '%sourceName%',
|
|
17
|
+
title: '%projectName%',
|
|
18
|
+
|
|
19
|
+
projectId: '%projectId%',
|
|
20
|
+
dataset: '%dataset%',
|
|
21
|
+
|
|
22
|
+
plugins: [
|
|
23
|
+
structureTool({structure}),
|
|
24
|
+
shopifyDocumentActions(),
|
|
25
|
+
shopifyAssets({
|
|
26
|
+
shopifyDomain: SHOPIFY_STORE_ID,
|
|
27
|
+
}),
|
|
28
|
+
...(isDev ? devOnlyPlugins : []),
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
schema: {
|
|
32
|
+
types: schemaTypes,
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
const shopifyTemplate: ProjectTemplate = {
|
|
38
|
+
configTemplate,
|
|
39
|
+
typescriptOnly: true,
|
|
40
|
+
dependencies: {
|
|
41
|
+
'@portabletext/toolkit': '^2.0.1',
|
|
42
|
+
'@sanity/icons': '^2.11.0',
|
|
43
|
+
'@sanity/ui': '^2.0.0',
|
|
44
|
+
'@types/lodash.get': '^4.4.7',
|
|
45
|
+
'lodash.get': '^4.4.2',
|
|
46
|
+
'pluralize-esm': '^9.0.4',
|
|
47
|
+
'sanity-plugin-shopify-assets': '^1.1.0',
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
export default shopifyTemplate
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {debug} from '../../debug'
|
|
2
|
+
import {type CliApiClient} from '../../types'
|
|
3
|
+
|
|
4
|
+
export async function updateInitialTemplateMetadata(
|
|
5
|
+
apiClient: CliApiClient,
|
|
6
|
+
projectId: string,
|
|
7
|
+
templateName: string,
|
|
8
|
+
): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
await apiClient({api: {projectId}}).request({
|
|
11
|
+
method: 'PATCH',
|
|
12
|
+
uri: `/projects/${projectId}`,
|
|
13
|
+
body: {metadata: {initialTemplate: templateName}},
|
|
14
|
+
})
|
|
15
|
+
} catch (err: unknown) {
|
|
16
|
+
// Non-critical that we update this metadata, and user does not need to be aware
|
|
17
|
+
let message = typeof err === 'string' ? err : '<unknown error>'
|
|
18
|
+
if (err instanceof Error) {
|
|
19
|
+
message = err.message
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
debug('Failed to update initial template metadata for project: %s', message)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {defineTrace} from '@sanity/telemetry'
|
|
2
|
+
|
|
3
|
+
interface SelectProviderStep {
|
|
4
|
+
step: 'selectProvider'
|
|
5
|
+
provider: string | undefined
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface WaitForTokenStep {
|
|
9
|
+
step: 'waitForToken'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type LoginTraceData = SelectProviderStep | WaitForTokenStep
|
|
13
|
+
|
|
14
|
+
export const LoginTrace = defineTrace<LoginTraceData>({
|
|
15
|
+
name: 'CLI Login Step Completed',
|
|
16
|
+
version: 1,
|
|
17
|
+
description: 'User completed a step in the CLI login flow',
|
|
18
|
+
})
|