metatrondelivery/package.json
metatroncubeswdev 381c52d01a fix: replace hand-scaffolded Functions with real CLI-generated ones
The user linked the app to a real Partner org and hit two live errors
running `shopify app dev`, which is exactly the verification the earlier
hand-scaffolded Functions couldn't get in this environment. Root-caused and
fixed both, then went further: regenerated both Functions from scratch via
`shopify app generate extension` (now possible — the user's session had
authenticated) instead of patching the guesses.

What broke and why:
- `shopify app config link` pulled a fresh app's (empty) remote config and
  overwrote shopify.app.toml, dropping the webhook subscriptions and
  app_proxy block — restored both, keeping the real client_id/name/scopes
  the CLI set.
- `[extensions.build.watch]` as a nested table was invalid TOML for this
  field — it's a plain `watch = [...]` array directly under
  `[extensions.build]`.
- The real failure ("doesn't have a build command or it's empty") turned
  out to be a red herring pointing at a stale filename
  (shopify.function.extension.toml, not the current shopify.extension.toml)
  — the actual problem was that `@shopify/shopify_function` was never
  installed for these extensions (confirmed: no node_modules), because
  hand-writing package.json doesn't run the install step
  `shopify app generate extension` does automatically.

Rather than keep guessing at the toolchain, regenerated both Functions for
real:
- `shopify app generate extension --template=cart_checkout_validation` and
  `--template=delivery_customization` (--flavor=vanilla-js), which produces
  a working vite/vitest-based build+test setup, real
  `@shopify/shopify-function-test-helpers` fixture testing (builds actual
  WASM and runs it via function-runner), and a generated GraphQL type file
  per extension.
- This surfaced several concrete corrections to what was hand-written
  before: the real target names are `cart.validations.generate.run` and
  `cart.delivery-options.transform.run` (not `purchase.validation.run` /
  `purchase.delivery-customization.run`), current api_version is 2026-07
  (not 2025-01), the validation output wraps errors in
  `operations: [{ validationAdd: { errors } }]` with a plain `message`
  field (not top-level `errors` with `localizedMessage`), and the rename
  operation is `deliveryOptionRename: { deliveryOptionHandle, title }` (not
  `rename: { deliveryOptionHandle, title }`).
- Rewrote each extension's `.graphql` input query to request our actual
  dd_* cart attributes (plus delivery option handles for the rename case),
  regenerated types via `npm run typegen` in each, and ported the pure
  evaluate.js decision logic (same exported function names/behavior as
  before, now proven correct against the live schema) into the adapter
  file the generator expects.
- Replaced each extension's demo fixture with ones matching our real
  logic; `npm test` inside each extension now compiles real WASM and runs
  function-runner against them — this is strictly stronger verification
  than the previous pure-JS-only unit tests (which are kept too, unchanged,
  since the evaluate.js files kept the same interface).

Repo-wide wiring: extensions/*/generated and extensions/*/dist are not
committed (matches the CLI's own per-extension .gitignore) — added
`npm run typegen:functions` (runs automatically before `npm run typecheck`
via a pretypecheck hook) and `npm run test:functions`, both now also in CI.
Root `npm install` picked these two folders up as proper npm workspace
members (they already have their own package.json from generation).

Verified: lint, typecheck, all 52 unit tests, all 8 integration tests, both
extensions' real WASM/function-runner test suites (5 fixtures total), and
both `npm run build` / `npm run build:widget` all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 20:14:21 -04:00

99 lines
3.2 KiB
JSON

{
"name": "delivery-datetime-app",
"private": true,
"scripts": {
"build": "remix vite:build",
"predev": "npm run build:widget",
"dev": "shopify app dev",
"predeploy": "npm run build:widget",
"config:link": "shopify app config link",
"generate": "shopify app generate",
"deploy": "shopify app deploy",
"config:use": "shopify app config use",
"env": "shopify app env",
"start": "remix-serve ./build/server/index.js",
"docker-start": "npm run setup && npm run start",
"setup": "prisma generate && prisma migrate deploy",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"typegen:functions": "npm --prefix extensions/validation-slot run typegen && npm --prefix extensions/delivery-customization run typegen",
"pretypecheck": "npm run typegen:functions",
"typecheck": "tsc --noEmit",
"test:functions": "npm --prefix extensions/validation-slot test && npm --prefix extensions/delivery-customization test",
"test": "vitest",
"test:integration": "vitest run --config vitest.integration.config.ts",
"test:e2e": "playwright test",
"build:widget": "esbuild extensions/datetime-widget/src/datetime-widget.ts --bundle --minify --target=es2019 --outfile=extensions/datetime-widget/assets/datetime-widget.js",
"worker": "tsx jobs/worker.ts",
"shopify": "shopify",
"prisma": "prisma",
"graphql-codegen": "graphql-codegen",
"vite": "vite"
},
"type": "module",
"engines": {
"node": ">=20.19 <22 || >=22.12"
},
"dependencies": {
"@prisma/client": "^6.2.1",
"@remix-run/dev": "^2.16.1",
"@remix-run/fs-routes": "^2.16.1",
"@remix-run/node": "^2.16.1",
"@remix-run/react": "^2.16.1",
"@remix-run/serve": "^2.16.1",
"@shopify/app-bridge-react": "^4.1.6",
"@shopify/polaris": "^12.0.0",
"@shopify/shopify-app-remix": "^4.1.0",
"@shopify/shopify-app-session-storage-prisma": "^9.0.1",
"bullmq": "^5.34.0",
"ioredis": "^5.4.2",
"isbot": "^5.1.0",
"luxon": "^3.5.0",
"prisma": "^6.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"vite-tsconfig-paths": "^5.0.1"
},
"devDependencies": {
"@playwright/test": "^1.49.1",
"@remix-run/eslint-config": "^2.16.1",
"@remix-run/route-config": "^2.16.1",
"@shopify/api-codegen-preset": "^1.1.1",
"@types/eslint": "^9.6.1",
"@types/luxon": "^3.4.2",
"@types/node": "^22.2.0",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"dotenv": "^16.4.7",
"esbuild": "^0.24.2",
"eslint": "^8.42.0",
"eslint-config-prettier": "^10.0.1",
"prettier": "^3.2.4",
"tsx": "^4.19.2",
"typescript": "^5.2.2",
"vite": "^6.2.2",
"vitest": "^2.1.8"
},
"workspaces": {
"packages": [
"extensions/*"
]
},
"trustedDependencies": [
"@shopify/plugin-cloudflare"
],
"resolutions": {
"@graphql-tools/url-loader": "8.0.16",
"@graphql-codegen/client-preset": "4.7.0",
"@graphql-codegen/typescript-operations": "4.5.0",
"minimatch": "9.0.5",
"vite": "^6.2.2"
},
"overrides": {
"@graphql-tools/url-loader": "8.0.16",
"@graphql-codegen/client-preset": "4.7.0",
"@graphql-codegen/typescript-operations": "4.5.0",
"minimatch": "9.0.5",
"vite": "^6.2.2"
}
}