create-documentation
Version:
CLI to genernate docs from tests
41 lines (40 loc) • 1.34 kB
JavaScript
import { prompt } from "enquirer";
import fs from "fs-extra";
import path from "path";
import chalk from "chalk";
const main = async () => {
console.log(chalk.green("📝 Welcome to docs! Let's set things up."));
const answers = await prompt([
{
type: "input",
name: "testDir",
message: "Where are your test files located?",
initial: "./tests",
},
{
type: "input",
name: "outputDir",
message: "Where should the docs be generated?",
initial: "./docs",
},
{
type: "select",
name: "framework",
message: "Which test framework are you using?",
choices: ["jest", "vitest", "mocha"],
},
]);
const config = {
testDir: answers.testDir,
outputDir: answers.outputDir,
framework: answers.framework,
};
const configPath = path.join(process.cwd(), "docs.config.json");
await fs.writeJson(configPath, config, { spaces: 2 });
// Also make sure output directory exists
await fs.ensureDir(answers.outputDir);
console.log(chalk.blue(`✅ Configuration saved to docs.config.json`));
console.log(chalk.yellow(`📂 Output directory ensured at ${answers.outputDir}`));
};
main();