Skip to content

Commit a8f4c35

Browse files
Merge pull request #5818 from Shopify/shauns/05-16-remove_opt-out_for_improve_config_module_loading
Remove opt-out for improve config module loading
2 parents 0466057 + e66b6e3 commit a8f4c35

File tree

4 files changed

+12
-64
lines changed

4 files changed

+12
-64
lines changed

.changeset/funny-pumpkins-smash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/app': minor
3+
---
4+
5+
Opt-out removed for validation of unsupported app configuration sections

packages/app/src/cli/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const environmentVariableNames = {
55
enableAppLogPolling: 'SHOPIFY_CLI_ENABLE_APP_LOG_POLLING',
66
templatesJsonPath: 'SHOPIFY_CLI_APP_TEMPLATES_JSON_PATH',
77
mkcertBinaryPath: 'SHOPIFY_CLI_MKCERT_BINARY',
8-
disableUnsupportedConfigPropertyChecks: 'SHOPIFY_CLI_DISABLE_UNSUPPORTED_CONFIG_PROPERTY_CHECKS',
98
disableMinificationOnDev: 'SHOPIFY_CLI_DISABLE_MINIFICATION_ON_DEV',
109
}
1110

packages/app/src/cli/models/app/loader.test.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ wrong = "property"
25692569
await expect(loadTestingApp()).rejects.toThrow(AbortError)
25702570
})
25712571

2572-
test('loads the app with an unsupported config property, under failure mode (default)', async () => {
2572+
test('loads the app with an unsupported config property', async () => {
25732573
const linkedAppConfigurationWithExtraConfig = `
25742574
name = "for-testing"
25752575
client_id = "1234567890"
@@ -2597,42 +2597,6 @@ wrong = "property"
25972597
'Unsupported section(s) in app configuration: and_another, something_else',
25982598
)
25992599
})
2600-
2601-
test('loads the app with an unsupported config property, under passthrough mode', async () => {
2602-
vi.stubEnv('SHOPIFY_CLI_DISABLE_UNSUPPORTED_CONFIG_PROPERTY_CHECKS', '1')
2603-
const linkedAppConfigurationWithExtraConfig = `
2604-
name = "for-testing"
2605-
client_id = "1234567890"
2606-
application_url = "https://example.com/lala"
2607-
embedded = true
2608-
2609-
[build]
2610-
include_config_on_deploy = true
2611-
2612-
[webhooks]
2613-
api_version = "2023-07"
2614-
2615-
[auth]
2616-
redirect_urls = [ "https://example.com/api/auth" ]
2617-
2618-
[something_else]
2619-
not_valid = true
2620-
2621-
[and_another]
2622-
bad = true
2623-
`
2624-
await writeConfig(linkedAppConfigurationWithExtraConfig)
2625-
2626-
const app = await loadTestingApp()
2627-
expect(app.allExtensions.map((ext) => ext.specification.identifier).sort()).toEqual([
2628-
'app_access',
2629-
'app_home',
2630-
'branding',
2631-
'webhooks',
2632-
])
2633-
2634-
vi.unstubAllEnvs()
2635-
})
26362600
})
26372601

26382602
describe('getAppConfigurationFileName', () => {

packages/app/src/cli/models/app/loader.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
AppHiddenConfig,
2020
isLegacyAppSchema,
2121
} from './app.js'
22-
import {configurationFileNames, dotEnvFileNames, environmentVariableNames} from '../../constants.js'
22+
import {configurationFileNames, dotEnvFileNames} from '../../constants.js'
2323
import metadata from '../../metadata.js'
2424
import {ExtensionInstance} from '../extensions/extension-instance.js'
2525
import {ExtensionsArraySchema, UnifiedSchema} from '../extensions/schemas.js'
@@ -55,8 +55,6 @@ import {joinWithAnd, slugify} from '@shopify/cli-kit/common/string'
5555
import {getArrayRejectingUndefined} from '@shopify/cli-kit/common/array'
5656
import {showNotificationsIfNeeded} from '@shopify/cli-kit/node/notifications-system'
5757
import ignore from 'ignore'
58-
import {getEnvironmentVariables} from '@shopify/cli-kit/node/environment'
59-
import {isTruthy} from '@shopify/cli-kit/node/context/utilities'
6058

6159
const defaultExtensionDirectory = 'extensions/*'
6260

@@ -182,18 +180,6 @@ export function parseConfigurationObjectAgainstSpecification<TSchema extends zod
182180
}
183181
}
184182

185-
/**
186-
* Returns true if we should fail if an unsupported app.toml config property is found.
187-
*
188-
* This is deactivated if SHOPIFY_CLI_DISABLE_UNSUPPORTED_CONFIG_PROPERTY_CHECKS is set
189-
*/
190-
async function shouldFailIfUnsupportedConfigProperty(): Promise<boolean> {
191-
const env = getEnvironmentVariables()
192-
// devs can also opt-out
193-
const disableUnsupportedConfigPropertyChecks = env[environmentVariableNames.disableUnsupportedConfigPropertyChecks]
194-
return !isTruthy(disableUnsupportedConfigPropertyChecks)
195-
}
196-
197183
export class AppErrors {
198184
private errors: {
199185
[key: string]: OutputMessage
@@ -656,8 +642,6 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
656642
}
657643

658644
private async createConfigExtensionInstances(directory: string, appConfiguration: TConfig & CurrentAppConfiguration) {
659-
const failIfUnsupportedConfigProperty = await shouldFailIfUnsupportedConfigProperty()
660-
661645
const extensionInstancesWithKeys = await Promise.all(
662646
this.specifications
663647
.filter((specification) => specification.uidStrategy === 'single')
@@ -697,15 +681,11 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
697681
})
698682

699683
if (unusedKeys.length > 0) {
700-
if (failIfUnsupportedConfigProperty) {
701-
this.abortOrReport(
702-
outputContent`Unsupported section(s) in app configuration: ${unusedKeys.sort().join(', ')}`,
703-
undefined,
704-
appConfiguration.path,
705-
)
706-
} else {
707-
outputDebug(outputContent`Unused keys in app configuration: ${outputToken.json(unusedKeys)}`)
708-
}
684+
this.abortOrReport(
685+
outputContent`Unsupported section(s) in app configuration: ${unusedKeys.sort().join(', ')}`,
686+
undefined,
687+
appConfiguration.path,
688+
)
709689
}
710690
return extensionInstancesWithKeys
711691
.filter(([instance]) => instance)

0 commit comments

Comments
 (0)