feat(atlassian): implement milestone M4 - packaging and doc sync
This commit is contained in:
@@ -1 +1,60 @@
|
||||
console.log("sync-agents not implemented yet");
|
||||
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const SHARED_SCRIPTS_DIR = path.resolve(__dirname, "..");
|
||||
const ATLASSIAN_SKILL_DIR = path.resolve(SHARED_SCRIPTS_DIR, "..", "..");
|
||||
const AGENTS = ["codex", "claude-code", "cursor", "opencode"] as const;
|
||||
const ENTRIES_TO_COPY = ["pnpm-lock.yaml", "tsconfig.json", "src"] as const;
|
||||
|
||||
async function replaceEntry(source: string, target: string) {
|
||||
await rm(target, { recursive: true, force: true });
|
||||
await cp(source, target, { recursive: true });
|
||||
}
|
||||
|
||||
async function syncAgent(agent: (typeof AGENTS)[number]) {
|
||||
const targetScriptsDir = path.join(ATLASSIAN_SKILL_DIR, agent, "scripts");
|
||||
await mkdir(targetScriptsDir, { recursive: true });
|
||||
|
||||
for (const entry of ENTRIES_TO_COPY) {
|
||||
await replaceEntry(
|
||||
path.join(SHARED_SCRIPTS_DIR, entry),
|
||||
path.join(targetScriptsDir, entry),
|
||||
);
|
||||
}
|
||||
|
||||
const sourcePackageJson = JSON.parse(
|
||||
await readFile(path.join(SHARED_SCRIPTS_DIR, "package.json"), "utf8"),
|
||||
) as {
|
||||
scripts?: Record<string, string>;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
sourcePackageJson.scripts = {
|
||||
atlassian: sourcePackageJson.scripts?.atlassian ?? "tsx src/cli.ts",
|
||||
typecheck: sourcePackageJson.scripts?.typecheck ?? "tsc --noEmit",
|
||||
};
|
||||
|
||||
await writeFile(
|
||||
path.join(targetScriptsDir, "package.json"),
|
||||
`${JSON.stringify(sourcePackageJson, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
for (const agent of AGENTS) {
|
||||
await syncAgent(agent);
|
||||
}
|
||||
|
||||
console.log(`Synced runtime bundle into ${AGENTS.length} agent script directories.`);
|
||||
}
|
||||
|
||||
main().catch((error: unknown) => {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error(message);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user