mirror of
https://github.com/Effect-TS/effect.git
synced 2026-11-27 02:25:36 +08:00
Co-authored-by: Daniel Izdebski <20744582+duckception@users.noreply.github.com>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
/* oxlint-disable no-undef */
|
|
import assert from "node:assert/strict"
|
|
import { createHash } from "node:crypto"
|
|
import * as Fs from "node:fs/promises"
|
|
|
|
const version = "1.81.0"
|
|
const sha256 = "78f2fdbfa9c73a0b0407f3603ff5b058268fe9fd0b484ebc8ef4f935e55b59ca"
|
|
const url = `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${version}/dist/browser/standalone.js`
|
|
const response = await fetch(url)
|
|
assert.ok(response.ok, `Failed to fetch ${url}: ${response.status}`)
|
|
const bytes = await response.bytes()
|
|
assert.equal(createHash("sha256").update(bytes).digest("hex"), sha256, `Unexpected input: ${url}`)
|
|
|
|
// The bundle runs inline, so a relative source map would point at the user's server.
|
|
const javascript = new TextDecoder().decode(bytes).replace(/\n\/\/# sourceMappingURL=\S+\s*$/, "\n")
|
|
const source = `/* oxlint-disable no-undef */
|
|
/* Generated by scripts/package-scalar.mjs from @scalar/api-reference ${version} (MIT).
|
|
* Source: ${url}
|
|
* SHA-256: ${sha256}
|
|
*/
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
export const javascript =
|
|
${JSON.stringify(javascript)}
|
|
`
|
|
|
|
await Fs.writeFile("packages/effect/src/http-api/internal/httpApiScalar.ts", source)
|