packages/ at markup-kit dd1e6eb5270e
A snapshot of packages/ in the Weft repository; the official packages are published from these commits. Markup-Kit-Commit: dd1e6eb5270e62e0c8b6c202b3d01f0da6e00ddc
This commit is contained in:
commit
306b143104
72 changed files with 10915 additions and 0 deletions
31
stripe/scripts/integration.mjs
Normal file
31
stripe/scripts/integration.mjs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Runs packages/integration/stripe against stripe-mock (https://github.com/stripe/stripe-mock), which must be on the PATH or
|
||||
// named by STRIPE_MOCK. It needs no network and no Stripe account.
|
||||
import { spawn, spawnSync } from "node:child_process"
|
||||
import { dirname, join } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..")
|
||||
const weft = process.env.WEFT_BIN ?? join(root, "../../core/target/release/weft")
|
||||
const port = 12111 + (process.pid % 1000)
|
||||
const mock = spawn(process.env.STRIPE_MOCK ?? "stripe-mock", ["-http-port", String(port), "-https-port", "0"], { stdio: "ignore" })
|
||||
let status = 1
|
||||
try {
|
||||
for (let i = 0; ; i++) {
|
||||
const up = await fetch(`http://127.0.0.1:${port}/v1/customers`, { headers: { authorization: "Bearer sk_test_1" } }).then(() => true, () => false)
|
||||
if (up) break
|
||||
if (i > 100) throw new Error("stripe-mock didn't start")
|
||||
await new Promise((r) => setTimeout(r, 100))
|
||||
}
|
||||
spawnSync(weft, ["install"], { cwd: join(root, "../integration/stripe"), stdio: "inherit" })
|
||||
const r = spawnSync(weft, ["run", "."], {
|
||||
cwd: join(root, "../integration/stripe"),
|
||||
encoding: "utf8",
|
||||
env: { ...process.env, STRIPE_MOCK_URL: `http://127.0.0.1:${port}`, WEFT_DEADLINE_MS: "0" },
|
||||
})
|
||||
process.stdout.write(r.stdout)
|
||||
process.stderr.write(r.stderr)
|
||||
status = r.status === 0 ? 0 : 1
|
||||
} finally {
|
||||
mock.kill()
|
||||
}
|
||||
process.exit(status)
|
||||
Loading…
Reference in a new issue