Skip to content

Commit eb9a421

Browse files
Add client steps implementation to support existing functionalities
1 parent 3c9a3bb commit eb9a421

10 files changed

Lines changed: 1038 additions & 4 deletions

File tree

packages/app/src/cli/models/extensions/extension-instance.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const CONFIG_EXTENSION_IDS: string[] = [
4444
WebhookSubscriptionSpecIdentifier,
4545
WebhooksSpecIdentifier,
4646
EventsSpecIdentifier,
47+
'admin',
4748
]
4849

4950
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {buildFunctionExtension} from '../extension.js'
2+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
3+
4+
/**
5+
* Executes a build_function build step.
6+
*
7+
* Compiles the function extension (JavaScript or other language) to WASM,
8+
* applying wasm-opt and trampoline as configured.
9+
*/
10+
export async function executeBuildFunctionStep(_step: LifecycleStep, context: BuildContext): Promise<void> {
11+
return buildFunctionExtension(context.extension, context.options)
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {runThemeCheck} from '../theme-check.js'
2+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
3+
4+
/**
5+
* Executes a build_theme build step.
6+
*
7+
* Runs theme check on the extension directory and writes any offenses to stdout.
8+
*/
9+
export async function executeBuildThemeStep(_step: LifecycleStep, context: BuildContext): Promise<void> {
10+
const {extension, options} = context
11+
options.stdout.write(`Running theme check on your Theme app extension...`)
12+
const offenses = await runThemeCheck(extension.directory)
13+
if (offenses) options.stdout.write(offenses)
14+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {themeExtensionFiles} from '../../../utilities/extensions/theme.js'
2+
import {copyFile} from '@shopify/cli-kit/node/fs'
3+
import {relativePath, joinPath} from '@shopify/cli-kit/node/path'
4+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
5+
6+
/**
7+
* Executes a bundle_theme build step.
8+
*
9+
* Copies theme extension files to the output directory, preserving relative paths.
10+
* Respects the extension's .shopifyignore file and the standard ignore patterns.
11+
*/
12+
export async function executeBundleThemeStep(
13+
_step: LifecycleStep,
14+
context: BuildContext,
15+
): Promise<{filesCopied: number}> {
16+
const {extension, options} = context
17+
options.stdout.write(`Bundling theme extension ${extension.localIdentifier}...`)
18+
const files = await themeExtensionFiles(extension)
19+
20+
await Promise.all(
21+
files.map(async (filepath) => {
22+
const relativePathName = relativePath(extension.directory, filepath)
23+
const outputFile = joinPath(extension.outputPath, relativePathName)
24+
if (filepath === outputFile) return
25+
await copyFile(filepath, outputFile)
26+
}),
27+
)
28+
29+
return {filesCopied: files.length}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {buildUIExtension} from '../extension.js'
2+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
3+
4+
/**
5+
* Executes a bundle_ui build step.
6+
*
7+
* Bundles the UI extension using esbuild, writing output to extension.outputPath.
8+
*/
9+
export async function executeBundleUIStep(_step: LifecycleStep, context: BuildContext): Promise<void> {
10+
return buildUIExtension(context.extension, context.options)
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
2+
3+
/**
4+
* Executes a copy_static_assets build step.
5+
*
6+
* Copies static assets defined in the extension's build_manifest to the output directory.
7+
* This is a no-op for extensions that do not define static assets.
8+
*/
9+
export async function executeCopyStaticAssetsStep(_step: LifecycleStep, context: BuildContext): Promise<void> {
10+
return context.extension.copyStaticAssets()
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {touchFile, writeFile} from '@shopify/cli-kit/node/fs'
2+
import type {LifecycleStep, BuildContext} from '../client-steps.js'
3+
4+
/**
5+
* Executes a create_tax_stub build step.
6+
*
7+
* Creates a minimal JavaScript stub file at the extension's output path,
8+
* satisfying the tax calculation extension bundle format.
9+
*/
10+
export async function executeCreateTaxStubStep(_step: LifecycleStep, context: BuildContext): Promise<void> {
11+
const {extension} = context
12+
await touchFile(extension.outputPath)
13+
await writeFile(extension.outputPath, '(()=>{})();')
14+
}

0 commit comments

Comments
 (0)