Skip to content
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
20 changes: 11 additions & 9 deletions packages/app/src/cli/models/extensions/extension-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {WebhooksSpecIdentifier} from './specifications/app_config_webhook.js'
import {WebhookSubscriptionSpecIdentifier} from './specifications/app_config_webhook_subscription.js'
import {
ExtensionBuildOptions,
buildFlowTemplateExtension,
buildFunctionExtension,
buildThemeExtension,
buildUIExtension,
Expand Down Expand Up @@ -135,7 +134,14 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
}

get outputFileName() {
return this.isFunctionExtension ? 'index.wasm' : `${this.handle}.js`
const mode = this.specification.buildConfig.mode
if (mode === 'copy_files' || mode === 'theme') {
return ''
} else if (mode === 'function') {
return 'index.wasm'
} else {
return `${this.handle}.js`
}
}

constructor(options: {
Expand Down Expand Up @@ -344,13 +350,12 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi

switch (mode) {
case 'theme':
return buildThemeExtension(this, options)
await buildThemeExtension(this, options)
return bundleThemeExtension(this, options)
case 'function':
return buildFunctionExtension(this, options)
case 'ui':
return buildUIExtension(this, options)
case 'flow':
return buildFlowTemplateExtension(this, options)
case 'tax_calculation':
await touchFile(this.outputPath)
await writeFile(this.outputPath, '(()=>{})();')
Expand All @@ -371,9 +376,6 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
this.outputPath = this.getOutputPathForDirectory(bundleDirectory, outputId)

await this.build(options)
if (this.isThemeExtension) {
await bundleThemeExtension(this, options)
}

const bundleInputPath = joinPath(bundleDirectory, this.getOutputFolderId(outputId))
await this.keepBuiltSourcemapsLocally(bundleInputPath)
Expand Down Expand Up @@ -402,7 +404,7 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi

getOutputPathForDirectory(directory: string, outputId?: string) {
const id = this.getOutputFolderId(outputId)
const outputFile = this.isThemeExtension ? '' : joinPath('dist', this.outputFileName)
const outputFile = this.outputFileName === '' ? '' : joinPath('dist', this.outputFileName)
return joinPath(directory, id, outputFile)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/models/extensions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Asset {
}

type BuildConfig =
| {mode: 'ui' | 'theme' | 'flow' | 'function' | 'tax_calculation' | 'none'}
| {mode: 'ui' | 'theme' | 'function' | 'tax_calculation' | 'none'}
| {mode: 'copy_files'; filePatterns: string[]; ignoredFilePatterns?: string[]}
/**
* Extension specification with all the needed properties and methods to load an extension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const flowTemplateSpec = createExtensionSpecification({
identifier: 'flow_template',
schema: FlowTemplateExtensionSchema,
appModuleFeatures: (_) => ['ui_preview'],
buildConfig: {mode: 'flow'},
buildConfig: {mode: 'copy_files', filePatterns: ['*.flow', '*.json', '*.toml']},
deployConfig: async (config, extensionPath) => {
return {
template_handle: config.handle,
Expand Down
15 changes: 1 addition & 14 deletions packages/app/src/cli/services/build/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {runThemeCheck} from './theme-check.js'
import {AppInterface} from '../../models/app/app.js'
import {bundleExtension, bundleFlowTemplateExtension} from '../extensions/bundle.js'
import {bundleExtension} from '../extensions/bundle.js'
import {buildJSFunction, runTrampoline, runWasmOpt} from '../function/build.js'
import {ExtensionInstance} from '../../models/extensions/extension-instance.js'
import {FunctionConfigType} from '../../models/extensions/specifications/function.js'
Expand Down Expand Up @@ -65,19 +65,6 @@ export async function buildThemeExtension(extension: ExtensionInstance, options:
if (offenses) options.stdout.write(offenses)
}

/**
* It builds the flow template extensions.
* @param options - Build options.
*/
export async function buildFlowTemplateExtension(
extension: ExtensionInstance,
options: ExtensionBuildOptions,
): Promise<void> {
options.stdout.write(`Building Flow Template extension ${extension.localIdentifier}...`)
await bundleFlowTemplateExtension(extension)
options.stdout.write(`${extension.localIdentifier} successfully built`)
}

/**
* It builds the UI extensions.
* @param options - Build options.
Expand Down
12 changes: 0 additions & 12 deletions packages/app/src/cli/services/extensions/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {ExtensionBuildOptions} from '../build/extension.js'
import {ExtensionInstance} from '../../models/extensions/extension-instance.js'
import {themeExtensionFiles} from '../../utilities/extensions/theme.js'
import {EsbuildEnvVarRegex, environmentVariableNames} from '../../constants.js'
import {flowTemplateExtensionFiles} from '../../utilities/extensions/flow-template.js'
import {context as esContext, formatMessagesSync} from 'esbuild'
import {AbortSignal} from '@shopify/cli-kit/node/abort'
import {copyFile, glob} from '@shopify/cli-kit/node/fs'
Expand Down Expand Up @@ -69,17 +68,6 @@ export async function bundleThemeExtension(
options.stdout.write(`Bundling theme extension ${extension.localIdentifier}...`)
const files = await themeExtensionFiles(extension)

await Promise.all(
files.map(function (filepath) {
const relativePathName = relativePath(extension.directory, filepath)
const outputFile = joinPath(extension.outputPath, relativePathName)
return copyFile(filepath, outputFile)
}),
)
}

export async function bundleFlowTemplateExtension(extension: ExtensionInstance): Promise<void> {
const files = await flowTemplateExtensionFiles(extension)
await Promise.all(
files.map(function (filepath) {
const relativePathName = relativePath(extension.directory, filepath)
Expand Down
52 changes: 0 additions & 52 deletions packages/app/src/cli/utilities/extensions/flow-template.test.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/app/src/cli/utilities/extensions/flow-template.ts

This file was deleted.

Loading