Skip to content

Sync latest discount function examples - #76

Open
devisscher wants to merge 1 commit into
mainfrom
devisscher-sync-dft-2026-08-05
Open

Sync latest discount function examples#76
devisscher wants to merge 1 commit into
mainfrom
devisscher-sync-dft-2026-08-05

Conversation

@devisscher

Copy link
Copy Markdown
Contributor

Problem

discounts-reference-app has drifted from the examples and reference material in discount-functions-testing. The accumulated source changes include updated Function APIs and tooling, app intent links for create and edit flows, and refreshed JavaScript and Rust examples.

A first regeneration also exposed two source defects that would have removed live Rust tutorial coderefs and left the generated React Router lint command unusable. Those fixes are tracked in discount-functions-testing#1438.

What this PR does

  • Regenerates the full reference app from DFT main at 5cd46c55, plus the source fixes in Shopify/discount-functions-testing#1438 at 8505d6cd.
  • Updates generated API types, dependencies, Function sources, Rust targets, and React Router scaffolding.
  • Adds the JavaScript and Rust app intent schemas, instructions, and admin.app.intent.link examples for discount create and edit flows.
  • Preserves every existing coderef tag and adds paired discount-function.app-intent-link coderefs for JavaScript and Rust.
  • Includes the generated app-intent content from Add shopify/Discount app intent link snippets for React Router tutorial #75, so that focused PR is no longer needed once this PR lands.

This is generated output. Source changes belong in discount-functions-testing; this PR does not curate the generated files by hand.

Test plan

Reproduce validation

Prerequisites:

  • Node.js 22.22 or later and pnpm 10.33
  • Rust with the wasm32-unknown-unknown target
  • Shopify CLI 4.5 or later for JavaScript Function builds
  • A valid local shopify.app.toml when running Shopify CLI builds
  1. Install dependencies:

    pnpm install -r
  2. Validate the React Router app:

    cd examples/react-router-app
    env -u HOST -u PORT -u SHOPIFY_APP_URL pnpm lint
    env -u HOST -u PORT -u SHOPIFY_APP_URL pnpm build

    Expected: lint exits 0 with no errors, and client and SSR bundles build.

  3. Validate the mock HTTP server:

    cd examples/mock-http-server
    pnpm build

    Expected: client and SSR bundles build.

  4. Run the JavaScript unit tests:

    cd examples/javascript/default/extensions/discount-function
    ./node_modules/.bin/vitest run src/

    Expected: 7 tests pass across 2 files. The other three JavaScript examples currently contain no unit-test files.

  5. Build each JavaScript Function from a temporary app directory containing a valid shopify.app.toml:

    shopify app function build --path extensions/discount-function

    Repeat for default, network-access, metafield, and discount-rejection.

    Expected: each command produces dist/function.wasm.

  6. Test and build each Rust Function:

    for example in default network-access metafield discount-rejection; do
      (
        cd "examples/rust/$example/extensions/discount-function"
        cargo test
        cargo build --release --target wasm32-unknown-unknown
      )
    done

    Expected: all four test commands and all four WASM builds pass.

  7. Verify generated documentation contracts:

    • Parse all JSON files with a JSON parser.
    • Parse all TOML files with a TOML parser.
    • Compare [START ...] and [END ...] tag inventories against main.

    Expected: all files parse, every tag is balanced, and no coderef tag is removed.

Local development results

Validated on 2026-08-05 at reference-app commit e99fb28 using DFT source commit 8505d6cd, Node.js 22.22.0, pnpm 10.33.0, and Shopify CLI 4.5.1.

  • Full reference-app generation passed. Repeating generation from the same source left the committed worktree clean.
  • Documentation contract review passed: 618 JSON files and 29 TOML files parsed; all coderefs were balanced; no existing coderef tags were removed.
  • React Router lint passed with 0 errors and 16 existing no-explicit-any warnings.
  • React Router client and SSR builds passed.
  • Mock HTTP server client and SSR builds passed.
  • All four JavaScript Functions built successfully. The default example's 7 tests passed; the other examples contain no test files.
  • All four Rust cargo test commands passed, with 6 total tests, and all four wasm32-unknown-unknown release builds passed.
  • No merchant-shop or end-to-end app-intent flow was run for this generated sync. The app-intent files match the focused implementation in Add shopify/Discount app intent link snippets for React Router tutorial #75 byte-for-byte.

Assisted-By: devx/c67db487-f777-4783-8b30-503062671792
@devisscher
devisscher marked this pull request as ready for review August 5, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant