@litodocs/cli 0.7.0 → 1.1.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/package.json +7 -2
- package/src/cli.js +2 -2
- package/src/core/framework-runner.js +23 -1
- package/src/core/scaffold.js +4 -3
- package/src/core/update-check.js +11 -1
- package/lito-manifest.schema.json +0 -118
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litodocs/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Beautiful documentation sites from Markdown. Fast, simple, and open-source.",
|
|
5
|
-
"main": "src/index.js",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"bin": {
|
|
8
7
|
"lito": "./bin/cli.js"
|
|
9
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"src/",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
10
15
|
"scripts": {
|
|
11
16
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
17
|
},
|
package/src/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
templateListCommand,
|
|
13
13
|
templateCacheCommand,
|
|
14
14
|
} from "./commands/template.js";
|
|
15
|
-
import { checkForUpdates, upgradeCommand } from "./core/update-check.js";
|
|
15
|
+
import { checkForUpdates, upgradeCommand, getCurrentVersion } from "./core/update-check.js";
|
|
16
16
|
|
|
17
17
|
export async function cli() {
|
|
18
18
|
const program = new Command();
|
|
@@ -25,7 +25,7 @@ export async function cli() {
|
|
|
25
25
|
.description(
|
|
26
26
|
"Beautiful documentation sites from Markdown. Fast, simple, and open-source."
|
|
27
27
|
)
|
|
28
|
-
.version(
|
|
28
|
+
.version(getCurrentVersion());
|
|
29
29
|
|
|
30
30
|
program
|
|
31
31
|
.command("build")
|
|
@@ -60,6 +60,18 @@ const DEFAULT_FRAMEWORK_CONFIGS = {
|
|
|
60
60
|
// HMR trigger file that will be updated when content changes
|
|
61
61
|
hmrTriggerFile: 'src/.lito-hmr-trigger.js',
|
|
62
62
|
},
|
|
63
|
+
nuxt: {
|
|
64
|
+
name: 'nuxt',
|
|
65
|
+
commands: {
|
|
66
|
+
dev: ['nuxt', ['dev']],
|
|
67
|
+
build: ['nuxt', ['build']],
|
|
68
|
+
},
|
|
69
|
+
contentDir: 'content',
|
|
70
|
+
publicDir: 'public',
|
|
71
|
+
configFile: 'nuxt.config.ts',
|
|
72
|
+
layoutInjection: false,
|
|
73
|
+
useMDX: true,
|
|
74
|
+
},
|
|
63
75
|
};
|
|
64
76
|
|
|
65
77
|
/**
|
|
@@ -99,6 +111,11 @@ export async function detectFramework(projectDir) {
|
|
|
99
111
|
return DEFAULT_FRAMEWORK_CONFIGS.astro;
|
|
100
112
|
}
|
|
101
113
|
|
|
114
|
+
if (await pathExists(join(projectDir, 'nuxt.config.ts')) ||
|
|
115
|
+
await pathExists(join(projectDir, 'nuxt.config.js'))) {
|
|
116
|
+
return DEFAULT_FRAMEWORK_CONFIGS.nuxt;
|
|
117
|
+
}
|
|
118
|
+
|
|
102
119
|
if (await pathExists(join(projectDir, 'next.config.js')) ||
|
|
103
120
|
await pathExists(join(projectDir, 'next.config.mjs')) ||
|
|
104
121
|
await pathExists(join(projectDir, 'next.config.ts'))) {
|
|
@@ -113,6 +130,7 @@ export async function detectFramework(projectDir) {
|
|
|
113
130
|
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
114
131
|
|
|
115
132
|
if (deps['next']) return DEFAULT_FRAMEWORK_CONFIGS.next;
|
|
133
|
+
if (deps['nuxt']) return DEFAULT_FRAMEWORK_CONFIGS.nuxt;
|
|
116
134
|
if (deps['astro']) return DEFAULT_FRAMEWORK_CONFIGS.astro;
|
|
117
135
|
if (deps['vue'] && deps['vite']) return DEFAULT_FRAMEWORK_CONFIGS.vue;
|
|
118
136
|
if (deps['react'] && deps['vite']) return DEFAULT_FRAMEWORK_CONFIGS.react;
|
|
@@ -162,6 +180,8 @@ export async function runFrameworkDev(projectDir, frameworkConfig, port = '4321'
|
|
|
162
180
|
devArgs.push('--port', port);
|
|
163
181
|
} else if (frameworkConfig.name === 'next') {
|
|
164
182
|
devArgs.push('-p', port);
|
|
183
|
+
} else if (frameworkConfig.name === 'nuxt') {
|
|
184
|
+
devArgs.push('--port', port);
|
|
165
185
|
} else {
|
|
166
186
|
// Vite-based frameworks
|
|
167
187
|
devArgs.push('--port', port);
|
|
@@ -189,6 +209,8 @@ export function getOutputDir(frameworkConfig) {
|
|
|
189
209
|
return 'dist';
|
|
190
210
|
case 'next':
|
|
191
211
|
return '.next';
|
|
212
|
+
case 'nuxt':
|
|
213
|
+
return '.output/public';
|
|
192
214
|
case 'react':
|
|
193
215
|
case 'vue':
|
|
194
216
|
return 'dist';
|
|
@@ -202,7 +224,7 @@ export function getOutputDir(frameworkConfig) {
|
|
|
202
224
|
*/
|
|
203
225
|
export function needsSearchIndex(frameworkConfig) {
|
|
204
226
|
// Only static-output frameworks need pagefind
|
|
205
|
-
return ['astro', 'react', 'vue'].includes(frameworkConfig.name);
|
|
227
|
+
return ['astro', 'react', 'vue', 'nuxt'].includes(frameworkConfig.name);
|
|
206
228
|
}
|
|
207
229
|
|
|
208
230
|
export { DEFAULT_FRAMEWORK_CONFIGS };
|
package/src/core/scaffold.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pkg from 'fs-extra';
|
|
2
2
|
const { ensureDir, emptyDir, copy, remove } = pkg;
|
|
3
|
-
import {
|
|
3
|
+
import { homedir } from 'os';
|
|
4
4
|
import { join, basename } from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { dirname } from 'path';
|
|
@@ -8,8 +8,9 @@ import { dirname } from 'path';
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = dirname(__filename);
|
|
10
10
|
|
|
11
|
-
// Use a
|
|
12
|
-
|
|
11
|
+
// Use a directory under the user's home to avoid resolution issues
|
|
12
|
+
// with bundlers (e.g. Turbopack) that fail to resolve node_modules from /tmp
|
|
13
|
+
const LITO_DIR = join(homedir(), '.lito', 'dev-project');
|
|
13
14
|
|
|
14
15
|
export async function scaffoldProject(customTemplatePath = null) {
|
|
15
16
|
// Ensure the directory exists (creates if it doesn't)
|
package/src/core/update-check.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { exec } from 'child_process';
|
|
2
2
|
import { promisify } from 'util';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
3
6
|
import pc from 'picocolors';
|
|
4
7
|
import { confirm } from '@clack/prompts';
|
|
5
8
|
|
|
@@ -11,7 +14,14 @@ const PACKAGE_NAME = '@litodocs/cli';
|
|
|
11
14
|
* Get the current installed version from package.json
|
|
12
15
|
*/
|
|
13
16
|
export function getCurrentVersion() {
|
|
14
|
-
|
|
17
|
+
try {
|
|
18
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const pkgPath = join(__dirname, '..', '..', 'package.json');
|
|
20
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
21
|
+
return pkg.version;
|
|
22
|
+
} catch {
|
|
23
|
+
return '1.0.0';
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
26
|
|
|
17
27
|
/**
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lito Template Manifest",
|
|
4
|
-
"description": "Configuration schema for Lito documentation templates",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "Template name"
|
|
10
|
-
},
|
|
11
|
-
"version": {
|
|
12
|
-
"type": "string",
|
|
13
|
-
"description": "Template version (semver)"
|
|
14
|
-
},
|
|
15
|
-
"framework": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"enum": ["astro", "react", "next", "vue", "nuxt", "svelte"],
|
|
18
|
-
"description": "The framework this template uses"
|
|
19
|
-
},
|
|
20
|
-
"frameworkConfig": {
|
|
21
|
-
"type": "object",
|
|
22
|
-
"description": "Custom framework configuration overrides",
|
|
23
|
-
"properties": {
|
|
24
|
-
"contentDir": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "Directory where documentation content is placed"
|
|
27
|
-
},
|
|
28
|
-
"publicDir": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"description": "Directory for static public assets"
|
|
31
|
-
},
|
|
32
|
-
"configFile": {
|
|
33
|
-
"type": "string",
|
|
34
|
-
"description": "Main framework config file name"
|
|
35
|
-
},
|
|
36
|
-
"layoutInjection": {
|
|
37
|
-
"type": "boolean",
|
|
38
|
-
"description": "Whether to inject layout frontmatter into markdown files"
|
|
39
|
-
},
|
|
40
|
-
"layoutPath": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"description": "Path to the markdown layout component"
|
|
43
|
-
},
|
|
44
|
-
"useMDX": {
|
|
45
|
-
"type": "boolean",
|
|
46
|
-
"description": "Whether the template uses MDX for markdown processing"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"commands": {
|
|
51
|
-
"type": "object",
|
|
52
|
-
"description": "Custom build/dev commands",
|
|
53
|
-
"properties": {
|
|
54
|
-
"dev": {
|
|
55
|
-
"type": "array",
|
|
56
|
-
"items": [
|
|
57
|
-
{ "type": "string", "description": "Binary name" },
|
|
58
|
-
{ "type": "array", "items": { "type": "string" }, "description": "Arguments" }
|
|
59
|
-
],
|
|
60
|
-
"description": "Dev server command [binary, [args]]"
|
|
61
|
-
},
|
|
62
|
-
"build": {
|
|
63
|
-
"type": "array",
|
|
64
|
-
"items": [
|
|
65
|
-
{ "type": "string", "description": "Binary name" },
|
|
66
|
-
{ "type": "array", "items": { "type": "string" }, "description": "Arguments" }
|
|
67
|
-
],
|
|
68
|
-
"description": "Build command [binary, [args]]"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"features": {
|
|
73
|
-
"type": "object",
|
|
74
|
-
"description": "Template feature flags",
|
|
75
|
-
"properties": {
|
|
76
|
-
"search": {
|
|
77
|
-
"type": "boolean",
|
|
78
|
-
"default": true,
|
|
79
|
-
"description": "Whether template supports search"
|
|
80
|
-
},
|
|
81
|
-
"i18n": {
|
|
82
|
-
"type": "boolean",
|
|
83
|
-
"default": false,
|
|
84
|
-
"description": "Whether template supports internationalization"
|
|
85
|
-
},
|
|
86
|
-
"versioning": {
|
|
87
|
-
"type": "boolean",
|
|
88
|
-
"default": false,
|
|
89
|
-
"description": "Whether template supports doc versioning"
|
|
90
|
-
},
|
|
91
|
-
"darkMode": {
|
|
92
|
-
"type": "boolean",
|
|
93
|
-
"default": true,
|
|
94
|
-
"description": "Whether template supports dark mode"
|
|
95
|
-
},
|
|
96
|
-
"apiDocs": {
|
|
97
|
-
"type": "boolean",
|
|
98
|
-
"default": false,
|
|
99
|
-
"description": "Whether template supports OpenAPI documentation"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
"requiredFiles": {
|
|
104
|
-
"type": "array",
|
|
105
|
-
"items": { "type": "string" },
|
|
106
|
-
"description": "List of files required for this template to work"
|
|
107
|
-
},
|
|
108
|
-
"author": {
|
|
109
|
-
"type": "string",
|
|
110
|
-
"description": "Template author"
|
|
111
|
-
},
|
|
112
|
-
"repository": {
|
|
113
|
-
"type": "string",
|
|
114
|
-
"description": "Git repository URL"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"required": ["framework"]
|
|
118
|
-
}
|