mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
#!/usr/bin/env node
|
|
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { build } from "esbuild";
|
|
import { writeGeneratedTextAsset } from "./lib/generated-text-asset.mts";
|
|
|
|
type DiscordActivitySdkBuildParams = {
|
|
build?: (
|
|
options: Parameters<typeof build>[0],
|
|
) => Promise<{ outputFiles?: Array<{ text: string }> }>;
|
|
outputPath?: string;
|
|
};
|
|
|
|
const modulePath = fileURLToPath(import.meta.url);
|
|
const repoRoot = path.resolve(path.dirname(modulePath), "..");
|
|
const discordDir = path.join(repoRoot, "extensions/discord");
|
|
const outputPath = path.join(repoRoot, "extensions/discord/assets/embedded-app-sdk.mjs");
|
|
|
|
/** Builds the browser SDK bundle without rewriting an identical generated asset. */
|
|
export async function buildDiscordActivitySdk(params: DiscordActivitySdkBuildParams = {}) {
|
|
const buildImpl = params.build ?? build;
|
|
const targetPath = params.outputPath ?? outputPath;
|
|
const result = await buildImpl({
|
|
entryPoints: ["@discord/embedded-app-sdk"],
|
|
absWorkingDir: discordDir,
|
|
bundle: true,
|
|
platform: "browser",
|
|
target: "es2020",
|
|
format: "esm",
|
|
minify: true,
|
|
legalComments: "none",
|
|
outfile: targetPath,
|
|
write: false,
|
|
});
|
|
|
|
const outputFile = result.outputFiles?.[0];
|
|
if (!outputFile) {
|
|
throw new Error("esbuild did not produce the Discord Embedded App SDK bundle");
|
|
}
|
|
|
|
return writeGeneratedTextAsset(targetPath, outputFile.text);
|
|
}
|
|
|
|
if (process.argv[1] === modulePath) {
|
|
await buildDiscordActivitySdk();
|
|
}
|