From d87ca12cd4924cadc8cc59c44a37cae9e2c2fab9 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 12 Apr 2026 01:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20Add=20metadata=20entry=20for=20i?= =?UTF-8?q?nit-cheatsheet.ts=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-meta-v2.json | 9 ++++++ single-scripts/init-cheatsheet.ts | 49 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 single-scripts/init-cheatsheet.ts diff --git a/script-meta-v2.json b/script-meta-v2.json index a3d6651..f90f38b 100644 --- a/script-meta-v2.json +++ b/script-meta-v2.json @@ -151,6 +151,15 @@ "publish_time": 1737375737613, "update_time": 1770822121766 }, + "init-cheatsheet.ts": { + "script_name": "init-cheatsheet.ts", + "script_length": 1257, + "script_sha256": "dc2a11300fb1c96ff3edaa2ea0c942e95d98e7e3c4f7fa93aa565606d59e6da3", + "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/init-cheatsheet.ts", + "single_script_file": true, + "publish_time": 1775929369681, + "update_time": 1775929369681 + }, "ip.ts": { "script_name": "ip.ts", "script_length": 653, diff --git a/single-scripts/init-cheatsheet.ts b/single-scripts/init-cheatsheet.ts new file mode 100755 index 0000000..4e42357 --- /dev/null +++ b/single-scripts/init-cheatsheet.ts @@ -0,0 +1,49 @@ +#!/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 { + 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")); +} + +main().catch((err) => { + log.error(err); + exit(1); +}).then(() => exit(0)); + +// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T014242+08:00.MEUCIDaSrI8WyJa6nyc3Gd5D +// SP/P4BvB3pOKrU9FP7uB/QMAAiEAw/ZuIjxQnOVmSpiP/LRdcvPJlqeAkYaRjoPbMW9Pklg=