Skip to content

Commit 1b47f9a

Browse files
authored
Merge pull request #6524 from Shopify/10-16-surface_rewritten_liquid_files_to_dev_and_push_commands
Surface rewritten liquid files to dev and push commands
2 parents 13e54c7 + 32f489c commit 1b47f9a

File tree

15 files changed

+358
-65
lines changed

15 files changed

+358
-65
lines changed

.changeset/sour-boats-grab.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/cli-kit': minor
3+
'@shopify/theme': minor
4+
---
5+
6+
Add ability to notify user when Liquid files are rewritten remotely

packages/cli-kit/src/cli/api/graphql/admin/generated/theme_files_upsert.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type ThemeFilesUpsertMutationVariables = Types.Exact<{
1010

1111
export type ThemeFilesUpsertMutation = {
1212
themeFilesUpsert?: {
13-
upsertedThemeFiles?: {filename: string}[] | null
13+
upsertedThemeFiles?: {filename: string; checksumMd5?: string | null}[] | null
1414
userErrors: {filename?: string | null; message: string}[]
1515
} | null
1616
}
@@ -71,6 +71,7 @@ export const ThemeFilesUpsert = {
7171
kind: 'SelectionSet',
7272
selections: [
7373
{kind: 'Field', name: {kind: 'Name', value: 'filename'}},
74+
{kind: 'Field', name: {kind: 'Name', value: 'checksumMd5'}},
7475
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
7576
],
7677
},

packages/cli-kit/src/cli/api/graphql/admin/mutations/theme_files_upsert.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $the
22
themeFilesUpsert(files: $files, themeId: $themeId) {
33
upsertedThemeFiles {
44
filename
5+
checksumMd5
56
}
67
userErrors {
78
filename

packages/cli-kit/src/public/node/themes/api.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,19 @@ describe('bulkUploadThemeAssets', async () => {
553553
key: 'snippets/product-variant-picker.liquid',
554554
success: true,
555555
operation: Operation.Upload,
556+
asset: {
557+
checksum: '',
558+
key: 'snippets/product-variant-picker.liquid',
559+
},
556560
},
557561
{
558562
key: 'templates/404.json',
559563
success: true,
560564
operation: Operation.Upload,
565+
asset: {
566+
checksum: '',
567+
key: 'templates/404.json',
568+
},
561569
},
562570
])
563571
})

packages/cli-kit/src/public/node/themes/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ function processUploadResults(uploadResults: ThemeFilesUpsertMutation): Result[]
315315
key: file.filename,
316316
success: true,
317317
operation: Operation.Upload,
318+
asset: {
319+
key: file.filename,
320+
checksum: file.checksumMd5 ?? '',
321+
},
318322
})
319323
})
320324

packages/theme/src/cli/services/dev.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ export async function dev(options: DevOptions) {
101101
session.storefrontPassword = await storefrontPasswordPromise
102102
}
103103

104-
const {serverStart, renderDevSetupProgress} = setupDevServer(options.theme, ctx)
104+
const {serverStart, renderDevSetupProgress, syncRewrittenFilesPromise} = setupDevServer(options.theme, ctx)
105105

106106
if (!options['theme-editor-sync']) {
107107
session.storefrontPassword = await storefrontPasswordPromise
108108
}
109109

110110
await renderDevSetupProgress()
111111
await serverStart()
112+
await syncRewrittenFilesPromise()
112113

113114
renderLinks(urls)
114115
if (options.open) {

packages/theme/src/cli/services/push.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('push', () => {
4949
workPromise: Promise.resolve(),
5050
uploadResults: new Map(),
5151
renderThemeSyncProgress: () => Promise.resolve(),
52+
syncRewrittenFilesPromise: Promise.resolve(),
5253
})
5354
vi.mocked(ensureThemeStore).mockReturnValue('example.myshopify.com')
5455
vi.mocked(ensureAuthenticatedThemes).mockResolvedValue(adminSession)
@@ -93,6 +94,7 @@ describe('push', () => {
9394
workPromise: Promise.resolve(),
9495
uploadResults,
9596
renderThemeSyncProgress: () => Promise.resolve(),
97+
syncRewrittenFilesPromise: Promise.resolve(),
9698
})
9799

98100
// When

packages/theme/src/cli/services/push.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,20 @@ async function executePush(
205205
const themeFileSystem = mountThemeFileSystem(options.path, {filters: options})
206206
recordTiming('theme-service:push:file-system')
207207

208-
const {uploadResults, renderThemeSyncProgress} = uploadTheme(
208+
const {uploadResults, renderThemeSyncProgress, syncRewrittenFilesPromise} = uploadTheme(
209209
theme,
210210
session,
211211
themeChecksums,
212212
themeFileSystem,
213-
options,
213+
{
214+
...options,
215+
handleRewrittenFiles: 'warn',
216+
},
214217
context,
215218
)
216219

217220
await renderThemeSyncProgress()
221+
await syncRewrittenFilesPromise
218222

219223
if (options.publish) {
220224
await themePublish(theme.id, session)

packages/theme/src/cli/utilities/theme-downloader.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ function buildDownloadTasks(
8686
return batches
8787
}
8888

89-
async function downloadFiles(theme: Theme, fileSystem: ThemeFileSystem, filenames: string[], session: AdminSession) {
89+
export async function downloadFiles(
90+
theme: Theme,
91+
fileSystem: ThemeFileSystem,
92+
filenames: string[],
93+
session: AdminSession,
94+
) {
9095
const assets = await fetchThemeAssets(theme.id, filenames, session)
9196
if (!assets) return
9297

packages/theme/src/cli/utilities/theme-environment/theme-environment.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ vi.mock('../theme-uploader.js', async () => {
3434
})
3535
beforeEach(() => {
3636
vi.mocked(uploadTheme).mockImplementation(() => {
37-
return {workPromise: Promise.resolve(), uploadResults: new Map(), renderThemeSyncProgress: () => Promise.resolve()}
37+
return {
38+
workPromise: Promise.resolve(),
39+
uploadResults: new Map(),
40+
renderThemeSyncProgress: () => Promise.resolve(),
41+
syncRewrittenFilesPromise: Promise.resolve(),
42+
}
3843
})
3944
})
4045

@@ -126,6 +131,7 @@ describe('setupDevServer', () => {
126131
nodelete: true,
127132
deferPartialWork: true,
128133
backgroundWorkCatch: expect.any(Function),
134+
handleRewrittenFiles: 'fix',
129135
})
130136
})
131137

@@ -176,6 +182,7 @@ describe('setupDevServer', () => {
176182
nodelete: true,
177183
deferPartialWork: true,
178184
backgroundWorkCatch: expect.any(Function),
185+
handleRewrittenFiles: 'fix',
179186
})
180187
})
181188

0 commit comments

Comments
 (0)