Skip to content

Commit e66b6e3

Browse files
committed
Remove opt-out for improve config module loading
1 parent d691457 commit e66b6e3

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
disableWasmTomlPatch: 'SHOPIFY_CLI_DISABLE_WASM_TOML_PATCH',
1110
}

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

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

2550-
test('loads the app with an unsupported config property, under failure mode (default)', async () => {
2550+
test('loads the app with an unsupported config property', async () => {
25512551
const linkedAppConfigurationWithExtraConfig = `
25522552
name = "for-testing"
25532553
client_id = "1234567890"
@@ -2575,42 +2575,6 @@ wrong = "property"
25752575
'Unsupported section(s) in app configuration: and_another, something_else',
25762576
)
25772577
})
2578-
2579-
test('loads the app with an unsupported config property, under passthrough mode', async () => {
2580-
vi.stubEnv('SHOPIFY_CLI_DISABLE_UNSUPPORTED_CONFIG_PROPERTY_CHECKS', '1')
2581-
const linkedAppConfigurationWithExtraConfig = `
2582-
name = "for-testing"
2583-
client_id = "1234567890"
2584-
application_url = "https://example.com/lala"
2585-
embedded = true
2586-
2587-
[build]
2588-
include_config_on_deploy = true
2589-
2590-
[webhooks]
2591-
api_version = "2023-07"
2592-
2593-
[auth]
2594-
redirect_urls = [ "https://example.com/api/auth" ]
2595-
2596-
[something_else]
2597-
not_valid = true
2598-
2599-
[and_another]
2600-
bad = true
2601-
`
2602-
await writeConfig(linkedAppConfigurationWithExtraConfig)
2603-
2604-
const app = await loadTestingApp()
2605-
expect(app.allExtensions.map((ext) => ext.specification.identifier).sort()).toEqual([
2606-
'app_access',
2607-
'app_home',
2608-
'branding',
2609-
'webhooks',
2610-
])
2611-
2612-
vi.unstubAllEnvs()
2613-
})
26142578
})
26152579

26162580
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'
@@ -54,8 +54,6 @@ import {joinWithAnd, slugify} from '@shopify/cli-kit/common/string'
5454
import {getArrayRejectingUndefined} from '@shopify/cli-kit/common/array'
5555
import {showNotificationsIfNeeded} from '@shopify/cli-kit/node/notifications-system'
5656
import ignore from 'ignore'
57-
import {getEnvironmentVariables} from '@shopify/cli-kit/node/environment'
58-
import {isTruthy} from '@shopify/cli-kit/node/context/utilities'
5957

6058
const defaultExtensionDirectory = 'extensions/*'
6159

@@ -181,18 +179,6 @@ export function parseConfigurationObjectAgainstSpecification<TSchema extends zod
181179
}
182180
}
183181

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

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

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

0 commit comments

Comments
 (0)