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

Add pos_ui_extension to migration for ui_extension #4162

Merged
merged 4 commits into from
Jul 5, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/rare-lizards-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli': minor
---

Added extension type pos_ui_extension to the ui_extension migration process
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 changes: 3 additions & 1 deletion packages/app/src/cli/services/context/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export async function extensionMigrationPrompt(
.map((name) => `"${name}"`)
.join(', ')

const migrationEndType = toMigrate.map(({local}) => `"${local.type}"`).join(', ')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the same structure as the other variables in the prompt, but oddly enough this always ends up being one value in the toMigrate, even if there are two extensions to be migrated. Then if you deploy again, it will go to the second extension that needs to be migrated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isaacroldan any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean you have 2 local ui_extensions and 2 remote pos_ui_extension but only 1 in the toMigrate?

The code at getUIExtensionsToMigrate is pretty simple, it just finds matching extensions locally and remotely, you can debug that method and see why it might not match a specific extension.

Also, specifically about this line of code, you are not filtering for duplicated types here, check how uniqueMigrationTypes does it just above.


renderInfo({
headline: "Extension migrations can't be undone.",
body: `Your ${migrationNames} configuration has been updated. Migrating gives you access to new features and won't impact the end user experience. All previous extension versions will reflect this change.`,
})

const confirmMessage = includeRemoteType
? `Yes, confirm migration from ${uniqueMigrationTypes}`
? `Yes, confirm migration from ${uniqueMigrationTypes} to ${migrationEndType}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-07-05 at 1 14 04 PM

: 'Yes, confirm migration'

return renderConfirmationPrompt({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ describe('getExtensionsToMigrate()', () => {
}

describe('if local.id matches remote.id', () => {
test('returns extensions where local.type is ui_extension but remote.type is POS_UI_EXTENSION', () => {
// Given
const localExtension = getLocalExtension({type: 'ui_extension'})
const remoteExtension = getRemoteExtension({type: 'POS_UI_EXTENSION'})

// When
const toMigrate = getUIExtensionsToMigrate([localExtension], [remoteExtension], defaultIds)

// Then
expect(toMigrate).toStrictEqual([{local: localExtension, remote: remoteExtension}])
})

test('returns extensions where local.type is ui_extension but remote.type is CHECKOUT_UI_EXTENSION', () => {
// Given
const localExtension = getLocalExtension({type: 'ui_extension'})
Expand All @@ -54,7 +66,7 @@ describe('getExtensionsToMigrate()', () => {
expect(toMigrate).toStrictEqual([])
})

test('does not return extensions where remote.type is not CHECKOUT_UI_EXTENSION', () => {
test('does not return extensions where remote.type is not CHECKOUT_UI_EXTENSION or POS_UI_EXTENSION', () => {
// Given
const localExtension = {...getLocalExtension(), type: 'ui_extension'}
const remoteExtension = {...getRemoteExtension(), type: 'PRODUCT_SUBSCRIPTION_UI_EXTENSION'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getUIExtensionsToMigrate(
identifiers: IdentifiersExtensions,
) {
const ids = getExtensionIds(localSources, identifiers)
const remoteExtensionTypesToMigrate = ['CHECKOUT_UI_EXTENSION']
const remoteExtensionTypesToMigrate = ['CHECKOUT_UI_EXTENSION', 'POS_UI_EXTENSION']

return localSources.reduce<LocalRemoteSource[]>((accumulator, localSource) => {
if (localSource.type === 'ui_extension') {
Expand Down