feat(http-recorder): prepare independent beta release
This commit is contained in:
parent
f48f24ec4e
commit
81eea42e80
17 changed files with 485 additions and 85 deletions
34
packages/http-recorder/script/publish.ts
Normal file
34
packages/http-recorder/script/publish.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bun
|
||||
import { $ } from "bun"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { pack } from "./pack.js"
|
||||
import { verifyPackage } from "./verify-package.js"
|
||||
|
||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
||||
process.chdir(dir)
|
||||
|
||||
const published = async (name: string, version: string) => {
|
||||
const result = await $`npm view ${name}@${version} version`.quiet().nothrow()
|
||||
if (result.exitCode === 0) return true
|
||||
const stderr = result.stderr.toString()
|
||||
if (stderr.includes("E404")) return false
|
||||
throw new Error(`Failed to check whether ${name}@${version} is published:\n${stderr}`)
|
||||
}
|
||||
|
||||
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- package.json is validated by the package schema and build checks.
|
||||
const pkg = JSON.parse(await Bun.file("package.json").text()) as { readonly name: string; readonly version: string }
|
||||
if (pkg.version === "0.0.0") throw new Error("Version the HTTP recorder before publishing")
|
||||
if (!(await Bun.file("CHANGELOG.md").exists()))
|
||||
throw new Error("Generate the HTTP recorder changelog before publishing")
|
||||
|
||||
if (await published(pkg.name, pkg.version)) {
|
||||
console.log(`already published ${pkg.name}@${pkg.version}`)
|
||||
} else {
|
||||
const archive = await pack()
|
||||
try {
|
||||
await verifyPackage(archive)
|
||||
await $`npm publish ${archive} --tag beta --access public --provenance`
|
||||
} finally {
|
||||
await Bun.file(archive).delete()
|
||||
}
|
||||
}
|
||||
|
|
@ -25,11 +25,14 @@ import { Layer } from "effect"
|
|||
import { HttpClient } from "effect/unstable/http"
|
||||
import { Socket } from "effect/unstable/socket"
|
||||
|
||||
const options: HttpRecorder.RecorderOptions = { redact: { jsonFields: ["access_token"] } }
|
||||
const options: HttpRecorder.RecorderOptions = { match: () => true, redact: { jsonFields: ["access_token"] } }
|
||||
const socketOptions: HttpRecorder.SocketRecorderOptions = { redact: { jsonFields: ["access_token"] } }
|
||||
HttpRecorder.http("consumer", options) satisfies Layer.Layer<HttpClient.HttpClient>
|
||||
HttpRecorder.socket("consumer/socket", options).pipe(
|
||||
HttpRecorder.socket("consumer/socket", socketOptions).pipe(
|
||||
Layer.provide(NodeSocket.layerWebSocket("wss://example.test")),
|
||||
) satisfies Layer.Layer<Socket.Socket>
|
||||
// @ts-expect-error HTTP request matching does not apply to WebSocket frames.
|
||||
HttpRecorder.socket("consumer/socket", { match: () => true })
|
||||
`,
|
||||
)
|
||||
await writeFile(
|
||||
|
|
@ -41,7 +44,7 @@ HttpRecorder.socket("consumer/socket", options).pipe(
|
|||
moduleResolution: "NodeNext",
|
||||
strict: true,
|
||||
noEmit: true,
|
||||
// Required by effect@4.0.0-beta.74: its schema.d.ts references an undeclared SchemaErrorTypeId.
|
||||
// Required by effect@4.0.0-beta.83: its declarations currently contain unresolved internal symbols.
|
||||
skipLibCheck: true,
|
||||
lib: ["ES2022", "DOM", "ESNext.Disposable"],
|
||||
},
|
||||
|
|
|
|||
18
packages/http-recorder/script/version.ts
Normal file
18
packages/http-recorder/script/version.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bun
|
||||
import { $ } from "bun"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
const packages = await Array.fromAsync(
|
||||
new Bun.Glob("packages/**/package.json").scan({
|
||||
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
|
||||
absolute: true,
|
||||
}),
|
||||
)
|
||||
const ignored = (await Promise.all(packages.map(async (file): Promise<unknown> => Bun.file(file).json())))
|
||||
.map((pkg) =>
|
||||
typeof pkg === "object" && pkg !== null && "name" in pkg && typeof pkg.name === "string" ? pkg.name : undefined,
|
||||
)
|
||||
.filter((name): name is string => name !== undefined && name !== "@opencode-ai/http-recorder")
|
||||
.flatMap((name) => ["--ignore", name])
|
||||
|
||||
await $`bunx changeset version ${ignored}`
|
||||
Loading…
Add table
Add a link
Reference in a new issue