Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On deploy, make it impossible to deploy when scope is in the toml #5098

Draft
wants to merge 1 commit into
base: 12-12-on_dev_rewrite_scopes_to_required_scopes_
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/app/src/cli/models/extensions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export function createConfigExtensionSpecification<TConfiguration extends BaseCo
appConfig: CurrentAppConfiguration,
storeFqdn: string,
) => Promise<string>
preDeployValidation?: (extension: ExtensionInstance<TConfiguration>) => Promise<void>
}): ExtensionSpecification<TConfiguration> {
const appModuleFeatures = spec.appModuleFeatures ?? (() => [])
return createExtensionSpecification({
Expand All @@ -246,6 +247,7 @@ export function createConfigExtensionSpecification<TConfiguration extends BaseCo
experience: 'configuration',
uidStrategy: spec.uidStrategy ?? 'single',
getDevSessionActionUpdateMessage: spec.getDevSessionActionUpdateMessage,
preDeployValidation: spec.preDeployValidation,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {outputContent, outputToken} from '@shopify/cli-kit/node/output'
import {normalizeDelimitedString} from '@shopify/cli-kit/common/string'
import {zod} from '@shopify/cli-kit/node/schema'
import {AbortError} from '@shopify/cli-kit/node/error'

const AppAccessSchema = zod.object({
access: zod
Expand Down Expand Up @@ -51,6 +52,22 @@
const scopesURL = await buildAppURLForWeb(storeFqdn, appConfig.client_id)
return outputContent`Scopes updated. ${outputToken.link('Open app to accept scopes.', scopesURL)}`.value
},
preDeployValidation: async (extension: any) => {

Check failure on line 55 in packages/app/src/cli/models/extensions/specifications/app_config_app_access.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/models/extensions/specifications/app_config_app_access.ts#L55

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
const scopes = extension.configuration.access_scopes.scopes
if (scopes !== undefined) {
const requiredScopes: string[] = scopes.split(',')
const formattedRequiredScopes = requiredScopes.map((s) => `"${s}"`).join(', ')

Check failure on line 59 in packages/app/src/cli/models/extensions/specifications/app_config_app_access.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/models/extensions/specifications/app_config_app_access.ts#L59

[id-length] Identifier name 's' is too short (< 2).
throw new AbortError(
`The 'scopes' configuration is deprecated and no longer supported. It has been replaced by 'required_scopes'`,
`In your 'shopify.app.toml' file, replace 'scopes' with 'required_scopes'.

- scopes: "${scopes}"
+ required_scopes: [${formattedRequiredScopes}]
`,
)
}
return Promise.resolve()
},
})

export default appAccessSpec
Loading