Initial codex-flows monorepo
This commit is contained in:
commit
3c446b11a4
642 changed files with 19676 additions and 0 deletions
67
packages/codex-client/scripts/pack-dry-run.ts
Normal file
67
packages/codex-client/scripts/pack-dry-run.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
type PackFile = {
|
||||
path: string;
|
||||
size: number;
|
||||
};
|
||||
|
||||
type PackResult = {
|
||||
name: string;
|
||||
version: string;
|
||||
filename: string;
|
||||
files: PackFile[];
|
||||
unpackedSize: number;
|
||||
size: number;
|
||||
};
|
||||
|
||||
const proc = Bun.spawn(["npm", "pack", "--dry-run", "--json"], {
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
|
||||
const [stdout, stderr, exitCode] = await Promise.all([
|
||||
new Response(proc.stdout).text(),
|
||||
new Response(proc.stderr).text(),
|
||||
proc.exited,
|
||||
]);
|
||||
|
||||
if (exitCode !== 0) {
|
||||
process.stderr.write(stderr);
|
||||
process.stderr.write(stdout);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
|
||||
const results = JSON.parse(stdout) as PackResult[];
|
||||
const result = results[0];
|
||||
|
||||
if (!result) {
|
||||
throw new Error("npm pack did not return package metadata");
|
||||
}
|
||||
|
||||
const byTopLevel = new Map<string, number>();
|
||||
for (const file of result.files) {
|
||||
const [topLevel = file.path] = file.path.split("/");
|
||||
byTopLevel.set(topLevel, (byTopLevel.get(topLevel) ?? 0) + 1);
|
||||
}
|
||||
|
||||
const topLevelSummary = [...byTopLevel.entries()]
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([name, count]) => `${name}: ${count}`)
|
||||
.join(", ");
|
||||
|
||||
console.log(`${result.name}@${result.version}`);
|
||||
console.log(`tarball: ${result.filename}`);
|
||||
console.log(`files: ${result.files.length} (${topLevelSummary})`);
|
||||
console.log(`package size: ${formatBytes(result.size)}`);
|
||||
console.log(`unpacked size: ${formatBytes(result.unpackedSize)}`);
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) {
|
||||
return `${bytes} B`;
|
||||
}
|
||||
|
||||
const kib = bytes / 1024;
|
||||
if (kib < 1024) {
|
||||
return `${kib.toFixed(1)} KiB`;
|
||||
}
|
||||
|
||||
return `${(kib / 1024).toFixed(1)} MiB`;
|
||||
}
|
||||
18
packages/codex-client/scripts/smoke-exports.ts
Normal file
18
packages/codex-client/scripts/smoke-exports.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const checks = [
|
||||
["@peezy-tech/codex-flows", ["CodexAppServerClient"]],
|
||||
["@peezy-tech/codex-flows/browser", ["CodexAppServerClient"]],
|
||||
["@peezy-tech/codex-flows/flows", ["CodexFlowClient", "createCodexFlowClient"]],
|
||||
["@peezy-tech/codex-flows/rpc", ["JsonRpcError"]],
|
||||
["@peezy-tech/codex-flows/generated", ["v2"]],
|
||||
] as const;
|
||||
|
||||
for (const [specifier, expectedExports] of checks) {
|
||||
const module = await import(specifier);
|
||||
for (const exportName of expectedExports) {
|
||||
if (!(exportName in module)) {
|
||||
throw new Error(`${specifier} is missing export ${exportName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("export smoke test passed");
|
||||
Loading…
Add table
Add a link
Reference in a new issue