Add create-docforge starter CLI

This commit is contained in:
thePR0M3TH3AN
2025-07-10 10:50:29 -04:00
parent 8b04671e4e
commit d7045ade89
8 changed files with 78 additions and 1 deletions

45
bin/create-docforge.js Executable file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
function copyDir(src, dest) {
fs.mkdirSync(dest, { recursive: true });
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyDir(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
}
function main() {
const args = process.argv.slice(2);
const install = args.includes('--install');
const targetArg = args.find(a => !a.startsWith('-')) || '.';
const targetDir = path.resolve(process.cwd(), targetArg);
const templateDir = path.join(__dirname, '..', 'starter');
copyDir(templateDir, targetDir);
const pkgPath = path.join(targetDir, 'package.json');
if (fs.existsSync(pkgPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const version = require('../package.json').version;
if (pkg.dependencies && pkg.dependencies.docforge)
pkg.dependencies.docforge = `^${version}`;
pkg.name = path.basename(targetDir);
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
}
if (install) {
execSync('npm install', { cwd: targetDir, stdio: 'inherit' });
}
console.log(`DocForge starter created at ${targetDir}`);
}
main();

View File

@@ -13,5 +13,8 @@
"lunr": "^2.3.9",
"js-yaml": "^4.1.0"
},
"license": "MIT"
"license": "MIT",
"bin": {
"create-docforge": "./bin/create-docforge.js"
}
}

6
starter/config.yaml Normal file
View File

@@ -0,0 +1,6 @@
site:
title: "DocForge Docs"
description: "Simple static docs."
navigation:
search: true

View File

@@ -0,0 +1,3 @@
# API Endpoints
Document your API here.

View File

@@ -0,0 +1,3 @@
# Install
Run `npm install` then `npm run build` to generate your site.

View File

@@ -0,0 +1,3 @@
# Getting Started
This section helps you begin with DocForge.

3
starter/content/index.md Normal file
View File

@@ -0,0 +1,3 @@
# Welcome to DocForge
This is your new documentation site. Start editing files in the `content/` folder.

11
starter/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "my-docforge-site",
"private": true,
"scripts": {
"dev": "eleventy --serve",
"build": "node node_modules/docforge/src/generator/index.js"
},
"dependencies": {
"docforge": "*"
}
}