mirror of
https://github.com/PR0M3TH3AN/Archivox.git
synced 2025-09-08 06:58:43 +00:00
Merge pull request #10 from PR0M3TH3AN/codex/set-up-testing-and-ci-workflow
Add Jest tests and CI workflow
This commit is contained in:
17
.github/workflows/ci.yml
vendored
Normal file
17
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- run: npm install
|
||||||
|
- run: npm test
|
@@ -1,5 +1,7 @@
|
|||||||
# DocForge: Final Specification
|
# DocForge: Final Specification
|
||||||
|
|
||||||
|
[](https://github.com/yourusername/DocForge/actions/workflows/ci.yml)
|
||||||
|
|
||||||
**Version:** 1.0
|
**Version:** 1.0
|
||||||
**Date:** July 10, 2025
|
**Date:** July 10, 2025
|
||||||
**Overview:** DocForge is a modular, lightweight static site generator (SSG) for building "Read the Docs"-style documentation sites. It prioritizes user simplicity: content is driven entirely by Markdown files in a `content` folder, which automatically determines page structure, titles, and sidebar links. No manual HTML, link creation, or complex setups are needed. The site is mobile-friendly, SEO-optimized, and deployable to Netlify or similar hosts.
|
**Overview:** DocForge is a modular, lightweight static site generator (SSG) for building "Read the Docs"-style documentation sites. It prioritizes user simplicity: content is driven entirely by Markdown files in a `content` folder, which automatically determines page structure, titles, and sidebar links. No manual HTML, link creation, or complex setups are needed. The site is mobile-friendly, SEO-optimized, and deployable to Netlify or similar hosts.
|
||||||
|
15
__tests__/buildNav.test.js
Normal file
15
__tests__/buildNav.test.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
const { buildNav } = require('../src/generator');
|
||||||
|
|
||||||
|
test('generates navigation tree', () => {
|
||||||
|
const pages = [
|
||||||
|
{ file: 'guide/install.md', data: { title: 'Install', order: 1 } },
|
||||||
|
{ file: 'guide/usage.md', data: { title: 'Usage', order: 2 } },
|
||||||
|
{ file: 'guide/nested/info.md', data: { title: 'Info', order: 1 } }
|
||||||
|
];
|
||||||
|
const tree = buildNav(pages);
|
||||||
|
const guide = tree.find(n => n.name === 'guide');
|
||||||
|
expect(guide).toBeDefined();
|
||||||
|
expect(guide.children.length).toBe(3);
|
||||||
|
const install = guide.children.find(c => c.name === 'install.md');
|
||||||
|
expect(install.path).toBe('/guide/install.html');
|
||||||
|
});
|
13
__tests__/loadConfig.test.js
Normal file
13
__tests__/loadConfig.test.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const loadConfig = require('../src/config/loadConfig');
|
||||||
|
|
||||||
|
test('loads configuration and merges defaults', () => {
|
||||||
|
const dir = fs.mkdtempSync(path.join(__dirname, 'cfg-'));
|
||||||
|
const file = path.join(dir, 'config.yaml');
|
||||||
|
fs.writeFileSync(file, 'site:\n title: Test Site\n');
|
||||||
|
const cfg = loadConfig(file);
|
||||||
|
expect(cfg.site.title).toBe('Test Site');
|
||||||
|
expect(cfg.navigation.search).toBe(true);
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
});
|
23
__tests__/pluginHooks.test.js
Normal file
23
__tests__/pluginHooks.test.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const loadPlugins = require('../src/config/loadPlugins');
|
||||||
|
|
||||||
|
test('plugin hook modifies data', async () => {
|
||||||
|
const dir = fs.mkdtempSync(path.join(require('os').tmpdir(), 'plugins-'));
|
||||||
|
const pluginFile = path.join(dir, 'test.plugin.js');
|
||||||
|
fs.writeFileSync(
|
||||||
|
pluginFile,
|
||||||
|
"module.exports = { onParseMarkdown: ({ content }) => ({ content: content + '!!' }) };\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const plugins = loadPlugins({ pluginsDir: dir, plugins: ['test.plugin'] });
|
||||||
|
let data = { content: 'hello' };
|
||||||
|
for (const plugin of plugins) {
|
||||||
|
if (typeof plugin.onParseMarkdown === 'function') {
|
||||||
|
const res = await plugin.onParseMarkdown(data);
|
||||||
|
if (res !== undefined) data = res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(data.content).toBe('hello!!');
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
});
|
3193
package-lock.json
generated
3193
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,8 @@
|
|||||||
"description": "DocForge static site generator",
|
"description": "DocForge static site generator",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "eleventy --serve",
|
"dev": "eleventy --serve",
|
||||||
"build": "node src/generator/index.js"
|
"build": "node src/generator/index.js",
|
||||||
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy": "^2.0.1",
|
"@11ty/eleventy": "^2.0.1",
|
||||||
@@ -13,6 +14,9 @@
|
|||||||
"lunr": "^2.3.9",
|
"lunr": "^2.3.9",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"jest": "^29.6.1"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"create-docforge": "./bin/create-docforge.js"
|
"create-docforge": "./bin/create-docforge.js"
|
||||||
|
@@ -165,4 +165,4 @@ async function generate({ contentDir = 'content', outputDir = '_site', configPat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { generate };
|
module.exports = { generate, buildNav };
|
||||||
|
Reference in New Issue
Block a user