-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Initial commit
0 parents
commit 120d454
Showing
199 changed files
with
46,161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Reset API Docs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "openapi/*.yml" | ||
|
||
jobs: | ||
reset-api-docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install Dependencies | ||
run: npm install docusaurus | ||
|
||
- name: Clean and Generate API Docs | ||
run: npx docusaurus clean-api-docs all && npx docusaurus gen-api-docs all | ||
|
||
- name: Add Components to API | ||
run: node apiFiles.config.js | ||
|
||
- name: Configure Git | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "actions@github.com" | ||
- name: Commit changes | ||
run: | | ||
git add . | ||
git commit -m "Update API Reference based on OpenAPI files" | ||
- name: Push changes | ||
uses: ad-m/github-push-action@v0.6.0 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Rewrite Custom Configs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "bin/**" | ||
- "changelog/**" | ||
- "docs/**" | ||
- "i18n/**" | ||
- "openAPI/**" | ||
- "static/**" | ||
|
||
jobs: | ||
reset-custom-configs: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # Ensure the token has write permissions | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches and tags | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Run styles config script | ||
run: node writedocs/styles.config.js | ||
|
||
- name: Run Home config script | ||
run: node home.config.js | ||
|
||
- name: Configure Git | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "actions@github.com" | ||
- name: Commit changes | ||
run: | | ||
git add . | ||
if git diff-index --quiet HEAD --; then | ||
echo "No changes to commit. Exiting." | ||
exit 0 | ||
fi | ||
git commit -m "Updates based on changes in config.json" | ||
- name: Pull and Push Changes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git pull --rebase origin main | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# WriteDocs CLI | ||
|
||
**WriteDocs CLI** is a command-line tool designed to help you manage and run your WriteDocs development environment. It provides easy commands to start your development server, handle API integrations, and more. | ||
|
||
## Features | ||
|
||
- **Start the WriteDocs development server** with ease. | ||
- **Run API integration tasks** for your documentation projects. | ||
- **User-friendly command-line interface** with helpful prompts and retry logic for common issues, like port conflicts. | ||
|
||
## Installation | ||
|
||
To install WriteDocs CLI globally, run: | ||
|
||
```bash | ||
npm install -g writedocs | ||
``` | ||
|
||
This command installs the CLI tool globally on your system, making the `writedocs` command available from anywhere in your terminal. | ||
|
||
## Usage | ||
|
||
After installation, you can use the `writedocs` command followed by the appropriate sub-command to perform various tasks. | ||
|
||
### Available Commands | ||
|
||
- **`writedocs dev`** | ||
Start the WriteDocs development server. This command handles port conflicts and retries automatically. | ||
|
||
```bash | ||
writedocs dev | ||
``` | ||
|
||
- **`writedocs api`** | ||
Generates endpoint markdown pages from your OpenAPI Specification files. | ||
|
||
```bash | ||
writedocs api | ||
``` | ||
|
||
- **`writedocs help`** | ||
Display help information, showing available commands and their descriptions. | ||
|
||
```bash | ||
writedocs help | ||
``` | ||
|
||
### Example | ||
|
||
Starting the development server: | ||
|
||
```bash | ||
writedocs dev | ||
``` | ||
|
||
If port 3000 is in use, the CLI will automatically try the next available port (e.g., 3001, 3002) until it finds an open port. | ||
|
||
## Troubleshooting | ||
|
||
### Port Conflicts | ||
|
||
If you encounter issues with port conflicts (e.g., "Port 3000 is already in use"), the CLI will automatically try the next available port. If it exceeds the maximum number of retries, it will display an error message. | ||
|
||
### Exceeding Retries | ||
|
||
If the maximum number of retries is exceeded, check your system for conflicting services or manually specify a port by adjusting your environment variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const COMPONENTS_IMPORT = 'import { Accordion, AccordionGroup, Callout, Card, CardList, Image, Video, Tabs } from "@site/src/components";'; | ||
|
||
// Function to recursively get all files in a directory | ||
function getAllFiles(dirPath, arrayOfFiles) { | ||
const files = fs.readdirSync(dirPath); | ||
|
||
arrayOfFiles = arrayOfFiles || []; | ||
|
||
files.forEach(function (file) { | ||
if (fs.statSync(path.join(dirPath, file)).isDirectory()) { | ||
arrayOfFiles = getAllFiles(path.join(dirPath, file), arrayOfFiles); | ||
} else if (file.endsWith('.mdx')) { | ||
arrayOfFiles.push(path.join(dirPath, file)); | ||
} | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
// Function to extract components from the index.js file | ||
function extractComponents(filePath) { | ||
const fileContent = fs.readFileSync(filePath, 'utf-8'); | ||
const exportRegex = /export\s*\{\s*([\s\S]*?)\s*\};/; | ||
const match = fileContent.match(exportRegex); | ||
|
||
if (match && match[1]) { | ||
const filteredComponents = match[1] | ||
.split(',') | ||
.filter((component) => component.trim() !== 'TabItem'); | ||
|
||
const components = filteredComponents | ||
.map((component) => component.trim()) | ||
.join(', '); | ||
|
||
// Construct the import string | ||
const importString = `import { ${components} } from "@site/src/components";`; | ||
|
||
return importString; | ||
} else { | ||
return COMPONENTS_IMPORT; | ||
} | ||
} | ||
|
||
// Function to edit the files | ||
function editFiles(files, importString) { | ||
files.forEach(file => { | ||
let fileContent = fs.readFileSync(file, 'utf-8'); | ||
|
||
fileContent = fileContent.replace(/</g, '<').replace(/>/g, '>'); | ||
|
||
// Split file content into lines | ||
const parts = fileContent.split('---'); | ||
if (parts.length >= 3) { | ||
const metadata = parts[1]; | ||
const body = parts.slice(2).join('---'); | ||
|
||
const newContent = `---${metadata}---\n\n${importString}${body}`; | ||
fs.writeFileSync(file, newContent, 'utf-8'); | ||
} | ||
}); | ||
} | ||
|
||
function runAddContent(dirPath) { | ||
const componentsFilePath = path.join(__dirname, 'src/components/index.js'); | ||
// Get all mdx files in the directory | ||
const files = getAllFiles(dirPath); | ||
|
||
// Generate the import string | ||
const importString = extractComponents(componentsFilePath); | ||
|
||
// Edit each file by adding the import string after the metadata | ||
editFiles(files, importString); | ||
} | ||
|
||
|
||
function main() { | ||
// const { languages } = getJson('./config.json'); | ||
const paths = [path.join(__dirname, 'docs/reference')]; | ||
// if (languages && languages.length > 1) { | ||
// languages.slice(1).forEach((lang) => { | ||
// paths.push(path.join(__dirname,`i18n/${lang}/docusaurus-plugin-content-docs/current/reference`)); | ||
// }); | ||
// } | ||
paths.forEach((path) => { | ||
runAddContent(path); | ||
}) | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset'), "@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## CLI | ||
|
||
To deprecate multiple versions at once: | ||
|
||
```powershell | ||
for ($version = 44; $version -le XX; $version++) { | ||
npm deprecate writedocs@1.1.$version "Deprecated version" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { exec } = require("child_process"); | ||
const util = require("util"); | ||
|
||
const execAsync = util.promisify(exec); | ||
|
||
try { | ||
execAsync('node plan.config.js', { stdio: 'inherit' }); | ||
execAsync('node home.config.js', { stdio: 'inherit' }); | ||
execAsync('node ./writedocs/styles.config.js', { stdio: 'inherit' }); | ||
execAsync('node ./src/utils/parseConfig.js', { stdio: 'inherit' }); | ||
execAsync('node sidebar.config.js', { stdio: 'inherit' }); | ||
execAsync('node transpiler.config.js', { stdio: 'inherit' }); | ||
console.log('Prebuild steps completed successfully.'); | ||
} catch (error) { | ||
console.error('Error during precli steps:', error); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const sidebarError = (output) => { | ||
let errorOutput = output; | ||
errorOutput = errorOutput.replace(/docusaurus/gi, 'WriteDocs'); | ||
|
||
// Replace specific phrases with new ones | ||
errorOutput = errorOutput.replace( | ||
/\[ERROR\] Error: Invalid sidebar file at "sidebars\.js"\./gi, | ||
'[SIDEBAR_ERROR] Invalid sidebar configuration in "config.json".' | ||
); | ||
errorOutput = errorOutput.replace( | ||
/These sidebar document ids do not exist:/gi, | ||
'The following files could not be found inside docs folder:' | ||
); | ||
errorOutput = errorOutput.replace( | ||
/Available document ids are:/gi, | ||
'Available files are:' | ||
); | ||
|
||
return errorOutput; | ||
} | ||
|
||
// Keep only the first phrase that ends with .md or .mdx and remove the rest of the content | ||
const extractMdxError = (output) => { | ||
const errorMatch = output.match(/Error:.*\nCause:.*\n/); | ||
|
||
if (errorMatch) { | ||
return errorMatch[0].replace( | ||
/Error/gi, | ||
'[MDX_ERROR]' | ||
); | ||
} | ||
|
||
return output; | ||
} | ||
|
||
const suppressWebpackCacheMessages = (output) => { | ||
return output | ||
.split('\n') | ||
.filter(line => | ||
!line.includes('[webpack.cache.PackFileCacheStrategy]') && | ||
!line.includes('while serializing webpack/lib/cache/PackFileCacheStrategy') | ||
) | ||
.join('\n'); | ||
}; | ||
|
||
// Remove all "at ... file" lines from the error stack trace | ||
const removeAtFileLines = (output) => { | ||
return output.split('\n').filter(line => !line.trim().startsWith('at')).join('\n'); | ||
} | ||
|
||
const replaceErrorOutput = (output) => { | ||
let errorOutput = sidebarError(output); | ||
|
||
errorOutput = extractMdxError(errorOutput); | ||
errorOutput = removeAtFileLines(errorOutput); | ||
errorOutput = suppressWebpackCacheMessages(errorOutput); | ||
return errorOutput; | ||
} | ||
|
||
module.exports = { replaceErrorOutput } |
Oops, something went wrong.