Lines 1-41javascript
3// packages/kynver-tools-cli/src/commands/init.ts
4import fs from "node:fs/promises";
5import path from "node:path";
6var SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
7async function runInit(rawName, flags = {}) {
9 throw new Error("Usage: kynver-tool init <name> [--dir <path>]");
11 const slug = rawName.trim().toLowerCase();
12 if (!SLUG_RE.test(slug)) {
14 `Invalid name "${rawName}": lowercase letters, digits, hyphens; 1\u201364 chars; can't start/end with a hyphen.`
17 const targetDir = path.resolve(flags.dir ?? slug);
18 await scaffoldProject(slug, targetDir);
19 console.log(`\u2714 scaffolded ${slug} at ${targetDir}`);
22 console.log(` cd ${path.relative(process.cwd(), targetDir) || "."}`);
23 console.log(" npm install");
24 console.log(" kynver-tool list");
25 console.log(` kynver-tool invoke greet --args '{"name":"world"}'`);
27async function scaffoldProject(slug, targetDir) {
28 await fs.mkdir(targetDir, { recursive: true });
29 const entries = await fs.readdir(targetDir);
30 if (entries.filter((e) => e !== ".git").length > 0) {
31 throw new Error(`Refusing to scaffold into non-empty directory: ${targetDir}`);
35 ["kynver.tool.json", manifestJson(slug)],
36 ["package.json", packageJson(slug)],
37 ["tsconfig.json", TSCONFIG],
HighCloud Metadata Access
Source reaches cloud instance metadata or link-local credential endpoints.
dist/cli.jsView on unpkg · L21 38 [".gitignore", GITIGNORE],
39 ["README.md", readme(slug)]
41 for (const [name, content] of writes) {