create-docs-engine 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +220 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# create-docs-engine
|
|
2
|
+
|
|
3
|
+
Scaffold a new docs-engine documentation site with one command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-docs-engine my-docs
|
|
9
|
+
cd my-docs
|
|
10
|
+
pnpm dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Interactive CLI prompts for project configuration
|
|
16
|
+
- Support for npm, pnpm, and yarn
|
|
17
|
+
- Optional features (screenshots, mermaid, git integration)
|
|
18
|
+
- Ready-to-run SvelteKit project with docs-engine configured
|
|
19
|
+
- Sample documentation files included
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Specify project name
|
|
25
|
+
npx create-docs-engine my-docs
|
|
26
|
+
|
|
27
|
+
# Interactive mode (will prompt for project name)
|
|
28
|
+
npx create-docs-engine
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## What's Included
|
|
32
|
+
|
|
33
|
+
The generated project includes:
|
|
34
|
+
|
|
35
|
+
- `docs/` - Markdown documentation files
|
|
36
|
+
- `src/routes/` - SvelteKit routes
|
|
37
|
+
- Sample markdown files demonstrating features
|
|
38
|
+
- Configured package.json with scripts
|
|
39
|
+
- .gitignore file
|
|
40
|
+
- README.md
|
|
41
|
+
|
|
42
|
+
## Development
|
|
43
|
+
|
|
44
|
+
After creating a project:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
cd my-docs
|
|
48
|
+
pnpm dev # Start dev server
|
|
49
|
+
pnpm build # Build for production
|
|
50
|
+
pnpm preview # Preview production build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
import { promises as fs } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import prompts from "prompts";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import ora from "ora";
|
|
10
|
+
import { execSync } from "child_process";
|
|
11
|
+
async function main() {
|
|
12
|
+
console.log(chalk.bold.cyan("\n\u{1F680} Create Docs Engine\n"));
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
let projectName = args[0];
|
|
15
|
+
if (!projectName) {
|
|
16
|
+
const response = await prompts({
|
|
17
|
+
type: "text",
|
|
18
|
+
name: "projectName",
|
|
19
|
+
message: "Project name:",
|
|
20
|
+
initial: "my-docs"
|
|
21
|
+
});
|
|
22
|
+
projectName = response.projectName;
|
|
23
|
+
}
|
|
24
|
+
if (!projectName) {
|
|
25
|
+
console.error(chalk.red("\u274C Project name is required"));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
29
|
+
const dirExists = await fs.access(projectPath).then(() => true).catch(() => false);
|
|
30
|
+
if (dirExists) {
|
|
31
|
+
const response = await prompts({
|
|
32
|
+
type: "confirm",
|
|
33
|
+
name: "overwrite",
|
|
34
|
+
message: `Directory "${projectName}" already exists. Overwrite?`,
|
|
35
|
+
initial: false
|
|
36
|
+
});
|
|
37
|
+
if (!response.overwrite) {
|
|
38
|
+
console.log(chalk.yellow("Aborted"));
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
await fs.rm(projectPath, { recursive: true, force: true });
|
|
42
|
+
}
|
|
43
|
+
const answers = await prompts([
|
|
44
|
+
{
|
|
45
|
+
type: "select",
|
|
46
|
+
name: "packageManager",
|
|
47
|
+
message: "Package manager:",
|
|
48
|
+
choices: [
|
|
49
|
+
{ title: "pnpm (recommended)", value: "pnpm" },
|
|
50
|
+
{ title: "npm", value: "npm" },
|
|
51
|
+
{ title: "yarn", value: "yarn" }
|
|
52
|
+
],
|
|
53
|
+
initial: 0
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "multiselect",
|
|
57
|
+
name: "features",
|
|
58
|
+
message: "Select features:",
|
|
59
|
+
choices: [
|
|
60
|
+
{ title: "Screenshots (web + CLI)", value: "screenshots", selected: true },
|
|
61
|
+
{ title: "Mermaid diagrams", value: "mermaid", selected: true },
|
|
62
|
+
{ title: "Git integration", value: "git", selected: true }
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: (_prev, values) => values.features.includes("git") ? "text" : null,
|
|
67
|
+
name: "gitRepo",
|
|
68
|
+
message: "Git repository URL (optional):",
|
|
69
|
+
initial: ""
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
const config = {
|
|
73
|
+
projectName,
|
|
74
|
+
packageManager: answers.packageManager,
|
|
75
|
+
features: {
|
|
76
|
+
screenshots: answers.features.includes("screenshots"),
|
|
77
|
+
mermaid: answers.features.includes("mermaid"),
|
|
78
|
+
git: answers.features.includes("git")
|
|
79
|
+
},
|
|
80
|
+
gitRepo: answers.gitRepo
|
|
81
|
+
};
|
|
82
|
+
const spinner = ora("Creating project...").start();
|
|
83
|
+
try {
|
|
84
|
+
await generateProject(projectPath, config);
|
|
85
|
+
spinner.succeed("Project created successfully!");
|
|
86
|
+
spinner.text = "Installing dependencies...";
|
|
87
|
+
spinner.start();
|
|
88
|
+
await installDependencies(projectPath, config.packageManager);
|
|
89
|
+
spinner.succeed("Dependencies installed!");
|
|
90
|
+
console.log(chalk.green.bold("\n\u2728 All done!\n"));
|
|
91
|
+
console.log(chalk.cyan("Next steps:"));
|
|
92
|
+
console.log(chalk.gray(` cd ${projectName}`));
|
|
93
|
+
console.log(chalk.gray(` ${config.packageManager} dev`));
|
|
94
|
+
console.log();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
spinner.fail("Failed to create project");
|
|
97
|
+
console.error(chalk.red(error instanceof Error ? error.message : "Unknown error"));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function generateProject(projectPath, config) {
|
|
102
|
+
await fs.mkdir(projectPath, { recursive: true });
|
|
103
|
+
const packageJson = {
|
|
104
|
+
name: config.projectName,
|
|
105
|
+
version: "0.1.0",
|
|
106
|
+
private: true,
|
|
107
|
+
type: "module",
|
|
108
|
+
scripts: {
|
|
109
|
+
dev: "vite dev",
|
|
110
|
+
build: "vite build",
|
|
111
|
+
preview: "vite preview"
|
|
112
|
+
},
|
|
113
|
+
dependencies: {
|
|
114
|
+
"@goobits/docs-engine": "latest",
|
|
115
|
+
"@sveltejs/kit": "^2.0.0",
|
|
116
|
+
svelte: "^5.0.0"
|
|
117
|
+
},
|
|
118
|
+
devDependencies: {
|
|
119
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
120
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
121
|
+
vite: "^6.0.0"
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
await fs.writeFile(path.join(projectPath, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
125
|
+
await fs.mkdir(path.join(projectPath, "docs"), { recursive: true });
|
|
126
|
+
await fs.mkdir(path.join(projectPath, "src/routes"), { recursive: true });
|
|
127
|
+
await fs.writeFile(
|
|
128
|
+
path.join(projectPath, "docs/index.md"),
|
|
129
|
+
`---
|
|
130
|
+
title: Home
|
|
131
|
+
description: Welcome to the documentation
|
|
132
|
+
section: Getting Started
|
|
133
|
+
order: 1
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
# Welcome to Docs Engine
|
|
137
|
+
|
|
138
|
+
This is your new documentation site powered by docs-engine.
|
|
139
|
+
|
|
140
|
+
## Features
|
|
141
|
+
|
|
142
|
+
- \u{1F4DD} Markdown-based documentation
|
|
143
|
+
- \u{1F3A8} Beautiful theming (Dracula, GitHub, Minimal)
|
|
144
|
+
- \u{1F50D} Instant Cmd+K search
|
|
145
|
+
- \u2B05\uFE0F\u27A1\uFE0F Previous/Next navigation
|
|
146
|
+
- \u{1F527} Git integration with edit links
|
|
147
|
+
- \u{1F4CA} Mermaid diagrams
|
|
148
|
+
${config.features.screenshots ? "- \u{1F4F8} Screenshot support\n" : ""}`
|
|
149
|
+
);
|
|
150
|
+
await fs.writeFile(
|
|
151
|
+
path.join(projectPath, "docs/getting-started.md"),
|
|
152
|
+
`---
|
|
153
|
+
title: Getting Started
|
|
154
|
+
description: Learn how to use docs-engine
|
|
155
|
+
section: Getting Started
|
|
156
|
+
order: 2
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
# Getting Started
|
|
160
|
+
|
|
161
|
+
Start writing documentation by adding markdown files to the \`docs/\` directory.
|
|
162
|
+
|
|
163
|
+
## Writing Docs
|
|
164
|
+
|
|
165
|
+
Each markdown file can have frontmatter:
|
|
166
|
+
|
|
167
|
+
\`\`\`yaml
|
|
168
|
+
---
|
|
169
|
+
title: Page Title
|
|
170
|
+
description: Page description
|
|
171
|
+
section: Section Name
|
|
172
|
+
order: 1
|
|
173
|
+
---
|
|
174
|
+
\`\`\`
|
|
175
|
+
`
|
|
176
|
+
);
|
|
177
|
+
await fs.writeFile(
|
|
178
|
+
path.join(projectPath, "README.md"),
|
|
179
|
+
`# ${config.projectName}
|
|
180
|
+
|
|
181
|
+
Documentation site built with [docs-engine](https://github.com/goobits/docs-engine).
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
\`\`\`bash
|
|
186
|
+
${config.packageManager} dev
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
## Building
|
|
190
|
+
|
|
191
|
+
\`\`\`bash
|
|
192
|
+
${config.packageManager} build
|
|
193
|
+
\`\`\`
|
|
194
|
+
`
|
|
195
|
+
);
|
|
196
|
+
await fs.writeFile(
|
|
197
|
+
path.join(projectPath, ".gitignore"),
|
|
198
|
+
`node_modules/
|
|
199
|
+
.svelte-kit/
|
|
200
|
+
build/
|
|
201
|
+
.DS_Store
|
|
202
|
+
*.log
|
|
203
|
+
`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
async function installDependencies(projectPath, packageManager) {
|
|
207
|
+
const commands = {
|
|
208
|
+
npm: "npm install",
|
|
209
|
+
pnpm: "pnpm install",
|
|
210
|
+
yarn: "yarn"
|
|
211
|
+
};
|
|
212
|
+
execSync(commands[packageManager], {
|
|
213
|
+
cwd: projectPath,
|
|
214
|
+
stdio: "ignore"
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
main().catch((error) => {
|
|
218
|
+
console.error(chalk.red("Unexpected error:"), error);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-docs-engine",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "CLI tool to scaffold a new docs-engine documentation site",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-docs-engine": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"template"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsup --watch"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"documentation",
|
|
20
|
+
"sveltekit",
|
|
21
|
+
"markdown",
|
|
22
|
+
"docs",
|
|
23
|
+
"cli",
|
|
24
|
+
"generator"
|
|
25
|
+
],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"prompts": "^2.4.2",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"ora": "^9.1.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.0.10",
|
|
35
|
+
"@types/prompts": "^2.4.9",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|