create-ardo 1.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.
Files changed (3) hide show
  1. package/README.md +57 -0
  2. package/dist/index.js +265 -0
  3. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # create-ardo
2
+
3
+ Scaffolding tool for [Ardo](https://github.com/sebastian-software/ardo) documentation projects.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ # With npm
9
+ npm create ardo@latest
10
+
11
+ # With pnpm
12
+ pnpm create ardo@latest
13
+
14
+ # With yarn
15
+ yarn create ardo
16
+
17
+ # With bun
18
+ bun create ardo
19
+ ```
20
+
21
+ ### Specify project name
22
+
23
+ ```bash
24
+ npm create ardo@latest my-docs
25
+ ```
26
+
27
+ ### Non-interactive
28
+
29
+ ```bash
30
+ npm create ardo@latest my-docs minimal
31
+ ```
32
+
33
+ ## What's Created
34
+
35
+ ```
36
+ my-docs/
37
+ ├── content/
38
+ │ ├── index.md
39
+ │ └── guide/
40
+ │ └── getting-started.md
41
+ ├── vite.config.ts
42
+ ├── tsconfig.json
43
+ ├── package.json
44
+ └── .gitignore
45
+ ```
46
+
47
+ ## After Creation
48
+
49
+ ```bash
50
+ cd my-docs
51
+ pnpm install
52
+ pnpm dev
53
+ ```
54
+
55
+ ## License
56
+
57
+ [MIT](../../LICENSE) © [Sebastian Software GmbH](https://sebastian-software.de)
package/dist/index.js ADDED
@@ -0,0 +1,265 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import prompts from "prompts";
7
+ import { blue, cyan, green, red, reset, yellow } from "kolorist";
8
+ var templates = [
9
+ {
10
+ name: "minimal",
11
+ display: "Minimal",
12
+ description: "Basic setup with essential files only"
13
+ }
14
+ ];
15
+ var defaultTargetDir = "my-docs";
16
+ async function main() {
17
+ console.log();
18
+ console.log(` ${cyan("\u25C6")} ${green("create-ardo")}`);
19
+ console.log();
20
+ const argTargetDir = process.argv[2];
21
+ const argTemplate = process.argv[3];
22
+ let targetDir = argTargetDir || defaultTargetDir;
23
+ let template = argTemplate;
24
+ const response = await prompts(
25
+ [
26
+ {
27
+ type: argTargetDir ? null : "text",
28
+ name: "projectName",
29
+ message: reset("Project name:"),
30
+ initial: defaultTargetDir,
31
+ onState: (state) => {
32
+ targetDir = formatTargetDir(state.value) || defaultTargetDir;
33
+ }
34
+ },
35
+ {
36
+ type: () => !fs.existsSync(targetDir) || isEmpty(targetDir) ? null : "select",
37
+ name: "overwrite",
38
+ message: () => `${targetDir === "." ? "Current directory" : `Target directory "${targetDir}"`} is not empty. How would you like to proceed?`,
39
+ choices: [
40
+ { title: "Remove existing files and continue", value: "yes" },
41
+ { title: "Cancel operation", value: "no" },
42
+ { title: "Ignore files and continue", value: "ignore" }
43
+ ]
44
+ },
45
+ {
46
+ type: (_, { overwrite: overwrite2 }) => {
47
+ if (overwrite2 === "no") {
48
+ throw new Error(red("\u2716") + " Operation cancelled");
49
+ }
50
+ return null;
51
+ },
52
+ name: "overwriteChecker"
53
+ },
54
+ {
55
+ type: argTemplate && isValidTemplate(argTemplate) ? null : "select",
56
+ name: "template",
57
+ message: reset("Select a template:"),
58
+ choices: templates.map((t) => ({
59
+ title: `${t.display} ${yellow(`- ${t.description}`)}`,
60
+ value: t.name
61
+ }))
62
+ },
63
+ {
64
+ type: "text",
65
+ name: "siteTitle",
66
+ message: reset("Site title:"),
67
+ initial: "My Documentation"
68
+ }
69
+ ],
70
+ {
71
+ onCancel: () => {
72
+ throw new Error(red("\u2716") + " Operation cancelled");
73
+ }
74
+ }
75
+ );
76
+ const { overwrite, template: templateChoice, siteTitle } = response;
77
+ template = templateChoice || template || "minimal";
78
+ const root = path.join(process.cwd(), targetDir);
79
+ if (overwrite === "yes") {
80
+ emptyDir(root);
81
+ } else if (!fs.existsSync(root)) {
82
+ fs.mkdirSync(root, { recursive: true });
83
+ }
84
+ console.log();
85
+ console.log(` ${cyan("Scaffolding project in")} ${root}...`);
86
+ console.log();
87
+ createProjectStructure(root, template, siteTitle, targetDir);
88
+ console.log(` ${green("Done!")} Now run:`);
89
+ console.log();
90
+ if (root !== process.cwd()) {
91
+ console.log(` ${blue("cd")} ${targetDir}`);
92
+ }
93
+ console.log(` ${blue("pnpm install")}`);
94
+ console.log(` ${blue("pnpm dev")}`);
95
+ console.log();
96
+ }
97
+ function createProjectStructure(root, _template, siteTitle, projectName) {
98
+ const pkg = {
99
+ name: projectName,
100
+ version: "0.0.0",
101
+ private: true,
102
+ type: "module",
103
+ scripts: {
104
+ dev: "vite",
105
+ build: "vite build",
106
+ preview: "vite preview"
107
+ },
108
+ dependencies: {
109
+ ardo: "^1.0.0",
110
+ react: "^19.0.0",
111
+ "react-dom": "^19.0.0"
112
+ },
113
+ devDependencies: {
114
+ "@types/react": "^19.0.0",
115
+ "@types/react-dom": "^19.0.0",
116
+ typescript: "^5.7.0",
117
+ vite: "^6.0.0"
118
+ }
119
+ };
120
+ fs.writeFileSync(path.join(root, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
121
+ const tsconfig = {
122
+ compilerOptions: {
123
+ target: "ES2022",
124
+ lib: ["ES2022", "DOM", "DOM.Iterable"],
125
+ module: "ESNext",
126
+ moduleResolution: "bundler",
127
+ resolveJsonModule: true,
128
+ allowImportingTsExtensions: true,
129
+ strict: true,
130
+ noEmit: true,
131
+ esModuleInterop: true,
132
+ skipLibCheck: true,
133
+ forceConsistentCasingInFileNames: true,
134
+ jsx: "react-jsx"
135
+ },
136
+ include: ["src/**/*", "*.ts", "*.config.ts"],
137
+ exclude: ["node_modules", "dist"]
138
+ };
139
+ fs.writeFileSync(path.join(root, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n");
140
+ const viteConfig = `import { defineConfig } from 'vite'
141
+ import { ardo } from 'ardo/vite'
142
+
143
+ export default defineConfig({
144
+ plugins: [
145
+ ardo({
146
+ title: '${siteTitle}',
147
+ description: 'Built with Ardo',
148
+
149
+ themeConfig: {
150
+ siteTitle: '${siteTitle}',
151
+
152
+ nav: [
153
+ { text: 'Guide', link: '/guide/getting-started' },
154
+ ],
155
+
156
+ sidebar: [
157
+ {
158
+ text: 'Guide',
159
+ items: [
160
+ { text: 'Getting Started', link: '/guide/getting-started' },
161
+ ],
162
+ },
163
+ ],
164
+
165
+ footer: {
166
+ message: 'Built with Ardo',
167
+ },
168
+
169
+ search: {
170
+ enabled: true,
171
+ },
172
+ },
173
+ }),
174
+ ],
175
+ })
176
+ `;
177
+ fs.writeFileSync(path.join(root, "vite.config.ts"), viteConfig);
178
+ const gitignore = `node_modules
179
+ dist
180
+ .DS_Store
181
+ *.local
182
+ `;
183
+ fs.writeFileSync(path.join(root, ".gitignore"), gitignore);
184
+ const contentDir = path.join(root, "content");
185
+ const guideDir = path.join(contentDir, "guide");
186
+ fs.mkdirSync(guideDir, { recursive: true });
187
+ const indexMd = `---
188
+ title: Welcome
189
+ ---
190
+
191
+ # Welcome to ${siteTitle}
192
+
193
+ This documentation site is built with [Ardo](https://github.com/sebastian-software/ardo).
194
+
195
+ ## Getting Started
196
+
197
+ Check out the [Getting Started](/guide/getting-started) guide to learn more.
198
+ `;
199
+ fs.writeFileSync(path.join(contentDir, "index.md"), indexMd);
200
+ const gettingStartedMd = `---
201
+ title: Getting Started
202
+ ---
203
+
204
+ # Getting Started
205
+
206
+ Welcome to your new documentation site!
207
+
208
+ ## Development
209
+
210
+ \`\`\`bash
211
+ # Start development server
212
+ pnpm dev
213
+
214
+ # Build for production
215
+ pnpm build
216
+
217
+ # Preview production build
218
+ pnpm preview
219
+ \`\`\`
220
+
221
+ ## Adding Content
222
+
223
+ Create \`.md\` or \`.mdx\` files in the \`content/\` directory. They will automatically become pages.
224
+
225
+ ## Configuration
226
+
227
+ Edit \`vite.config.ts\` to customize your site:
228
+
229
+ - Navigation links
230
+ - Sidebar structure
231
+ - Site title and description
232
+ - Theme options
233
+
234
+ ## Learn More
235
+
236
+ - [Ardo Documentation](https://sebastian-software.github.io/ardo/)
237
+ - [GitHub Repository](https://github.com/sebastian-software/ardo)
238
+ `;
239
+ fs.writeFileSync(path.join(guideDir, "getting-started.md"), gettingStartedMd);
240
+ }
241
+ function formatTargetDir(targetDir) {
242
+ return targetDir?.trim().replace(/\/+$/g, "");
243
+ }
244
+ function isEmpty(dirPath) {
245
+ const files = fs.readdirSync(dirPath);
246
+ return files.length === 0 || files.length === 1 && files[0] === ".git";
247
+ }
248
+ function emptyDir(dir) {
249
+ if (!fs.existsSync(dir)) {
250
+ return;
251
+ }
252
+ for (const file of fs.readdirSync(dir)) {
253
+ if (file === ".git") {
254
+ continue;
255
+ }
256
+ fs.rmSync(path.join(dir, file), { recursive: true, force: true });
257
+ }
258
+ }
259
+ function isValidTemplate(template) {
260
+ return templates.some((t) => t.name === template);
261
+ }
262
+ main().catch((e) => {
263
+ console.error(e.message);
264
+ process.exit(1);
265
+ });
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "create-ardo",
3
+ "version": "1.0.0",
4
+ "description": "Scaffolding tool for Ardo documentation projects",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-ardo": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsup",
14
+ "dev": "tsup --watch",
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "keywords": [
18
+ "ardo",
19
+ "create",
20
+ "scaffold",
21
+ "documentation",
22
+ "cli"
23
+ ],
24
+ "author": "Sebastian Software GmbH",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/sebastian-software/ardo.git",
29
+ "directory": "packages/create-ardo"
30
+ },
31
+ "homepage": "https://sebastian-software.github.io/ardo/",
32
+ "bugs": {
33
+ "url": "https://github.com/sebastian-software/ardo/issues"
34
+ },
35
+ "dependencies": {
36
+ "prompts": "^2.4.2",
37
+ "kolorist": "^1.8.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^22.10.0",
41
+ "@types/prompts": "^2.4.9",
42
+ "tsup": "^8.5.1",
43
+ "typescript": "^5.9.3"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ }
48
+ }