Skip to content

Commit d455eb6

Browse files
authored
Merge pull request #6501 from Shopify/Remove_print_target_uniqueness_validator
Remove deprecated print action target uniqueness validator
2 parents be03157 + 7c417ca commit d455eb6

File tree

4 files changed

+5
-84
lines changed

4 files changed

+5
-84
lines changed

.changeset/beige-masks-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/app': patch
3+
---
4+
5+
Remove redundant Admin print action extension uniqueness validator

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -509,51 +509,6 @@ wrong = "property"
509509
await expect(loadTestingApp()).rejects.toThrow(/Duplicated handle/)
510510
})
511511

512-
test('throws an error if the app has more than one print action with the same target', async () => {
513-
// Given
514-
await writeConfig(appConfiguration)
515-
516-
const blockConfiguration = `
517-
api_version = "2022-07"
518-
519-
[[extensions]]
520-
type = "ui_extension"
521-
name = "my_extension_1"
522-
handle = "handle-1"
523-
description = "custom description"
524-
525-
[[extensions.targeting]]
526-
module = "./src/ActionExtension.js"
527-
target = "admin.product-details.print-action.render"
528-
529-
[[extensions]]
530-
type = "ui_extension"
531-
handle = "handle-2"
532-
name = "my_extension_2"
533-
description = "custom description"
534-
535-
[[extensions.targeting]]
536-
module = "./src/ActionExtension.js"
537-
target = "admin.product-details.print-action.render"
538-
`
539-
await writeBlockConfig({
540-
blockConfiguration,
541-
name: 'my_extension_1',
542-
})
543-
544-
// Create a temporary ActionExtension.js file
545-
const extensionDirectory = joinPath(tmpDir, 'extensions', 'my_extension_1', 'src')
546-
await mkdir(extensionDirectory)
547-
548-
const tempFilePath = joinPath(extensionDirectory, 'ActionExtension.js')
549-
await writeFile(tempFilePath, '/* ActionExtension.js content */')
550-
551-
// When
552-
await expect(loadTestingApp()).rejects.toThrow(
553-
`A single target can't support two print action extensions from the same app. Point your extensions at different targets, or remove an extension.\n\nThe following extensions both target admin.product-details.print-action.render:\n · handle-1\n · handle-2`,
554-
)
555-
})
556-
557512
test('throws an error if the extension configuration is unified and doesnt include a handle', async () => {
558513
// Given
559514
await writeConfig(appConfiguration, {

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {findConfigFiles} from '../../prompts/config.js'
3232
import {WebhookSubscriptionSpecIdentifier} from '../extensions/specifications/app_config_webhook_subscription.js'
3333
import {WebhooksSchema} from '../extensions/specifications/app_config_webhook_schemas/webhooks_schema.js'
3434
import {loadLocalExtensionsSpecifications} from '../extensions/load-specifications.js'
35-
import {UIExtensionSchemaType} from '../extensions/specifications/ui_extension.js'
3635
import {patchAppHiddenConfigFile} from '../../services/app/patch-app-configuration-file.js'
3736
import {getOrCreateAppConfigHiddenPath} from '../../utilities/app/config/hidden-app-config.js'
3837
import {ApplicationURLs, generateApplicationURLs} from '../../services/dev/urls.js'
@@ -545,10 +544,6 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
545544
}
546545
})
547546

548-
// Temporary code to validate that there is a single print action extension per target in an app.
549-
// Should be replaced by core validation.
550-
this.validatePrintActionExtensionsUniqueness(allExtensions)
551-
552547
return allExtensions
553548
}
554549

@@ -745,31 +740,6 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
745740
}
746741
}
747742

748-
private validatePrintActionExtensionsUniqueness(allExtensions: ExtensionInstance[]) {
749-
const duplicates: {[key: string]: ExtensionInstance[]} = {}
750-
751-
allExtensions
752-
.filter((ext) => ext.type === 'ui_extension')
753-
.forEach((extension) => {
754-
const points = extension.configuration.extension_points as UIExtensionSchemaType['extension_points']
755-
const targets = points.flatMap((point) => point.target).filter((target) => printTargets.includes(target))
756-
targets.forEach((target) => {
757-
const targetExtensions = duplicates[target] ?? []
758-
targetExtensions.push(extension)
759-
duplicates[target] = targetExtensions
760-
761-
if (targetExtensions.length > 1) {
762-
const extensionHandles = ['', ...targetExtensions.map((ext) => ext.configuration.handle)].join('\n · ')
763-
this.abortOrReport(
764-
outputContent`A single target can't support two print action extensions from the same app. Point your extensions at different targets, or remove an extension.\n\nThe following extensions both target ${target}:${extensionHandles}`,
765-
undefined,
766-
extension.configurationPath,
767-
)
768-
}
769-
})
770-
})
771-
}
772-
773743
private getDevApplicationURLs(currentConfiguration: TConfig, webs: Web[]): ApplicationURLs | undefined {
774744
const previousDevUrls = this.previousApp?.devApplicationURLs
775745
if (!previousDevUrls || !isCurrentAppSchema(currentConfiguration)) return previousDevUrls
@@ -1320,10 +1290,3 @@ export function isValidFormatAppConfigurationFileName(configName: string): confi
13201290
}
13211291
return false
13221292
}
1323-
1324-
const printTargets = [
1325-
'admin.order-details.print-action.render',
1326-
'admin.order-index.selection-print-action.render',
1327-
'admin.product-details.print-action.render',
1328-
'admin.product-index.selection-print-action.render',
1329-
]

packages/app/src/cli/models/extensions/specifications/ui_extension.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export interface BuildManifest {
3333

3434
const missingExtensionPointsMessage = 'No extension targets defined, add a `targeting` field to your configuration'
3535

36-
export type UIExtensionSchemaType = zod.infer<typeof UIExtensionSchema>
37-
3836
export const UIExtensionSchema = BaseSchema.extend({
3937
name: zod.string(),
4038
type: zod.literal('ui_extension'),

0 commit comments

Comments
 (0)