feat(studio): git wrapper and StudioStore (create course, drafts, save as commit)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fc37da9789
commit
a6f887f31c
4 files changed
+664
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { mkdtempSync, realpathSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { $ } from "bun";
|
||||
import { createStudioStore, type Identity } from "../src/server/store";
|
||||
|
||||
export const ada: Identity & { id: string } = { id: "u-ada", name: "Ada Lovelace", email: "ada@example.org" };
|
||||
export const bob: Identity & { id: string } = { id: "u-bob", name: "Bob Ext", email: "bob@example.org" };
|
||||
|
||||
export function tempDir(prefix = "stc-studio-"): string {
|
||||
return realpathSync(mkdtempSync(join(tmpdir(), prefix)));
|
||||
}
|
||||
|
||||
export async function newStore() {
|
||||
const dataDir = tempDir();
|
||||
const store = createStudioStore({ dataDir });
|
||||
return { dataDir, store };
|
||||
}
|
||||
|
||||
/** Runs git as an outside tool (VS Code, a terminal) would: plain identity, in the given dir. */
|
||||
export async function extGit(cwd: string, ...args: string[]): Promise<string> {
|
||||
const r = await $`git -c user.name=${bob.name} -c user.email=${bob.email} -c commit.gpgsign=false -c core.hooksPath=/dev/null ${args}`.cwd(cwd).quiet().nothrow();
|
||||
if (r.exitCode !== 0) throw new Error(`git ${args.join(" ")} failed: ${r.stderr.toString()}`);
|
||||
return r.stdout.toString().trim();
|
||||
}
|
||||
Reference in new issue
Block a user