Skip to content

Commit c4ffb37

Browse files
committed
feat: enhance CLI with new config options for metadata and branding, update generateConfig to reflect changes
1 parent 3342fdb commit c4ffb37

6 files changed

Lines changed: 159 additions & 51 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules/
1+
node_modules
22
dist/
33
.DS_Store
44
*.log

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.github
2+
.gitignore
3+
CHANGELOG.md
4+
package-lock.json

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.5] - 2026-01-02
9+
10+
### Added
11+
12+
- **CLI Config Options**: New command-line options for configuring documentation metadata and branding
13+
- `--name <name>` - Set project name directly from CLI
14+
- `--description <description>` - Set project description
15+
- `--primary-color <color>` - Set primary theme color (hex format)
16+
- `--accent-color <color>` - Set accent theme color (hex format)
17+
- `--favicon <path>` - Set favicon path
18+
- `--logo <path>` - Set logo path
19+
- **Enhanced Config Management**: CLI options now automatically update `docs-config.json` during build/dev/eject operations
20+
21+
### Removed
22+
23+
- **Unused Dependency**: Removed `zod` package (was not being used, reduces bundle size)
24+
25+
### Improved
26+
27+
- **Cleaner Dependencies**: Only 8 essential packages now (from 9)
28+
- **CLI Usability**: No need to manually edit `docs-config.json` for basic configuration
29+
830
## [0.3.0] - 2026-01-01
931

1032
### Added

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devrohit06/superdocs",
3-
"version": "0.3.0",
3+
"version": "0.3.5",
44
"description": "The open-source Mintlify alternative. Beautiful documentation sites from Markdown.",
55
"main": "src/index.js",
66
"type": "module",
@@ -32,7 +32,6 @@
3232
"commander": "^12.1.0",
3333
"execa": "^9.0.0",
3434
"fs-extra": "^11.2.0",
35-
"picocolors": "^1.1.1",
36-
"zod": "^3.23.0"
35+
"picocolors": "^1.1.1"
3736
}
38-
}
37+
}

src/cli.js

Lines changed: 84 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,114 @@
1-
import { Command } from 'commander';
2-
import pc from 'picocolors';
3-
import { buildCommand } from './commands/build.js';
4-
import { devCommand } from './commands/dev.js';
5-
import { ejectCommand } from './commands/eject.js';
6-
import { templateListCommand, templateCacheCommand } from './commands/template.js';
1+
import { Command } from "commander";
2+
import pc from "picocolors";
3+
import { buildCommand } from "./commands/build.js";
4+
import { devCommand } from "./commands/dev.js";
5+
import { ejectCommand } from "./commands/eject.js";
6+
import {
7+
templateListCommand,
8+
templateCacheCommand,
9+
} from "./commands/template.js";
710

811
export async function cli() {
912
const program = new Command();
1013

1114
program
12-
.name('superdocs')
13-
.description('The open-source Mintlify alternative. Beautiful docs from Markdown.')
14-
.version('0.3.0');
15+
.name("superdocs")
16+
.description(
17+
"The open-source Mintlify alternative. Beautiful docs from Markdown."
18+
)
19+
.version("0.3.5");
1520

1621
program
17-
.command('build')
18-
.description('Build the documentation site')
19-
.requiredOption('-i, --input <path>', 'Path to the docs folder')
20-
.option('-o, --output <path>', 'Output directory for the built site', './dist')
21-
.option('-t, --template <name>', 'Template to use (default, github:owner/repo, or local path)', 'default')
22-
.option('-b, --base-url <url>', 'Base URL for the site', '/')
23-
.option('--search', 'Enable search functionality', false)
24-
.option('--refresh', 'Force re-download template (bypass cache)', false)
22+
.command("build")
23+
.description("Build the documentation site")
24+
.requiredOption("-i, --input <path>", "Path to the docs folder")
25+
.option(
26+
"-o, --output <path>",
27+
"Output directory for the built site",
28+
"./dist"
29+
)
30+
.option(
31+
"-t, --template <name>",
32+
"Template to use (default, github:owner/repo, or local path)",
33+
"default"
34+
)
35+
.option("-b, --base-url <url>", "Base URL for the site", "/")
36+
.option("--name <name>", "Project name")
37+
.option("--description <description>", "Project description")
38+
.option("--primary-color <color>", "Primary theme color (hex)")
39+
.option("--accent-color <color>", "Accent theme color (hex)")
40+
.option("--favicon <path>", "Favicon path")
41+
.option("--logo <path>", "Logo path")
42+
.option("--search", "Enable search functionality", false)
43+
.option("--refresh", "Force re-download template (bypass cache)", false)
2544
.action(buildCommand);
2645

2746
program
28-
.command('dev')
29-
.description('Start development server with watch mode')
30-
.requiredOption('-i, --input <path>', 'Path to the docs folder')
31-
.option('-t, --template <name>', 'Template to use (default, github:owner/repo, or local path)', 'default')
32-
.option('-b, --base-url <url>', 'Base URL for the site', '/')
33-
.option('--search', 'Enable search functionality', false)
34-
.option('-p, --port <number>', 'Port for dev server', '4321')
35-
.option('--refresh', 'Force re-download template (bypass cache)', false)
47+
.command("dev")
48+
.description("Start development server with watch mode")
49+
.requiredOption("-i, --input <path>", "Path to the docs folder")
50+
.option(
51+
"-t, --template <name>",
52+
"Template to use (default, github:owner/repo, or local path)",
53+
"default"
54+
)
55+
.option("-b, --base-url <url>", "Base URL for the site", "/")
56+
.option("--name <name>", "Project name")
57+
.option("--description <description>", "Project description")
58+
.option("--primary-color <color>", "Primary theme color (hex)")
59+
.option("--accent-color <color>", "Accent theme color (hex)")
60+
.option("--favicon <path>", "Favicon path")
61+
.option("--logo <path>", "Logo path")
62+
.option("--search", "Enable search functionality", false)
63+
.option("-p, --port <number>", "Port for dev server", "4321")
64+
.option("--refresh", "Force re-download template (bypass cache)", false)
3665
.action(devCommand);
3766

3867
program
39-
.command('eject')
40-
.description('Export the full Astro project source code')
41-
.requiredOption('-i, --input <path>', 'Path to the docs folder')
42-
.option('-o, --output <path>', 'Output directory for the project', './astro-docs-project')
43-
.option('-t, --template <name>', 'Template to use (default, github:owner/repo, or local path)', 'default')
44-
.option('-b, --base-url <url>', 'Base URL for the site', '/')
45-
.option('--search', 'Enable search functionality', false)
46-
.option('--refresh', 'Force re-download template (bypass cache)', false)
68+
.command("eject")
69+
.description("Export the full Astro project source code")
70+
.requiredOption("-i, --input <path>", "Path to the docs folder")
71+
.option(
72+
"-o, --output <path>",
73+
"Output directory for the project",
74+
"./astro-docs-project"
75+
)
76+
.option(
77+
"-t, --template <name>",
78+
"Template to use (default, github:owner/repo, or local path)",
79+
"default"
80+
)
81+
.option("-b, --base-url <url>", "Base URL for the site", "/")
82+
.option("--name <name>", "Project name")
83+
.option("--description <description>", "Project description")
84+
.option("--primary-color <color>", "Primary theme color (hex)")
85+
.option("--accent-color <color>", "Accent theme color (hex)")
86+
.option("--favicon <path>", "Favicon path")
87+
.option("--logo <path>", "Logo path")
88+
.option("--search", "Enable search functionality", false)
89+
.option("--refresh", "Force re-download template (bypass cache)", false)
4790
.action(ejectCommand);
4891

4992
// Template management commands
5093
const templateCmd = program
51-
.command('template')
52-
.description('Manage documentation templates');
94+
.command("template")
95+
.description("Manage documentation templates");
5396

5497
templateCmd
55-
.command('list')
56-
.description('List available templates')
98+
.command("list")
99+
.description("List available templates")
57100
.action(templateListCommand);
58101

59102
templateCmd
60-
.command('cache')
61-
.description('Manage template cache')
62-
.option('--clear', 'Clear all cached templates')
103+
.command("cache")
104+
.description("Manage template cache")
105+
.option("--clear", "Clear all cached templates")
63106
.action(templateCacheCommand);
64107

65108
try {
66109
await program.parseAsync(process.argv);
67110
} catch (error) {
68-
console.error(pc.red('Error:'), error.message);
111+
console.error(pc.red("Error:"), error.message);
69112
process.exit(1);
70113
}
71114
}

src/core/config.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,59 @@ const { readFile, writeFile } = pkg;
33
import { join } from "path";
44

55
export async function generateConfig(projectDir, options) {
6-
const { baseUrl } = options;
6+
const {
7+
baseUrl,
8+
name,
9+
description,
10+
primaryColor,
11+
accentColor,
12+
favicon,
13+
logo,
14+
} = options;
715

8-
// Only modify if base URL is not default
16+
// Update docs-config.json with metadata and theme options
17+
const configPath = join(projectDir, "docs-config.json");
18+
let config = JSON.parse(await readFile(configPath, "utf-8"));
19+
20+
// Update metadata
21+
if (name) {
22+
config.metadata = config.metadata || {};
23+
config.metadata.name = name;
24+
}
25+
26+
if (description) {
27+
config.metadata = config.metadata || {};
28+
config.metadata.description = description;
29+
}
30+
31+
// Update theme colors
32+
if (primaryColor || accentColor) {
33+
config.theme = config.theme || {};
34+
if (primaryColor) config.theme.primaryColor = primaryColor;
35+
if (accentColor) config.theme.accentColor = accentColor;
36+
}
37+
38+
// Update branding
39+
if (favicon || logo) {
40+
config.branding = config.branding || {};
41+
if (favicon) config.branding.favicon = favicon;
42+
if (logo) config.branding.logo = config.branding.logo || {};
43+
if (logo) config.branding.logo.src = logo;
44+
}
45+
46+
await writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
47+
48+
// Update astro.config.mjs with base URL if needed
949
if (baseUrl && baseUrl !== "/") {
10-
const configPath = join(projectDir, "astro.config.mjs");
11-
let content = await readFile(configPath, "utf-8");
50+
const astroConfigPath = join(projectDir, "astro.config.mjs");
51+
let content = await readFile(astroConfigPath, "utf-8");
1252

1353
// Add base option to defineConfig
1454
content = content.replace(
1555
"export default defineConfig({",
1656
`export default defineConfig({\n base: '${baseUrl}',`
1757
);
1858

19-
await writeFile(configPath, content, "utf-8");
59+
await writeFile(astroConfigPath, content, "utf-8");
2060
}
2161
}

0 commit comments

Comments
 (0)