diff --git a/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.test.ts b/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.test.ts index c45f98bdf6..665b3d9a9e 100644 --- a/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.test.ts +++ b/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.test.ts @@ -7,9 +7,9 @@ vi.mock('@shopify/cli-kit/node/fs') describe('hosted_app_home', () => { describe('transform', () => { - test('should return the transformed object with static_root', () => { + test('should return the transformed object with static_root (local admin subsection to flat remote)', () => { const object = { - static_root: 'public', + admin: {static_root: 'public'}, } const appConfigSpec = spec @@ -20,7 +20,7 @@ describe('hosted_app_home', () => { }) }) - test('should return empty object when static_root is not provided', () => { + test('should return empty object when admin.static_root is not provided', () => { const object = {} const appConfigSpec = spec @@ -31,7 +31,7 @@ describe('hosted_app_home', () => { }) describe('reverseTransform', () => { - test('should return the reversed transformed object with static_root', () => { + test('should return the reversed transformed object (flat remote to local admin subsection)', () => { const object = { static_root: 'public', } @@ -40,7 +40,7 @@ describe('hosted_app_home', () => { const result = appConfigSpec.transformRemoteToLocal!(object) expect(result).toMatchObject({ - static_root: 'public', + admin: {static_root: 'public'}, }) }) @@ -57,7 +57,7 @@ describe('hosted_app_home', () => { describe('copyStaticAssets', () => { test('should copy static assets from source to output directory', async () => { vi.mocked(copyDirectoryContents).mockResolvedValue(undefined) - const config = {static_root: 'public'} + const config = {admin: {static_root: 'public'}} const directory = '/app/root' const outputPath = '/output/dist/bundle.js' @@ -66,7 +66,7 @@ describe('hosted_app_home', () => { expect(copyDirectoryContents).toHaveBeenCalledWith('/app/root/public', '/output/dist') }) - test('should not copy assets when static_root is not provided', async () => { + test('should not copy assets when admin.static_root is not provided', async () => { const config = {} const directory = '/app/root' const outputPath = '/output/dist/bundle.js' @@ -78,7 +78,7 @@ describe('hosted_app_home', () => { test('should throw error when copy fails', async () => { vi.mocked(copyDirectoryContents).mockRejectedValue(new Error('Permission denied')) - const config = {static_root: 'public'} + const config = {admin: {static_root: 'public'}} const directory = '/app/root' const outputPath = '/output/dist/bundle.js' diff --git a/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.ts b/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.ts index 6b71b71049..9b608fcef6 100644 --- a/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.ts +++ b/packages/app/src/cli/models/extensions/specifications/app_config_hosted_app_home.ts @@ -5,11 +5,15 @@ import {dirname, joinPath} from '@shopify/cli-kit/node/path' import {zod} from '@shopify/cli-kit/node/schema' const HostedAppHomeSchema = BaseSchemaWithoutHandle.extend({ - static_root: zod.string().optional(), + admin: zod + .object({ + static_root: zod.string().optional(), + }) + .optional(), }) const HostedAppHomeTransformConfig: TransformationConfig = { - static_root: 'static_root', + static_root: 'admin.static_root', } export const HostedAppHomeSpecIdentifier = 'hosted_app_home' @@ -20,8 +24,9 @@ const hostedAppHomeSpec = createConfigExtensionSpecification({ schema: HostedAppHomeSchema, transformConfig: HostedAppHomeTransformConfig, copyStaticAssets: async (config, directory, outputPath) => { - if (!config.static_root) return - const sourceDir = joinPath(directory, config.static_root) + const staticRoot = config.admin?.static_root + if (!staticRoot) return + const sourceDir = joinPath(directory, staticRoot) const outputDir = dirname(outputPath) return copyDirectoryContents(sourceDir, outputDir).catch((error) => {