@sanity/cli 5.9.0-next.8 → 6.0.0-alpha.11

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 (919) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3212 -2
  3. package/bin/run.cmd +3 -0
  4. package/bin/run.js +33 -0
  5. package/codemods/deskRename.js +115 -96
  6. package/codemods/partsTypeDirective.js +7 -7
  7. package/codemods/reactIconsV3.js +78 -51
  8. package/dist/SanityHelp.js +43 -0
  9. package/dist/SanityHelp.js.map +1 -0
  10. package/dist/actions/auth/authServer.js +153 -0
  11. package/dist/actions/auth/authServer.js.map +1 -0
  12. package/dist/actions/auth/getProviderName.js +15 -0
  13. package/dist/actions/auth/getProviderName.js.map +1 -0
  14. package/dist/actions/auth/login/getProvider.js +54 -0
  15. package/dist/actions/auth/login/getProvider.js.map +1 -0
  16. package/dist/actions/auth/login/getSSOProvider.js +30 -0
  17. package/dist/actions/auth/login/getSSOProvider.js.map +1 -0
  18. package/dist/actions/auth/login/login.js +101 -0
  19. package/dist/actions/auth/login/login.js.map +1 -0
  20. package/dist/actions/auth/login/promptProviders.js +23 -0
  21. package/dist/actions/auth/login/promptProviders.js.map +1 -0
  22. package/dist/actions/auth/login/samlProviderToLoginProvider.js +15 -0
  23. package/dist/actions/auth/login/samlProviderToLoginProvider.js.map +1 -0
  24. package/dist/actions/auth/types.js +7 -0
  25. package/dist/actions/auth/types.js.map +1 -0
  26. package/dist/actions/backup/archiveDir.js +43 -0
  27. package/dist/actions/backup/archiveDir.js.map +1 -0
  28. package/dist/actions/backup/assertDatasetExist.js +16 -0
  29. package/dist/actions/backup/assertDatasetExist.js.map +1 -0
  30. package/dist/actions/backup/backupDownloadDebug.js +4 -0
  31. package/dist/actions/backup/backupDownloadDebug.js.map +1 -0
  32. package/dist/actions/backup/cleanupTmpDir.js +19 -0
  33. package/dist/actions/backup/cleanupTmpDir.js.map +1 -0
  34. package/dist/actions/backup/constants.js +3 -0
  35. package/dist/actions/backup/constants.js.map +1 -0
  36. package/dist/actions/backup/downloadAsset.js +54 -0
  37. package/dist/actions/backup/downloadAsset.js.map +1 -0
  38. package/dist/actions/backup/downloadDocument.js +32 -0
  39. package/dist/actions/backup/downloadDocument.js.map +1 -0
  40. package/dist/actions/backup/fetchNextBackupPage.js +48 -0
  41. package/dist/actions/backup/fetchNextBackupPage.js.map +1 -0
  42. package/dist/actions/backup/progressSpinner.js +40 -0
  43. package/dist/actions/backup/progressSpinner.js.map +1 -0
  44. package/dist/actions/build/buildApp.js +159 -0
  45. package/dist/actions/build/buildApp.js.map +1 -0
  46. package/dist/actions/build/buildDebug.js +4 -0
  47. package/dist/actions/build/buildDebug.js.map +1 -0
  48. package/dist/actions/build/buildStaticFiles.js +82 -0
  49. package/dist/actions/build/buildStaticFiles.js.map +1 -0
  50. package/dist/actions/build/buildStudio.js +202 -0
  51. package/dist/actions/build/buildStudio.js.map +1 -0
  52. package/dist/actions/build/buildVendorDependencies.js +179 -0
  53. package/dist/actions/build/buildVendorDependencies.js.map +1 -0
  54. package/dist/actions/build/checkRequiredDependencies.js +122 -0
  55. package/dist/actions/build/checkRequiredDependencies.js.map +1 -0
  56. package/dist/actions/build/checkStudioDependencyVersions.js +154 -0
  57. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -0
  58. package/dist/actions/build/createExternalFromImportMap.js +11 -0
  59. package/dist/actions/build/createExternalFromImportMap.js.map +1 -0
  60. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js +13 -0
  61. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js.map +1 -0
  62. package/dist/actions/build/decorateIndexWithBridgeScript.js +17 -0
  63. package/dist/actions/build/decorateIndexWithBridgeScript.js.map +1 -0
  64. package/dist/actions/build/determineBasePath.js +20 -0
  65. package/dist/actions/build/determineBasePath.js.map +1 -0
  66. package/dist/actions/build/generateWebManifest.js +27 -0
  67. package/dist/actions/build/generateWebManifest.js.map +1 -0
  68. package/dist/actions/build/getAppEnvVars.js +9 -0
  69. package/dist/actions/build/getAppEnvVars.js.map +1 -0
  70. package/dist/actions/build/getAutoUpdatesImportMap.js +57 -0
  71. package/dist/actions/build/getAutoUpdatesImportMap.js.map +1 -0
  72. package/dist/actions/build/getEntryModule.js +46 -0
  73. package/dist/actions/build/getEntryModule.js.map +1 -0
  74. package/dist/actions/build/getPossibleDocumentComponentLocations.js +11 -0
  75. package/dist/actions/build/getPossibleDocumentComponentLocations.js.map +1 -0
  76. package/dist/actions/build/getStudioEnvVars.js +9 -0
  77. package/dist/actions/build/getStudioEnvVars.js.map +1 -0
  78. package/dist/actions/build/getStudioEnvironmentVariables.js +58 -0
  79. package/dist/actions/build/getStudioEnvironmentVariables.js.map +1 -0
  80. package/dist/actions/build/getViteConfig.js +180 -0
  81. package/dist/actions/build/getViteConfig.js.map +1 -0
  82. package/dist/actions/build/normalizeBasePath.js +9 -0
  83. package/dist/actions/build/normalizeBasePath.js.map +1 -0
  84. package/dist/actions/build/renderDocument.js +54 -0
  85. package/dist/actions/build/renderDocument.js.map +1 -0
  86. package/dist/actions/build/renderDocument.worker.js +9 -0
  87. package/dist/actions/build/renderDocument.worker.js.map +1 -0
  88. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js +59 -0
  89. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js.map +1 -0
  90. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js +61 -0
  91. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js.map +1 -0
  92. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js +165 -0
  93. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js.map +1 -0
  94. package/dist/actions/build/renderDocumentWorker/components/Favicons.js +28 -0
  95. package/dist/actions/build/renderDocumentWorker/components/Favicons.js.map +1 -0
  96. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js +177 -0
  97. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js.map +1 -0
  98. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js +51 -0
  99. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js.map +1 -0
  100. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js +41 -0
  101. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js.map +1 -0
  102. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js +55 -0
  103. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js.map +1 -0
  104. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js +31 -0
  105. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js.map +1 -0
  106. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +30 -0
  107. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +1 -0
  108. package/dist/actions/build/renderDocumentWorker/types.js +5 -0
  109. package/dist/actions/build/renderDocumentWorker/types.js.map +1 -0
  110. package/dist/actions/build/shouldAutoUpdate.js +35 -0
  111. package/dist/actions/build/shouldAutoUpdate.js.map +1 -0
  112. package/dist/actions/build/types.js +3 -0
  113. package/dist/actions/build/types.js.map +1 -0
  114. package/dist/actions/build/writeFavicons.js +26 -0
  115. package/dist/actions/build/writeFavicons.js.map +1 -0
  116. package/dist/actions/build/writeSanityRuntime.js +61 -0
  117. package/dist/actions/build/writeSanityRuntime.js.map +1 -0
  118. package/dist/actions/build/writeWebManifest.js +12 -0
  119. package/dist/actions/build/writeWebManifest.js.map +1 -0
  120. package/dist/actions/codemods/deskRename.js +18 -0
  121. package/dist/actions/codemods/deskRename.js.map +1 -0
  122. package/dist/actions/codemods/index.js +10 -0
  123. package/dist/actions/codemods/index.js.map +1 -0
  124. package/dist/actions/codemods/partsTypeDirective.js +27 -0
  125. package/dist/actions/codemods/partsTypeDirective.js.map +1 -0
  126. package/dist/actions/codemods/reactIconsV3.js +30 -0
  127. package/dist/actions/codemods/reactIconsV3.js.map +1 -0
  128. package/dist/actions/codemods/types.js +3 -0
  129. package/dist/actions/codemods/types.js.map +1 -0
  130. package/dist/actions/cors/filterAndValidateOrigin.js +38 -0
  131. package/dist/actions/cors/filterAndValidateOrigin.js.map +1 -0
  132. package/dist/actions/dataset/create.js +46 -0
  133. package/dist/actions/dataset/create.js.map +1 -0
  134. package/dist/actions/dataset/determineDatasetAclMode.js +36 -0
  135. package/dist/actions/dataset/determineDatasetAclMode.js.map +1 -0
  136. package/dist/actions/dataset/processAliasName.js +20 -0
  137. package/dist/actions/dataset/processAliasName.js.map +1 -0
  138. package/dist/actions/dataset/validateDatasetAliasName.js +28 -0
  139. package/dist/actions/dataset/validateDatasetAliasName.js.map +1 -0
  140. package/dist/actions/dataset/validateDatasetName.js +39 -0
  141. package/dist/actions/dataset/validateDatasetName.js.map +1 -0
  142. package/dist/actions/debug/gatherDebugInfo.js +104 -0
  143. package/dist/actions/debug/gatherDebugInfo.js.map +1 -0
  144. package/dist/actions/debug/getGlobalConfigLocation.js +7 -0
  145. package/dist/actions/debug/getGlobalConfigLocation.js.map +1 -0
  146. package/dist/actions/debug/types.js +3 -0
  147. package/dist/actions/debug/types.js.map +1 -0
  148. package/dist/actions/deploy/checkDir.js +31 -0
  149. package/dist/actions/deploy/checkDir.js.map +1 -0
  150. package/dist/actions/deploy/createStudioUserApplication.js +59 -0
  151. package/dist/actions/deploy/createStudioUserApplication.js.map +1 -0
  152. package/dist/actions/deploy/createUserApplicationForApp.js +56 -0
  153. package/dist/actions/deploy/createUserApplicationForApp.js.map +1 -0
  154. package/dist/actions/deploy/deployApp.js +162 -0
  155. package/dist/actions/deploy/deployApp.js.map +1 -0
  156. package/dist/actions/deploy/deployDebug.js +4 -0
  157. package/dist/actions/deploy/deployDebug.js.map +1 -0
  158. package/dist/actions/deploy/deployStudio.js +134 -0
  159. package/dist/actions/deploy/deployStudio.js.map +1 -0
  160. package/dist/actions/deploy/findUserApplicationForApp.js +110 -0
  161. package/dist/actions/deploy/findUserApplicationForApp.js.map +1 -0
  162. package/dist/actions/deploy/findUserApplicationForStudio.js +143 -0
  163. package/dist/actions/deploy/findUserApplicationForStudio.js.map +1 -0
  164. package/dist/actions/deploy/types.js +3 -0
  165. package/dist/actions/deploy/types.js.map +1 -0
  166. package/dist/actions/dev/devAction.js +7 -0
  167. package/dist/actions/dev/devAction.js.map +1 -0
  168. package/dist/actions/dev/devDebug.js +4 -0
  169. package/dist/actions/dev/devDebug.js.map +1 -0
  170. package/dist/actions/dev/getCoreAppUrl.js +10 -0
  171. package/dist/actions/dev/getCoreAppUrl.js.map +1 -0
  172. package/dist/actions/dev/getDevServerConfig.js +28 -0
  173. package/dist/actions/dev/getDevServerConfig.js.map +1 -0
  174. package/dist/actions/dev/startAppDevServer.js +57 -0
  175. package/dist/actions/dev/startAppDevServer.js.map +1 -0
  176. package/dist/actions/dev/startStudioDevServer.js +154 -0
  177. package/dist/actions/dev/startStudioDevServer.js.map +1 -0
  178. package/dist/actions/dev/types.js +3 -0
  179. package/dist/actions/dev/types.js.map +1 -0
  180. package/dist/actions/docs/normalizeDocsPath.js +15 -0
  181. package/dist/actions/docs/normalizeDocsPath.js.map +1 -0
  182. package/dist/actions/documents/constants.js +3 -0
  183. package/dist/actions/documents/constants.js.map +1 -0
  184. package/dist/actions/documents/editor.js +26 -0
  185. package/dist/actions/documents/editor.js.map +1 -0
  186. package/dist/actions/documents/types.js +3 -0
  187. package/dist/actions/documents/types.js.map +1 -0
  188. package/dist/actions/documents/validate.js +60 -0
  189. package/dist/actions/documents/validate.js.map +1 -0
  190. package/dist/actions/documents/validateDocuments.worker.js +251 -0
  191. package/dist/actions/documents/validateDocuments.worker.js.map +1 -0
  192. package/dist/actions/documents/validation/reporters/index.js +10 -0
  193. package/dist/actions/documents/validation/reporters/index.js.map +1 -0
  194. package/dist/actions/documents/validation/reporters/jsonReporter.js +25 -0
  195. package/dist/actions/documents/validation/reporters/jsonReporter.js.map +1 -0
  196. package/dist/actions/documents/validation/reporters/ndjsonReporter.js +18 -0
  197. package/dist/actions/documents/validation/reporters/ndjsonReporter.js.map +1 -0
  198. package/dist/actions/documents/validation/reporters/prettyReporter/formatDocumentValidation.js +62 -0
  199. package/dist/actions/documents/validation/reporters/prettyReporter/formatDocumentValidation.js.map +1 -0
  200. package/dist/actions/documents/validation/reporters/prettyReporter/index.js +3 -0
  201. package/dist/actions/documents/validation/reporters/prettyReporter/index.js.map +1 -0
  202. package/dist/actions/documents/validation/reporters/prettyReporter/prettyReporter.js +92 -0
  203. package/dist/actions/documents/validation/reporters/prettyReporter/prettyReporter.js.map +1 -0
  204. package/dist/actions/documents/validation/reporters/prettyReporter/util.js +45 -0
  205. package/dist/actions/documents/validation/reporters/prettyReporter/util.js.map +1 -0
  206. package/dist/actions/exec/configClient.worker.js +9 -0
  207. package/dist/actions/exec/configClient.worker.js.map +1 -0
  208. package/dist/actions/exec/execScript.js +77 -0
  209. package/dist/actions/exec/execScript.js.map +1 -0
  210. package/dist/actions/exec/registerBrowserEnv.worker.js +17 -0
  211. package/dist/actions/exec/registerBrowserEnv.worker.js.map +1 -0
  212. package/dist/actions/graphql/SchemaError.js +37 -0
  213. package/dist/actions/graphql/SchemaError.js.map +1 -0
  214. package/dist/actions/graphql/extractFromSanitySchema.js +659 -0
  215. package/dist/actions/graphql/extractFromSanitySchema.js.map +1 -0
  216. package/dist/actions/graphql/gen1/generateTypeFilters.js +226 -0
  217. package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -0
  218. package/dist/actions/graphql/gen1/generateTypeQueries.js +85 -0
  219. package/dist/actions/graphql/gen1/generateTypeQueries.js.map +1 -0
  220. package/dist/actions/graphql/gen1/index.js +19 -0
  221. package/dist/actions/graphql/gen1/index.js.map +1 -0
  222. package/dist/actions/graphql/gen2/filters/booleanFilters.js +26 -0
  223. package/dist/actions/graphql/gen2/filters/booleanFilters.js.map +1 -0
  224. package/dist/actions/graphql/gen2/filters/dateFilters.js +46 -0
  225. package/dist/actions/graphql/gen2/filters/dateFilters.js.map +1 -0
  226. package/dist/actions/graphql/gen2/filters/dateTimeFilters.js +46 -0
  227. package/dist/actions/graphql/gen2/filters/dateTimeFilters.js.map +1 -0
  228. package/dist/actions/graphql/gen2/filters/documentFilters.js +21 -0
  229. package/dist/actions/graphql/gen2/filters/documentFilters.js.map +1 -0
  230. package/dist/actions/graphql/gen2/filters/floatFilters.js +46 -0
  231. package/dist/actions/graphql/gen2/filters/floatFilters.js.map +1 -0
  232. package/dist/actions/graphql/gen2/filters/idFilters.js +44 -0
  233. package/dist/actions/graphql/gen2/filters/idFilters.js.map +1 -0
  234. package/dist/actions/graphql/gen2/filters/integerFilters.js +46 -0
  235. package/dist/actions/graphql/gen2/filters/integerFilters.js.map +1 -0
  236. package/dist/actions/graphql/gen2/filters/stringFilters.js +49 -0
  237. package/dist/actions/graphql/gen2/filters/stringFilters.js.map +1 -0
  238. package/dist/actions/graphql/gen2/generateTypeFilters.js +85 -0
  239. package/dist/actions/graphql/gen2/generateTypeFilters.js.map +1 -0
  240. package/dist/actions/graphql/gen2/generateTypeQueries.js +107 -0
  241. package/dist/actions/graphql/gen2/generateTypeQueries.js.map +1 -0
  242. package/dist/actions/graphql/gen2/generateTypeSortings.js +70 -0
  243. package/dist/actions/graphql/gen2/generateTypeSortings.js.map +1 -0
  244. package/dist/actions/graphql/gen2/index.js +22 -0
  245. package/dist/actions/graphql/gen2/index.js.map +1 -0
  246. package/dist/actions/graphql/gen3/filters/documentFilters.js +21 -0
  247. package/dist/actions/graphql/gen3/filters/documentFilters.js.map +1 -0
  248. package/dist/actions/graphql/gen3/generateTypeFilters.js +101 -0
  249. package/dist/actions/graphql/gen3/generateTypeFilters.js.map +1 -0
  250. package/dist/actions/graphql/gen3/generateTypeQueries.js +104 -0
  251. package/dist/actions/graphql/gen3/generateTypeQueries.js.map +1 -0
  252. package/dist/actions/graphql/gen3/generateTypeSortings.js +70 -0
  253. package/dist/actions/graphql/gen3/generateTypeSortings.js.map +1 -0
  254. package/dist/actions/graphql/gen3/index.js +31 -0
  255. package/dist/actions/graphql/gen3/index.js.map +1 -0
  256. package/dist/actions/graphql/gen3/utils.js +12 -0
  257. package/dist/actions/graphql/gen3/utils.js.map +1 -0
  258. package/dist/actions/graphql/getGraphQLAPIs.js +65 -0
  259. package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -0
  260. package/dist/actions/graphql/getGraphQLAPIs.worker.js +126 -0
  261. package/dist/actions/graphql/getGraphQLAPIs.worker.js.map +1 -0
  262. package/dist/actions/graphql/graphqlDebug.js +4 -0
  263. package/dist/actions/graphql/graphqlDebug.js.map +1 -0
  264. package/dist/actions/graphql/helpUrls.js +3 -0
  265. package/dist/actions/graphql/helpUrls.js.map +1 -0
  266. package/dist/actions/graphql/helpers.js +11 -0
  267. package/dist/actions/graphql/helpers.js.map +1 -0
  268. package/dist/actions/graphql/resolveApiGeneration.js +43 -0
  269. package/dist/actions/graphql/resolveApiGeneration.js.map +1 -0
  270. package/dist/actions/graphql/types.js +3 -0
  271. package/dist/actions/graphql/types.js.map +1 -0
  272. package/dist/actions/hook/constants.js +3 -0
  273. package/dist/actions/hook/constants.js.map +1 -0
  274. package/dist/actions/hook/formatFailure.js +29 -0
  275. package/dist/actions/hook/formatFailure.js.map +1 -0
  276. package/dist/actions/hook/types.js +3 -0
  277. package/dist/actions/hook/types.js.map +1 -0
  278. package/dist/actions/init/bootstrapLocalTemplate.js +137 -0
  279. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -0
  280. package/dist/actions/init/bootstrapRemoteTemplate.js +109 -0
  281. package/dist/actions/init/bootstrapRemoteTemplate.js.map +1 -0
  282. package/dist/actions/init/bootstrapTemplate.js +32 -0
  283. package/dist/actions/init/bootstrapTemplate.js.map +1 -0
  284. package/dist/actions/init/checkNextJsReactCompatibility.js +21 -0
  285. package/dist/actions/init/checkNextJsReactCompatibility.js.map +1 -0
  286. package/dist/actions/init/constants.js +3 -0
  287. package/dist/actions/init/constants.js.map +1 -0
  288. package/dist/actions/init/countNestedFolders.js +6 -0
  289. package/dist/actions/init/countNestedFolders.js.map +1 -0
  290. package/dist/actions/init/createAppCliConfig.js +19 -0
  291. package/dist/actions/init/createAppCliConfig.js.map +1 -0
  292. package/dist/actions/init/createCliConfig.js +27 -0
  293. package/dist/actions/init/createCliConfig.js.map +1 -0
  294. package/dist/actions/init/createPackageManifest.js +86 -0
  295. package/dist/actions/init/createPackageManifest.js.map +1 -0
  296. package/dist/actions/init/createStudioConfig.js +41 -0
  297. package/dist/actions/init/createStudioConfig.js.map +1 -0
  298. package/dist/actions/init/determineAppTemplate.js +16 -0
  299. package/dist/actions/init/determineAppTemplate.js.map +1 -0
  300. package/dist/actions/init/env/createOrAppendEnvVars.js +25 -0
  301. package/dist/actions/init/env/createOrAppendEnvVars.js.map +1 -0
  302. package/dist/actions/init/env/parseAndUpdateEnvVars.js +42 -0
  303. package/dist/actions/init/env/parseAndUpdateEnvVars.js.map +1 -0
  304. package/dist/actions/init/env/writeEnvVarsToFile.js +49 -0
  305. package/dist/actions/init/env/writeEnvVarsToFile.js.map +1 -0
  306. package/dist/actions/init/fetchPostInitPrompt.js +30 -0
  307. package/dist/actions/init/fetchPostInitPrompt.js.map +1 -0
  308. package/dist/actions/init/git.js +65 -0
  309. package/dist/actions/init/git.js.map +1 -0
  310. package/dist/actions/init/processTemplate.js +56 -0
  311. package/dist/actions/init/processTemplate.js.map +1 -0
  312. package/dist/actions/init/remoteTemplate.js +211 -0
  313. package/dist/actions/init/remoteTemplate.js.map +1 -0
  314. package/dist/actions/init/resolvePackageManager.js +20 -0
  315. package/dist/actions/init/resolvePackageManager.js.map +1 -0
  316. package/dist/actions/init/templates/appQuickstart.js +28 -0
  317. package/dist/actions/init/templates/appQuickstart.js.map +1 -0
  318. package/dist/actions/init/templates/appSanityUi.js +30 -0
  319. package/dist/actions/init/templates/appSanityUi.js.map +1 -0
  320. package/dist/actions/init/templates/blog.js +4 -0
  321. package/dist/actions/init/templates/blog.js.map +1 -0
  322. package/dist/actions/init/templates/clean.js +4 -0
  323. package/dist/actions/init/templates/clean.js.map +1 -0
  324. package/dist/actions/init/templates/getStarted.js +35 -0
  325. package/dist/actions/init/templates/getStarted.js.map +1 -0
  326. package/dist/actions/init/templates/index.js +23 -0
  327. package/dist/actions/init/templates/index.js.map +1 -0
  328. package/dist/actions/init/templates/moviedb.js +34 -0
  329. package/dist/actions/init/templates/moviedb.js.map +1 -0
  330. package/dist/actions/init/templates/nextjs/index.js +213 -0
  331. package/dist/actions/init/templates/nextjs/index.js.map +1 -0
  332. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js +247 -0
  333. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js.map +1 -0
  334. package/dist/actions/init/templates/quickstart.js +4 -0
  335. package/dist/actions/init/templates/quickstart.js.map +1 -0
  336. package/dist/actions/init/templates/shopify.js +77 -0
  337. package/dist/actions/init/templates/shopify.js.map +1 -0
  338. package/dist/actions/init/templates/shopifyOnline.js +49 -0
  339. package/dist/actions/init/templates/shopifyOnline.js.map +1 -0
  340. package/dist/actions/init/types.js +3 -0
  341. package/dist/actions/init/types.js.map +1 -0
  342. package/dist/actions/init/updateInitialTemplateMetadata.js +17 -0
  343. package/dist/actions/init/updateInitialTemplateMetadata.js.map +1 -0
  344. package/dist/actions/manifest/SchemaIcon.js +21 -0
  345. package/dist/actions/manifest/SchemaIcon.js.map +1 -0
  346. package/dist/actions/manifest/extractAppManifest.js +51 -0
  347. package/dist/actions/manifest/extractAppManifest.js.map +1 -0
  348. package/dist/actions/manifest/extractManifest.js +93 -0
  349. package/dist/actions/manifest/extractManifest.js.map +1 -0
  350. package/dist/actions/manifest/extractWorkspaceManifest.js +406 -0
  351. package/dist/actions/manifest/extractWorkspaceManifest.js.map +1 -0
  352. package/dist/actions/manifest/purifyConfig.js +307 -0
  353. package/dist/actions/manifest/purifyConfig.js.map +1 -0
  354. package/dist/actions/manifest/schemaTypeHelpers.js +110 -0
  355. package/dist/actions/manifest/schemaTypeHelpers.js.map +1 -0
  356. package/dist/actions/manifest/types.js +5 -0
  357. package/dist/actions/manifest/types.js.map +1 -0
  358. package/dist/actions/mcp/detectAvailableEditors.js +75 -0
  359. package/dist/actions/mcp/detectAvailableEditors.js.map +1 -0
  360. package/dist/actions/mcp/editorConfigs.js +147 -0
  361. package/dist/actions/mcp/editorConfigs.js.map +1 -0
  362. package/dist/actions/mcp/promptForMCPSetup.js +24 -0
  363. package/dist/actions/mcp/promptForMCPSetup.js.map +1 -0
  364. package/dist/actions/mcp/setupMCP.js +88 -0
  365. package/dist/actions/mcp/setupMCP.js.map +1 -0
  366. package/dist/actions/mcp/types.js +3 -0
  367. package/dist/actions/mcp/types.js.map +1 -0
  368. package/dist/actions/mcp/writeMCPConfig.js +41 -0
  369. package/dist/actions/mcp/writeMCPConfig.js.map +1 -0
  370. package/dist/actions/media/__tests__/createMockClient.js +32 -0
  371. package/dist/actions/media/__tests__/createMockClient.js.map +1 -0
  372. package/dist/actions/media/getMediaLibraryConfig.js +5 -0
  373. package/dist/actions/media/getMediaLibraryConfig.js.map +1 -0
  374. package/dist/actions/media/importAspects.js +112 -0
  375. package/dist/actions/media/importAspects.js.map +1 -0
  376. package/dist/actions/media/importMedia.js +213 -0
  377. package/dist/actions/media/importMedia.js.map +1 -0
  378. package/dist/actions/media/importMediaDebug.js +4 -0
  379. package/dist/actions/media/importMediaDebug.js.map +1 -0
  380. package/dist/actions/organizations/getOrganization.js +67 -0
  381. package/dist/actions/organizations/getOrganization.js.map +1 -0
  382. package/dist/actions/organizations/getOrganizationChoices.js +23 -0
  383. package/dist/actions/organizations/getOrganizationChoices.js.map +1 -0
  384. package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js +9 -0
  385. package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js.map +1 -0
  386. package/dist/actions/organizations/hasProjectAttachGrant.js +24 -0
  387. package/dist/actions/organizations/hasProjectAttachGrant.js.map +1 -0
  388. package/dist/actions/organizations/validateOrganizationName.js +10 -0
  389. package/dist/actions/organizations/validateOrganizationName.js.map +1 -0
  390. package/dist/actions/preview/getPreviewServerConfig.js +16 -0
  391. package/dist/actions/preview/getPreviewServerConfig.js.map +1 -0
  392. package/dist/actions/preview/previewAction.js +20 -0
  393. package/dist/actions/preview/previewAction.js.map +1 -0
  394. package/dist/actions/preview/types.js +3 -0
  395. package/dist/actions/preview/types.js.map +1 -0
  396. package/dist/actions/projects/getManageUrl.js +7 -0
  397. package/dist/actions/projects/getManageUrl.js.map +1 -0
  398. package/dist/actions/projects/validateProjectName.js +11 -0
  399. package/dist/actions/projects/validateProjectName.js.map +1 -0
  400. package/dist/actions/schema/deleteSchemaAction.js +101 -0
  401. package/dist/actions/schema/deleteSchemaAction.js.map +1 -0
  402. package/dist/actions/schema/deploySchemas.js +98 -0
  403. package/dist/actions/schema/deploySchemas.js.map +1 -0
  404. package/dist/actions/schema/extractSanitySchema.worker.js +38 -0
  405. package/dist/actions/schema/extractSanitySchema.worker.js.map +1 -0
  406. package/dist/actions/schema/extractSchema.js +77 -0
  407. package/dist/actions/schema/extractSchema.js.map +1 -0
  408. package/dist/actions/schema/formatSchemaValidation.js +74 -0
  409. package/dist/actions/schema/formatSchemaValidation.js.map +1 -0
  410. package/dist/actions/schema/listSchemas.js +119 -0
  411. package/dist/actions/schema/listSchemas.js.map +1 -0
  412. package/dist/actions/schema/metafile.js +51 -0
  413. package/dist/actions/schema/metafile.js.map +1 -0
  414. package/dist/actions/schema/schemaStoreTypes.js +19 -0
  415. package/dist/actions/schema/schemaStoreTypes.js.map +1 -0
  416. package/dist/actions/schema/types.js +9 -0
  417. package/dist/actions/schema/types.js.map +1 -0
  418. package/dist/actions/schema/utils/debug.js +6 -0
  419. package/dist/actions/schema/utils/debug.js.map +1 -0
  420. package/dist/actions/schema/utils/extractValidationFromSchemaError.js +12 -0
  421. package/dist/actions/schema/utils/extractValidationFromSchemaError.js.map +1 -0
  422. package/dist/actions/schema/utils/manifestExtractor.js +33 -0
  423. package/dist/actions/schema/utils/manifestExtractor.js.map +1 -0
  424. package/dist/actions/schema/utils/manifestReader.js +71 -0
  425. package/dist/actions/schema/utils/manifestReader.js.map +1 -0
  426. package/dist/actions/schema/utils/schemaStoreOutStrings.js +11 -0
  427. package/dist/actions/schema/utils/schemaStoreOutStrings.js.map +1 -0
  428. package/dist/actions/schema/utils/schemaStoreValidation.js +108 -0
  429. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -0
  430. package/dist/actions/schema/utils/uniqByProjectIdDataset.js +9 -0
  431. package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -0
  432. package/dist/actions/schema/utils/workspaceSchemaId.js +23 -0
  433. package/dist/actions/schema/utils/workspaceSchemaId.js.map +1 -0
  434. package/dist/actions/schema/validateAction.js +71 -0
  435. package/dist/actions/schema/validateAction.js.map +1 -0
  436. package/dist/actions/schema/validateSchema.worker.js +124 -0
  437. package/dist/actions/schema/validateSchema.worker.js.map +1 -0
  438. package/dist/actions/telemetry/getLearnMoreMessage.js +15 -0
  439. package/dist/actions/telemetry/getLearnMoreMessage.js.map +1 -0
  440. package/dist/actions/telemetry/getStatusDisplay.js +26 -0
  441. package/dist/actions/telemetry/getStatusDisplay.js.map +1 -0
  442. package/dist/actions/telemetry/getStatusMessage.js +36 -0
  443. package/dist/actions/telemetry/getStatusMessage.js.map +1 -0
  444. package/dist/actions/telemetry/resolveConsent.js +48 -0
  445. package/dist/actions/telemetry/resolveConsent.js.map +1 -0
  446. package/dist/actions/telemetry/setConsent.js +83 -0
  447. package/dist/actions/telemetry/setConsent.js.map +1 -0
  448. package/dist/actions/telemetry/telemetryDebug.js +4 -0
  449. package/dist/actions/telemetry/telemetryDebug.js.map +1 -0
  450. package/dist/actions/telemetry/telemetryDisclosure.js +33 -0
  451. package/dist/actions/telemetry/telemetryDisclosure.js.map +1 -0
  452. package/dist/actions/telemetry/telemetryLearnMoreMessage.js +15 -0
  453. package/dist/actions/telemetry/telemetryLearnMoreMessage.js.map +1 -0
  454. package/dist/actions/tokens/constants.js +5 -0
  455. package/dist/actions/tokens/constants.js.map +1 -0
  456. package/dist/actions/tokens/types.js +3 -0
  457. package/dist/actions/tokens/types.js.map +1 -0
  458. package/dist/actions/tokens/validateRole.js +23 -0
  459. package/dist/actions/tokens/validateRole.js.map +1 -0
  460. package/dist/actions/undeploy/getStudioOrAppUserApplication.js +36 -0
  461. package/dist/actions/undeploy/getStudioOrAppUserApplication.js.map +1 -0
  462. package/dist/actions/users/getMembersForProject.js +47 -0
  463. package/dist/actions/users/getMembersForProject.js.map +1 -0
  464. package/dist/actions/users/getPendingInvitations.js +15 -0
  465. package/dist/actions/users/getPendingInvitations.js.map +1 -0
  466. package/dist/actions/users/types.js +3 -0
  467. package/dist/actions/users/types.js.map +1 -0
  468. package/dist/actions/users/usersDebug.js +4 -0
  469. package/dist/actions/users/usersDebug.js.map +1 -0
  470. package/dist/actions/users/validateEmail.js +14 -0
  471. package/dist/actions/users/validateEmail.js.map +1 -0
  472. package/dist/actions/versions/buildPackageArray.js +44 -0
  473. package/dist/actions/versions/buildPackageArray.js.map +1 -0
  474. package/dist/actions/versions/filterSanityModules.js +20 -0
  475. package/dist/actions/versions/filterSanityModules.js.map +1 -0
  476. package/dist/actions/versions/findSanityModulesVersions.js +47 -0
  477. package/dist/actions/versions/findSanityModulesVersions.js.map +1 -0
  478. package/dist/actions/versions/getFormatters.js +30 -0
  479. package/dist/actions/versions/getFormatters.js.map +1 -0
  480. package/dist/actions/versions/tryFindLatestVersion.js +21 -0
  481. package/dist/actions/versions/tryFindLatestVersion.js.map +1 -0
  482. package/dist/actions/versions/types.js +5 -0
  483. package/dist/actions/versions/types.js.map +1 -0
  484. package/dist/actions/versions/versionsDebug.js +4 -0
  485. package/dist/actions/versions/versionsDebug.js.map +1 -0
  486. package/dist/commands/backup/disable.js +94 -0
  487. package/dist/commands/backup/disable.js.map +1 -0
  488. package/dist/commands/backup/download.js +291 -0
  489. package/dist/commands/backup/download.js.map +1 -0
  490. package/dist/commands/backup/enable.js +99 -0
  491. package/dist/commands/backup/enable.js.map +1 -0
  492. package/dist/commands/backup/list.js +187 -0
  493. package/dist/commands/backup/list.js.map +1 -0
  494. package/dist/commands/build.js +82 -0
  495. package/dist/commands/build.js.map +1 -0
  496. package/dist/commands/codemod.js +141 -0
  497. package/dist/commands/codemod.js.map +1 -0
  498. package/dist/commands/cors/add.js +154 -0
  499. package/dist/commands/cors/add.js.map +1 -0
  500. package/dist/commands/cors/delete.js +90 -0
  501. package/dist/commands/cors/delete.js.map +1 -0
  502. package/dist/commands/cors/list.js +40 -0
  503. package/dist/commands/cors/list.js.map +1 -0
  504. package/dist/commands/dataset/alias/create.js +118 -0
  505. package/dist/commands/dataset/alias/create.js.map +1 -0
  506. package/dist/commands/dataset/alias/delete.js +88 -0
  507. package/dist/commands/dataset/alias/delete.js.map +1 -0
  508. package/dist/commands/dataset/alias/link.js +137 -0
  509. package/dist/commands/dataset/alias/link.js.map +1 -0
  510. package/dist/commands/dataset/alias/unlink.js +98 -0
  511. package/dist/commands/dataset/alias/unlink.js.map +1 -0
  512. package/dist/commands/dataset/copy.js +369 -0
  513. package/dist/commands/dataset/copy.js.map +1 -0
  514. package/dist/commands/dataset/create.js +106 -0
  515. package/dist/commands/dataset/create.js.map +1 -0
  516. package/dist/commands/dataset/delete.js +104 -0
  517. package/dist/commands/dataset/delete.js.map +1 -0
  518. package/dist/commands/dataset/export.js +271 -0
  519. package/dist/commands/dataset/export.js.map +1 -0
  520. package/dist/commands/dataset/import.js +3 -0
  521. package/dist/commands/dataset/import.js.map +1 -0
  522. package/dist/commands/dataset/list.js +50 -0
  523. package/dist/commands/dataset/list.js.map +1 -0
  524. package/dist/commands/dataset/visibility/get.js +55 -0
  525. package/dist/commands/dataset/visibility/get.js.map +1 -0
  526. package/dist/commands/dataset/visibility/set.js +88 -0
  527. package/dist/commands/dataset/visibility/set.js.map +1 -0
  528. package/dist/commands/debug.js +93 -0
  529. package/dist/commands/debug.js.map +1 -0
  530. package/dist/commands/deploy.js +115 -0
  531. package/dist/commands/deploy.js.map +1 -0
  532. package/dist/commands/dev.js +65 -0
  533. package/dist/commands/dev.js.map +1 -0
  534. package/dist/commands/docs/browse.js +15 -0
  535. package/dist/commands/docs/browse.js.map +1 -0
  536. package/dist/commands/docs/read.js +81 -0
  537. package/dist/commands/docs/read.js.map +1 -0
  538. package/dist/commands/docs/search.js +111 -0
  539. package/dist/commands/docs/search.js.map +1 -0
  540. package/dist/commands/documents/create.js +338 -0
  541. package/dist/commands/documents/create.js.map +1 -0
  542. package/dist/commands/documents/delete.js +104 -0
  543. package/dist/commands/documents/delete.js.map +1 -0
  544. package/dist/commands/documents/get.js +85 -0
  545. package/dist/commands/documents/get.js.map +1 -0
  546. package/dist/commands/documents/query.js +105 -0
  547. package/dist/commands/documents/query.js.map +1 -0
  548. package/dist/commands/documents/validate.js +142 -0
  549. package/dist/commands/documents/validate.js.map +1 -0
  550. package/dist/commands/exec.js +54 -0
  551. package/dist/commands/exec.js.map +1 -0
  552. package/dist/commands/graphql/deploy.js +429 -0
  553. package/dist/commands/graphql/deploy.js.map +1 -0
  554. package/dist/commands/graphql/list.js +53 -0
  555. package/dist/commands/graphql/list.js.map +1 -0
  556. package/dist/commands/graphql/undeploy.js +143 -0
  557. package/dist/commands/graphql/undeploy.js.map +1 -0
  558. package/dist/commands/hook/attempt.js +66 -0
  559. package/dist/commands/hook/attempt.js.map +1 -0
  560. package/dist/commands/hook/create.js +46 -0
  561. package/dist/commands/hook/create.js.map +1 -0
  562. package/dist/commands/hook/delete.js +86 -0
  563. package/dist/commands/hook/delete.js.map +1 -0
  564. package/dist/commands/hook/list.js +46 -0
  565. package/dist/commands/hook/list.js.map +1 -0
  566. package/dist/commands/hook/logs.js +184 -0
  567. package/dist/commands/hook/logs.js.map +1 -0
  568. package/dist/commands/init.js +1389 -0
  569. package/dist/commands/init.js.map +1 -0
  570. package/dist/commands/install.js +43 -0
  571. package/dist/commands/install.js.map +1 -0
  572. package/dist/commands/learn.js +15 -0
  573. package/dist/commands/learn.js.map +1 -0
  574. package/dist/commands/login.js +50 -0
  575. package/dist/commands/login.js.map +1 -0
  576. package/dist/commands/logout.js +37 -0
  577. package/dist/commands/logout.js.map +1 -0
  578. package/dist/commands/manage.js +29 -0
  579. package/dist/commands/manage.js.map +1 -0
  580. package/dist/commands/manifest/extract.js +43 -0
  581. package/dist/commands/manifest/extract.js.map +1 -0
  582. package/dist/commands/mcp/configure.js +28 -0
  583. package/dist/commands/mcp/configure.js.map +1 -0
  584. package/dist/commands/media/create-aspect.js +88 -0
  585. package/dist/commands/media/create-aspect.js.map +1 -0
  586. package/dist/commands/media/delete-aspect.js +85 -0
  587. package/dist/commands/media/delete-aspect.js.map +1 -0
  588. package/dist/commands/media/deploy-aspect.js +151 -0
  589. package/dist/commands/media/deploy-aspect.js.map +1 -0
  590. package/dist/commands/media/export.js +210 -0
  591. package/dist/commands/media/export.js.map +1 -0
  592. package/dist/commands/media/import.js +160 -0
  593. package/dist/commands/media/import.js.map +1 -0
  594. package/dist/commands/openapi/get.js +83 -0
  595. package/dist/commands/openapi/get.js.map +1 -0
  596. package/dist/commands/openapi/list.js +80 -0
  597. package/dist/commands/openapi/list.js.map +1 -0
  598. package/dist/commands/preview.js +60 -0
  599. package/dist/commands/preview.js.map +1 -0
  600. package/dist/commands/projects/create.js +181 -0
  601. package/dist/commands/projects/create.js.map +1 -0
  602. package/dist/commands/projects/list.js +76 -0
  603. package/dist/commands/projects/list.js.map +1 -0
  604. package/dist/commands/schema/delete.js +91 -0
  605. package/dist/commands/schema/delete.js.map +1 -0
  606. package/dist/commands/schema/deploy.js +98 -0
  607. package/dist/commands/schema/deploy.js.map +1 -0
  608. package/dist/commands/schema/extract.js +46 -0
  609. package/dist/commands/schema/extract.js.map +1 -0
  610. package/dist/commands/schema/list.js +104 -0
  611. package/dist/commands/schema/list.js.map +1 -0
  612. package/dist/commands/schema/validate.js +73 -0
  613. package/dist/commands/schema/validate.js.map +1 -0
  614. package/dist/commands/telemetry/disable.js +33 -0
  615. package/dist/commands/telemetry/disable.js.map +1 -0
  616. package/dist/commands/telemetry/enable.js +33 -0
  617. package/dist/commands/telemetry/enable.js.map +1 -0
  618. package/dist/commands/telemetry/status.js +25 -0
  619. package/dist/commands/telemetry/status.js.map +1 -0
  620. package/dist/commands/tokens/add.js +135 -0
  621. package/dist/commands/tokens/add.js.map +1 -0
  622. package/dist/commands/tokens/delete.js +107 -0
  623. package/dist/commands/tokens/delete.js.map +1 -0
  624. package/dist/commands/tokens/list.js +92 -0
  625. package/dist/commands/tokens/list.js.map +1 -0
  626. package/dist/commands/undeploy.js +93 -0
  627. package/dist/commands/undeploy.js.map +1 -0
  628. package/dist/commands/users/invite.js +100 -0
  629. package/dist/commands/users/invite.js.map +1 -0
  630. package/dist/commands/users/list.js +101 -0
  631. package/dist/commands/users/list.js.map +1 -0
  632. package/dist/commands/versions.js +27 -0
  633. package/dist/commands/versions.js.map +1 -0
  634. package/dist/config/createCliConfig.js +9 -0
  635. package/dist/config/createCliConfig.js.map +1 -0
  636. package/dist/config/defineCliConfig.js +5 -0
  637. package/dist/config/defineCliConfig.js.map +1 -0
  638. package/dist/hooks/prerun/flushTelemetry.worker.js +22 -0
  639. package/dist/hooks/prerun/flushTelemetry.worker.js.map +1 -0
  640. package/dist/hooks/prerun/injectEnvVariables.js +31 -0
  641. package/dist/hooks/prerun/injectEnvVariables.js.map +1 -0
  642. package/dist/hooks/prerun/setupTelemetry.js +72 -0
  643. package/dist/hooks/prerun/setupTelemetry.js.map +1 -0
  644. package/dist/hooks/prerun/warnings.js +6 -0
  645. package/dist/hooks/prerun/warnings.js.map +1 -0
  646. package/dist/index.d.ts +2326 -0
  647. package/dist/index.js +6 -0
  648. package/dist/index.js.map +1 -0
  649. package/dist/prompts/init/nextjs.js +56 -0
  650. package/dist/prompts/init/nextjs.js.map +1 -0
  651. package/dist/prompts/init/promptForTypescript.js +9 -0
  652. package/dist/prompts/init/promptForTypescript.js.map +1 -0
  653. package/dist/prompts/promptForDataset.js +32 -0
  654. package/dist/prompts/promptForDataset.js.map +1 -0
  655. package/dist/prompts/promptForDatasetAclMode.js +27 -0
  656. package/dist/prompts/promptForDatasetAclMode.js.map +1 -0
  657. package/dist/prompts/promptForDatasetAliasName.js +17 -0
  658. package/dist/prompts/promptForDatasetAliasName.js.map +1 -0
  659. package/dist/prompts/promptForDatasetName.js +20 -0
  660. package/dist/prompts/promptForDatasetName.js.map +1 -0
  661. package/dist/prompts/promptForDefaultConfig.js +12 -0
  662. package/dist/prompts/promptForDefaultConfig.js.map +1 -0
  663. package/dist/prompts/promptForMediaLibrary.js +37 -0
  664. package/dist/prompts/promptForMediaLibrary.js.map +1 -0
  665. package/dist/prompts/promptForOrganizationName.js +11 -0
  666. package/dist/prompts/promptForOrganizationName.js.map +1 -0
  667. package/dist/prompts/promptForProjectName.js +11 -0
  668. package/dist/prompts/promptForProjectName.js.map +1 -0
  669. package/dist/prompts/selectDataset.js +12 -0
  670. package/dist/prompts/selectDataset.js.map +1 -0
  671. package/dist/prompts/selectMediaLibrary.js +34 -0
  672. package/dist/prompts/selectMediaLibrary.js.map +1 -0
  673. package/dist/server/devServer.js +53 -0
  674. package/dist/server/devServer.js.map +1 -0
  675. package/dist/server/gracefulServerDeath.js +12 -0
  676. package/dist/server/gracefulServerDeath.js.map +1 -0
  677. package/dist/server/previewServer.js +93 -0
  678. package/dist/server/previewServer.js.map +1 -0
  679. package/dist/server/serverDebug.js +4 -0
  680. package/dist/server/serverDebug.js.map +1 -0
  681. package/dist/server/vite/plugin-sanity-basepath-redirect.js +25 -0
  682. package/dist/server/vite/plugin-sanity-basepath-redirect.js.map +1 -0
  683. package/dist/server/vite/plugin-sanity-build-entries.js +65 -0
  684. package/dist/server/vite/plugin-sanity-build-entries.js.map +1 -0
  685. package/dist/server/vite/plugin-sanity-favicons.js +72 -0
  686. package/dist/server/vite/plugin-sanity-favicons.js.map +1 -0
  687. package/dist/server/vite/plugin-sanity-runtime-rewrite.js +18 -0
  688. package/dist/server/vite/plugin-sanity-runtime-rewrite.js.map +1 -0
  689. package/dist/services/auth.js +13 -0
  690. package/dist/services/auth.js.map +1 -0
  691. package/dist/services/backup.js +51 -0
  692. package/dist/services/backup.js.map +1 -0
  693. package/dist/services/cors.js +38 -0
  694. package/dist/services/cors.js.map +1 -0
  695. package/dist/services/datasetAliases.js +64 -0
  696. package/dist/services/datasetAliases.js.map +1 -0
  697. package/dist/services/datasets.js +153 -0
  698. package/dist/services/datasets.js.map +1 -0
  699. package/dist/services/docs.js +46 -0
  700. package/dist/services/docs.js.map +1 -0
  701. package/dist/services/documents.js +56 -0
  702. package/dist/services/documents.js.map +1 -0
  703. package/dist/services/getProjectFeatures.js +16 -0
  704. package/dist/services/getProjectFeatures.js.map +1 -0
  705. package/dist/services/getUrlHeaders.js +36 -0
  706. package/dist/services/getUrlHeaders.js.map +1 -0
  707. package/dist/services/graphql.js +96 -0
  708. package/dist/services/graphql.js.map +1 -0
  709. package/dist/services/hooks.js +59 -0
  710. package/dist/services/hooks.js.map +1 -0
  711. package/dist/services/mcp.js +50 -0
  712. package/dist/services/mcp.js.map +1 -0
  713. package/dist/services/mediaLibraries.js +74 -0
  714. package/dist/services/mediaLibraries.js.map +1 -0
  715. package/dist/services/organizations.js +42 -0
  716. package/dist/services/organizations.js.map +1 -0
  717. package/dist/services/plans.js +37 -0
  718. package/dist/services/plans.js.map +1 -0
  719. package/dist/services/projects.js +119 -0
  720. package/dist/services/projects.js.map +1 -0
  721. package/dist/services/schemas.js +40 -0
  722. package/dist/services/schemas.js.map +1 -0
  723. package/dist/services/telemetry.js +80 -0
  724. package/dist/services/telemetry.js.map +1 -0
  725. package/dist/services/tokens.js +72 -0
  726. package/dist/services/tokens.js.map +1 -0
  727. package/dist/services/user.js +35 -0
  728. package/dist/services/user.js.map +1 -0
  729. package/dist/services/userApplications.js +164 -0
  730. package/dist/services/userApplications.js.map +1 -0
  731. package/dist/studioDependencies.js +24 -0
  732. package/dist/studioDependencies.js.map +1 -0
  733. package/dist/telemetry/build.telemetry.js +13 -0
  734. package/dist/telemetry/build.telemetry.js.map +1 -0
  735. package/dist/telemetry/cli.telemetry.js +8 -0
  736. package/dist/telemetry/cli.telemetry.js.map +1 -0
  737. package/dist/telemetry/extractSchema.telemetry.js +8 -0
  738. package/dist/telemetry/extractSchema.telemetry.js.map +1 -0
  739. package/dist/telemetry/init.telemetry.js +8 -0
  740. package/dist/telemetry/init.telemetry.js.map +1 -0
  741. package/dist/telemetry/login.telemetry.js +8 -0
  742. package/dist/telemetry/login.telemetry.js.map +1 -0
  743. package/dist/telemetry/mcp.telemetry.js +8 -0
  744. package/dist/telemetry/mcp.telemetry.js.map +1 -0
  745. package/dist/types.js +5 -0
  746. package/dist/types.js.map +1 -0
  747. package/dist/typings/deepSortObject.d.js +2 -0
  748. package/dist/typings/deepSortObject.d.js.map +1 -0
  749. package/dist/util/absolutify.js +26 -0
  750. package/dist/util/absolutify.js.map +1 -0
  751. package/dist/util/appId.js +58 -0
  752. package/dist/util/appId.js.map +1 -0
  753. package/dist/util/canLaunchBrowser.js +14 -0
  754. package/dist/util/canLaunchBrowser.js.map +1 -0
  755. package/dist/util/cliClient.js +41 -0
  756. package/dist/util/cliClient.js.map +1 -0
  757. package/dist/util/compareDependencyVersions.js +73 -0
  758. package/dist/util/compareDependencyVersions.js.map +1 -0
  759. package/dist/util/copy.js +37 -0
  760. package/dist/util/copy.js.map +1 -0
  761. package/dist/util/copyDir.js +63 -0
  762. package/dist/util/copyDir.js.map +1 -0
  763. package/dist/util/detectRuntime.js +20 -0
  764. package/dist/util/detectRuntime.js.map +1 -0
  765. package/dist/util/determineIsApp.js +9 -0
  766. package/dist/util/determineIsApp.js.map +1 -0
  767. package/dist/util/dirIsEmptyOrNonExistent.js +18 -0
  768. package/dist/util/dirIsEmptyOrNonExistent.js.map +1 -0
  769. package/dist/util/ensureTrailingSlash.js +12 -0
  770. package/dist/util/ensureTrailingSlash.js.map +1 -0
  771. package/dist/util/errorMessages.js +6 -0
  772. package/dist/util/errorMessages.js.map +1 -0
  773. package/dist/util/extractDocumentsFromNdjsonOrTarball.js +88 -0
  774. package/dist/util/extractDocumentsFromNdjsonOrTarball.js.map +1 -0
  775. package/dist/util/findNdjsonEntry.js +21 -0
  776. package/dist/util/findNdjsonEntry.js.map +1 -0
  777. package/dist/util/formatSize.js +10 -0
  778. package/dist/util/formatSize.js.map +1 -0
  779. package/dist/util/frameworkPort.js +61 -0
  780. package/dist/util/frameworkPort.js.map +1 -0
  781. package/dist/util/fsUtils.js +34 -0
  782. package/dist/util/fsUtils.js.map +1 -0
  783. package/dist/util/getCliVersion.js +28 -0
  784. package/dist/util/getCliVersion.js.map +1 -0
  785. package/dist/util/getErrorMessage.js +19 -0
  786. package/dist/util/getErrorMessage.js.map +1 -0
  787. package/dist/util/getLocalPackageVersion.js +32 -0
  788. package/dist/util/getLocalPackageVersion.js.map +1 -0
  789. package/dist/util/getProjectDefaults.js +77 -0
  790. package/dist/util/getProjectDefaults.js.map +1 -0
  791. package/dist/util/getSanityEnv.js +3 -0
  792. package/dist/util/getSanityEnv.js.map +1 -0
  793. package/dist/util/getSharedServerConfig.js +31 -0
  794. package/dist/util/getSharedServerConfig.js.map +1 -0
  795. package/dist/util/getWorkspace.js +18 -0
  796. package/dist/util/getWorkspace.js.map +1 -0
  797. package/dist/util/humanFileSize.js +12 -0
  798. package/dist/util/humanFileSize.js.map +1 -0
  799. package/dist/util/importStudioConfig.js +40 -0
  800. package/dist/util/importStudioConfig.js.map +1 -0
  801. package/dist/util/isPathDirName.js +6 -0
  802. package/dist/util/isPathDirName.js.map +1 -0
  803. package/dist/util/isSanityDocumentish.js +20 -0
  804. package/dist/util/isSanityDocumentish.js.map +1 -0
  805. package/dist/util/loadEnv.js +3 -0
  806. package/dist/util/loadEnv.js.map +1 -0
  807. package/dist/util/moduleFormatUtils.js +18 -0
  808. package/dist/util/moduleFormatUtils.js.map +1 -0
  809. package/dist/util/packageManager/installPackages.js +87 -0
  810. package/dist/util/packageManager/installPackages.js.map +1 -0
  811. package/dist/util/packageManager/packageManagerChoice.js +181 -0
  812. package/dist/util/packageManager/packageManagerChoice.js.map +1 -0
  813. package/dist/util/packageManager/upgradePackages.js +69 -0
  814. package/dist/util/packageManager/upgradePackages.js.map +1 -0
  815. package/dist/util/parseArguments.js +42 -0
  816. package/dist/util/parseArguments.js.map +1 -0
  817. package/dist/util/pluralize.js +11 -0
  818. package/dist/util/pluralize.js.map +1 -0
  819. package/dist/util/readModuleVersion.js +15 -0
  820. package/dist/util/readModuleVersion.js.map +1 -0
  821. package/dist/util/readPackageJson.js +44 -0
  822. package/dist/util/readPackageJson.js.map +1 -0
  823. package/dist/util/readPackageManifest.js +46 -0
  824. package/dist/util/readPackageManifest.js.map +1 -0
  825. package/dist/util/readdirRecursive.js +24 -0
  826. package/dist/util/readdirRecursive.js.map +1 -0
  827. package/dist/util/resolveLatestVersions.js +21 -0
  828. package/dist/util/resolveLatestVersions.js.map +1 -0
  829. package/dist/util/toInt.js +9 -0
  830. package/dist/util/toInt.js.map +1 -0
  831. package/dist/util/trimHashFromVersion.js +8 -0
  832. package/dist/util/trimHashFromVersion.js.map +1 -0
  833. package/dist/util/uniqBy.js +14 -0
  834. package/dist/util/uniqBy.js.map +1 -0
  835. package/dist/util/validation/validateDocumentsUtils.js +33 -0
  836. package/dist/util/validation/validateDocumentsUtils.js.map +1 -0
  837. package/dist/util/warnAboutMissingAppId.js +15 -0
  838. package/dist/util/warnAboutMissingAppId.js.map +1 -0
  839. package/dist/util/warnOnNonProductionEnvironment.js +18 -0
  840. package/dist/util/warnOnNonProductionEnvironment.js.map +1 -0
  841. package/dist/util/workerChannels.js +172 -0
  842. package/dist/util/workerChannels.js.map +1 -0
  843. package/oclif.config.js +21 -0
  844. package/oclif.manifest.json +4154 -0
  845. package/package.json +138 -98
  846. package/templates/app-quickstart/src/App.css +3 -1
  847. package/templates/app-quickstart/src/App.tsx +1 -1
  848. package/templates/app-sanity-ui/src/App.tsx +2 -2
  849. package/templates/app-sanity-ui/src/ExampleComponent.tsx +2 -1
  850. package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +3 -3
  851. package/templates/get-started/plugins/sanity-plugin-tutorial/index.ts +2 -2
  852. package/templates/shopify/components/hotspots/ProductTooltip.tsx +1 -1
  853. package/templates/shopify/components/icons/Shopify.tsx +0 -2
  854. package/templates/shopify/components/inputs/CollectionHidden.tsx +0 -1
  855. package/templates/shopify/components/media/ColorTheme.tsx +1 -1
  856. package/templates/shopify/constants.ts +4 -4
  857. package/templates/shopify/plugins/customDocumentActions/index.ts +2 -2
  858. package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +1 -1
  859. package/templates/shopify/schemaTypes/documents/collection.tsx +1 -2
  860. package/templates/shopify/schemaTypes/documents/page.ts +1 -1
  861. package/templates/shopify/schemaTypes/documents/product.tsx +1 -1
  862. package/templates/shopify/schemaTypes/documents/productVariant.tsx +2 -3
  863. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx +0 -1
  864. package/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx +1 -3
  865. package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +0 -1
  866. package/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts +2 -3
  867. package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +1 -1
  868. package/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts +1 -2
  869. package/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts +1 -2
  870. package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +7 -7
  871. package/templates/shopify/schemaTypes/singletons/homeType.ts +8 -8
  872. package/templates/shopify/structure/collectionStructure.ts +4 -1
  873. package/templates/shopify/structure/colorThemeStructure.ts +1 -1
  874. package/templates/shopify/structure/homeStructure.ts +2 -2
  875. package/templates/shopify/structure/index.ts +1 -1
  876. package/templates/shopify/structure/pageStructure.ts +2 -2
  877. package/templates/shopify/structure/productStructure.ts +7 -7
  878. package/templates/shopify/structure/settingStructure.ts +1 -1
  879. package/templates/shopify/utils/defineStructure.ts +1 -1
  880. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/index.ts +1 -1
  881. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +1 -1
  882. package/templates/shopify-online-storefront/structure/collectionStructure.ts +4 -1
  883. package/templates/shopify-online-storefront/structure/productStructure.ts +4 -4
  884. package/templates/shopify-online-storefront/utils/defineStructure.ts +1 -1
  885. package/bin/dev.js +0 -30
  886. package/bin/sanity +0 -14
  887. package/lib/_chunks-cjs/cli.js +0 -70870
  888. package/lib/_chunks-cjs/cli.js.map +0 -1
  889. package/lib/_chunks-cjs/cliWorker.js +0 -19
  890. package/lib/_chunks-cjs/cliWorker.js.map +0 -1
  891. package/lib/_chunks-cjs/generateAction.js +0 -128
  892. package/lib/_chunks-cjs/generateAction.js.map +0 -1
  893. package/lib/_chunks-cjs/getCliConfig.js +0 -89
  894. package/lib/_chunks-cjs/getCliConfig.js.map +0 -1
  895. package/lib/_chunks-cjs/index.js +0 -31
  896. package/lib/_chunks-cjs/index.js.map +0 -1
  897. package/lib/_chunks-cjs/journeyConfig.js +0 -113
  898. package/lib/_chunks-cjs/journeyConfig.js.map +0 -1
  899. package/lib/_chunks-cjs/loadEnv.js +0 -347
  900. package/lib/_chunks-cjs/loadEnv.js.map +0 -1
  901. package/lib/_chunks-dts/types.d.ts +0 -432
  902. package/lib/cli.d.ts +0 -7
  903. package/lib/cli.js +0 -10
  904. package/lib/cli.js.map +0 -1
  905. package/lib/index.d.ts +0 -44
  906. package/lib/index.js +0 -46
  907. package/lib/index.js.map +0 -1
  908. package/lib/run.d.ts +0 -1
  909. package/lib/run.js +0 -8
  910. package/lib/run.js.map +0 -1
  911. package/lib/workers/getAndWriteJourneySchema.d.ts +0 -1
  912. package/lib/workers/getAndWriteJourneySchema.js +0 -4
  913. package/lib/workers/getAndWriteJourneySchema.js.map +0 -1
  914. package/lib/workers/getCliConfig.d.ts +0 -1
  915. package/lib/workers/getCliConfig.js +0 -10
  916. package/lib/workers/getCliConfig.js.map +0 -1
  917. package/lib/workers/typegenGenerate.d.ts +0 -18
  918. package/lib/workers/typegenGenerate.js +0 -47
  919. package/lib/workers/typegenGenerate.js.map +0 -1
@@ -0,0 +1,1389 @@
1
+ // @Todo will remove by time migration of this command is complete
2
+ import { existsSync } from 'node:fs';
3
+ import { mkdir, writeFile } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { styleText } from 'node:util';
6
+ import { Args, Flags } from '@oclif/core';
7
+ import { CLIError } from '@oclif/core/errors';
8
+ import { getCliToken, SanityCommand, subdebug } from '@sanity/cli-core';
9
+ import { confirm, input, logSymbols, select, Separator, spinner } from '@sanity/cli-core/ux';
10
+ import { isHttpError } from '@sanity/client';
11
+ import { DatasetImportCommand } from '@sanity/import';
12
+ import { frameworks } from '@vercel/frameworks';
13
+ import { detectFrameworkRecord, LocalFileSystemDetector } from '@vercel/fs-detectors';
14
+ import { execa } from 'execa';
15
+ import { deburr } from 'lodash-es';
16
+ import { getProviderName } from '../actions/auth/getProviderName.js';
17
+ import { login } from '../actions/auth/login/login.js';
18
+ import { createDataset } from '../actions/dataset/create.js';
19
+ import { bootstrapTemplate } from '../actions/init/bootstrapTemplate.js';
20
+ import { checkNextJsReactCompatibility } from '../actions/init/checkNextJsReactCompatibility.js';
21
+ import { countNestedFolders } from '../actions/init/countNestedFolders.js';
22
+ import { determineAppTemplate } from '../actions/init/determineAppTemplate.js';
23
+ import { createOrAppendEnvVars } from '../actions/init/env/createOrAppendEnvVars.js';
24
+ import { fetchPostInitPrompt } from '../actions/init/fetchPostInitPrompt.js';
25
+ import { tryGitInit } from '../actions/init/git.js';
26
+ import { checkIsRemoteTemplate, getGitHubRepoInfo } from '../actions/init/remoteTemplate.js';
27
+ import { resolvePackageManager } from '../actions/init/resolvePackageManager.js';
28
+ import templates from '../actions/init/templates/index.js';
29
+ import { sanityCliTemplate, sanityConfigTemplate, sanityFolder, sanityStudioTemplate } from '../actions/init/templates/nextjs/index.js';
30
+ import { setupMCP } from '../actions/mcp/setupMCP.js';
31
+ import { getOrganizationChoices } from '../actions/organizations/getOrganizationChoices.js';
32
+ import { getOrganizationsWithAttachGrantInfo } from '../actions/organizations/getOrganizationsWithAttachGrantInfo.js';
33
+ import { hasProjectAttachGrant } from '../actions/organizations/hasProjectAttachGrant.js';
34
+ import { promptForAppendEnv, promptForConfigFiles, promptForEmbeddedStudio, promptForNextTemplate, promptForStudioPath } from '../prompts/init/nextjs.js';
35
+ import { promptForTypeScript } from '../prompts/init/promptForTypescript.js';
36
+ import { promptForDatasetName } from '../prompts/promptForDatasetName.js';
37
+ import { promptForDefaultConfig } from '../prompts/promptForDefaultConfig.js';
38
+ import { promptForOrganizationName } from '../prompts/promptForOrganizationName.js';
39
+ import { createCorsOrigin, listCorsOrigins } from '../services/cors.js';
40
+ import { createDataset as createDatasetService, listDatasets } from '../services/datasets.js';
41
+ import { getProjectFeatures } from '../services/getProjectFeatures.js';
42
+ import { createOrganization, listOrganizations } from '../services/organizations.js';
43
+ import { getPlanId, getPlanIdFromCoupon } from '../services/plans.js';
44
+ import { createProject, listProjects, updateProjectInitializedAt } from '../services/projects.js';
45
+ import { getCliUser } from '../services/user.js';
46
+ import { CLIInitStepCompleted } from '../telemetry/init.telemetry.js';
47
+ import { absolutify, validateEmptyPath } from '../util/fsUtils.js';
48
+ import { getProjectDefaults } from '../util/getProjectDefaults.js';
49
+ import { installDeclaredPackages, installNewPackages } from '../util/packageManager/installPackages.js';
50
+ import { getPartialEnvWithNpmPath } from '../util/packageManager/packageManagerChoice.js';
51
+ const debug = subdebug('init');
52
+ export class InitCommand extends SanityCommand {
53
+ static args = {
54
+ type: Args.string({
55
+ hidden: true
56
+ })
57
+ };
58
+ static description = 'Initialize a new Sanity Studio, project and/or app';
59
+ static enableJsonFlag = true;
60
+ static examples = [
61
+ '<%= config.bin %> <%= command.id %>',
62
+ {
63
+ command: '<%= config.bin %> <%= command.id %> --dataset-default',
64
+ description: 'Initialize a new project with a public dataset named "production"'
65
+ },
66
+ {
67
+ command: '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset production --output-path ~/myproj',
68
+ description: 'Initialize a project with the given project ID and dataset to the given path'
69
+ },
70
+ {
71
+ command: '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset staging --template moviedb --output-path .',
72
+ description: 'Initialize a project with the given project ID and dataset using the moviedb template to the given path'
73
+ },
74
+ {
75
+ command: '<%= config.bin %> <%= command.id %> -y --create-project "Movies Unlimited" --dataset moviedb --visibility private --template moviedb --output-path /Users/espenh/movies-unlimited',
76
+ description: 'Create a brand new project with name "Movies Unlimited"'
77
+ }
78
+ ];
79
+ static flags = {
80
+ 'auto-updates': Flags.boolean({
81
+ allowNo: true,
82
+ default: true,
83
+ description: 'Enable auto updates of studio versions',
84
+ exclusive: [
85
+ 'bare'
86
+ ]
87
+ }),
88
+ bare: Flags.boolean({
89
+ description: 'Skip the Studio initialization and only print the selected project ID and dataset name to stdout'
90
+ }),
91
+ coupon: Flags.string({
92
+ description: 'Optionally select a coupon for a new project (cannot be used with --project-plan)',
93
+ exclusive: [
94
+ 'project-plan'
95
+ ],
96
+ helpValue: '<code>'
97
+ }),
98
+ 'create-project': Flags.string({
99
+ description: 'Create a new project with the given name',
100
+ helpValue: '<name>'
101
+ }),
102
+ dataset: Flags.string({
103
+ description: 'Dataset name for the studio',
104
+ exclusive: [
105
+ 'dataset-default'
106
+ ],
107
+ helpValue: '<name>'
108
+ }),
109
+ 'dataset-default': Flags.boolean({
110
+ description: 'Set up a project with a public dataset named "production"'
111
+ }),
112
+ env: Flags.string({
113
+ description: 'Write environment variables to file',
114
+ exclusive: [
115
+ 'bare'
116
+ ],
117
+ helpValue: '<filename>',
118
+ parse: async (input)=>{
119
+ if (!input.startsWith('.env')) {
120
+ throw new CLIError('Env filename (`--env`) must start with `.env`');
121
+ }
122
+ return input;
123
+ }
124
+ }),
125
+ 'from-create': Flags.boolean({
126
+ description: 'Internal flag to indicate that the command is run from create-sanity',
127
+ hidden: true
128
+ }),
129
+ git: Flags.string({
130
+ default: undefined,
131
+ description: 'Specify a commit message for initial commit, or disable git init',
132
+ exclusive: [
133
+ 'bare'
134
+ ],
135
+ // oclif doesn't indent correctly with custom help labels, thus leading space :/
136
+ helpLabel: ' --[no-]git',
137
+ helpValue: '<message>'
138
+ }),
139
+ mcp: Flags.boolean({
140
+ allowNo: true,
141
+ default: true,
142
+ description: 'Enable AI editor integration (MCP) setup'
143
+ }),
144
+ 'nextjs-add-config-files': Flags.boolean({
145
+ allowNo: true,
146
+ default: undefined,
147
+ description: 'Add config files to Next.js project',
148
+ helpGroup: 'Next.js'
149
+ }),
150
+ 'nextjs-append-env': Flags.boolean({
151
+ allowNo: true,
152
+ default: undefined,
153
+ description: 'Append project ID and dataset to .env file',
154
+ helpGroup: 'Next.js'
155
+ }),
156
+ 'nextjs-embed-studio': Flags.boolean({
157
+ allowNo: true,
158
+ default: undefined,
159
+ description: 'Embed the Studio in Next.js application',
160
+ helpGroup: 'Next.js'
161
+ }),
162
+ // oclif doesn't support a boolean/string flag combination, but listing both a
163
+ // `--git` and a `--no-git` flag in help breaks conventions, so we hide this one,
164
+ // but use it to "combine" the two in the actual logic.
165
+ 'no-git': Flags.boolean({
166
+ description: 'Disable git initialization',
167
+ exclusive: [
168
+ 'git'
169
+ ],
170
+ hidden: true
171
+ }),
172
+ organization: Flags.string({
173
+ description: 'Organization ID to use for the project',
174
+ helpValue: '<id>'
175
+ }),
176
+ 'output-path': Flags.string({
177
+ description: 'Path to write studio project to',
178
+ exclusive: [
179
+ 'bare'
180
+ ],
181
+ helpValue: '<path>'
182
+ }),
183
+ 'overwrite-files': Flags.boolean({
184
+ allowNo: true,
185
+ default: undefined,
186
+ description: 'Overwrite existing files'
187
+ }),
188
+ 'package-manager': Flags.string({
189
+ description: 'Specify which package manager to use [allowed: npm, yarn, pnpm]',
190
+ exclusive: [
191
+ 'bare'
192
+ ],
193
+ helpValue: '<manager>',
194
+ options: [
195
+ 'npm',
196
+ 'yarn',
197
+ 'pnpm'
198
+ ]
199
+ }),
200
+ project: Flags.string({
201
+ aliases: [
202
+ 'project-id'
203
+ ],
204
+ description: 'Project ID to use for the studio',
205
+ exclusive: [
206
+ 'create-project'
207
+ ],
208
+ helpValue: '<id>'
209
+ }),
210
+ 'project-plan': Flags.string({
211
+ description: 'Optionally select a plan for a new project',
212
+ helpValue: '<name>'
213
+ }),
214
+ provider: Flags.string({
215
+ description: 'Login provider to use',
216
+ helpValue: '<provider>'
217
+ }),
218
+ quickstart: Flags.boolean({
219
+ deprecated: true,
220
+ description: 'Used for initializing a project from a server schema that is saved in the Journey API',
221
+ hidden: true
222
+ }),
223
+ reconfigure: Flags.boolean({
224
+ deprecated: {
225
+ message: 'This flag is no longer supported',
226
+ version: '3.0.0'
227
+ },
228
+ description: 'Reconfigure an existing project',
229
+ hidden: true
230
+ }),
231
+ template: Flags.string({
232
+ description: 'Project template to use [default: "clean"]',
233
+ exclusive: [
234
+ 'bare'
235
+ ],
236
+ helpValue: '<template>'
237
+ }),
238
+ // Porting over a beta flag
239
+ // Oclif doesn't seem to support something in beta so hiding for now
240
+ 'template-token': Flags.string({
241
+ description: 'Used for accessing private GitHub repo templates',
242
+ hidden: true
243
+ }),
244
+ typescript: Flags.boolean({
245
+ allowNo: true,
246
+ default: undefined,
247
+ description: 'Enable TypeScript support',
248
+ exclusive: [
249
+ 'bare'
250
+ ]
251
+ }),
252
+ visibility: Flags.string({
253
+ description: 'Visibility mode for dataset',
254
+ helpValue: '<mode>',
255
+ options: [
256
+ 'public',
257
+ 'private'
258
+ ]
259
+ }),
260
+ yes: Flags.boolean({
261
+ char: 'y',
262
+ default: false,
263
+ description: 'Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults'
264
+ })
265
+ };
266
+ _trace;
267
+ async run() {
268
+ const workDir = process.cwd();
269
+ const createProjectName = this.flags['create-project'];
270
+ // For backwards "compatibility" - we used to allow `sanity init plugin`,
271
+ // and no longer do - but instead of printing an error about an unknown
272
+ // _command_, we want to acknowledge that the user is trying to do something
273
+ // that no longer exists but might have at some point in the past.
274
+ if (this.args.type) {
275
+ this.error(this.args.type === 'plugin' ? 'Initializing plugins through the CLI is no longer supported' : `Unknown init type "${this.args.type}"`, {
276
+ exit: 1
277
+ });
278
+ }
279
+ this._trace = this.telemetry.trace(CLIInitStepCompleted);
280
+ // Slightly more helpful message for removed flags rather than just saying the flag
281
+ // does not exist.
282
+ if (this.flags.reconfigure) {
283
+ this.error('--reconfigure is deprecated - manual configuration is now required', {
284
+ exit: 1
285
+ });
286
+ }
287
+ // Oclif doesn't support custom exclusive error messaging
288
+ if (this.flags.project && this.flags.organization) {
289
+ this.error('You have specified both a project and an organization. To move a project to an organization please visit https://www.sanity.io/manage', {
290
+ exit: 1
291
+ });
292
+ }
293
+ const defaultConfig = this.flags['dataset-default'];
294
+ let showDefaultConfigPrompt = !defaultConfig;
295
+ if (this.flags.dataset || this.flags.visibility || this.flags['dataset-default'] || this.isUnattended()) {
296
+ showDefaultConfigPrompt = false;
297
+ }
298
+ const detectedFramework = await detectFrameworkRecord({
299
+ frameworkList: frameworks,
300
+ fs: new LocalFileSystemDetector(process.cwd())
301
+ });
302
+ const isNextJs = detectedFramework?.slug === 'nextjs';
303
+ let remoteTemplateInfo;
304
+ if (this.flags.template && checkIsRemoteTemplate(this.flags.template)) {
305
+ remoteTemplateInfo = await getGitHubRepoInfo(this.flags.template, this.flags['template-token']);
306
+ }
307
+ if (detectedFramework && detectedFramework.slug !== 'sanity' && remoteTemplateInfo) {
308
+ this.error(`A remote template cannot be used with a detected framework. Detected: ${detectedFramework.name}`, {
309
+ exit: 1
310
+ });
311
+ }
312
+ // Checks flags are present when in unattended mode
313
+ if (this.isUnattended()) {
314
+ this.checkFlagsInUnattendedMode({
315
+ createProjectName,
316
+ isNextJs
317
+ });
318
+ }
319
+ this._trace.start();
320
+ this._trace.log({
321
+ flags: {
322
+ bare: this.flags.bare,
323
+ coupon: this.flags.coupon,
324
+ defaultConfig,
325
+ env: this.flags.env,
326
+ git: this.flags.git,
327
+ plan: this.flags['project-plan'],
328
+ reconfigure: this.flags.reconfigure,
329
+ unattended: this.isUnattended()
330
+ },
331
+ step: 'start'
332
+ });
333
+ // Plan can be set through `--project-plan`, or implied through `--coupon`.
334
+ // As coupons can expire and project plans might change/be removed, we need to
335
+ // verify that the passed flags are valid. The complexity of this is hidden in the
336
+ // below plan methods, eventually returning a plan ID or undefined if we are told to
337
+ // use the default plan.
338
+ const planId = await this.getPlan();
339
+ let envFilenameDefault = '.env';
340
+ if (detectedFramework && detectedFramework.slug === 'nextjs') {
341
+ envFilenameDefault = '.env.local';
342
+ }
343
+ const envFilename = typeof this.flags.env === 'string' ? this.flags.env : envFilenameDefault;
344
+ // If the user isn't already autenticated, make it so
345
+ const { user } = await this.ensureAuthenticated();
346
+ const isAppTemplate = this.flags.template ? determineAppTemplate(this.flags.template) : false // Default to false
347
+ ;
348
+ if (!isAppTemplate) {
349
+ this.log(`${logSymbols.success} Fetching existing projects`);
350
+ this.log('');
351
+ }
352
+ let newProject;
353
+ if (createProjectName) {
354
+ newProject = await this.createProjectFromName({
355
+ createProjectName,
356
+ planId,
357
+ user
358
+ });
359
+ }
360
+ const { datasetName, displayName, isFirstProject, organizationId, projectId } = await this.getProjectDetails({
361
+ isAppTemplate,
362
+ newProject,
363
+ planId,
364
+ showDefaultConfigPrompt,
365
+ user
366
+ });
367
+ // If user doesn't want to output any template code
368
+ if (this.flags.bare) {
369
+ this.log(`${logSymbols.success} Below are your project details`);
370
+ this.log('');
371
+ this.log(`Project ID: ${styleText('cyan', projectId)}`);
372
+ this.log(`Dataset: ${styleText('cyan', datasetName)}`);
373
+ this.log(`\nYou can find your project on Sanity Manage — https://www.sanity.io/manage/project/${projectId}\n`);
374
+ return;
375
+ }
376
+ let initNext = this.flagOrDefault('nextjs-add-config-files', false);
377
+ if (isNextJs && this.promptForUndefinedFlag(this.flags['nextjs-add-config-files'])) {
378
+ initNext = await promptForConfigFiles();
379
+ }
380
+ this._trace.log({
381
+ detectedFramework: detectedFramework?.name,
382
+ selectedOption: initNext ? 'yes' : 'no',
383
+ step: 'useDetectedFramework'
384
+ });
385
+ const sluggedName = deburr(displayName.toLowerCase()).replaceAll(/\s+/g, '-').replaceAll(/[^a-z0-9-]/g, '');
386
+ // add more frameworks to this as we add support for them
387
+ // this is used to skip the getProjectInfo prompt
388
+ const initFramework = initNext;
389
+ // Gather project defaults based on environment
390
+ const defaults = await getProjectDefaults({
391
+ isPlugin: false,
392
+ workDir
393
+ });
394
+ // Prompt the user for required information
395
+ const outputPath = await this.getProjectOutputPath({
396
+ initFramework,
397
+ sluggedName,
398
+ workDir
399
+ });
400
+ // Set up MCP integration
401
+ const mcpResult = await setupMCP(this.flags.mcp);
402
+ this._trace.log({
403
+ configuredEditors: mcpResult.configuredEditors,
404
+ detectedEditors: mcpResult.detectedEditors,
405
+ skipped: mcpResult.skipped,
406
+ step: 'mcpSetup'
407
+ });
408
+ if (mcpResult.error) {
409
+ this._trace.error(mcpResult.error);
410
+ }
411
+ const mcpConfigured = mcpResult.configuredEditors;
412
+ if (isNextJs) {
413
+ await checkNextJsReactCompatibility({
414
+ detectedFramework,
415
+ output: this.output,
416
+ outputPath
417
+ });
418
+ }
419
+ if (initNext) {
420
+ await this.initNextJs({
421
+ datasetName,
422
+ detectedFramework,
423
+ envFilename,
424
+ mcpConfigured,
425
+ projectId,
426
+ workDir
427
+ });
428
+ }
429
+ // user wants to write environment variables to file
430
+ if (this.flags.env) {
431
+ await createOrAppendEnvVars({
432
+ envVars: {
433
+ DATASET: datasetName,
434
+ PROJECT_ID: projectId
435
+ },
436
+ filename: envFilename,
437
+ framework: detectedFramework,
438
+ log: false,
439
+ output: this.output,
440
+ outputPath
441
+ });
442
+ this.exit(0);
443
+ }
444
+ // Prompt for template to use
445
+ const templateName = await this.promptForTemplate();
446
+ this._trace.log({
447
+ selectedOption: templateName,
448
+ step: 'selectProjectTemplate'
449
+ });
450
+ const template = templates[templateName];
451
+ if (!remoteTemplateInfo && !template) {
452
+ this.error(`Template "${templateName}" not found`, {
453
+ exit: 1
454
+ });
455
+ }
456
+ let useTypeScript = this.flags.typescript;
457
+ if (!remoteTemplateInfo && template && template.typescriptOnly === true) {
458
+ useTypeScript = true;
459
+ } else if (this.promptForUndefinedFlag(this.flags.typescript)) {
460
+ useTypeScript = await promptForTypeScript();
461
+ this._trace.log({
462
+ selectedOption: useTypeScript ? 'yes' : 'no',
463
+ step: 'useTypeScript'
464
+ });
465
+ }
466
+ // If the template has a sample dataset, prompt the user whether or not we should import it
467
+ const shouldImport = !this.isUnattended() && template?.datasetUrl && await this.promptForDatasetImport(template.importPrompt);
468
+ this._trace.log({
469
+ selectedOption: shouldImport ? 'yes' : 'no',
470
+ step: 'importTemplateDataset'
471
+ });
472
+ try {
473
+ await updateProjectInitializedAt(projectId);
474
+ } catch (err) {
475
+ // Non-critical update
476
+ debug('Failed to update cliInitializedAt metadata', err);
477
+ }
478
+ try {
479
+ await bootstrapTemplate({
480
+ autoUpdates: this.flags['auto-updates'],
481
+ bearerToken: this.flags['template-token'],
482
+ dataset: datasetName,
483
+ organizationId,
484
+ output: this.output,
485
+ outputPath,
486
+ overwriteFiles: this.flags['overwrite-files'],
487
+ packageName: sluggedName,
488
+ projectId,
489
+ projectName: displayName || defaults.projectName,
490
+ remoteTemplateInfo,
491
+ templateName,
492
+ useTypeScript
493
+ });
494
+ } catch (error) {
495
+ if (error instanceof Error) {
496
+ throw error;
497
+ }
498
+ throw new Error(String(error));
499
+ }
500
+ const pkgManager = await resolvePackageManager({
501
+ interactive: !this.isUnattended(),
502
+ output: this.output,
503
+ packageManager: this.flags['package-manager'],
504
+ targetDir: outputPath
505
+ });
506
+ this._trace.log({
507
+ selectedOption: pkgManager,
508
+ step: 'selectPackageManager'
509
+ });
510
+ // Now for the slow part... installing dependencies
511
+ await installDeclaredPackages(outputPath, pkgManager, {
512
+ output: this.output,
513
+ workDir
514
+ });
515
+ const useGit = this.flags.git === undefined || Boolean(this.flags.git);
516
+ const commitMessage = this.flags.git;
517
+ // Try initializing a git repository
518
+ if (useGit) {
519
+ tryGitInit(outputPath, typeof commitMessage === 'string' ? commitMessage : undefined);
520
+ }
521
+ // Prompt for dataset import (if a dataset is defined)
522
+ if (shouldImport && template?.datasetUrl) {
523
+ const token = await getCliToken();
524
+ if (!token) {
525
+ this.error('Authentication required to import dataset', {
526
+ exit: 1
527
+ });
528
+ }
529
+ await DatasetImportCommand.run([
530
+ template.datasetUrl,
531
+ '--project',
532
+ projectId,
533
+ '--dataset',
534
+ datasetName,
535
+ '--token',
536
+ token
537
+ ], {
538
+ root: outputPath
539
+ });
540
+ this.log('');
541
+ this.log('If you want to delete the imported data, use');
542
+ this.log(` ${styleText('cyan', `npx sanity dataset delete ${datasetName}`)}`);
543
+ this.log('and create a new clean dataset with');
544
+ this.log(` ${styleText('cyan', `npx sanity dataset create <name>`)}\n`);
545
+ }
546
+ const devCommandMap = {
547
+ bun: 'bun dev',
548
+ manual: 'npm run dev',
549
+ npm: 'npm run dev',
550
+ pnpm: 'pnpm dev',
551
+ yarn: 'yarn dev'
552
+ };
553
+ const devCommand = devCommandMap[pkgManager];
554
+ const isCurrentDir = outputPath === process.cwd();
555
+ const goToProjectDir = `\n(${styleText('cyan', `cd ${outputPath}`)} to navigate to your new project directory)`;
556
+ if (isAppTemplate) {
557
+ //output for custom apps here
558
+ this.log(`${logSymbols.success} ${styleText([
559
+ 'green',
560
+ 'bold'
561
+ ], 'Success!')} Your custom app has been scaffolded.`);
562
+ if (!isCurrentDir) this.log(goToProjectDir);
563
+ this.log(`\n${styleText('bold', 'Next')}, configure the project(s) and dataset(s) your app should work with.`);
564
+ this.log('\nGet started in `src/App.tsx`, or refer to our documentation for a walkthrough:');
565
+ this.log(styleText([
566
+ 'blue',
567
+ 'underline'
568
+ ], 'https://www.sanity.io/docs/app-sdk/sdk-configuration'));
569
+ if (mcpConfigured && mcpConfigured.length > 0) {
570
+ const message = await this.getPostInitMCPPrompt(mcpConfigured);
571
+ this.log(`\n${message}`);
572
+ this.log(`\nLearn more: ${styleText('cyan', 'https://mcp.sanity.io')}`);
573
+ this.log(`\nHave feedback? Tell us in the community: ${styleText('cyan', 'https://www.sanity.io/community/join')}`);
574
+ }
575
+ this.log('\n');
576
+ this.log(`Other helpful commands:`);
577
+ this.log(`npx sanity docs browse to open the documentation in a browser`);
578
+ this.log(`npx sanity dev to start the development server for your app`);
579
+ this.log(`npx sanity deploy to deploy your app`);
580
+ } else {
581
+ //output for Studios here
582
+ this.log(`✅ ${styleText([
583
+ 'green',
584
+ 'bold'
585
+ ], 'Success!')} Your Studio has been created.`);
586
+ if (!isCurrentDir) this.log(goToProjectDir);
587
+ this.log(`\nGet started by running ${styleText('cyan', devCommand)} to launch your Studio's development server`);
588
+ if (mcpConfigured && mcpConfigured.length > 0) {
589
+ const message = await this.getPostInitMCPPrompt(mcpConfigured);
590
+ this.log(`\n${message}`);
591
+ this.log(`\nLearn more: ${styleText('cyan', 'https://mcp.sanity.io')}`);
592
+ this.log(`\nHave feedback? Tell us in the community: ${styleText('cyan', 'https://www.sanity.io/community/join')}`);
593
+ }
594
+ this.log('\n');
595
+ this.log(`Other helpful commands:`);
596
+ this.log(`npx sanity docs browse to open the documentation in a browser`);
597
+ this.log(`npx sanity manage to open the project settings in a browser`);
598
+ this.log(`npx sanity help to explore the CLI manual`);
599
+ }
600
+ if (isFirstProject) {
601
+ this._trace.log({
602
+ selectedOption: 'yes',
603
+ step: 'sendCommunityInvite'
604
+ });
605
+ const DISCORD_INVITE_LINK = 'https://www.sanity.io/community/join';
606
+ this.log(`\nJoin the Sanity community: ${styleText('cyan', DISCORD_INVITE_LINK)}`);
607
+ this.log('We look forward to seeing you there!\n');
608
+ }
609
+ this._trace.complete();
610
+ }
611
+ checkFlagsInUnattendedMode({ createProjectName, isNextJs }) {
612
+ debug('Unattended mode, validating required options');
613
+ if (!this.flags['dataset']) {
614
+ this.error(`\`--dataset\` must be specified in unattended mode`, {
615
+ exit: 1
616
+ });
617
+ }
618
+ // output-path is required in unattended mode when not using nextjs
619
+ if (!isNextJs && !this.flags['output-path']) {
620
+ this.error(`\`--output-path\` must be specified in unattended mode`, {
621
+ exit: 1
622
+ });
623
+ }
624
+ if (!this.flags.project && !createProjectName) {
625
+ this.error('`--project <id>` or `--create-project <name>` must be specified in unattended mode', {
626
+ exit: 1
627
+ });
628
+ }
629
+ if (createProjectName && !this.flags.organization) {
630
+ this.error('--create-project is not supported in unattended mode without an organization, please specify an organization with `--organization <id>`', {
631
+ exit: 1
632
+ });
633
+ }
634
+ }
635
+ async createProjectFromName({ createProjectName, planId, user }) {
636
+ debug('--create-project specified, creating a new project');
637
+ let orgForCreateProjectFlag = this.flags.organization;
638
+ if (!orgForCreateProjectFlag) {
639
+ debug('no organization specified, selecting one');
640
+ const organizations = await listOrganizations();
641
+ orgForCreateProjectFlag = await this.promptUserForOrganization({
642
+ organizations,
643
+ user
644
+ });
645
+ }
646
+ debug('creating a new project');
647
+ const createdProject = await createProject({
648
+ displayName: createProjectName.trim(),
649
+ metadata: {
650
+ coupon: this.flags.coupon
651
+ },
652
+ organizationId: orgForCreateProjectFlag,
653
+ subscription: planId ? {
654
+ planId
655
+ } : undefined
656
+ });
657
+ debug('Project with ID %s created', createdProject.projectId);
658
+ if (this.flags.dataset) {
659
+ debug('--dataset specified, creating dataset (%s)', this.flags.dataset);
660
+ const spin = spinner('Creating dataset').start();
661
+ await createDatasetService({
662
+ aclMode: this.flags.visibility,
663
+ datasetName: this.flags.dataset,
664
+ projectId: createdProject.projectId
665
+ });
666
+ spin.succeed();
667
+ }
668
+ return createdProject.projectId;
669
+ }
670
+ // @todo do we actually need to be authenticated for init? check flags and determine.
671
+ async ensureAuthenticated() {
672
+ let isAuthenticated = await getCliToken() !== undefined;
673
+ debug(isAuthenticated ? 'User already has a token' : 'User has no token');
674
+ let user;
675
+ if (isAuthenticated) {
676
+ // It _appears_ we are authenticated, but the token might be invalid/expired,
677
+ // so we need to verify that we can actually make an authenticated request.
678
+ try {
679
+ user = await getCliUser();
680
+ } catch {
681
+ // assume that any error means that the token is invalid
682
+ isAuthenticated = false;
683
+ }
684
+ }
685
+ if (isAuthenticated) {
686
+ this._trace.log({
687
+ alreadyLoggedIn: true,
688
+ step: 'login'
689
+ });
690
+ } else {
691
+ if (this.isUnattended()) {
692
+ this.error('Must be logged in to run this command in unattended mode, run `sanity login`', {
693
+ exit: 1
694
+ });
695
+ }
696
+ this._trace.log({
697
+ step: 'login'
698
+ });
699
+ await login({
700
+ output: this.output,
701
+ telemetry: this._trace.newContext('login')
702
+ });
703
+ }
704
+ user = await getCliUser();
705
+ this.log(`${logSymbols.success} You are logged in as ${user.email} using ${getProviderName(user.provider)}`);
706
+ return {
707
+ user
708
+ };
709
+ }
710
+ flagOrDefault(flag, defaultValue) {
711
+ return typeof this.flags[flag] === 'boolean' ? this.flags[flag] : defaultValue;
712
+ }
713
+ async getOrCreateDataset(opts) {
714
+ const visibility = this.flags.visibility;
715
+ const dataset = this.flags.dataset;
716
+ let defaultConfig = this.flags['dataset-default'];
717
+ if (dataset && this.isUnattended()) {
718
+ return {
719
+ datasetName: dataset,
720
+ userAction: 'none'
721
+ };
722
+ }
723
+ const [datasets, projectFeatures] = await Promise.all([
724
+ listDatasets(opts.projectId),
725
+ getProjectFeatures(opts.projectId)
726
+ ]);
727
+ if (dataset) {
728
+ debug('User has specified dataset through a flag (%s)', dataset);
729
+ const existing = datasets.find((ds)=>ds.name === dataset);
730
+ if (!existing) {
731
+ debug('Specified dataset not found, creating it');
732
+ await createDataset({
733
+ datasetName: dataset,
734
+ forcePublic: defaultConfig,
735
+ output: this.output,
736
+ projectFeatures,
737
+ projectId: opts.projectId,
738
+ visibility
739
+ });
740
+ }
741
+ return {
742
+ datasetName: dataset,
743
+ userAction: 'none'
744
+ };
745
+ }
746
+ const datasetInfo = 'Your content will be stored in a dataset that can be public or private, depending on\nwhether you want to query your content with or without authentication.\nThe default dataset configuration has a public dataset named "production".';
747
+ if (datasets.length === 0) {
748
+ debug('No datasets found for project, prompting for name');
749
+ if (opts.showDefaultConfigPrompt) {
750
+ this.log(datasetInfo);
751
+ defaultConfig = await promptForDefaultConfig();
752
+ }
753
+ const name = defaultConfig ? 'production' : await promptForDatasetName({
754
+ message: 'Name of your first dataset:'
755
+ });
756
+ await createDataset({
757
+ datasetName: name,
758
+ forcePublic: defaultConfig,
759
+ output: this.output,
760
+ projectFeatures,
761
+ projectId: opts.projectId,
762
+ visibility
763
+ });
764
+ return {
765
+ datasetName: name,
766
+ userAction: 'create'
767
+ };
768
+ }
769
+ debug(`User has ${datasets.length} dataset(s) already, showing list of choices`);
770
+ const datasetChoices = datasets.map((dataset)=>({
771
+ value: dataset.name
772
+ }));
773
+ const selected = await select({
774
+ choices: [
775
+ {
776
+ name: 'Create new dataset',
777
+ value: 'new'
778
+ },
779
+ new Separator(),
780
+ ...datasetChoices
781
+ ],
782
+ message: 'Select dataset to use'
783
+ });
784
+ if (selected === 'new') {
785
+ const existingDatasetNames = datasets.map((ds)=>ds.name);
786
+ debug('User wants to create a new dataset, prompting for name');
787
+ if (opts.showDefaultConfigPrompt && !existingDatasetNames.includes('production')) {
788
+ this.log(datasetInfo);
789
+ defaultConfig = await promptForDefaultConfig();
790
+ }
791
+ const newDatasetName = defaultConfig ? 'production' : await promptForDatasetName({
792
+ message: 'Dataset name:'
793
+ }, existingDatasetNames);
794
+ await createDataset({
795
+ datasetName: newDatasetName,
796
+ forcePublic: defaultConfig,
797
+ output: this.output,
798
+ projectFeatures,
799
+ projectId: opts.projectId,
800
+ visibility
801
+ });
802
+ return {
803
+ datasetName: newDatasetName,
804
+ userAction: 'create'
805
+ };
806
+ }
807
+ debug(`Returning selected dataset (${selected})`);
808
+ return {
809
+ datasetName: selected,
810
+ userAction: 'select'
811
+ };
812
+ }
813
+ async getOrCreateProject({ newProject, planId, user }) {
814
+ const projectId = this.flags.project || newProject;
815
+ const organizationId = this.flags.organization;
816
+ let projects;
817
+ let organizations;
818
+ try {
819
+ const [allProjects, allOrgs] = await Promise.all([
820
+ listProjects(),
821
+ listOrganizations()
822
+ ]);
823
+ projects = allProjects.toSorted((a, b)=>b.createdAt.localeCompare(a.createdAt));
824
+ organizations = allOrgs;
825
+ } catch (err) {
826
+ if (this.isUnattended() && projectId) {
827
+ return {
828
+ displayName: 'Unknown project',
829
+ isFirstProject: false,
830
+ projectId,
831
+ userAction: 'select'
832
+ };
833
+ }
834
+ this.error(`Failed to communicate with the Sanity API:\n${err.message}`, {
835
+ exit: 1
836
+ });
837
+ }
838
+ if (projects.length === 0 && this.isUnattended()) {
839
+ this.error('No projects found for current user', {
840
+ exit: 1
841
+ });
842
+ }
843
+ if (projectId) {
844
+ const project = projects.find((proj)=>proj.id === projectId);
845
+ if (!project && !this.isUnattended()) {
846
+ this.error(`Given project ID (${projectId}) not found, or you do not have access to it`, {
847
+ exit: 1
848
+ });
849
+ }
850
+ return {
851
+ displayName: project ? project.displayName : 'Unknown project',
852
+ isFirstProject: false,
853
+ projectId,
854
+ userAction: 'select'
855
+ };
856
+ }
857
+ if (organizationId) {
858
+ const organization = organizations.find((org)=>org.id === organizationId) || organizations.find((org)=>org.slug === organizationId);
859
+ if (!organization) {
860
+ this.error(`Given organization ID (${organizationId}) not found, or you do not have access to it`, {
861
+ exit: 1
862
+ });
863
+ }
864
+ if (!await hasProjectAttachGrant(organizationId)) {
865
+ this.error('You lack the necessary permissions to attach a project to this organization', {
866
+ exit: 1
867
+ });
868
+ }
869
+ }
870
+ // If the user has no projects or is using a coupon (which can only be applied to new projects)
871
+ // just ask for project details instead of showing a list of projects
872
+ const isUsersFirstProject = projects.length === 0;
873
+ if (isUsersFirstProject || this.flags.coupon) {
874
+ debug(isUsersFirstProject ? 'No projects found for user, prompting for name' : 'Using a coupon - skipping project selection');
875
+ const newProject = await this.promptForProjectCreation({
876
+ isUsersFirstProject,
877
+ organizationId,
878
+ organizations,
879
+ planId,
880
+ user
881
+ });
882
+ return {
883
+ ...newProject,
884
+ isFirstProject: isUsersFirstProject,
885
+ userAction: 'create'
886
+ };
887
+ }
888
+ debug(`User has ${projects.length} project(s) already, showing list of choices`);
889
+ const projectChoices = projects.map((project)=>({
890
+ name: `${project.displayName} (${project.id})`,
891
+ value: project.id
892
+ }));
893
+ const selected = await select({
894
+ choices: [
895
+ {
896
+ name: 'Create new project',
897
+ value: 'new'
898
+ },
899
+ new Separator(),
900
+ ...projectChoices
901
+ ],
902
+ message: 'Create a new project or select an existing one'
903
+ });
904
+ if (selected === 'new') {
905
+ debug('User wants to create a new project, prompting for name');
906
+ const newProject = await this.promptForProjectCreation({
907
+ isUsersFirstProject,
908
+ organizationId,
909
+ organizations,
910
+ planId,
911
+ user
912
+ });
913
+ return {
914
+ ...newProject,
915
+ isFirstProject: isUsersFirstProject,
916
+ userAction: 'create'
917
+ };
918
+ }
919
+ debug(`Returning selected project (${selected})`);
920
+ return {
921
+ displayName: projects.find((proj)=>proj.id === selected)?.displayName || '',
922
+ isFirstProject: isUsersFirstProject,
923
+ projectId: selected,
924
+ userAction: 'select'
925
+ };
926
+ }
927
+ async getPlan() {
928
+ const intendedPlan = this.flags['project-plan'];
929
+ const intendedCoupon = this.flags.coupon;
930
+ if (intendedCoupon) {
931
+ return this.verifyCoupon(intendedCoupon);
932
+ } else if (intendedPlan) {
933
+ return this.verifyPlan(intendedPlan);
934
+ } else {
935
+ return undefined;
936
+ }
937
+ }
938
+ async getPostInitMCPPrompt(editorsNames) {
939
+ return fetchPostInitPrompt(new Intl.ListFormat('en').format(editorsNames));
940
+ }
941
+ async getProjectDetails({ isAppTemplate, newProject, planId, showDefaultConfigPrompt, user }) {
942
+ if (isAppTemplate) {
943
+ const organizations = await listOrganizations({
944
+ includeImplicitMemberships: 'true',
945
+ includeMembers: 'true'
946
+ });
947
+ const appOrganizationId = await this.promptUserForOrganization({
948
+ organizations,
949
+ user
950
+ });
951
+ return {
952
+ datasetName: '',
953
+ displayName: '',
954
+ isFirstProject: false,
955
+ organizationId: appOrganizationId,
956
+ projectId: ''
957
+ };
958
+ }
959
+ debug('Prompting user to select or create a project');
960
+ const project = await this.getOrCreateProject({
961
+ newProject,
962
+ planId,
963
+ user
964
+ });
965
+ debug(`Project with name ${project.displayName} selected`);
966
+ // Now let's pick or create a dataset
967
+ debug('Prompting user to select or create a dataset');
968
+ const dataset = await this.getOrCreateDataset({
969
+ displayName: project.displayName,
970
+ projectId: project.projectId,
971
+ showDefaultConfigPrompt
972
+ });
973
+ debug(`Dataset with name ${dataset.datasetName} selected`);
974
+ this._trace.log({
975
+ datasetName: dataset.datasetName,
976
+ selectedOption: dataset.userAction,
977
+ step: 'createOrSelectDataset',
978
+ visibility: this.flags.visibility
979
+ });
980
+ return {
981
+ datasetName: dataset.datasetName,
982
+ displayName: project.displayName,
983
+ isFirstProject: project.isFirstProject,
984
+ projectId: project.projectId
985
+ };
986
+ }
987
+ async getProjectOutputPath({ initFramework, sluggedName, workDir }) {
988
+ const outputPath = this.flags['output-path'];
989
+ const specifiedPath = outputPath && path.resolve(outputPath);
990
+ if (this.isUnattended() || specifiedPath || this.flags.env || initFramework) {
991
+ return specifiedPath || workDir;
992
+ }
993
+ const inputPath = await input({
994
+ default: path.join(workDir, sluggedName),
995
+ message: 'Project output path:',
996
+ validate: validateEmptyPath
997
+ });
998
+ return absolutify(inputPath);
999
+ }
1000
+ async initNextJs({ datasetName, detectedFramework, envFilename, mcpConfigured, projectId, workDir }) {
1001
+ let useTypeScript = this.flagOrDefault('typescript', true);
1002
+ if (this.promptForUndefinedFlag(this.flags.typescript)) {
1003
+ useTypeScript = await promptForTypeScript();
1004
+ }
1005
+ this._trace.log({
1006
+ selectedOption: useTypeScript ? 'yes' : 'no',
1007
+ step: 'useTypeScript'
1008
+ });
1009
+ const fileExtension = useTypeScript ? 'ts' : 'js';
1010
+ let embeddedStudio = this.flagOrDefault('nextjs-embed-studio', true);
1011
+ if (this.promptForUndefinedFlag(this.flags['nextjs-embed-studio'])) {
1012
+ embeddedStudio = await promptForEmbeddedStudio();
1013
+ }
1014
+ let hasSrcFolder = false;
1015
+ if (embeddedStudio) {
1016
+ // find source path (app or src/app)
1017
+ const appDir = 'app';
1018
+ let srcPath = path.join(workDir, appDir);
1019
+ if (!existsSync(srcPath)) {
1020
+ srcPath = path.join(workDir, 'src', appDir);
1021
+ hasSrcFolder = true;
1022
+ if (!existsSync(srcPath)) {
1023
+ try {
1024
+ await mkdir(srcPath, {
1025
+ recursive: true
1026
+ });
1027
+ } catch {
1028
+ debug('Error creating folder %s', srcPath);
1029
+ }
1030
+ }
1031
+ }
1032
+ const studioPath = this.isUnattended() ? '/studio' : await promptForStudioPath();
1033
+ const embeddedStudioRouteFilePath = path.join(srcPath, `${studioPath}/`, `[[...tool]]/page.${fileExtension}x`);
1034
+ // this selects the correct template string based on whether the user is using the app or pages directory and
1035
+ // replaces the ":configPath:" placeholder in the template with the correct path to the sanity.config.ts file.
1036
+ // we account for the user-defined embeddedStudioPath (default /studio) is accounted for by creating enough "../"
1037
+ // relative paths to reach the root level of the project
1038
+ await this.writeOrOverwrite(embeddedStudioRouteFilePath, sanityStudioTemplate.replace(':configPath:', `${'../'.repeat(countNestedFolders(embeddedStudioRouteFilePath.slice(workDir.length)))}sanity.config`), workDir);
1039
+ const sanityConfigPath = path.join(workDir, `sanity.config.${fileExtension}`);
1040
+ await this.writeOrOverwrite(sanityConfigPath, sanityConfigTemplate(hasSrcFolder).replace(':route:', embeddedStudioRouteFilePath.slice(workDir.length).replace('src/', '')).replace(':basePath:', studioPath), workDir);
1041
+ }
1042
+ const sanityCliPath = path.join(workDir, `sanity.cli.${fileExtension}`);
1043
+ await this.writeOrOverwrite(sanityCliPath, sanityCliTemplate, workDir);
1044
+ let templateToUse = this.flags.template ?? 'clean';
1045
+ if (this.promptForUndefinedFlag(this.flags.template)) {
1046
+ templateToUse = await promptForNextTemplate();
1047
+ }
1048
+ await this.writeSourceFiles({
1049
+ fileExtension,
1050
+ files: sanityFolder(useTypeScript, templateToUse),
1051
+ folderPath: undefined,
1052
+ srcFolderPrefix: hasSrcFolder,
1053
+ workDir
1054
+ });
1055
+ let appendEnv = this.flagOrDefault('nextjs-append-env', true);
1056
+ if (this.promptForUndefinedFlag(this.flags['nextjs-append-env'])) {
1057
+ appendEnv = await promptForAppendEnv(envFilename);
1058
+ }
1059
+ if (appendEnv) {
1060
+ await createOrAppendEnvVars({
1061
+ envVars: {
1062
+ DATASET: datasetName,
1063
+ PROJECT_ID: projectId
1064
+ },
1065
+ filename: envFilename,
1066
+ framework: detectedFramework,
1067
+ log: true,
1068
+ output: this.output,
1069
+ outputPath: workDir
1070
+ });
1071
+ }
1072
+ if (embeddedStudio) {
1073
+ const nextjsLocalDevOrigin = 'http://localhost:3000';
1074
+ const existingCorsOrigins = await listCorsOrigins(projectId);
1075
+ const hasExistingCorsOrigin = existingCorsOrigins.some((item)=>item.origin === nextjsLocalDevOrigin);
1076
+ if (!hasExistingCorsOrigin) {
1077
+ try {
1078
+ const createCorsRes = await createCorsOrigin({
1079
+ allowCredentials: true,
1080
+ origin: nextjsLocalDevOrigin,
1081
+ projectId
1082
+ });
1083
+ this.log(createCorsRes.id ? `Added ${nextjsLocalDevOrigin} to CORS origins` : `Failed to add ${nextjsLocalDevOrigin} to CORS origins`);
1084
+ } catch (error) {
1085
+ debug(`Error creating new CORS Origin ${nextjsLocalDevOrigin}: ${error}`);
1086
+ this.error(`Failed to add ${nextjsLocalDevOrigin} to CORS origins: ${error}`, {
1087
+ exit: 1
1088
+ });
1089
+ }
1090
+ }
1091
+ }
1092
+ const chosen = await resolvePackageManager({
1093
+ interactive: !this.isUnattended(),
1094
+ output: this.output,
1095
+ packageManager: this.flags['package-manager'],
1096
+ targetDir: workDir
1097
+ });
1098
+ this._trace.log({
1099
+ selectedOption: chosen,
1100
+ step: 'selectPackageManager'
1101
+ });
1102
+ const packages = [
1103
+ '@sanity/vision@4',
1104
+ 'sanity@4',
1105
+ '@sanity/image-url@1',
1106
+ 'styled-components@6'
1107
+ ];
1108
+ if (templateToUse === 'blog') {
1109
+ packages.push('@sanity/icons');
1110
+ }
1111
+ await installNewPackages({
1112
+ packageManager: chosen,
1113
+ packages
1114
+ }, {
1115
+ output: this.output,
1116
+ workDir
1117
+ });
1118
+ // will refactor this later
1119
+ const execOptions = {
1120
+ cwd: workDir,
1121
+ encoding: 'utf8',
1122
+ env: getPartialEnvWithNpmPath(workDir),
1123
+ stdio: 'inherit'
1124
+ };
1125
+ switch(chosen){
1126
+ case 'npm':
1127
+ {
1128
+ await execa('npm', [
1129
+ 'install',
1130
+ '--legacy-peer-deps',
1131
+ 'next-sanity@11'
1132
+ ], execOptions);
1133
+ break;
1134
+ }
1135
+ case 'pnpm':
1136
+ {
1137
+ await execa('pnpm', [
1138
+ 'install',
1139
+ 'next-sanity@11'
1140
+ ], execOptions);
1141
+ break;
1142
+ }
1143
+ case 'yarn':
1144
+ {
1145
+ await execa('npx', [
1146
+ 'install-peerdeps',
1147
+ '--yarn',
1148
+ 'next-sanity@11'
1149
+ ], execOptions);
1150
+ break;
1151
+ }
1152
+ default:
1153
+ {
1154
+ break;
1155
+ }
1156
+ }
1157
+ this.log(`\n${styleText('green', 'Success!')} Your Sanity configuration files has been added to this project`);
1158
+ if (mcpConfigured && mcpConfigured.length > 0) {
1159
+ const message = await this.getPostInitMCPPrompt(mcpConfigured);
1160
+ this.log(`\n${message}`);
1161
+ this.log(`\nLearn more: ${styleText('cyan', 'https://mcp.sanity.io')}`);
1162
+ this.log(`\nHave feedback? Tell us in the community: ${styleText('cyan', 'https://www.sanity.io/community/join')}`);
1163
+ }
1164
+ this.exit(0);
1165
+ }
1166
+ async promptForDatasetImport(message) {
1167
+ return confirm({
1168
+ default: true,
1169
+ message: message || 'This template includes a sample dataset, would you like to use it?'
1170
+ });
1171
+ }
1172
+ async promptForProjectCreation({ isUsersFirstProject, organizationId, organizations, planId, user }) {
1173
+ const projectName = await input({
1174
+ default: 'My Sanity Project',
1175
+ message: 'Project name:',
1176
+ validate (input) {
1177
+ if (!input || input.trim() === '') {
1178
+ return 'Project name cannot be empty';
1179
+ }
1180
+ if (input.length > 80) {
1181
+ return 'Project name cannot be longer than 80 characters';
1182
+ }
1183
+ return true;
1184
+ }
1185
+ });
1186
+ const organization = organizationId || await this.promptUserForOrganization({
1187
+ organizations,
1188
+ user
1189
+ });
1190
+ const newProject = await createProject({
1191
+ displayName: projectName,
1192
+ metadata: {
1193
+ coupon: this.flags.coupon
1194
+ },
1195
+ organizationId: organization,
1196
+ subscription: planId ? {
1197
+ planId
1198
+ } : undefined
1199
+ });
1200
+ return {
1201
+ ...newProject,
1202
+ isFirstProject: isUsersFirstProject,
1203
+ userAction: 'create'
1204
+ };
1205
+ }
1206
+ async promptForTemplate() {
1207
+ const template = this.flags.template;
1208
+ const defaultTemplate = this.isUnattended() || template ? template || 'clean' : null;
1209
+ if (defaultTemplate) {
1210
+ return defaultTemplate;
1211
+ }
1212
+ return select({
1213
+ choices: [
1214
+ {
1215
+ name: 'Clean project with no predefined schema types',
1216
+ value: 'clean'
1217
+ },
1218
+ {
1219
+ name: 'Blog (schema)',
1220
+ value: 'blog'
1221
+ },
1222
+ {
1223
+ name: 'E-commerce (Shopify)',
1224
+ value: 'shopify'
1225
+ },
1226
+ {
1227
+ name: 'Movie project (schema + sample data)',
1228
+ value: 'moviedb'
1229
+ }
1230
+ ],
1231
+ message: 'Select project template'
1232
+ });
1233
+ }
1234
+ promptForUndefinedFlag(flag) {
1235
+ return !this.isUnattended() && flag === undefined;
1236
+ }
1237
+ async promptUserForNewOrganization(user) {
1238
+ const name = await promptForOrganizationName(user);
1239
+ const spin = spinner('Creating organization').start();
1240
+ const organization = await createOrganization(name);
1241
+ spin.succeed();
1242
+ return organization;
1243
+ }
1244
+ async promptUserForOrganization({ organizations, user }) {
1245
+ // If the user has no organizations, prompt them to create one with the same name as
1246
+ // their user, but allow them to customize it if they want
1247
+ if (organizations.length === 0) {
1248
+ const newOrganization = await this.promptUserForNewOrganization(user);
1249
+ return newOrganization.id;
1250
+ }
1251
+ // If the user has organizations, let them choose from them, but also allow them to
1252
+ // create a new one in case they do not have access to any of them, or they want to
1253
+ // create a personal/other organization.
1254
+ debug(`User has ${organizations.length} organization(s), checking attach access`);
1255
+ const withGrantInfo = await getOrganizationsWithAttachGrantInfo(organizations);
1256
+ const withAttach = withGrantInfo.filter(({ hasAttachGrant })=>hasAttachGrant);
1257
+ debug('User has attach access to %d organizations.', withAttach.length);
1258
+ const organizationChoices = getOrganizationChoices(withAttach);
1259
+ // If the user only has a single organization (and they have attach access to it),
1260
+ // we'll default to that one. Otherwise, we'll default to the organization with the
1261
+ // same name as the user if it exists.
1262
+ const defaultOrganizationId = withAttach.length === 1 ? withAttach[0].organization.id : organizations.find((org)=>org.name === user?.name)?.id;
1263
+ const chosenOrg = await select({
1264
+ choices: organizationChoices,
1265
+ default: defaultOrganizationId || undefined,
1266
+ message: 'Select organization:'
1267
+ });
1268
+ if (chosenOrg === '-new-') {
1269
+ const newOrganization = await this.promptUserForNewOrganization(user);
1270
+ return newOrganization.id;
1271
+ }
1272
+ return chosenOrg || undefined;
1273
+ }
1274
+ async verifyCoupon(intendedCoupon) {
1275
+ try {
1276
+ const planId = await getPlanIdFromCoupon(intendedCoupon);
1277
+ this.log(`Coupon "${intendedCoupon}" validated!\n`);
1278
+ return planId;
1279
+ } catch (err) {
1280
+ if (!isHttpError(err) || err.statusCode !== 404) {
1281
+ const message = err instanceof Error ? err.message : `${err}`;
1282
+ this.error(`Unable to validate coupon, please try again later:\n\n${message}`, {
1283
+ exit: 1
1284
+ });
1285
+ }
1286
+ const useDefaultPlan = this.isUnattended() || await confirm({
1287
+ default: true,
1288
+ message: `Coupon "${intendedCoupon}" is not available, use default plan instead?`
1289
+ });
1290
+ if (this.isUnattended()) {
1291
+ this.warn(`Coupon "${intendedCoupon}" is not available - using default plan`);
1292
+ }
1293
+ this._trace.log({
1294
+ coupon: intendedCoupon,
1295
+ selectedOption: useDefaultPlan ? 'yes' : 'no',
1296
+ step: 'useDefaultPlanCoupon'
1297
+ });
1298
+ if (useDefaultPlan) {
1299
+ this.log('Using default plan.');
1300
+ } else {
1301
+ this.error(`Coupon "${intendedCoupon}" does not exist`, {
1302
+ exit: 1
1303
+ });
1304
+ }
1305
+ }
1306
+ }
1307
+ async verifyPlan(intendedPlan) {
1308
+ try {
1309
+ const planId = await getPlanId(intendedPlan);
1310
+ return planId;
1311
+ } catch (err) {
1312
+ if (!isHttpError(err) || err.statusCode !== 404) {
1313
+ const message = err instanceof Error ? err.message : `${err}`;
1314
+ this.error(`Unable to validate plan, please try again later:\n\n${message}`, {
1315
+ exit: 1
1316
+ });
1317
+ }
1318
+ const useDefaultPlan = this.isUnattended() || await confirm({
1319
+ default: true,
1320
+ message: `Project plan "${intendedPlan}" does not exist, use default plan instead?`
1321
+ });
1322
+ if (this.isUnattended()) {
1323
+ this.warn(`Project plan "${intendedPlan}" does not exist - using default plan`);
1324
+ }
1325
+ this._trace.log({
1326
+ planId: intendedPlan,
1327
+ selectedOption: useDefaultPlan ? 'yes' : 'no',
1328
+ step: 'useDefaultPlanId'
1329
+ });
1330
+ if (useDefaultPlan) {
1331
+ this.log('Using default plan.');
1332
+ } else {
1333
+ this.error(`Plan id "${intendedPlan}" does not exist`, {
1334
+ exit: 1
1335
+ });
1336
+ }
1337
+ }
1338
+ }
1339
+ async writeOrOverwrite(filePath, content, workDir) {
1340
+ if (existsSync(filePath)) {
1341
+ let overwrite = this.flagOrDefault('overwrite-files', false);
1342
+ if (this.promptForUndefinedFlag(this.flags['overwrite-files'])) {
1343
+ overwrite = await confirm({
1344
+ default: false,
1345
+ message: `File ${styleText('yellow', filePath.replace(workDir, ''))} already exists. Do you want to overwrite it?`
1346
+ });
1347
+ }
1348
+ if (!overwrite) {
1349
+ return;
1350
+ }
1351
+ }
1352
+ // make folder if not exists
1353
+ const folderPath = path.dirname(filePath);
1354
+ try {
1355
+ await mkdir(folderPath, {
1356
+ recursive: true
1357
+ });
1358
+ } catch {
1359
+ debug('Error creating folder %s', folderPath);
1360
+ }
1361
+ await writeFile(filePath, content, {
1362
+ encoding: 'utf8'
1363
+ });
1364
+ }
1365
+ // write sanity folder files
1366
+ async writeSourceFiles({ fileExtension, files, folderPath, srcFolderPrefix, workDir }) {
1367
+ for (const [filePath, content] of Object.entries(files)){
1368
+ // check if file ends with full stop to indicate it's file and not directory (this only works with our template tree structure)
1369
+ if (filePath.includes('.') && typeof content === 'string') {
1370
+ await this.writeOrOverwrite(path.join(workDir, srcFolderPrefix ? 'src' : '', 'sanity', folderPath || '', `${filePath}${fileExtension}`), content, workDir);
1371
+ } else {
1372
+ await mkdir(path.join(workDir, srcFolderPrefix ? 'src' : '', 'sanity', filePath), {
1373
+ recursive: true
1374
+ });
1375
+ if (typeof content === 'object') {
1376
+ await this.writeSourceFiles({
1377
+ fileExtension,
1378
+ files: content,
1379
+ folderPath: filePath,
1380
+ srcFolderPrefix,
1381
+ workDir
1382
+ });
1383
+ }
1384
+ }
1385
+ }
1386
+ }
1387
+ }
1388
+
1389
+ //# sourceMappingURL=init.js.map