@sanity/cli 6.0.0-alpha.4 → 6.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/dev/startStudioDevServer.js +3 -8
- package/dist/actions/dev/startStudioDevServer.js.map +1 -1
- package/dist/actions/dev/types.d.ts +1 -3
- package/dist/actions/dev/types.js.map +1 -1
- package/dist/actions/documents/validate.d.ts +0 -2
- package/dist/actions/documents/validate.js +21 -1
- package/dist/actions/documents/validate.js.map +1 -1
- package/dist/actions/exec/execScript.js +1 -1
- package/dist/actions/exec/execScript.js.map +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.js +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.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 +2 -5
- 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/deleteSchemaAction.d.ts +13 -5
- package/dist/actions/schema/deleteSchemaAction.js +12 -17
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/deploySchemas.d.ts +15 -0
- package/dist/actions/schema/deploySchemas.js +98 -0
- package/dist/actions/schema/deploySchemas.js.map +1 -0
- package/dist/actions/schema/listSchemas.d.ts +12 -0
- package/dist/actions/schema/listSchemas.js +119 -0
- package/dist/actions/schema/listSchemas.js.map +1 -0
- package/dist/actions/schema/schemaStoreTypes.d.ts +0 -11
- package/dist/actions/schema/schemaStoreTypes.js.map +1 -1
- package/dist/actions/schema/utils/debug.d.ts +2 -0
- package/dist/actions/schema/utils/debug.js +5 -0
- package/dist/actions/schema/utils/debug.js.map +1 -0
- package/dist/actions/schema/utils/manifestExtractor.d.ts +3 -8
- package/dist/actions/schema/utils/manifestExtractor.js +12 -17
- package/dist/actions/schema/utils/manifestExtractor.js.map +1 -1
- package/dist/actions/schema/utils/manifestReader.d.ts +2 -9
- package/dist/actions/schema/utils/manifestReader.js +6 -12
- package/dist/actions/schema/utils/manifestReader.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.d.ts +0 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.d.ts +10 -62
- package/dist/actions/schema/utils/schemaStoreValidation.js +38 -125
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +14 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js +9 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -0
- package/dist/actions/users/getMembersForProject.d.ts +1 -3
- package/dist/actions/users/getMembersForProject.js +6 -17
- package/dist/actions/users/getMembersForProject.js.map +1 -1
- package/dist/actions/users/types.d.ts +0 -11
- package/dist/actions/users/types.js.map +1 -1
- package/dist/commands/backup/disable.js +5 -11
- package/dist/commands/backup/disable.js.map +1 -1
- package/dist/commands/backup/enable.js +5 -11
- package/dist/commands/backup/enable.js.map +1 -1
- package/dist/commands/backup/list.js +7 -8
- package/dist/commands/backup/list.js.map +1 -1
- package/dist/commands/cors/add.js +5 -13
- package/dist/commands/cors/add.js.map +1 -1
- package/dist/commands/cors/delete.js +7 -15
- package/dist/commands/cors/delete.js.map +1 -1
- package/dist/commands/cors/list.js +2 -10
- package/dist/commands/cors/list.js.map +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/dataset/export.js +4 -4
- package/dist/commands/dataset/export.js.map +1 -1
- package/dist/commands/debug.js +5 -9
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/dev.js +0 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/documents/create.d.ts +1 -0
- package/dist/commands/documents/create.js +10 -9
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/documents/delete.js +2 -3
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/get.js +2 -3
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/query.js +2 -3
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/documents/validate.js +0 -20
- package/dist/commands/documents/validate.js.map +1 -1
- package/dist/commands/graphql/list.js +2 -2
- package/dist/commands/graphql/list.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +4 -9
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/hook/create.js +2 -6
- package/dist/commands/hook/create.js.map +1 -1
- package/dist/commands/hook/delete.js +5 -17
- package/dist/commands/hook/delete.js.map +1 -1
- package/dist/commands/hook/list.js +2 -8
- package/dist/commands/hook/list.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/commands/media/export.js +2 -2
- package/dist/commands/media/export.js.map +1 -1
- package/dist/commands/media/import.js +2 -2
- package/dist/commands/media/import.js.map +1 -1
- package/dist/commands/projects/list.js +2 -6
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/schema/delete.d.ts +1 -1
- package/dist/commands/schema/delete.js +20 -23
- package/dist/commands/schema/delete.js.map +1 -1
- package/dist/commands/schema/deploy.d.ts +16 -0
- package/dist/commands/schema/deploy.js +98 -0
- package/dist/commands/schema/deploy.js.map +1 -0
- package/dist/commands/schema/list.d.ts +15 -0
- package/dist/commands/schema/list.js +104 -0
- package/dist/commands/schema/list.js.map +1 -0
- package/dist/commands/tokens/add.js +3 -5
- package/dist/commands/tokens/add.js.map +1 -1
- package/dist/commands/users/invite.js +6 -17
- package/dist/commands/users/invite.js.map +1 -1
- package/dist/commands/users/list.js +4 -7
- package/dist/commands/users/list.js.map +1 -1
- package/dist/config/createCliConfig.d.ts +13 -4
- 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/backup.d.ts +8 -0
- package/dist/services/backup.js +19 -0
- package/dist/services/backup.js.map +1 -1
- package/dist/services/cors.d.ts +23 -0
- package/dist/services/cors.js +38 -0
- package/dist/services/cors.js.map +1 -0
- package/dist/services/graphql.d.ts +7 -0
- package/dist/services/graphql.js +11 -0
- package/dist/services/graphql.js.map +1 -1
- package/dist/services/hooks.d.ts +2 -0
- package/dist/services/hooks.js +19 -0
- package/dist/services/hooks.js.map +1 -1
- package/dist/services/organizations.d.ts +4 -2
- package/dist/services/organizations.js +3 -2
- package/dist/services/organizations.js.map +1 -1
- package/dist/services/projects.d.ts +11 -0
- package/dist/services/projects.js +41 -0
- package/dist/services/projects.js.map +1 -1
- package/dist/services/schemas.d.ts +4 -0
- package/dist/services/schemas.js +40 -0
- package/dist/services/schemas.js.map +1 -0
- package/dist/services/user.d.ts +13 -0
- package/dist/services/user.js +27 -3
- 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/dist/util/errorMessages.d.ts +1 -0
- package/dist/util/errorMessages.js +1 -0
- package/dist/util/errorMessages.js.map +1 -1
- package/dist/util/getCliVersion.js +1 -1
- package/dist/util/getCliVersion.js.map +1 -1
- package/dist/util/readPackageJson.d.ts +1 -15
- package/dist/util/readPackageJson.js +1 -1
- package/dist/util/readPackageJson.js.map +1 -1
- package/dist/util/uniqBy.d.ts +1 -0
- package/dist/util/uniqBy.js +14 -0
- package/dist/util/uniqBy.js.map +1 -0
- package/oclif.manifest.json +284 -139
- package/package.json +36 -33
- 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/cors/constants.d.ts +0 -1
- package/dist/actions/cors/constants.js +0 -3
- package/dist/actions/cors/constants.js.map +0 -1
- package/dist/actions/cors/types.d.ts +0 -9
- package/dist/actions/cors/types.js +0 -3
- package/dist/actions/cors/types.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__/deleteSchemaAction.test.js +0 -294
- package/dist/actions/schema/__tests__/deleteSchemaAction.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/schema/schemaStoreConstants.d.ts +0 -1
- package/dist/actions/schema/schemaStoreConstants.js +0 -4
- package/dist/actions/schema/schemaStoreConstants.js.map +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.d.ts +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.js +0 -5
- package/dist/actions/schema/utils/schemaActionHelpers.js.map +0 -1
- package/dist/actions/schema/utils/schemaApiClient.d.ts +0 -6
- package/dist/actions/schema/utils/schemaApiClient.js +0 -17
- package/dist/actions/schema/utils/schemaApiClient.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/actions/users/apiVersion.d.ts +0 -6
- package/dist/actions/users/apiVersion.js +0 -7
- package/dist/actions/users/apiVersion.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 -697
- package/dist/commands/__tests__/debug.test.js.map +0 -1
- package/dist/commands/__tests__/deploy.test.js +0 -1913
- package/dist/commands/__tests__/deploy.test.js.map +0 -1
- package/dist/commands/__tests__/dev.test.js +0 -410
- 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 -60
- package/dist/commands/__tests__/init/init.authentication.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.create-new-project.test.js +0 -196
- package/dist/commands/__tests__/init/init.create-new-project.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.plan.test.js +0 -220
- package/dist/commands/__tests__/init/init.plan.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.setup.test.js +0 -279
- package/dist/commands/__tests__/init/init.setup.test.js.map +0 -1
- package/dist/commands/__tests__/install.test.js +0 -258
- 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 -88
- package/dist/commands/__tests__/logout.test.js.map +0 -1
- package/dist/commands/__tests__/manage.test.js +0 -105
- 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 -134
- package/dist/commands/__tests__/versions.test.js.map +0 -1
- package/dist/commands/backup/__tests__/disable.test.js +0 -207
- package/dist/commands/backup/__tests__/disable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/download.test.js +0 -679
- package/dist/commands/backup/__tests__/download.test.js.map +0 -1
- package/dist/commands/backup/__tests__/enable.test.js +0 -317
- package/dist/commands/backup/__tests__/enable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/list.test.js +0 -321
- package/dist/commands/backup/__tests__/list.test.js.map +0 -1
- package/dist/commands/cors/__tests__/add.test.js +0 -346
- package/dist/commands/cors/__tests__/add.test.js.map +0 -1
- package/dist/commands/cors/__tests__/delete.test.js +0 -293
- package/dist/commands/cors/__tests__/delete.test.js.map +0 -1
- package/dist/commands/cors/__tests__/list.test.js +0 -218
- package/dist/commands/cors/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/copy.test.js +0 -520
- package/dist/commands/dataset/__tests__/copy.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/create.test.js +0 -312
- package/dist/commands/dataset/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/delete.test.js +0 -224
- package/dist/commands/dataset/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/export.test.js +0 -561
- 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 -174
- package/dist/commands/dataset/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/create.test.js +0 -299
- package/dist/commands/dataset/alias/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/delete.test.js +0 -236
- package/dist/commands/dataset/alias/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/link.test.js +0 -336
- package/dist/commands/dataset/alias/__tests__/link.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/unlink.test.js +0 -298
- package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/get.test.js +0 -147
- package/dist/commands/dataset/visibility/__tests__/get.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/set.test.js +0 -245
- 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 -254
- package/dist/commands/docs/__tests__/search.test.js.map +0 -1
- package/dist/commands/documents/__tests__/create.test.js +0 -967
- package/dist/commands/documents/__tests__/create.test.js.map +0 -1
- package/dist/commands/documents/__tests__/delete.test.js +0 -268
- package/dist/commands/documents/__tests__/delete.test.js.map +0 -1
- package/dist/commands/documents/__tests__/get.test.js +0 -209
- package/dist/commands/documents/__tests__/get.test.js.map +0 -1
- package/dist/commands/documents/__tests__/query.test.js +0 -405
- package/dist/commands/documents/__tests__/query.test.js.map +0 -1
- package/dist/commands/documents/__tests__/validate.test.js +0 -226
- package/dist/commands/documents/__tests__/validate.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/list.test.js +0 -228
- package/dist/commands/graphql/__tests__/list.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/undeploy.test.js +0 -384
- package/dist/commands/graphql/__tests__/undeploy.test.js.map +0 -1
- package/dist/commands/hook/__tests__/attempt.test.js +0 -260
- package/dist/commands/hook/__tests__/attempt.test.js.map +0 -1
- package/dist/commands/hook/__tests__/create.test.js +0 -121
- package/dist/commands/hook/__tests__/create.test.js.map +0 -1
- package/dist/commands/hook/__tests__/delete.test.js +0 -220
- package/dist/commands/hook/__tests__/delete.test.js.map +0 -1
- package/dist/commands/hook/__tests__/list.test.js +0 -138
- package/dist/commands/hook/__tests__/list.test.js.map +0 -1
- package/dist/commands/hook/__tests__/logs.test.js +0 -770
- package/dist/commands/hook/__tests__/logs.test.js.map +0 -1
- package/dist/commands/manifest/__tests__/extract.test.js +0 -123
- 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 -160
- package/dist/commands/media/__tests__/create-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/delete-aspect.test.js +0 -333
- package/dist/commands/media/__tests__/delete-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/deploy-aspect.test.js +0 -632
- package/dist/commands/media/__tests__/deploy-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/export.test.js +0 -398
- package/dist/commands/media/__tests__/export.test.js.map +0 -1
- package/dist/commands/media/__tests__/import.test.js +0 -281
- 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 -153
- package/dist/commands/projects/__tests__/list.test.js.map +0 -1
- package/dist/commands/schema/__tests__/delete.test.js +0 -209
- package/dist/commands/schema/__tests__/delete.test.js.map +0 -1
- package/dist/commands/schema/__tests__/extract.test.js +0 -113
- package/dist/commands/schema/__tests__/extract.test.js.map +0 -1
- package/dist/commands/schema/__tests__/validate.test.js +0 -104
- package/dist/commands/schema/__tests__/validate.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/disable.test.js +0 -145
- package/dist/commands/telemetry/__tests__/disable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/enable.test.js +0 -131
- package/dist/commands/telemetry/__tests__/enable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/status.test.js +0 -153
- package/dist/commands/telemetry/__tests__/status.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/add.test.js +0 -420
- package/dist/commands/tokens/__tests__/add.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/delete.test.js +0 -375
- package/dist/commands/tokens/__tests__/delete.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/list.test.js +0 -368
- package/dist/commands/tokens/__tests__/list.test.js.map +0 -1
- package/dist/commands/users/__tests__/invite.test.js +0 -341
- package/dist/commands/users/__tests__/invite.test.js.map +0 -1
- package/dist/commands/users/__tests__/list.test.js +0 -401
- 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
|
@@ -3,7 +3,6 @@ import path from 'node:path';
|
|
|
3
3
|
import { Flags } from '@oclif/core';
|
|
4
4
|
import { SanityCommand } from '@sanity/cli-core';
|
|
5
5
|
import { chalk, confirm, logSymbols } from '@sanity/cli-core/ux';
|
|
6
|
-
import { DOCUMENTS_API_VERSION } from '../../actions/documents/constants.js';
|
|
7
6
|
import { validateDocuments } from '../../actions/documents/validate.js';
|
|
8
7
|
import { reporters } from '../../actions/documents/validation/reporters/index.js';
|
|
9
8
|
export class ValidateDocumentsCommand extends SanityCommand {
|
|
@@ -72,10 +71,6 @@ export class ValidateDocumentsCommand extends SanityCommand {
|
|
|
72
71
|
async run() {
|
|
73
72
|
const { flags } = await this.parse(ValidateDocumentsCommand);
|
|
74
73
|
const unattendedMode = Boolean(flags.yes);
|
|
75
|
-
const apiClient = await this.getGlobalApiClient({
|
|
76
|
-
apiVersion: DOCUMENTS_API_VERSION,
|
|
77
|
-
requireUser: true
|
|
78
|
-
});
|
|
79
74
|
const cliConfig = await this.getCliConfig();
|
|
80
75
|
const workDir = (await this.getProjectRoot()).directory;
|
|
81
76
|
if (!unattendedMode) {
|
|
@@ -107,20 +102,6 @@ export class ValidateDocumentsCommand extends SanityCommand {
|
|
|
107
102
|
const level = flags.level;
|
|
108
103
|
const maxCustomValidationConcurrency = flags['max-custom-validation-concurrency'];
|
|
109
104
|
const maxFetchConcurrency = flags['max-fetch-concurrency'];
|
|
110
|
-
const clientConfig = {
|
|
111
|
-
...apiClient.config(),
|
|
112
|
-
// we set this explictly to true because we pass in a token via the
|
|
113
|
-
// `clientConfiguration` object and also mock a browser environment in
|
|
114
|
-
// this worker which triggers the browser warning
|
|
115
|
-
ignoreBrowserTokenWarning: true,
|
|
116
|
-
// Removing from object so config can be serialized
|
|
117
|
-
// before sent to validation worker
|
|
118
|
-
requester: undefined,
|
|
119
|
-
// we set this explictly to true because the default client configuration
|
|
120
|
-
// from the CLI comes configured with `useProjectHostname: false` when
|
|
121
|
-
// `requireProject` is set to false
|
|
122
|
-
useProjectHostname: true
|
|
123
|
-
};
|
|
124
105
|
let ndjsonFilePath;
|
|
125
106
|
if (flags.file) {
|
|
126
107
|
const filePath = path.resolve(workDir, flags.file);
|
|
@@ -131,7 +112,6 @@ export class ValidateDocumentsCommand extends SanityCommand {
|
|
|
131
112
|
ndjsonFilePath = filePath;
|
|
132
113
|
}
|
|
133
114
|
const overallLevel = await validateDocuments({
|
|
134
|
-
clientConfig,
|
|
135
115
|
dataset: flags.dataset,
|
|
136
116
|
level,
|
|
137
117
|
maxCustomValidationConcurrency,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/documents/validate.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {Flags} from '@oclif/core'\nimport {Output, SanityCommand} from '@sanity/cli-core'\nimport {chalk, confirm, logSymbols} from '@sanity/cli-core/ux'\nimport {type ClientConfig} from '@sanity/client'\n\nimport {DOCUMENTS_API_VERSION} from '../../actions/documents/constants.js'\nimport {Level} from '../../actions/documents/types.js'\nimport {validateDocuments} from '../../actions/documents/validate.js'\nimport {reporters} from '../../actions/documents/validation/reporters/index.js'\nimport {type ValidationWorkerChannel} from '../../threads/validateDocuments.js'\nimport {type WorkerChannelReceiver} from '../../util/workerChannels.js'\n\ntype ValidateDocumentsCommandFlags = ValidateDocumentsCommand['flags']\n\nexport type BuiltInValidationReporter = (options: {\n flags: ValidateDocumentsCommandFlags\n output: Output\n worker: WorkerChannelReceiver<ValidationWorkerChannel>\n}) => Promise<Level>\n\nexport class ValidateDocumentsCommand extends SanityCommand<typeof ValidateDocumentsCommand> {\n static description = 'Validate documents in a dataset against the studio schema'\n\n static examples = [\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default',\n description: 'Validates all documents in a Sanity project with more than one workspace',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default --dataset staging',\n description: 'Override the dataset specified in the workspace',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --yes > report.txt',\n description: 'Save the results of the report into a file',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --level info',\n description: 'Report out info level validation markers too',\n },\n ]\n\n static flags = {\n dataset: Flags.string({\n char: 'd',\n description:\n 'Override the dataset used. By default, this is derived from the given workspace',\n }),\n file: Flags.string({\n description:\n 'Provide a path to either an .ndjson file or a tarball containing an .ndjson file',\n }),\n format: Flags.string({\n description:\n 'The output format used to print the found validation markers and report progress',\n }),\n level: Flags.custom<Level>({\n default: 'warning',\n description: 'The minimum level reported out. Defaults to warning',\n options: ['error', 'warning', 'info'],\n parse: async (input) => {\n if (input !== 'error' && input !== 'warning' && input !== 'info') {\n throw new Error(`Invalid level: ${input}. Must be 'error', 'warning', or 'info'`)\n }\n return input as Level\n },\n })(),\n 'max-custom-validation-concurrency': Flags.integer({\n default: 5,\n description: 'Specify how many custom validators can run concurrently',\n }),\n 'max-fetch-concurrency': Flags.integer({\n default: 25,\n description: 'Specify how many `client.fetch` requests are allow concurrency at once',\n }),\n workspace: Flags.string({\n description: 'The name of the workspace to use when downloading and validating all documents',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description: 'Skips the first confirmation prompt',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ValidateDocumentsCommand)\n const unattendedMode = Boolean(flags.yes)\n\n const apiClient = await this.getGlobalApiClient({\n apiVersion: DOCUMENTS_API_VERSION,\n requireUser: true,\n })\n const cliConfig = await this.getCliConfig()\n const workDir = (await this.getProjectRoot()).directory\n\n if (!unattendedMode) {\n this.log(\n `${chalk.yellow(`${logSymbols.warning} Warning:`)} This command ${\n flags.file\n ? 'reads all documents from your input file'\n : 'downloads all documents from your dataset'\n } and processes them through your local schema within a ` +\n `simulated browser environment.\\n`,\n )\n this.log(`Potential pitfalls:\\n`)\n this.log(\n `- Processes all documents locally (excluding assets). Large datasets may require more resources.`,\n )\n this.log(\n `- Executes all custom validation functions. Some functions may need to be refactored for compatibility.`,\n )\n this.log(\n `- Not all standard browser features are available and may cause issues while loading your Studio.`,\n )\n this.log(\n `- Adheres to document permissions. Ensure this account can see all desired documents.`,\n )\n if (flags.file) {\n this.log(\n `- Checks for missing document references against the live dataset if not found in your file.`,\n )\n }\n\n const confirmed = await confirm({\n default: true,\n message: `Are you sure you want to continue?`,\n })\n\n if (!confirmed) {\n this.log('User aborted')\n this.exit(1)\n }\n }\n\n if (flags.format && !(flags.format in reporters)) {\n const formatter = new Intl.ListFormat('en-US', {\n style: 'long',\n type: 'conjunction',\n })\n throw new Error(\n `Did not recognize format '${flags.format}'. Available formats are ${formatter.format(\n Object.keys(reporters).map((key) => `'${key}'`),\n )}`,\n )\n }\n\n const level = flags.level\n const maxCustomValidationConcurrency = flags['max-custom-validation-concurrency']\n const maxFetchConcurrency = flags['max-fetch-concurrency']\n\n const clientConfig: ClientConfig = {\n ...apiClient.config(),\n // we set this explictly to true because we pass in a token via the\n // `clientConfiguration` object and also mock a browser environment in\n // this worker which triggers the browser warning\n ignoreBrowserTokenWarning: true,\n // Removing from object so config can be serialized\n // before sent to validation worker\n requester: undefined,\n // we set this explictly to true because the default client configuration\n // from the CLI comes configured with `useProjectHostname: false` when\n // `requireProject` is set to false\n useProjectHostname: true,\n }\n\n let ndjsonFilePath\n if (flags.file) {\n const filePath = path.resolve(workDir, flags.file)\n\n const stat = await fs.promises.stat(filePath)\n if (!stat.isFile()) {\n this.error(`'--file' must point to a valid ndjson file or tarball`)\n }\n\n ndjsonFilePath = filePath\n }\n\n const overallLevel = await validateDocuments({\n clientConfig,\n dataset: flags.dataset,\n level,\n maxCustomValidationConcurrency,\n maxFetchConcurrency,\n ndjsonFilePath,\n reporter: (worker) => {\n const reporter =\n flags.format && flags.format in reporters\n ? reporters[flags.format as keyof typeof reporters]\n : reporters.pretty\n\n return reporter({flags, output: this.output, worker})\n },\n studioHost: cliConfig?.studioHost,\n workDir,\n workspace: flags.workspace,\n })\n\n if (overallLevel === 'error') {\n this.exit(1)\n }\n }\n}\n"],"names":["fs","path","Flags","SanityCommand","chalk","confirm","logSymbols","DOCUMENTS_API_VERSION","validateDocuments","reporters","ValidateDocumentsCommand","description","examples","command","flags","dataset","string","char","file","format","level","custom","default","options","parse","input","Error","integer","workspace","yes","boolean","run","unattendedMode","Boolean","apiClient","getGlobalApiClient","apiVersion","requireUser","cliConfig","getCliConfig","workDir","getProjectRoot","directory","log","yellow","warning","confirmed","message","exit","formatter","Intl","ListFormat","style","type","Object","keys","map","key","maxCustomValidationConcurrency","maxFetchConcurrency","clientConfig","config","ignoreBrowserTokenWarning","requester","undefined","useProjectHostname","ndjsonFilePath","filePath","resolve","stat","promises","isFile","error","overallLevel","reporter","worker","pretty","output","studioHost"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAgBC,aAAa,QAAO,mBAAkB;AACtD,SAAQC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAO,sBAAqB;AAG9D,SAAQC,qBAAqB,QAAO,uCAAsC;AAE1E,SAAQC,iBAAiB,QAAO,sCAAqC;AACrE,SAAQC,SAAS,QAAO,wDAAuD;AAY/E,OAAO,MAAMC,iCAAiCP;IAC5C,OAAOQ,cAAc,4DAA2D;IAEhF,OAAOC,WAAW;QAChB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAOG,QAAQ;QACbC,SAASb,MAAMc,MAAM,CAAC;YACpBC,MAAM;YACNN,aACE;QACJ;QACAO,MAAMhB,MAAMc,MAAM,CAAC;YACjBL,aACE;QACJ;QACAQ,QAAQjB,MAAMc,MAAM,CAAC;YACnBL,aACE;QACJ;QACAS,OAAOlB,MAAMmB,MAAM,CAAQ;YACzBC,SAAS;YACTX,aAAa;YACbY,SAAS;gBAAC;gBAAS;gBAAW;aAAO;YACrCC,OAAO,OAAOC;gBACZ,IAAIA,UAAU,WAAWA,UAAU,aAAaA,UAAU,QAAQ;oBAChE,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAED,MAAM,uCAAuC,CAAC;gBAClF;gBACA,OAAOA;YACT;QACF;QACA,qCAAqCvB,MAAMyB,OAAO,CAAC;YACjDL,SAAS;YACTX,aAAa;QACf;QACA,yBAAyBT,MAAMyB,OAAO,CAAC;YACrCL,SAAS;YACTX,aAAa;QACf;QACAiB,WAAW1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B,GACjDV,UAAUmE,MAAM;gBAEtB,OAAOF,SAAS;oBAAC5D;oBAAO+D,QAAQ,IAAI,CAACA,MAAM;oBAAEF;gBAAM;YACrD;YACAG,YAAYxC,WAAWwC;YACvBtC;YACAZ,WAAWd,MAAMc,SAAS;QAC5B;QAEA,IAAI6C,iBAAiB,SAAS;YAC5B,IAAI,CAACzB,IAAI,CAAC;QACZ;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/documents/validate.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {Flags} from '@oclif/core'\nimport {Output, SanityCommand} from '@sanity/cli-core'\nimport {chalk, confirm, logSymbols} from '@sanity/cli-core/ux'\n\nimport {Level} from '../../actions/documents/types.js'\nimport {validateDocuments} from '../../actions/documents/validate.js'\nimport {reporters} from '../../actions/documents/validation/reporters/index.js'\nimport {type ValidationWorkerChannel} from '../../threads/validateDocuments.js'\nimport {type WorkerChannelReceiver} from '../../util/workerChannels.js'\n\ntype ValidateDocumentsCommandFlags = ValidateDocumentsCommand['flags']\n\nexport type BuiltInValidationReporter = (options: {\n flags: ValidateDocumentsCommandFlags\n output: Output\n worker: WorkerChannelReceiver<ValidationWorkerChannel>\n}) => Promise<Level>\n\nexport class ValidateDocumentsCommand extends SanityCommand<typeof ValidateDocumentsCommand> {\n static description = 'Validate documents in a dataset against the studio schema'\n\n static examples = [\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default',\n description: 'Validates all documents in a Sanity project with more than one workspace',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default --dataset staging',\n description: 'Override the dataset specified in the workspace',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --yes > report.txt',\n description: 'Save the results of the report into a file',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --level info',\n description: 'Report out info level validation markers too',\n },\n ]\n\n static flags = {\n dataset: Flags.string({\n char: 'd',\n description:\n 'Override the dataset used. By default, this is derived from the given workspace',\n }),\n file: Flags.string({\n description:\n 'Provide a path to either an .ndjson file or a tarball containing an .ndjson file',\n }),\n format: Flags.string({\n description:\n 'The output format used to print the found validation markers and report progress',\n }),\n level: Flags.custom<Level>({\n default: 'warning',\n description: 'The minimum level reported out. Defaults to warning',\n options: ['error', 'warning', 'info'],\n parse: async (input) => {\n if (input !== 'error' && input !== 'warning' && input !== 'info') {\n throw new Error(`Invalid level: ${input}. Must be 'error', 'warning', or 'info'`)\n }\n return input as Level\n },\n })(),\n 'max-custom-validation-concurrency': Flags.integer({\n default: 5,\n description: 'Specify how many custom validators can run concurrently',\n }),\n 'max-fetch-concurrency': Flags.integer({\n default: 25,\n description: 'Specify how many `client.fetch` requests are allow concurrency at once',\n }),\n workspace: Flags.string({\n description: 'The name of the workspace to use when downloading and validating all documents',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description: 'Skips the first confirmation prompt',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ValidateDocumentsCommand)\n const unattendedMode = Boolean(flags.yes)\n\n const cliConfig = await this.getCliConfig()\n const workDir = (await this.getProjectRoot()).directory\n\n if (!unattendedMode) {\n this.log(\n `${chalk.yellow(`${logSymbols.warning} Warning:`)} This command ${\n flags.file\n ? 'reads all documents from your input file'\n : 'downloads all documents from your dataset'\n } and processes them through your local schema within a ` +\n `simulated browser environment.\\n`,\n )\n this.log(`Potential pitfalls:\\n`)\n this.log(\n `- Processes all documents locally (excluding assets). Large datasets may require more resources.`,\n )\n this.log(\n `- Executes all custom validation functions. Some functions may need to be refactored for compatibility.`,\n )\n this.log(\n `- Not all standard browser features are available and may cause issues while loading your Studio.`,\n )\n this.log(\n `- Adheres to document permissions. Ensure this account can see all desired documents.`,\n )\n if (flags.file) {\n this.log(\n `- Checks for missing document references against the live dataset if not found in your file.`,\n )\n }\n\n const confirmed = await confirm({\n default: true,\n message: `Are you sure you want to continue?`,\n })\n\n if (!confirmed) {\n this.log('User aborted')\n this.exit(1)\n }\n }\n\n if (flags.format && !(flags.format in reporters)) {\n const formatter = new Intl.ListFormat('en-US', {\n style: 'long',\n type: 'conjunction',\n })\n throw new Error(\n `Did not recognize format '${flags.format}'. Available formats are ${formatter.format(\n Object.keys(reporters).map((key) => `'${key}'`),\n )}`,\n )\n }\n\n const level = flags.level\n const maxCustomValidationConcurrency = flags['max-custom-validation-concurrency']\n const maxFetchConcurrency = flags['max-fetch-concurrency']\n\n let ndjsonFilePath\n if (flags.file) {\n const filePath = path.resolve(workDir, flags.file)\n\n const stat = await fs.promises.stat(filePath)\n if (!stat.isFile()) {\n this.error(`'--file' must point to a valid ndjson file or tarball`)\n }\n\n ndjsonFilePath = filePath\n }\n\n const overallLevel = await validateDocuments({\n dataset: flags.dataset,\n level,\n maxCustomValidationConcurrency,\n maxFetchConcurrency,\n ndjsonFilePath,\n reporter: (worker) => {\n const reporter =\n flags.format && flags.format in reporters\n ? reporters[flags.format as keyof typeof reporters]\n : reporters.pretty\n\n return reporter({flags, output: this.output, worker})\n },\n studioHost: cliConfig?.studioHost,\n workDir,\n workspace: flags.workspace,\n })\n\n if (overallLevel === 'error') {\n this.exit(1)\n }\n }\n}\n"],"names":["fs","path","Flags","SanityCommand","chalk","confirm","logSymbols","validateDocuments","reporters","ValidateDocumentsCommand","description","examples","command","flags","dataset","string","char","file","format","level","custom","default","options","parse","input","Error","integer","workspace","yes","boolean","run","unattendedMode","Boolean","cliConfig","getCliConfig","workDir","getProjectRoot","directory","log","yellow","warning","confirmed","message","exit","formatter","Intl","ListFormat","style","type","Object","keys","map","key","maxCustomValidationConcurrency","maxFetchConcurrency","ndjsonFilePath","filePath","resolve","stat","promises","isFile","error","overallLevel","reporter","worker","pretty","output","studioHost"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAgBC,aAAa,QAAO,mBAAkB;AACtD,SAAQC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAO,sBAAqB;AAG9D,SAAQC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AAC,oCAAoC;QACjF,MAAMyC,sBAAsBzC,KAAK,CAAC,wBAAwB;QAE1D,IAAI0C;QACJ,IAAI1C,MAAMI,IAAI,EAAE;YACd,MAAMuC,WAAWvD,KAAKwD,OAAO,CAACtB,SAAStB,MAAMI,IAAI;YAEjD,MAAMyC,OAAO,MAAM1D,GAAG2D,QAAQ,CAACD,IAAI,CAACF;YACpC,IAAI,CAACE,KAAKE,MAAM,IAAI;gBAClB,IAAI,CAACC,KAAK,CAAC,CAAC,qDAAqD,CAAC;YACpE;YAEAN,iBAAiBC;QACnB;QAEA,MAAMM,eAAe,MAAMvD,kBAAkB;YAC3CO,SAASD,MAAMC,OAAO;YACtBK;YACAkC;YACAC;YACAC;YACAQ,UAAU,CAACC;gBACT,MAAMD,WACJlD,MAAMK,MAAM,IAAIL,MAAMK,MAAM,IAAIV,YAC5BA,SAAS,CAACK,MAAMK,MAAM,CAA2B,GACjDV,UAAUyD,MAAM;gBAEtB,OAAOF,SAAS;oBAAClD;oBAAOqD,QAAQ,IAAI,CAACA,MAAM;oBAAEF;gBAAM;YACrD;YACAG,YAAYlC,WAAWkC;YACvBhC;YACAR,WAAWd,MAAMc,SAAS;QAC5B;QAEA,IAAImC,iBAAiB,SAAS;YAC5B,IAAI,CAACnB,IAAI,CAAC;QACZ;IACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
1
|
+
import { getProjectCliClient, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
2
|
import { chalk } from '@sanity/cli-core/ux';
|
|
3
3
|
import { GRAPHQL_API_VERSION, listGraphQLEndpoints } from '../../services/graphql.js';
|
|
4
4
|
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
@@ -33,7 +33,7 @@ export class List extends SanityCommand {
|
|
|
33
33
|
this.log("This project doesn't have any GraphQL endpoints deployed.");
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const client = await
|
|
36
|
+
const client = await getProjectCliClient({
|
|
37
37
|
apiVersion: GRAPHQL_API_VERSION,
|
|
38
38
|
projectId
|
|
39
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/graphql/list.ts"],"sourcesContent":["import {SanityCommand, subdebug} from '@sanity/cli-core'\nimport {chalk} from '@sanity/cli-core/ux'\n\nimport {\n GRAPHQL_API_VERSION,\n type GraphQLEndpoint,\n listGraphQLEndpoints,\n} from '../../services/graphql.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst listGraphQLDebug = subdebug('graphql:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List all GraphQL endpoints deployed for this project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List GraphQL endpoints for the current project',\n },\n ]\n\n public async run(): Promise<void> {\n await this.parse(List)\n\n const projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n let endpoints: GraphQLEndpoint[] | undefined\n try {\n endpoints = await listGraphQLEndpoints(projectId)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n\n listGraphQLDebug(`Error fetching GraphQL endpoints for project ${projectId}`, error)\n this.error(`GraphQL endpoints list retrieval failed:\\n${message}`, {exit: 1})\n }\n\n if (!endpoints || endpoints.length === 0) {\n this.log(\"This project doesn't have any GraphQL endpoints deployed.\")\n return\n }\n\n const client = await
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/graphql/list.ts"],"sourcesContent":["import {getProjectCliClient, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {chalk} from '@sanity/cli-core/ux'\n\nimport {\n GRAPHQL_API_VERSION,\n type GraphQLEndpoint,\n listGraphQLEndpoints,\n} from '../../services/graphql.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst listGraphQLDebug = subdebug('graphql:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List all GraphQL endpoints deployed for this project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List GraphQL endpoints for the current project',\n },\n ]\n\n public async run(): Promise<void> {\n await this.parse(List)\n\n const projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n let endpoints: GraphQLEndpoint[] | undefined\n try {\n endpoints = await listGraphQLEndpoints(projectId)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n\n listGraphQLDebug(`Error fetching GraphQL endpoints for project ${projectId}`, error)\n this.error(`GraphQL endpoints list retrieval failed:\\n${message}`, {exit: 1})\n }\n\n if (!endpoints || endpoints.length === 0) {\n this.log(\"This project doesn't have any GraphQL endpoints deployed.\")\n return\n }\n\n const client = await getProjectCliClient({\n apiVersion: GRAPHQL_API_VERSION,\n projectId,\n })\n\n this.log('Here are the GraphQL endpoints deployed for this project:')\n for (const [index, endpoint] of endpoints.entries()) {\n const {dataset, tag} = endpoint\n const url = client.getUrl(`/graphql/${dataset}/${tag}`)\n\n this.log(`${index + 1}. ${chalk.bold('Dataset:')} ${dataset}`)\n this.log(` ${chalk.bold('Tag:')} ${tag}`)\n this.log(` ${chalk.bold('Generation:')} ${endpoint.generation}`)\n this.log(` ${chalk.bold('Playground:')} ${endpoint.playgroundEnabled}`)\n this.log(` ${chalk.bold('URL:')} ${url}\\n`)\n }\n }\n}\n"],"names":["getProjectCliClient","SanityCommand","subdebug","chalk","GRAPHQL_API_VERSION","listGraphQLEndpoints","NO_PROJECT_ID","listGraphQLDebug","List","description","examples","command","run","parse","projectId","getProjectId","error","exit","endpoints","message","Error","String","length","log","client","apiVersion","index","endpoint","entries","dataset","tag","url","getUrl","bold","generation","playgroundEnabled"],"mappings":"AAAA,SAAQA,mBAAmB,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAC7E,SAAQC,KAAK,QAAO,sBAAqB;AAEzC,SACEC,mBAAmB,EAEnBC,oBAAoB,QACf,4BAA2B;AAClC,SAAQC,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KAAK;YACnD,IAAI,CAACP,GAAG,CAAC,CAAC,IAAI,EAAEpB,MAAM8B,IAAI,CAAC,eAAe,EAAE,EAAEN,SAASO,UAAU,EAAE;YACnE,IAAI,CAACX,GAAG,CAAC,CAAC,IAAI,EAAEpB,MAAM8B,IAAI,CAAC,eAAe,EAAE,EAAEN,SAASQ,iBAAiB,EAAE;YAC1E,IAAI,CAACZ,GAAG,CAAC,CAAC,IAAI,EAAEpB,MAAM8B,IAAI,CAAC,QAAQ,EAAE,EAAEF,IAAI,EAAE,CAAC;QAChD;IACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import { Flags } from '@oclif/core';
|
|
|
2
2
|
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { confirm } from '@sanity/cli-core/ux';
|
|
4
4
|
import { getGraphQLAPIs } from '../../actions/graphql/getGraphQLAPIs.js';
|
|
5
|
-
import {
|
|
5
|
+
import { deleteGraphQLAPI } from '../../services/graphql.js';
|
|
6
6
|
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
7
7
|
const undeployGraphqlDebug = subdebug('graphql:undeploy');
|
|
8
8
|
export class Undeploy extends SanityCommand {
|
|
@@ -123,16 +123,11 @@ export class Undeploy extends SanityCommand {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
// Delete the GraphQL API
|
|
127
126
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
await deleteGraphQLAPI({
|
|
128
|
+
dataset,
|
|
130
129
|
projectId,
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
await client.request({
|
|
134
|
-
method: 'DELETE',
|
|
135
|
-
uri: `/apis/graphql/${dataset}/${tag}`
|
|
130
|
+
tag
|
|
136
131
|
});
|
|
137
132
|
this.log('GraphQL API deleted');
|
|
138
133
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/graphql/undeploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand, subdebug} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {getGraphQLAPIs} from '../../actions/graphql/getGraphQLAPIs.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/graphql/undeploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand, subdebug} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {getGraphQLAPIs} from '../../actions/graphql/getGraphQLAPIs.js'\nimport {deleteGraphQLAPI} from '../../services/graphql.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst undeployGraphqlDebug = subdebug('graphql:undeploy')\n\nexport class Undeploy extends SanityCommand<typeof Undeploy> {\n static override description = 'Remove a deployed GraphQL API'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Undeploy GraphQL API for current project and dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --api ios',\n description: 'Undeploy API with ID \"ios\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging',\n description: 'Undeploy GraphQL API for staging dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging --tag next',\n description: 'Undeploy GraphQL API for staging dataset with \"next\" tag',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --force',\n description: 'Undeploy GraphQL API without confirmation prompt',\n },\n ]\n\n static override flags = {\n api: Flags.string({\n description: 'Undeploy API with this ID (project, dataset and tag flags take precedence)',\n required: false,\n }),\n dataset: Flags.string({\n description: 'Dataset to undeploy GraphQL API from',\n required: false,\n }),\n force: Flags.boolean({\n description: 'Skip confirmation prompt',\n required: false,\n }),\n project: Flags.string({\n description: 'Project ID to delete GraphQL API for',\n required: false,\n }),\n tag: Flags.string({\n default: 'default',\n description: 'Tag to undeploy GraphQL API from',\n required: false,\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Undeploy)\n const {api: apiFlag, dataset: datasetFlag, force, project: projectFlag, tag: tagFlag} = flags\n\n let projectId = projectFlag\n let dataset = datasetFlag\n let tag = tagFlag\n\n // If specifying --api, use it for the flags not provided\n if (apiFlag) {\n const workDir = process.cwd()\n const apiDefs = await getGraphQLAPIs(workDir)\n const apiDef = apiDefs.find((def) => def.id === apiFlag)\n\n if (!apiDef) {\n this.error(`GraphQL API \"${apiFlag}\" not found`, {exit: 1})\n }\n\n if (projectId && projectId !== apiDef.projectId) {\n this.warn(`Both --api and --project specified, using --project ${projectId}`)\n } else {\n projectId = apiDef.projectId\n }\n\n if (dataset && dataset !== apiDef.dataset) {\n this.warn(`Both --api and --dataset specified, using --dataset ${dataset}`)\n } else {\n dataset = apiDef.dataset\n }\n\n if (tag && tag !== 'default' && apiDef.tag && tag !== apiDef.tag) {\n this.warn(`Both --api and --tag specified, using --tag ${tag}`)\n } else {\n tag = apiDef.tag || 'default'\n }\n }\n\n // Get projectId from config if not specified\n if (!projectId) {\n projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n }\n\n // Get dataset from CLI config if not specified\n if (!dataset) {\n const cliConfig = await this.getCliConfig()\n dataset = cliConfig.api?.dataset\n }\n\n if (!dataset) {\n this.error(\n 'Dataset is required. Specify it with --dataset or configure it in your project.',\n {\n exit: 1,\n },\n )\n }\n\n // Confirm deletion unless --force is used\n if (!force) {\n const confirmMessage =\n tag === 'default'\n ? `Are you absolutely sure you want to delete the current GraphQL API connected to the \"${dataset}\" dataset in project ${projectId}?`\n : `Are you absolutely sure you want to delete the GraphQL API connected to the \"${dataset}\" dataset in project ${projectId}, tagged \"${tag}\"?`\n\n try {\n const confirmed = await confirm({\n default: false,\n message: confirmMessage,\n })\n\n if (!confirmed) {\n this.log('Operation cancelled')\n return\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(`${error}`)\n undeployGraphqlDebug('User cancelled', err)\n this.error('Operation cancelled', {exit: 1})\n }\n }\n\n try {\n await deleteGraphQLAPI({\n dataset,\n projectId,\n tag,\n })\n\n this.log('GraphQL API deleted')\n } catch (error) {\n const err = error instanceof Error ? error : new Error(`${error}`)\n undeployGraphqlDebug(`Error deleting GraphQL API for ${dataset}/${tag}`, err)\n this.error(`GraphQL API deletion failed:\\n${err.message}`, {exit: 1})\n }\n }\n}\n"],"names":["Flags","SanityCommand","subdebug","confirm","getGraphQLAPIs","deleteGraphQLAPI","NO_PROJECT_ID","undeployGraphqlDebug","Undeploy","description","examples","command","flags","api","string","required","dataset","force","boolean","project","tag","default","run","parse","apiFlag","datasetFlag","projectFlag","tagFlag","projectId","workDir","process","cwd","apiDefs","apiDef","find","def","id","error","exit","warn","getProjectId","cliConfig","getCliConfig","confirmMessage","confirmed","message","log","err","Error"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACxD,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,cAAc,QAAO,0CAAyC;AACtE,SAAQC,gBAAgB,QAAO,4BAA2B;AAC1D,SAAQC,aAAa,QAAO,8BAA6B;AAEzD,MAAMC,uBAAuBL,SAAS;AAEtC,OAAO,MAAMM,iBAAiBP;IAC5B,OAAgBQ,cAAc,gCAA+B;IAE7D,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAgBG,QAAQ;QACtBC,KAAKb,MAAMc,MAAM,CAAC;YAChBL,aAAa;YACbM,UAAU;QACZ;QACAC,SAAShB,MAAMc,MAAM,CAAC;YACpBL,aAAa;YACbM,UAAU;QACZ;QACAE,OAAOjB,MAAMkB,OAAO,CAAC;YACnBT,aAAa;YACbM,UAAU;QACZ;QACAI,SAASnB,MAAMc,MAAM,CAAC;YACpB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AA8B,EAAEU,IAAIF,OAAO,EAAE,EAAE;gBAACP,MAAM;YAAC;QACrE;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSanityUrl, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
2
|
import open from 'open';
|
|
3
|
-
import {
|
|
3
|
+
import { getProjectById } from '../../services/projects.js';
|
|
4
4
|
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
5
5
|
const createHookDebug = subdebug('hook:create');
|
|
6
6
|
export class CreateHookCommand extends SanityCommand {
|
|
@@ -12,10 +12,6 @@ export class CreateHookCommand extends SanityCommand {
|
|
|
12
12
|
}
|
|
13
13
|
];
|
|
14
14
|
async run() {
|
|
15
|
-
const client = await this.getGlobalApiClient({
|
|
16
|
-
apiVersion: HOOK_API_VERSION,
|
|
17
|
-
requireUser: true
|
|
18
|
-
});
|
|
19
15
|
const projectId = await this.getProjectId();
|
|
20
16
|
if (!projectId) {
|
|
21
17
|
this.error(NO_PROJECT_ID, {
|
|
@@ -24,7 +20,7 @@ export class CreateHookCommand extends SanityCommand {
|
|
|
24
20
|
}
|
|
25
21
|
let projectInfo;
|
|
26
22
|
try {
|
|
27
|
-
projectInfo = await
|
|
23
|
+
projectInfo = await getProjectById(projectId);
|
|
28
24
|
} catch (error) {
|
|
29
25
|
const err = error;
|
|
30
26
|
createHookDebug(`Error fetching project info for project ${projectId}`, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hook/create.ts"],"sourcesContent":["import {getSanityUrl, SanityCommand, subdebug} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hook/create.ts"],"sourcesContent":["import {getSanityUrl, SanityCommand, subdebug} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {getProjectById} from '../../services/projects.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst createHookDebug = subdebug('hook:create')\n\nexport class CreateHookCommand extends SanityCommand<typeof CreateHookCommand> {\n static override description = 'Create a new webhook for the current project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Create a new webhook for the current project',\n },\n ]\n\n public async run() {\n const projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n let projectInfo: {organizationId?: string | null}\n try {\n projectInfo = await getProjectById(projectId)\n } catch (error) {\n const err = error as Error\n createHookDebug(`Error fetching project info for project ${projectId}`, err)\n this.error(`Failed to fetch project information:\\n${err.message}`, {exit: 1})\n }\n\n const organizationId = projectInfo.organizationId || 'personal'\n const manageUrl = `${getSanityUrl()}/organizations/${organizationId}/project/${projectId}/api/webhooks/new`\n\n this.log(`Opening ${manageUrl}`)\n\n try {\n await open(manageUrl)\n } catch (error) {\n const err = error as Error\n createHookDebug('Error opening browser', err)\n this.error(`Failed to open browser:\\n${err.message}`, {exit: 1})\n }\n }\n}\n"],"names":["getSanityUrl","SanityCommand","subdebug","open","getProjectById","NO_PROJECT_ID","createHookDebug","CreateHookCommand","description","examples","command","run","projectId","getProjectId","error","exit","projectInfo","err","message","organizationId","manageUrl","log"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACtE,OAAOC,UAAU,OAAM;AAEvB,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,aAAa,QAAO,8BAA6B;AAEzD,MAAMC,kBAAkBJ,SAAS;AAEjC,OAAO,MAAMK,0BAA0BN;IACrC,OAAgBO,cAAc,+CAA8C;IAC5E,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAM;QACjB,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY;QACzC,IAAI,CAACD,WAAW;YACd,IAAI,CAACE,KAAK,CAACT,eAAe;gBAACU,MAAM;YAAC;QACpC;QAEA,IAAIC;QACJ,IAAI;YACFA,cAAc,MAAMZ,eAAeQ;QACrC,EAAE,OAAOE,OAAO;YACd,MAAMG,MAAMH;YACZR,gBAAgB,CAAC,wCAAwC,EAAEM,WAAW,EAAEK;YACxE,IAAI,CAACH,KAAK,CAAC,CAAC,sCAAsC,EAAEG,IAAIC,OAAO,EAAE,EAAE;gBAACH,MAAM;YAAC;QAC7E;QAEA,MAAMI,iBAAiBH,YAAYG,cAAc,IAAI;QACrD,MAAMC,YAAY,GAAGpB,eAAe,eAAe,EAAEmB,eAAe,SAAS,EAAEP,UAAU,iBAAiB,CAAC;QAE3G,IAAI,CAACS,GAAG,CAAC,CAAC,QAAQ,EAAED,WAAW;QAE/B,IAAI;YACF,MAAMjB,KAAKiB;QACb,EAAE,OAAON,OAAO;YACd,MAAMG,MAAMH;YACZR,gBAAgB,yBAAyBW;YACzC,IAAI,CAACH,KAAK,CAAC,CAAC,yBAAyB,EAAEG,IAAIC,OAAO,EAAE,EAAE;gBAACH,MAAM;YAAC;QAChE;IACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
2
|
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { select } from '@sanity/cli-core/ux';
|
|
4
|
-
import {
|
|
4
|
+
import { deleteHookForProject, listHooksForProject } from '../../services/hooks.js';
|
|
5
5
|
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
6
6
|
const deleteHookDebug = subdebug('hook:delete');
|
|
7
7
|
export class Delete extends SanityCommand {
|
|
@@ -24,11 +24,6 @@ export class Delete extends SanityCommand {
|
|
|
24
24
|
];
|
|
25
25
|
async run() {
|
|
26
26
|
const { args } = await this.parse(Delete);
|
|
27
|
-
const client = await this.getGlobalApiClient({
|
|
28
|
-
apiVersion: HOOK_API_VERSION,
|
|
29
|
-
requireUser: true
|
|
30
|
-
});
|
|
31
|
-
// Ensure we have project context
|
|
32
27
|
const projectId = await this.getProjectId();
|
|
33
28
|
if (!projectId) {
|
|
34
29
|
this.error(NO_PROJECT_ID, {
|
|
@@ -36,13 +31,9 @@ export class Delete extends SanityCommand {
|
|
|
36
31
|
});
|
|
37
32
|
}
|
|
38
33
|
// Get the hook ID to delete
|
|
39
|
-
const hookId = await this.promptForHook(args.name,
|
|
40
|
-
// Delete the hook
|
|
34
|
+
const hookId = await this.promptForHook(args.name, projectId);
|
|
41
35
|
try {
|
|
42
|
-
await
|
|
43
|
-
method: 'DELETE',
|
|
44
|
-
uri: `/hooks/projects/${projectId}/${hookId}`
|
|
45
|
-
});
|
|
36
|
+
await deleteHookForProject(projectId, hookId);
|
|
46
37
|
this.log('Hook deleted');
|
|
47
38
|
} catch (error) {
|
|
48
39
|
const err = error;
|
|
@@ -52,13 +43,10 @@ export class Delete extends SanityCommand {
|
|
|
52
43
|
});
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
async promptForHook(specifiedName,
|
|
56
|
-
// Fetch all hooks for this project
|
|
46
|
+
async promptForHook(specifiedName, projectId) {
|
|
57
47
|
let hooks;
|
|
58
48
|
try {
|
|
59
|
-
hooks = await
|
|
60
|
-
uri: `/hooks/projects/${projectId}`
|
|
61
|
-
});
|
|
49
|
+
hooks = await listHooksForProject(projectId);
|
|
62
50
|
} catch (error) {
|
|
63
51
|
const err = error;
|
|
64
52
|
deleteHookDebug(`Error fetching hooks for project ${projectId}`, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hook/delete.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {SanityCommand, subdebug} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hook/delete.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {SanityCommand, subdebug} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {deleteHookForProject, listHooksForProject} from '../../services/hooks.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst deleteHookDebug = subdebug('hook:delete')\n\nexport class Delete extends SanityCommand<typeof Delete> {\n static override args = {\n name: Args.string({\n description: 'Name of hook to delete (will prompt if not provided)',\n required: false,\n }),\n }\n\n static override description = 'Delete a hook within your project'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Interactively select and delete a hook',\n },\n {\n command: '<%= config.bin %> <%= command.id %> my-hook',\n description: 'Delete a specific hook by name',\n },\n ]\n\n public async run(): Promise<void> {\n const {args} = await this.parse(Delete)\n\n const projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n // Get the hook ID to delete\n const hookId = await this.promptForHook(args.name, projectId)\n\n try {\n await deleteHookForProject(projectId, hookId)\n\n this.log('Hook deleted')\n } catch (error) {\n const err = error as Error\n deleteHookDebug(`Error deleting hook ${hookId} for project ${projectId}`, err)\n this.error(`Hook deletion failed:\\n${err.message}`, {exit: 1})\n }\n }\n\n private async promptForHook(\n specifiedName: string | undefined,\n projectId: string,\n ): Promise<string> {\n let hooks: Hook[]\n try {\n hooks = await listHooksForProject(projectId)\n } catch (error) {\n const err = error as Error\n deleteHookDebug(`Error fetching hooks for project ${projectId}`, err)\n this.error(`Failed to fetch hooks:\\n${err.message}`, {exit: 1})\n }\n\n if (hooks.length === 0) {\n this.error('No hooks configured for this project.', {exit: 1})\n }\n\n // If hook name is specified, find it in the list\n if (specifiedName) {\n const specifiedNameLower = specifiedName.toLowerCase()\n const selectedHook = hooks.find((hook) => hook.name.toLowerCase() === specifiedNameLower)\n\n if (!selectedHook) {\n this.error(`Hook with name \"${specifiedName}\" not found`, {exit: 1})\n }\n\n return selectedHook.id\n }\n\n // If no hook name specified, prompt user to select one\n const choices = hooks.map((hook) => ({\n name: hook.name,\n value: hook.id,\n }))\n\n const selectedId = await select({\n choices,\n message: 'Select hook to delete',\n })\n\n return selectedId\n }\n}\n"],"names":["Args","SanityCommand","subdebug","select","deleteHookForProject","listHooksForProject","NO_PROJECT_ID","deleteHookDebug","Delete","args","name","string","description","required","examples","command","run","parse","projectId","getProjectId","error","exit","hookId","promptForHook","log","err","message","specifiedName","hooks","length","specifiedNameLower","toLowerCase","selectedHook","find","hook","id","choices","map","value","selectedId"],"mappings":"AAAA,SAAQA,IAAI,QAAO,cAAa;AAChC,SAAQC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACxD,SAAQC,MAAM,QAAO,sBAAqB;AAG1C,SAAQC,oBAAoB,EAAEC,mBAAmB,QAAO,0BAAyB;AACjF,SAAQC,aAAa,QAAO,8BAA6B;AAEzD,MAAMC,kBAAkBL,SAAS;AAEjC,OAAO,MAAMM,eAAeP;IAC1B,OAAgBQ,OAAO;QACrBC,MAAMV,KAAKW,MAAM,CAAC;YAChBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,oCAAmC;IAEjE,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;KACD,CAAA;IAED,MAAaI,MAAqB;QAChC,MAAM,EAACP,IAAI,EAAC,GAAG,MAAM,IAAI,CAACQ,KAAK,CAACT;QAEhC,MAAMU,YAAY,MAAM,IAAI,CAACC,YAAY;QACzC,IAAI,CAACD,WAAW;YACd,IAAI,CAACE,KAAK,CAACd,eAAe;gBAACe,MAAM;YAAC;QACpC;QAEA,4BAA4B;QAC5B,MAAMC,SAAS,MAAM,IAAI,CAACC,aAAa,CAACd,KAAKC,IAAI,EAAEQ;QAEnD,IAAI;YACF,MAAMd,qBAAqBc,WAAWI;YAEtC,IAAI,CAACE,GAAG,CAAC;QACX,EAAE,OAAOJ,OAAO;YACd,MAAMK,MAAML;YACZb,gBAAgB,CAAC,oBAAoB,EAAEe,OAAO,aAAa,EAAEJ,WAAW,EAAEO;YAC1E,IAAI,CAACL,KAAK,CAAC,CAAC,uBAAuB,EAAEK,IAAIC,OAAO,EAAE,EAAE;gBAACL,MAAM;YAAC;QAC9D;IACF;IAEA,MAAcE,cACZI,aAAiC,EACjCT,SAAiB,EACA;QACjB,IAAIU;QACJ,IAAI;YACFA,QAAQ,MAAMvB,oBAAoBa;QACpC,EAAE,OAAOE,OAAO;YACd,MAAMK,MAAML;YACZb,gBAAgB,CAAC,iCAAiC,EAAEW,WAAW,EAAEO;YACjE,IAAI,CAACL,KAAK,CAAC,CAAC,wBAAwB,EAAEK,IAAIC,OAAO,EAAE,EAAE;gBAACL,MAAM;YAAC;QAC/D;QAEA,IAAIO,MAAMC,MAAM,KAAK,GAAG;YACtB,IAAI,CAACT,KAAK,CAAC,yCAAyC;gBAACC,MAAM;YAAC;QAC9D;QAEA,iDAAiD;QACjD,IAAIM,eAAe;YACjB,MAAMG,qBAAqBH,cAAcI,WAAW;YACpD,MAAMC,eAAeJ,MAAMK,IAAI,CAAC,CAACC,OAASA,KAAKxB,IAAI,CAACqB,WAAW,OAAOD;YAEtE,IAAI,CAACE,cAAc;gBACjB,IAAI,CAACZ,KAAK,CAAC,CAAC,gBAAgB,EAAEO,cAAc,WAAW,CAAC,EAAE;oBAACN,MAAM;gBAAC;YACpE;YAEA,OAAOW,aAAaG,EAAE;QACxB;QAEA,uDAAuD;QACvD,MAAMC,UAAUR,MAAMS,GAAG,CAAC,CAACH,OAAU,CAAA;gBACnCxB,MAAMwB,KAAKxB,IAAI;gBACf4B,OAAOJ,KAAKC,EAAE;YAChB,CAAA;QAEA,MAAMI,aAAa,MAAMpC,OAAO;YAC9BiC;YACAV,SAAS;QACX;QAEA,OAAOa;IACT;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
|
-
import {
|
|
2
|
+
import { listHooksForProject } from '../../services/hooks.js';
|
|
3
3
|
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
4
4
|
const listHookDebug = subdebug('hook:list');
|
|
5
5
|
export class List extends SanityCommand {
|
|
@@ -11,10 +11,6 @@ export class List extends SanityCommand {
|
|
|
11
11
|
}
|
|
12
12
|
];
|
|
13
13
|
async run() {
|
|
14
|
-
const client = await this.getGlobalApiClient({
|
|
15
|
-
apiVersion: HOOK_API_VERSION,
|
|
16
|
-
requireUser: true
|
|
17
|
-
});
|
|
18
14
|
// Ensure we have project context
|
|
19
15
|
const projectId = await this.getProjectId();
|
|
20
16
|
if (!projectId) {
|
|
@@ -24,9 +20,7 @@ export class List extends SanityCommand {
|
|
|
24
20
|
}
|
|
25
21
|
let hooks;
|
|
26
22
|
try {
|
|
27
|
-
hooks = await
|
|
28
|
-
uri: `/hooks/projects/${projectId}`
|
|
29
|
-
});
|
|
23
|
+
hooks = await listHooksForProject(projectId);
|
|
30
24
|
} catch (error) {
|
|
31
25
|
const err = error;
|
|
32
26
|
listHookDebug(`Error fetching hooks for project ${projectId}`, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hook/list.ts"],"sourcesContent":["import {SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hook/list.ts"],"sourcesContent":["import {SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {listHooksForProject} from '../../services/hooks.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst listHookDebug = subdebug('hook:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List hooks for a given project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List hooks for a given project',\n },\n ]\n\n public async run() {\n // Ensure we have project context\n const projectId = await this.getProjectId()\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n let hooks: Hook[]\n try {\n hooks = await listHooksForProject(projectId)\n } catch (error) {\n const err = error as Error\n\n listHookDebug(`Error fetching hooks for project ${projectId}`, err)\n this.error(`Hook list retrieval failed:\\n${err.message}`, {exit: 1})\n }\n\n for (const hook of hooks) {\n this.log(`Name: ${hook.name}`)\n this.log(`Dataset: ${hook.dataset}`)\n this.log(`URL: ${hook.url}`)\n\n if (hook.type === 'document') {\n this.log(`HTTP method: ${hook.httpMethod}`)\n\n if (hook.description) {\n this.log(`Description: ${hook.description}`)\n }\n }\n\n this.log('')\n }\n }\n}\n"],"names":["SanityCommand","subdebug","listHooksForProject","NO_PROJECT_ID","listHookDebug","List","description","examples","command","run","projectId","getProjectId","error","exit","hooks","err","message","hook","log","name","dataset","url","type","httpMethod"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAGxD,SAAQC,mBAAmB,QAAO,0BAAyB;AAC3D,SAAQC,aAAa,QAAO,8BAA6B;AAEzD,MAAMC,gBAAgBH,SAAS;AAE/B,OAAO,MAAMI,aAAaL;IACxB,OAAgBM,cAAc,iCAAgC;IAC9D,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAM;QACjB,iCAAiC;QACjC,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY;QACzC,IAAI,CAACD,WAAW;YACd,IAAI,CAACE,KAAK,CAACT,eAAe;gBAACU,MAAM;YAAC;QACpC;QAEA,IAAIC;QACJ,IAAI;YACFA,QAAQ,MAAMZ,oBAAoBQ;QACpC,EAAE,OAAOE,OAAO;YACd,MAAMG,MAAMH;YAEZR,cAAc,CAAC,iCAAiC,EAAEM,WAAW,EAAEK;YAC/D,IAAI,CAACH,KAAK,CAAC,CAAC,6BAA6B,EAAEG,IAAIC,OAAO,EAAE,EAAE;gBAACH,MAAM;YAAC;QACpE;QAEA,KAAK,MAAMI,QAAQH,MAAO;YACxB,IAAI,CAACI,GAAG,CAAC,CAAC,MAAM,EAAED,KAAKE,IAAI,EAAE;YAC7B,IAAI,CAACD,GAAG,CAAC,CAAC,SAAS,EAAED,KAAKG,OAAO,EAAE;YACnC,IAAI,CAACF,GAAG,CAAC,CAAC,KAAK,EAAED,KAAKI,GAAG,EAAE;YAE3B,IAAIJ,KAAKK,IAAI,KAAK,YAAY;gBAC5B,IAAI,CAACJ,GAAG,CAAC,CAAC,aAAa,EAAED,KAAKM,UAAU,EAAE;gBAE1C,IAAIN,KAAKX,WAAW,EAAE;oBACpB,IAAI,CAACY,GAAG,CAAC,CAAC,aAAa,EAAED,KAAKX,WAAW,EAAE;gBAC7C;YACF;YAEA,IAAI,CAACY,GAAG,CAAC;QACX;IACF;AACF"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -40,9 +40,14 @@ export declare class InitCommand extends SanityCommand<typeof InitCommand> {
|
|
|
40
40
|
};
|
|
41
41
|
run(): Promise<void>;
|
|
42
42
|
private checkFlagsInUnattendedMode;
|
|
43
|
-
private
|
|
43
|
+
private createProjectFromName;
|
|
44
44
|
private ensureAuthenticated;
|
|
45
|
+
private getOrCreateDataset;
|
|
46
|
+
private getOrCreateProject;
|
|
45
47
|
private getPlan;
|
|
48
|
+
private getProjectDetails;
|
|
49
|
+
private promptForDefaultConfig;
|
|
50
|
+
private promptForProjectCreation;
|
|
46
51
|
private promptUserForNewOrganization;
|
|
47
52
|
private promptUserForOrganization;
|
|
48
53
|
private verifyCoupon;
|