File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed
Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ import {DevSessionCreateMutation} from '../api/graphql/app-dev/generated/dev-ses
5656import { DevSessionUpdateMutation } from '../api/graphql/app-dev/generated/dev-session-update.js'
5757import { DevSessionDeleteMutation } from '../api/graphql/app-dev/generated/dev-session-delete.js'
5858import { isAppManagementDisabled } from '@shopify/cli-kit/node/context/local'
59+ import { blockPartnersAccess } from '@shopify/cli-kit/node/environment'
60+ import { AbortError } from '@shopify/cli-kit/node/error'
5961
6062export enum ClientName {
6163 AppManagement = 'app-management' ,
@@ -77,7 +79,17 @@ export interface AppVersionIdentifiers {
7779}
7880
7981export function allDeveloperPlatformClients ( ) : DeveloperPlatformClient [ ] {
80- return isAppManagementDisabled ( ) ? [ new PartnersClient ( ) ] : [ new PartnersClient ( ) , new AppManagementClient ( ) ]
82+ const clients : DeveloperPlatformClient [ ] = [ ]
83+ if ( ! blockPartnersAccess ( ) ) {
84+ clients . push ( new PartnersClient ( ) )
85+ }
86+ if ( ! isAppManagementDisabled ( ) ) {
87+ clients . push ( new AppManagementClient ( ) )
88+ }
89+ if ( clients . length === 0 ) {
90+ throw new AbortError ( 'Both Partners and App Management APIs are deactivated.' )
91+ }
92+ return clients
8193}
8294
8395/**
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export const environmentVariables = {
4545 otelURL : 'SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT' ,
4646 themeKitAccessDomain : 'SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN' ,
4747 json : 'SHOPIFY_FLAG_JSON' ,
48+ neverUsePartnersApi : 'SHOPIFY_CLI_NEVER_USE_PARTNERS_API' ,
4849}
4950
5051export const defaultThemeKitAccessDomain = 'theme-kit-access.shopifyapps.com'
Original file line number Diff line number Diff line change 11import { spinFqdn } from './spin.js'
2- import { AbortError } from '../error.js'
2+ import { AbortError , BugError } from '../error.js'
33import { serviceEnvironment } from '../../../private/node/context/service.js'
44import { DevServer , DevServerCore } from '../vendor/dev_server/DevServer.js'
5+ import { blockPartnersAccess } from '../environment.js'
56
67export const CouldntObtainPartnersSpinFQDNError = new AbortError (
78 "Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment." ,
@@ -22,6 +23,9 @@ export const NotProvidedStoreFQDNError = new AbortError(
2223 * @returns Fully-qualified domain of the partners service we should interact with.
2324 */
2425export async function partnersFqdn ( ) : Promise < string > {
26+ if ( blockPartnersAccess ( ) ) {
27+ throw new BugError ( 'Partners API is blocked by the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable.' )
28+ }
2529 const environment = serviceEnvironment ( )
2630 const productionFqdn = 'partners.shopify.com'
2731 switch ( environment ) {
Original file line number Diff line number Diff line change @@ -82,3 +82,12 @@ export function getIdentityTokenInformation(): {accessToken: string; refreshToke
8282export function jsonOutputEnabled ( environment = getEnvironmentVariables ( ) ) : boolean {
8383 return sniffForJson ( ) || isTruthy ( environment [ environmentVariables . json ] )
8484}
85+
86+ /**
87+ * If true, the CLI should not use the Partners API.
88+ *
89+ * @returns True if the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable is set.
90+ */
91+ export function blockPartnersAccess ( ) : boolean {
92+ return isTruthy ( getEnvironmentVariables ( ) [ environmentVariables . neverUsePartnersApi ] )
93+ }
You can’t perform that action at this time.
0 commit comments