35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
/**
|
|
* Render the Lark status-change cards WITHOUT sending them, so a design change
|
|
* can be eyeballed (or piped into `lark-cli im +messages-send`) without pinging
|
|
* every watcher on a real task.
|
|
*
|
|
* Run from repo root:
|
|
* bun scripts/preview-notify-cards.ts # every card, as JSON lines
|
|
* bun scripts/preview-notify-cards.ts bug:manual_review # just one
|
|
*
|
|
* Output is one `{name, card}` JSON object per line, so you can pick one with
|
|
* jq and hand it straight to lark-cli:
|
|
* bun scripts/preview-notify-cards.ts bug:manual_review | jq -c .card
|
|
*/
|
|
/**
|
|
* Previews must render the PRODUCTION link, whatever the local `.env` says.
|
|
*
|
|
* A developer's `.env` points APP_BASE_URL at their own host, so a preview built
|
|
* with it carries a domain no recipient can open — and the reviewer of the
|
|
* preview has no way to tell that apart from a genuine bug in the card. Set
|
|
* before any card module loads. Override with PREVIEW_BASE_URL when you really
|
|
* do want to preview against a local build.
|
|
*/
|
|
const PREVIEW_BASE_URL = process.env.PREVIEW_BASE_URL || "https://streamline.bytedance.net";
|
|
process.env.APP_BASE_URL = PREVIEW_BASE_URL;
|
|
|
|
// Dynamic import: the card modules capture APP_BASE_URL through appBaseUrl() at
|
|
// BUILD time, so the override above has to be in place before they load.
|
|
const { CARDS } = await import("./_notify-preview-cards");
|
|
|
|
const want = new Set(process.argv.slice(2));
|
|
for (const [name, build] of Object.entries(CARDS)) {
|
|
if (want.size && !want.has(name)) continue;
|
|
console.log(JSON.stringify({ name, card: build() }));
|
|
}
|