@@ -48,9 +48,25 @@ export default async function initSanity(args, context) {
48
48
// Ensure we are using the output path provided by user
49
49
const outputPath = answers . outputPath || workDir
50
50
51
+ // Prompt for template to use
52
+ const templateName = await prompt . single ( {
53
+ message : 'Select project template' ,
54
+ type : 'list' ,
55
+ choices : [
56
+ {
57
+ value : 'moviedb' ,
58
+ name : 'Movie database (schema + sample data)'
59
+ } ,
60
+ {
61
+ value : 'clean' ,
62
+ name : 'Clean, minimal project'
63
+ }
64
+ ]
65
+ } )
66
+
51
67
// Build a full set of resolved options
52
68
const initOptions = {
53
- template : 'moviedb' ,
69
+ template : templateName ,
54
70
outputDir : outputPath ,
55
71
name : sluggedName ,
56
72
displayName : displayName ,
@@ -81,16 +97,10 @@ export default async function initSanity(args, context) {
81
97
82
98
// Check if we're currently in the output path, so we can give a better start message
83
99
if ( outputPath === process . cwd ( ) ) {
84
- output . print (
85
- `\n${ chalk . green ( 'Success!' ) } You can now run "${ chalk . cyan (
86
- 'sanity start'
87
- ) } "`
88
- )
100
+ output . print ( `\n${ chalk . green ( 'Success!' ) } You can now run "${ chalk . cyan ( 'sanity start' ) } "` )
89
101
} else {
90
102
output . print (
91
- `\n${ chalk . green (
92
- 'Success!'
93
- ) } You can now change to directory "${ chalk . cyan (
103
+ `\n${ chalk . green ( 'Success!' ) } You can now change to directory "${ chalk . cyan (
94
104
outputPath
95
105
) } " and run "${ chalk . cyan ( 'sanity start' ) } "`
96
106
)
@@ -105,17 +115,13 @@ export default async function initSanity(args, context) {
105
115
}
106
116
107
117
async function getOrCreateUser ( ) {
108
- output . print (
109
- "We can't find any auth credentials in your Sanity config - looks like you"
110
- )
118
+ output . print ( "We can't find any auth credentials in your Sanity config - looks like you" )
111
119
output . print ( "haven't used Sanity on this system before?\n" )
112
120
113
121
// Provide login options (`sanity login`)
114
122
await login ( args , context )
115
123
116
- output . print (
117
- "Good stuff, you're now authenticated. You'll need a project to keep your"
118
- )
124
+ output . print ( "Good stuff, you're now authenticated. You'll need a project to keep your" )
119
125
output . print ( 'data sets and collaborators safe and snug.' )
120
126
}
121
127
@@ -124,9 +130,7 @@ export default async function initSanity(args, context) {
124
130
try {
125
131
projects = await apiClient ( { requireProject : false } ) . projects . list ( )
126
132
} catch ( err ) {
127
- throw new Error (
128
- `Failed to communicate with the Sanity API:\n${ err . message } `
129
- )
133
+ throw new Error ( `Failed to communicate with the Sanity API:\n${ err . message } ` )
130
134
}
131
135
132
136
if ( projects . length === 0 ) {
@@ -135,9 +139,7 @@ export default async function initSanity(args, context) {
135
139
return createProject ( apiClient , { displayName : projectName } )
136
140
}
137
141
138
- debug (
139
- `User has ${ projects . length } project(s) already, showing list of choices`
140
- )
142
+ debug ( `User has ${ projects . length } project(s) already, showing list of choices` )
141
143
142
144
const projectChoices = projects . map ( project => ( {
143
145
value : project . id ,
@@ -185,9 +187,7 @@ export default async function initSanity(args, context) {
185
187
return { datasetName : name }
186
188
}
187
189
188
- debug (
189
- `User has ${ datasets . length } dataset(s) already, showing list of choices`
190
- )
190
+ debug ( `User has ${ datasets . length } dataset(s) already, showing list of choices` )
191
191
const datasetChoices = datasets . map ( dataset => ( { value : dataset . name } ) )
192
192
193
193
const selected = await prompt . single ( {
0 commit comments