// Proves the official packages end to end against the registry app running locally: starts `apps/registry`, makes a // publish token and a signing key for the owner `weft`, publishes each package signed, then in a fresh app runs // `weft add`, checks it, runs it on the VM and builds it for the browser. Nothing leaves this machine. // // node packages/scripts/verify-local.mjs [markdown] [stripe] [email] import { spawn, spawnSync } from "node:child_process" import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs" import { dirname, join } from "node:path" import { fileURLToPath } from "node:url" const repo = join(dirname(fileURLToPath(import.meta.url)), "../..") const weft = process.env.WEFT_BIN ?? join(repo, "core/target/release/weft") const work = join(repo, "core/target/tools/verify") const admin = "local-operator-token" const port = 4873 + (process.pid % 1000) const registry = `http://127.0.0.1:${port}` // What a fresh app does with each package, and the line it must print. No network: these run offline. const apps = { markdown: { main: `import { toHtml } from "@weft/markdown" import { log } from "std/log" log(toHtml("# Hello\\n\\n- [x] **done** ")) `, expect: "

Hello

\n", capabilities: "capabilities none", }, stripe: { main: `import { client } from "@weft/stripe" import { signature, verify } from "@weft/stripe/webhooks" import { log } from "std/log" let payload = "{\\"id\\":\\"evt_1\\",\\"type\\":\\"checkout.session.completed\\",\\"created\\":1,\\"data\\":{\\"object\\":{}}}" let event = try verify(payload, signature(payload, "whsec_local", 1700000000), "whsec_local", { now: 1700000000 }) log(event.type, client("sk_test_local").baseUrl) `, expect: "checkout.session.completed https://api.stripe.com", capabilities: "capabilities http.fetch", }, email: { main: `import { memory, outbox, send } from "@weft/email" import { toMime } from "@weft/email/mime" import { document } from "@weft/email/template" import { render } from "std/app" import { log } from "std/log" import Welcome from "./Welcome" let body = document(render(Welcome), { title: "Hi" }) let sent = try await send(memory(), { from: "a@example.com", to: ["b@example.com"], subject: "Hi", html: body.html, text: body.text }) log(sent.provider, outbox().length, toMime(outbox()[0], { id: "x" }).includes("multipart/alternative")) `, files: { "Welcome.weft": `import Button from "@weft/email/components/Button" import H1 from "@weft/email/components/H1" import P from "@weft/email/components/P" ---

Hi

Welcome