51 lines
1.3 KiB
TypeScript
Executable File
51 lines
1.3 KiB
TypeScript
Executable File
#!/usr/bin/env runts -- --allow-all
|
|
|
|
import {
|
|
existsPath,
|
|
exit,
|
|
log,
|
|
makeDirectory,
|
|
writeStringToFile,
|
|
} from "https://script.hatter.ink/@70/deno-commons-mod.ts";
|
|
|
|
async function main(): Promise<void> {
|
|
const name = prompt("Cheat sheet name:");
|
|
const repo = prompt("Cheat sheet repo:");
|
|
const desc = prompt("Cheat sheet description:");
|
|
|
|
if (await existsPath(name)) {
|
|
log.error(`Path ${name} exists`);
|
|
}
|
|
const cheatsheetFile = `${name}/CHEATSHEET.md`;
|
|
if (await existsPath(cheatsheetFile)) {
|
|
log.error(`File ${cheatsheetFile} exists`);
|
|
}
|
|
await makeDirectory(name);
|
|
|
|
const md: string[] = [];
|
|
md.push(`# ${name}`);
|
|
md.push("");
|
|
md.push("## Meta");
|
|
md.push("");
|
|
md.push("```yaml");
|
|
md.push(`name: ${name}`);
|
|
if (repo) {
|
|
md.push(`repo: ${repo}`);
|
|
}
|
|
md.push(`description: ${desc}`);
|
|
md.push("```");
|
|
md.push("");
|
|
md.push("");
|
|
|
|
await writeStringToFile(cheatsheetFile, md.join("\n"));
|
|
log.success(`Init ${name} successfully.`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
log.error(err);
|
|
exit(1);
|
|
}).then(() => exit(0));
|
|
|
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T231322+08:00.MEYCIQD09vR5PjKTl9b+gQJQ
|
|
// ycR0M7Okd9ygkuG5U8lP9HYvBAIhAKpaHWZmGiTK8rX/iQg95M5y5m3y1HvyCaGsB8EATdeQ
|