@sanity/cli 6.0.0-alpha.5 → 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 (461) 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/init/remoteTemplate.js +1 -1
  14. package/dist/actions/init/remoteTemplate.js.map +1 -1
  15. package/dist/actions/manifest/extractAppManifest.d.ts +20 -0
  16. package/dist/actions/manifest/extractAppManifest.js +51 -0
  17. package/dist/actions/manifest/extractAppManifest.js.map +1 -0
  18. package/dist/actions/manifest/extractManifest.js +1 -1
  19. package/dist/actions/manifest/extractManifest.js.map +1 -1
  20. package/dist/actions/manifest/types.d.ts +6 -1
  21. package/dist/actions/manifest/types.js.map +1 -1
  22. package/dist/actions/media/importAspects.js +2 -1
  23. package/dist/actions/media/importAspects.js.map +1 -1
  24. package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +1 -1
  25. package/dist/commands/dataset/create.d.ts +0 -2
  26. package/dist/commands/dataset/create.js +8 -54
  27. package/dist/commands/dataset/create.js.map +1 -1
  28. package/dist/commands/debug.js +5 -9
  29. package/dist/commands/debug.js.map +1 -1
  30. package/dist/commands/init.d.ts +6 -1
  31. package/dist/commands/init.js +358 -20
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/manifest/extract.js +7 -8
  34. package/dist/commands/manifest/extract.js.map +1 -1
  35. package/dist/config/createCliConfig.d.ts +9 -0
  36. package/dist/prompts/init/promptForTypescript.d.ts +2 -0
  37. package/dist/prompts/init/promptForTypescript.js +15 -0
  38. package/dist/prompts/init/promptForTypescript.js.map +1 -0
  39. package/dist/prompts/promptForDatasetAclMode.d.ts +9 -0
  40. package/dist/prompts/promptForDatasetAclMode.js +27 -0
  41. package/dist/prompts/promptForDatasetAclMode.js.map +1 -0
  42. package/dist/prompts/promptForDatasetName.d.ts +1 -1
  43. package/dist/prompts/promptForDatasetName.js +4 -1
  44. package/dist/prompts/promptForDatasetName.js.map +1 -1
  45. package/dist/services/organizations.d.ts +3 -1
  46. package/dist/services/organizations.js +2 -1
  47. package/dist/services/organizations.js.map +1 -1
  48. package/dist/services/user.d.ts +5 -0
  49. package/dist/services/user.js +12 -1
  50. package/dist/services/user.js.map +1 -1
  51. package/dist/services/userApplications.d.ts +3 -1
  52. package/dist/services/userApplications.js +5 -1
  53. package/dist/services/userApplications.js.map +1 -1
  54. package/oclif.manifest.json +113 -113
  55. package/package.json +16 -12
  56. package/templates/app-quickstart/src/App.css +20 -0
  57. package/templates/app-quickstart/src/App.tsx +25 -0
  58. package/templates/app-quickstart/src/ExampleComponent.css +90 -0
  59. package/templates/app-quickstart/src/ExampleComponent.tsx +37 -0
  60. package/templates/app-sanity-ui/src/App.tsx +34 -0
  61. package/templates/app-sanity-ui/src/ExampleComponent.tsx +34 -0
  62. package/templates/app-sanity-ui/src/SanityUI.tsx +23 -0
  63. package/templates/blog/README.md +11 -0
  64. package/templates/blog/schemaTypes/author.js +50 -0
  65. package/templates/blog/schemaTypes/blockContent.js +67 -0
  66. package/templates/blog/schemaTypes/category.js +19 -0
  67. package/templates/blog/schemaTypes/index.js +6 -0
  68. package/templates/blog/schemaTypes/post.js +65 -0
  69. package/templates/blog/static/.gitkeep +1 -0
  70. package/templates/clean/README.md +9 -0
  71. package/templates/clean/schemaTypes/index.js +1 -0
  72. package/templates/clean/static/.gitkeep +1 -0
  73. package/templates/ecommerce/README.md +11 -0
  74. package/templates/ecommerce/plugins/.gitkeep +1 -0
  75. package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +62 -0
  76. package/templates/ecommerce/plugins/barcode-input/index.js +9 -0
  77. package/templates/ecommerce/plugins/barcode-input/schemaType.js +60 -0
  78. package/templates/ecommerce/schemaTypes/blockContent.js +67 -0
  79. package/templates/ecommerce/schemaTypes/category.js +39 -0
  80. package/templates/ecommerce/schemaTypes/index.js +23 -0
  81. package/templates/ecommerce/schemaTypes/locale/localeBlockContent.js +19 -0
  82. package/templates/ecommerce/schemaTypes/locale/localeString.js +19 -0
  83. package/templates/ecommerce/schemaTypes/locale/localeText.js +19 -0
  84. package/templates/ecommerce/schemaTypes/locale/supportedLanguages.js +5 -0
  85. package/templates/ecommerce/schemaTypes/product.js +83 -0
  86. package/templates/ecommerce/schemaTypes/productVariant.js +52 -0
  87. package/templates/ecommerce/schemaTypes/vendor.js +39 -0
  88. package/templates/ecommerce/static/.gitkeep +1 -0
  89. package/templates/get-started/README.md +9 -0
  90. package/templates/get-started/plugins/.gitkeep +1 -0
  91. package/templates/get-started/plugins/sanity-plugin-tutorial/CustomDefaultLayout.tsx +16 -0
  92. package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +104 -0
  93. package/templates/get-started/plugins/sanity-plugin-tutorial/index.ts +11 -0
  94. package/templates/get-started/schemaTypes/index.ts +1 -0
  95. package/templates/get-started/static/.gitkeep +1 -0
  96. package/templates/moviedb/README.md +10 -0
  97. package/templates/moviedb/schemaTypes/blockContent.js +67 -0
  98. package/templates/moviedb/schemaTypes/castMember.js +37 -0
  99. package/templates/moviedb/schemaTypes/crewMember.js +52 -0
  100. package/templates/moviedb/schemaTypes/index.js +22 -0
  101. package/templates/moviedb/schemaTypes/movie.js +85 -0
  102. package/templates/moviedb/schemaTypes/person.js +37 -0
  103. package/templates/moviedb/schemaTypes/plotSummaries.js +20 -0
  104. package/templates/moviedb/schemaTypes/plotSummary.js +24 -0
  105. package/templates/moviedb/schemaTypes/screening.js +81 -0
  106. package/templates/moviedb/static/.gitkeep +1 -0
  107. package/templates/quickstart/README.md +9 -0
  108. package/templates/quickstart/schemaTypes/index.js +1 -0
  109. package/templates/quickstart/static/.gitkeep +1 -0
  110. package/templates/shared/gitignore.txt +29 -0
  111. package/templates/shared/tsconfig.json +17 -0
  112. package/templates/shopify/README.md +85 -0
  113. package/templates/shopify/components/hotspots/ProductTooltip.tsx +38 -0
  114. package/templates/shopify/components/icons/Shopify.tsx +20 -0
  115. package/templates/shopify/components/inputs/CollectionHidden.tsx +23 -0
  116. package/templates/shopify/components/inputs/PlaceholderString.tsx +20 -0
  117. package/templates/shopify/components/inputs/ProductHidden.tsx +64 -0
  118. package/templates/shopify/components/inputs/ProductVariantHidden.tsx +24 -0
  119. package/templates/shopify/components/inputs/ProxyString.tsx +32 -0
  120. package/templates/shopify/components/media/ColorTheme.tsx +38 -0
  121. package/templates/shopify/components/media/ShopifyDocumentStatus.tsx +82 -0
  122. package/templates/shopify/components/studio/Navbar.tsx +29 -0
  123. package/templates/shopify/constants.ts +61 -0
  124. package/templates/shopify/docs/features.md +158 -0
  125. package/templates/shopify/plugins/customDocumentActions/index.ts +55 -0
  126. package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +144 -0
  127. package/templates/shopify/plugins/customDocumentActions/shopifyLink.ts +39 -0
  128. package/templates/shopify/plugins/customDocumentActions/types.ts +14 -0
  129. package/templates/shopify/schemaTypes/documents/collection.tsx +142 -0
  130. package/templates/shopify/schemaTypes/documents/colorTheme.tsx +44 -0
  131. package/templates/shopify/schemaTypes/documents/page.ts +70 -0
  132. package/templates/shopify/schemaTypes/documents/product.tsx +132 -0
  133. package/templates/shopify/schemaTypes/documents/productVariant.tsx +67 -0
  134. package/templates/shopify/schemaTypes/index.ts +108 -0
  135. package/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts +27 -0
  136. package/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts +16 -0
  137. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx +48 -0
  138. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx +50 -0
  139. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts +40 -0
  140. package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts +49 -0
  141. package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
  142. package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
  143. package/templates/shopify/schemaTypes/objects/global/menuType.ts +17 -0
  144. package/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts +37 -0
  145. package/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts +48 -0
  146. package/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx +17 -0
  147. package/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx +60 -0
  148. package/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx +34 -0
  149. package/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx +37 -0
  150. package/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx +33 -0
  151. package/templates/shopify/schemaTypes/objects/link/linkProductType.tsx +60 -0
  152. package/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts +33 -0
  153. package/templates/shopify/schemaTypes/objects/module/accordionType.ts +28 -0
  154. package/templates/shopify/schemaTypes/objects/module/callToActionType.tsx +85 -0
  155. package/templates/shopify/schemaTypes/objects/module/calloutType.ts +38 -0
  156. package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +47 -0
  157. package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
  158. package/templates/shopify/schemaTypes/objects/module/gridType.ts +28 -0
  159. package/templates/shopify/schemaTypes/objects/module/heroType.tsx +40 -0
  160. package/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx +19 -0
  161. package/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts +80 -0
  162. package/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx +51 -0
  163. package/templates/shopify/schemaTypes/objects/module/instagramType.ts +35 -0
  164. package/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx +50 -0
  165. package/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx +42 -0
  166. package/templates/shopify/schemaTypes/objects/seoType.ts +31 -0
  167. package/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx +37 -0
  168. package/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts +25 -0
  169. package/templates/shopify/schemaTypes/objects/shopify/optionType.tsx +31 -0
  170. package/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts +11 -0
  171. package/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts +20 -0
  172. package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +142 -0
  173. package/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts +12 -0
  174. package/templates/shopify/schemaTypes/objects/shopify/shopType.ts +15 -0
  175. package/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts +84 -0
  176. package/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts +131 -0
  177. package/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts +121 -0
  178. package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
  179. package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
  180. package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
  181. package/templates/shopify/schemaTypes/singletons/settingsType.ts +96 -0
  182. package/templates/shopify/static/.gitkeep +1 -0
  183. package/templates/shopify/structure/collectionStructure.ts +9 -0
  184. package/templates/shopify/structure/colorThemeStructure.ts +9 -0
  185. package/templates/shopify/structure/homeStructure.ts +9 -0
  186. package/templates/shopify/structure/index.ts +57 -0
  187. package/templates/shopify/structure/pageStructure.ts +11 -0
  188. package/templates/shopify/structure/productStructure.ts +51 -0
  189. package/templates/shopify/structure/settingStructure.ts +9 -0
  190. package/templates/shopify/utils/blocksToText.ts +20 -0
  191. package/templates/shopify/utils/defineStructure.ts +11 -0
  192. package/templates/shopify/utils/getPriceRange.ts +24 -0
  193. package/templates/shopify/utils/shopifyUrls.ts +22 -0
  194. package/templates/shopify/utils/validateSlug.ts +18 -0
  195. package/templates/shopify-online-storefront/README.md +54 -0
  196. package/templates/shopify-online-storefront/components/icons/Shopify.tsx +22 -0
  197. package/templates/shopify-online-storefront/components/inputs/CollectionHidden.tsx +23 -0
  198. package/templates/shopify-online-storefront/components/inputs/PlaceholderString.tsx +25 -0
  199. package/templates/shopify-online-storefront/components/inputs/ProductHidden.tsx +66 -0
  200. package/templates/shopify-online-storefront/components/inputs/ProductVariantHidden.tsx +25 -0
  201. package/templates/shopify-online-storefront/components/inputs/ProxyString.tsx +38 -0
  202. package/templates/shopify-online-storefront/components/media/ShopifyDocumentStatus.tsx +83 -0
  203. package/templates/shopify-online-storefront/constants.ts +18 -0
  204. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/index.ts +45 -0
  205. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +144 -0
  206. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyLink.ts +39 -0
  207. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/types.ts +14 -0
  208. package/templates/shopify-online-storefront/schemaTypes/blocks/blockContent.ts +32 -0
  209. package/templates/shopify-online-storefront/schemaTypes/documents/collection.tsx +83 -0
  210. package/templates/shopify-online-storefront/schemaTypes/documents/product.tsx +102 -0
  211. package/templates/shopify-online-storefront/schemaTypes/documents/productVariant.tsx +82 -0
  212. package/templates/shopify-online-storefront/schemaTypes/index.ts +43 -0
  213. package/templates/shopify-online-storefront/schemaTypes/objects/accordion.ts +31 -0
  214. package/templates/shopify-online-storefront/schemaTypes/objects/accordionGroup.ts +35 -0
  215. package/templates/shopify-online-storefront/schemaTypes/objects/callout.ts +40 -0
  216. package/templates/shopify-online-storefront/schemaTypes/objects/inventory.ts +30 -0
  217. package/templates/shopify-online-storefront/schemaTypes/objects/option.ts +30 -0
  218. package/templates/shopify-online-storefront/schemaTypes/objects/priceRange.ts +22 -0
  219. package/templates/shopify-online-storefront/schemaTypes/objects/proxyString.ts +11 -0
  220. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollection.ts +109 -0
  221. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollectionRule.tsx +45 -0
  222. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProduct.ts +165 -0
  223. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProductVariant.ts +151 -0
  224. package/templates/shopify-online-storefront/structure/collectionStructure.ts +9 -0
  225. package/templates/shopify-online-storefront/structure/index.ts +37 -0
  226. package/templates/shopify-online-storefront/structure/productStructure.ts +35 -0
  227. package/templates/shopify-online-storefront/utils/defineStructure.ts +11 -0
  228. package/templates/shopify-online-storefront/utils/getPriceRange.ts +24 -0
  229. package/templates/shopify-online-storefront/utils/shopifyUrls.ts +22 -0
  230. package/dist/actions/build/__tests__/buildApp.test.js +0 -367
  231. package/dist/actions/build/__tests__/buildApp.test.js.map +0 -1
  232. package/dist/actions/build/__tests__/buildStudio.test.js +0 -561
  233. package/dist/actions/build/__tests__/buildStudio.test.js.map +0 -1
  234. package/dist/actions/build/__tests__/checkRequiredDependencies.test.js +0 -233
  235. package/dist/actions/build/__tests__/checkRequiredDependencies.test.js.map +0 -1
  236. package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js +0 -414
  237. package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js.map +0 -1
  238. package/dist/actions/build/__tests__/determineBasePath.test.js +0 -24
  239. package/dist/actions/build/__tests__/determineBasePath.test.js.map +0 -1
  240. package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js +0 -109
  241. package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js.map +0 -1
  242. package/dist/actions/build/__tests__/getViteConfig.test.js +0 -493
  243. package/dist/actions/build/__tests__/getViteConfig.test.js.map +0 -1
  244. package/dist/actions/build/__tests__/renderDocument.test.js +0 -278
  245. package/dist/actions/build/__tests__/renderDocument.test.js.map +0 -1
  246. package/dist/actions/build/__tests__/shouldAutoUpdate.test.js +0 -153
  247. package/dist/actions/build/__tests__/shouldAutoUpdate.test.js.map +0 -1
  248. package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js +0 -657
  249. package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js.map +0 -1
  250. package/dist/actions/dataset/__tests__/validateDatasetName.test.js +0 -182
  251. package/dist/actions/dataset/__tests__/validateDatasetName.test.js.map +0 -1
  252. package/dist/actions/deploy/__tests__/checkDir.test.js +0 -120
  253. package/dist/actions/deploy/__tests__/checkDir.test.js.map +0 -1
  254. package/dist/actions/docs/__tests__/normalizeDocsPath.test.js +0 -16
  255. package/dist/actions/docs/__tests__/normalizeDocsPath.test.js.map +0 -1
  256. package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js +0 -124
  257. package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js.map +0 -1
  258. package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +0 -274
  259. package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +0 -1
  260. package/dist/actions/media/__tests__/importMedia.test.js +0 -182
  261. package/dist/actions/media/__tests__/importMedia.test.js.map +0 -1
  262. package/dist/actions/schema/__tests__/formatSchemaValidation.test.js +0 -174
  263. package/dist/actions/schema/__tests__/formatSchemaValidation.test.js.map +0 -1
  264. package/dist/actions/schema/__tests__/validateAction.test.js +0 -281
  265. package/dist/actions/schema/__tests__/validateAction.test.js.map +0 -1
  266. package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js +0 -27
  267. package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js.map +0 -1
  268. package/dist/actions/users/__tests__/validateEmail.test.js +0 -16
  269. package/dist/actions/users/__tests__/validateEmail.test.js.map +0 -1
  270. package/dist/commands/__tests__/blueprints.test.js +0 -54
  271. package/dist/commands/__tests__/blueprints.test.js.map +0 -1
  272. package/dist/commands/__tests__/build.test.js +0 -132
  273. package/dist/commands/__tests__/build.test.js.map +0 -1
  274. package/dist/commands/__tests__/codemod.test.js +0 -271
  275. package/dist/commands/__tests__/codemod.test.js.map +0 -1
  276. package/dist/commands/__tests__/debug.test.js +0 -590
  277. package/dist/commands/__tests__/debug.test.js.map +0 -1
  278. package/dist/commands/__tests__/deploy.test.js +0 -1945
  279. package/dist/commands/__tests__/deploy.test.js.map +0 -1
  280. package/dist/commands/__tests__/dev.test.js +0 -453
  281. package/dist/commands/__tests__/dev.test.js.map +0 -1
  282. package/dist/commands/__tests__/exec.test.js +0 -207
  283. package/dist/commands/__tests__/exec.test.js.map +0 -1
  284. package/dist/commands/__tests__/init/init.authentication.test.js +0 -73
  285. package/dist/commands/__tests__/init/init.authentication.test.js.map +0 -1
  286. package/dist/commands/__tests__/init/init.create-new-project.test.js +0 -195
  287. package/dist/commands/__tests__/init/init.create-new-project.test.js.map +0 -1
  288. package/dist/commands/__tests__/init/init.plan.test.js +0 -279
  289. package/dist/commands/__tests__/init/init.plan.test.js.map +0 -1
  290. package/dist/commands/__tests__/init/init.setup.test.js +0 -335
  291. package/dist/commands/__tests__/init/init.setup.test.js.map +0 -1
  292. package/dist/commands/__tests__/install.test.js +0 -282
  293. package/dist/commands/__tests__/install.test.js.map +0 -1
  294. package/dist/commands/__tests__/learn.test.js +0 -29
  295. package/dist/commands/__tests__/learn.test.js.map +0 -1
  296. package/dist/commands/__tests__/logout.test.js +0 -91
  297. package/dist/commands/__tests__/logout.test.js.map +0 -1
  298. package/dist/commands/__tests__/manage.test.js +0 -110
  299. package/dist/commands/__tests__/manage.test.js.map +0 -1
  300. package/dist/commands/__tests__/migration.test.js +0 -119
  301. package/dist/commands/__tests__/migration.test.js.map +0 -1
  302. package/dist/commands/__tests__/preview.test.js +0 -261
  303. package/dist/commands/__tests__/preview.test.js.map +0 -1
  304. package/dist/commands/__tests__/start.test.js +0 -253
  305. package/dist/commands/__tests__/start.test.js.map +0 -1
  306. package/dist/commands/__tests__/undeploy.test.js +0 -382
  307. package/dist/commands/__tests__/undeploy.test.js.map +0 -1
  308. package/dist/commands/__tests__/versions.test.js +0 -142
  309. package/dist/commands/__tests__/versions.test.js.map +0 -1
  310. package/dist/commands/backup/__tests__/disable.test.js +0 -204
  311. package/dist/commands/backup/__tests__/disable.test.js.map +0 -1
  312. package/dist/commands/backup/__tests__/download.test.js +0 -768
  313. package/dist/commands/backup/__tests__/download.test.js.map +0 -1
  314. package/dist/commands/backup/__tests__/enable.test.js +0 -286
  315. package/dist/commands/backup/__tests__/enable.test.js.map +0 -1
  316. package/dist/commands/backup/__tests__/list.test.js +0 -330
  317. package/dist/commands/backup/__tests__/list.test.js.map +0 -1
  318. package/dist/commands/cors/__tests__/add.test.js +0 -376
  319. package/dist/commands/cors/__tests__/add.test.js.map +0 -1
  320. package/dist/commands/cors/__tests__/delete.test.js +0 -308
  321. package/dist/commands/cors/__tests__/delete.test.js.map +0 -1
  322. package/dist/commands/cors/__tests__/list.test.js +0 -241
  323. package/dist/commands/cors/__tests__/list.test.js.map +0 -1
  324. package/dist/commands/dataset/__tests__/copy.test.js +0 -628
  325. package/dist/commands/dataset/__tests__/copy.test.js.map +0 -1
  326. package/dist/commands/dataset/__tests__/create.test.js +0 -342
  327. package/dist/commands/dataset/__tests__/create.test.js.map +0 -1
  328. package/dist/commands/dataset/__tests__/delete.test.js +0 -231
  329. package/dist/commands/dataset/__tests__/delete.test.js.map +0 -1
  330. package/dist/commands/dataset/__tests__/export.test.js +0 -601
  331. package/dist/commands/dataset/__tests__/export.test.js.map +0 -1
  332. package/dist/commands/dataset/__tests__/import.test.js +0 -53
  333. package/dist/commands/dataset/__tests__/import.test.js.map +0 -1
  334. package/dist/commands/dataset/__tests__/list.test.js +0 -216
  335. package/dist/commands/dataset/__tests__/list.test.js.map +0 -1
  336. package/dist/commands/dataset/alias/__tests__/create.test.js +0 -339
  337. package/dist/commands/dataset/alias/__tests__/create.test.js.map +0 -1
  338. package/dist/commands/dataset/alias/__tests__/delete.test.js +0 -247
  339. package/dist/commands/dataset/alias/__tests__/delete.test.js.map +0 -1
  340. package/dist/commands/dataset/alias/__tests__/link.test.js +0 -376
  341. package/dist/commands/dataset/alias/__tests__/link.test.js.map +0 -1
  342. package/dist/commands/dataset/alias/__tests__/unlink.test.js +0 -313
  343. package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +0 -1
  344. package/dist/commands/dataset/visibility/__tests__/get.test.js +0 -128
  345. package/dist/commands/dataset/visibility/__tests__/get.test.js.map +0 -1
  346. package/dist/commands/dataset/visibility/__tests__/set.test.js +0 -198
  347. package/dist/commands/dataset/visibility/__tests__/set.test.js.map +0 -1
  348. package/dist/commands/docs/__tests__/browse.test.js +0 -29
  349. package/dist/commands/docs/__tests__/browse.test.js.map +0 -1
  350. package/dist/commands/docs/__tests__/read.test.js +0 -78
  351. package/dist/commands/docs/__tests__/read.test.js.map +0 -1
  352. package/dist/commands/docs/__tests__/search.test.js +0 -255
  353. package/dist/commands/docs/__tests__/search.test.js.map +0 -1
  354. package/dist/commands/documents/__tests__/create.test.js +0 -1030
  355. package/dist/commands/documents/__tests__/create.test.js.map +0 -1
  356. package/dist/commands/documents/__tests__/delete.test.js +0 -300
  357. package/dist/commands/documents/__tests__/delete.test.js.map +0 -1
  358. package/dist/commands/documents/__tests__/get.test.js +0 -182
  359. package/dist/commands/documents/__tests__/get.test.js.map +0 -1
  360. package/dist/commands/documents/__tests__/query.test.js +0 -300
  361. package/dist/commands/documents/__tests__/query.test.js.map +0 -1
  362. package/dist/commands/documents/__tests__/validate.test.js +0 -249
  363. package/dist/commands/documents/__tests__/validate.test.js.map +0 -1
  364. package/dist/commands/graphql/__tests__/list.test.js +0 -240
  365. package/dist/commands/graphql/__tests__/list.test.js.map +0 -1
  366. package/dist/commands/graphql/__tests__/undeploy.test.js +0 -410
  367. package/dist/commands/graphql/__tests__/undeploy.test.js.map +0 -1
  368. package/dist/commands/hook/__tests__/attempt.test.js +0 -275
  369. package/dist/commands/hook/__tests__/attempt.test.js.map +0 -1
  370. package/dist/commands/hook/__tests__/create.test.js +0 -119
  371. package/dist/commands/hook/__tests__/create.test.js.map +0 -1
  372. package/dist/commands/hook/__tests__/delete.test.js +0 -233
  373. package/dist/commands/hook/__tests__/delete.test.js.map +0 -1
  374. package/dist/commands/hook/__tests__/list.test.js +0 -145
  375. package/dist/commands/hook/__tests__/list.test.js.map +0 -1
  376. package/dist/commands/hook/__tests__/logs.test.js +0 -798
  377. package/dist/commands/hook/__tests__/logs.test.js.map +0 -1
  378. package/dist/commands/manifest/__tests__/extract.test.js +0 -132
  379. package/dist/commands/manifest/__tests__/extract.test.js.map +0 -1
  380. package/dist/commands/mcp/__tests__/configure.test.js +0 -397
  381. package/dist/commands/mcp/__tests__/configure.test.js.map +0 -1
  382. package/dist/commands/media/__tests__/create-aspect.test.js +0 -173
  383. package/dist/commands/media/__tests__/create-aspect.test.js.map +0 -1
  384. package/dist/commands/media/__tests__/delete-aspect.test.js +0 -342
  385. package/dist/commands/media/__tests__/delete-aspect.test.js.map +0 -1
  386. package/dist/commands/media/__tests__/deploy-aspect.test.js +0 -619
  387. package/dist/commands/media/__tests__/deploy-aspect.test.js.map +0 -1
  388. package/dist/commands/media/__tests__/export.test.js +0 -697
  389. package/dist/commands/media/__tests__/export.test.js.map +0 -1
  390. package/dist/commands/media/__tests__/import.test.js +0 -347
  391. package/dist/commands/media/__tests__/import.test.js.map +0 -1
  392. package/dist/commands/openapi/__tests__/get.test.js +0 -149
  393. package/dist/commands/openapi/__tests__/get.test.js.map +0 -1
  394. package/dist/commands/openapi/__tests__/list.test.js +0 -113
  395. package/dist/commands/openapi/__tests__/list.test.js.map +0 -1
  396. package/dist/commands/projects/__tests__/list.test.js +0 -154
  397. package/dist/commands/projects/__tests__/list.test.js.map +0 -1
  398. package/dist/commands/schema/__tests__/delete.test.js +0 -454
  399. package/dist/commands/schema/__tests__/delete.test.js.map +0 -1
  400. package/dist/commands/schema/__tests__/deploy.test.js +0 -348
  401. package/dist/commands/schema/__tests__/deploy.test.js.map +0 -1
  402. package/dist/commands/schema/__tests__/extract.test.js +0 -121
  403. package/dist/commands/schema/__tests__/extract.test.js.map +0 -1
  404. package/dist/commands/schema/__tests__/list.test.js +0 -399
  405. package/dist/commands/schema/__tests__/list.test.js.map +0 -1
  406. package/dist/commands/schema/__tests__/validate.test.js +0 -121
  407. package/dist/commands/schema/__tests__/validate.test.js.map +0 -1
  408. package/dist/commands/telemetry/__tests__/disable.test.js +0 -147
  409. package/dist/commands/telemetry/__tests__/disable.test.js.map +0 -1
  410. package/dist/commands/telemetry/__tests__/enable.test.js +0 -133
  411. package/dist/commands/telemetry/__tests__/enable.test.js.map +0 -1
  412. package/dist/commands/telemetry/__tests__/status.test.js +0 -155
  413. package/dist/commands/telemetry/__tests__/status.test.js.map +0 -1
  414. package/dist/commands/tokens/__tests__/add.test.js +0 -435
  415. package/dist/commands/tokens/__tests__/add.test.js.map +0 -1
  416. package/dist/commands/tokens/__tests__/delete.test.js +0 -405
  417. package/dist/commands/tokens/__tests__/delete.test.js.map +0 -1
  418. package/dist/commands/tokens/__tests__/list.test.js +0 -395
  419. package/dist/commands/tokens/__tests__/list.test.js.map +0 -1
  420. package/dist/commands/users/__tests__/invite.test.js +0 -362
  421. package/dist/commands/users/__tests__/invite.test.js.map +0 -1
  422. package/dist/commands/users/__tests__/list.test.js +0 -407
  423. package/dist/commands/users/__tests__/list.test.js.map +0 -1
  424. package/dist/hooks/prerun/__tests__/setupTelemetry.test.js +0 -77
  425. package/dist/hooks/prerun/__tests__/setupTelemetry.test.js.map +0 -1
  426. package/dist/services/__tests__/datasetAliases.test.js +0 -131
  427. package/dist/services/__tests__/datasetAliases.test.js.map +0 -1
  428. package/dist/services/__tests__/datasets.test.js +0 -436
  429. package/dist/services/__tests__/datasets.test.js.map +0 -1
  430. package/dist/services/__tests__/graphql.test.js +0 -43
  431. package/dist/services/__tests__/graphql.test.js.map +0 -1
  432. package/dist/services/__tests__/mediaLibraries.test.js +0 -88
  433. package/dist/services/__tests__/mediaLibraries.test.js.map +0 -1
  434. package/dist/services/__tests__/projects.test.js +0 -41
  435. package/dist/services/__tests__/projects.test.js.map +0 -1
  436. package/dist/services/__tests__/userApplications.test.js +0 -113
  437. package/dist/services/__tests__/userApplications.test.js.map +0 -1
  438. package/dist/util/__tests__/appId.test.js +0 -31
  439. package/dist/util/__tests__/appId.test.js.map +0 -1
  440. package/dist/util/__tests__/cliClient.test.js +0 -184
  441. package/dist/util/__tests__/cliClient.test.js.map +0 -1
  442. package/dist/util/__tests__/compareDependencyVersions.test.js +0 -426
  443. package/dist/util/__tests__/compareDependencyVersions.test.js.map +0 -1
  444. package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js +0 -74
  445. package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js.map +0 -1
  446. package/dist/util/__tests__/findNdjsonEntry.test.js +0 -54
  447. package/dist/util/__tests__/findNdjsonEntry.test.js.map +0 -1
  448. package/dist/util/__tests__/getCliVersion.test.js +0 -28
  449. package/dist/util/__tests__/getCliVersion.test.js.map +0 -1
  450. package/dist/util/__tests__/getLocalPackageVersion.test.js +0 -84
  451. package/dist/util/__tests__/getLocalPackageVersion.test.js.map +0 -1
  452. package/dist/util/__tests__/getWorkspace.test.js +0 -37
  453. package/dist/util/__tests__/getWorkspace.test.js.map +0 -1
  454. package/dist/util/__tests__/readPackageJson.test.js +0 -69
  455. package/dist/util/__tests__/readPackageJson.test.js.map +0 -1
  456. package/dist/util/__tests__/warnAboutMissingAppId.test.js +0 -28
  457. package/dist/util/__tests__/warnAboutMissingAppId.test.js.map +0 -1
  458. package/dist/util/packageManager/__tests__/installPackages.test.js +0 -388
  459. package/dist/util/packageManager/__tests__/installPackages.test.js.map +0 -1
  460. package/dist/util/validation/ __tests__/validateDocuments.test.js +0 -274
  461. package/dist/util/validation/ __tests__/validateDocuments.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/documents/__tests__/get.test.ts"],"sourcesContent":["import {runCommand} from '@oclif/test'\nimport {chalk} from '@sanity/cli-core/ux'\nimport {testCommand} from '@sanity/cli-test'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\n\nimport {NO_PROJECT_ID} from '../../../util/errorMessages.js'\nimport {GetDocumentCommand} from '../get.js'\n\nconst testProjectId = 'test-project'\nconst testDataset = 'production'\n\nconst defaultMocks = {\n cliConfig: {api: {dataset: testDataset, projectId: testProjectId}},\n projectRoot: {\n directory: '/test/path',\n path: '/test/path/sanity.config.ts',\n type: 'studio' as const,\n },\n token: 'test-token',\n}\n\nconst mockGetDocument = vi.hoisted(() => vi.fn())\n\nvi.mock('@sanity/cli-core', async () => {\n const actual = await vi.importActual('@sanity/cli-core')\n return {\n ...actual,\n getProjectCliClient: vi.fn().mockResolvedValue({\n getDocument: mockGetDocument,\n }),\n }\n})\n\ndescribe('#documents:get', () => {\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('--help works', async () => {\n const {stdout} = await runCommand(['documents get', '--help'])\n\n expect(stdout).toContain('Get and print a document by ID')\n expect(stdout).toContain('ARGUMENTS')\n expect(stdout).toContain('DOCUMENTID')\n })\n\n test('retrieves and displays a document successfully', async () => {\n const mockDoc = {\n _id: 'test-doc',\n _type: 'post',\n content: 'This is a test post',\n title: 'Test Post',\n }\n\n mockGetDocument.mockResolvedValue(mockDoc)\n\n const {stdout} = await testCommand(GetDocumentCommand, ['test-doc'], {\n mocks: defaultMocks,\n })\n\n expect(stdout).toContain('\"_id\": \"test-doc\"')\n expect(stdout).toContain('\"title\": \"Test Post\"')\n expect(mockGetDocument).toHaveBeenCalledWith('test-doc')\n })\n\n test('displays colorized output when --pretty flag is used', async () => {\n const mockDoc = {\n _id: 'test-doc',\n _type: 'post',\n title: 'Test Post',\n }\n\n mockGetDocument.mockResolvedValue(mockDoc)\n\n const originalChalkLevel = chalk.level\n // Force colorization\n chalk.level = 3\n\n const {stdout} = await testCommand(GetDocumentCommand, ['test-doc', '--pretty'], {\n capture: {\n stripAnsi: false,\n },\n mocks: defaultMocks,\n })\n\n // Reset chalk level\n chalk.level = originalChalkLevel\n\n // Check that the output contains the document data\n expect(stdout).toContain('test-doc')\n expect(stdout).toContain('Test Post')\n expect(stdout).toContain('_id')\n expect(stdout).toContain('_type')\n expect(stdout).toContain('title')\n\n // eslint-disable-next-line no-control-regex\n expect(stdout).toMatch(/\\u001B\\[\\d+m/)\n expect(mockGetDocument).toHaveBeenCalledWith('test-doc')\n })\n\n test('uses custom dataset when --dataset flag is provided', async () => {\n const mockDoc = {\n _id: 'test-doc',\n _type: 'post',\n title: 'Test Post',\n }\n\n mockGetDocument.mockResolvedValue(mockDoc)\n\n const {stdout} = await testCommand(GetDocumentCommand, ['test-doc', '--dataset', 'staging'], {\n mocks: defaultMocks,\n })\n\n expect(stdout).toContain('\"_id\": \"test-doc\"')\n expect(stdout).toContain('\"title\": \"Test Post\"')\n expect(mockGetDocument).toHaveBeenCalledWith('test-doc')\n })\n\n test('throws error when document is not found', async () => {\n mockGetDocument.mockResolvedValue(null)\n\n const {error} = await testCommand(GetDocumentCommand, ['nonexistent-doc'], {\n mocks: defaultMocks,\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('Document \"nonexistent-doc\" not found')\n expect(error?.oclif?.exit).toBe(1)\n expect(mockGetDocument).toHaveBeenCalledWith('nonexistent-doc')\n })\n\n test('throws error when no project ID is configured', async () => {\n const {error} = await testCommand(GetDocumentCommand, ['test-doc'], {\n mocks: {\n ...defaultMocks,\n cliConfig: {api: {dataset: 'production', projectId: undefined}},\n },\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toEqual(NO_PROJECT_ID)\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('throws error when no dataset is configured and none provided', async () => {\n const {error} = await testCommand(GetDocumentCommand, ['test-doc'], {\n mocks: {\n ...defaultMocks,\n cliConfig: {api: {dataset: undefined, projectId: testProjectId}},\n },\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('No dataset specified')\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('handles client errors gracefully', async () => {\n mockGetDocument.mockRejectedValue(new Error('Network error'))\n\n const {error} = await testCommand(GetDocumentCommand, ['test-doc'], {\n mocks: defaultMocks,\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('Failed to fetch document')\n expect(error?.oclif?.exit).toBe(1)\n expect(mockGetDocument).toHaveBeenCalledWith('test-doc')\n })\n\n test('requires document ID argument', async () => {\n const {error} = await testCommand(GetDocumentCommand, [], {\n mocks: defaultMocks,\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('Missing 1 required arg')\n expect(error?.oclif?.exit).toBe(2)\n })\n})\n"],"names":["runCommand","chalk","testCommand","afterEach","describe","expect","test","vi","NO_PROJECT_ID","GetDocumentCommand","testProjectId","testDataset","defaultMocks","cliConfig","api","dataset","projectId","projectRoot","directory","path","type","token","mockGetDocument","hoisted","fn","mock","actual","importActual","getProjectCliClient","mockResolvedValue","getDocument","clearAllMocks","stdout","toContain","mockDoc","_id","_type","content","title","mocks","toHaveBeenCalledWith","originalChalkLevel","level","capture","stripAnsi","toMatch","error","toBeInstanceOf","Error","message","oclif","exit","toBe","undefined","toEqual","mockRejectedValue"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAa;AACtC,SAAQC,KAAK,QAAO,sBAAqB;AACzC,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAE5D,SAAQC,aAAa,QAAO,iCAAgC;AAC5D,SAAQC,kBAAkB,QAAO,YAAW;AAE5C,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SAAS,CAAC;QACjC5B,OAAOyC,OAAOI,OAAOC,MAAMC,IAAI,CAAC;IAClC;AACF"}
@@ -1,300 +0,0 @@
1
- import { runCommand } from '@oclif/test';
2
- import { chalk } from '@sanity/cli-core/ux';
3
- import { testCommand } from '@sanity/cli-test';
4
- import { afterEach, describe, expect, test, vi } from 'vitest';
5
- import { QueryDocumentCommand } from '../query.js';
6
- const testProjectId = 'test-project';
7
- const testDataset = 'production';
8
- const defaultMocks = {
9
- cliConfig: {
10
- api: {
11
- dataset: testDataset,
12
- projectId: testProjectId
13
- }
14
- },
15
- projectRoot: {
16
- directory: '/test/path',
17
- path: '/test/path/sanity.config.ts',
18
- type: 'studio'
19
- },
20
- token: 'test-token'
21
- };
22
- const mockFetch = vi.hoisted(()=>vi.fn());
23
- vi.mock('@sanity/cli-core', async ()=>{
24
- const actual = await vi.importActual('@sanity/cli-core');
25
- return {
26
- ...actual,
27
- getProjectCliClient: vi.fn().mockResolvedValue({
28
- fetch: mockFetch
29
- })
30
- };
31
- });
32
- describe('#documents:query', ()=>{
33
- afterEach(()=>{
34
- vi.clearAllMocks();
35
- });
36
- test('--help works', async ()=>{
37
- const { stdout } = await runCommand([
38
- 'documents query',
39
- '--help'
40
- ]);
41
- expect(stdout).toMatchInlineSnapshot(String.raw`
42
- "Query for documents
43
-
44
- USAGE
45
- $ sanity documents query QUERY [--anonymous] [--api-version <value>] [-d
46
- <value>] [--pretty] [-p <value>]
47
-
48
- ARGUMENTS
49
- QUERY GROQ query to run against the dataset
50
-
51
- FLAGS
52
- -d, --dataset=<value> Dataset to query (overrides config)
53
- -p, --project=<value> Project ID to query (overrides config)
54
- --anonymous Send the query without any authorization token
55
- --api-version=<value> [env: SANITY_CLI_QUERY_API_VERSION] API version to
56
- use (defaults to 2025-08-15)
57
- --pretty Colorize JSON output
58
-
59
- DESCRIPTION
60
- Query for documents
61
-
62
- EXAMPLES
63
- Fetch 5 documents of type "movie"
64
-
65
- $ sanity documents query '*[_type == "movie"][0..4]'
66
-
67
- Fetch title of the oldest movie in the dataset named "staging"
68
-
69
- $ sanity documents query '*[_type == "movie"]|order(releaseDate \
70
- asc)[0]{title}' --dataset staging
71
-
72
- Use API version v2021-06-07 and do a query
73
-
74
- $ sanity documents query '*[_id == "header"] { "headerText": \
75
- pt::text(body) }' --api-version v2021-06-07
76
-
77
- "
78
- `);
79
- });
80
- test('executes query successfully with basic options', async ()=>{
81
- const mockResults = [
82
- {
83
- _id: 'movie1',
84
- _type: 'movie',
85
- title: 'The Matrix'
86
- },
87
- {
88
- _id: 'movie2',
89
- _type: 'movie',
90
- title: 'Inception'
91
- }
92
- ];
93
- mockFetch.mockResolvedValue(mockResults);
94
- const { stdout } = await testCommand(QueryDocumentCommand, [
95
- '*[_type == "movie"]'
96
- ], {
97
- mocks: defaultMocks
98
- });
99
- expect(stdout).toContain('"_id": "movie1"');
100
- expect(stdout).toContain('"title": "The Matrix"');
101
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
102
- });
103
- test('executes query with pretty flag for colorized output', async ()=>{
104
- const mockResults = [
105
- {
106
- _id: 'test',
107
- title: 'Test Movie'
108
- }
109
- ];
110
- mockFetch.mockResolvedValue(mockResults);
111
- const originalChalkLevel = chalk.level;
112
- // Force colorization
113
- chalk.level = 3;
114
- const { stdout } = await testCommand(QueryDocumentCommand, [
115
- '*[_type == "movie"]',
116
- '--pretty'
117
- ], {
118
- capture: {
119
- stripAnsi: false
120
- },
121
- mocks: defaultMocks
122
- });
123
- // Reset chalk level
124
- chalk.level = originalChalkLevel;
125
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
126
- expect(stdout).toContain('"_id"');
127
- expect(stdout).toContain('test');
128
- // eslint-disable-next-line no-control-regex
129
- expect(stdout).toMatch(/\u001B\[\d+m/);
130
- });
131
- test('uses dataset flag to override config', async ()=>{
132
- const mockResults = [
133
- {
134
- _id: 'test',
135
- title: 'Test'
136
- }
137
- ];
138
- const overrideDataset = 'staging';
139
- mockFetch.mockResolvedValue(mockResults);
140
- const { stdout } = await testCommand(QueryDocumentCommand, [
141
- '*[_type == "movie"]',
142
- '--dataset',
143
- overrideDataset
144
- ], {
145
- mocks: defaultMocks
146
- });
147
- expect(stdout).toContain('"_id": "test"');
148
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
149
- });
150
- test('uses project flag to override config', async ()=>{
151
- const mockResults = [
152
- {
153
- _id: 'test',
154
- title: 'Test'
155
- }
156
- ];
157
- mockFetch.mockResolvedValue(mockResults);
158
- const { stdout } = await testCommand(QueryDocumentCommand, [
159
- '*[_type == "movie"]',
160
- '--project',
161
- 'other-project'
162
- ], {
163
- mocks: defaultMocks
164
- });
165
- expect(stdout).toContain('"_id": "test"');
166
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
167
- });
168
- test('uses anonymous flag to skip authentication', async ()=>{
169
- const mockResults = [
170
- {
171
- _id: 'test',
172
- title: 'Test'
173
- }
174
- ];
175
- mockFetch.mockResolvedValue(mockResults);
176
- const { stdout } = await testCommand(QueryDocumentCommand, [
177
- '*[_type == "movie"]',
178
- '--anonymous'
179
- ], {
180
- mocks: defaultMocks
181
- });
182
- expect(stdout).toContain('"_id": "test"');
183
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
184
- });
185
- test('uses custom API version', async ()=>{
186
- const mockResults = [
187
- {
188
- _id: 'test',
189
- title: 'Test'
190
- }
191
- ];
192
- const customApiVersion = 'v2021-06-07';
193
- mockFetch.mockResolvedValue(mockResults);
194
- const { stdout } = await testCommand(QueryDocumentCommand, [
195
- '*[_type == "movie"]',
196
- '--api-version',
197
- customApiVersion
198
- ], {
199
- mocks: defaultMocks
200
- });
201
- expect(stdout).toContain('"_id": "test"');
202
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
203
- });
204
- test('shows warning and uses default API version when not specified', async ()=>{
205
- const mockResults = [
206
- {
207
- _id: 'test',
208
- title: 'Test'
209
- }
210
- ];
211
- mockFetch.mockResolvedValue(mockResults);
212
- const { stderr, stdout } = await testCommand(QueryDocumentCommand, [
213
- '*[_type == "movie"]'
214
- ], {
215
- mocks: defaultMocks
216
- });
217
- expect(stderr).toContain('--api-version not specified, using `2025-08-15`');
218
- expect(stdout).toContain('"_id": "test"');
219
- });
220
- test('fails when no project ID is configured or provided', async ()=>{
221
- const { error } = await testCommand(QueryDocumentCommand, [
222
- '*[_type == "movie"]'
223
- ], {
224
- mocks: {
225
- ...defaultMocks,
226
- cliConfig: {
227
- api: {
228
- dataset: testDataset
229
- }
230
- }
231
- }
232
- });
233
- expect(error).toBeInstanceOf(Error);
234
- expect(error?.message).toContain('sanity.cli.ts does not contain a project identifier');
235
- expect(error?.oclif?.exit).toBe(1);
236
- });
237
- test('fails when no dataset is configured or provided', async ()=>{
238
- const { error } = await testCommand(QueryDocumentCommand, [
239
- '*[_type == "movie"]'
240
- ], {
241
- mocks: {
242
- ...defaultMocks,
243
- cliConfig: {
244
- api: {
245
- projectId: testProjectId
246
- }
247
- }
248
- }
249
- });
250
- expect(error).toBeInstanceOf(Error);
251
- expect(error?.message).toContain('No dataset specified');
252
- expect(error?.oclif?.exit).toBe(1);
253
- });
254
- test('fails when query returns null/undefined', async ()=>{
255
- mockFetch.mockResolvedValue(null);
256
- const { error } = await testCommand(QueryDocumentCommand, [
257
- '*[_type == "nonexistent"]'
258
- ], {
259
- mocks: defaultMocks
260
- });
261
- expect(error).toBeInstanceOf(Error);
262
- expect(error?.message).toContain('Query returned no results');
263
- expect(error?.oclif?.exit).toBe(1);
264
- });
265
- test('handles query execution errors', async ()=>{
266
- const queryError = new Error('Invalid query syntax');
267
- mockFetch.mockRejectedValue(queryError);
268
- const { error } = await testCommand(QueryDocumentCommand, [
269
- 'invalid query'
270
- ], {
271
- mocks: defaultMocks
272
- });
273
- expect(error).toBeInstanceOf(Error);
274
- expect(error?.message).toContain('Invalid GROQ query syntax: Invalid query syntax');
275
- expect(error?.message).toContain('Query: invalid query');
276
- expect(error?.oclif?.exit).toBe(1);
277
- });
278
- test('uses environment variable for API version when set', async ()=>{
279
- const mockResults = [
280
- {
281
- _id: 'test',
282
- title: 'Test'
283
- }
284
- ];
285
- const envApiVersion = 'v2023-01-01';
286
- // Mock environment variable
287
- vi.stubEnv('SANITY_CLI_QUERY_API_VERSION', envApiVersion);
288
- mockFetch.mockResolvedValue(mockResults);
289
- const { stdout } = await testCommand(QueryDocumentCommand, [
290
- '*[_type == "movie"]'
291
- ], {
292
- mocks: defaultMocks
293
- });
294
- expect(stdout).toContain('"_id": "test"');
295
- expect(mockFetch).toHaveBeenCalledWith('*[_type == "movie"]');
296
- vi.unstubAllEnvs();
297
- });
298
- });
299
-
300
- //# sourceMappingURL=query.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/documents/__tests__/query.test.ts"],"sourcesContent":["import {runCommand} from '@oclif/test'\nimport {chalk} from '@sanity/cli-core/ux'\nimport {testCommand} from '@sanity/cli-test'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\n\nimport {QueryDocumentCommand} from '../query.js'\n\nconst testProjectId = 'test-project'\nconst testDataset = 'production'\n\nconst defaultMocks = {\n cliConfig: {api: {dataset: testDataset, projectId: testProjectId}},\n projectRoot: {\n directory: '/test/path',\n path: '/test/path/sanity.config.ts',\n type: 'studio' as const,\n },\n token: 'test-token',\n}\n\nconst mockFetch = vi.hoisted(() => vi.fn())\n\nvi.mock('@sanity/cli-core', async () => {\n const actual = await vi.importActual('@sanity/cli-core')\n return {\n ...actual,\n getProjectCliClient: vi.fn().mockResolvedValue({\n fetch: mockFetch,\n }),\n }\n})\n\ndescribe('#documents:query', () => {\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('--help works', async () => {\n const {stdout} = await runCommand(['documents query', '--help'])\n\n expect(stdout).toMatchInlineSnapshot(String.raw`\n \"Query for documents\n\n USAGE\n $ sanity documents query QUERY [--anonymous] [--api-version <value>] [-d\n <value>] [--pretty] [-p <value>]\n\n ARGUMENTS\n QUERY GROQ query to run against the dataset\n\n FLAGS\n -d, --dataset=<value> Dataset to query (overrides config)\n -p, --project=<value> Project ID to query (overrides config)\n --anonymous Send the query without any authorization token\n --api-version=<value> [env: SANITY_CLI_QUERY_API_VERSION] API version to\n use (defaults to 2025-08-15)\n --pretty Colorize JSON output\n\n DESCRIPTION\n Query for documents\n\n EXAMPLES\n Fetch 5 documents of type \"movie\"\n\n $ sanity documents query '*[_type == \"movie\"][0..4]'\n\n Fetch title of the oldest movie in the dataset named \"staging\"\n\n $ sanity documents query '*[_type == \"movie\"]|order(releaseDate \\\n asc)[0]{title}' --dataset staging\n\n Use API version v2021-06-07 and do a query\n\n $ sanity documents query '*[_id == \"header\"] { \"headerText\": \\\n pt::text(body) }' --api-version v2021-06-07\n\n \"\n `)\n })\n\n test('executes query successfully with basic options', async () => {\n const mockResults = [\n {\n _id: 'movie1',\n _type: 'movie',\n title: 'The Matrix',\n },\n {\n _id: 'movie2',\n _type: 'movie',\n title: 'Inception',\n },\n ]\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]'], {\n mocks: defaultMocks,\n })\n\n expect(stdout).toContain('\"_id\": \"movie1\"')\n expect(stdout).toContain('\"title\": \"The Matrix\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n })\n\n test('executes query with pretty flag for colorized output', async () => {\n const mockResults = [{_id: 'test', title: 'Test Movie'}]\n\n mockFetch.mockResolvedValue(mockResults)\n\n const originalChalkLevel = chalk.level\n // Force colorization\n chalk.level = 3\n\n const {stdout} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]', '--pretty'], {\n capture: {\n stripAnsi: false,\n },\n mocks: defaultMocks,\n })\n\n // Reset chalk level\n chalk.level = originalChalkLevel\n\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n expect(stdout).toContain('\"_id\"')\n expect(stdout).toContain('test')\n // eslint-disable-next-line no-control-regex\n expect(stdout).toMatch(/\\u001B\\[\\d+m/)\n })\n\n test('uses dataset flag to override config', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n const overrideDataset = 'staging'\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(\n QueryDocumentCommand,\n ['*[_type == \"movie\"]', '--dataset', overrideDataset],\n {\n mocks: defaultMocks,\n },\n )\n\n expect(stdout).toContain('\"_id\": \"test\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n })\n\n test('uses project flag to override config', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(\n QueryDocumentCommand,\n ['*[_type == \"movie\"]', '--project', 'other-project'],\n {\n mocks: defaultMocks,\n },\n )\n\n expect(stdout).toContain('\"_id\": \"test\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n })\n\n test('uses anonymous flag to skip authentication', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(\n QueryDocumentCommand,\n ['*[_type == \"movie\"]', '--anonymous'],\n {\n mocks: defaultMocks,\n },\n )\n\n expect(stdout).toContain('\"_id\": \"test\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n })\n\n test('uses custom API version', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n const customApiVersion = 'v2021-06-07'\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(\n QueryDocumentCommand,\n ['*[_type == \"movie\"]', '--api-version', customApiVersion],\n {\n mocks: defaultMocks,\n },\n )\n\n expect(stdout).toContain('\"_id\": \"test\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n })\n\n test('shows warning and uses default API version when not specified', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stderr, stdout} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]'], {\n mocks: defaultMocks,\n })\n\n expect(stderr).toContain('--api-version not specified, using `2025-08-15`')\n expect(stdout).toContain('\"_id\": \"test\"')\n })\n\n test('fails when no project ID is configured or provided', async () => {\n const {error} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]'], {\n mocks: {\n ...defaultMocks,\n cliConfig: {api: {dataset: testDataset}},\n },\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('sanity.cli.ts does not contain a project identifier')\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('fails when no dataset is configured or provided', async () => {\n const {error} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]'], {\n mocks: {\n ...defaultMocks,\n cliConfig: {api: {projectId: testProjectId}},\n },\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('No dataset specified')\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('fails when query returns null/undefined', async () => {\n mockFetch.mockResolvedValue(null)\n\n const {error} = await testCommand(QueryDocumentCommand, ['*[_type == \"nonexistent\"]'], {\n mocks: defaultMocks,\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('Query returned no results')\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('handles query execution errors', async () => {\n const queryError = new Error('Invalid query syntax')\n\n mockFetch.mockRejectedValue(queryError)\n\n const {error} = await testCommand(QueryDocumentCommand, ['invalid query'], {\n mocks: defaultMocks,\n })\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain('Invalid GROQ query syntax: Invalid query syntax')\n expect(error?.message).toContain('Query: invalid query')\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('uses environment variable for API version when set', async () => {\n const mockResults = [{_id: 'test', title: 'Test'}]\n const envApiVersion = 'v2023-01-01'\n\n // Mock environment variable\n vi.stubEnv('SANITY_CLI_QUERY_API_VERSION', envApiVersion)\n\n mockFetch.mockResolvedValue(mockResults)\n\n const {stdout} = await testCommand(QueryDocumentCommand, ['*[_type == \"movie\"]'], {\n mocks: defaultMocks,\n })\n\n expect(stdout).toContain('\"_id\": \"test\"')\n expect(mockFetch).toHaveBeenCalledWith('*[_type == \"movie\"]')\n\n vi.unstubAllEnvs()\n })\n})\n"],"names":["runCommand","chalk","testCommand","afterEach","describe","expect","test","vi","QueryDocumentCommand","testProjectId","testDataset","defaultMocks","cliConfig","api","dataset","projectId","projectRoot","directory","path","type","token","mockFetch","hoisted","fn","mock","actual","importActual","getProjectCliClient","mockResolvedValue","fetch","clearAllMocks","stdout","toMatchInlineSnapshot","String","raw","mockResults","_id","_type","title","mocks","toContain","toHaveBeenCalledWith","originalChalkLevel","level","capture","stripAnsi","toMatch","overrideDataset","customApiVersion","stderr","error","toBeInstanceOf","Error","message","oclif","exit","toBe","queryError","mockRejectedValue","envApiVersion","stubEnv","unstubAllEnvs"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAa;AACtC,SAAQC,KAAK,QAAO,sBAAqB;AACzC,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAE5D,SAAQC,oBAAoB,QAAO,cAAa;AAEhD,MAAMC,gBAAgB;AACtB,MAAMC,cAAc;AAEpB,MAAMC,eAAe;IACnBC,WAAW;QAACC,KAAK;YAACC,SAASJ;YAAaK,WAAWN;QAAa;IAAC;IACjEO,aAAa;QACXC,WAAW;QACXC,MAAM;QACNC,MAAM;IACR;IACAC,OAAO;AACT;AAEA,MAAMC,YAAYd,GAAGe,OAAO,CAAC,IAAMf,GAAGgB,EAAE;AAExChB,GAAGiB,IAAI,CAAC,oBAAoB;IAC1B,MAAMC,SAAS,MAAMlB,GAAGmB,YAAY,CAAC;IACrC,OAAO;QACL,GAAGD,MAAM;QACTE,qBAAqBpB,GAAGgB,EAAE,GAAGK,iBAAiB,CAAC;YAC7CC,OAAOR;QACT;IACF;AACF;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OAAOC,cAAc,CAACC;QAC7B/C,OAAO6C,OAAOG,SAASb,SAAS,CAAC;QACjCnC,OAAO6C,OAAOI,OAAOC,MAAMC,IAAI,CAAC;IAClC;IAEAlD,KAAK,kCAAkC;QACrC,MAAMmD,aAAa,IAAIL,MAAM;QAE7B/B,UAAUqC,iBAAiB,CAACD;QAE5B,MAAM,EAACP,KAAK,EAAC,GAAG,MAAMhD,YAAYM,sBAAsB;YAAC;SAAgB,EAAE;YACzE+B,OAAO5B;QACT;QAEAN,OAAO6C,OAAOC,cAAc,CAACC;QAC7B/C,OAAO6C,OAAOG,SAASb,SAAS,CAAC;QACjCnC,OAAO6C,OAAOG,SAASb,SAAS,CAAC;QACjCnC,OAAO6C,OAAOI,OAAOC,MAAMC,IAAI,CAAC;IAClC;IAEAlD,KAAK,sDAAsD;QACzD,MAAM6B,cAAc;YAAC;gBAACC,KAAK;gBAAQE,OAAO;YAAM;SAAE;QAClD,MAAMqB,gBAAgB;QAEtB,4BAA4B;QAC5BpD,GAAGqD,OAAO,CAAC,gCAAgCD;QAE3CtC,UAAUO,iBAAiB,CAACO;QAE5B,MAAM,EAACJ,MAAM,EAAC,GAAG,MAAM7B,YAAYM,sBAAsB;YAAC;SAAsB,EAAE;YAChF+B,OAAO5B;QACT;QAEAN,OAAO0B,QAAQS,SAAS,CAAC;QACzBnC,OAAOgB,WAAWoB,oBAAoB,CAAC;QAEvClC,GAAGsD,aAAa;IAClB;AACF"}
@@ -1,249 +0,0 @@
1
- import { runCommand } from '@oclif/test';
2
- import { testCommand } from '@sanity/cli-test';
3
- import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
4
- import { ValidateDocumentsCommand } from '../validate.js';
5
- const mocks = vi.hoisted(()=>({
6
- confirm: vi.fn(),
7
- isFile: vi.fn(),
8
- validate: vi.fn()
9
- }));
10
- vi.mock('node:fs', ()=>({
11
- default: {
12
- promises: {
13
- stat: vi.fn().mockResolvedValue({
14
- isFile: mocks.isFile
15
- })
16
- },
17
- resolve: vi.fn((dir, file)=>`/resolved/${file}`)
18
- }
19
- }));
20
- vi.mock('@sanity/cli-core/ux', async ()=>{
21
- const actual = await vi.importActual('@sanity/cli-core/ux');
22
- return {
23
- ...actual,
24
- confirm: mocks.confirm
25
- };
26
- });
27
- vi.mock('../../../actions/documents/validate.js', ()=>({
28
- validateDocuments: mocks.validate
29
- }));
30
- const mockConfirm = mocks.confirm;
31
- const mockIsFile = mocks.isFile;
32
- const mockValidate = mocks.validate;
33
- const testProjectId = 'test-project';
34
- const testDataset = 'test-dataset';
35
- const defaultMocks = {
36
- cliConfig: {
37
- api: {
38
- dataset: testDataset,
39
- projectId: testProjectId
40
- }
41
- },
42
- globalApiClient: {
43
- config: vi.fn(()=>({
44
- dataset: testDataset,
45
- projectId: testProjectId
46
- }))
47
- },
48
- projectRoot: {
49
- directory: '/test/path',
50
- path: '/test/path/sanity.config.ts',
51
- type: 'studio'
52
- },
53
- token: 'test-token'
54
- };
55
- describe('#documents:validate', ()=>{
56
- afterEach(()=>{
57
- vi.clearAllMocks();
58
- });
59
- beforeEach(()=>{
60
- mockConfirm.mockResolvedValue(true);
61
- mockIsFile.mockReturnValue(true);
62
- });
63
- test('--help works', async ()=>{
64
- const { stdout } = await runCommand([
65
- 'documents validate',
66
- '--help'
67
- ]);
68
- expect(stdout).toMatchInlineSnapshot(`
69
- "Validate documents in a dataset against the studio schema
70
-
71
- USAGE
72
- $ sanity documents validate [-d <value>] [--file <value>] [--format <value>]
73
- [--level error|warning|info] [--max-custom-validation-concurrency <value>]
74
- [--max-fetch-concurrency <value>] [--workspace <value>] [-y]
75
-
76
- FLAGS
77
- -d, --dataset=<value> Override the dataset used. By
78
- default, this is derived from
79
- the given workspace
80
- -y, --yes Skips the first confirmation
81
- prompt
82
- --file=<value> Provide a path to either an
83
- .ndjson file or a tarball
84
- containing an .ndjson file
85
- --format=<value> The output format used to
86
- print the found validation
87
- markers and report progress
88
- --level=<option> [default: warning] The
89
- minimum level reported out.
90
- Defaults to warning
91
- <options: error|warning|info>
92
- --max-custom-validation-concurrency=<value> [default: 5] Specify how many
93
- custom validators can run
94
- concurrently
95
- --max-fetch-concurrency=<value> [default: 25] Specify how
96
- many \`client.fetch\` requests
97
- are allow concurrency at once
98
- --workspace=<value> The name of the workspace to
99
- use when downloading and
100
- validating all documents
101
-
102
- DESCRIPTION
103
- Validate documents in a dataset against the studio schema
104
-
105
- EXAMPLES
106
- Validates all documents in a Sanity project with more than one workspace
107
-
108
- $ sanity documents validate --workspace default
109
-
110
- Override the dataset specified in the workspace
111
-
112
- $ sanity documents validate --workspace default --dataset staging
113
-
114
- Save the results of the report into a file
115
-
116
- $ sanity documents validate --yes > report.txt
117
-
118
- Report out info level validation markers too
119
-
120
- $ sanity documents validate --level info
121
-
122
- "
123
- `);
124
- });
125
- test('throws error if user enters unsupported level flag', async ()=>{
126
- const { error } = await testCommand(ValidateDocumentsCommand, [
127
- '--level',
128
- 'critical'
129
- ], {
130
- mocks: defaultMocks
131
- });
132
- expect(error?.message).toContain('Expected --level=critical to be one of: error, warning, info');
133
- });
134
- test('throws error if user enters non integer max-custom-validation-concurrency flag', async ()=>{
135
- const { error } = await testCommand(ValidateDocumentsCommand, [
136
- '--max-custom-validation-concurrency',
137
- 'abc'
138
- ], {
139
- mocks: defaultMocks
140
- });
141
- expect(error?.message).toContain('Expected an integer but received: abc');
142
- });
143
- test('throws error if user enters non integer max-fetch-concurrency flag', async ()=>{
144
- const { error } = await testCommand(ValidateDocumentsCommand, [
145
- '--max-fetch-concurrency',
146
- 'xyz'
147
- ], {
148
- mocks: defaultMocks
149
- });
150
- expect(error?.message).toContain('Expected an integer but received: xyz');
151
- });
152
- test('prompts user to confirm by default and exits if they do not want to continue', async ()=>{
153
- mockConfirm.mockResolvedValue(false);
154
- const { stdout } = await testCommand(ValidateDocumentsCommand, [], {
155
- mocks: defaultMocks
156
- });
157
- expect(stdout).toMatchInlineSnapshot(`
158
- "⚠ Warning: This command downloads all documents from your dataset and processes them through your local schema within a simulated browser environment.
159
-
160
- Potential pitfalls:
161
-
162
- - Processes all documents locally (excluding assets). Large datasets may require more resources.
163
- - Executes all custom validation functions. Some functions may need to be refactored for compatibility.
164
- - Not all standard browser features are available and may cause issues while loading your Studio.
165
- - Adheres to document permissions. Ensure this account can see all desired documents.
166
- User aborted
167
- "
168
- `);
169
- expect(mockConfirm).toHaveBeenCalledWith({
170
- default: true,
171
- message: expect.stringContaining('Are you sure you want to continue?')
172
- });
173
- expect(mockConfirm).toHaveBeenCalled();
174
- });
175
- test('skips confirm if user uses yes flag', async ()=>{
176
- await testCommand(ValidateDocumentsCommand, [
177
- '--y'
178
- ], {
179
- mocks: defaultMocks
180
- });
181
- expect(mockConfirm).not.toHaveBeenCalled();
182
- });
183
- test('exits if format is incorrect value', async ()=>{
184
- const { error } = await testCommand(ValidateDocumentsCommand, [
185
- '--format',
186
- 'xml'
187
- ], {
188
- mocks: defaultMocks
189
- });
190
- expect(error?.message).toContain("Did not recognize format 'xml'. Available formats are 'json', 'ndjson', and 'pretty'");
191
- });
192
- test('exits if user inputs invalid file path in flag', async ()=>{
193
- mockIsFile.mockReturnValue(false);
194
- const { error } = await testCommand(ValidateDocumentsCommand, [
195
- '--file',
196
- '/non/existent/file.ndjson'
197
- ], {
198
- mocks: defaultMocks
199
- });
200
- expect(error?.message).toContain("'--file' must point to a valid ndjson file or tarball");
201
- });
202
- test('validateDocuments is called with the correct params', async ()=>{
203
- mockValidate.mockResolvedValue('warning');
204
- await testCommand(ValidateDocumentsCommand, [
205
- '--yes',
206
- '--dataset',
207
- 'my-dataset',
208
- '--workspace',
209
- 'my-workspace',
210
- '--level',
211
- 'info',
212
- '--max-custom-validation-concurrency',
213
- '10',
214
- '--max-fetch-concurrency',
215
- '50',
216
- '--file',
217
- '/path/to/file.ndjson'
218
- ], {
219
- mocks: defaultMocks
220
- });
221
- expect(mockValidate).toHaveBeenCalledWith({
222
- dataset: 'my-dataset',
223
- level: 'info',
224
- maxCustomValidationConcurrency: 10,
225
- maxFetchConcurrency: 50,
226
- ndjsonFilePath: expect.stringContaining('file.ndjson'),
227
- reporter: expect.any(Function),
228
- studioHost: undefined,
229
- workDir: '/test/path',
230
- workspace: 'my-workspace'
231
- });
232
- });
233
- test('exits with code 1 if validateDocuments returns overall level as error', async ()=>{
234
- mockValidate.mockResolvedValue('error');
235
- const { error } = await testCommand(ValidateDocumentsCommand, [], {
236
- mocks: defaultMocks
237
- });
238
- expect(error?.oclif?.exit).toBe(1);
239
- });
240
- test('exits with code 0 if validateDocuments does not return overall level as error', async ()=>{
241
- mockValidate.mockResolvedValue('warning');
242
- const { error } = await testCommand(ValidateDocumentsCommand, [], {
243
- mocks: defaultMocks
244
- });
245
- expect(error).toBe(undefined);
246
- });
247
- });
248
-
249
- //# sourceMappingURL=validate.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/commands/documents/__tests__/validate.test.ts"],"sourcesContent":["import {runCommand} from '@oclif/test'\nimport {testCommand} from '@sanity/cli-test'\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {ValidateDocumentsCommand} from '../validate.js'\n\nconst mocks = vi.hoisted(() => ({\n confirm: vi.fn(),\n isFile: vi.fn(),\n validate: vi.fn(),\n}))\n\nvi.mock('node:fs', () => ({\n default: {\n promises: {\n stat: vi.fn().mockResolvedValue({\n isFile: mocks.isFile,\n }),\n },\n resolve: vi.fn((dir, file) => `/resolved/${file}`),\n },\n}))\n\nvi.mock('@sanity/cli-core/ux', async () => {\n const actual = await vi.importActual<typeof import('@sanity/cli-core/ux')>('@sanity/cli-core/ux')\n return {\n ...actual,\n confirm: mocks.confirm,\n }\n})\n\nvi.mock('../../../actions/documents/validate.js', () => ({\n validateDocuments: mocks.validate,\n}))\n\nconst mockConfirm = mocks.confirm\nconst mockIsFile = mocks.isFile\nconst mockValidate = mocks.validate\n\nconst testProjectId = 'test-project'\nconst testDataset = 'test-dataset'\n\nconst defaultMocks = {\n cliConfig: {api: {dataset: testDataset, projectId: testProjectId}},\n globalApiClient: {\n config: vi.fn(() => ({\n dataset: testDataset,\n projectId: testProjectId,\n })),\n } as never,\n projectRoot: {\n directory: '/test/path',\n path: '/test/path/sanity.config.ts',\n type: 'studio' as const,\n },\n token: 'test-token',\n}\n\ndescribe('#documents:validate', () => {\n afterEach(() => {\n vi.clearAllMocks()\n })\n beforeEach(() => {\n mockConfirm.mockResolvedValue(true)\n mockIsFile.mockReturnValue(true)\n })\n\n test('--help works', async () => {\n const {stdout} = await runCommand(['documents validate', '--help'])\n\n expect(stdout).toMatchInlineSnapshot(`\n \"Validate documents in a dataset against the studio schema\n\n USAGE\n $ sanity documents validate [-d <value>] [--file <value>] [--format <value>]\n [--level error|warning|info] [--max-custom-validation-concurrency <value>]\n [--max-fetch-concurrency <value>] [--workspace <value>] [-y]\n\n FLAGS\n -d, --dataset=<value> Override the dataset used. By\n default, this is derived from\n the given workspace\n -y, --yes Skips the first confirmation\n prompt\n --file=<value> Provide a path to either an\n .ndjson file or a tarball\n containing an .ndjson file\n --format=<value> The output format used to\n print the found validation\n markers and report progress\n --level=<option> [default: warning] The\n minimum level reported out.\n Defaults to warning\n <options: error|warning|info>\n --max-custom-validation-concurrency=<value> [default: 5] Specify how many\n custom validators can run\n concurrently\n --max-fetch-concurrency=<value> [default: 25] Specify how\n many \\`client.fetch\\` requests\n are allow concurrency at once\n --workspace=<value> The name of the workspace to\n use when downloading and\n validating all documents\n\n DESCRIPTION\n Validate documents in a dataset against the studio schema\n\n EXAMPLES\n Validates all documents in a Sanity project with more than one workspace\n\n $ sanity documents validate --workspace default\n\n Override the dataset specified in the workspace\n\n $ sanity documents validate --workspace default --dataset staging\n\n Save the results of the report into a file\n\n $ sanity documents validate --yes > report.txt\n\n Report out info level validation markers too\n\n $ sanity documents validate --level info\n\n \"\n `)\n })\n\n test('throws error if user enters unsupported level flag', async () => {\n const {error} = await testCommand(ValidateDocumentsCommand, ['--level', 'critical'], {\n mocks: defaultMocks,\n })\n\n expect(error?.message).toContain('Expected --level=critical to be one of: error, warning, info')\n })\n\n test('throws error if user enters non integer max-custom-validation-concurrency flag', async () => {\n const {error} = await testCommand(\n ValidateDocumentsCommand,\n ['--max-custom-validation-concurrency', 'abc'],\n {mocks: defaultMocks},\n )\n\n expect(error?.message).toContain('Expected an integer but received: abc')\n })\n\n test('throws error if user enters non integer max-fetch-concurrency flag', async () => {\n const {error} = await testCommand(\n ValidateDocumentsCommand,\n ['--max-fetch-concurrency', 'xyz'],\n {mocks: defaultMocks},\n )\n\n expect(error?.message).toContain('Expected an integer but received: xyz')\n })\n\n test('prompts user to confirm by default and exits if they do not want to continue', async () => {\n mockConfirm.mockResolvedValue(false)\n\n const {stdout} = await testCommand(ValidateDocumentsCommand, [], {mocks: defaultMocks})\n\n expect(stdout).toMatchInlineSnapshot(`\n \"⚠ Warning: This command downloads all documents from your dataset and processes them through your local schema within a simulated browser environment.\n\n Potential pitfalls:\n\n - Processes all documents locally (excluding assets). Large datasets may require more resources.\n - Executes all custom validation functions. Some functions may need to be refactored for compatibility.\n - Not all standard browser features are available and may cause issues while loading your Studio.\n - Adheres to document permissions. Ensure this account can see all desired documents.\n User aborted\n \"\n `)\n expect(mockConfirm).toHaveBeenCalledWith({\n default: true,\n message: expect.stringContaining('Are you sure you want to continue?'),\n })\n expect(mockConfirm).toHaveBeenCalled()\n })\n\n test('skips confirm if user uses yes flag', async () => {\n await testCommand(ValidateDocumentsCommand, ['--y'], {mocks: defaultMocks})\n\n expect(mockConfirm).not.toHaveBeenCalled()\n })\n\n test('exits if format is incorrect value', async () => {\n const {error} = await testCommand(ValidateDocumentsCommand, ['--format', 'xml'], {\n mocks: defaultMocks,\n })\n\n expect(error?.message).toContain(\n \"Did not recognize format 'xml'. Available formats are 'json', 'ndjson', and 'pretty'\",\n )\n })\n\n test('exits if user inputs invalid file path in flag', async () => {\n mockIsFile.mockReturnValue(false)\n\n const {error} = await testCommand(\n ValidateDocumentsCommand,\n ['--file', '/non/existent/file.ndjson'],\n {mocks: defaultMocks},\n )\n\n expect(error?.message).toContain(\"'--file' must point to a valid ndjson file or tarball\")\n })\n\n test('validateDocuments is called with the correct params', async () => {\n mockValidate.mockResolvedValue('warning')\n\n await testCommand(\n ValidateDocumentsCommand,\n [\n '--yes',\n '--dataset',\n 'my-dataset',\n '--workspace',\n 'my-workspace',\n '--level',\n 'info',\n '--max-custom-validation-concurrency',\n '10',\n '--max-fetch-concurrency',\n '50',\n '--file',\n '/path/to/file.ndjson',\n ],\n {mocks: defaultMocks},\n )\n\n expect(mockValidate).toHaveBeenCalledWith({\n dataset: 'my-dataset',\n level: 'info',\n maxCustomValidationConcurrency: 10,\n maxFetchConcurrency: 50,\n ndjsonFilePath: expect.stringContaining('file.ndjson'),\n reporter: expect.any(Function),\n studioHost: undefined,\n workDir: '/test/path',\n workspace: 'my-workspace',\n })\n })\n\n test('exits with code 1 if validateDocuments returns overall level as error', async () => {\n mockValidate.mockResolvedValue('error')\n\n const {error} = await testCommand(ValidateDocumentsCommand, [], {mocks: defaultMocks})\n\n expect(error?.oclif?.exit).toBe(1)\n })\n\n test('exits with code 0 if validateDocuments does not return overall level as error', async () => {\n mockValidate.mockResolvedValue('warning')\n\n const {error} = await testCommand(ValidateDocumentsCommand, [], {mocks: defaultMocks})\n\n expect(error).toBe(undefined)\n })\n})\n"],"names":["runCommand","testCommand","afterEach","beforeEach","describe","expect","test","vi","ValidateDocumentsCommand","mocks","hoisted","confirm","fn","isFile","validate","mock","default","promises","stat","mockResolvedValue","resolve","dir","file","actual","importActual","validateDocuments","mockConfirm","mockIsFile","mockValidate","testProjectId","testDataset","defaultMocks","cliConfig","api","dataset","projectId","globalApiClient","config","projectRoot","directory","path","type","token","clearAllMocks","mockReturnValue","stdout","toMatchInlineSnapshot","error","message","toContain","toHaveBeenCalledWith","stringContaining","toHaveBeenCalled","not","level","maxCustomValidationConcurrency","maxFetchConcurrency","ndjsonFilePath","reporter","any","Function","studioHost","undefined","workDir","workspace","oclif","exit","toBe"],"mappings":"AAAA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