@clidey/dory 0.29.0 → 0.30.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/bin/dist/dory.js +115 -29
- package/bin/dist/dory.js.map +1 -1
- package/package.json +12 -4
- package/.dockerignore +0 -4
- package/CLAUDE.md +0 -178
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -91
- package/SECURITY.md +0 -11
- package/bin/dory.ts +0 -433
- package/dist/favicon.svg +0 -75
- package/dist/frontmatter.json +0 -77
- package/dist/index.html +0 -55
- package/dist/llms.txt +0 -561
- package/dist/logo/logo.svg +0 -18
- package/docs/api-playground-demo.mdx +0 -119
- package/docs/api-reference/asyncapi.json +0 -324
- package/docs/api-reference/openapi.json +0 -366
- package/docs/api-reference/operations/create.mdx +0 -5
- package/docs/api-reference/operations/delete.mdx +0 -5
- package/docs/api-reference/operations/get.mdx +0 -5
- package/docs/api-reference/operations/update.mdx +0 -5
- package/docs/api-reference/websocket-operations/receive-chat-message.mdx +0 -5
- package/docs/api-reference/websocket-operations/receive-notifications.mdx +0 -5
- package/docs/api-reference/websocket-operations/receive-presence-update.mdx +0 -5
- package/docs/api-reference/websocket-operations/send-chat-message.mdx +0 -5
- package/docs/api-reference/websocket-operations/send-presence-update.mdx +0 -5
- package/docs/dory.json +0 -64
- package/docs/favicon.svg +0 -75
- package/docs/features.mdx +0 -440
- package/docs/introduction.mdx +0 -44
- package/docs/logo/logo.svg +0 -18
- package/docs/websocket-playground-demo.mdx +0 -135
- package/index.html +0 -54
- package/scripts/generate-frontmatter-json.js +0 -154
- package/scripts/generate-llm-txt.js +0 -115
- package/src/app.css +0 -5
- package/src/app.tsx +0 -13
- package/src/components/dropdown.tsx +0 -53
- package/src/components/hooks.tsx +0 -28
- package/src/components/loading.tsx +0 -21
- package/src/components/mdx-provider.tsx +0 -13
- package/src/components/navigation.tsx +0 -58
- package/src/components/notification.tsx +0 -13
- package/src/components/routes.tsx +0 -92
- package/src/components/search-index.ts +0 -43
- package/src/components/search.tsx +0 -435
- package/src/components/store.ts +0 -216
- package/src/config/mdx.js +0 -12
- package/src/config/mdx.ts +0 -12
- package/src/main.tsx +0 -22
- package/src/mdx/accordion.tsx +0 -41
- package/src/mdx/api-playground.tsx +0 -659
- package/src/mdx/api.tsx +0 -354
- package/src/mdx/async-api.tsx +0 -353
- package/src/mdx/callout.tsx +0 -64
- package/src/mdx/card.tsx +0 -54
- package/src/mdx/code.tsx +0 -289
- package/src/mdx/expandable.tsx +0 -36
- package/src/mdx/fence.tsx +0 -74
- package/src/mdx/icon.tsx +0 -73
- package/src/mdx/latex.tsx +0 -26
- package/src/mdx/list.tsx +0 -7
- package/src/mdx/mdx.tsx +0 -47
- package/src/mdx/mermaid.tsx +0 -147
- package/src/mdx/open-api.tsx +0 -311
- package/src/mdx/processor.ts +0 -174
- package/src/mdx/source.tsx +0 -58
- package/src/mdx/step.tsx +0 -51
- package/src/mdx/table.tsx +0 -20
- package/src/mdx/tag.tsx +0 -53
- package/src/mdx/text.tsx +0 -99
- package/src/mdx/websocket-playground.tsx +0 -824
- package/src/plugins/docs-assets.ts +0 -79
- package/src/plugins/frontmatter-dev-server.ts +0 -158
- package/src/plugins/frontmatter-generator.ts +0 -157
- package/src/plugins/html-metadata-injector.ts +0 -76
- package/src/plugins/llm-txt-dev-server.ts +0 -183
- package/src/plugins/llm-txt-generator.ts +0 -186
- package/src/plugins/sanitize.ts +0 -163
- package/src/plugins/unified-mdx-plugin.ts +0 -35
- package/src/theme.scss +0 -72
- package/src/types/config.ts +0 -47
- package/src/ui/header.tsx +0 -91
- package/src/ui/layout.tsx +0 -226
- package/src/ui/mobile-navigation.tsx +0 -64
- package/src/ui/prev-next-link.tsx +0 -74
- package/src/ui/table-of-content.tsx +0 -166
- package/src/utils/colors.ts +0 -54
- package/src/utils/fonts.ts +0 -23
- package/src/utils/functions.ts +0 -12
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -33
- package/tsconfig.bin.json +0 -24
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -43
package/CONTRIBUTING.md
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
When contributing to this repository, please first discuss the change you wish to make via issue,
|
|
4
|
-
email, or any other method with the owners of this repository before making a change.
|
|
5
|
-
|
|
6
|
-
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
|
7
|
-
|
|
8
|
-
## Pull Request Process
|
|
9
|
-
|
|
10
|
-
1. Please do not include any build artifacts unless absolutely necessary.
|
|
11
|
-
2. Update the README.md with details of changes to the interface, this includes new environment
|
|
12
|
-
variables, exposed ports, useful file locations and container parameters.
|
|
13
|
-
3. You're free to choose what you want to work on - there will always be existing issues and we welcome all feature requests.
|
|
14
|
-
4. If you choose to work on an issue, please check on the thread if there has been any activity - if someone's working on something, check with them and see if they'd like help, or if they're still working on it.
|
|
15
|
-
5. If you choose to add a new feature, please open an issue with a title that starts with [FR] and we can have a quick discussion to see viability!
|
|
16
|
-
6. When you're ready, open a pull request, add a detailed description of what you've done, and we'll be in touch! Do not hesitate to update it if you find you missed/wanted to add something.
|
|
17
|
-
|
|
18
|
-
## Code of Conduct
|
|
19
|
-
|
|
20
|
-
### Our Pledge
|
|
21
|
-
|
|
22
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
23
|
-
contributors and maintainers pledge to making participation in our project and
|
|
24
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
25
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
26
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
27
|
-
orientation.
|
|
28
|
-
|
|
29
|
-
### Our Standards
|
|
30
|
-
|
|
31
|
-
Examples of behavior that contributes to creating a positive environment
|
|
32
|
-
include:
|
|
33
|
-
|
|
34
|
-
* Using welcoming and inclusive language
|
|
35
|
-
* Being respectful of differing viewpoints and experiences
|
|
36
|
-
* Gracefully accepting constructive criticism
|
|
37
|
-
* Focusing on what is best for the community
|
|
38
|
-
* Showing empathy towards other community members
|
|
39
|
-
|
|
40
|
-
Examples of unacceptable behavior by participants include:
|
|
41
|
-
|
|
42
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
43
|
-
advances
|
|
44
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
45
|
-
* Public or private harassment
|
|
46
|
-
* Publishing others' private information, such as a physical or electronic
|
|
47
|
-
address, without explicit permission
|
|
48
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
49
|
-
professional setting
|
|
50
|
-
|
|
51
|
-
### Our Responsibilities
|
|
52
|
-
|
|
53
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
54
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
55
|
-
response to any instances of unacceptable behavior.
|
|
56
|
-
|
|
57
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
58
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
59
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
60
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
61
|
-
threatening, offensive, or harmful.
|
|
62
|
-
|
|
63
|
-
### Scope
|
|
64
|
-
|
|
65
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
66
|
-
when an individual is representing the project or its community. Examples of
|
|
67
|
-
representing a project or community include using an official project e-mail
|
|
68
|
-
address, posting via an official social media account, or acting as an appointed
|
|
69
|
-
representative at an online or offline event. Representation of a project may be
|
|
70
|
-
further defined and clarified by project maintainers.
|
|
71
|
-
|
|
72
|
-
### Enforcement
|
|
73
|
-
|
|
74
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
75
|
-
reported by contacting the project team at support@clidey.com. All
|
|
76
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
77
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
78
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
79
|
-
Further details of specific enforcement policies may be posted separately.
|
|
80
|
-
|
|
81
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
82
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
83
|
-
members of the project's leadership.
|
|
84
|
-
|
|
85
|
-
### Attribution
|
|
86
|
-
|
|
87
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
88
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
|
89
|
-
|
|
90
|
-
[homepage]: http://contributor-covenant.org
|
|
91
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
package/SECURITY.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
Currently the latest version of Dory is supported. We advise you to upgrade whenever possible to receive the latest security updates.
|
|
6
|
-
|
|
7
|
-
## Reporting a Vulnerability
|
|
8
|
-
|
|
9
|
-
Please use the repo's Report A Vulnerability option to report.
|
|
10
|
-
|
|
11
|
-
The team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix, and may ask for additional information or guidance.
|
package/bin/dory.ts
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import { existsSync, rmSync, mkdirSync, cpSync, readFileSync, readdirSync } from 'fs';
|
|
5
|
-
import { resolve, dirname } from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
import { createServer } from 'http';
|
|
8
|
-
import sirv from 'sirv';
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = dirname(__filename);
|
|
12
|
-
|
|
13
|
-
// Get the root directory of the Dory package
|
|
14
|
-
const getDoryRoot = (): string => {
|
|
15
|
-
// In development: bin/dory.ts -> root is parent
|
|
16
|
-
// In production: bin/dist/dory.js -> root is parent of parent
|
|
17
|
-
const isDevelopment = __dirname.endsWith('bin');
|
|
18
|
-
return isDevelopment ? resolve(__dirname, '..') : resolve(__dirname, '..', '..');
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Get the user's current working directory
|
|
22
|
-
const getUserRoot = (): string => process.cwd();
|
|
23
|
-
|
|
24
|
-
interface DoryConfig {
|
|
25
|
-
name?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
navigation?: unknown;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const validateDoryConfig = (config: DoryConfig): void => {
|
|
32
|
-
if (!config || typeof config !== 'object') {
|
|
33
|
-
throw new Error('Configuration must be a valid object');
|
|
34
|
-
}
|
|
35
|
-
// Add more validation as needed
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const commands = {
|
|
39
|
-
build: () => {
|
|
40
|
-
console.log('🐟 Dory is ready to build your docs!');
|
|
41
|
-
|
|
42
|
-
const userRoot = getUserRoot();
|
|
43
|
-
const doryRoot = getDoryRoot();
|
|
44
|
-
const doryConfigPath = resolve(userRoot, 'dory.json');
|
|
45
|
-
const tempDocsDir = resolve(doryRoot, 'docs');
|
|
46
|
-
const docsBackupDir = resolve(doryRoot, '.docs-backup');
|
|
47
|
-
const doryDistDir = resolve(doryRoot, 'dist');
|
|
48
|
-
const userDistDir = resolve(userRoot, 'dist');
|
|
49
|
-
|
|
50
|
-
// Step 1: Validate prerequisites before making any changes
|
|
51
|
-
console.log('🔍 Validating project structure...');
|
|
52
|
-
|
|
53
|
-
if (!existsSync(doryConfigPath)) {
|
|
54
|
-
console.error('❌ dory.json not found in current directory');
|
|
55
|
-
console.error(` Looking for: ${doryConfigPath}`);
|
|
56
|
-
console.error(' Create a dory.json file to configure your documentation site');
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Read and validate dory.json
|
|
61
|
-
let config: DoryConfig;
|
|
62
|
-
try {
|
|
63
|
-
const configContent = readFileSync(doryConfigPath, 'utf8');
|
|
64
|
-
config = JSON.parse(configContent) as DoryConfig;
|
|
65
|
-
validateDoryConfig(config);
|
|
66
|
-
console.log(`📋 Building: ${config.name || 'Documentation'}`);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('❌ Failed to parse dory.json:');
|
|
69
|
-
if (error instanceof Error) {
|
|
70
|
-
console.error(` ${error.message}`);
|
|
71
|
-
}
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Check if pnpm is available
|
|
76
|
-
try {
|
|
77
|
-
execSync('pnpm --version', { stdio: 'ignore' });
|
|
78
|
-
} catch {
|
|
79
|
-
console.error('❌ pnpm is not installed');
|
|
80
|
-
console.error(' Install it with: npm install -g pnpm');
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Step 2: Backup existing docs directory if it exists
|
|
85
|
-
console.log('🧹 Preparing workspace...');
|
|
86
|
-
const docsExistedBefore = existsSync(tempDocsDir);
|
|
87
|
-
|
|
88
|
-
if (docsExistedBefore) {
|
|
89
|
-
console.log('💾 Backing up existing docs directory...');
|
|
90
|
-
if (existsSync(docsBackupDir)) {
|
|
91
|
-
rmSync(docsBackupDir, { recursive: true, force: true });
|
|
92
|
-
}
|
|
93
|
-
cpSync(tempDocsDir, docsBackupDir, { recursive: true, force: true });
|
|
94
|
-
rmSync(tempDocsDir, { recursive: true, force: true });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
// Step 3: Copy user files to temp docs directory
|
|
99
|
-
mkdirSync(tempDocsDir, { recursive: true });
|
|
100
|
-
|
|
101
|
-
console.log('📁 Gathering project files...');
|
|
102
|
-
|
|
103
|
-
// Define files/dirs to exclude
|
|
104
|
-
const excludeItems = new Set([
|
|
105
|
-
'node_modules',
|
|
106
|
-
'dist',
|
|
107
|
-
'.git',
|
|
108
|
-
'.github',
|
|
109
|
-
'docs',
|
|
110
|
-
'.DS_Store',
|
|
111
|
-
'.env',
|
|
112
|
-
'.env.local',
|
|
113
|
-
'pnpm-lock.yaml',
|
|
114
|
-
'package-lock.json',
|
|
115
|
-
'yarn.lock'
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
const items = readdirSync(userRoot);
|
|
119
|
-
let copiedCount = 0;
|
|
120
|
-
|
|
121
|
-
for (const item of items) {
|
|
122
|
-
if (excludeItems.has(item)) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const srcPath = resolve(userRoot, item);
|
|
127
|
-
const destPath = resolve(tempDocsDir, item);
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
cpSync(srcPath, destPath, { recursive: true, force: true });
|
|
131
|
-
copiedCount++;
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.warn(`⚠️ Could not copy ${item}: ${error instanceof Error ? error.message : 'unknown error'}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
console.log(`✅ Copied ${copiedCount} items`);
|
|
138
|
-
|
|
139
|
-
// Verify critical files exist
|
|
140
|
-
const doryJsonPath = resolve(tempDocsDir, 'dory.json');
|
|
141
|
-
if (!existsSync(doryJsonPath)) {
|
|
142
|
-
console.error('❌ dory.json was not copied to docs directory');
|
|
143
|
-
console.error(` Expected: ${doryJsonPath}`);
|
|
144
|
-
console.error(' This file is required for the build');
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Step 4: Run the build
|
|
149
|
-
console.log('⚡ Building documentation...');
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
execSync('pnpm run build', {
|
|
153
|
-
stdio: 'inherit',
|
|
154
|
-
cwd: doryRoot,
|
|
155
|
-
env: { ...process.env }
|
|
156
|
-
});
|
|
157
|
-
} catch (error) {
|
|
158
|
-
console.error('❌ Build failed');
|
|
159
|
-
console.error(' Check the error messages above for details');
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Step 5: Verify build output
|
|
164
|
-
console.log('🔍 Verifying build output...');
|
|
165
|
-
|
|
166
|
-
if (!existsSync(doryDistDir)) {
|
|
167
|
-
console.error('❌ Build completed but dist folder was not created');
|
|
168
|
-
console.error(` Expected: ${doryDistDir}`);
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const indexHtml = resolve(doryDistDir, 'index.html');
|
|
173
|
-
if (!existsSync(indexHtml)) {
|
|
174
|
-
console.error('❌ Build incomplete: index.html not found');
|
|
175
|
-
console.error(' The build may have failed silently');
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Check if dist has content
|
|
180
|
-
const distFiles = readdirSync(doryDistDir);
|
|
181
|
-
if (distFiles.length === 0) {
|
|
182
|
-
console.error('❌ Build completed but dist folder is empty');
|
|
183
|
-
process.exit(1);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
console.log('🎉 Build completed successfully!');
|
|
187
|
-
|
|
188
|
-
// Step 6: Copy dist to user's directory
|
|
189
|
-
console.log('📦 Copying build output...');
|
|
190
|
-
|
|
191
|
-
// Only copy if they're different directories
|
|
192
|
-
if (doryDistDir !== userDistDir) {
|
|
193
|
-
if (existsSync(userDistDir)) {
|
|
194
|
-
rmSync(userDistDir, { recursive: true, force: true });
|
|
195
|
-
}
|
|
196
|
-
cpSync(doryDistDir, userDistDir, { recursive: true, force: true });
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
console.log('✨ Documentation ready in dist/');
|
|
200
|
-
|
|
201
|
-
} finally {
|
|
202
|
-
// Step 7: Always clean up temp directories and restore backup
|
|
203
|
-
console.log('🧹 Cleaning up...');
|
|
204
|
-
|
|
205
|
-
try {
|
|
206
|
-
// Remove the temporary docs directory
|
|
207
|
-
if (existsSync(tempDocsDir)) {
|
|
208
|
-
rmSync(tempDocsDir, { recursive: true, force: true });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Restore the original docs directory if it existed before
|
|
212
|
-
if (docsExistedBefore && existsSync(docsBackupDir)) {
|
|
213
|
-
console.log('📦 Restoring original docs directory...');
|
|
214
|
-
cpSync(docsBackupDir, tempDocsDir, { recursive: true, force: true });
|
|
215
|
-
rmSync(docsBackupDir, { recursive: true, force: true });
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Only clean up doryDistDir if it's different from userDistDir
|
|
219
|
-
// (in production they're different, in dev they might be the same)
|
|
220
|
-
if (doryDistDir !== userDistDir && existsSync(doryDistDir)) {
|
|
221
|
-
rmSync(doryDistDir, { recursive: true, force: true });
|
|
222
|
-
}
|
|
223
|
-
} catch (error) {
|
|
224
|
-
console.warn('⚠️ Could not clean up temp directories');
|
|
225
|
-
// Try to restore backup even if cleanup failed
|
|
226
|
-
if (docsExistedBefore && existsSync(docsBackupDir)) {
|
|
227
|
-
console.log('🔄 Attempting to restore backup...');
|
|
228
|
-
try {
|
|
229
|
-
if (existsSync(tempDocsDir)) {
|
|
230
|
-
rmSync(tempDocsDir, { recursive: true, force: true });
|
|
231
|
-
}
|
|
232
|
-
cpSync(docsBackupDir, tempDocsDir, { recursive: true, force: true });
|
|
233
|
-
rmSync(docsBackupDir, { recursive: true, force: true });
|
|
234
|
-
} catch (restoreError) {
|
|
235
|
-
console.error('❌ Failed to restore docs backup!');
|
|
236
|
-
console.error(` Backup location: ${docsBackupDir}`);
|
|
237
|
-
console.error(' You may need to manually restore your docs directory');
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
console.log('✅ Done!');
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
preview: () => {
|
|
247
|
-
console.log('👀 Starting docs preview...');
|
|
248
|
-
|
|
249
|
-
const userRoot = getUserRoot();
|
|
250
|
-
const distDir = resolve(userRoot, 'dist');
|
|
251
|
-
let port = parseInt(process.env.PORT || '3000', 10);
|
|
252
|
-
|
|
253
|
-
// Validate dist folder exists
|
|
254
|
-
if (!existsSync(distDir)) {
|
|
255
|
-
console.error('❌ dist folder not found');
|
|
256
|
-
console.error(` Looking for: ${distDir}`);
|
|
257
|
-
console.error(' Run "dory build" first to generate the documentation');
|
|
258
|
-
process.exit(1);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Check if dist has content
|
|
262
|
-
const distFiles = readdirSync(distDir);
|
|
263
|
-
if (distFiles.length === 0) {
|
|
264
|
-
console.error('❌ dist folder is empty');
|
|
265
|
-
console.error(' Run "dory build" to generate documentation');
|
|
266
|
-
process.exit(1);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const serve = sirv(distDir, {
|
|
270
|
-
dev: false,
|
|
271
|
-
single: true,
|
|
272
|
-
etag: true,
|
|
273
|
-
gzip: true,
|
|
274
|
-
brotli: true,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
const server = createServer((req, res) => {
|
|
278
|
-
serve(req, res);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
const tryPort = (currentPort: number): void => {
|
|
282
|
-
server.listen(currentPort)
|
|
283
|
-
.on('listening', () => {
|
|
284
|
-
console.log(`🚀 Documentation live at http://localhost:${currentPort}`);
|
|
285
|
-
console.log(' Press Ctrl+C to stop the server');
|
|
286
|
-
})
|
|
287
|
-
.on('error', (err: NodeJS.ErrnoException) => {
|
|
288
|
-
if (err.code === 'EADDRINUSE') {
|
|
289
|
-
console.log(`⚠️ Port ${currentPort} in use, trying ${currentPort + 1}...`);
|
|
290
|
-
tryPort(currentPort + 1);
|
|
291
|
-
} else {
|
|
292
|
-
console.error('❌ Failed to start server:', err.message);
|
|
293
|
-
process.exit(1);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
tryPort(port);
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
'verify:content': async () => {
|
|
302
|
-
const args = process.argv.slice(3);
|
|
303
|
-
let content = '';
|
|
304
|
-
let fileName = '';
|
|
305
|
-
|
|
306
|
-
// Parse arguments
|
|
307
|
-
for (let i = 0; i < args.length; i++) {
|
|
308
|
-
if (args[i] === '--content' && i + 1 < args.length) {
|
|
309
|
-
content = args[i + 1];
|
|
310
|
-
break;
|
|
311
|
-
} else if (args[i] === '--file' && i + 1 < args.length) {
|
|
312
|
-
const filePath = resolve(getUserRoot(), args[i + 1]);
|
|
313
|
-
if (!existsSync(filePath)) {
|
|
314
|
-
console.error(`❌ File not found: ${filePath}`);
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
content = readFileSync(filePath, 'utf8');
|
|
318
|
-
fileName = filePath;
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (!content) {
|
|
324
|
-
console.error('❌ --content or --file argument is required');
|
|
325
|
-
console.log('Usage:');
|
|
326
|
-
console.log(' dory verify:content --content "<mdx-content>"');
|
|
327
|
-
console.log(' dory verify:content --file <path-to-mdx-file>');
|
|
328
|
-
process.exit(1);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
try {
|
|
332
|
-
const doryRoot = getDoryRoot();
|
|
333
|
-
const processorPath = resolve(doryRoot, 'src', 'mdx', 'processor.ts');
|
|
334
|
-
|
|
335
|
-
if (!existsSync(processorPath)) {
|
|
336
|
-
console.error('❌ MDX processor not found');
|
|
337
|
-
console.error(' This feature requires Dory source files');
|
|
338
|
-
process.exit(1);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Use the shared MDX processor that matches the main build exactly
|
|
342
|
-
const { verifyMdxContent } = await import(processorPath);
|
|
343
|
-
const result = await verifyMdxContent(content, fileName);
|
|
344
|
-
|
|
345
|
-
if (!result.valid) {
|
|
346
|
-
throw result.error;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Silent success - no output means no errors
|
|
350
|
-
|
|
351
|
-
} catch (error) {
|
|
352
|
-
console.error('❌ MDX compilation failed:');
|
|
353
|
-
if (error instanceof Error) {
|
|
354
|
-
console.error(` ${error.message}`);
|
|
355
|
-
|
|
356
|
-
// Provide more detailed error information if available
|
|
357
|
-
const errorWithPosition = error as Error & { line?: number; column?: number; source?: string };
|
|
358
|
-
if (errorWithPosition.line !== undefined && errorWithPosition.column !== undefined) {
|
|
359
|
-
console.error(` at line ${errorWithPosition.line}, column ${errorWithPosition.column}`);
|
|
360
|
-
}
|
|
361
|
-
if (errorWithPosition.source) {
|
|
362
|
-
console.error(' Source:', errorWithPosition.source);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
process.exit(1);
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
|
|
370
|
-
help: () => {
|
|
371
|
-
console.log(`
|
|
372
|
-
🐟 Dory CLI - Documentation Builder
|
|
373
|
-
|
|
374
|
-
Usage:
|
|
375
|
-
dory <command> [options]
|
|
376
|
-
|
|
377
|
-
Commands:
|
|
378
|
-
build Build your documentation site
|
|
379
|
-
Requirements: dory.json in current directory
|
|
380
|
-
Output: dist/ folder with static site
|
|
381
|
-
|
|
382
|
-
preview Preview built documentation
|
|
383
|
-
Requirements: dist/ folder (run build first)
|
|
384
|
-
Starts local server on port 3000
|
|
385
|
-
|
|
386
|
-
verify:content Verify MDX content compilation
|
|
387
|
-
Options: --content "<mdx>" or --file <path>
|
|
388
|
-
Silent on success, shows errors on failure
|
|
389
|
-
|
|
390
|
-
help Show this help message
|
|
391
|
-
|
|
392
|
-
Examples:
|
|
393
|
-
dory build
|
|
394
|
-
dory preview
|
|
395
|
-
dory verify:content --content "# Hello World"
|
|
396
|
-
dory verify:content --file docs/intro.mdx
|
|
397
|
-
|
|
398
|
-
For more information, visit: https://github.com/clidey/dory
|
|
399
|
-
`);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
type CommandName = keyof typeof commands;
|
|
404
|
-
|
|
405
|
-
// Parse command line arguments
|
|
406
|
-
const command = process.argv[2];
|
|
407
|
-
|
|
408
|
-
async function runCommand(): Promise<void> {
|
|
409
|
-
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
410
|
-
commands.help();
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (command in commands) {
|
|
415
|
-
await commands[command as CommandName]();
|
|
416
|
-
} else {
|
|
417
|
-
console.error(`❌ Unknown command: ${command}`);
|
|
418
|
-
console.log(' Run "dory help" for available commands');
|
|
419
|
-
process.exit(1);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
runCommand().catch((error: unknown) => {
|
|
424
|
-
console.error('❌ Command failed');
|
|
425
|
-
if (error instanceof Error) {
|
|
426
|
-
console.error(` ${error.message}`);
|
|
427
|
-
if (error.stack && process.env.DEBUG) {
|
|
428
|
-
console.error('\nStack trace:');
|
|
429
|
-
console.error(error.stack);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
process.exit(1);
|
|
433
|
-
});
|