@sanity/cli 6.0.0-alpha.4 → 6.0.0-alpha.6

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 (608) hide show
  1. package/dist/actions/dataset/create.d.ts +49 -0
  2. package/dist/actions/dataset/create.js +48 -0
  3. package/dist/actions/dataset/create.js.map +1 -0
  4. package/dist/actions/dataset/determineDatasetAclMode.d.ts +37 -0
  5. package/dist/actions/dataset/determineDatasetAclMode.js +36 -0
  6. package/dist/actions/dataset/determineDatasetAclMode.js.map +1 -0
  7. package/dist/actions/debug/gatherDebugInfo.js +15 -21
  8. package/dist/actions/debug/gatherDebugInfo.js.map +1 -1
  9. package/dist/actions/debug/types.d.ts +0 -2
  10. package/dist/actions/debug/types.js.map +1 -1
  11. package/dist/actions/deploy/deployApp.js +13 -0
  12. package/dist/actions/deploy/deployApp.js.map +1 -1
  13. package/dist/actions/dev/startStudioDevServer.js +3 -8
  14. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  15. package/dist/actions/dev/types.d.ts +1 -3
  16. package/dist/actions/dev/types.js.map +1 -1
  17. package/dist/actions/documents/validate.d.ts +0 -2
  18. package/dist/actions/documents/validate.js +21 -1
  19. package/dist/actions/documents/validate.js.map +1 -1
  20. package/dist/actions/exec/execScript.js +1 -1
  21. package/dist/actions/exec/execScript.js.map +1 -1
  22. package/dist/actions/graphql/getGraphQLAPIs.js +1 -1
  23. package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -1
  24. package/dist/actions/init/remoteTemplate.js +1 -1
  25. package/dist/actions/init/remoteTemplate.js.map +1 -1
  26. package/dist/actions/manifest/extractAppManifest.d.ts +20 -0
  27. package/dist/actions/manifest/extractAppManifest.js +51 -0
  28. package/dist/actions/manifest/extractAppManifest.js.map +1 -0
  29. package/dist/actions/manifest/extractManifest.js +2 -5
  30. package/dist/actions/manifest/extractManifest.js.map +1 -1
  31. package/dist/actions/manifest/types.d.ts +6 -1
  32. package/dist/actions/manifest/types.js.map +1 -1
  33. package/dist/actions/media/importAspects.js +2 -1
  34. package/dist/actions/media/importAspects.js.map +1 -1
  35. package/dist/actions/schema/deleteSchemaAction.d.ts +13 -5
  36. package/dist/actions/schema/deleteSchemaAction.js +12 -17
  37. package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
  38. package/dist/actions/schema/deploySchemas.d.ts +15 -0
  39. package/dist/actions/schema/deploySchemas.js +98 -0
  40. package/dist/actions/schema/deploySchemas.js.map +1 -0
  41. package/dist/actions/schema/listSchemas.d.ts +12 -0
  42. package/dist/actions/schema/listSchemas.js +119 -0
  43. package/dist/actions/schema/listSchemas.js.map +1 -0
  44. package/dist/actions/schema/schemaStoreTypes.d.ts +0 -11
  45. package/dist/actions/schema/schemaStoreTypes.js.map +1 -1
  46. package/dist/actions/schema/utils/debug.d.ts +2 -0
  47. package/dist/actions/schema/utils/debug.js +5 -0
  48. package/dist/actions/schema/utils/debug.js.map +1 -0
  49. package/dist/actions/schema/utils/manifestExtractor.d.ts +3 -8
  50. package/dist/actions/schema/utils/manifestExtractor.js +12 -17
  51. package/dist/actions/schema/utils/manifestExtractor.js.map +1 -1
  52. package/dist/actions/schema/utils/manifestReader.d.ts +2 -9
  53. package/dist/actions/schema/utils/manifestReader.js +6 -12
  54. package/dist/actions/schema/utils/manifestReader.js.map +1 -1
  55. package/dist/actions/schema/utils/schemaStoreOutStrings.d.ts +0 -1
  56. package/dist/actions/schema/utils/schemaStoreOutStrings.js +1 -1
  57. package/dist/actions/schema/utils/schemaStoreOutStrings.js.map +1 -1
  58. package/dist/actions/schema/utils/schemaStoreValidation.d.ts +10 -62
  59. package/dist/actions/schema/utils/schemaStoreValidation.js +38 -125
  60. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
  61. package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +14 -0
  62. package/dist/actions/schema/utils/uniqByProjectIdDataset.js +9 -0
  63. package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -0
  64. package/dist/actions/users/getMembersForProject.d.ts +1 -3
  65. package/dist/actions/users/getMembersForProject.js +6 -17
  66. package/dist/actions/users/getMembersForProject.js.map +1 -1
  67. package/dist/actions/users/types.d.ts +0 -11
  68. package/dist/actions/users/types.js.map +1 -1
  69. package/dist/commands/backup/disable.js +5 -11
  70. package/dist/commands/backup/disable.js.map +1 -1
  71. package/dist/commands/backup/enable.js +5 -11
  72. package/dist/commands/backup/enable.js.map +1 -1
  73. package/dist/commands/backup/list.js +7 -8
  74. package/dist/commands/backup/list.js.map +1 -1
  75. package/dist/commands/cors/add.js +5 -13
  76. package/dist/commands/cors/add.js.map +1 -1
  77. package/dist/commands/cors/delete.js +7 -15
  78. package/dist/commands/cors/delete.js.map +1 -1
  79. package/dist/commands/cors/list.js +2 -10
  80. package/dist/commands/cors/list.js.map +1 -1
  81. package/dist/commands/dataset/create.d.ts +0 -2
  82. package/dist/commands/dataset/create.js +8 -54
  83. package/dist/commands/dataset/create.js.map +1 -1
  84. package/dist/commands/dataset/export.js +4 -4
  85. package/dist/commands/dataset/export.js.map +1 -1
  86. package/dist/commands/debug.js +5 -9
  87. package/dist/commands/debug.js.map +1 -1
  88. package/dist/commands/dev.js +0 -1
  89. package/dist/commands/dev.js.map +1 -1
  90. package/dist/commands/documents/create.d.ts +1 -0
  91. package/dist/commands/documents/create.js +10 -9
  92. package/dist/commands/documents/create.js.map +1 -1
  93. package/dist/commands/documents/delete.js +2 -3
  94. package/dist/commands/documents/delete.js.map +1 -1
  95. package/dist/commands/documents/get.js +2 -3
  96. package/dist/commands/documents/get.js.map +1 -1
  97. package/dist/commands/documents/query.js +2 -3
  98. package/dist/commands/documents/query.js.map +1 -1
  99. package/dist/commands/documents/validate.js +0 -20
  100. package/dist/commands/documents/validate.js.map +1 -1
  101. package/dist/commands/graphql/list.js +2 -2
  102. package/dist/commands/graphql/list.js.map +1 -1
  103. package/dist/commands/graphql/undeploy.js +4 -9
  104. package/dist/commands/graphql/undeploy.js.map +1 -1
  105. package/dist/commands/hook/create.js +2 -6
  106. package/dist/commands/hook/create.js.map +1 -1
  107. package/dist/commands/hook/delete.js +5 -17
  108. package/dist/commands/hook/delete.js.map +1 -1
  109. package/dist/commands/hook/list.js +2 -8
  110. package/dist/commands/hook/list.js.map +1 -1
  111. package/dist/commands/init.d.ts +6 -1
  112. package/dist/commands/init.js +358 -20
  113. package/dist/commands/init.js.map +1 -1
  114. package/dist/commands/manifest/extract.js +7 -8
  115. package/dist/commands/manifest/extract.js.map +1 -1
  116. package/dist/commands/media/export.js +2 -2
  117. package/dist/commands/media/export.js.map +1 -1
  118. package/dist/commands/media/import.js +2 -2
  119. package/dist/commands/media/import.js.map +1 -1
  120. package/dist/commands/projects/list.js +2 -6
  121. package/dist/commands/projects/list.js.map +1 -1
  122. package/dist/commands/schema/delete.d.ts +1 -1
  123. package/dist/commands/schema/delete.js +20 -23
  124. package/dist/commands/schema/delete.js.map +1 -1
  125. package/dist/commands/schema/deploy.d.ts +16 -0
  126. package/dist/commands/schema/deploy.js +98 -0
  127. package/dist/commands/schema/deploy.js.map +1 -0
  128. package/dist/commands/schema/list.d.ts +15 -0
  129. package/dist/commands/schema/list.js +104 -0
  130. package/dist/commands/schema/list.js.map +1 -0
  131. package/dist/commands/tokens/add.js +3 -5
  132. package/dist/commands/tokens/add.js.map +1 -1
  133. package/dist/commands/users/invite.js +6 -17
  134. package/dist/commands/users/invite.js.map +1 -1
  135. package/dist/commands/users/list.js +4 -7
  136. package/dist/commands/users/list.js.map +1 -1
  137. package/dist/config/createCliConfig.d.ts +13 -4
  138. package/dist/prompts/init/promptForTypescript.d.ts +2 -0
  139. package/dist/prompts/init/promptForTypescript.js +15 -0
  140. package/dist/prompts/init/promptForTypescript.js.map +1 -0
  141. package/dist/prompts/promptForDatasetAclMode.d.ts +9 -0
  142. package/dist/prompts/promptForDatasetAclMode.js +27 -0
  143. package/dist/prompts/promptForDatasetAclMode.js.map +1 -0
  144. package/dist/prompts/promptForDatasetName.d.ts +1 -1
  145. package/dist/prompts/promptForDatasetName.js +4 -1
  146. package/dist/prompts/promptForDatasetName.js.map +1 -1
  147. package/dist/services/backup.d.ts +8 -0
  148. package/dist/services/backup.js +19 -0
  149. package/dist/services/backup.js.map +1 -1
  150. package/dist/services/cors.d.ts +23 -0
  151. package/dist/services/cors.js +38 -0
  152. package/dist/services/cors.js.map +1 -0
  153. package/dist/services/graphql.d.ts +7 -0
  154. package/dist/services/graphql.js +11 -0
  155. package/dist/services/graphql.js.map +1 -1
  156. package/dist/services/hooks.d.ts +2 -0
  157. package/dist/services/hooks.js +19 -0
  158. package/dist/services/hooks.js.map +1 -1
  159. package/dist/services/organizations.d.ts +4 -2
  160. package/dist/services/organizations.js +3 -2
  161. package/dist/services/organizations.js.map +1 -1
  162. package/dist/services/projects.d.ts +11 -0
  163. package/dist/services/projects.js +41 -0
  164. package/dist/services/projects.js.map +1 -1
  165. package/dist/services/schemas.d.ts +4 -0
  166. package/dist/services/schemas.js +40 -0
  167. package/dist/services/schemas.js.map +1 -0
  168. package/dist/services/user.d.ts +13 -0
  169. package/dist/services/user.js +27 -3
  170. package/dist/services/user.js.map +1 -1
  171. package/dist/services/userApplications.d.ts +3 -1
  172. package/dist/services/userApplications.js +5 -1
  173. package/dist/services/userApplications.js.map +1 -1
  174. package/dist/util/errorMessages.d.ts +1 -0
  175. package/dist/util/errorMessages.js +1 -0
  176. package/dist/util/errorMessages.js.map +1 -1
  177. package/dist/util/getCliVersion.js +1 -1
  178. package/dist/util/getCliVersion.js.map +1 -1
  179. package/dist/util/readPackageJson.d.ts +1 -15
  180. package/dist/util/readPackageJson.js +1 -1
  181. package/dist/util/readPackageJson.js.map +1 -1
  182. package/dist/util/uniqBy.d.ts +1 -0
  183. package/dist/util/uniqBy.js +14 -0
  184. package/dist/util/uniqBy.js.map +1 -0
  185. package/oclif.manifest.json +284 -139
  186. package/package.json +36 -33
  187. package/templates/app-quickstart/src/App.css +20 -0
  188. package/templates/app-quickstart/src/App.tsx +25 -0
  189. package/templates/app-quickstart/src/ExampleComponent.css +90 -0
  190. package/templates/app-quickstart/src/ExampleComponent.tsx +37 -0
  191. package/templates/app-sanity-ui/src/App.tsx +34 -0
  192. package/templates/app-sanity-ui/src/ExampleComponent.tsx +34 -0
  193. package/templates/app-sanity-ui/src/SanityUI.tsx +23 -0
  194. package/templates/blog/README.md +11 -0
  195. package/templates/blog/schemaTypes/author.js +50 -0
  196. package/templates/blog/schemaTypes/blockContent.js +67 -0
  197. package/templates/blog/schemaTypes/category.js +19 -0
  198. package/templates/blog/schemaTypes/index.js +6 -0
  199. package/templates/blog/schemaTypes/post.js +65 -0
  200. package/templates/blog/static/.gitkeep +1 -0
  201. package/templates/clean/README.md +9 -0
  202. package/templates/clean/schemaTypes/index.js +1 -0
  203. package/templates/clean/static/.gitkeep +1 -0
  204. package/templates/ecommerce/README.md +11 -0
  205. package/templates/ecommerce/plugins/.gitkeep +1 -0
  206. package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +62 -0
  207. package/templates/ecommerce/plugins/barcode-input/index.js +9 -0
  208. package/templates/ecommerce/plugins/barcode-input/schemaType.js +60 -0
  209. package/templates/ecommerce/schemaTypes/blockContent.js +67 -0
  210. package/templates/ecommerce/schemaTypes/category.js +39 -0
  211. package/templates/ecommerce/schemaTypes/index.js +23 -0
  212. package/templates/ecommerce/schemaTypes/locale/localeBlockContent.js +19 -0
  213. package/templates/ecommerce/schemaTypes/locale/localeString.js +19 -0
  214. package/templates/ecommerce/schemaTypes/locale/localeText.js +19 -0
  215. package/templates/ecommerce/schemaTypes/locale/supportedLanguages.js +5 -0
  216. package/templates/ecommerce/schemaTypes/product.js +83 -0
  217. package/templates/ecommerce/schemaTypes/productVariant.js +52 -0
  218. package/templates/ecommerce/schemaTypes/vendor.js +39 -0
  219. package/templates/ecommerce/static/.gitkeep +1 -0
  220. package/templates/get-started/README.md +9 -0
  221. package/templates/get-started/plugins/.gitkeep +1 -0
  222. package/templates/get-started/plugins/sanity-plugin-tutorial/CustomDefaultLayout.tsx +16 -0
  223. package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +104 -0
  224. package/templates/get-started/plugins/sanity-plugin-tutorial/index.ts +11 -0
  225. package/templates/get-started/schemaTypes/index.ts +1 -0
  226. package/templates/get-started/static/.gitkeep +1 -0
  227. package/templates/moviedb/README.md +10 -0
  228. package/templates/moviedb/schemaTypes/blockContent.js +67 -0
  229. package/templates/moviedb/schemaTypes/castMember.js +37 -0
  230. package/templates/moviedb/schemaTypes/crewMember.js +52 -0
  231. package/templates/moviedb/schemaTypes/index.js +22 -0
  232. package/templates/moviedb/schemaTypes/movie.js +85 -0
  233. package/templates/moviedb/schemaTypes/person.js +37 -0
  234. package/templates/moviedb/schemaTypes/plotSummaries.js +20 -0
  235. package/templates/moviedb/schemaTypes/plotSummary.js +24 -0
  236. package/templates/moviedb/schemaTypes/screening.js +81 -0
  237. package/templates/moviedb/static/.gitkeep +1 -0
  238. package/templates/quickstart/README.md +9 -0
  239. package/templates/quickstart/schemaTypes/index.js +1 -0
  240. package/templates/quickstart/static/.gitkeep +1 -0
  241. package/templates/shared/gitignore.txt +29 -0
  242. package/templates/shared/tsconfig.json +17 -0
  243. package/templates/shopify/README.md +85 -0
  244. package/templates/shopify/components/hotspots/ProductTooltip.tsx +38 -0
  245. package/templates/shopify/components/icons/Shopify.tsx +20 -0
  246. package/templates/shopify/components/inputs/CollectionHidden.tsx +23 -0
  247. package/templates/shopify/components/inputs/PlaceholderString.tsx +20 -0
  248. package/templates/shopify/components/inputs/ProductHidden.tsx +64 -0
  249. package/templates/shopify/components/inputs/ProductVariantHidden.tsx +24 -0
  250. package/templates/shopify/components/inputs/ProxyString.tsx +32 -0
  251. package/templates/shopify/components/media/ColorTheme.tsx +38 -0
  252. package/templates/shopify/components/media/ShopifyDocumentStatus.tsx +82 -0
  253. package/templates/shopify/components/studio/Navbar.tsx +29 -0
  254. package/templates/shopify/constants.ts +61 -0
  255. package/templates/shopify/docs/features.md +158 -0
  256. package/templates/shopify/plugins/customDocumentActions/index.ts +55 -0
  257. package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +144 -0
  258. package/templates/shopify/plugins/customDocumentActions/shopifyLink.ts +39 -0
  259. package/templates/shopify/plugins/customDocumentActions/types.ts +14 -0
  260. package/templates/shopify/schemaTypes/documents/collection.tsx +142 -0
  261. package/templates/shopify/schemaTypes/documents/colorTheme.tsx +44 -0
  262. package/templates/shopify/schemaTypes/documents/page.ts +70 -0
  263. package/templates/shopify/schemaTypes/documents/product.tsx +132 -0
  264. package/templates/shopify/schemaTypes/documents/productVariant.tsx +67 -0
  265. package/templates/shopify/schemaTypes/index.ts +108 -0
  266. package/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts +27 -0
  267. package/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts +16 -0
  268. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx +48 -0
  269. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx +50 -0
  270. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts +40 -0
  271. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts +49 -0
  272. package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
  273. package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
  274. package/templates/shopify/schemaTypes/objects/global/menuType.ts +17 -0
  275. package/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts +37 -0
  276. package/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts +48 -0
  277. package/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx +17 -0
  278. package/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx +60 -0
  279. package/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx +34 -0
  280. package/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx +37 -0
  281. package/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx +33 -0
  282. package/templates/shopify/schemaTypes/objects/link/linkProductType.tsx +60 -0
  283. package/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts +33 -0
  284. package/templates/shopify/schemaTypes/objects/module/accordionType.ts +28 -0
  285. package/templates/shopify/schemaTypes/objects/module/callToActionType.tsx +85 -0
  286. package/templates/shopify/schemaTypes/objects/module/calloutType.ts +38 -0
  287. package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +47 -0
  288. package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
  289. package/templates/shopify/schemaTypes/objects/module/gridType.ts +28 -0
  290. package/templates/shopify/schemaTypes/objects/module/heroType.tsx +40 -0
  291. package/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx +19 -0
  292. package/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts +80 -0
  293. package/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx +51 -0
  294. package/templates/shopify/schemaTypes/objects/module/instagramType.ts +35 -0
  295. package/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx +50 -0
  296. package/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx +42 -0
  297. package/templates/shopify/schemaTypes/objects/seoType.ts +31 -0
  298. package/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx +37 -0
  299. package/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts +25 -0
  300. package/templates/shopify/schemaTypes/objects/shopify/optionType.tsx +31 -0
  301. package/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts +11 -0
  302. package/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts +20 -0
  303. package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +142 -0
  304. package/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts +12 -0
  305. package/templates/shopify/schemaTypes/objects/shopify/shopType.ts +15 -0
  306. package/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts +84 -0
  307. package/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts +131 -0
  308. package/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts +121 -0
  309. package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
  310. package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
  311. package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
  312. package/templates/shopify/schemaTypes/singletons/settingsType.ts +96 -0
  313. package/templates/shopify/static/.gitkeep +1 -0
  314. package/templates/shopify/structure/collectionStructure.ts +9 -0
  315. package/templates/shopify/structure/colorThemeStructure.ts +9 -0
  316. package/templates/shopify/structure/homeStructure.ts +9 -0
  317. package/templates/shopify/structure/index.ts +57 -0
  318. package/templates/shopify/structure/pageStructure.ts +11 -0
  319. package/templates/shopify/structure/productStructure.ts +51 -0
  320. package/templates/shopify/structure/settingStructure.ts +9 -0
  321. package/templates/shopify/utils/blocksToText.ts +20 -0
  322. package/templates/shopify/utils/defineStructure.ts +11 -0
  323. package/templates/shopify/utils/getPriceRange.ts +24 -0
  324. package/templates/shopify/utils/shopifyUrls.ts +22 -0
  325. package/templates/shopify/utils/validateSlug.ts +18 -0
  326. package/templates/shopify-online-storefront/README.md +54 -0
  327. package/templates/shopify-online-storefront/components/icons/Shopify.tsx +22 -0
  328. package/templates/shopify-online-storefront/components/inputs/CollectionHidden.tsx +23 -0
  329. package/templates/shopify-online-storefront/components/inputs/PlaceholderString.tsx +25 -0
  330. package/templates/shopify-online-storefront/components/inputs/ProductHidden.tsx +66 -0
  331. package/templates/shopify-online-storefront/components/inputs/ProductVariantHidden.tsx +25 -0
  332. package/templates/shopify-online-storefront/components/inputs/ProxyString.tsx +38 -0
  333. package/templates/shopify-online-storefront/components/media/ShopifyDocumentStatus.tsx +83 -0
  334. package/templates/shopify-online-storefront/constants.ts +18 -0
  335. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/index.ts +45 -0
  336. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +144 -0
  337. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyLink.ts +39 -0
  338. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/types.ts +14 -0
  339. package/templates/shopify-online-storefront/schemaTypes/blocks/blockContent.ts +32 -0
  340. package/templates/shopify-online-storefront/schemaTypes/documents/collection.tsx +83 -0
  341. package/templates/shopify-online-storefront/schemaTypes/documents/product.tsx +102 -0
  342. package/templates/shopify-online-storefront/schemaTypes/documents/productVariant.tsx +82 -0
  343. package/templates/shopify-online-storefront/schemaTypes/index.ts +43 -0
  344. package/templates/shopify-online-storefront/schemaTypes/objects/accordion.ts +31 -0
  345. package/templates/shopify-online-storefront/schemaTypes/objects/accordionGroup.ts +35 -0
  346. package/templates/shopify-online-storefront/schemaTypes/objects/callout.ts +40 -0
  347. package/templates/shopify-online-storefront/schemaTypes/objects/inventory.ts +30 -0
  348. package/templates/shopify-online-storefront/schemaTypes/objects/option.ts +30 -0
  349. package/templates/shopify-online-storefront/schemaTypes/objects/priceRange.ts +22 -0
  350. package/templates/shopify-online-storefront/schemaTypes/objects/proxyString.ts +11 -0
  351. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollection.ts +109 -0
  352. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollectionRule.tsx +45 -0
  353. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProduct.ts +165 -0
  354. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProductVariant.ts +151 -0
  355. package/templates/shopify-online-storefront/structure/collectionStructure.ts +9 -0
  356. package/templates/shopify-online-storefront/structure/index.ts +37 -0
  357. package/templates/shopify-online-storefront/structure/productStructure.ts +35 -0
  358. package/templates/shopify-online-storefront/utils/defineStructure.ts +11 -0
  359. package/templates/shopify-online-storefront/utils/getPriceRange.ts +24 -0
  360. package/templates/shopify-online-storefront/utils/shopifyUrls.ts +22 -0
  361. package/dist/actions/build/__tests__/buildApp.test.js +0 -367
  362. package/dist/actions/build/__tests__/buildApp.test.js.map +0 -1
  363. package/dist/actions/build/__tests__/buildStudio.test.js +0 -561
  364. package/dist/actions/build/__tests__/buildStudio.test.js.map +0 -1
  365. package/dist/actions/build/__tests__/checkRequiredDependencies.test.js +0 -233
  366. package/dist/actions/build/__tests__/checkRequiredDependencies.test.js.map +0 -1
  367. package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js +0 -414
  368. package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js.map +0 -1
  369. package/dist/actions/build/__tests__/determineBasePath.test.js +0 -24
  370. package/dist/actions/build/__tests__/determineBasePath.test.js.map +0 -1
  371. package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js +0 -109
  372. package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js.map +0 -1
  373. package/dist/actions/build/__tests__/getViteConfig.test.js +0 -493
  374. package/dist/actions/build/__tests__/getViteConfig.test.js.map +0 -1
  375. package/dist/actions/build/__tests__/renderDocument.test.js +0 -278
  376. package/dist/actions/build/__tests__/renderDocument.test.js.map +0 -1
  377. package/dist/actions/build/__tests__/shouldAutoUpdate.test.js +0 -153
  378. package/dist/actions/build/__tests__/shouldAutoUpdate.test.js.map +0 -1
  379. package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js +0 -657
  380. package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js.map +0 -1
  381. package/dist/actions/cors/constants.d.ts +0 -1
  382. package/dist/actions/cors/constants.js +0 -3
  383. package/dist/actions/cors/constants.js.map +0 -1
  384. package/dist/actions/cors/types.d.ts +0 -9
  385. package/dist/actions/cors/types.js +0 -3
  386. package/dist/actions/cors/types.js.map +0 -1
  387. package/dist/actions/dataset/__tests__/validateDatasetName.test.js +0 -182
  388. package/dist/actions/dataset/__tests__/validateDatasetName.test.js.map +0 -1
  389. package/dist/actions/deploy/__tests__/checkDir.test.js +0 -120
  390. package/dist/actions/deploy/__tests__/checkDir.test.js.map +0 -1
  391. package/dist/actions/docs/__tests__/normalizeDocsPath.test.js +0 -16
  392. package/dist/actions/docs/__tests__/normalizeDocsPath.test.js.map +0 -1
  393. package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js +0 -124
  394. package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js.map +0 -1
  395. package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +0 -274
  396. package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +0 -1
  397. package/dist/actions/media/__tests__/importMedia.test.js +0 -182
  398. package/dist/actions/media/__tests__/importMedia.test.js.map +0 -1
  399. package/dist/actions/schema/__tests__/deleteSchemaAction.test.js +0 -294
  400. package/dist/actions/schema/__tests__/deleteSchemaAction.test.js.map +0 -1
  401. package/dist/actions/schema/__tests__/formatSchemaValidation.test.js +0 -174
  402. package/dist/actions/schema/__tests__/formatSchemaValidation.test.js.map +0 -1
  403. package/dist/actions/schema/__tests__/validateAction.test.js +0 -281
  404. package/dist/actions/schema/__tests__/validateAction.test.js.map +0 -1
  405. package/dist/actions/schema/schemaStoreConstants.d.ts +0 -1
  406. package/dist/actions/schema/schemaStoreConstants.js +0 -4
  407. package/dist/actions/schema/schemaStoreConstants.js.map +0 -1
  408. package/dist/actions/schema/utils/schemaActionHelpers.d.ts +0 -1
  409. package/dist/actions/schema/utils/schemaActionHelpers.js +0 -5
  410. package/dist/actions/schema/utils/schemaActionHelpers.js.map +0 -1
  411. package/dist/actions/schema/utils/schemaApiClient.d.ts +0 -6
  412. package/dist/actions/schema/utils/schemaApiClient.js +0 -17
  413. package/dist/actions/schema/utils/schemaApiClient.js.map +0 -1
  414. package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js +0 -27
  415. package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js.map +0 -1
  416. package/dist/actions/users/__tests__/validateEmail.test.js +0 -16
  417. package/dist/actions/users/__tests__/validateEmail.test.js.map +0 -1
  418. package/dist/actions/users/apiVersion.d.ts +0 -6
  419. package/dist/actions/users/apiVersion.js +0 -7
  420. package/dist/actions/users/apiVersion.js.map +0 -1
  421. package/dist/commands/__tests__/blueprints.test.js +0 -54
  422. package/dist/commands/__tests__/blueprints.test.js.map +0 -1
  423. package/dist/commands/__tests__/build.test.js +0 -132
  424. package/dist/commands/__tests__/build.test.js.map +0 -1
  425. package/dist/commands/__tests__/codemod.test.js +0 -271
  426. package/dist/commands/__tests__/codemod.test.js.map +0 -1
  427. package/dist/commands/__tests__/debug.test.js +0 -697
  428. package/dist/commands/__tests__/debug.test.js.map +0 -1
  429. package/dist/commands/__tests__/deploy.test.js +0 -1913
  430. package/dist/commands/__tests__/deploy.test.js.map +0 -1
  431. package/dist/commands/__tests__/dev.test.js +0 -410
  432. package/dist/commands/__tests__/dev.test.js.map +0 -1
  433. package/dist/commands/__tests__/exec.test.js +0 -207
  434. package/dist/commands/__tests__/exec.test.js.map +0 -1
  435. package/dist/commands/__tests__/init/init.authentication.test.js +0 -60
  436. package/dist/commands/__tests__/init/init.authentication.test.js.map +0 -1
  437. package/dist/commands/__tests__/init/init.create-new-project.test.js +0 -196
  438. package/dist/commands/__tests__/init/init.create-new-project.test.js.map +0 -1
  439. package/dist/commands/__tests__/init/init.plan.test.js +0 -220
  440. package/dist/commands/__tests__/init/init.plan.test.js.map +0 -1
  441. package/dist/commands/__tests__/init/init.setup.test.js +0 -279
  442. package/dist/commands/__tests__/init/init.setup.test.js.map +0 -1
  443. package/dist/commands/__tests__/install.test.js +0 -258
  444. package/dist/commands/__tests__/install.test.js.map +0 -1
  445. package/dist/commands/__tests__/learn.test.js +0 -29
  446. package/dist/commands/__tests__/learn.test.js.map +0 -1
  447. package/dist/commands/__tests__/logout.test.js +0 -88
  448. package/dist/commands/__tests__/logout.test.js.map +0 -1
  449. package/dist/commands/__tests__/manage.test.js +0 -105
  450. package/dist/commands/__tests__/manage.test.js.map +0 -1
  451. package/dist/commands/__tests__/migration.test.js +0 -119
  452. package/dist/commands/__tests__/migration.test.js.map +0 -1
  453. package/dist/commands/__tests__/preview.test.js +0 -261
  454. package/dist/commands/__tests__/preview.test.js.map +0 -1
  455. package/dist/commands/__tests__/start.test.js +0 -253
  456. package/dist/commands/__tests__/start.test.js.map +0 -1
  457. package/dist/commands/__tests__/undeploy.test.js +0 -382
  458. package/dist/commands/__tests__/undeploy.test.js.map +0 -1
  459. package/dist/commands/__tests__/versions.test.js +0 -134
  460. package/dist/commands/__tests__/versions.test.js.map +0 -1
  461. package/dist/commands/backup/__tests__/disable.test.js +0 -207
  462. package/dist/commands/backup/__tests__/disable.test.js.map +0 -1
  463. package/dist/commands/backup/__tests__/download.test.js +0 -679
  464. package/dist/commands/backup/__tests__/download.test.js.map +0 -1
  465. package/dist/commands/backup/__tests__/enable.test.js +0 -317
  466. package/dist/commands/backup/__tests__/enable.test.js.map +0 -1
  467. package/dist/commands/backup/__tests__/list.test.js +0 -321
  468. package/dist/commands/backup/__tests__/list.test.js.map +0 -1
  469. package/dist/commands/cors/__tests__/add.test.js +0 -346
  470. package/dist/commands/cors/__tests__/add.test.js.map +0 -1
  471. package/dist/commands/cors/__tests__/delete.test.js +0 -293
  472. package/dist/commands/cors/__tests__/delete.test.js.map +0 -1
  473. package/dist/commands/cors/__tests__/list.test.js +0 -218
  474. package/dist/commands/cors/__tests__/list.test.js.map +0 -1
  475. package/dist/commands/dataset/__tests__/copy.test.js +0 -520
  476. package/dist/commands/dataset/__tests__/copy.test.js.map +0 -1
  477. package/dist/commands/dataset/__tests__/create.test.js +0 -312
  478. package/dist/commands/dataset/__tests__/create.test.js.map +0 -1
  479. package/dist/commands/dataset/__tests__/delete.test.js +0 -224
  480. package/dist/commands/dataset/__tests__/delete.test.js.map +0 -1
  481. package/dist/commands/dataset/__tests__/export.test.js +0 -561
  482. package/dist/commands/dataset/__tests__/export.test.js.map +0 -1
  483. package/dist/commands/dataset/__tests__/import.test.js +0 -53
  484. package/dist/commands/dataset/__tests__/import.test.js.map +0 -1
  485. package/dist/commands/dataset/__tests__/list.test.js +0 -174
  486. package/dist/commands/dataset/__tests__/list.test.js.map +0 -1
  487. package/dist/commands/dataset/alias/__tests__/create.test.js +0 -299
  488. package/dist/commands/dataset/alias/__tests__/create.test.js.map +0 -1
  489. package/dist/commands/dataset/alias/__tests__/delete.test.js +0 -236
  490. package/dist/commands/dataset/alias/__tests__/delete.test.js.map +0 -1
  491. package/dist/commands/dataset/alias/__tests__/link.test.js +0 -336
  492. package/dist/commands/dataset/alias/__tests__/link.test.js.map +0 -1
  493. package/dist/commands/dataset/alias/__tests__/unlink.test.js +0 -298
  494. package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +0 -1
  495. package/dist/commands/dataset/visibility/__tests__/get.test.js +0 -147
  496. package/dist/commands/dataset/visibility/__tests__/get.test.js.map +0 -1
  497. package/dist/commands/dataset/visibility/__tests__/set.test.js +0 -245
  498. package/dist/commands/dataset/visibility/__tests__/set.test.js.map +0 -1
  499. package/dist/commands/docs/__tests__/browse.test.js +0 -29
  500. package/dist/commands/docs/__tests__/browse.test.js.map +0 -1
  501. package/dist/commands/docs/__tests__/read.test.js +0 -78
  502. package/dist/commands/docs/__tests__/read.test.js.map +0 -1
  503. package/dist/commands/docs/__tests__/search.test.js +0 -254
  504. package/dist/commands/docs/__tests__/search.test.js.map +0 -1
  505. package/dist/commands/documents/__tests__/create.test.js +0 -967
  506. package/dist/commands/documents/__tests__/create.test.js.map +0 -1
  507. package/dist/commands/documents/__tests__/delete.test.js +0 -268
  508. package/dist/commands/documents/__tests__/delete.test.js.map +0 -1
  509. package/dist/commands/documents/__tests__/get.test.js +0 -209
  510. package/dist/commands/documents/__tests__/get.test.js.map +0 -1
  511. package/dist/commands/documents/__tests__/query.test.js +0 -405
  512. package/dist/commands/documents/__tests__/query.test.js.map +0 -1
  513. package/dist/commands/documents/__tests__/validate.test.js +0 -226
  514. package/dist/commands/documents/__tests__/validate.test.js.map +0 -1
  515. package/dist/commands/graphql/__tests__/list.test.js +0 -228
  516. package/dist/commands/graphql/__tests__/list.test.js.map +0 -1
  517. package/dist/commands/graphql/__tests__/undeploy.test.js +0 -384
  518. package/dist/commands/graphql/__tests__/undeploy.test.js.map +0 -1
  519. package/dist/commands/hook/__tests__/attempt.test.js +0 -260
  520. package/dist/commands/hook/__tests__/attempt.test.js.map +0 -1
  521. package/dist/commands/hook/__tests__/create.test.js +0 -121
  522. package/dist/commands/hook/__tests__/create.test.js.map +0 -1
  523. package/dist/commands/hook/__tests__/delete.test.js +0 -220
  524. package/dist/commands/hook/__tests__/delete.test.js.map +0 -1
  525. package/dist/commands/hook/__tests__/list.test.js +0 -138
  526. package/dist/commands/hook/__tests__/list.test.js.map +0 -1
  527. package/dist/commands/hook/__tests__/logs.test.js +0 -770
  528. package/dist/commands/hook/__tests__/logs.test.js.map +0 -1
  529. package/dist/commands/manifest/__tests__/extract.test.js +0 -123
  530. package/dist/commands/manifest/__tests__/extract.test.js.map +0 -1
  531. package/dist/commands/mcp/__tests__/configure.test.js +0 -397
  532. package/dist/commands/mcp/__tests__/configure.test.js.map +0 -1
  533. package/dist/commands/media/__tests__/create-aspect.test.js +0 -160
  534. package/dist/commands/media/__tests__/create-aspect.test.js.map +0 -1
  535. package/dist/commands/media/__tests__/delete-aspect.test.js +0 -333
  536. package/dist/commands/media/__tests__/delete-aspect.test.js.map +0 -1
  537. package/dist/commands/media/__tests__/deploy-aspect.test.js +0 -632
  538. package/dist/commands/media/__tests__/deploy-aspect.test.js.map +0 -1
  539. package/dist/commands/media/__tests__/export.test.js +0 -398
  540. package/dist/commands/media/__tests__/export.test.js.map +0 -1
  541. package/dist/commands/media/__tests__/import.test.js +0 -281
  542. package/dist/commands/media/__tests__/import.test.js.map +0 -1
  543. package/dist/commands/openapi/__tests__/get.test.js +0 -149
  544. package/dist/commands/openapi/__tests__/get.test.js.map +0 -1
  545. package/dist/commands/openapi/__tests__/list.test.js +0 -113
  546. package/dist/commands/openapi/__tests__/list.test.js.map +0 -1
  547. package/dist/commands/projects/__tests__/list.test.js +0 -153
  548. package/dist/commands/projects/__tests__/list.test.js.map +0 -1
  549. package/dist/commands/schema/__tests__/delete.test.js +0 -209
  550. package/dist/commands/schema/__tests__/delete.test.js.map +0 -1
  551. package/dist/commands/schema/__tests__/extract.test.js +0 -113
  552. package/dist/commands/schema/__tests__/extract.test.js.map +0 -1
  553. package/dist/commands/schema/__tests__/validate.test.js +0 -104
  554. package/dist/commands/schema/__tests__/validate.test.js.map +0 -1
  555. package/dist/commands/telemetry/__tests__/disable.test.js +0 -145
  556. package/dist/commands/telemetry/__tests__/disable.test.js.map +0 -1
  557. package/dist/commands/telemetry/__tests__/enable.test.js +0 -131
  558. package/dist/commands/telemetry/__tests__/enable.test.js.map +0 -1
  559. package/dist/commands/telemetry/__tests__/status.test.js +0 -153
  560. package/dist/commands/telemetry/__tests__/status.test.js.map +0 -1
  561. package/dist/commands/tokens/__tests__/add.test.js +0 -420
  562. package/dist/commands/tokens/__tests__/add.test.js.map +0 -1
  563. package/dist/commands/tokens/__tests__/delete.test.js +0 -375
  564. package/dist/commands/tokens/__tests__/delete.test.js.map +0 -1
  565. package/dist/commands/tokens/__tests__/list.test.js +0 -368
  566. package/dist/commands/tokens/__tests__/list.test.js.map +0 -1
  567. package/dist/commands/users/__tests__/invite.test.js +0 -341
  568. package/dist/commands/users/__tests__/invite.test.js.map +0 -1
  569. package/dist/commands/users/__tests__/list.test.js +0 -401
  570. package/dist/commands/users/__tests__/list.test.js.map +0 -1
  571. package/dist/hooks/prerun/__tests__/setupTelemetry.test.js +0 -77
  572. package/dist/hooks/prerun/__tests__/setupTelemetry.test.js.map +0 -1
  573. package/dist/services/__tests__/datasetAliases.test.js +0 -131
  574. package/dist/services/__tests__/datasetAliases.test.js.map +0 -1
  575. package/dist/services/__tests__/datasets.test.js +0 -436
  576. package/dist/services/__tests__/datasets.test.js.map +0 -1
  577. package/dist/services/__tests__/graphql.test.js +0 -43
  578. package/dist/services/__tests__/graphql.test.js.map +0 -1
  579. package/dist/services/__tests__/mediaLibraries.test.js +0 -88
  580. package/dist/services/__tests__/mediaLibraries.test.js.map +0 -1
  581. package/dist/services/__tests__/projects.test.js +0 -41
  582. package/dist/services/__tests__/projects.test.js.map +0 -1
  583. package/dist/services/__tests__/userApplications.test.js +0 -113
  584. package/dist/services/__tests__/userApplications.test.js.map +0 -1
  585. package/dist/util/__tests__/appId.test.js +0 -31
  586. package/dist/util/__tests__/appId.test.js.map +0 -1
  587. package/dist/util/__tests__/cliClient.test.js +0 -184
  588. package/dist/util/__tests__/cliClient.test.js.map +0 -1
  589. package/dist/util/__tests__/compareDependencyVersions.test.js +0 -426
  590. package/dist/util/__tests__/compareDependencyVersions.test.js.map +0 -1
  591. package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js +0 -74
  592. package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js.map +0 -1
  593. package/dist/util/__tests__/findNdjsonEntry.test.js +0 -54
  594. package/dist/util/__tests__/findNdjsonEntry.test.js.map +0 -1
  595. package/dist/util/__tests__/getCliVersion.test.js +0 -28
  596. package/dist/util/__tests__/getCliVersion.test.js.map +0 -1
  597. package/dist/util/__tests__/getLocalPackageVersion.test.js +0 -84
  598. package/dist/util/__tests__/getLocalPackageVersion.test.js.map +0 -1
  599. package/dist/util/__tests__/getWorkspace.test.js +0 -37
  600. package/dist/util/__tests__/getWorkspace.test.js.map +0 -1
  601. package/dist/util/__tests__/readPackageJson.test.js +0 -69
  602. package/dist/util/__tests__/readPackageJson.test.js.map +0 -1
  603. package/dist/util/__tests__/warnAboutMissingAppId.test.js +0 -28
  604. package/dist/util/__tests__/warnAboutMissingAppId.test.js.map +0 -1
  605. package/dist/util/packageManager/__tests__/installPackages.test.js +0 -388
  606. package/dist/util/packageManager/__tests__/installPackages.test.js.map +0 -1
  607. package/dist/util/validation/ __tests__/validateDocuments.test.js +0 -274
  608. package/dist/util/validation/ __tests__/validateDocuments.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/util/__tests__/getCliVersion.test.ts"],"sourcesContent":["import {packageDirectory} from 'pkg-dir'\nimport {describe, expect, test, vi} from 'vitest'\n\nimport {getCliVersion} from '../getCliVersion.js'\nimport {readPackageJson} from '../readPackageJson.js'\n\nvi.mock('pkg-dir')\nvi.mock(import('../readPackageJson.js'))\n\ndescribe('#getCliVersion', () => {\n test('should return the version of the @sanity/cli package', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce('/test/path')\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: '@sanity/cli',\n version: '1.0.0',\n })\n\n const version = await getCliVersion()\n\n expect(version).toBe('1.0.0')\n })\n\n test('should throw an error if the package.json is not found', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce('/test/path')\n vi.mocked(readPackageJson).mockRejectedValueOnce(new Error('Package.json not found'))\n\n await expect(getCliVersion()).rejects.toThrow('Package.json not found')\n })\n\n test('should throw an error if cli path is not found', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce(undefined)\n\n await expect(getCliVersion()).rejects.toThrow('Unable to resolve root of @sanity/cli module')\n })\n})\n"],"names":["packageDirectory","describe","expect","test","vi","getCliVersion","readPackageJson","mock","mocked","mockResolvedValueOnce","name","version","toBe","mockRejectedValueOnce","Error","rejects","toThrow","undefined"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,UAAS;AACxC,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAEjD,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,eAAe,QAAO,wBAAuB;AAErDF,GAAGG,IAAI,CAAC;AACRH,GAAGG,IAAI,CAAC,MAAM,CAAC;AAEfN,SAAS,kBAAkB;IACzBE,KAAK,wDAAwD;QAC3DC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAAC;QAClDL,GAAGI,MAAM,CAACF,iBAAiBG,qBAAqB,CAAC;YAC/CC,MAAM;YACNC,SAAS;QACX;QAEA,MAAMA,UAAU,MAAMN;QAEtBH,OAAOS,SAASC,IAAI,CAAC;IACvB;IAEAT,KAAK,0DAA0D;QAC7DC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAAC;QAClDL,GAAGI,MAAM,CAACF,iBAAiBO,qBAAqB,CAAC,IAAIC,MAAM;QAE3D,MAAMZ,OAAOG,iBAAiBU,OAAO,CAACC,OAAO,CAAC;IAChD;IAEAb,KAAK,kDAAkD;QACrDC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAACQ;QAElD,MAAMf,OAAOG,iBAAiBU,OAAO,CAACC,OAAO,CAAC;IAChD;AACF"}
@@ -1,84 +0,0 @@
1
- import { join } from 'node:path';
2
- // Import the mocked modules
3
- import resolveFrom from 'resolve-from';
4
- import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
5
- import { getLocalPackageVersion } from '../getLocalPackageVersion';
6
- import { readPackageJson } from '../readPackageJson.js';
7
- // Mock the dependencies
8
- vi.mock('resolve-from', ()=>({
9
- default: {
10
- silent: vi.fn()
11
- }
12
- }));
13
- vi.mock('../readPackageJson', ()=>({
14
- readPackageJson: vi.fn()
15
- }));
16
- describe('getLocalPackageVersion', ()=>{
17
- const mockWorkDir = '/mock/work/dir';
18
- const mockModuleId = '@sanity/test';
19
- beforeEach(()=>{
20
- vi.resetAllMocks();
21
- });
22
- afterEach(()=>{
23
- vi.clearAllMocks();
24
- });
25
- test('returns version when package.json is directly resolved', async ()=>{
26
- const mockPath = join(mockWorkDir, 'node_modules', mockModuleId, 'package.json');
27
- const mockVersion = '1.0.0';
28
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath);
29
- vi.mocked(readPackageJson).mockResolvedValueOnce({
30
- name: mockModuleId,
31
- version: mockVersion
32
- });
33
- const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
34
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
35
- expect(readPackageJson).toHaveBeenCalledWith(mockPath);
36
- expect(result).toBe(mockVersion);
37
- });
38
- test('handles packages with exports field when direct resolution fails', async ()=>{
39
- const modulePath = join(mockWorkDir, 'node_modules', mockModuleId, 'index.js');
40
- const moduleRoot = join(mockWorkDir, 'node_modules', mockModuleId);
41
- const manifestPath = join(moduleRoot, 'package.json');
42
- const mockVersion = '2.0.0';
43
- // First call returns null (direct package.json resolution fails)
44
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
45
- // Second call succeeds (resolving the module itself)
46
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(modulePath);
47
- vi.mocked(readPackageJson).mockResolvedValueOnce({
48
- name: mockModuleId,
49
- version: mockVersion
50
- });
51
- const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
52
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
53
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId);
54
- expect(readPackageJson).toHaveBeenCalledWith(manifestPath);
55
- expect(result).toBe(mockVersion);
56
- });
57
- test('returns undefined when module cannot be resolved at all', async ()=>{
58
- // Both resolution attempts fail
59
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
60
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
61
- const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
62
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
63
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId);
64
- expect(readPackageJson).not.toHaveBeenCalled();
65
- expect(result).toBeUndefined();
66
- });
67
- test('uses process.cwd() when workDir is not provided', async ()=>{
68
- const mockCwd = '/current/working/dir';
69
- const mockPath = join(mockCwd, 'node_modules', mockModuleId, 'package.json');
70
- const mockVersion = '3.0.0';
71
- vi.spyOn(process, 'cwd').mockReturnValue(mockCwd);
72
- vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath);
73
- vi.mocked(readPackageJson).mockResolvedValueOnce({
74
- name: mockModuleId,
75
- version: mockVersion
76
- });
77
- const result = await getLocalPackageVersion(mockModuleId, '');
78
- expect(resolveFrom.silent).toHaveBeenCalledWith(mockCwd, join(mockModuleId, 'package.json'));
79
- expect(readPackageJson).toHaveBeenCalledWith(mockPath);
80
- expect(result).toBe(mockVersion);
81
- });
82
- });
83
-
84
- //# sourceMappingURL=getLocalPackageVersion.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/util/__tests__/getLocalPackageVersion.test.ts"],"sourcesContent":["import {join} from 'node:path'\n\n// Import the mocked modules\nimport resolveFrom from 'resolve-from'\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {getLocalPackageVersion} from '../getLocalPackageVersion'\nimport {readPackageJson} from '../readPackageJson.js'\n\n// Mock the dependencies\nvi.mock('resolve-from', () => ({\n default: {\n silent: vi.fn(),\n },\n}))\n\nvi.mock('../readPackageJson', () => ({\n readPackageJson: vi.fn(),\n}))\n\ndescribe('getLocalPackageVersion', () => {\n const mockWorkDir = '/mock/work/dir'\n const mockModuleId = '@sanity/test'\n\n beforeEach(() => {\n vi.resetAllMocks()\n })\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('returns version when package.json is directly resolved', async () => {\n const mockPath = join(mockWorkDir, 'node_modules', mockModuleId, 'package.json')\n const mockVersion = '1.0.0'\n\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(readPackageJson).toHaveBeenCalledWith(mockPath)\n expect(result).toBe(mockVersion)\n })\n\n test('handles packages with exports field when direct resolution fails', async () => {\n const modulePath = join(mockWorkDir, 'node_modules', mockModuleId, 'index.js')\n const moduleRoot = join(mockWorkDir, 'node_modules', mockModuleId)\n const manifestPath = join(moduleRoot, 'package.json')\n const mockVersion = '2.0.0'\n\n // First call returns null (direct package.json resolution fails)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n // Second call succeeds (resolving the module itself)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(modulePath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId)\n expect(readPackageJson).toHaveBeenCalledWith(manifestPath)\n expect(result).toBe(mockVersion)\n })\n\n test('returns undefined when module cannot be resolved at all', async () => {\n // Both resolution attempts fail\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId)\n expect(readPackageJson).not.toHaveBeenCalled()\n expect(result).toBeUndefined()\n })\n\n test('uses process.cwd() when workDir is not provided', async () => {\n const mockCwd = '/current/working/dir'\n const mockPath = join(mockCwd, 'node_modules', mockModuleId, 'package.json')\n const mockVersion = '3.0.0'\n\n vi.spyOn(process, 'cwd').mockReturnValue(mockCwd)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, '')\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockCwd, join(mockModuleId, 'package.json'))\n expect(readPackageJson).toHaveBeenCalledWith(mockPath)\n expect(result).toBe(mockVersion)\n })\n})\n"],"names":["join","resolveFrom","afterEach","beforeEach","describe","expect","test","vi","getLocalPackageVersion","readPackageJson","mock","default","silent","fn","mockWorkDir","mockModuleId","resetAllMocks","clearAllMocks","mockPath","mockVersion","mocked","mockReturnValueOnce","mockResolvedValueOnce","name","version","result","toHaveBeenCalledWith","toBe","modulePath","moduleRoot","manifestPath","undefined","not","toHaveBeenCalled","toBeUndefined","mockCwd","spyOn","process","mockReturnValue"],"mappings":"AAAA,SAAQA,IAAI,QAAO,YAAW;AAE9B,4BAA4B;AAC5B,OAAOC,iBAAiB,eAAc;AACtC,SAAQC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAExE,SAAQC,sBAAsB,QAAO,4BAA2B;AAChE,SAAQC,eAAe,QAAO,wBAAuB;AAErD,wBAAwB;AACxBF,GAAGG,IAAI,CAAC,gBAAgB,IAAO,CAAA;QAC7BC,SAAS;YACPC,QAAQL,GAAGM,EAAE;QACf;IACF,CAAA;AAEAN,GAAGG,IAAI,CAAC,sBAAsB,IAAO,CAAA;QACnCD,iBAAiBF,GAAGM,EAAE;IACxB,CAAA;AAEAT,SAAS,0BAA0B;IACjC,MAAMU,cAAc;IACpB,MAAMC,eAAe;IAErBZ,WAAW;QACTI,GAAGS,aAAa;IAClB;IAEAd,UAAU;QACRK,GAAGU,aAAa;IAClB;IAEAX,KAAK,0DAA0D;QAC7D,MAAMY,WAAWlB,KAAKc,aAAa,gBAAgBC,cAAc;QACjE,MAAMI,cAAc;QAEpBZ,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACH;QAClDX,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOI,iBAAiBiB,oBAAoB,CAACR;QAC7Cb,OAAOoB,QAAQE,IAAI,CAACR;IACtB;IAEAb,KAAK,oEAAoE;QACvE,MAAMsB,aAAa5B,KAAKc,aAAa,gBAAgBC,cAAc;QACnE,MAAMc,aAAa7B,KAAKc,aAAa,gBAAgBC;QACrD,MAAMe,eAAe9B,KAAK6B,YAAY;QACtC,MAAMV,cAAc;QAEpB,iEAAiE;QACjEZ,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAClD,qDAAqD;QACrDxB,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACO;QAClDrB,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAaC;QAC7DV,OAAOI,iBAAiBiB,oBAAoB,CAACI;QAC7CzB,OAAOoB,QAAQE,IAAI,CAACR;IACtB;IAEAb,KAAK,2DAA2D;QAC9D,gCAAgC;QAChCC,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAClDxB,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAElD,MAAMN,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAaC;QAC7DV,OAAOI,iBAAiBuB,GAAG,CAACC,gBAAgB;QAC5C5B,OAAOoB,QAAQS,aAAa;IAC9B;IAEA5B,KAAK,mDAAmD;QACtD,MAAM6B,UAAU;QAChB,MAAMjB,WAAWlB,KAAKmC,SAAS,gBAAgBpB,cAAc;QAC7D,MAAMI,cAAc;QAEpBZ,GAAG6B,KAAK,CAACC,SAAS,OAAOC,eAAe,CAACH;QACzC5B,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACH;QAClDX,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAc;QAE1DV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACS,SAASnC,KAAKe,cAAc;QAC5EV,OAAOI,iBAAiBiB,oBAAoB,CAACR;QAC7Cb,OAAOoB,QAAQE,IAAI,CAACR;IACtB;AACF"}
@@ -1,37 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { getWorkspace } from '../getWorkspace';
3
- const mockWorkspaces = [
4
- {
5
- basePath: '/',
6
- dataset: 'production',
7
- name: 'test',
8
- projectId: 'test-project'
9
- },
10
- {
11
- basePath: '/',
12
- dataset: 'staging',
13
- name: 'test-staging',
14
- projectId: 'test-project'
15
- }
16
- ];
17
- describe('#getWorkspace', ()=>{
18
- test('returns a default workspace if only one exists', ()=>{
19
- const workspace = getWorkspace(mockWorkspaces.slice(0, 1));
20
- expect(workspace).toMatchObject(mockWorkspaces[0]);
21
- });
22
- test('returns a workspace by name if multiple exist', ()=>{
23
- const workspace = getWorkspace(mockWorkspaces, 'test-staging');
24
- expect(workspace).toMatchObject(mockWorkspaces[1]);
25
- });
26
- test('throws an error if no workspaces exist', ()=>{
27
- expect(()=>getWorkspace([])).toThrowError('No workspaces found');
28
- });
29
- test('throws an error if multiple workspaces exist but no name is specified', ()=>{
30
- expect(()=>getWorkspace(mockWorkspaces)).toThrowError(`Multiple workspaces found. Please specify which workspace to use with "--workspace". Available workspaces: test, test-staging`);
31
- });
32
- test('throws an error if workspace with specified name does not exist', ()=>{
33
- expect(()=>getWorkspace(mockWorkspaces, 'test-dev')).toThrowError(`Could not find "test-dev" workspace. Available workspaces: test, test-staging`);
34
- });
35
- });
36
-
37
- //# sourceMappingURL=getWorkspace.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/util/__tests__/getWorkspace.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {getWorkspace} from '../getWorkspace'\n\nconst mockWorkspaces = [\n {\n basePath: '/',\n dataset: 'production',\n name: 'test',\n projectId: 'test-project',\n },\n {\n basePath: '/',\n dataset: 'staging',\n name: 'test-staging',\n projectId: 'test-project',\n },\n]\n\ndescribe('#getWorkspace', () => {\n test('returns a default workspace if only one exists', () => {\n const workspace = getWorkspace(mockWorkspaces.slice(0, 1))\n expect(workspace).toMatchObject(mockWorkspaces[0])\n })\n\n test('returns a workspace by name if multiple exist', () => {\n const workspace = getWorkspace(mockWorkspaces, 'test-staging')\n expect(workspace).toMatchObject(mockWorkspaces[1])\n })\n\n test('throws an error if no workspaces exist', () => {\n expect(() => getWorkspace([])).toThrowError('No workspaces found')\n })\n\n test('throws an error if multiple workspaces exist but no name is specified', () => {\n expect(() => getWorkspace(mockWorkspaces)).toThrowError(\n `Multiple workspaces found. Please specify which workspace to use with \"--workspace\". Available workspaces: test, test-staging`,\n )\n })\n\n test('throws an error if workspace with specified name does not exist', () => {\n expect(() => getWorkspace(mockWorkspaces, 'test-dev')).toThrowError(\n `Could not find \"test-dev\" workspace. Available workspaces: test, test-staging`,\n )\n })\n})\n"],"names":["describe","expect","test","getWorkspace","mockWorkspaces","basePath","dataset","name","projectId","workspace","slice","toMatchObject","toThrowError"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,YAAY,QAAO,kBAAiB;AAE5C,MAAMC,iBAAiB;IACrB;QACEC,UAAU;QACVC,SAAS;QACTC,MAAM;QACNC,WAAW;IACb;IACA;QACEH,UAAU;QACVC,SAAS;QACTC,MAAM;QACNC,WAAW;IACb;CACD;AAEDR,SAAS,iBAAiB;IACxBE,KAAK,kDAAkD;QACrD,MAAMO,YAAYN,aAAaC,eAAeM,KAAK,CAAC,GAAG;QACvDT,OAAOQ,WAAWE,aAAa,CAACP,cAAc,CAAC,EAAE;IACnD;IAEAF,KAAK,iDAAiD;QACpD,MAAMO,YAAYN,aAAaC,gBAAgB;QAC/CH,OAAOQ,WAAWE,aAAa,CAACP,cAAc,CAAC,EAAE;IACnD;IAEAF,KAAK,0CAA0C;QAC7CD,OAAO,IAAME,aAAa,EAAE,GAAGS,YAAY,CAAC;IAC9C;IAEAV,KAAK,yEAAyE;QAC5ED,OAAO,IAAME,aAAaC,iBAAiBQ,YAAY,CACrD,CAAC,6HAA6H,CAAC;IAEnI;IAEAV,KAAK,mEAAmE;QACtED,OAAO,IAAME,aAAaC,gBAAgB,aAAaQ,YAAY,CACjE,CAAC,6EAA6E,CAAC;IAEnF;AACF"}
@@ -1,69 +0,0 @@
1
- // Import the mocked module
2
- import { readFile } from 'node:fs/promises';
3
- import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
4
- import { readPackageJson } from '../readPackageJson';
5
- // Mock the node:fs/promises module
6
- vi.mock('node:fs/promises', ()=>({
7
- readFile: vi.fn()
8
- }));
9
- describe('readPackageJson', ()=>{
10
- const mockFilePath = '/mock/path/package.json';
11
- beforeEach(()=>{
12
- vi.resetAllMocks();
13
- });
14
- afterEach(()=>{
15
- vi.clearAllMocks();
16
- });
17
- test('returns parsed package.json content when file is valid', async ()=>{
18
- const mockPackage = {
19
- dependencies: {
20
- 'some-dep': '^1.0.0'
21
- },
22
- devDependencies: {
23
- 'some-dev-dep': '^2.0.0'
24
- },
25
- name: '@sanity/test-package',
26
- version: '1.0.0'
27
- };
28
- vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(mockPackage));
29
- const result = await readPackageJson(mockFilePath);
30
- expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
31
- expect(result).toEqual(mockPackage);
32
- });
33
- test('throws error when file cannot be read', async ()=>{
34
- const mockError = new Error('File not found');
35
- vi.mocked(readFile).mockRejectedValueOnce(mockError);
36
- await expect(readPackageJson(mockFilePath)).rejects.toThrow('Failed to read');
37
- expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
38
- });
39
- test('throws error when JSON is invalid', async ()=>{
40
- vi.mocked(readFile).mockResolvedValueOnce('invalid json content');
41
- await expect(readPackageJson(mockFilePath)).rejects.toThrow();
42
- expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
43
- });
44
- test('throws error when required fields are missing', async ()=>{
45
- // Missing name field
46
- const invalidPackage = {
47
- version: '1.0.0'
48
- };
49
- vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(invalidPackage));
50
- await expect(readPackageJson(mockFilePath)).rejects.toThrow('Invalid package.json');
51
- expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
52
- });
53
- test('handles optional fields correctly', async ()=>{
54
- // Only required fields, no optional ones
55
- const minimalPackage = {
56
- name: '@sanity/minimal',
57
- version: '1.0.0'
58
- };
59
- vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(minimalPackage));
60
- const result = await readPackageJson(mockFilePath);
61
- expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
62
- expect(result).toEqual(minimalPackage);
63
- expect(result.dependencies).toBeUndefined();
64
- expect(result.devDependencies).toBeUndefined();
65
- expect(result.peerDependencies).toBeUndefined();
66
- });
67
- });
68
-
69
- //# sourceMappingURL=readPackageJson.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/util/__tests__/readPackageJson.test.ts"],"sourcesContent":["// Import the mocked module\nimport {readFile} from 'node:fs/promises'\n\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {readPackageJson} from '../readPackageJson'\n\n// Mock the node:fs/promises module\nvi.mock('node:fs/promises', () => ({\n readFile: vi.fn(),\n}))\n\ndescribe('readPackageJson', () => {\n const mockFilePath = '/mock/path/package.json'\n\n beforeEach(() => {\n vi.resetAllMocks()\n })\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('returns parsed package.json content when file is valid', async () => {\n const mockPackage = {\n dependencies: {\n 'some-dep': '^1.0.0',\n },\n devDependencies: {\n 'some-dev-dep': '^2.0.0',\n },\n name: '@sanity/test-package',\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(mockPackage))\n\n const result = await readPackageJson(mockFilePath)\n\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n expect(result).toEqual(mockPackage)\n })\n\n test('throws error when file cannot be read', async () => {\n const mockError = new Error('File not found')\n vi.mocked(readFile).mockRejectedValueOnce(mockError)\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow('Failed to read')\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('throws error when JSON is invalid', async () => {\n vi.mocked(readFile).mockResolvedValueOnce('invalid json content')\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow()\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('throws error when required fields are missing', async () => {\n // Missing name field\n const invalidPackage = {\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(invalidPackage))\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow('Invalid package.json')\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('handles optional fields correctly', async () => {\n // Only required fields, no optional ones\n const minimalPackage = {\n name: '@sanity/minimal',\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(minimalPackage))\n\n const result = await readPackageJson(mockFilePath)\n\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n expect(result).toEqual(minimalPackage)\n expect(result.dependencies).toBeUndefined()\n expect(result.devDependencies).toBeUndefined()\n expect(result.peerDependencies).toBeUndefined()\n })\n})\n"],"names":["readFile","afterEach","beforeEach","describe","expect","test","vi","readPackageJson","mock","fn","mockFilePath","resetAllMocks","clearAllMocks","mockPackage","dependencies","devDependencies","name","version","mocked","mockResolvedValueOnce","JSON","stringify","result","toHaveBeenCalledWith","toEqual","mockError","Error","mockRejectedValueOnce","rejects","toThrow","invalidPackage","minimalPackage","toBeUndefined","peerDependencies"],"mappings":"AAAA,2BAA2B;AAC3B,SAAQA,QAAQ,QAAO,mBAAkB;AAEzC,SAAQC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAExE,SAAQC,eAAe,QAAO,qBAAoB;AAElD,mCAAmC;AACnCD,GAAGE,IAAI,CAAC,oBAAoB,IAAO,CAAA;QACjCR,UAAUM,GAAGG,EAAE;IACjB,CAAA;AAEAN,SAAS,mBAAmB;IAC1B,MAAMO,eAAe;IAErBR,WAAW;QACTI,GAAGK,aAAa;IAClB;IAEAV,UAAU;QACRK,GAAGM,aAAa;IAClB;IAEAP,KAAK,0DAA0D;QAC7D,MAAMQ,cAAc;YAClBC,cAAc;gBACZ,YAAY;YACd;YACAC,iBAAiB;gBACf,gBAAgB;YAClB;YACAC,MAAM;YACNC,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACR;QAEzD,MAAMS,SAAS,MAAMf,gBAAgBG;QAErCN,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;QACpDN,OAAOkB,QAAQE,OAAO,CAACX;IACzB;IAEAR,KAAK,yCAAyC;QAC5C,MAAMoB,YAAY,IAAIC,MAAM;QAC5BpB,GAAGY,MAAM,CAAClB,UAAU2B,qBAAqB,CAACF;QAE1C,MAAMrB,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO,CAAC;QAC5DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,qCAAqC;QACxCC,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAAC;QAE1C,MAAMf,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO;QAC3DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,iDAAiD;QACpD,qBAAqB;QACrB,MAAMyB,iBAAiB;YACrBb,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACS;QAEzD,MAAM1B,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO,CAAC;QAC5DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,qCAAqC;QACxC,yCAAyC;QACzC,MAAM0B,iBAAiB;YACrBf,MAAM;YACNC,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACU;QAEzD,MAAMT,SAAS,MAAMf,gBAAgBG;QAErCN,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;QACpDN,OAAOkB,QAAQE,OAAO,CAACO;QACvB3B,OAAOkB,OAAOR,YAAY,EAAEkB,aAAa;QACzC5B,OAAOkB,OAAOP,eAAe,EAAEiB,aAAa;QAC5C5B,OAAOkB,OAAOW,gBAAgB,EAAED,aAAa;IAC/C;AACF"}
@@ -1,28 +0,0 @@
1
- import { describe, expect, test, vi } from 'vitest';
2
- import { warnAboutMissingAppId } from '../warnAboutMissingAppId';
3
- describe('warnAboutMissingAppId', ()=>{
4
- const mockOutput = {
5
- error: vi.fn(),
6
- log: vi.fn(),
7
- warn: vi.fn()
8
- };
9
- test('should log the expected warning when called', ()=>{
10
- warnAboutMissingAppId({
11
- appType: 'studio',
12
- output: mockOutput,
13
- projectId: 'project-id'
14
- });
15
- expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'));
16
- expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage/project/project-id/studios'));
17
- });
18
- test('should be resilient to missing project IDs', ()=>{
19
- warnAboutMissingAppId({
20
- appType: 'app',
21
- output: mockOutput
22
- });
23
- expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'));
24
- expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage'));
25
- });
26
- });
27
-
28
- //# sourceMappingURL=warnAboutMissingAppId.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/util/__tests__/warnAboutMissingAppId.test.ts"],"sourcesContent":["import {Output} from '@sanity/cli-core'\nimport {describe, expect, test, vi} from 'vitest'\n\nimport {warnAboutMissingAppId} from '../warnAboutMissingAppId'\n\ndescribe('warnAboutMissingAppId', () => {\n const mockOutput = {\n error: vi.fn(),\n log: vi.fn(),\n warn: vi.fn(),\n } as unknown as Output\n\n test('should log the expected warning when called', () => {\n warnAboutMissingAppId({\n appType: 'studio',\n output: mockOutput,\n projectId: 'project-id',\n })\n\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'))\n expect(mockOutput.warn).toBeCalledWith(\n expect.stringContaining('https://www.sanity.io/manage/project/project-id/studios'),\n )\n })\n\n test('should be resilient to missing project IDs', () => {\n warnAboutMissingAppId({\n appType: 'app',\n output: mockOutput,\n })\n\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'))\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage'))\n })\n})\n"],"names":["describe","expect","test","vi","warnAboutMissingAppId","mockOutput","error","fn","log","warn","appType","output","projectId","toBeCalledWith","stringContaining"],"mappings":"AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAEjD,SAAQC,qBAAqB,QAAO,2BAA0B;AAE9DJ,SAAS,yBAAyB;IAChC,MAAMK,aAAa;QACjBC,OAAOH,GAAGI,EAAE;QACZC,KAAKL,GAAGI,EAAE;QACVE,MAAMN,GAAGI,EAAE;IACb;IAEAL,KAAK,+CAA+C;QAClDE,sBAAsB;YACpBM,SAAS;YACTC,QAAQN;YACRO,WAAW;QACb;QAEAX,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;QAC/Db,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CACpCZ,OAAOa,gBAAgB,CAAC;IAE5B;IAEAZ,KAAK,8CAA8C;QACjDE,sBAAsB;YACpBM,SAAS;YACTC,QAAQN;QACV;QAEAJ,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;QAC/Db,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;IACjE;AACF"}
@@ -1,388 +0,0 @@
1
- import { spinner } from '@sanity/cli-core/ux';
2
- import { execa } from 'execa';
3
- import { beforeEach, describe, expect, test, vi } from 'vitest';
4
- import { installDeclaredPackages, installNewPackages } from '../installPackages.js';
5
- import { getPartialEnvWithNpmPath } from '../packageManagerChoice.js';
6
- // Mock external dependencies
7
- vi.mock('execa', ()=>({
8
- execa: vi.fn()
9
- }));
10
- vi.mock('../packageManagerChoice.js', ()=>({
11
- getPartialEnvWithNpmPath: vi.fn()
12
- }));
13
- vi.mock('@sanity/cli-core/ux', async ()=>{
14
- const actual = await vi.importActual('@sanity/cli-core/ux');
15
- return {
16
- ...actual,
17
- spinner: vi.fn(()=>({
18
- fail: vi.fn().mockReturnThis(),
19
- start: vi.fn().mockReturnThis(),
20
- succeed: vi.fn().mockReturnThis()
21
- }))
22
- };
23
- });
24
- const mockExeca = vi.mocked(execa);
25
- const mockSpinner = vi.mocked(spinner);
26
- const mockGetPartialEnvWithNpmPath = vi.mocked(getPartialEnvWithNpmPath);
27
- const mockOutput = {
28
- error: vi.fn(),
29
- log: vi.fn(),
30
- warn: vi.fn()
31
- };
32
- const mockSpinnerInstance = {
33
- fail: vi.fn().mockReturnThis(),
34
- start: vi.fn().mockReturnThis(),
35
- succeed: vi.fn().mockReturnThis()
36
- };
37
- beforeEach(()=>{
38
- vi.clearAllMocks();
39
- mockGetPartialEnvWithNpmPath.mockReturnValue({
40
- PATH: '/mock/path'
41
- });
42
- mockSpinner.mockReturnValue(mockSpinnerInstance);
43
- });
44
- describe('installDeclaredPackages', ()=>{
45
- const workDir = '/test/project';
46
- const context = {
47
- output: mockOutput,
48
- workDir
49
- };
50
- test('installs with npm successfully', async ()=>{
51
- const mockResult = {
52
- exitCode: 0,
53
- failed: false,
54
- stdout: 'Installation successful'
55
- };
56
- mockExeca.mockResolvedValueOnce(mockResult);
57
- await installDeclaredPackages(workDir, 'npm', context);
58
- expect(execa).toHaveBeenCalledWith('npm', [
59
- 'install'
60
- ], {
61
- cwd: workDir,
62
- encoding: 'utf8',
63
- env: {
64
- PATH: '/mock/path'
65
- },
66
- stdio: 'pipe'
67
- });
68
- expect(mockSpinnerInstance.start).toHaveBeenCalled();
69
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
70
- expect(mockSpinnerInstance.fail).not.toHaveBeenCalled();
71
- });
72
- test('installs with yarn successfully', async ()=>{
73
- const mockResult = {
74
- exitCode: 0,
75
- failed: false,
76
- stdout: 'Installation successful'
77
- };
78
- mockExeca.mockResolvedValueOnce(mockResult);
79
- await installDeclaredPackages(workDir, 'yarn', context);
80
- expect(execa).toHaveBeenCalledWith('yarn', [
81
- 'install'
82
- ], {
83
- cwd: workDir,
84
- encoding: 'utf8',
85
- env: {
86
- PATH: '/mock/path'
87
- },
88
- stdio: 'pipe'
89
- });
90
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
91
- });
92
- test('installs with pnpm successfully', async ()=>{
93
- const mockResult = {
94
- exitCode: 0,
95
- failed: false,
96
- stdout: 'Installation successful'
97
- };
98
- mockExeca.mockResolvedValueOnce(mockResult);
99
- await installDeclaredPackages(workDir, 'pnpm', context);
100
- expect(execa).toHaveBeenCalledWith('pnpm', [
101
- 'install'
102
- ], {
103
- cwd: workDir,
104
- encoding: 'utf8',
105
- env: {
106
- PATH: '/mock/path'
107
- },
108
- stdio: 'pipe'
109
- });
110
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
111
- });
112
- test('installs with bun successfully', async ()=>{
113
- const mockResult = {
114
- exitCode: 0,
115
- failed: false,
116
- stdout: 'Installation successful'
117
- };
118
- mockExeca.mockResolvedValueOnce(mockResult);
119
- await installDeclaredPackages(workDir, 'bun', context);
120
- expect(execa).toHaveBeenCalledWith('bun', [
121
- 'install'
122
- ], {
123
- cwd: workDir,
124
- encoding: 'utf8',
125
- env: {
126
- PATH: '/mock/path'
127
- },
128
- stdio: 'pipe'
129
- });
130
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
131
- });
132
- test('handles manual package manager', async ()=>{
133
- await installDeclaredPackages(workDir, 'manual', context);
134
- expect(execa).not.toHaveBeenCalled();
135
- expect(mockOutput.log).toHaveBeenCalledWith("Manual installation selected — run 'npm install' or equivalent");
136
- });
137
- test('handles installation failure with exit code', async ()=>{
138
- const mockResult = {
139
- exitCode: 1,
140
- failed: true,
141
- stdout: 'Error: Package not found'
142
- };
143
- mockExeca.mockResolvedValueOnce(mockResult);
144
- await expect(installDeclaredPackages(workDir, 'npm', context));
145
- expect(mockSpinnerInstance.fail).toHaveBeenCalled();
146
- expect(mockOutput.log).toHaveBeenCalledWith('Error: Package not found');
147
- expect(mockOutput.error).toHaveBeenCalledWith('Dependency installation failed', {
148
- exit: 1
149
- });
150
- });
151
- test('handles installation failure with failed flag', async ()=>{
152
- const mockResult = {
153
- exitCode: 0,
154
- failed: true,
155
- stdout: 'Command failed'
156
- };
157
- mockExeca.mockResolvedValueOnce(mockResult);
158
- await expect(installDeclaredPackages(workDir, 'npm', context));
159
- expect(mockSpinnerInstance.fail).toHaveBeenCalled();
160
- expect(mockOutput.log).toHaveBeenCalledWith('Command failed');
161
- expect(mockOutput.error).toHaveBeenCalledWith('Dependency installation failed', {
162
- exit: 1
163
- });
164
- });
165
- });
166
- describe('installNewPackages', ()=>{
167
- const workDir = '/test/project';
168
- const context = {
169
- output: mockOutput,
170
- workDir
171
- };
172
- test('installs single package with npm successfully', async ()=>{
173
- const options = {
174
- packageManager: 'npm',
175
- packages: [
176
- '@sanity/vision'
177
- ]
178
- };
179
- const mockResult = {
180
- exitCode: 0,
181
- failed: false,
182
- stdout: 'Installation successful'
183
- };
184
- mockExeca.mockResolvedValueOnce(mockResult);
185
- await installNewPackages(options, context);
186
- expect(execa).toHaveBeenCalledWith('npm', [
187
- 'install',
188
- '--save',
189
- '@sanity/vision'
190
- ], {
191
- cwd: workDir,
192
- encoding: 'utf8',
193
- env: {
194
- PATH: '/mock/path'
195
- },
196
- stdio: 'pipe'
197
- });
198
- expect(mockSpinnerInstance.start).toHaveBeenCalled();
199
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
200
- });
201
- test('installs multiple packages with yarn successfully', async ()=>{
202
- const options = {
203
- packageManager: 'yarn',
204
- packages: [
205
- '@sanity/vision',
206
- 'react-icons'
207
- ]
208
- };
209
- const mockResult = {
210
- exitCode: 0,
211
- failed: false,
212
- stdout: 'Installation successful'
213
- };
214
- mockExeca.mockResolvedValueOnce(mockResult);
215
- await installNewPackages(options, context);
216
- expect(execa).toHaveBeenCalledWith('yarn', [
217
- 'add',
218
- '@sanity/vision',
219
- 'react-icons'
220
- ], {
221
- cwd: workDir,
222
- encoding: 'utf8',
223
- env: {
224
- PATH: '/mock/path'
225
- },
226
- stdio: 'pipe'
227
- });
228
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
229
- });
230
- test('installs packages with pnpm successfully', async ()=>{
231
- const options = {
232
- packageManager: 'pnpm',
233
- packages: [
234
- 'lodash'
235
- ]
236
- };
237
- const mockResult = {
238
- exitCode: 0,
239
- failed: false,
240
- stdout: 'Installation successful'
241
- };
242
- mockExeca.mockResolvedValueOnce(mockResult);
243
- await installNewPackages(options, context);
244
- expect(execa).toHaveBeenCalledWith('pnpm', [
245
- 'add',
246
- '--save-prod',
247
- 'lodash'
248
- ], {
249
- cwd: workDir,
250
- encoding: 'utf8',
251
- env: {
252
- PATH: '/mock/path'
253
- },
254
- stdio: 'pipe'
255
- });
256
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
257
- });
258
- test('installs packages with bun successfully', async ()=>{
259
- const options = {
260
- packageManager: 'bun',
261
- packages: [
262
- 'express'
263
- ]
264
- };
265
- const mockResult = {
266
- exitCode: 0,
267
- failed: false,
268
- stdout: 'Installation successful'
269
- };
270
- mockExeca.mockResolvedValueOnce(mockResult);
271
- await installNewPackages(options, context);
272
- expect(execa).toHaveBeenCalledWith('bun', [
273
- 'add',
274
- 'express'
275
- ], {
276
- cwd: workDir,
277
- encoding: 'utf8',
278
- env: {
279
- PATH: '/mock/path'
280
- },
281
- stdio: 'pipe'
282
- });
283
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
284
- });
285
- test('handles manual package manager for new packages', async ()=>{
286
- const options = {
287
- packageManager: 'manual',
288
- packages: [
289
- 'some-package'
290
- ]
291
- };
292
- await installNewPackages(options, context);
293
- expect(execa).not.toHaveBeenCalled();
294
- expect(mockOutput.log).toHaveBeenCalledWith("Manual installation selected - run 'npm install --save some-package' or equivalent");
295
- });
296
- test('handles installation failure with error output', async ()=>{
297
- const options = {
298
- packageManager: 'npm',
299
- packages: [
300
- 'nonexistent-package'
301
- ]
302
- };
303
- const mockResult = {
304
- exitCode: 1,
305
- failed: true,
306
- stdout: 'Error: Package not found'
307
- };
308
- mockExeca.mockResolvedValueOnce(mockResult);
309
- await expect(installNewPackages(options, context));
310
- expect(mockSpinnerInstance.fail).toHaveBeenCalled();
311
- expect(mockOutput.log).toHaveBeenCalledWith('Error: Package not found');
312
- expect(mockOutput.error).toHaveBeenCalledWith('Package installation failed', {
313
- exit: 1
314
- });
315
- });
316
- test('handles installation failure with failed flag', async ()=>{
317
- const options = {
318
- packageManager: 'pnpm',
319
- packages: [
320
- 'failing-package'
321
- ]
322
- };
323
- const mockResult = {
324
- exitCode: 0,
325
- failed: true,
326
- stdout: 'Command execution failed'
327
- };
328
- mockExeca.mockResolvedValueOnce(mockResult);
329
- await expect(installNewPackages(options, context));
330
- expect(mockSpinnerInstance.fail).toHaveBeenCalled();
331
- expect(mockOutput.log).toHaveBeenCalledWith('Command execution failed');
332
- expect(mockOutput.error).toHaveBeenCalledWith('Package installation failed', {
333
- exit: 1
334
- });
335
- });
336
- test('handles empty packages array', async ()=>{
337
- const options = {
338
- packageManager: 'npm',
339
- packages: []
340
- };
341
- const mockResult = {
342
- exitCode: 0,
343
- failed: false,
344
- stdout: 'Nothing to install'
345
- };
346
- mockExeca.mockResolvedValueOnce(mockResult);
347
- await installNewPackages(options, context);
348
- expect(execa).toHaveBeenCalledWith('npm', [
349
- 'install',
350
- '--save'
351
- ], {
352
- cwd: workDir,
353
- encoding: 'utf8',
354
- env: {
355
- PATH: '/mock/path'
356
- },
357
- stdio: 'pipe'
358
- });
359
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
360
- });
361
- });
362
- describe('error handling edge cases', ()=>{
363
- const workDir = '/test/project';
364
- const context = {
365
- output: mockOutput,
366
- workDir
367
- };
368
- test('handles undefined result in installDeclaredPackages', async ()=>{
369
- mockExeca.mockResolvedValueOnce(undefined);
370
- await installDeclaredPackages(workDir, 'npm', context);
371
- // Should not throw if result is undefined and no error conditions
372
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
373
- });
374
- test('handles undefined result in installNewPackages', async ()=>{
375
- const options = {
376
- packageManager: 'npm',
377
- packages: [
378
- 'test'
379
- ]
380
- };
381
- mockExeca.mockResolvedValueOnce(undefined);
382
- await installNewPackages(options, context);
383
- // Should not throw if result is undefined and no error conditions
384
- expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
385
- });
386
- });
387
-
388
- //# sourceMappingURL=installPackages.test.js.map