Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
testSingleWebhookSubscriptionExtension,
placeholderAppConfiguration,
} from '../app/app.test-data.js'
import {ExtensionBuildOptions, buildUIExtension} from '../../services/build/extension.js'
import {ExtensionBuildOptions} from '../../services/build/extension.js'
import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
import {joinPath} from '@shopify/cli-kit/node/path'
import {describe, expect, test, vi} from 'vitest'
Expand Down Expand Up @@ -172,33 +172,6 @@ describe('build', async () => {
})
})

test('calls copyStaticAssets after buildUIExtension when building UI extensions', async () => {
await inTemporaryDirectory(async (tmpDir) => {
// Given
const extensionInstance = await testUIExtension({
type: 'ui_extension',
directory: tmpDir,
})

const copyStaticAssetsSpy = vi.spyOn(extensionInstance, 'copyStaticAssets').mockResolvedValue()
vi.mocked(buildUIExtension).mockResolvedValue()

const options: ExtensionBuildOptions = {
stdout: new Writable({write: vi.fn()}),
stderr: new Writable({write: vi.fn()}),
app: testApp(),
environment: 'production',
}

// When
await extensionInstance.build(options)

// Then
expect(buildUIExtension).toHaveBeenCalledWith(extensionInstance, options)
expect(copyStaticAssetsSpy).toHaveBeenCalledOnce()
})
})

test('does not copy shopify.extension.toml file when bundling theme extensions', async () => {
await inTemporaryDirectory(async (tmpDir) => {
// Given
Expand Down
10 changes: 0 additions & 10 deletions packages/app/src/cli/models/extensions/extension-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,6 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
return [...new Set(watchedFiles.map((file) => normalizePath(file)))]
}

/**
* Copy static assets from the extension directory to the output path
* Used by both dev and deploy builds
*/
async copyStaticAssets(outputPath?: string) {
if (this.specification.copyStaticAssets) {
return this.specification.copyStaticAssets(this.configuration, this.directory, outputPath ?? this.outputPath)
}
}

/**
* Rescans imports for this extension and updates the cached import paths
* Returns true if the imports changed
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/cli/models/extensions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ const NewExtensionPointSchema = zod.object({
should_render: ShouldRenderSchema.optional(),
tools: zod.string().optional(),
instructions: zod.string().optional(),
intents: zod
.array(
zod.object({
type: zod.string(),
action: zod.string(),
schema: zod.string(),
name: zod.string().optional(),
description: zod.string().optional(),
}),
)
.optional(),
metafields: zod.array(MetafieldSchema).optional(),
default_placement: zod.string().optional(),
urls: zod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const testClientSteps: ClientSteps = [
lifecycle: 'deploy',
steps: [
{
id: 'copy_static',
name: 'Copy static assets',
type: 'copy_static_assets',
id: 'bundle-ui',
name: 'Bundle UI Extension',
type: 'bundle_ui',
},
],
},
Expand Down
6 changes: 1 addition & 5 deletions packages/app/src/cli/models/extensions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum AssetIdentifier {
Main = 'main',
Tools = 'tools',
Instructions = 'instructions',
Intents = 'intents',
}

export interface Asset {
Expand Down Expand Up @@ -132,11 +133,6 @@ export interface ExtensionSpecification<TConfiguration extends BaseConfigType =
typeDefinitionsByFile: Map<string, Set<string>>,
) => Promise<void>

/**
* Copy static assets from the extension directory to the output path
*/
copyStaticAssets?: (configuration: TConfiguration, directory: string, outputPath: string) => Promise<void>

/**
* Custom watch configuration for dev sessions.
* Return a DevSessionWatchConfig with paths to watch and optionally paths to ignore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const checkoutPostPurchaseSpec = createExtensionSpecification({
clientSteps: [
{
lifecycle: 'deploy',
steps: [
{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}},
{id: 'copy-static-assets', name: 'Copy Static Assets', type: 'copy_static_assets', config: {}},
],
steps: [{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}}],
},
],
deployConfig: async (config, _) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const checkoutSpec = createExtensionSpecification({
clientSteps: [
{
lifecycle: 'deploy',
steps: [
{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}},
{id: 'copy-static-assets', name: 'Copy Static Assets', type: 'copy_static_assets', config: {}},
],
steps: [{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}}],
},
],
deployConfig: async (config, directory) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const posUISpec = createExtensionSpecification({
clientSteps: [
{
lifecycle: 'deploy',
steps: [
{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}},
{id: 'copy-static-assets', name: 'Copy Static Assets', type: 'copy_static_assets', config: {}},
],
steps: [{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}}],
},
],
deployConfig: async (config, directory) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ const productSubscriptionSpec = createExtensionSpecification({
clientSteps: [
{
lifecycle: 'deploy',
steps: [
{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}},
{id: 'copy-static-assets', name: 'Copy Static Assets', type: 'copy_static_assets', config: {}},
],
steps: [{id: 'bundle-ui', name: 'Bundle UI Extension', type: 'bundle_ui', config: {}}],
},
],
deployConfig: async (_, directory) => {
Expand Down
Loading
Loading