Files
hyperframes/scripts/generate-skill-module-copies.mjs
T
Michael Wang 90de9b6196 fix(cli): a project .env provider key prints a note when it is used (#8056)
A provider key from a project .env is still used when no own credential
competes. Capture vision (OpenRouter, Gemini, Google and both Vertex parts),
snapshot --describe, Gemini speech and Lyria music now print one note per key
before it is first used, naming the variable and the escaped .env path, as
the ElevenLabs note does. The ignoring notes escape the path too, and the
media-use skill gets a generated copy of the CLI's terminal-text helper.
2026-11-17 16:52:55 +00:00

57 lines
2.0 KiB
JavaScript

import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
export const skillModuleCopies = [
[
"packages/cli/src/media-use/lib/media-fetch.mjs",
["skills/media-use/scripts/lib/media-fetch.mjs"],
],
[
"packages/cli/src/media-use/lib/terminal-text.mjs",
["skills/media-use/scripts/lib/terminal-text.mjs"],
],
[
"packages/cli/src/media-use/lib/openverse.mjs",
["skills/media-use/audio/scripts/lib/openverse.mjs"],
],
[
"skills/hyperframes/scripts/lib/main-module.mjs",
[
"skills/media-use/audio/scripts/lib/main-module.mjs",
"packages/cli/src/media-use/lib/main-module.mjs",
],
],
[
"skills/hyperframes/scripts/lib/windows-exe-search.mjs",
[
"skills/media-use/scripts/lib/windows-exe-search.mjs",
"skills/figma/scripts/lib/windows-exe-search.mjs",
// The CLI build replaces the published media-use scripts/lib with this folder.
"packages/cli/src/media-use/lib/windows-exe-search.mjs",
],
],
];
function synchronizeCopy(content, target, check) {
const path = resolve(root, target);
if (check) return readFileSync(path, "utf8") !== content;
mkdirSync(dirname(path), { recursive: true });
writeFileSync(path, content);
return false;
}
export function generateSkillModuleCopies({ check = false } = {}) {
return skillModuleCopies.flatMap(([source, targets]) => {
const content = readFileSync(resolve(root, source), "utf8");
return targets.filter((target) => synchronizeCopy(content, target, check));
});
}
if (process.argv[1] && pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url) {
const drifted = generateSkillModuleCopies({ check: process.argv.includes("--check") });
if (drifted.length) throw new Error("Regenerate skill module copies: " + drifted.join(", "));
console.log("Skill module copies are in sync");
}