@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.
- package/dist/actions/dataset/create.d.ts +49 -0
- package/dist/actions/dataset/create.js +48 -0
- package/dist/actions/dataset/create.js.map +1 -0
- package/dist/actions/dataset/determineDatasetAclMode.d.ts +37 -0
- package/dist/actions/dataset/determineDatasetAclMode.js +36 -0
- package/dist/actions/dataset/determineDatasetAclMode.js.map +1 -0
- package/dist/actions/debug/gatherDebugInfo.js +15 -21
- package/dist/actions/debug/gatherDebugInfo.js.map +1 -1
- package/dist/actions/debug/types.d.ts +0 -2
- package/dist/actions/debug/types.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +13 -0
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/init/remoteTemplate.js +1 -1
- package/dist/actions/init/remoteTemplate.js.map +1 -1
- package/dist/actions/manifest/extractAppManifest.d.ts +20 -0
- package/dist/actions/manifest/extractAppManifest.js +51 -0
- package/dist/actions/manifest/extractAppManifest.js.map +1 -0
- package/dist/actions/manifest/extractManifest.js +1 -1
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/manifest/types.d.ts +6 -1
- package/dist/actions/manifest/types.js.map +1 -1
- package/dist/actions/media/importAspects.js +2 -1
- package/dist/actions/media/importAspects.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +1 -1
- package/dist/commands/dataset/create.d.ts +0 -2
- package/dist/commands/dataset/create.js +8 -54
- package/dist/commands/dataset/create.js.map +1 -1
- package/dist/commands/debug.js +5 -9
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.js +358 -20
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/manifest/extract.js +7 -8
- package/dist/commands/manifest/extract.js.map +1 -1
- package/dist/config/createCliConfig.d.ts +9 -0
- package/dist/prompts/init/promptForTypescript.d.ts +2 -0
- package/dist/prompts/init/promptForTypescript.js +15 -0
- package/dist/prompts/init/promptForTypescript.js.map +1 -0
- package/dist/prompts/promptForDatasetAclMode.d.ts +9 -0
- package/dist/prompts/promptForDatasetAclMode.js +27 -0
- package/dist/prompts/promptForDatasetAclMode.js.map +1 -0
- package/dist/prompts/promptForDatasetName.d.ts +1 -1
- package/dist/prompts/promptForDatasetName.js +4 -1
- package/dist/prompts/promptForDatasetName.js.map +1 -1
- package/dist/services/organizations.d.ts +3 -1
- package/dist/services/organizations.js +2 -1
- package/dist/services/organizations.js.map +1 -1
- package/dist/services/user.d.ts +5 -0
- package/dist/services/user.js +12 -1
- package/dist/services/user.js.map +1 -1
- package/dist/services/userApplications.d.ts +3 -1
- package/dist/services/userApplications.js +5 -1
- package/dist/services/userApplications.js.map +1 -1
- package/oclif.manifest.json +113 -113
- package/package.json +16 -12
- package/templates/app-quickstart/src/App.css +20 -0
- package/templates/app-quickstart/src/App.tsx +25 -0
- package/templates/app-quickstart/src/ExampleComponent.css +90 -0
- package/templates/app-quickstart/src/ExampleComponent.tsx +37 -0
- package/templates/app-sanity-ui/src/App.tsx +34 -0
- package/templates/app-sanity-ui/src/ExampleComponent.tsx +34 -0
- package/templates/app-sanity-ui/src/SanityUI.tsx +23 -0
- package/templates/blog/README.md +11 -0
- package/templates/blog/schemaTypes/author.js +50 -0
- package/templates/blog/schemaTypes/blockContent.js +67 -0
- package/templates/blog/schemaTypes/category.js +19 -0
- package/templates/blog/schemaTypes/index.js +6 -0
- package/templates/blog/schemaTypes/post.js +65 -0
- package/templates/blog/static/.gitkeep +1 -0
- package/templates/clean/README.md +9 -0
- package/templates/clean/schemaTypes/index.js +1 -0
- package/templates/clean/static/.gitkeep +1 -0
- package/templates/ecommerce/README.md +11 -0
- package/templates/ecommerce/plugins/.gitkeep +1 -0
- package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +62 -0
- package/templates/ecommerce/plugins/barcode-input/index.js +9 -0
- package/templates/ecommerce/plugins/barcode-input/schemaType.js +60 -0
- package/templates/ecommerce/schemaTypes/blockContent.js +67 -0
- package/templates/ecommerce/schemaTypes/category.js +39 -0
- package/templates/ecommerce/schemaTypes/index.js +23 -0
- package/templates/ecommerce/schemaTypes/locale/localeBlockContent.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/localeString.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/localeText.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/supportedLanguages.js +5 -0
- package/templates/ecommerce/schemaTypes/product.js +83 -0
- package/templates/ecommerce/schemaTypes/productVariant.js +52 -0
- package/templates/ecommerce/schemaTypes/vendor.js +39 -0
- package/templates/ecommerce/static/.gitkeep +1 -0
- package/templates/get-started/README.md +9 -0
- package/templates/get-started/plugins/.gitkeep +1 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/CustomDefaultLayout.tsx +16 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +104 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/index.ts +11 -0
- package/templates/get-started/schemaTypes/index.ts +1 -0
- package/templates/get-started/static/.gitkeep +1 -0
- package/templates/moviedb/README.md +10 -0
- package/templates/moviedb/schemaTypes/blockContent.js +67 -0
- package/templates/moviedb/schemaTypes/castMember.js +37 -0
- package/templates/moviedb/schemaTypes/crewMember.js +52 -0
- package/templates/moviedb/schemaTypes/index.js +22 -0
- package/templates/moviedb/schemaTypes/movie.js +85 -0
- package/templates/moviedb/schemaTypes/person.js +37 -0
- package/templates/moviedb/schemaTypes/plotSummaries.js +20 -0
- package/templates/moviedb/schemaTypes/plotSummary.js +24 -0
- package/templates/moviedb/schemaTypes/screening.js +81 -0
- package/templates/moviedb/static/.gitkeep +1 -0
- package/templates/quickstart/README.md +9 -0
- package/templates/quickstart/schemaTypes/index.js +1 -0
- package/templates/quickstart/static/.gitkeep +1 -0
- package/templates/shared/gitignore.txt +29 -0
- package/templates/shared/tsconfig.json +17 -0
- package/templates/shopify/README.md +85 -0
- package/templates/shopify/components/hotspots/ProductTooltip.tsx +38 -0
- package/templates/shopify/components/icons/Shopify.tsx +20 -0
- package/templates/shopify/components/inputs/CollectionHidden.tsx +23 -0
- package/templates/shopify/components/inputs/PlaceholderString.tsx +20 -0
- package/templates/shopify/components/inputs/ProductHidden.tsx +64 -0
- package/templates/shopify/components/inputs/ProductVariantHidden.tsx +24 -0
- package/templates/shopify/components/inputs/ProxyString.tsx +32 -0
- package/templates/shopify/components/media/ColorTheme.tsx +38 -0
- package/templates/shopify/components/media/ShopifyDocumentStatus.tsx +82 -0
- package/templates/shopify/components/studio/Navbar.tsx +29 -0
- package/templates/shopify/constants.ts +61 -0
- package/templates/shopify/docs/features.md +158 -0
- package/templates/shopify/plugins/customDocumentActions/index.ts +55 -0
- package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +144 -0
- package/templates/shopify/plugins/customDocumentActions/shopifyLink.ts +39 -0
- package/templates/shopify/plugins/customDocumentActions/types.ts +14 -0
- package/templates/shopify/schemaTypes/documents/collection.tsx +142 -0
- package/templates/shopify/schemaTypes/documents/colorTheme.tsx +44 -0
- package/templates/shopify/schemaTypes/documents/page.ts +70 -0
- package/templates/shopify/schemaTypes/documents/product.tsx +132 -0
- package/templates/shopify/schemaTypes/documents/productVariant.tsx +67 -0
- package/templates/shopify/schemaTypes/index.ts +108 -0
- package/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts +27 -0
- package/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts +16 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx +48 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx +50 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts +40 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts +49 -0
- package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
- package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
- package/templates/shopify/schemaTypes/objects/global/menuType.ts +17 -0
- package/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts +37 -0
- package/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts +48 -0
- package/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx +17 -0
- package/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx +60 -0
- package/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx +34 -0
- package/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx +37 -0
- package/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx +33 -0
- package/templates/shopify/schemaTypes/objects/link/linkProductType.tsx +60 -0
- package/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts +33 -0
- package/templates/shopify/schemaTypes/objects/module/accordionType.ts +28 -0
- package/templates/shopify/schemaTypes/objects/module/callToActionType.tsx +85 -0
- package/templates/shopify/schemaTypes/objects/module/calloutType.ts +38 -0
- package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +47 -0
- package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
- package/templates/shopify/schemaTypes/objects/module/gridType.ts +28 -0
- package/templates/shopify/schemaTypes/objects/module/heroType.tsx +40 -0
- package/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx +19 -0
- package/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts +80 -0
- package/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx +51 -0
- package/templates/shopify/schemaTypes/objects/module/instagramType.ts +35 -0
- package/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx +50 -0
- package/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx +42 -0
- package/templates/shopify/schemaTypes/objects/seoType.ts +31 -0
- package/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx +37 -0
- package/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts +25 -0
- package/templates/shopify/schemaTypes/objects/shopify/optionType.tsx +31 -0
- package/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts +11 -0
- package/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts +20 -0
- package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +142 -0
- package/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts +12 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopType.ts +15 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts +84 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts +131 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts +121 -0
- package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
- package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
- package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
- package/templates/shopify/schemaTypes/singletons/settingsType.ts +96 -0
- package/templates/shopify/static/.gitkeep +1 -0
- package/templates/shopify/structure/collectionStructure.ts +9 -0
- package/templates/shopify/structure/colorThemeStructure.ts +9 -0
- package/templates/shopify/structure/homeStructure.ts +9 -0
- package/templates/shopify/structure/index.ts +57 -0
- package/templates/shopify/structure/pageStructure.ts +11 -0
- package/templates/shopify/structure/productStructure.ts +51 -0
- package/templates/shopify/structure/settingStructure.ts +9 -0
- package/templates/shopify/utils/blocksToText.ts +20 -0
- package/templates/shopify/utils/defineStructure.ts +11 -0
- package/templates/shopify/utils/getPriceRange.ts +24 -0
- package/templates/shopify/utils/shopifyUrls.ts +22 -0
- package/templates/shopify/utils/validateSlug.ts +18 -0
- package/templates/shopify-online-storefront/README.md +54 -0
- package/templates/shopify-online-storefront/components/icons/Shopify.tsx +22 -0
- package/templates/shopify-online-storefront/components/inputs/CollectionHidden.tsx +23 -0
- package/templates/shopify-online-storefront/components/inputs/PlaceholderString.tsx +25 -0
- package/templates/shopify-online-storefront/components/inputs/ProductHidden.tsx +66 -0
- package/templates/shopify-online-storefront/components/inputs/ProductVariantHidden.tsx +25 -0
- package/templates/shopify-online-storefront/components/inputs/ProxyString.tsx +38 -0
- package/templates/shopify-online-storefront/components/media/ShopifyDocumentStatus.tsx +83 -0
- package/templates/shopify-online-storefront/constants.ts +18 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/index.ts +45 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +144 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyLink.ts +39 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/types.ts +14 -0
- package/templates/shopify-online-storefront/schemaTypes/blocks/blockContent.ts +32 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/collection.tsx +83 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/product.tsx +102 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/productVariant.tsx +82 -0
- package/templates/shopify-online-storefront/schemaTypes/index.ts +43 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/accordion.ts +31 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/accordionGroup.ts +35 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/callout.ts +40 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/inventory.ts +30 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/option.ts +30 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/priceRange.ts +22 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/proxyString.ts +11 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollection.ts +109 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollectionRule.tsx +45 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProduct.ts +165 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProductVariant.ts +151 -0
- package/templates/shopify-online-storefront/structure/collectionStructure.ts +9 -0
- package/templates/shopify-online-storefront/structure/index.ts +37 -0
- package/templates/shopify-online-storefront/structure/productStructure.ts +35 -0
- package/templates/shopify-online-storefront/utils/defineStructure.ts +11 -0
- package/templates/shopify-online-storefront/utils/getPriceRange.ts +24 -0
- package/templates/shopify-online-storefront/utils/shopifyUrls.ts +22 -0
- package/dist/actions/build/__tests__/buildApp.test.js +0 -367
- package/dist/actions/build/__tests__/buildApp.test.js.map +0 -1
- package/dist/actions/build/__tests__/buildStudio.test.js +0 -561
- package/dist/actions/build/__tests__/buildStudio.test.js.map +0 -1
- package/dist/actions/build/__tests__/checkRequiredDependencies.test.js +0 -233
- package/dist/actions/build/__tests__/checkRequiredDependencies.test.js.map +0 -1
- package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js +0 -414
- package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js.map +0 -1
- package/dist/actions/build/__tests__/determineBasePath.test.js +0 -24
- package/dist/actions/build/__tests__/determineBasePath.test.js.map +0 -1
- package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js +0 -109
- package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js.map +0 -1
- package/dist/actions/build/__tests__/getViteConfig.test.js +0 -493
- package/dist/actions/build/__tests__/getViteConfig.test.js.map +0 -1
- package/dist/actions/build/__tests__/renderDocument.test.js +0 -278
- package/dist/actions/build/__tests__/renderDocument.test.js.map +0 -1
- package/dist/actions/build/__tests__/shouldAutoUpdate.test.js +0 -153
- package/dist/actions/build/__tests__/shouldAutoUpdate.test.js.map +0 -1
- package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js +0 -657
- package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js.map +0 -1
- package/dist/actions/dataset/__tests__/validateDatasetName.test.js +0 -182
- package/dist/actions/dataset/__tests__/validateDatasetName.test.js.map +0 -1
- package/dist/actions/deploy/__tests__/checkDir.test.js +0 -120
- package/dist/actions/deploy/__tests__/checkDir.test.js.map +0 -1
- package/dist/actions/docs/__tests__/normalizeDocsPath.test.js +0 -16
- package/dist/actions/docs/__tests__/normalizeDocsPath.test.js.map +0 -1
- package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js +0 -124
- package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js.map +0 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +0 -274
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +0 -1
- package/dist/actions/media/__tests__/importMedia.test.js +0 -182
- package/dist/actions/media/__tests__/importMedia.test.js.map +0 -1
- package/dist/actions/schema/__tests__/formatSchemaValidation.test.js +0 -174
- package/dist/actions/schema/__tests__/formatSchemaValidation.test.js.map +0 -1
- package/dist/actions/schema/__tests__/validateAction.test.js +0 -281
- package/dist/actions/schema/__tests__/validateAction.test.js.map +0 -1
- package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js +0 -27
- package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js.map +0 -1
- package/dist/actions/users/__tests__/validateEmail.test.js +0 -16
- package/dist/actions/users/__tests__/validateEmail.test.js.map +0 -1
- package/dist/commands/__tests__/blueprints.test.js +0 -54
- package/dist/commands/__tests__/blueprints.test.js.map +0 -1
- package/dist/commands/__tests__/build.test.js +0 -132
- package/dist/commands/__tests__/build.test.js.map +0 -1
- package/dist/commands/__tests__/codemod.test.js +0 -271
- package/dist/commands/__tests__/codemod.test.js.map +0 -1
- package/dist/commands/__tests__/debug.test.js +0 -590
- package/dist/commands/__tests__/debug.test.js.map +0 -1
- package/dist/commands/__tests__/deploy.test.js +0 -1945
- package/dist/commands/__tests__/deploy.test.js.map +0 -1
- package/dist/commands/__tests__/dev.test.js +0 -453
- package/dist/commands/__tests__/dev.test.js.map +0 -1
- package/dist/commands/__tests__/exec.test.js +0 -207
- package/dist/commands/__tests__/exec.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.authentication.test.js +0 -73
- package/dist/commands/__tests__/init/init.authentication.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.create-new-project.test.js +0 -195
- package/dist/commands/__tests__/init/init.create-new-project.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.plan.test.js +0 -279
- package/dist/commands/__tests__/init/init.plan.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.setup.test.js +0 -335
- package/dist/commands/__tests__/init/init.setup.test.js.map +0 -1
- package/dist/commands/__tests__/install.test.js +0 -282
- package/dist/commands/__tests__/install.test.js.map +0 -1
- package/dist/commands/__tests__/learn.test.js +0 -29
- package/dist/commands/__tests__/learn.test.js.map +0 -1
- package/dist/commands/__tests__/logout.test.js +0 -91
- package/dist/commands/__tests__/logout.test.js.map +0 -1
- package/dist/commands/__tests__/manage.test.js +0 -110
- package/dist/commands/__tests__/manage.test.js.map +0 -1
- package/dist/commands/__tests__/migration.test.js +0 -119
- package/dist/commands/__tests__/migration.test.js.map +0 -1
- package/dist/commands/__tests__/preview.test.js +0 -261
- package/dist/commands/__tests__/preview.test.js.map +0 -1
- package/dist/commands/__tests__/start.test.js +0 -253
- package/dist/commands/__tests__/start.test.js.map +0 -1
- package/dist/commands/__tests__/undeploy.test.js +0 -382
- package/dist/commands/__tests__/undeploy.test.js.map +0 -1
- package/dist/commands/__tests__/versions.test.js +0 -142
- package/dist/commands/__tests__/versions.test.js.map +0 -1
- package/dist/commands/backup/__tests__/disable.test.js +0 -204
- package/dist/commands/backup/__tests__/disable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/download.test.js +0 -768
- package/dist/commands/backup/__tests__/download.test.js.map +0 -1
- package/dist/commands/backup/__tests__/enable.test.js +0 -286
- package/dist/commands/backup/__tests__/enable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/list.test.js +0 -330
- package/dist/commands/backup/__tests__/list.test.js.map +0 -1
- package/dist/commands/cors/__tests__/add.test.js +0 -376
- package/dist/commands/cors/__tests__/add.test.js.map +0 -1
- package/dist/commands/cors/__tests__/delete.test.js +0 -308
- package/dist/commands/cors/__tests__/delete.test.js.map +0 -1
- package/dist/commands/cors/__tests__/list.test.js +0 -241
- package/dist/commands/cors/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/copy.test.js +0 -628
- package/dist/commands/dataset/__tests__/copy.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/create.test.js +0 -342
- package/dist/commands/dataset/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/delete.test.js +0 -231
- package/dist/commands/dataset/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/export.test.js +0 -601
- package/dist/commands/dataset/__tests__/export.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/import.test.js +0 -53
- package/dist/commands/dataset/__tests__/import.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/list.test.js +0 -216
- package/dist/commands/dataset/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/create.test.js +0 -339
- package/dist/commands/dataset/alias/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/delete.test.js +0 -247
- package/dist/commands/dataset/alias/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/link.test.js +0 -376
- package/dist/commands/dataset/alias/__tests__/link.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/unlink.test.js +0 -313
- package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/get.test.js +0 -128
- package/dist/commands/dataset/visibility/__tests__/get.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/set.test.js +0 -198
- package/dist/commands/dataset/visibility/__tests__/set.test.js.map +0 -1
- package/dist/commands/docs/__tests__/browse.test.js +0 -29
- package/dist/commands/docs/__tests__/browse.test.js.map +0 -1
- package/dist/commands/docs/__tests__/read.test.js +0 -78
- package/dist/commands/docs/__tests__/read.test.js.map +0 -1
- package/dist/commands/docs/__tests__/search.test.js +0 -255
- package/dist/commands/docs/__tests__/search.test.js.map +0 -1
- package/dist/commands/documents/__tests__/create.test.js +0 -1030
- package/dist/commands/documents/__tests__/create.test.js.map +0 -1
- package/dist/commands/documents/__tests__/delete.test.js +0 -300
- package/dist/commands/documents/__tests__/delete.test.js.map +0 -1
- package/dist/commands/documents/__tests__/get.test.js +0 -182
- package/dist/commands/documents/__tests__/get.test.js.map +0 -1
- package/dist/commands/documents/__tests__/query.test.js +0 -300
- package/dist/commands/documents/__tests__/query.test.js.map +0 -1
- package/dist/commands/documents/__tests__/validate.test.js +0 -249
- package/dist/commands/documents/__tests__/validate.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/list.test.js +0 -240
- package/dist/commands/graphql/__tests__/list.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/undeploy.test.js +0 -410
- package/dist/commands/graphql/__tests__/undeploy.test.js.map +0 -1
- package/dist/commands/hook/__tests__/attempt.test.js +0 -275
- package/dist/commands/hook/__tests__/attempt.test.js.map +0 -1
- package/dist/commands/hook/__tests__/create.test.js +0 -119
- package/dist/commands/hook/__tests__/create.test.js.map +0 -1
- package/dist/commands/hook/__tests__/delete.test.js +0 -233
- package/dist/commands/hook/__tests__/delete.test.js.map +0 -1
- package/dist/commands/hook/__tests__/list.test.js +0 -145
- package/dist/commands/hook/__tests__/list.test.js.map +0 -1
- package/dist/commands/hook/__tests__/logs.test.js +0 -798
- package/dist/commands/hook/__tests__/logs.test.js.map +0 -1
- package/dist/commands/manifest/__tests__/extract.test.js +0 -132
- package/dist/commands/manifest/__tests__/extract.test.js.map +0 -1
- package/dist/commands/mcp/__tests__/configure.test.js +0 -397
- package/dist/commands/mcp/__tests__/configure.test.js.map +0 -1
- package/dist/commands/media/__tests__/create-aspect.test.js +0 -173
- package/dist/commands/media/__tests__/create-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/delete-aspect.test.js +0 -342
- package/dist/commands/media/__tests__/delete-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/deploy-aspect.test.js +0 -619
- package/dist/commands/media/__tests__/deploy-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/export.test.js +0 -697
- package/dist/commands/media/__tests__/export.test.js.map +0 -1
- package/dist/commands/media/__tests__/import.test.js +0 -347
- package/dist/commands/media/__tests__/import.test.js.map +0 -1
- package/dist/commands/openapi/__tests__/get.test.js +0 -149
- package/dist/commands/openapi/__tests__/get.test.js.map +0 -1
- package/dist/commands/openapi/__tests__/list.test.js +0 -113
- package/dist/commands/openapi/__tests__/list.test.js.map +0 -1
- package/dist/commands/projects/__tests__/list.test.js +0 -154
- package/dist/commands/projects/__tests__/list.test.js.map +0 -1
- package/dist/commands/schema/__tests__/delete.test.js +0 -454
- package/dist/commands/schema/__tests__/delete.test.js.map +0 -1
- package/dist/commands/schema/__tests__/deploy.test.js +0 -348
- package/dist/commands/schema/__tests__/deploy.test.js.map +0 -1
- package/dist/commands/schema/__tests__/extract.test.js +0 -121
- package/dist/commands/schema/__tests__/extract.test.js.map +0 -1
- package/dist/commands/schema/__tests__/list.test.js +0 -399
- package/dist/commands/schema/__tests__/list.test.js.map +0 -1
- package/dist/commands/schema/__tests__/validate.test.js +0 -121
- package/dist/commands/schema/__tests__/validate.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/disable.test.js +0 -147
- package/dist/commands/telemetry/__tests__/disable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/enable.test.js +0 -133
- package/dist/commands/telemetry/__tests__/enable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/status.test.js +0 -155
- package/dist/commands/telemetry/__tests__/status.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/add.test.js +0 -435
- package/dist/commands/tokens/__tests__/add.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/delete.test.js +0 -405
- package/dist/commands/tokens/__tests__/delete.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/list.test.js +0 -395
- package/dist/commands/tokens/__tests__/list.test.js.map +0 -1
- package/dist/commands/users/__tests__/invite.test.js +0 -362
- package/dist/commands/users/__tests__/invite.test.js.map +0 -1
- package/dist/commands/users/__tests__/list.test.js +0 -407
- package/dist/commands/users/__tests__/list.test.js.map +0 -1
- package/dist/hooks/prerun/__tests__/setupTelemetry.test.js +0 -77
- package/dist/hooks/prerun/__tests__/setupTelemetry.test.js.map +0 -1
- package/dist/services/__tests__/datasetAliases.test.js +0 -131
- package/dist/services/__tests__/datasetAliases.test.js.map +0 -1
- package/dist/services/__tests__/datasets.test.js +0 -436
- package/dist/services/__tests__/datasets.test.js.map +0 -1
- package/dist/services/__tests__/graphql.test.js +0 -43
- package/dist/services/__tests__/graphql.test.js.map +0 -1
- package/dist/services/__tests__/mediaLibraries.test.js +0 -88
- package/dist/services/__tests__/mediaLibraries.test.js.map +0 -1
- package/dist/services/__tests__/projects.test.js +0 -41
- package/dist/services/__tests__/projects.test.js.map +0 -1
- package/dist/services/__tests__/userApplications.test.js +0 -113
- package/dist/services/__tests__/userApplications.test.js.map +0 -1
- package/dist/util/__tests__/appId.test.js +0 -31
- package/dist/util/__tests__/appId.test.js.map +0 -1
- package/dist/util/__tests__/cliClient.test.js +0 -184
- package/dist/util/__tests__/cliClient.test.js.map +0 -1
- package/dist/util/__tests__/compareDependencyVersions.test.js +0 -426
- package/dist/util/__tests__/compareDependencyVersions.test.js.map +0 -1
- package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js +0 -74
- package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js.map +0 -1
- package/dist/util/__tests__/findNdjsonEntry.test.js +0 -54
- package/dist/util/__tests__/findNdjsonEntry.test.js.map +0 -1
- package/dist/util/__tests__/getCliVersion.test.js +0 -28
- package/dist/util/__tests__/getCliVersion.test.js.map +0 -1
- package/dist/util/__tests__/getLocalPackageVersion.test.js +0 -84
- package/dist/util/__tests__/getLocalPackageVersion.test.js.map +0 -1
- package/dist/util/__tests__/getWorkspace.test.js +0 -37
- package/dist/util/__tests__/getWorkspace.test.js.map +0 -1
- package/dist/util/__tests__/readPackageJson.test.js +0 -69
- package/dist/util/__tests__/readPackageJson.test.js.map +0 -1
- package/dist/util/__tests__/warnAboutMissingAppId.test.js +0 -28
- package/dist/util/__tests__/warnAboutMissingAppId.test.js.map +0 -1
- package/dist/util/packageManager/__tests__/installPackages.test.js +0 -388
- package/dist/util/packageManager/__tests__/installPackages.test.js.map +0 -1
- package/dist/util/validation/ __tests__/validateDocuments.test.js +0 -274
- package/dist/util/validation/ __tests__/validateDocuments.test.js.map +0 -1
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import { runCommand } from '@oclif/test';
|
|
2
|
-
import { getProjectCliClient } from '@sanity/cli-core';
|
|
3
|
-
import { mockApi, testCommand } from '@sanity/cli-test';
|
|
4
|
-
import nock from 'nock';
|
|
5
|
-
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
6
|
-
import { PROJECTS_API_VERSION } from '../../../services/projects.js';
|
|
7
|
-
import { USERS_API_VERSION } from '../../../services/user.js';
|
|
8
|
-
import { NO_PROJECT_ID } from '../../../util/errorMessages.js';
|
|
9
|
-
import { List } from '../list.js';
|
|
10
|
-
const testProjectId = 'test-project';
|
|
11
|
-
const defaultMocks = {
|
|
12
|
-
cliConfig: {
|
|
13
|
-
api: {
|
|
14
|
-
projectId: testProjectId
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
projectRoot: {
|
|
18
|
-
directory: '/test/path',
|
|
19
|
-
path: '/test/path/sanity.config.ts',
|
|
20
|
-
type: 'studio'
|
|
21
|
-
},
|
|
22
|
-
token: 'test-token'
|
|
23
|
-
};
|
|
24
|
-
vi.mock('@sanity/cli-core', async ()=>{
|
|
25
|
-
const actual = await vi.importActual('@sanity/cli-core');
|
|
26
|
-
return {
|
|
27
|
-
...actual,
|
|
28
|
-
getProjectCliClient: vi.fn()
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
const mockGetProjectCliClient = vi.mocked(getProjectCliClient);
|
|
32
|
-
describe('#list', ()=>{
|
|
33
|
-
afterEach(()=>{
|
|
34
|
-
vi.clearAllMocks();
|
|
35
|
-
const pending = nock.pendingMocks();
|
|
36
|
-
nock.cleanAll();
|
|
37
|
-
expect(pending, 'pending mocks').toEqual([]);
|
|
38
|
-
});
|
|
39
|
-
test('--help works', async ()=>{
|
|
40
|
-
const { stdout } = await runCommand([
|
|
41
|
-
'users list',
|
|
42
|
-
'--help'
|
|
43
|
-
]);
|
|
44
|
-
expect(stdout).toContain('List all users of the project');
|
|
45
|
-
});
|
|
46
|
-
test('displays users correctly', async ()=>{
|
|
47
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
48
|
-
projects: {
|
|
49
|
-
getById: vi.fn().mockResolvedValue({
|
|
50
|
-
members: [
|
|
51
|
-
{
|
|
52
|
-
id: 'user1',
|
|
53
|
-
isRobot: false,
|
|
54
|
-
role: 'developer'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'user2',
|
|
58
|
-
isRobot: false,
|
|
59
|
-
role: 'admin'
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
mockApi({
|
|
66
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
67
|
-
uri: `/invitations/project/${testProjectId}`
|
|
68
|
-
}).reply(200, []);
|
|
69
|
-
mockApi({
|
|
70
|
-
apiVersion: USERS_API_VERSION,
|
|
71
|
-
uri: '/users/user1,user2'
|
|
72
|
-
}).reply(200, [
|
|
73
|
-
{
|
|
74
|
-
createdAt: '2023-01-01',
|
|
75
|
-
displayName: 'User One',
|
|
76
|
-
id: 'user1'
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
createdAt: '2023-01-02',
|
|
80
|
-
displayName: 'User Two',
|
|
81
|
-
id: 'user2'
|
|
82
|
-
}
|
|
83
|
-
]);
|
|
84
|
-
const { stdout } = await testCommand(List, [], {
|
|
85
|
-
mocks: defaultMocks
|
|
86
|
-
});
|
|
87
|
-
expect(stdout).toMatchSnapshot();
|
|
88
|
-
});
|
|
89
|
-
test('displays pending invitations correctly', async ()=>{
|
|
90
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
91
|
-
projects: {
|
|
92
|
-
getById: vi.fn().mockResolvedValue({
|
|
93
|
-
members: [
|
|
94
|
-
{
|
|
95
|
-
id: 'user1',
|
|
96
|
-
isRobot: false,
|
|
97
|
-
role: 'developer'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'user2',
|
|
101
|
-
isRobot: false,
|
|
102
|
-
role: 'admin'
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
mockApi({
|
|
109
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
110
|
-
uri: `/invitations/project/${testProjectId}`
|
|
111
|
-
}).reply(200, [
|
|
112
|
-
{
|
|
113
|
-
createdAt: '2023-02-01',
|
|
114
|
-
email: 'pending@example.com',
|
|
115
|
-
id: 'invite1',
|
|
116
|
-
invitedByUser: {
|
|
117
|
-
id: 'user2'
|
|
118
|
-
},
|
|
119
|
-
role: 'viewer'
|
|
120
|
-
}
|
|
121
|
-
]);
|
|
122
|
-
mockApi({
|
|
123
|
-
apiVersion: USERS_API_VERSION,
|
|
124
|
-
uri: '/users/user1,user2'
|
|
125
|
-
}).reply(200, [
|
|
126
|
-
{
|
|
127
|
-
createdAt: '2023-01-01',
|
|
128
|
-
displayName: 'User One',
|
|
129
|
-
id: 'user1'
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
createdAt: '2023-01-02',
|
|
133
|
-
displayName: 'User Two',
|
|
134
|
-
id: 'user2'
|
|
135
|
-
}
|
|
136
|
-
]);
|
|
137
|
-
const { stdout } = await testCommand(List, [], {
|
|
138
|
-
mocks: defaultMocks
|
|
139
|
-
});
|
|
140
|
-
expect(stdout).toMatchSnapshot();
|
|
141
|
-
});
|
|
142
|
-
test('displays an error if the API request fails', async ()=>{
|
|
143
|
-
// Wait for 50ms to ensure the Promise.all is called
|
|
144
|
-
setTimeout(()=>mockGetProjectCliClient.mockRejectedValue(new Error('Internal server error')), 50);
|
|
145
|
-
mockApi({
|
|
146
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
147
|
-
uri: `/invitations/project/${testProjectId}`
|
|
148
|
-
}).reply(200, []);
|
|
149
|
-
const { error } = await testCommand(List, [], {
|
|
150
|
-
mocks: defaultMocks
|
|
151
|
-
});
|
|
152
|
-
expect(error).toBeInstanceOf(Error);
|
|
153
|
-
expect(error?.message).toContain(`Error fetching members for ${testProjectId}`);
|
|
154
|
-
});
|
|
155
|
-
test('sorts by role when --sort role is specified', async ()=>{
|
|
156
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
157
|
-
projects: {
|
|
158
|
-
getById: vi.fn().mockResolvedValue({
|
|
159
|
-
members: [
|
|
160
|
-
{
|
|
161
|
-
id: 'user1',
|
|
162
|
-
isRobot: false,
|
|
163
|
-
role: 'developer'
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: 'user2',
|
|
167
|
-
isRobot: false,
|
|
168
|
-
role: 'admin'
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 'user3',
|
|
172
|
-
isRobot: false,
|
|
173
|
-
role: 'viewer'
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
})
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
mockApi({
|
|
180
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
181
|
-
uri: `/invitations/project/${testProjectId}`
|
|
182
|
-
}).reply(200, []);
|
|
183
|
-
mockApi({
|
|
184
|
-
apiVersion: USERS_API_VERSION,
|
|
185
|
-
uri: '/users/user1,user2,user3'
|
|
186
|
-
}).reply(200, [
|
|
187
|
-
{
|
|
188
|
-
createdAt: '2023-01-01',
|
|
189
|
-
displayName: 'User One',
|
|
190
|
-
id: 'user1'
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
createdAt: '2023-01-02',
|
|
194
|
-
displayName: 'User Two',
|
|
195
|
-
id: 'user2'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
createdAt: '2023-01-03',
|
|
199
|
-
displayName: 'User Three',
|
|
200
|
-
id: 'user3'
|
|
201
|
-
}
|
|
202
|
-
]);
|
|
203
|
-
const { stdout } = await testCommand(List, [
|
|
204
|
-
'--sort',
|
|
205
|
-
'role'
|
|
206
|
-
], {
|
|
207
|
-
mocks: defaultMocks
|
|
208
|
-
});
|
|
209
|
-
// Check that we have all the roles in the output
|
|
210
|
-
expect(stdout).toMatchSnapshot();
|
|
211
|
-
// Split by lines and remove empty lines
|
|
212
|
-
const lines = stdout.split('\n').filter(Boolean);
|
|
213
|
-
// Find the indices of lines containing each role
|
|
214
|
-
const adminIndex = lines.findIndex((line)=>line.includes('admin'));
|
|
215
|
-
const developerIndex = lines.findIndex((line)=>line.includes('developer'));
|
|
216
|
-
const viewerIndex = lines.findIndex((line)=>line.includes('viewer'));
|
|
217
|
-
// Verify they all exist
|
|
218
|
-
expect(adminIndex).toBeGreaterThan(-1);
|
|
219
|
-
expect(developerIndex).toBeGreaterThan(-1);
|
|
220
|
-
expect(viewerIndex).toBeGreaterThan(-1);
|
|
221
|
-
// Now check the sort order (admin should come first alphabetically)
|
|
222
|
-
expect(adminIndex).toBeLessThan(developerIndex);
|
|
223
|
-
expect(developerIndex).toBeLessThan(viewerIndex);
|
|
224
|
-
});
|
|
225
|
-
test('sorts in descending order when --order desc is specified', async ()=>{
|
|
226
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
227
|
-
projects: {
|
|
228
|
-
getById: vi.fn().mockResolvedValue({
|
|
229
|
-
members: [
|
|
230
|
-
{
|
|
231
|
-
id: 'user1',
|
|
232
|
-
isRobot: false,
|
|
233
|
-
role: 'developer'
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
id: 'user2',
|
|
237
|
-
isRobot: false,
|
|
238
|
-
role: 'admin'
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
id: 'user3',
|
|
242
|
-
isRobot: false,
|
|
243
|
-
role: 'viewer'
|
|
244
|
-
}
|
|
245
|
-
]
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
mockApi({
|
|
250
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
251
|
-
uri: `/invitations/project/${testProjectId}`
|
|
252
|
-
}).reply(200, []);
|
|
253
|
-
mockApi({
|
|
254
|
-
apiVersion: USERS_API_VERSION,
|
|
255
|
-
uri: '/users/user1,user2,user3'
|
|
256
|
-
}).reply(200, [
|
|
257
|
-
{
|
|
258
|
-
createdAt: '2023-01-01',
|
|
259
|
-
displayName: 'User One',
|
|
260
|
-
id: 'user1'
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
createdAt: '2023-01-02',
|
|
264
|
-
displayName: 'User Two',
|
|
265
|
-
id: 'user2'
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
createdAt: '2023-01-03',
|
|
269
|
-
displayName: 'User Three',
|
|
270
|
-
id: 'user3'
|
|
271
|
-
}
|
|
272
|
-
]);
|
|
273
|
-
const { stdout } = await testCommand(List, [
|
|
274
|
-
'--order',
|
|
275
|
-
'desc'
|
|
276
|
-
], {
|
|
277
|
-
mocks: defaultMocks
|
|
278
|
-
});
|
|
279
|
-
// Check that we have all the dates in the output
|
|
280
|
-
expect(stdout).toContain('2023-01-01');
|
|
281
|
-
expect(stdout).toContain('2023-01-02');
|
|
282
|
-
expect(stdout).toContain('2023-01-03');
|
|
283
|
-
// By default, it sorts by date, so we need to check the reverse chronological order
|
|
284
|
-
const lines = stdout.split('\n').filter(Boolean);
|
|
285
|
-
const line2023_01_03 = lines.findIndex((line)=>line.includes('2023-01-03'));
|
|
286
|
-
const line2023_01_02 = lines.findIndex((line)=>line.includes('2023-01-02'));
|
|
287
|
-
const line2023_01_01 = lines.findIndex((line)=>line.includes('2023-01-01'));
|
|
288
|
-
expect(line2023_01_03).toBeGreaterThan(0); // First line is header
|
|
289
|
-
expect(line2023_01_02).toBeGreaterThan(0);
|
|
290
|
-
expect(line2023_01_01).toBeGreaterThan(0);
|
|
291
|
-
// Check the order
|
|
292
|
-
expect(line2023_01_03).toBeLessThan(line2023_01_02);
|
|
293
|
-
expect(line2023_01_02).toBeLessThan(line2023_01_01);
|
|
294
|
-
});
|
|
295
|
-
test('excludes invitations when --no-invitations is specified', async ()=>{
|
|
296
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
297
|
-
projects: {
|
|
298
|
-
getById: vi.fn().mockResolvedValue({
|
|
299
|
-
members: [
|
|
300
|
-
{
|
|
301
|
-
id: 'user1',
|
|
302
|
-
isRobot: false,
|
|
303
|
-
role: 'developer'
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
id: 'user2',
|
|
307
|
-
isRobot: false,
|
|
308
|
-
role: 'admin'
|
|
309
|
-
}
|
|
310
|
-
]
|
|
311
|
-
})
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
mockApi({
|
|
315
|
-
apiVersion: USERS_API_VERSION,
|
|
316
|
-
uri: '/users/user1,user2'
|
|
317
|
-
}).reply(200, [
|
|
318
|
-
{
|
|
319
|
-
createdAt: '2023-01-01',
|
|
320
|
-
displayName: 'User One',
|
|
321
|
-
id: 'user1'
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
createdAt: '2023-01-02',
|
|
325
|
-
displayName: 'User Two',
|
|
326
|
-
id: 'user2'
|
|
327
|
-
}
|
|
328
|
-
]);
|
|
329
|
-
const { stdout } = await testCommand(List, [
|
|
330
|
-
'--no-invitations'
|
|
331
|
-
], {
|
|
332
|
-
mocks: defaultMocks
|
|
333
|
-
});
|
|
334
|
-
// Check that pending invitation is not in the output
|
|
335
|
-
expect(stdout).not.toContain('pending@example.com');
|
|
336
|
-
expect(stdout).not.toContain('viewer');
|
|
337
|
-
});
|
|
338
|
-
test('excludes robots when --no-robots is specified', async ()=>{
|
|
339
|
-
mockGetProjectCliClient.mockResolvedValue({
|
|
340
|
-
projects: {
|
|
341
|
-
getById: vi.fn().mockResolvedValue({
|
|
342
|
-
members: [
|
|
343
|
-
{
|
|
344
|
-
id: 'user1',
|
|
345
|
-
isRobot: false,
|
|
346
|
-
role: 'developer'
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
id: 'user2',
|
|
350
|
-
isRobot: false,
|
|
351
|
-
role: 'admin'
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
id: 'robot1',
|
|
355
|
-
isRobot: true,
|
|
356
|
-
role: 'viewer'
|
|
357
|
-
}
|
|
358
|
-
]
|
|
359
|
-
})
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
mockApi({
|
|
363
|
-
apiVersion: PROJECTS_API_VERSION,
|
|
364
|
-
uri: `/invitations/project/${testProjectId}`
|
|
365
|
-
}).reply(200, []);
|
|
366
|
-
mockApi({
|
|
367
|
-
apiVersion: USERS_API_VERSION,
|
|
368
|
-
uri: '/users/user1,user2'
|
|
369
|
-
}).reply(200, [
|
|
370
|
-
{
|
|
371
|
-
createdAt: '2023-01-01',
|
|
372
|
-
displayName: 'User One',
|
|
373
|
-
id: 'user1'
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
createdAt: '2023-01-02',
|
|
377
|
-
displayName: 'User Two',
|
|
378
|
-
id: 'user2'
|
|
379
|
-
}
|
|
380
|
-
]);
|
|
381
|
-
const { stdout } = await testCommand(List, [
|
|
382
|
-
'--no-robots'
|
|
383
|
-
], {
|
|
384
|
-
mocks: defaultMocks
|
|
385
|
-
});
|
|
386
|
-
// Check that robot is not in the output
|
|
387
|
-
expect(stdout).not.toContain('robot1');
|
|
388
|
-
expect(stdout).not.toContain('Robot One');
|
|
389
|
-
});
|
|
390
|
-
test('throws error when no project ID is found', async ()=>{
|
|
391
|
-
const { error } = await testCommand(List, [], {
|
|
392
|
-
mocks: {
|
|
393
|
-
...defaultMocks,
|
|
394
|
-
cliConfig: {
|
|
395
|
-
api: {
|
|
396
|
-
projectId: undefined
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
expect(error).toBeInstanceOf(Error);
|
|
402
|
-
expect(error?.message).toEqual(NO_PROJECT_ID);
|
|
403
|
-
expect(error?.oclif?.exit).toBe(1);
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
//# sourceMappingURL=list.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/users/__tests__/list.test.ts"],"sourcesContent":["import {runCommand} from '@oclif/test'\nimport {getProjectCliClient} from '@sanity/cli-core'\nimport {mockApi, testCommand} from '@sanity/cli-test'\nimport nock from 'nock'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\n\nimport {PROJECTS_API_VERSION} from '../../../services/projects.js'\nimport {USERS_API_VERSION} from '../../../services/user.js'\nimport {NO_PROJECT_ID} from '../../../util/errorMessages.js'\nimport {List} from '../list.js'\n\nconst testProjectId = 'test-project'\n\nconst defaultMocks = {\n cliConfig: {api: {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\nvi.mock('@sanity/cli-core', async () => {\n const actual = await vi.importActual('@sanity/cli-core')\n return {\n ...actual,\n getProjectCliClient: vi.fn(),\n }\n})\n\nconst mockGetProjectCliClient = vi.mocked(getProjectCliClient)\n\ndescribe('#list', () => {\n afterEach(() => {\n vi.clearAllMocks()\n const pending = nock.pendingMocks()\n nock.cleanAll()\n expect(pending, 'pending mocks').toEqual([])\n })\n\n test('--help works', async () => {\n const {stdout} = await runCommand(['users list', '--help'])\n\n expect(stdout).toContain('List all users of the project')\n })\n\n test('displays users correctly', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n ],\n }),\n },\n } as never)\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [])\n\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n ])\n\n const {stdout} = await testCommand(List, [], {mocks: defaultMocks})\n\n expect(stdout).toMatchSnapshot()\n })\n\n test('displays pending invitations correctly', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n ],\n }),\n },\n } as never)\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [\n {\n createdAt: '2023-02-01',\n email: 'pending@example.com',\n id: 'invite1',\n invitedByUser: {id: 'user2'},\n role: 'viewer',\n },\n ])\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n ])\n\n const {stdout} = await testCommand(List, [], {mocks: defaultMocks})\n\n expect(stdout).toMatchSnapshot()\n })\n\n test('displays an error if the API request fails', async () => {\n // Wait for 50ms to ensure the Promise.all is called\n setTimeout(\n () => mockGetProjectCliClient.mockRejectedValue(new Error('Internal server error')),\n 50,\n )\n\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [])\n\n const {error} = await testCommand(List, [], {mocks: defaultMocks})\n\n expect(error).toBeInstanceOf(Error)\n expect(error?.message).toContain(`Error fetching members for ${testProjectId}`)\n })\n\n test('sorts by role when --sort role is specified', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n {id: 'user3', isRobot: false, role: 'viewer'},\n ],\n }),\n },\n } as never)\n\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [])\n\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2,user3',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n {createdAt: '2023-01-03', displayName: 'User Three', id: 'user3'},\n ])\n\n const {stdout} = await testCommand(List, ['--sort', 'role'], {mocks: defaultMocks})\n\n // Check that we have all the roles in the output\n expect(stdout).toMatchSnapshot()\n\n // Split by lines and remove empty lines\n const lines = stdout.split('\\n').filter(Boolean)\n\n // Find the indices of lines containing each role\n const adminIndex = lines.findIndex((line) => line.includes('admin'))\n const developerIndex = lines.findIndex((line) => line.includes('developer'))\n const viewerIndex = lines.findIndex((line) => line.includes('viewer'))\n\n // Verify they all exist\n expect(adminIndex).toBeGreaterThan(-1)\n expect(developerIndex).toBeGreaterThan(-1)\n expect(viewerIndex).toBeGreaterThan(-1)\n\n // Now check the sort order (admin should come first alphabetically)\n expect(adminIndex).toBeLessThan(developerIndex)\n expect(developerIndex).toBeLessThan(viewerIndex)\n })\n\n test('sorts in descending order when --order desc is specified', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n {id: 'user3', isRobot: false, role: 'viewer'},\n ],\n }),\n },\n } as never)\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [])\n\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2,user3',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n {createdAt: '2023-01-03', displayName: 'User Three', id: 'user3'},\n ])\n\n const {stdout} = await testCommand(List, ['--order', 'desc'], {mocks: defaultMocks})\n\n // Check that we have all the dates in the output\n expect(stdout).toContain('2023-01-01')\n expect(stdout).toContain('2023-01-02')\n expect(stdout).toContain('2023-01-03')\n\n // By default, it sorts by date, so we need to check the reverse chronological order\n const lines = stdout.split('\\n').filter(Boolean)\n\n const line2023_01_03 = lines.findIndex((line) => line.includes('2023-01-03'))\n const line2023_01_02 = lines.findIndex((line) => line.includes('2023-01-02'))\n const line2023_01_01 = lines.findIndex((line) => line.includes('2023-01-01'))\n\n expect(line2023_01_03).toBeGreaterThan(0) // First line is header\n expect(line2023_01_02).toBeGreaterThan(0)\n expect(line2023_01_01).toBeGreaterThan(0)\n\n // Check the order\n expect(line2023_01_03).toBeLessThan(line2023_01_02)\n expect(line2023_01_02).toBeLessThan(line2023_01_01)\n })\n\n test('excludes invitations when --no-invitations is specified', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n ],\n }),\n },\n } as never)\n\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n ])\n\n const {stdout} = await testCommand(List, ['--no-invitations'], {mocks: defaultMocks})\n\n // Check that pending invitation is not in the output\n expect(stdout).not.toContain('pending@example.com')\n expect(stdout).not.toContain('viewer')\n })\n\n test('excludes robots when --no-robots is specified', async () => {\n mockGetProjectCliClient.mockResolvedValue({\n projects: {\n getById: vi.fn().mockResolvedValue({\n members: [\n {id: 'user1', isRobot: false, role: 'developer'},\n {id: 'user2', isRobot: false, role: 'admin'},\n {id: 'robot1', isRobot: true, role: 'viewer'},\n ],\n }),\n },\n } as never)\n\n mockApi({\n apiVersion: PROJECTS_API_VERSION,\n uri: `/invitations/project/${testProjectId}`,\n }).reply(200, [])\n\n mockApi({\n apiVersion: USERS_API_VERSION,\n uri: '/users/user1,user2',\n }).reply(200, [\n {createdAt: '2023-01-01', displayName: 'User One', id: 'user1'},\n {createdAt: '2023-01-02', displayName: 'User Two', id: 'user2'},\n ])\n\n const {stdout} = await testCommand(List, ['--no-robots'], {mocks: defaultMocks})\n\n // Check that robot is not in the output\n expect(stdout).not.toContain('robot1')\n expect(stdout).not.toContain('Robot One')\n })\n\n test('throws error when no project ID is found', async () => {\n const {error} = await testCommand(List, [], {\n mocks: {\n ...defaultMocks,\n cliConfig: {api: {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"],"names":["runCommand","getProjectCliClient","mockApi","testCommand","nock","afterEach","describe","expect","test","vi","PROJECTS_API_VERSION","USERS_API_VERSION","NO_PROJECT_ID","List","testProjectId","defaultMocks","cliConfig","api","projectId","projectRoot","directory","path","type","token","mock","actual","importActual","fn","mockGetProjectCliClient","mocked","clearAllMocks","pending","pendingMocks","cleanAll","toEqual","stdout","toContain","mockResolvedValue","projects","getById","members","id","isRobot","role","apiVersion","uri","reply","createdAt","displayName","mocks","toMatchSnapshot","email","invitedByUser","setTimeout","mockRejectedValue","Error","error","toBeInstanceOf","message","lines","split","filter","Boolean","adminIndex","findIndex","line","includes","developerIndex","viewerIndex","toBeGreaterThan","toBeLessThan","line2023_01_03","line2023_01_02","line2023_01_01","not","undefined","oclif","exit","toBe"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAa;AACtC,SAAQC,mBAAmB,QAAO,mBAAkB;AACpD,SAAQC,OAAO,EAAEC,WAAW,QAAO,mBAAkB;AACrD,OAAOC,UAAU,OAAM;AACvB,SAAQC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI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,OAAOE,SAASxB,OAAO,CAACtB;QAC/BL,OAAOiD,OAAOoB,OAAOC,MAAMC,IAAI,CAAC;IAClC;AACF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { isCi } from '@sanity/cli-core';
|
|
2
|
-
import { testHook } from '@sanity/cli-test';
|
|
3
|
-
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
|
-
import { setupTelemetry } from '../setupTelemetry.js';
|
|
5
|
-
// Hoisted mock functions to avoid initialization order issues
|
|
6
|
-
const { mockGet, mockGetUserConfig, mockSet } = vi.hoisted(()=>{
|
|
7
|
-
const mockGet = vi.fn();
|
|
8
|
-
const mockSet = vi.fn();
|
|
9
|
-
const mockGetUserConfig = vi.fn(()=>({
|
|
10
|
-
get: mockGet,
|
|
11
|
-
set: mockSet
|
|
12
|
-
}));
|
|
13
|
-
return {
|
|
14
|
-
mockGet,
|
|
15
|
-
mockGetUserConfig,
|
|
16
|
-
mockSet
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
vi.mock('../../../../../cli-core/src/util/getUserConfig.js', ()=>({
|
|
20
|
-
getUserConfig: mockGetUserConfig
|
|
21
|
-
}));
|
|
22
|
-
vi.mock('../../../../../cli-core/src/util/isCi.js', ()=>({
|
|
23
|
-
isCi: vi.fn(()=>false)
|
|
24
|
-
}));
|
|
25
|
-
const mockIsCi = vi.mocked(isCi);
|
|
26
|
-
describe('#setupTelemetry', ()=>{
|
|
27
|
-
beforeEach(()=>{
|
|
28
|
-
vi.clearAllMocks();
|
|
29
|
-
mockGet.mockReturnValue(false); // Default: not disclosed
|
|
30
|
-
});
|
|
31
|
-
test('shows telemetry disclosure when not previously disclosed', async ()=>{
|
|
32
|
-
const { stderr } = await testHook(setupTelemetry);
|
|
33
|
-
expect(mockGet).toHaveBeenCalledWith('telemetryDisclosed');
|
|
34
|
-
expect(mockSet).toHaveBeenCalledWith('telemetryDisclosed', expect.any(Number));
|
|
35
|
-
expect(stderr).toMatchInlineSnapshot(`
|
|
36
|
-
"
|
|
37
|
-
╭─────────────────────────────────────────────────────────────────────────────╮
|
|
38
|
-
│ │
|
|
39
|
-
│ The Sanity CLI now collects telemetry data on general usage and errors. │
|
|
40
|
-
│ This helps us improve Sanity and prioritize features. │
|
|
41
|
-
│ │
|
|
42
|
-
│ To opt in/out, run npx sanity telemetry enable/disable. │
|
|
43
|
-
│ │
|
|
44
|
-
│ Learn more here: │
|
|
45
|
-
│ https://www.sanity.io/telemetry │
|
|
46
|
-
│ │
|
|
47
|
-
╰─────────────────────────────────────────────────────────────────────────────╯
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
`);
|
|
51
|
-
});
|
|
52
|
-
test('does not show disclosure when already disclosed', async ()=>{
|
|
53
|
-
mockGet.mockReturnValue(1_234_567_890); // Already disclosed timestamp
|
|
54
|
-
const { stderr } = await testHook(setupTelemetry);
|
|
55
|
-
expect(mockGet).toHaveBeenCalledWith('telemetryDisclosed');
|
|
56
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
57
|
-
expect(stderr).toBe('');
|
|
58
|
-
});
|
|
59
|
-
test('does not show disclosure in CI environment', async ()=>{
|
|
60
|
-
mockIsCi.mockReturnValueOnce(true);
|
|
61
|
-
const { stderr } = await testHook(setupTelemetry);
|
|
62
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
63
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
64
|
-
expect(stderr).toBe('');
|
|
65
|
-
});
|
|
66
|
-
test('sets disclosure timestamp when showing disclosure', async ()=>{
|
|
67
|
-
const beforeTime = Date.now();
|
|
68
|
-
await testHook(setupTelemetry);
|
|
69
|
-
const afterTime = Date.now();
|
|
70
|
-
expect(mockSet).toHaveBeenCalledWith('telemetryDisclosed', expect.any(Number));
|
|
71
|
-
const timestamp = mockSet.mock.calls[0][1];
|
|
72
|
-
expect(timestamp).toBeGreaterThanOrEqual(beforeTime);
|
|
73
|
-
expect(timestamp).toBeLessThanOrEqual(afterTime);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
//# sourceMappingURL=setupTelemetry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/prerun/__tests__/setupTelemetry.test.ts"],"sourcesContent":["import {isCi} from '@sanity/cli-core'\nimport {testHook} from '@sanity/cli-test'\nimport {beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {setupTelemetry} from '../setupTelemetry.js'\n\n// Hoisted mock functions to avoid initialization order issues\nconst {mockGet, mockGetUserConfig, mockSet} = vi.hoisted(() => {\n const mockGet = vi.fn()\n const mockSet = vi.fn()\n const mockGetUserConfig = vi.fn(() => ({\n get: mockGet,\n set: mockSet,\n }))\n return {mockGet, mockGetUserConfig, mockSet}\n})\n\nvi.mock('../../../../../cli-core/src/util/getUserConfig.js', () => ({\n getUserConfig: mockGetUserConfig,\n}))\n\nvi.mock('../../../../../cli-core/src/util/isCi.js', () => ({\n isCi: vi.fn(() => false),\n}))\n\nconst mockIsCi = vi.mocked(isCi)\n\ndescribe('#setupTelemetry', () => {\n beforeEach(() => {\n vi.clearAllMocks()\n mockGet.mockReturnValue(false) // Default: not disclosed\n })\n\n test('shows telemetry disclosure when not previously disclosed', async () => {\n const {stderr} = await testHook<'prerun'>(setupTelemetry)\n\n expect(mockGet).toHaveBeenCalledWith('telemetryDisclosed')\n expect(mockSet).toHaveBeenCalledWith('telemetryDisclosed', expect.any(Number))\n expect(stderr).toMatchInlineSnapshot(`\n \"\n ╭─────────────────────────────────────────────────────────────────────────────╮\n │ │\n │ The Sanity CLI now collects telemetry data on general usage and errors. │\n │ This helps us improve Sanity and prioritize features. │\n │ │\n │ To opt in/out, run npx sanity telemetry enable/disable. │\n │ │\n │ Learn more here: │\n │ https://www.sanity.io/telemetry │\n │ │\n ╰─────────────────────────────────────────────────────────────────────────────╯\n\n \"\n `)\n })\n\n test('does not show disclosure when already disclosed', async () => {\n mockGet.mockReturnValue(1_234_567_890) // Already disclosed timestamp\n\n const {stderr} = await testHook<'prerun'>(setupTelemetry)\n\n expect(mockGet).toHaveBeenCalledWith('telemetryDisclosed')\n expect(mockSet).not.toHaveBeenCalled()\n expect(stderr).toBe('')\n })\n\n test('does not show disclosure in CI environment', async () => {\n mockIsCi.mockReturnValueOnce(true)\n\n const {stderr} = await testHook<'prerun'>(setupTelemetry)\n\n expect(mockGet).not.toHaveBeenCalled()\n expect(mockSet).not.toHaveBeenCalled()\n expect(stderr).toBe('')\n })\n\n test('sets disclosure timestamp when showing disclosure', async () => {\n const beforeTime = Date.now()\n\n await testHook<'prerun'>(setupTelemetry)\n\n const afterTime = Date.now()\n expect(mockSet).toHaveBeenCalledWith('telemetryDisclosed', expect.any(Number))\n\n const timestamp = mockSet.mock.calls[0][1]\n expect(timestamp).toBeGreaterThanOrEqual(beforeTime)\n expect(timestamp).toBeLessThanOrEqual(afterTime)\n })\n})\n"],"names":["isCi","testHook","beforeEach","describe","expect","test","vi","setupTelemetry","mockGet","mockGetUserConfig","mockSet","hoisted","fn","get","set","mock","getUserConfig","mockIsCi","mocked","clearAllMocks","mockReturnValue","stderr","toHaveBeenCalledWith","any","Number","toMatchInlineSnapshot","not","toHaveBeenCalled","toBe","mockReturnValueOnce","beforeTime","Date","now","afterTime","timestamp","calls","toBeGreaterThanOrEqual","toBeLessThanOrEqual"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAE7D,SAAQC,cAAc,QAAO,uBAAsB;AAEnD,8DAA8D;AAC9D,MAAM,EAACC,OAAO,EAAEC,iBAAiB,EAAEC,OAAO,EAAC,GAAGJ,GAAGK,OAAO,CAAC;IACvD,MAAMH,UAAUF,GAAGM,EAAE;IACrB,MAAMF,UAAUJ,GAAGM,EAAE;IACrB,MAAMH,oBAAoBH,GAAGM,EA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M;QAEzB,MAAM0B,YAAYF,KAAKC,GAAG;QAC1B5B,OAAOM,SAASY,oBAAoB,CAAC,sBAAsBlB,OAAOmB,GAAG,CAACC;QAEtE,MAAMU,YAAYxB,QAAQK,IAAI,CAACoB,KAAK,CAAC,EAAE,CAAC,EAAE;QAC1C/B,OAAO8B,WAAWE,sBAAsB,CAACN;QACzC1B,OAAO8B,WAAWG,mBAAmB,CAACJ;IACxC;AACF"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { getProjectCliClient } from '@sanity/cli-core';
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
-
import { createAlias, DATASET_ALIASES_API_VERSION, listAliases, removeAlias, updateAlias } from '../datasetAliases.js';
|
|
4
|
-
vi.mock(import('@sanity/cli-core'), async (importOriginal)=>{
|
|
5
|
-
const actual = await importOriginal();
|
|
6
|
-
return {
|
|
7
|
-
...actual,
|
|
8
|
-
getProjectCliClient: vi.fn()
|
|
9
|
-
};
|
|
10
|
-
});
|
|
11
|
-
const mockClient = {
|
|
12
|
-
request: vi.fn()
|
|
13
|
-
};
|
|
14
|
-
const mockGetProjectCliClient = vi.mocked(getProjectCliClient);
|
|
15
|
-
beforeEach(()=>{
|
|
16
|
-
mockGetProjectCliClient.mockResolvedValue(mockClient);
|
|
17
|
-
});
|
|
18
|
-
afterEach(()=>{
|
|
19
|
-
vi.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
describe('#listAliases', ()=>{
|
|
22
|
-
test('calls client.request with correct parameters', async ()=>{
|
|
23
|
-
const mockAliases = [
|
|
24
|
-
{
|
|
25
|
-
datasetName: 'production',
|
|
26
|
-
name: 'prod'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
datasetName: 'development',
|
|
30
|
-
name: 'dev'
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
mockClient.request.mockResolvedValue(mockAliases);
|
|
34
|
-
const result = await listAliases('test-project');
|
|
35
|
-
expect(mockGetProjectCliClient).toHaveBeenCalledWith({
|
|
36
|
-
apiVersion: DATASET_ALIASES_API_VERSION,
|
|
37
|
-
projectId: 'test-project',
|
|
38
|
-
requireUser: true
|
|
39
|
-
});
|
|
40
|
-
expect(mockClient.request).toHaveBeenCalledWith({
|
|
41
|
-
uri: '/aliases'
|
|
42
|
-
});
|
|
43
|
-
expect(result).toBe(mockAliases);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('#createAlias', ()=>{
|
|
47
|
-
test('calls client.request with correct parameters when datasetName is provided', async ()=>{
|
|
48
|
-
const mockResponse = {
|
|
49
|
-
aliasName: 'prod',
|
|
50
|
-
datasetName: 'production'
|
|
51
|
-
};
|
|
52
|
-
mockClient.request.mockResolvedValue(mockResponse);
|
|
53
|
-
const result = await createAlias('test-project', 'prod', 'production');
|
|
54
|
-
expect(mockGetProjectCliClient).toHaveBeenCalledWith({
|
|
55
|
-
apiVersion: DATASET_ALIASES_API_VERSION,
|
|
56
|
-
projectId: 'test-project',
|
|
57
|
-
requireUser: true
|
|
58
|
-
});
|
|
59
|
-
expect(mockClient.request).toHaveBeenCalledWith({
|
|
60
|
-
body: {
|
|
61
|
-
datasetName: 'production'
|
|
62
|
-
},
|
|
63
|
-
method: 'PUT',
|
|
64
|
-
uri: '/aliases/prod'
|
|
65
|
-
});
|
|
66
|
-
expect(result).toBe(mockResponse);
|
|
67
|
-
});
|
|
68
|
-
test('calls client.request with undefined body when datasetName is null', async ()=>{
|
|
69
|
-
const mockResponse = {
|
|
70
|
-
aliasName: 'prod',
|
|
71
|
-
datasetName: null
|
|
72
|
-
};
|
|
73
|
-
mockClient.request.mockResolvedValue(mockResponse);
|
|
74
|
-
const result = await createAlias('test-project', 'prod', null);
|
|
75
|
-
expect(mockGetProjectCliClient).toHaveBeenCalledWith({
|
|
76
|
-
apiVersion: DATASET_ALIASES_API_VERSION,
|
|
77
|
-
projectId: 'test-project',
|
|
78
|
-
requireUser: true
|
|
79
|
-
});
|
|
80
|
-
expect(mockClient.request).toHaveBeenCalledWith({
|
|
81
|
-
body: undefined,
|
|
82
|
-
method: 'PUT',
|
|
83
|
-
uri: '/aliases/prod'
|
|
84
|
-
});
|
|
85
|
-
expect(result).toBe(mockResponse);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('#removeAlias', ()=>{
|
|
89
|
-
test('calls client.request with correct parameters', async ()=>{
|
|
90
|
-
const mockResponse = {
|
|
91
|
-
deleted: true
|
|
92
|
-
};
|
|
93
|
-
mockClient.request.mockResolvedValue(mockResponse);
|
|
94
|
-
const result = await removeAlias('test-project', 'test-alias');
|
|
95
|
-
expect(mockGetProjectCliClient).toHaveBeenCalledWith({
|
|
96
|
-
apiVersion: DATASET_ALIASES_API_VERSION,
|
|
97
|
-
projectId: 'test-project',
|
|
98
|
-
requireUser: true
|
|
99
|
-
});
|
|
100
|
-
expect(mockClient.request).toHaveBeenCalledWith({
|
|
101
|
-
method: 'DELETE',
|
|
102
|
-
uri: '/aliases/test-alias'
|
|
103
|
-
});
|
|
104
|
-
expect(result).toBe(mockResponse);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe('#updateAlias', ()=>{
|
|
108
|
-
test('calls client.request with correct parameters', async ()=>{
|
|
109
|
-
const mockResponse = {
|
|
110
|
-
aliasName: 'prod',
|
|
111
|
-
datasetName: 'production'
|
|
112
|
-
};
|
|
113
|
-
mockClient.request.mockResolvedValue(mockResponse);
|
|
114
|
-
const result = await updateAlias('test-project', 'prod', 'production');
|
|
115
|
-
expect(mockGetProjectCliClient).toHaveBeenCalledWith({
|
|
116
|
-
apiVersion: DATASET_ALIASES_API_VERSION,
|
|
117
|
-
projectId: 'test-project',
|
|
118
|
-
requireUser: true
|
|
119
|
-
});
|
|
120
|
-
expect(mockClient.request).toHaveBeenCalledWith({
|
|
121
|
-
body: {
|
|
122
|
-
datasetName: 'production'
|
|
123
|
-
},
|
|
124
|
-
method: 'PATCH',
|
|
125
|
-
uri: '/aliases/prod'
|
|
126
|
-
});
|
|
127
|
-
expect(result).toBe(mockResponse);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
//# sourceMappingURL=datasetAliases.test.js.map
|