Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add sync-docs to sync nextui docs #66

Merged
merged 37 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
86f4f4c
feat: all up to data do not show select
winchesHe May 1, 2024
eaa54d9
feat: init cache
winchesHe May 1, 2024
7ce9296
feat: add fetch version log
winchesHe May 1, 2024
3838899
feat: add cache use in getLatestVersion
winchesHe May 1, 2024
afbb819
feat: add cache script
winchesHe May 1, 2024
a924236
fix: issues
winchesHe May 9, 2024
2df40cc
fix: ci
winchesHe May 9, 2024
270f652
feat: optimize exec speed and exec loading state
winchesHe May 10, 2024
658bd58
Merge branch 'main' into feature-upgrade-all-up-to-data
winchesHe May 10, 2024
569ea56
fix: add main pkg when upgrade (#62)
winchesHe May 16, 2024
9f1891a
feat: add sort disabled pkg when select compoents (#63)
winchesHe May 16, 2024
fe13db9
feat(doctor): add peerDependencies check and less color (#64)
winchesHe May 19, 2024
e7778d1
docs: update README (#65)
winchesHe May 19, 2024
eeb75a8
docs: update README.md
winchesHe May 19, 2024
7a70959
ci: sync docs
winchesHe May 19, 2024
a18f73e
docs: test
winchesHe May 19, 2024
ce1c1cc
ci: test
winchesHe May 23, 2024
5ce93e5
ci: update
winchesHe May 23, 2024
96e9ec1
ci: update
winchesHe May 23, 2024
f0dac6e
ci: update
winchesHe May 23, 2024
0d2341b
ci: update
winchesHe May 23, 2024
58834a5
ci: update
winchesHe May 23, 2024
4301b29
ci: update
winchesHe May 23, 2024
15d2e24
ci: update
winchesHe May 23, 2024
4edb8c2
ci: update
winchesHe May 23, 2024
8f3bf55
ci: update
winchesHe May 23, 2024
9cb9a19
feat: add api-references update
winchesHe May 24, 2024
af43e08
ci: init sync
winchesHe May 24, 2024
899fb71
docs: update
winchesHe May 24, 2024
be06089
ci: update repo name
winchesHe May 24, 2024
a171f16
ci: test
winchesHe May 24, 2024
a7c997d
ci: test
winchesHe May 25, 2024
da114a7
ci: update
winchesHe May 25, 2024
5a9c3ad
Merge branch 'main' into docs-sync
winchesHe May 27, 2024
8b37335
Merge branch 'main' into docs-sync
winchesHe Jun 2, 2024
f405f01
fix: issues
winchesHe Jun 2, 2024
4687b31
fix: init cache error
winchesHe Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/sync.yml
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 'winchesHe'
git config --global user.email '329487092@qq.com'

winchesHe marked this conversation as resolved.
Show resolved Hide resolved
- 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.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ NextUI CLI v0.2.1
◇ Template created successfully!
◇ Next steps ───────────────────
│ cd next-app-template
│ npm install
├────────────────────────────────
◇ Next steps ───────╮
│ │
│ cd my-nextui-app
│ npm install │
│ │
├────────────────────╯
└ 🚀 Get started with npm run dev
```
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"link:remove": "pnpm uninstall --global nextui-cli",
"build": "tsup",
"update:components": "tsx src/scripts/update/update-components.ts",
"sync:docs": "tsx src/scripts/sync/sync.ts",
"clean:cache": "tsx src/scripts/cache/clean.ts",
"lint": "eslint . --max-warnings=0",
"lint:fix": "eslint . -max-warnings=0 --fix",
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ nextui.hook('preAction', async (command) => {
// Init cache
initCache(noCache);

// Init cache
initCache();
winchesHe marked this conversation as resolved.
Show resolved Hide resolved

if (args && commandList.includes(args as CommandName)) {
// Before run the command init the components.json
const nextUIComponents = (await getComponents()).components;
Expand Down
36 changes: 36 additions & 0 deletions src/scripts/sync/index.ts
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');
}
3 changes: 3 additions & 0 deletions src/scripts/sync/sync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {syncDocs} from '.';

syncDocs();
Loading