create-docus 1.1.0 → 2.0.0-beta.1

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 CHANGED
@@ -1,55 +1,112 @@
1
- # Docus CLI
1
+ [![docus](https://docus-puce.vercel.app/__og-image__/static/og.png)](https://docus.dev)
2
2
 
3
- The Docus CLI.
3
+ > CLI tool to create beautiful docs with Markdown
4
4
 
5
- ## Quick Setup
5
+ [![npm version](https://img.shields.io/npm/v/create-docus.svg?style=flat&colorA=020420&colorB=EEEEEE)](https://npmjs.com/package/create-docus)
6
+ [![npm downloads](https://img.shields.io/npm/dm/create-docus.svg?style=flat&colorA=020420&colorB=EEEEEE)](https://npm.chart.dev/create-docus)
7
+ [![License](https://img.shields.io/npm/l/create-docus.svg?style=flat&colorA=020420&colorB=EEEEEE)](https://npmjs.com/package/create-docus)
6
8
 
7
- Add `docus` package globally:
9
+ The fastest way to create a new [Docus](https://docus.dev) documentation project. This CLI tool scaffolds a complete documentation website using the [`docus`](https://www.github.com/nuxtlabs/docus/tree/main/layer) Nuxt layer.
10
+
11
+ ## 🚀 Quick Start
12
+
13
+ Create a new documentation project in seconds:
8
14
 
9
15
  ```bash
10
- # Using Yarn
11
- yarn global add docus
16
+ # Create a new project
17
+ npx create docus my-docs
18
+
19
+ # Navigate to your project
20
+ cd my-docs
12
21
 
13
- # Using NPM
14
- npm install --global docus
22
+ # Start development server
23
+ npm run dev
15
24
  ```
16
25
 
17
- ## Commands
26
+ That's it! Your documentation site will be running at `http://localhost:3000`
18
27
 
19
- ### `npm init docus`
28
+ ## 🎯 What it creates
20
29
 
21
- This package is also responsible for the `npm init docus` command.
30
+ The CLI scaffolds a complete documentation project with:
22
31
 
23
- You can use it without installing `docus` package globally.
32
+ - **Beautiful Design** - Clean, modern documentation theme
33
+ - 📱 **Responsive** - Mobile-first responsive design
34
+ - 🌙 **Dark Mode** - Built-in dark/light mode support
35
+ - 🔍 **Search** - Full-text search functionality
36
+ - 📝 **Markdown Enhanced** - Extended markdown with custom components
37
+ - 🎨 **Customizable** - Easy theming and brand customization
38
+ - ⚡ **Fast** - Optimized for performance with Nuxt 4
39
+ - 🔧 **TypeScript** - Full TypeScript support
24
40
 
25
- `--` is required as specified [here](https://docs.npmjs.com/cli/v7/commands/npm-init#forwarding-additional-options).
41
+ ## 📁 Project Structure
26
42
 
27
- ```bash
28
- npm init docus -- path/to/project
43
+ ### Generated project
29
44
 
30
- npm init docus -- --type="module" path/to/project
45
+ ```
46
+ my-docs/
47
+ ├── content/ # Your markdown content
48
+ │ ├── index.md # Homepage
49
+ │ └── docs/ # Documentation pages
50
+ ├── public/ # Static assets
51
+ └── package.json # Dependencies and scripts
52
+ ```
53
+
54
+ ### Optional files and folders
31
55
 
32
- npm init docus -- --type="theme" path/to/project
56
+ Docus uses a layer system, you can go further and use any feature or file of a classical Nuxt project:
57
+
58
+ ```
59
+ my-docs/
60
+ ├── app.config.ts # App configuration
61
+ ├── nuxt.config.ts # Nuxt configuration (add extra modules, components, etc.)
62
+ ├── app/ # App directory
63
+ │ ├── components/ # Components (add your own components)
64
+ │ ├── layouts/ # Layouts (add your own layouts)
65
+ │ └── pages/ # Pages (add your own pages)
66
+ └── server/ # Server-side code (add your own server-side code)
33
67
  ```
34
68
 
35
- ### `create-docus`
69
+ ## ⚡ Built with
36
70
 
37
- If you install the `docus` package globally, it will be shipped with `create-docus` executable.
71
+ Your project comes pre-configured with the best of the Nuxt ecosystem:
38
72
 
39
- This allows the creation of a [Docus project](https://github.com/docusgen/starter), a [theme](https://github.com/docusgen/theme-starter) or a [module](https://github.com/docusgen/module-starter).
73
+ - [Nuxt 4](https://nuxt.com) - The web framework
74
+ - [Nuxt Content](https://content.nuxt.com/) - File-based CMS
75
+ - [Nuxt UI Pro](https://ui.nuxt.com/pro) - Premium UI components
76
+ - [Nuxt Image](https://image.nuxt.com/) - Optimized images
77
+ - [Tailwind CSS 4](https://tailwindcss.com/) - Utility-first CSS
78
+ - [Docus Layer](https://www.npmjs.com/package/docus) - Documentation theme
40
79
 
41
- You can execute this command anywhere:
80
+ ## 🔗 Related Packages
81
+
82
+ - [`docus`](https://github.com/nuxtlabs/docus/tree/main/layer) - The Nuxt layer that powers your documentation
83
+
84
+ ## 📖 Documentation
85
+
86
+ For detailed documentation on customizing your Docus project, visit the [Docus Documentation](https://docus.dev)
87
+
88
+ ## 🛠️ Development
89
+
90
+ This repository contains the CLI tool source code.
91
+
92
+ ### Local Development
93
+
94
+ To contribute to the CLI tool:
42
95
 
43
96
  ```bash
44
- create-docus path/to/project
97
+ # Clone this repository
98
+ git clone https://github.com/nuxtlabs/docus
99
+
100
+ # Install dependencies
101
+ pnpm install
45
102
 
46
- create-docus --type="module" path/to/project
103
+ # Build the CLI
104
+ pnpm run build
47
105
 
48
- create-docus --type="theme" path/to/project
106
+ # Run the dev server to run the docus docs
107
+ pnpm run dev
49
108
  ```
50
109
 
51
- ## Development
110
+ ## 📄 License
52
111
 
53
- 1. Clone this repository
54
- 2. Install dependencies using `yarn install`
55
- 3. Start dev server using `yarn dev`
112
+ Published under the [MIT](https://github.com/nuxtlabs/docus/blob/main/LICENSE) license.
package/dist/main.mjs ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ // cli.ts
4
+ import { resolve } from "path";
5
+ import { defineCommand, runMain } from "citty";
6
+ function createCLI(opts) {
7
+ const main = defineCommand({
8
+ meta: {
9
+ name: opts.name,
10
+ description: opts.description
11
+ },
12
+ args: {
13
+ dir: {
14
+ type: "positional",
15
+ description: "Project directory",
16
+ required: false,
17
+ default: "docs"
18
+ }
19
+ },
20
+ async setup({ args }) {
21
+ const dir = resolve(args.dir);
22
+ const { runCommand } = await import("nuxi");
23
+ await runCommand("init", [dir, "-t", "gh:nuxtlabs/docus/.starters/default#feat/nuxt-cli"]);
24
+ }
25
+ });
26
+ return {
27
+ runMain: () => runMain(main)
28
+ };
29
+ }
30
+
31
+ // main.ts
32
+ var cli = createCLI({
33
+ name: "create-docus",
34
+ description: "Create a new Docus documentation project",
35
+ setup: {
36
+ defaults: {}
37
+ }
38
+ });
39
+ cli.runMain();
package/package.json CHANGED
@@ -1,73 +1,45 @@
1
1
  {
2
2
  "name": "create-docus",
3
- "version": "1.1.0",
4
- "description": "The Docus CLI.",
5
- "repository": "https://github.com/docusgen/cli",
6
- "bugs": {
7
- "url": "https://github.com/docusgen/cli/issues"
3
+ "description": "CLI for creating Docus documentation projects",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/nuxtlabs/docus.git"
8
7
  },
9
- "homepage": "https://github.com/docusgen/cli#readme",
10
- "author": "Yaël GUILLOUX <yael.guilloux@gmail.com>",
8
+ "private": false,
9
+ "version": "2.0.0-beta.1",
10
+ "keywords": [],
11
11
  "license": "MIT",
12
- "keywords": [
13
- "typescript",
14
- "starter"
15
- ],
16
- "main": "dist/index.js",
17
- "module": "dist/index.mjs",
18
- "types": "dist/src/index.d.ts",
19
- "scripts": {
20
- "dev": "jiti scripts/watch.ts --cache",
21
- "build": "unbuild",
22
- "lint": "prettier -c --parser typescript \"{src,tests}/**/*.[jt]s?(x)\"",
23
- "lint:fix": "yarn run lint --write",
24
- "test:types": "tsc --build tsconfig.json",
25
- "test:unit": "jest",
26
- "test": "yarn run test:types && yarn run test:unit"
27
- },
28
- "engines": {
29
- "node": ">=14.0.0"
30
- },
31
12
  "bin": {
32
- "create-docus": "dist/create-docus/create-docus.js"
13
+ "create-docus": "dist/main.mjs"
33
14
  },
34
15
  "files": [
35
- "dist/**/*",
36
- "LICENSE",
37
- "README.md"
16
+ "dist"
38
17
  ],
18
+ "scripts": {
19
+ "prepare": "pnpm build",
20
+ "build": "tsup-node ./main.ts --format esm",
21
+ "dev": "tsx ./main.ts",
22
+ "lint": "eslint ."
23
+ },
39
24
  "dependencies": {
40
- "degit": "^2.8.4",
41
- "execa": "^6.0.0",
42
- "kolorist": "^1.5.0",
43
- "minimist": "^1.2.5",
44
- "prompts": "^2.4.2"
25
+ "@nuxt/kit": "^4.0.0",
26
+ "c12": "^3.1.0",
27
+ "citty": "^0.1.6",
28
+ "defu": "^6.1.4",
29
+ "dotenv": "^17.2.0",
30
+ "git-url-parse": "^16.1.0",
31
+ "minimark": "^0.2.0",
32
+ "nuxi": "^3.26.2",
33
+ "pkg-types": "^2.2.0",
34
+ "scule": "^1.3.0",
35
+ "ufo": "^1.6.1",
36
+ "unctx": "^2.4.1",
37
+ "unist-util-visit": "^5.0.0"
45
38
  },
46
39
  "devDependencies": {
47
- "@types/degit": "^2.8.3",
48
- "@types/jest": "^27.0.3",
49
- "@types/minimist": "^1.2.2",
50
- "@types/prompts": "^2.0.14",
51
- "chokidar": "^3.5.2",
52
- "jest": "^27.3.1",
53
- "jiti": "^1.12.9",
54
- "lint-staged": "^12.1.2",
55
- "pascalcase": "^1.0.0",
56
- "prettier": "^2.4.1",
57
- "ts-jest": "^27.0.7",
58
- "typescript": "^4.5.2",
59
- "unbuild": "^0.5.13",
60
- "upath": "^2.0.1"
61
- },
62
- "gitHooks": {
63
- "pre-commit": "lint-staged"
40
+ "@types/node": "^24.0.14",
41
+ "tsup": "^8.5.0",
42
+ "tsx": "^4.20.3"
64
43
  },
65
- "lint-staged": {
66
- "*.js": [
67
- "prettier --write"
68
- ],
69
- "*.ts?(x)": [
70
- "prettier --parser=typescript --write"
71
- ]
72
- }
44
+ "packageManager": "pnpm@10.13.1"
73
45
  }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- // #!/usr/bin/env node
3
- "use strict";
4
-
5
- var _index = require("./index");
6
-
7
- (0, _index.createDocus)().catch(console.log);
@@ -1,246 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.args = void 0;
7
- exports.createDir = createDir;
8
- exports.createProject = createProject;
9
- exports.cwd = void 0;
10
- exports.getProjectType = getProjectType;
11
- exports.getTargetDir = getTargetDir;
12
- exports.getTemplate = getTemplate;
13
- exports.getValidPackageName = getValidPackageName;
14
- exports.pkgManager = exports.log = void 0;
15
-
16
- var _package = require("../../package.json");
17
-
18
- var _fs = _interopRequireDefault(require("fs"));
19
-
20
- var _path = _interopRequireDefault(require("path"));
21
-
22
- var _kolorist = require("kolorist");
23
-
24
- var _minimist = _interopRequireDefault(require("minimist"));
25
-
26
- var _prompts = _interopRequireDefault(require("prompts"));
27
-
28
- var _degit = _interopRequireDefault(require("degit"));
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- const cwd = process.cwd();
33
- exports.cwd = cwd;
34
- const args = (0, _minimist.default)(process.argv.slice(2));
35
- exports.args = args;
36
- const pkgManager = /pnpm/.test(process.env.npm_execpath || "") || /pnpm/.test(process.env.npm_config_user_agent || "") ? "pnpm" : /yarn/.test(process.env.npm_execpath || "") ? "yarn" : "npm";
37
- exports.pkgManager = pkgManager;
38
- const log = {
39
- space: () => console.log(),
40
- bold: str => (0, _kolorist.bold)(str),
41
- primary: str => (0, _kolorist.green)(str),
42
- secondary: str => (0, _kolorist.dim)(str),
43
- warning: str => (0, _kolorist.yellow)(str),
44
- error: str => (0, _kolorist.red)(str),
45
- broadcast: str => console.log(` ${str}`),
46
- motd: () => {
47
- log.space();
48
- log.broadcast(`${(0, _kolorist.bold)("Docus") + log.secondary(" CLI")} ${log.primary(`v${_package.version}`)}`);
49
- log.space();
50
- }
51
- };
52
- exports.log = log;
53
- const REPOSITORIES = {
54
- website: "git@github.com:docusgen/starter.git",
55
- theme: "git@github.com:docusgen/theme-starter.git",
56
- module: "git@github.com:docusgen/module-starter.git"
57
- };
58
-
59
- function copyDir(srcDir, destDir) {
60
- _fs.default.mkdirSync(destDir, {
61
- recursive: true
62
- });
63
-
64
- for (const file of _fs.default.readdirSync(srcDir)) {
65
- const srcFile = _path.default.resolve(srcDir, file);
66
-
67
- const destFile = _path.default.resolve(destDir, file);
68
-
69
- copy(srcFile, destFile);
70
- }
71
- }
72
-
73
- function emptyDir(dir) {
74
- if (!_fs.default.existsSync(dir)) return;
75
-
76
- for (const file of _fs.default.readdirSync(dir)) {
77
- const abs = _path.default.resolve(dir, file);
78
-
79
- if (_fs.default.lstatSync(abs).isDirectory()) {
80
- emptyDir(abs);
81
-
82
- _fs.default.rmdirSync(abs);
83
- } else {
84
- _fs.default.unlinkSync(abs);
85
- }
86
- }
87
- }
88
-
89
- function copy(src, dest) {
90
- const stat = _fs.default.statSync(src);
91
-
92
- if (stat.isDirectory()) copyDir(src, dest);else _fs.default.copyFileSync(src, dest);
93
- }
94
-
95
- function getProjectType() {
96
- switch (args["type"]) {
97
- case "theme":
98
- return "theme";
99
-
100
- case "module":
101
- return "module";
102
-
103
- default:
104
- return "website";
105
- }
106
- }
107
-
108
- async function getTemplate(projectType) {
109
- const {
110
- broadcast,
111
- primary,
112
- secondary
113
- } = log;
114
-
115
- const templateDir = _path.default.join(__dirname, "./template");
116
-
117
- broadcast([secondary("Cloning the latest"), primary(projectType === "website" ? "Docus" : projectType), secondary("template...")].join(" "));
118
- emptyDir(templateDir);
119
- const projectRepository = REPOSITORIES[projectType];
120
- const repo = (0, _degit.default)(projectRepository, {
121
- force: true,
122
- verbose: true,
123
- mode: "git"
124
- });
125
- await repo.clone(templateDir);
126
- return templateDir;
127
- }
128
-
129
- async function createDir(targetDir) {
130
- const projectPath = _path.default.join(cwd, targetDir);
131
-
132
- const {
133
- broadcast,
134
- warning,
135
- error,
136
- space,
137
- secondary
138
- } = log;
139
-
140
- if (!_fs.default.existsSync(projectPath)) {
141
- _fs.default.mkdirSync(projectPath, {
142
- recursive: true
143
- });
144
- } else {
145
- const existing = _fs.default.readdirSync(projectPath);
146
-
147
- const dir = projectPath.split("/");
148
- const dirName = dir[dir.length - 1];
149
-
150
- if (existing.length) {
151
- space();
152
- broadcast(warning(`Target directory "${dirName}" is not empty.`));
153
- space();
154
- const {
155
- yes
156
- } = await (0, _prompts.default)({
157
- type: "confirm",
158
- name: "yes",
159
- initial: "Y",
160
- message: "Remove existing files and continue?"
161
- });
162
- if (yes) emptyDir(projectPath);else {
163
- space();
164
- broadcast(warning(`Target directory is not empty and you do not want to overwrite it.`));
165
- space();
166
- broadcast(error(`Cancelling project creation.`));
167
- process.exit(1);
168
- }
169
- }
170
- }
171
-
172
- space();
173
- broadcast(secondary("Scaffolding project in ") + targetDir + secondary("..."));
174
- return projectPath;
175
- }
176
-
177
- async function getValidPackageName(projectName) {
178
- projectName = _path.default.basename(projectName);
179
- const packageNameRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
180
-
181
- if (packageNameRegExp.test(projectName)) {
182
- return projectName;
183
- } else {
184
- const suggestedPackageName = projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
185
- const {
186
- inputPackageName
187
- } = await (0, _prompts.default)({
188
- type: "text",
189
- name: "inputPackageName",
190
- message: "Package name:",
191
- initial: suggestedPackageName,
192
- validate: input => packageNameRegExp.test(input) ? true : "Invalid package.json name"
193
- });
194
- return inputPackageName;
195
- }
196
- }
197
-
198
- async function getTargetDir(projectType) {
199
- const {
200
- space,
201
- broadcast,
202
- error,
203
- warning
204
- } = log;
205
- let targetDir = args._[0];
206
-
207
- if (!targetDir) {
208
- const {
209
- projectName
210
- } = await (0, _prompts.default)({
211
- type: "text",
212
- name: "projectName",
213
- message: "Project name:",
214
- initial: `my-${projectType}`
215
- });
216
-
217
- if (!projectName) {
218
- space();
219
- broadcast(warning(`You must specify a project name.`));
220
- space();
221
- broadcast(error(`Cancelling project creation.`));
222
- process.exit(1);
223
- }
224
-
225
- targetDir = projectName.trim();
226
- }
227
-
228
- return targetDir;
229
- }
230
-
231
- function createProject(root, templateDir, packageName) {
232
- const write = (file, content = void 0) => {
233
- const targetPath = _path.default.join(root, file);
234
-
235
- if (content) _fs.default.writeFileSync(targetPath, content);else copy(_path.default.join(templateDir, file), targetPath);
236
- };
237
-
238
- const files = _fs.default.readdirSync(templateDir);
239
-
240
- for (const file of files.filter(f => f !== "package.json")) write(file);
241
-
242
- const pkg = require(_path.default.join(templateDir, "package.json"));
243
-
244
- pkg.name = packageName;
245
- write("package.json", JSON.stringify(pkg, null, 2));
246
- }
@@ -1,87 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDocus = createDocus;
7
-
8
- var _path = require("path");
9
-
10
- var _prompts = _interopRequireDefault(require("prompts"));
11
-
12
- var _execa = require("execa");
13
-
14
- var _helpers = require("./helpers");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const {
19
- motd,
20
- primary,
21
- secondary,
22
- warning,
23
- bold,
24
- space,
25
- broadcast
26
- } = _helpers.log;
27
-
28
- async function createDocus() {
29
- motd();
30
- const projectType = (0, _helpers.getProjectType)();
31
- const targetDir = await (0, _helpers.getTargetDir)(projectType);
32
- const packageName = await (0, _helpers.getValidPackageName)(targetDir);
33
- const projectPath = await (0, _helpers.createDir)(targetDir);
34
- const templateDir = await (0, _helpers.getTemplate)(projectType);
35
- (0, _helpers.createProject)(projectPath, templateDir, packageName);
36
- broadcast(primary("Done."));
37
- space();
38
- const {
39
- yes
40
- } = await (0, _prompts.default)({
41
- type: "confirm",
42
- name: "yes",
43
- initial: "Y",
44
- message: "Install and start it now?"
45
- });
46
- if (yes) await startProject(projectPath);else startItLater(projectPath);
47
- }
48
-
49
- async function startProject(projectPath) {
50
- space();
51
- const {
52
- agent
53
- } = await (0, _prompts.default)({
54
- name: "agent",
55
- type: "select",
56
- message: "Choose the agent",
57
- choices: ["yarn", "npm", "pnpm"].map(i => ({
58
- value: i,
59
- title: i
60
- }))
61
- });
62
-
63
- if (!agent) {
64
- space();
65
- broadcast(warning(`You cancelled the agent selection!`));
66
- return startItLater(projectPath);
67
- }
68
-
69
- await (0, _execa.execa)(agent, ["install"], {
70
- stdio: "inherit",
71
- cwd: projectPath
72
- });
73
- await (0, _execa.execa)(agent, ["run", "dev"], {
74
- stdio: "inherit",
75
- cwd: projectPath
76
- });
77
- }
78
-
79
- function startItLater(projectPath) {
80
- space();
81
- broadcast(secondary("Start it later with:"));
82
- space();
83
- const dir = (0, _path.relative)(_helpers.cwd, projectPath);
84
- if (projectPath !== _helpers.cwd) broadcast(primary(`cd ${bold(dir)}`));
85
- broadcast(primary(`${_helpers.pkgManager === "yarn" ? "yarn" : `${_helpers.pkgManager} install`}`));
86
- broadcast(primary(`${_helpers.pkgManager === "yarn" ? "yarn dev" : `${_helpers.pkgManager} run dev`}`));
87
- }
package/dist/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = void 0;
7
-
8
- var _default = () => {};
9
-
10
- module.exports = _default;