@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/getCliVersion.test.ts"],"sourcesContent":["import {packageDirectory} from 'package-directory'\nimport {describe, expect, test, vi} from 'vitest'\n\nimport {getCliVersion} from '../getCliVersion.js'\nimport {readPackageJson} from '../readPackageJson.js'\n\nvi.mock('package-directory')\nvi.mock(import('../readPackageJson.js'))\n\ndescribe('#getCliVersion', () => {\n test('should return the version of the @sanity/cli package', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce('/test/path')\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: '@sanity/cli',\n version: '1.0.0',\n })\n\n const version = await getCliVersion()\n\n expect(version).toBe('1.0.0')\n })\n\n test('should throw an error if the package.json is not found', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce('/test/path')\n vi.mocked(readPackageJson).mockRejectedValueOnce(new Error('Package.json not found'))\n\n await expect(getCliVersion()).rejects.toThrow('Package.json not found')\n })\n\n test('should throw an error if cli path is not found', async () => {\n vi.mocked(packageDirectory).mockResolvedValueOnce(undefined)\n\n await expect(getCliVersion()).rejects.toThrow('Unable to resolve root of @sanity/cli module')\n })\n})\n"],"names":["packageDirectory","describe","expect","test","vi","getCliVersion","readPackageJson","mock","mocked","mockResolvedValueOnce","name","version","toBe","mockRejectedValueOnce","Error","rejects","toThrow","undefined"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oBAAmB;AAClD,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAEjD,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,eAAe,QAAO,wBAAuB;AAErDF,GAAGG,IAAI,CAAC;AACRH,GAAGG,IAAI,CAAC,MAAM,CAAC;AAEfN,SAAS,kBAAkB;IACzBE,KAAK,wDAAwD;QAC3DC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAAC;QAClDL,GAAGI,MAAM,CAACF,iBAAiBG,qBAAqB,CAAC;YAC/CC,MAAM;YACNC,SAAS;QACX;QAEA,MAAMA,UAAU,MAAMN;QAEtBH,OAAOS,SAASC,IAAI,CAAC;IACvB;IAEAT,KAAK,0DAA0D;QAC7DC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAAC;QAClDL,GAAGI,MAAM,CAACF,iBAAiBO,qBAAqB,CAAC,IAAIC,MAAM;QAE3D,MAAMZ,OAAOG,iBAAiBU,OAAO,CAACC,OAAO,CAAC;IAChD;IAEAb,KAAK,kDAAkD;QACrDC,GAAGI,MAAM,CAACR,kBAAkBS,qBAAqB,CAACQ;QAElD,MAAMf,OAAOG,iBAAiBU,OAAO,CAACC,OAAO,CAAC;IAChD;AACF"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
// Import the mocked modules
|
|
3
|
-
import resolveFrom from 'resolve-from';
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
5
|
-
import { getLocalPackageVersion } from '../getLocalPackageVersion';
|
|
6
|
-
import { readPackageJson } from '../readPackageJson.js';
|
|
7
|
-
// Mock the dependencies
|
|
8
|
-
vi.mock('resolve-from', ()=>({
|
|
9
|
-
default: {
|
|
10
|
-
silent: vi.fn()
|
|
11
|
-
}
|
|
12
|
-
}));
|
|
13
|
-
vi.mock('../readPackageJson', ()=>({
|
|
14
|
-
readPackageJson: vi.fn()
|
|
15
|
-
}));
|
|
16
|
-
describe('getLocalPackageVersion', ()=>{
|
|
17
|
-
const mockWorkDir = '/mock/work/dir';
|
|
18
|
-
const mockModuleId = '@sanity/test';
|
|
19
|
-
beforeEach(()=>{
|
|
20
|
-
vi.resetAllMocks();
|
|
21
|
-
});
|
|
22
|
-
afterEach(()=>{
|
|
23
|
-
vi.clearAllMocks();
|
|
24
|
-
});
|
|
25
|
-
test('returns version when package.json is directly resolved', async ()=>{
|
|
26
|
-
const mockPath = join(mockWorkDir, 'node_modules', mockModuleId, 'package.json');
|
|
27
|
-
const mockVersion = '1.0.0';
|
|
28
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath);
|
|
29
|
-
vi.mocked(readPackageJson).mockResolvedValueOnce({
|
|
30
|
-
name: mockModuleId,
|
|
31
|
-
version: mockVersion
|
|
32
|
-
});
|
|
33
|
-
const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
|
|
34
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
|
|
35
|
-
expect(readPackageJson).toHaveBeenCalledWith(mockPath);
|
|
36
|
-
expect(result).toBe(mockVersion);
|
|
37
|
-
});
|
|
38
|
-
test('handles packages with exports field when direct resolution fails', async ()=>{
|
|
39
|
-
const modulePath = join(mockWorkDir, 'node_modules', mockModuleId, 'index.js');
|
|
40
|
-
const moduleRoot = join(mockWorkDir, 'node_modules', mockModuleId);
|
|
41
|
-
const manifestPath = join(moduleRoot, 'package.json');
|
|
42
|
-
const mockVersion = '2.0.0';
|
|
43
|
-
// First call returns null (direct package.json resolution fails)
|
|
44
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
|
|
45
|
-
// Second call succeeds (resolving the module itself)
|
|
46
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(modulePath);
|
|
47
|
-
vi.mocked(readPackageJson).mockResolvedValueOnce({
|
|
48
|
-
name: mockModuleId,
|
|
49
|
-
version: mockVersion
|
|
50
|
-
});
|
|
51
|
-
const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
|
|
52
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
|
|
53
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId);
|
|
54
|
-
expect(readPackageJson).toHaveBeenCalledWith(manifestPath);
|
|
55
|
-
expect(result).toBe(mockVersion);
|
|
56
|
-
});
|
|
57
|
-
test('returns undefined when module cannot be resolved at all', async ()=>{
|
|
58
|
-
// Both resolution attempts fail
|
|
59
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
|
|
60
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined);
|
|
61
|
-
const result = await getLocalPackageVersion(mockModuleId, mockWorkDir);
|
|
62
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'));
|
|
63
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId);
|
|
64
|
-
expect(readPackageJson).not.toHaveBeenCalled();
|
|
65
|
-
expect(result).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
test('uses process.cwd() when workDir is not provided', async ()=>{
|
|
68
|
-
const mockCwd = '/current/working/dir';
|
|
69
|
-
const mockPath = join(mockCwd, 'node_modules', mockModuleId, 'package.json');
|
|
70
|
-
const mockVersion = '3.0.0';
|
|
71
|
-
vi.spyOn(process, 'cwd').mockReturnValue(mockCwd);
|
|
72
|
-
vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath);
|
|
73
|
-
vi.mocked(readPackageJson).mockResolvedValueOnce({
|
|
74
|
-
name: mockModuleId,
|
|
75
|
-
version: mockVersion
|
|
76
|
-
});
|
|
77
|
-
const result = await getLocalPackageVersion(mockModuleId, '');
|
|
78
|
-
expect(resolveFrom.silent).toHaveBeenCalledWith(mockCwd, join(mockModuleId, 'package.json'));
|
|
79
|
-
expect(readPackageJson).toHaveBeenCalledWith(mockPath);
|
|
80
|
-
expect(result).toBe(mockVersion);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=getLocalPackageVersion.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/getLocalPackageVersion.test.ts"],"sourcesContent":["import {join} from 'node:path'\n\n// Import the mocked modules\nimport resolveFrom from 'resolve-from'\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {getLocalPackageVersion} from '../getLocalPackageVersion'\nimport {readPackageJson} from '../readPackageJson.js'\n\n// Mock the dependencies\nvi.mock('resolve-from', () => ({\n default: {\n silent: vi.fn(),\n },\n}))\n\nvi.mock('../readPackageJson', () => ({\n readPackageJson: vi.fn(),\n}))\n\ndescribe('getLocalPackageVersion', () => {\n const mockWorkDir = '/mock/work/dir'\n const mockModuleId = '@sanity/test'\n\n beforeEach(() => {\n vi.resetAllMocks()\n })\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('returns version when package.json is directly resolved', async () => {\n const mockPath = join(mockWorkDir, 'node_modules', mockModuleId, 'package.json')\n const mockVersion = '1.0.0'\n\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(readPackageJson).toHaveBeenCalledWith(mockPath)\n expect(result).toBe(mockVersion)\n })\n\n test('handles packages with exports field when direct resolution fails', async () => {\n const modulePath = join(mockWorkDir, 'node_modules', mockModuleId, 'index.js')\n const moduleRoot = join(mockWorkDir, 'node_modules', mockModuleId)\n const manifestPath = join(moduleRoot, 'package.json')\n const mockVersion = '2.0.0'\n\n // First call returns null (direct package.json resolution fails)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n // Second call succeeds (resolving the module itself)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(modulePath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId)\n expect(readPackageJson).toHaveBeenCalledWith(manifestPath)\n expect(result).toBe(mockVersion)\n })\n\n test('returns undefined when module cannot be resolved at all', async () => {\n // Both resolution attempts fail\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(undefined)\n\n const result = await getLocalPackageVersion(mockModuleId, mockWorkDir)\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, join(mockModuleId, 'package.json'))\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockWorkDir, mockModuleId)\n expect(readPackageJson).not.toHaveBeenCalled()\n expect(result).toBeUndefined()\n })\n\n test('uses process.cwd() when workDir is not provided', async () => {\n const mockCwd = '/current/working/dir'\n const mockPath = join(mockCwd, 'node_modules', mockModuleId, 'package.json')\n const mockVersion = '3.0.0'\n\n vi.spyOn(process, 'cwd').mockReturnValue(mockCwd)\n vi.mocked(resolveFrom.silent).mockReturnValueOnce(mockPath)\n vi.mocked(readPackageJson).mockResolvedValueOnce({\n name: mockModuleId,\n version: mockVersion,\n })\n\n const result = await getLocalPackageVersion(mockModuleId, '')\n\n expect(resolveFrom.silent).toHaveBeenCalledWith(mockCwd, join(mockModuleId, 'package.json'))\n expect(readPackageJson).toHaveBeenCalledWith(mockPath)\n expect(result).toBe(mockVersion)\n })\n})\n"],"names":["join","resolveFrom","afterEach","beforeEach","describe","expect","test","vi","getLocalPackageVersion","readPackageJson","mock","default","silent","fn","mockWorkDir","mockModuleId","resetAllMocks","clearAllMocks","mockPath","mockVersion","mocked","mockReturnValueOnce","mockResolvedValueOnce","name","version","result","toHaveBeenCalledWith","toBe","modulePath","moduleRoot","manifestPath","undefined","not","toHaveBeenCalled","toBeUndefined","mockCwd","spyOn","process","mockReturnValue"],"mappings":"AAAA,SAAQA,IAAI,QAAO,YAAW;AAE9B,4BAA4B;AAC5B,OAAOC,iBAAiB,eAAc;AACtC,SAAQC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAExE,SAAQC,sBAAsB,QAAO,4BAA2B;AAChE,SAAQC,eAAe,QAAO,wBAAuB;AAErD,wBAAwB;AACxBF,GAAGG,IAAI,CAAC,gBAAgB,IAAO,CAAA;QAC7BC,SAAS;YACPC,QAAQL,GAAGM,EAAE;QACf;IACF,CAAA;AAEAN,GAAGG,IAAI,CAAC,sBAAsB,IAAO,CAAA;QACnCD,iBAAiBF,GAAGM,EAAE;IACxB,CAAA;AAEAT,SAAS,0BAA0B;IACjC,MAAMU,cAAc;IACpB,MAAMC,eAAe;IAErBZ,WAAW;QACTI,GAAGS,aAAa;IAClB;IAEAd,UAAU;QACRK,GAAGU,aAAa;IAClB;IAEAX,KAAK,0DAA0D;QAC7D,MAAMY,WAAWlB,KAAKc,aAAa,gBAAgBC,cAAc;QACjE,MAAMI,cAAc;QAEpBZ,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACH;QAClDX,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOI,iBAAiBiB,oBAAoB,CAACR;QAC7Cb,OAAOoB,QAAQE,IAAI,CAACR;IACtB;IAEAb,KAAK,oEAAoE;QACvE,MAAMsB,aAAa5B,KAAKc,aAAa,gBAAgBC,cAAc;QACnE,MAAMc,aAAa7B,KAAKc,aAAa,gBAAgBC;QACrD,MAAMe,eAAe9B,KAAK6B,YAAY;QACtC,MAAMV,cAAc;QAEpB,iEAAiE;QACjEZ,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAClD,qDAAqD;QACrDxB,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACO;QAClDrB,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAaC;QAC7DV,OAAOI,iBAAiBiB,oBAAoB,CAACI;QAC7CzB,OAAOoB,QAAQE,IAAI,CAACR;IACtB;IAEAb,KAAK,2DAA2D;QAC9D,gCAAgC;QAChCC,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAClDxB,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACU;QAElD,MAAMN,SAAS,MAAMjB,uBAAuBO,cAAcD;QAE1DT,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAad,KAAKe,cAAc;QAChFV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACZ,aAAaC;QAC7DV,OAAOI,iBAAiBuB,GAAG,CAACC,gBAAgB;QAC5C5B,OAAOoB,QAAQS,aAAa;IAC9B;IAEA5B,KAAK,mDAAmD;QACtD,MAAM6B,UAAU;QAChB,MAAMjB,WAAWlB,KAAKmC,SAAS,gBAAgBpB,cAAc;QAC7D,MAAMI,cAAc;QAEpBZ,GAAG6B,KAAK,CAACC,SAAS,OAAOC,eAAe,CAACH;QACzC5B,GAAGa,MAAM,CAACnB,YAAYW,MAAM,EAAES,mBAAmB,CAACH;QAClDX,GAAGa,MAAM,CAACX,iBAAiBa,qBAAqB,CAAC;YAC/CC,MAAMR;YACNS,SAASL;QACX;QAEA,MAAMM,SAAS,MAAMjB,uBAAuBO,cAAc;QAE1DV,OAAOJ,YAAYW,MAAM,EAAEc,oBAAoB,CAACS,SAASnC,KAAKe,cAAc;QAC5EV,OAAOI,iBAAiBiB,oBAAoB,CAACR;QAC7Cb,OAAOoB,QAAQE,IAAI,CAACR;IACtB;AACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { getWorkspace } from '../getWorkspace';
|
|
3
|
-
const mockWorkspaces = [
|
|
4
|
-
{
|
|
5
|
-
basePath: '/',
|
|
6
|
-
dataset: 'production',
|
|
7
|
-
name: 'test',
|
|
8
|
-
projectId: 'test-project'
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
basePath: '/',
|
|
12
|
-
dataset: 'staging',
|
|
13
|
-
name: 'test-staging',
|
|
14
|
-
projectId: 'test-project'
|
|
15
|
-
}
|
|
16
|
-
];
|
|
17
|
-
describe('#getWorkspace', ()=>{
|
|
18
|
-
test('returns a default workspace if only one exists', ()=>{
|
|
19
|
-
const workspace = getWorkspace(mockWorkspaces.slice(0, 1));
|
|
20
|
-
expect(workspace).toMatchObject(mockWorkspaces[0]);
|
|
21
|
-
});
|
|
22
|
-
test('returns a workspace by name if multiple exist', ()=>{
|
|
23
|
-
const workspace = getWorkspace(mockWorkspaces, 'test-staging');
|
|
24
|
-
expect(workspace).toMatchObject(mockWorkspaces[1]);
|
|
25
|
-
});
|
|
26
|
-
test('throws an error if no workspaces exist', ()=>{
|
|
27
|
-
expect(()=>getWorkspace([])).toThrowError('No workspaces found');
|
|
28
|
-
});
|
|
29
|
-
test('throws an error if multiple workspaces exist but no name is specified', ()=>{
|
|
30
|
-
expect(()=>getWorkspace(mockWorkspaces)).toThrowError(`Multiple workspaces found. Please specify which workspace to use with "--workspace". Available workspaces: test, test-staging`);
|
|
31
|
-
});
|
|
32
|
-
test('throws an error if workspace with specified name does not exist', ()=>{
|
|
33
|
-
expect(()=>getWorkspace(mockWorkspaces, 'test-dev')).toThrowError(`Could not find "test-dev" workspace. Available workspaces: test, test-staging`);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=getWorkspace.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/getWorkspace.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {getWorkspace} from '../getWorkspace'\n\nconst mockWorkspaces = [\n {\n basePath: '/',\n dataset: 'production',\n name: 'test',\n projectId: 'test-project',\n },\n {\n basePath: '/',\n dataset: 'staging',\n name: 'test-staging',\n projectId: 'test-project',\n },\n]\n\ndescribe('#getWorkspace', () => {\n test('returns a default workspace if only one exists', () => {\n const workspace = getWorkspace(mockWorkspaces.slice(0, 1))\n expect(workspace).toMatchObject(mockWorkspaces[0])\n })\n\n test('returns a workspace by name if multiple exist', () => {\n const workspace = getWorkspace(mockWorkspaces, 'test-staging')\n expect(workspace).toMatchObject(mockWorkspaces[1])\n })\n\n test('throws an error if no workspaces exist', () => {\n expect(() => getWorkspace([])).toThrowError('No workspaces found')\n })\n\n test('throws an error if multiple workspaces exist but no name is specified', () => {\n expect(() => getWorkspace(mockWorkspaces)).toThrowError(\n `Multiple workspaces found. Please specify which workspace to use with \"--workspace\". Available workspaces: test, test-staging`,\n )\n })\n\n test('throws an error if workspace with specified name does not exist', () => {\n expect(() => getWorkspace(mockWorkspaces, 'test-dev')).toThrowError(\n `Could not find \"test-dev\" workspace. Available workspaces: test, test-staging`,\n )\n })\n})\n"],"names":["describe","expect","test","getWorkspace","mockWorkspaces","basePath","dataset","name","projectId","workspace","slice","toMatchObject","toThrowError"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,YAAY,QAAO,kBAAiB;AAE5C,MAAMC,iBAAiB;IACrB;QACEC,UAAU;QACVC,SAAS;QACTC,MAAM;QACNC,WAAW;IACb;IACA;QACEH,UAAU;QACVC,SAAS;QACTC,MAAM;QACNC,WAAW;IACb;CACD;AAEDR,SAAS,iBAAiB;IACxBE,KAAK,kDAAkD;QACrD,MAAMO,YAAYN,aAAaC,eAAeM,KAAK,CAAC,GAAG;QACvDT,OAAOQ,WAAWE,aAAa,CAACP,cAAc,CAAC,EAAE;IACnD;IAEAF,KAAK,iDAAiD;QACpD,MAAMO,YAAYN,aAAaC,gBAAgB;QAC/CH,OAAOQ,WAAWE,aAAa,CAACP,cAAc,CAAC,EAAE;IACnD;IAEAF,KAAK,0CAA0C;QAC7CD,OAAO,IAAME,aAAa,EAAE,GAAGS,YAAY,CAAC;IAC9C;IAEAV,KAAK,yEAAyE;QAC5ED,OAAO,IAAME,aAAaC,iBAAiBQ,YAAY,CACrD,CAAC,6HAA6H,CAAC;IAEnI;IAEAV,KAAK,mEAAmE;QACtED,OAAO,IAAME,aAAaC,gBAAgB,aAAaQ,YAAY,CACjE,CAAC,6EAA6E,CAAC;IAEnF;AACF"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Import the mocked module
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
|
-
import { readPackageJson } from '../readPackageJson';
|
|
5
|
-
// Mock the node:fs/promises module
|
|
6
|
-
vi.mock('node:fs/promises', ()=>({
|
|
7
|
-
readFile: vi.fn()
|
|
8
|
-
}));
|
|
9
|
-
describe('readPackageJson', ()=>{
|
|
10
|
-
const mockFilePath = '/mock/path/package.json';
|
|
11
|
-
beforeEach(()=>{
|
|
12
|
-
vi.resetAllMocks();
|
|
13
|
-
});
|
|
14
|
-
afterEach(()=>{
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
});
|
|
17
|
-
test('returns parsed package.json content when file is valid', async ()=>{
|
|
18
|
-
const mockPackage = {
|
|
19
|
-
dependencies: {
|
|
20
|
-
'some-dep': '^1.0.0'
|
|
21
|
-
},
|
|
22
|
-
devDependencies: {
|
|
23
|
-
'some-dev-dep': '^2.0.0'
|
|
24
|
-
},
|
|
25
|
-
name: '@sanity/test-package',
|
|
26
|
-
version: '1.0.0'
|
|
27
|
-
};
|
|
28
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(mockPackage));
|
|
29
|
-
const result = await readPackageJson(mockFilePath);
|
|
30
|
-
expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
|
|
31
|
-
expect(result).toEqual(mockPackage);
|
|
32
|
-
});
|
|
33
|
-
test('throws error when file cannot be read', async ()=>{
|
|
34
|
-
const mockError = new Error('File not found');
|
|
35
|
-
vi.mocked(readFile).mockRejectedValueOnce(mockError);
|
|
36
|
-
await expect(readPackageJson(mockFilePath)).rejects.toThrow('Failed to read');
|
|
37
|
-
expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
|
|
38
|
-
});
|
|
39
|
-
test('throws error when JSON is invalid', async ()=>{
|
|
40
|
-
vi.mocked(readFile).mockResolvedValueOnce('invalid json content');
|
|
41
|
-
await expect(readPackageJson(mockFilePath)).rejects.toThrow();
|
|
42
|
-
expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
|
|
43
|
-
});
|
|
44
|
-
test('throws error when required fields are missing', async ()=>{
|
|
45
|
-
// Missing name field
|
|
46
|
-
const invalidPackage = {
|
|
47
|
-
version: '1.0.0'
|
|
48
|
-
};
|
|
49
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(invalidPackage));
|
|
50
|
-
await expect(readPackageJson(mockFilePath)).rejects.toThrow('Invalid package.json');
|
|
51
|
-
expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
|
|
52
|
-
});
|
|
53
|
-
test('handles optional fields correctly', async ()=>{
|
|
54
|
-
// Only required fields, no optional ones
|
|
55
|
-
const minimalPackage = {
|
|
56
|
-
name: '@sanity/minimal',
|
|
57
|
-
version: '1.0.0'
|
|
58
|
-
};
|
|
59
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(minimalPackage));
|
|
60
|
-
const result = await readPackageJson(mockFilePath);
|
|
61
|
-
expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8');
|
|
62
|
-
expect(result).toEqual(minimalPackage);
|
|
63
|
-
expect(result.dependencies).toBeUndefined();
|
|
64
|
-
expect(result.devDependencies).toBeUndefined();
|
|
65
|
-
expect(result.peerDependencies).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=readPackageJson.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/readPackageJson.test.ts"],"sourcesContent":["// Import the mocked module\nimport {readFile} from 'node:fs/promises'\n\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {readPackageJson} from '../readPackageJson'\n\n// Mock the node:fs/promises module\nvi.mock('node:fs/promises', () => ({\n readFile: vi.fn(),\n}))\n\ndescribe('readPackageJson', () => {\n const mockFilePath = '/mock/path/package.json'\n\n beforeEach(() => {\n vi.resetAllMocks()\n })\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('returns parsed package.json content when file is valid', async () => {\n const mockPackage = {\n dependencies: {\n 'some-dep': '^1.0.0',\n },\n devDependencies: {\n 'some-dev-dep': '^2.0.0',\n },\n name: '@sanity/test-package',\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(mockPackage))\n\n const result = await readPackageJson(mockFilePath)\n\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n expect(result).toEqual(mockPackage)\n })\n\n test('throws error when file cannot be read', async () => {\n const mockError = new Error('File not found')\n vi.mocked(readFile).mockRejectedValueOnce(mockError)\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow('Failed to read')\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('throws error when JSON is invalid', async () => {\n vi.mocked(readFile).mockResolvedValueOnce('invalid json content')\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow()\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('throws error when required fields are missing', async () => {\n // Missing name field\n const invalidPackage = {\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(invalidPackage))\n\n await expect(readPackageJson(mockFilePath)).rejects.toThrow('Invalid package.json')\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n })\n\n test('handles optional fields correctly', async () => {\n // Only required fields, no optional ones\n const minimalPackage = {\n name: '@sanity/minimal',\n version: '1.0.0',\n }\n\n vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(minimalPackage))\n\n const result = await readPackageJson(mockFilePath)\n\n expect(readFile).toHaveBeenCalledWith(mockFilePath, 'utf8')\n expect(result).toEqual(minimalPackage)\n expect(result.dependencies).toBeUndefined()\n expect(result.devDependencies).toBeUndefined()\n expect(result.peerDependencies).toBeUndefined()\n })\n})\n"],"names":["readFile","afterEach","beforeEach","describe","expect","test","vi","readPackageJson","mock","fn","mockFilePath","resetAllMocks","clearAllMocks","mockPackage","dependencies","devDependencies","name","version","mocked","mockResolvedValueOnce","JSON","stringify","result","toHaveBeenCalledWith","toEqual","mockError","Error","mockRejectedValueOnce","rejects","toThrow","invalidPackage","minimalPackage","toBeUndefined","peerDependencies"],"mappings":"AAAA,2BAA2B;AAC3B,SAAQA,QAAQ,QAAO,mBAAkB;AAEzC,SAAQC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAExE,SAAQC,eAAe,QAAO,qBAAoB;AAElD,mCAAmC;AACnCD,GAAGE,IAAI,CAAC,oBAAoB,IAAO,CAAA;QACjCR,UAAUM,GAAGG,EAAE;IACjB,CAAA;AAEAN,SAAS,mBAAmB;IAC1B,MAAMO,eAAe;IAErBR,WAAW;QACTI,GAAGK,aAAa;IAClB;IAEAV,UAAU;QACRK,GAAGM,aAAa;IAClB;IAEAP,KAAK,0DAA0D;QAC7D,MAAMQ,cAAc;YAClBC,cAAc;gBACZ,YAAY;YACd;YACAC,iBAAiB;gBACf,gBAAgB;YAClB;YACAC,MAAM;YACNC,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACR;QAEzD,MAAMS,SAAS,MAAMf,gBAAgBG;QAErCN,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;QACpDN,OAAOkB,QAAQE,OAAO,CAACX;IACzB;IAEAR,KAAK,yCAAyC;QAC5C,MAAMoB,YAAY,IAAIC,MAAM;QAC5BpB,GAAGY,MAAM,CAAClB,UAAU2B,qBAAqB,CAACF;QAE1C,MAAMrB,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO,CAAC;QAC5DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,qCAAqC;QACxCC,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAAC;QAE1C,MAAMf,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO;QAC3DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,iDAAiD;QACpD,qBAAqB;QACrB,MAAMyB,iBAAiB;YACrBb,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACS;QAEzD,MAAM1B,OAAOG,gBAAgBG,eAAekB,OAAO,CAACC,OAAO,CAAC;QAC5DzB,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;IACtD;IAEAL,KAAK,qCAAqC;QACxC,yCAAyC;QACzC,MAAM0B,iBAAiB;YACrBf,MAAM;YACNC,SAAS;QACX;QAEAX,GAAGY,MAAM,CAAClB,UAAUmB,qBAAqB,CAACC,KAAKC,SAAS,CAACU;QAEzD,MAAMT,SAAS,MAAMf,gBAAgBG;QAErCN,OAAOJ,UAAUuB,oBAAoB,CAACb,cAAc;QACpDN,OAAOkB,QAAQE,OAAO,CAACO;QACvB3B,OAAOkB,OAAOR,YAAY,EAAEkB,aAAa;QACzC5B,OAAOkB,OAAOP,eAAe,EAAEiB,aAAa;QAC5C5B,OAAOkB,OAAOW,gBAAgB,EAAED,aAAa;IAC/C;AACF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
-
import { warnAboutMissingAppId } from '../warnAboutMissingAppId';
|
|
3
|
-
describe('warnAboutMissingAppId', ()=>{
|
|
4
|
-
const mockOutput = {
|
|
5
|
-
error: vi.fn(),
|
|
6
|
-
log: vi.fn(),
|
|
7
|
-
warn: vi.fn()
|
|
8
|
-
};
|
|
9
|
-
test('should log the expected warning when called', ()=>{
|
|
10
|
-
warnAboutMissingAppId({
|
|
11
|
-
appType: 'studio',
|
|
12
|
-
output: mockOutput,
|
|
13
|
-
projectId: 'project-id'
|
|
14
|
-
});
|
|
15
|
-
expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'));
|
|
16
|
-
expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage/project/project-id/studios'));
|
|
17
|
-
});
|
|
18
|
-
test('should be resilient to missing project IDs', ()=>{
|
|
19
|
-
warnAboutMissingAppId({
|
|
20
|
-
appType: 'app',
|
|
21
|
-
output: mockOutput
|
|
22
|
-
});
|
|
23
|
-
expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'));
|
|
24
|
-
expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage'));
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=warnAboutMissingAppId.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/warnAboutMissingAppId.test.ts"],"sourcesContent":["import {Output} from '@sanity/cli-core'\nimport {describe, expect, test, vi} from 'vitest'\n\nimport {warnAboutMissingAppId} from '../warnAboutMissingAppId'\n\ndescribe('warnAboutMissingAppId', () => {\n const mockOutput = {\n error: vi.fn(),\n log: vi.fn(),\n warn: vi.fn(),\n } as unknown as Output\n\n test('should log the expected warning when called', () => {\n warnAboutMissingAppId({\n appType: 'studio',\n output: mockOutput,\n projectId: 'project-id',\n })\n\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'))\n expect(mockOutput.warn).toBeCalledWith(\n expect.stringContaining('https://www.sanity.io/manage/project/project-id/studios'),\n )\n })\n\n test('should be resilient to missing project IDs', () => {\n warnAboutMissingAppId({\n appType: 'app',\n output: mockOutput,\n })\n\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('No appId configured'))\n expect(mockOutput.warn).toBeCalledWith(expect.stringContaining('https://www.sanity.io/manage'))\n })\n})\n"],"names":["describe","expect","test","vi","warnAboutMissingAppId","mockOutput","error","fn","log","warn","appType","output","projectId","toBeCalledWith","stringContaining"],"mappings":"AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAEjD,SAAQC,qBAAqB,QAAO,2BAA0B;AAE9DJ,SAAS,yBAAyB;IAChC,MAAMK,aAAa;QACjBC,OAAOH,GAAGI,EAAE;QACZC,KAAKL,GAAGI,EAAE;QACVE,MAAMN,GAAGI,EAAE;IACb;IAEAL,KAAK,+CAA+C;QAClDE,sBAAsB;YACpBM,SAAS;YACTC,QAAQN;YACRO,WAAW;QACb;QAEAX,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;QAC/Db,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CACpCZ,OAAOa,gBAAgB,CAAC;IAE5B;IAEAZ,KAAK,8CAA8C;QACjDE,sBAAsB;YACpBM,SAAS;YACTC,QAAQN;QACV;QAEAJ,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;QAC/Db,OAAOI,WAAWI,IAAI,EAAEI,cAAc,CAACZ,OAAOa,gBAAgB,CAAC;IACjE;AACF"}
|
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import { spinner } from '@sanity/cli-core/ux';
|
|
2
|
-
import { execa } from 'execa';
|
|
3
|
-
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
|
-
import { installDeclaredPackages, installNewPackages } from '../installPackages.js';
|
|
5
|
-
import { getPartialEnvWithNpmPath } from '../packageManagerChoice.js';
|
|
6
|
-
// Mock external dependencies
|
|
7
|
-
vi.mock('execa', ()=>({
|
|
8
|
-
execa: vi.fn()
|
|
9
|
-
}));
|
|
10
|
-
vi.mock('../packageManagerChoice.js', ()=>({
|
|
11
|
-
getPartialEnvWithNpmPath: vi.fn()
|
|
12
|
-
}));
|
|
13
|
-
vi.mock('@sanity/cli-core/ux', async ()=>{
|
|
14
|
-
const actual = await vi.importActual('@sanity/cli-core/ux');
|
|
15
|
-
return {
|
|
16
|
-
...actual,
|
|
17
|
-
spinner: vi.fn(()=>({
|
|
18
|
-
fail: vi.fn().mockReturnThis(),
|
|
19
|
-
start: vi.fn().mockReturnThis(),
|
|
20
|
-
succeed: vi.fn().mockReturnThis()
|
|
21
|
-
}))
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const mockExeca = vi.mocked(execa);
|
|
25
|
-
const mockSpinner = vi.mocked(spinner);
|
|
26
|
-
const mockGetPartialEnvWithNpmPath = vi.mocked(getPartialEnvWithNpmPath);
|
|
27
|
-
const mockOutput = {
|
|
28
|
-
error: vi.fn(),
|
|
29
|
-
log: vi.fn(),
|
|
30
|
-
warn: vi.fn()
|
|
31
|
-
};
|
|
32
|
-
const mockSpinnerInstance = {
|
|
33
|
-
fail: vi.fn().mockReturnThis(),
|
|
34
|
-
start: vi.fn().mockReturnThis(),
|
|
35
|
-
succeed: vi.fn().mockReturnThis()
|
|
36
|
-
};
|
|
37
|
-
beforeEach(()=>{
|
|
38
|
-
vi.clearAllMocks();
|
|
39
|
-
mockGetPartialEnvWithNpmPath.mockReturnValue({
|
|
40
|
-
PATH: '/mock/path'
|
|
41
|
-
});
|
|
42
|
-
mockSpinner.mockReturnValue(mockSpinnerInstance);
|
|
43
|
-
});
|
|
44
|
-
describe('installDeclaredPackages', ()=>{
|
|
45
|
-
const workDir = '/test/project';
|
|
46
|
-
const context = {
|
|
47
|
-
output: mockOutput,
|
|
48
|
-
workDir
|
|
49
|
-
};
|
|
50
|
-
test('installs with npm successfully', async ()=>{
|
|
51
|
-
const mockResult = {
|
|
52
|
-
exitCode: 0,
|
|
53
|
-
failed: false,
|
|
54
|
-
stdout: 'Installation successful'
|
|
55
|
-
};
|
|
56
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
57
|
-
await installDeclaredPackages(workDir, 'npm', context);
|
|
58
|
-
expect(execa).toHaveBeenCalledWith('npm', [
|
|
59
|
-
'install'
|
|
60
|
-
], {
|
|
61
|
-
cwd: workDir,
|
|
62
|
-
encoding: 'utf8',
|
|
63
|
-
env: {
|
|
64
|
-
PATH: '/mock/path'
|
|
65
|
-
},
|
|
66
|
-
stdio: 'pipe'
|
|
67
|
-
});
|
|
68
|
-
expect(mockSpinnerInstance.start).toHaveBeenCalled();
|
|
69
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
70
|
-
expect(mockSpinnerInstance.fail).not.toHaveBeenCalled();
|
|
71
|
-
});
|
|
72
|
-
test('installs with yarn successfully', async ()=>{
|
|
73
|
-
const mockResult = {
|
|
74
|
-
exitCode: 0,
|
|
75
|
-
failed: false,
|
|
76
|
-
stdout: 'Installation successful'
|
|
77
|
-
};
|
|
78
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
79
|
-
await installDeclaredPackages(workDir, 'yarn', context);
|
|
80
|
-
expect(execa).toHaveBeenCalledWith('yarn', [
|
|
81
|
-
'install'
|
|
82
|
-
], {
|
|
83
|
-
cwd: workDir,
|
|
84
|
-
encoding: 'utf8',
|
|
85
|
-
env: {
|
|
86
|
-
PATH: '/mock/path'
|
|
87
|
-
},
|
|
88
|
-
stdio: 'pipe'
|
|
89
|
-
});
|
|
90
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
test('installs with pnpm successfully', async ()=>{
|
|
93
|
-
const mockResult = {
|
|
94
|
-
exitCode: 0,
|
|
95
|
-
failed: false,
|
|
96
|
-
stdout: 'Installation successful'
|
|
97
|
-
};
|
|
98
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
99
|
-
await installDeclaredPackages(workDir, 'pnpm', context);
|
|
100
|
-
expect(execa).toHaveBeenCalledWith('pnpm', [
|
|
101
|
-
'install'
|
|
102
|
-
], {
|
|
103
|
-
cwd: workDir,
|
|
104
|
-
encoding: 'utf8',
|
|
105
|
-
env: {
|
|
106
|
-
PATH: '/mock/path'
|
|
107
|
-
},
|
|
108
|
-
stdio: 'pipe'
|
|
109
|
-
});
|
|
110
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
test('installs with bun successfully', async ()=>{
|
|
113
|
-
const mockResult = {
|
|
114
|
-
exitCode: 0,
|
|
115
|
-
failed: false,
|
|
116
|
-
stdout: 'Installation successful'
|
|
117
|
-
};
|
|
118
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
119
|
-
await installDeclaredPackages(workDir, 'bun', context);
|
|
120
|
-
expect(execa).toHaveBeenCalledWith('bun', [
|
|
121
|
-
'install'
|
|
122
|
-
], {
|
|
123
|
-
cwd: workDir,
|
|
124
|
-
encoding: 'utf8',
|
|
125
|
-
env: {
|
|
126
|
-
PATH: '/mock/path'
|
|
127
|
-
},
|
|
128
|
-
stdio: 'pipe'
|
|
129
|
-
});
|
|
130
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
131
|
-
});
|
|
132
|
-
test('handles manual package manager', async ()=>{
|
|
133
|
-
await installDeclaredPackages(workDir, 'manual', context);
|
|
134
|
-
expect(execa).not.toHaveBeenCalled();
|
|
135
|
-
expect(mockOutput.log).toHaveBeenCalledWith("Manual installation selected — run 'npm install' or equivalent");
|
|
136
|
-
});
|
|
137
|
-
test('handles installation failure with exit code', async ()=>{
|
|
138
|
-
const mockResult = {
|
|
139
|
-
exitCode: 1,
|
|
140
|
-
failed: true,
|
|
141
|
-
stdout: 'Error: Package not found'
|
|
142
|
-
};
|
|
143
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
144
|
-
await expect(installDeclaredPackages(workDir, 'npm', context));
|
|
145
|
-
expect(mockSpinnerInstance.fail).toHaveBeenCalled();
|
|
146
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Error: Package not found');
|
|
147
|
-
expect(mockOutput.error).toHaveBeenCalledWith('Dependency installation failed', {
|
|
148
|
-
exit: 1
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
test('handles installation failure with failed flag', async ()=>{
|
|
152
|
-
const mockResult = {
|
|
153
|
-
exitCode: 0,
|
|
154
|
-
failed: true,
|
|
155
|
-
stdout: 'Command failed'
|
|
156
|
-
};
|
|
157
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
158
|
-
await expect(installDeclaredPackages(workDir, 'npm', context));
|
|
159
|
-
expect(mockSpinnerInstance.fail).toHaveBeenCalled();
|
|
160
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Command failed');
|
|
161
|
-
expect(mockOutput.error).toHaveBeenCalledWith('Dependency installation failed', {
|
|
162
|
-
exit: 1
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
describe('installNewPackages', ()=>{
|
|
167
|
-
const workDir = '/test/project';
|
|
168
|
-
const context = {
|
|
169
|
-
output: mockOutput,
|
|
170
|
-
workDir
|
|
171
|
-
};
|
|
172
|
-
test('installs single package with npm successfully', async ()=>{
|
|
173
|
-
const options = {
|
|
174
|
-
packageManager: 'npm',
|
|
175
|
-
packages: [
|
|
176
|
-
'@sanity/vision'
|
|
177
|
-
]
|
|
178
|
-
};
|
|
179
|
-
const mockResult = {
|
|
180
|
-
exitCode: 0,
|
|
181
|
-
failed: false,
|
|
182
|
-
stdout: 'Installation successful'
|
|
183
|
-
};
|
|
184
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
185
|
-
await installNewPackages(options, context);
|
|
186
|
-
expect(execa).toHaveBeenCalledWith('npm', [
|
|
187
|
-
'install',
|
|
188
|
-
'--save',
|
|
189
|
-
'@sanity/vision'
|
|
190
|
-
], {
|
|
191
|
-
cwd: workDir,
|
|
192
|
-
encoding: 'utf8',
|
|
193
|
-
env: {
|
|
194
|
-
PATH: '/mock/path'
|
|
195
|
-
},
|
|
196
|
-
stdio: 'pipe'
|
|
197
|
-
});
|
|
198
|
-
expect(mockSpinnerInstance.start).toHaveBeenCalled();
|
|
199
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
200
|
-
});
|
|
201
|
-
test('installs multiple packages with yarn successfully', async ()=>{
|
|
202
|
-
const options = {
|
|
203
|
-
packageManager: 'yarn',
|
|
204
|
-
packages: [
|
|
205
|
-
'@sanity/vision',
|
|
206
|
-
'react-icons'
|
|
207
|
-
]
|
|
208
|
-
};
|
|
209
|
-
const mockResult = {
|
|
210
|
-
exitCode: 0,
|
|
211
|
-
failed: false,
|
|
212
|
-
stdout: 'Installation successful'
|
|
213
|
-
};
|
|
214
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
215
|
-
await installNewPackages(options, context);
|
|
216
|
-
expect(execa).toHaveBeenCalledWith('yarn', [
|
|
217
|
-
'add',
|
|
218
|
-
'@sanity/vision',
|
|
219
|
-
'react-icons'
|
|
220
|
-
], {
|
|
221
|
-
cwd: workDir,
|
|
222
|
-
encoding: 'utf8',
|
|
223
|
-
env: {
|
|
224
|
-
PATH: '/mock/path'
|
|
225
|
-
},
|
|
226
|
-
stdio: 'pipe'
|
|
227
|
-
});
|
|
228
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
229
|
-
});
|
|
230
|
-
test('installs packages with pnpm successfully', async ()=>{
|
|
231
|
-
const options = {
|
|
232
|
-
packageManager: 'pnpm',
|
|
233
|
-
packages: [
|
|
234
|
-
'lodash'
|
|
235
|
-
]
|
|
236
|
-
};
|
|
237
|
-
const mockResult = {
|
|
238
|
-
exitCode: 0,
|
|
239
|
-
failed: false,
|
|
240
|
-
stdout: 'Installation successful'
|
|
241
|
-
};
|
|
242
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
243
|
-
await installNewPackages(options, context);
|
|
244
|
-
expect(execa).toHaveBeenCalledWith('pnpm', [
|
|
245
|
-
'add',
|
|
246
|
-
'--save-prod',
|
|
247
|
-
'lodash'
|
|
248
|
-
], {
|
|
249
|
-
cwd: workDir,
|
|
250
|
-
encoding: 'utf8',
|
|
251
|
-
env: {
|
|
252
|
-
PATH: '/mock/path'
|
|
253
|
-
},
|
|
254
|
-
stdio: 'pipe'
|
|
255
|
-
});
|
|
256
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
257
|
-
});
|
|
258
|
-
test('installs packages with bun successfully', async ()=>{
|
|
259
|
-
const options = {
|
|
260
|
-
packageManager: 'bun',
|
|
261
|
-
packages: [
|
|
262
|
-
'express'
|
|
263
|
-
]
|
|
264
|
-
};
|
|
265
|
-
const mockResult = {
|
|
266
|
-
exitCode: 0,
|
|
267
|
-
failed: false,
|
|
268
|
-
stdout: 'Installation successful'
|
|
269
|
-
};
|
|
270
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
271
|
-
await installNewPackages(options, context);
|
|
272
|
-
expect(execa).toHaveBeenCalledWith('bun', [
|
|
273
|
-
'add',
|
|
274
|
-
'express'
|
|
275
|
-
], {
|
|
276
|
-
cwd: workDir,
|
|
277
|
-
encoding: 'utf8',
|
|
278
|
-
env: {
|
|
279
|
-
PATH: '/mock/path'
|
|
280
|
-
},
|
|
281
|
-
stdio: 'pipe'
|
|
282
|
-
});
|
|
283
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
284
|
-
});
|
|
285
|
-
test('handles manual package manager for new packages', async ()=>{
|
|
286
|
-
const options = {
|
|
287
|
-
packageManager: 'manual',
|
|
288
|
-
packages: [
|
|
289
|
-
'some-package'
|
|
290
|
-
]
|
|
291
|
-
};
|
|
292
|
-
await installNewPackages(options, context);
|
|
293
|
-
expect(execa).not.toHaveBeenCalled();
|
|
294
|
-
expect(mockOutput.log).toHaveBeenCalledWith("Manual installation selected - run 'npm install --save some-package' or equivalent");
|
|
295
|
-
});
|
|
296
|
-
test('handles installation failure with error output', async ()=>{
|
|
297
|
-
const options = {
|
|
298
|
-
packageManager: 'npm',
|
|
299
|
-
packages: [
|
|
300
|
-
'nonexistent-package'
|
|
301
|
-
]
|
|
302
|
-
};
|
|
303
|
-
const mockResult = {
|
|
304
|
-
exitCode: 1,
|
|
305
|
-
failed: true,
|
|
306
|
-
stdout: 'Error: Package not found'
|
|
307
|
-
};
|
|
308
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
309
|
-
await expect(installNewPackages(options, context));
|
|
310
|
-
expect(mockSpinnerInstance.fail).toHaveBeenCalled();
|
|
311
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Error: Package not found');
|
|
312
|
-
expect(mockOutput.error).toHaveBeenCalledWith('Package installation failed', {
|
|
313
|
-
exit: 1
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
test('handles installation failure with failed flag', async ()=>{
|
|
317
|
-
const options = {
|
|
318
|
-
packageManager: 'pnpm',
|
|
319
|
-
packages: [
|
|
320
|
-
'failing-package'
|
|
321
|
-
]
|
|
322
|
-
};
|
|
323
|
-
const mockResult = {
|
|
324
|
-
exitCode: 0,
|
|
325
|
-
failed: true,
|
|
326
|
-
stdout: 'Command execution failed'
|
|
327
|
-
};
|
|
328
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
329
|
-
await expect(installNewPackages(options, context));
|
|
330
|
-
expect(mockSpinnerInstance.fail).toHaveBeenCalled();
|
|
331
|
-
expect(mockOutput.log).toHaveBeenCalledWith('Command execution failed');
|
|
332
|
-
expect(mockOutput.error).toHaveBeenCalledWith('Package installation failed', {
|
|
333
|
-
exit: 1
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
test('handles empty packages array', async ()=>{
|
|
337
|
-
const options = {
|
|
338
|
-
packageManager: 'npm',
|
|
339
|
-
packages: []
|
|
340
|
-
};
|
|
341
|
-
const mockResult = {
|
|
342
|
-
exitCode: 0,
|
|
343
|
-
failed: false,
|
|
344
|
-
stdout: 'Nothing to install'
|
|
345
|
-
};
|
|
346
|
-
mockExeca.mockResolvedValueOnce(mockResult);
|
|
347
|
-
await installNewPackages(options, context);
|
|
348
|
-
expect(execa).toHaveBeenCalledWith('npm', [
|
|
349
|
-
'install',
|
|
350
|
-
'--save'
|
|
351
|
-
], {
|
|
352
|
-
cwd: workDir,
|
|
353
|
-
encoding: 'utf8',
|
|
354
|
-
env: {
|
|
355
|
-
PATH: '/mock/path'
|
|
356
|
-
},
|
|
357
|
-
stdio: 'pipe'
|
|
358
|
-
});
|
|
359
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
describe('error handling edge cases', ()=>{
|
|
363
|
-
const workDir = '/test/project';
|
|
364
|
-
const context = {
|
|
365
|
-
output: mockOutput,
|
|
366
|
-
workDir
|
|
367
|
-
};
|
|
368
|
-
test('handles undefined result in installDeclaredPackages', async ()=>{
|
|
369
|
-
mockExeca.mockResolvedValueOnce(undefined);
|
|
370
|
-
await installDeclaredPackages(workDir, 'npm', context);
|
|
371
|
-
// Should not throw if result is undefined and no error conditions
|
|
372
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
373
|
-
});
|
|
374
|
-
test('handles undefined result in installNewPackages', async ()=>{
|
|
375
|
-
const options = {
|
|
376
|
-
packageManager: 'npm',
|
|
377
|
-
packages: [
|
|
378
|
-
'test'
|
|
379
|
-
]
|
|
380
|
-
};
|
|
381
|
-
mockExeca.mockResolvedValueOnce(undefined);
|
|
382
|
-
await installNewPackages(options, context);
|
|
383
|
-
// Should not throw if result is undefined and no error conditions
|
|
384
|
-
expect(mockSpinnerInstance.succeed).toHaveBeenCalled();
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
//# sourceMappingURL=installPackages.test.js.map
|