-
Notifications
You must be signed in to change notification settings - Fork 229
Add client steps implementation to support existing functionalities #6966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 03-10-create_abstract_client_steps_infrastracture_to_externalize_the_ap_modules_client_configurations
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import {buildFunctionExtension} from '../extension.js' | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a build_function build step. | ||
| * | ||
| * Compiles the function extension (JavaScript or other language) to WASM, | ||
| * applying wasm-opt and trampoline as configured. | ||
| */ | ||
| export async function executeBuildFunctionStep(_step: LifecycleStep, context: BuildContext): Promise<void> { | ||
| return buildFunctionExtension(context.extension, context.options) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import {runThemeCheck} from '../theme-check.js' | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a build_theme build step. | ||
| * | ||
| * Runs theme check on the extension directory and writes any offenses to stdout. | ||
| */ | ||
| export async function executeBuildThemeStep(_step: LifecycleStep, context: BuildContext): Promise<void> { | ||
| const {extension, options} = context | ||
| options.stdout.write(`Running theme check on your Theme app extension...`) | ||
| const offenses = await runThemeCheck(extension.directory) | ||
| if (offenses) options.stdout.write(offenses) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import {themeExtensionFiles} from '../../../utilities/extensions/theme.js' | ||
| import {copyFile} from '@shopify/cli-kit/node/fs' | ||
| import {relativePath, joinPath} from '@shopify/cli-kit/node/path' | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a bundle_theme build step. | ||
| * | ||
| * Copies theme extension files to the output directory, preserving relative paths. | ||
| * Respects the extension's .shopifyignore file and the standard ignore patterns. | ||
| */ | ||
| export async function executeBundleThemeStep( | ||
| _step: LifecycleStep, | ||
| context: BuildContext, | ||
| ): Promise<{filesCopied: number}> { | ||
| const {extension, options} = context | ||
| options.stdout.write(`Bundling theme extension ${extension.localIdentifier}...`) | ||
| const files = await themeExtensionFiles(extension) | ||
|
|
||
| await Promise.all( | ||
| files.map(async (filepath) => { | ||
| const relativePathName = relativePath(extension.directory, filepath) | ||
| const outputFile = joinPath(extension.outputPath, relativePathName) | ||
| if (filepath === outputFile) return | ||
| await copyFile(filepath, outputFile) | ||
| }), | ||
| ) | ||
|
|
||
| return {filesCopied: files.length} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import {buildUIExtension} from '../extension.js' | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a bundle_ui build step. | ||
| * | ||
| * Bundles the UI extension using esbuild, writing output to extension.outputPath. | ||
| */ | ||
| export async function executeBundleUIStep(_step: LifecycleStep, context: BuildContext): Promise<void> { | ||
| return buildUIExtension(context.extension, context.options) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a copy_static_assets build step. | ||
| * | ||
| * Copies static assets defined in the extension's build_manifest to the output directory. | ||
| * This is a no-op for extensions that do not define static assets. | ||
| */ | ||
| export async function executeCopyStaticAssetsStep(_step: LifecycleStep, context: BuildContext): Promise<void> { | ||
| return context.extension.copyStaticAssets() | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import {touchFile, writeFile} from '@shopify/cli-kit/node/fs' | ||
| import type {LifecycleStep, BuildContext} from '../client-steps.js' | ||
|
|
||
| /** | ||
| * Executes a create_tax_stub build step. | ||
| * | ||
| * Creates a minimal JavaScript stub file at the extension's output path, | ||
| * satisfying the tax calculation extension bundle format. | ||
| */ | ||
| export async function executeCreateTaxStubStep(_step: LifecycleStep, context: BuildContext): Promise<void> { | ||
| const {extension} = context | ||
| await touchFile(extension.outputPath) | ||
| await writeFile(extension.outputPath, '(()=>{})();') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tax stub step can overwrite a directory with a JS file The step writes the stub to Evidence: await touchFile(extension.outputPath)
await writeFile(extension.outputPath, '(()=>{})();') |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we ever using
_step? why is it included?