mirror of
https://github.com/PR0M3TH3AN/Archivox.git
synced 2025-09-08 06:58:43 +00:00
Add create-docforge starter CLI
This commit is contained in:
45
bin/create-docforge.js
Executable file
45
bin/create-docforge.js
Executable 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();
|
@@ -13,5 +13,8 @@
|
|||||||
"lunr": "^2.3.9",
|
"lunr": "^2.3.9",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0"
|
||||||
},
|
},
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"create-docforge": "./bin/create-docforge.js"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
starter/config.yaml
Normal file
6
starter/config.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
site:
|
||||||
|
title: "DocForge Docs"
|
||||||
|
description: "Simple static docs."
|
||||||
|
|
||||||
|
navigation:
|
||||||
|
search: true
|
3
starter/content/advanced/api/endpoints.md
Normal file
3
starter/content/advanced/api/endpoints.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# API Endpoints
|
||||||
|
|
||||||
|
Document your API here.
|
3
starter/content/getting-started/01-install.md
Normal file
3
starter/content/getting-started/01-install.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Install
|
||||||
|
|
||||||
|
Run `npm install` then `npm run build` to generate your site.
|
3
starter/content/getting-started/index.md
Normal file
3
starter/content/getting-started/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Getting Started
|
||||||
|
|
||||||
|
This section helps you begin with DocForge.
|
3
starter/content/index.md
Normal file
3
starter/content/index.md
Normal 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
11
starter/package.json
Normal 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": "*"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user