-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add sync-docs to sync nextui docs (#66)
* feat: all up to data do not show select * feat: init cache * feat: add fetch version log * feat: add cache use in getLatestVersion * feat: add cache script * fix: issues * fix: ci * feat: optimize exec speed and exec loading state * fix: add main pkg when upgrade (#62) * feat: add sort disabled pkg when select compoents (#63) * feat: add sort disabled pkg when select compoents * feat: optimize display * feat(doctor): add peerDependencies check and less color (#64) * feat: optimize log and less color * feat(doctor): add peerDependencies check * docs: update README (#65) * feat: optimize log and less color * feat(doctor): add peerDependencies check * docs: update README * docs: update README.md * ci: sync docs * docs: test * ci: test * ci: update * ci: update * ci: update * ci: update * ci: update * ci: update * ci: update * ci: update * ci: update * feat: add api-references update * ci: init sync * docs: update * ci: update repo name * ci: test * ci: test * ci: update * fix: issues * fix: init cache error
- Loading branch information
Showing
6 changed files
with
108 additions
and
7 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,61 @@ | ||
name: sync docs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- README.md | ||
|
||
jobs: | ||
sync-docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
check-latest: true | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name 'GitHub Action' | ||
git config --global user.email 'action@github.com' | ||
- name: Clone nextui repository | ||
run: | | ||
git clone https://github.com/nextui-org/nextui nextui --depth 1 | ||
- name: Run docs sync script | ||
run: | | ||
pnpm sync:docs | ||
- name: Get version from package.json | ||
id: get_version | ||
run: | | ||
VERSION=$(jq -r '.version' package.json) | ||
echo "::set-output name=version::$VERSION" | ||
- name: Commit changes to nextui repository | ||
run: | | ||
cd nextui | ||
git add . | ||
git commit -m "docs: sync api from nextui-cli v${{ steps.get_version.outputs.version }}" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
path: nextui | ||
branch: sync-docs-${{ steps.get_version.outputs.version }} | ||
title: "docs: sync api from nextui-cli v${{ steps.get_version.outputs.version }}" | ||
body: Sync api from nextui-cli. |
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
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
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
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,36 @@ | ||
import {readFileSync, writeFileSync} from 'node:fs'; | ||
|
||
import {resolver} from 'src/constants/path'; | ||
|
||
export function syncDocs() { | ||
const docs = readFileSync(resolver('README.md'), 'utf-8'); | ||
const matchDocs = docs.match(/(?<=Usage: nextui \[command]\n\n)[\W\w]+(?=## Documentation)/)?.[0]; | ||
|
||
const targetPath = resolver('nextui/apps/docs/content/docs/api-references/cli-api.mdx'); | ||
const targetDocs = readFileSync(targetPath, 'utf-8'); | ||
const replaceTargetDocs = targetDocs.replace(/(?<=Usage: nextui \[command])[\W\w]+/, ''); | ||
let writeDocs = `${replaceTargetDocs}\n\n${matchDocs?.replace(/\n$/, '')}`; | ||
|
||
writeDocs = writeDocs.replaceAll(/```bash/g, '```codeBlock bash'); | ||
|
||
writeFileSync(targetPath, writeDocs, 'utf-8'); | ||
|
||
syncApiRoutes(); | ||
} | ||
|
||
function syncApiRoutes() { | ||
const targetPath = resolver('nextui/apps/docs/config/routes.json'); | ||
const targetDocs = JSON.parse(readFileSync(targetPath, 'utf-8')); | ||
|
||
targetDocs.routes.forEach((route) => { | ||
if (route.key === 'api-references') { | ||
route.routes.forEach((apiRoute) => { | ||
if (apiRoute.key === 'cli-api') { | ||
apiRoute.updated = true; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
writeFileSync(targetPath, JSON.stringify(targetDocs, null, 2), 'utf-8'); | ||
} |
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 @@ | ||
import {syncDocs} from '.'; | ||
|
||
syncDocs(); |