Skip to content

Commit 810b2e3

Browse files
isaacroldanClaude Code
andcommitted
Fix CI: update test expectations, lint formatting, unexport AppAssetsConfig
Co-authored-by: Claude Code <claude-code@anthropic.com>
1 parent b26213c commit 810b2e3

File tree

15 files changed

+288
-83
lines changed

15 files changed

+288
-83
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ export interface AppInterface<
229229
realExtensions: ExtensionInstance[]
230230
nonConfigExtensions: ExtensionInstance[]
231231
draftableExtensions: ExtensionInstance[]
232-
appAssetsConfigs: Record<string, string> | undefined
233232
errors: AppErrors
234233
hiddenConfig: AppHiddenConfig
235234
includeConfigOnDeploy: boolean | undefined
@@ -335,15 +334,6 @@ export class App<
335334
)
336335
}
337336

338-
get appAssetsConfigs(): Record<string, string> | undefined {
339-
if (!this.realExtensions.some((ext) => ext.specification.appAssetsConfig)) return undefined
340-
return this.realExtensions.reduce<Record<string, string>>((acc, ext) => {
341-
const config = ext.specification.appAssetsConfig?.(ext.configuration)
342-
if (config) acc[config.assetsKey] = joinPath(this.directory, config.assetsDir)
343-
return acc
344-
}, {})
345-
}
346-
347337
setDevApplicationURLs(devApplicationURLs: ApplicationURLs) {
348338
this.patchAppConfiguration(devApplicationURLs)
349339
this.realExtensions.forEach((ext) => ext.patchWithAppDevURLs(devApplicationURLs))

packages/app/src/cli/models/extensions/specification.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,6 @@ export interface ExtensionSpecification<TConfiguration extends BaseConfigType =
143143
* or undefined to watch all files in the extension directory.
144144
*/
145145
devSessionWatchConfig?: (extension: ExtensionInstance<TConfiguration>) => DevSessionWatchConfig | undefined
146-
147-
/**
148-
* App assets configuration for this extension.
149-
* Return undefined if this extension doesn't serve app assets.
150-
*/
151-
appAssetsConfig?: (config: TConfiguration) => AppAssetsConfig | undefined
152-
}
153-
154-
export interface AppAssetsConfig {
155-
/** The config key that points to the assets directory (e.g. 'admin.static_root') */
156-
assetsKey: string
157-
/** The assets directory relative to the extension directory */
158-
assetsDir: string
159146
}
160147

161148
export interface DevSessionWatchConfig {

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ const AdminSchema = zod.object({
77
admin: zod
88
.object({
99
static_root: zod.string().optional(),
10+
allowed_domains: zod.array(zod.string()).optional(),
1011
})
1112
.optional(),
1213
})
1314

14-
type AdminConfigType = zod.infer<typeof AdminSchema> & BaseConfigType
15+
export type AdminConfigType = zod.infer<typeof AdminSchema> & BaseConfigType
1516

1617
const adminSpecificationSpec = createExtensionSpecification<AdminConfigType>({
1718
identifier: 'admin',
@@ -33,6 +34,8 @@ const adminSpecificationSpec = createExtensionSpecification<AdminConfigType>({
3334
admin: {
3435
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3536
static_root: (remoteContent as any).admin.static_root,
37+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38+
allowed_domains: (remoteContent as any).admin.allowed_domains,
3639
},
3740
}
3841
},
@@ -62,11 +65,6 @@ const adminSpecificationSpec = createExtensionSpecification<AdminConfigType>({
6265
},
6366
],
6467
appModuleFeatures: () => [],
65-
appAssetsConfig: (config) => {
66-
const dir = config.admin?.static_root
67-
if (!dir) return undefined
68-
return {assetsKey: 'staticRoot', assetsDir: dir}
69-
},
7068
})
7169

7270
export default adminSpecificationSpec

packages/app/src/cli/services/build/steps/include-assets-step.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,10 +1082,7 @@ describe('executeIncludeAssetsStep', () => {
10821082

10831083
// When / Then — overwrites existing manifest.json
10841084
await expect(executeIncludeAssetsStep(step, contextWithConfig)).resolves.not.toThrow()
1085-
expect(fs.writeFile).toHaveBeenCalledWith(
1086-
'/test/output/manifest.json',
1087-
expect.any(String),
1088-
)
1085+
expect(fs.writeFile).toHaveBeenCalledWith('/test/output/manifest.json', expect.any(String))
10891086
})
10901087

10911088
test('writes an empty manifest when anchor resolves to a non-array value', async () => {

packages/app/src/cli/services/dev/extension.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ describe('devUIExtensions()', () => {
3333

3434
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3535
// @ts-ignore
36-
vi.spyOn(store, 'ExtensionsPayloadStore').mockImplementation(() => ({mock: 'payload-store'}))
36+
vi.spyOn(store, 'ExtensionsPayloadStore').mockImplementation(
37+
() =>
38+
({
39+
mock: 'payload-store',
40+
updateAdminConfigFromExtensionEvents: vi.fn(),
41+
getAppAssets: vi.fn(),
42+
}) as unknown as store.ExtensionsPayloadStore,
43+
)
3744
vi.spyOn(server, 'setupHTTPServer').mockReturnValue({
3845
mock: 'http-server',
3946
close: serverCloseSpy,
@@ -67,8 +74,9 @@ describe('devUIExtensions()', () => {
6774
// THEN
6875
expect(server.setupHTTPServer).toHaveBeenCalledWith({
6976
devOptions: {...options, websocketURL: 'wss://mock.url/extensions'},
70-
payloadStore: {mock: 'payload-store'},
77+
payloadStore: expect.objectContaining({mock: 'payload-store'}),
7178
getExtensions: expect.any(Function),
79+
getAppAssets: expect.any(Function),
7280
})
7381
})
7482

@@ -94,7 +102,7 @@ describe('devUIExtensions()', () => {
94102
expect(websocket.setupWebsocketConnection).toHaveBeenCalledWith({
95103
...options,
96104
httpServer: expect.objectContaining({mock: 'http-server'}),
97-
payloadStore: {mock: 'payload-store'},
105+
payloadStore: expect.objectContaining({mock: 'payload-store'}),
98106
websocketURL: 'wss://mock.url/extensions',
99107
})
100108
})

packages/app/src/cli/services/dev/extension.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {ExtensionInstance} from '../../models/extensions/extension-instance.js'
1212
import {AbortSignal} from '@shopify/cli-kit/node/abort'
1313
import {outputDebug} from '@shopify/cli-kit/node/output'
1414
import {DotEnvFile} from '@shopify/cli-kit/node/dot-env'
15-
import {getArrayRejectingUndefined} from '@shopify/cli-kit/common/array'
1615
import {Writable} from 'stream'
1716

1817
export interface ExtensionDevOptions {
@@ -36,7 +35,8 @@ export interface ExtensionDevOptions {
3635
buildDirectory?: string
3736

3837
/**
39-
* The extension to be built.
38+
* All real extensions in the app, including non-previewable ones (e.g., admin config).
39+
* Previewable extensions are filtered internally for the UI payload.
4040
*/
4141
extensions: ExtensionInstance[]
4242

@@ -113,11 +113,6 @@ export interface ExtensionDevOptions {
113113
* The app watcher that emits events when the app is updated
114114
*/
115115
appWatcher: AppEventWatcher
116-
117-
/**
118-
* Map of asset key to absolute directory path for app-level assets (e.g., admin static_root)
119-
*/
120-
appAssets?: Record<string, string>
121116
}
122117

123118
export async function devUIExtensions(options: ExtensionDevOptions): Promise<void> {
@@ -132,14 +127,14 @@ export async function devUIExtensions(options: ExtensionDevOptions): Promise<voi
132127
const bundlePath = payloadOptions.appWatcher.buildOutputPath
133128
const payloadStoreRawPayload = await getExtensionsPayloadStoreRawPayload(payloadOptions, bundlePath)
134129
const payloadStore = new ExtensionsPayloadStore(payloadStoreRawPayload, payloadOptions)
135-
let extensions = payloadOptions.extensions
130+
let extensions = payloadOptions.extensions.filter((ext) => ext.isPreviewable)
136131

137132
const getExtensions = () => {
138133
return extensions
139134
}
140135

141136
outputDebug(`Setting up the UI extensions HTTP server...`, payloadOptions.stdout)
142-
const getAppAssets = () => payloadOptions.appAssets
137+
const getAppAssets = () => payloadStore.getAppAssets()
143138
const httpServer = setupHTTPServer({
144139
devOptions: payloadOptions,
145140
payloadStore,
@@ -156,13 +151,10 @@ export async function devUIExtensions(options: ExtensionDevOptions): Promise<voi
156151
extensions = app.allExtensions.filter((ext) => ext.isPreviewable)
157152
}
158153

159-
// Handle App Assets updates.
160-
const appAssetsConfigs = extensionEvents.map((event) =>
161-
event.extension.specification.appAssetsConfig?.(event.extension.configuration),
162-
)
163-
getArrayRejectingUndefined(appAssetsConfigs).forEach((config) => {
164-
payloadStore.updateAppAssetTimestamp(config.assetsKey)
165-
})
154+
// Exception for AdminConfig: it's a extension that needs its config extracted at the app level
155+
// for the payloed. No other exceptions should be added, if this pattern is needed again we should
156+
// generalize it.
157+
payloadStore.updateAdminConfigFromExtensionEvents(extensionEvents)
166158

167159
for (const event of extensionEvents) {
168160
if (!event.extension.isPreviewable) continue

packages/app/src/cli/services/dev/extension/payload/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface ExtensionsPayloadInterface {
88
url: string
99
mobileUrl: string
1010
title: string
11+
allowedDomains?: string[]
1112
assets?: {
1213
[key: string]: {
1314
url: string

0 commit comments

Comments
 (0)