@clidey/dory 0.29.0 → 0.31.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 +108 -29
- package/bin/dist/dory.js.map +1 -1
- package/package.json +20 -4
- package/src/components/hooks.tsx +8 -0
- package/src/components/search.tsx +17 -4
- package/src/embed/loader.ts +200 -0
- package/src/embed/types.ts +54 -0
- package/src/embed/widget-iframe.ts +302 -0
- package/src/plugins/html-files-middleware.ts +108 -0
- package/src/sdk/index.ts +89 -0
- package/src/sdk/react.tsx +139 -0
- package/src/sdk/vue.ts +107 -0
- package/src/types/config.ts +42 -0
- package/src/ui/header.tsx +6 -1
- package/src/ui/layout.tsx +16 -5
- package/src/ui/mobile-navigation.tsx +11 -3
- package/src/ui/table-of-content.tsx +2 -1
- package/tsconfig.bin.json +1 -0
- package/vite.config.embed-loader.ts +28 -0
- package/vite.config.embed-widget.ts +31 -0
- package/vite.config.ts +2 -0
- 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/scripts/generate-frontmatter-json.js +0 -154
- package/scripts/generate-llm-txt.js +0 -115
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
-
and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
-
overall community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
-
advances of any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email
|
|
35
|
-
address, without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official e-mail address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
support@clidey.com.
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series
|
|
86
|
-
of actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or
|
|
93
|
-
permanent ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
-
the community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.0, available at
|
|
119
|
-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
-
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
-
|
|
124
|
-
[homepage]: https://www.contributor-covenant.org
|
|
125
|
-
|
|
126
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
-
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
-
https://www.contributor-covenant.org/translations.
|
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
|
-
});
|