Skip to content

Commit 7cbe820

Browse files
committed
Fix docs lint issues and reuse setup action in release workflow
1 parent 8aa8903 commit 7cbe820

File tree

10 files changed

+106
-92
lines changed

10 files changed

+106
-92
lines changed

.github/actions/setup-node-pnpm/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
description: pnpm version
1111
required: false
1212
default: "10.33.0"
13+
registry-url:
14+
description: Optional npm registry URL to configure for npm publish/auth steps
15+
required: false
16+
default: ""
1317
install:
1418
description: Whether to run pnpm install
1519
required: false
@@ -29,6 +33,7 @@ runs:
2933
node-version: ${{ inputs.node-version }}
3034
cache: pnpm
3135
cache-dependency-path: pnpm-lock.yaml
36+
registry-url: ${{ inputs.registry-url }}
3237

3338
- name: Install workspace dependencies
3439
if: inputs.install == 'true'

.github/workflows/release-cli.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Release Packages
22

33
env:
4-
NODE_VERSION: "25.6.1"
54
NPM_REGISTRY_URL: https://registry.npmjs.org/
65
NPM_PUBLISH_VERIFY_ATTEMPTS: "90"
76
NPM_PUBLISH_VERIFY_DELAY_SECONDS: "10"
@@ -57,9 +56,9 @@ jobs:
5756
version: ${{ steps.check.outputs.version }}
5857
steps:
5958
- uses: actions/checkout@v6
60-
- uses: actions/setup-node@v6
59+
- uses: ./.github/actions/setup-node-pnpm
6160
with:
62-
node-version: ${{ env.NODE_VERSION }}
61+
install: "false"
6362

6463
- name: Check if should publish
6564
id: check
@@ -240,10 +239,6 @@ jobs:
240239
- uses: ./.github/actions/setup-node-pnpm
241240
with:
242241
install: "true"
243-
- name: Setup npm registry
244-
uses: actions/setup-node@v6
245-
with:
246-
node-version: ${{ env.NODE_VERSION }}
247242
registry-url: https://registry.npmjs.org/
248243
- name: Preflight npm auth
249244
shell: bash
@@ -464,10 +459,7 @@ jobs:
464459
steps:
465460
- uses: actions/checkout@v6
466461
- uses: ./.github/actions/setup-node-pnpm
467-
- name: Setup npm registry
468-
uses: actions/setup-node@v6
469462
with:
470-
node-version: ${{ env.NODE_VERSION }}
471463
registry-url: https://registry.npmjs.org/
472464
- name: Preflight npm auth
473465
shell: bash
@@ -590,10 +582,7 @@ jobs:
590582
steps:
591583
- uses: actions/checkout@v6
592584
- uses: ./.github/actions/setup-node-pnpm
593-
- name: Setup npm registry
594-
uses: actions/setup-node@v6
595585
with:
596-
node-version: ${{ env.NODE_VERSION }}
597586
registry-url: https://registry.npmjs.org/
598587
- name: Preflight npm auth
599588
shell: bash

doc/app/docs/[[...mdxPath]]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default async function DocsLayout({
1616
const firstSegment = params.mdxPath?.[0]
1717
const section = firstSegment != null && isDocSectionName(firstSegment)
1818
? firstSegment
19-
: undefined
19+
: void 0
2020
const pageMap = await getPageMap(section ? `/docs/${section}` : '/docs')
2121

2222
return (

doc/app/layout.tsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
import type { Metadata } from "next";
2-
import { Inter, JetBrains_Mono } from "next/font/google";
3-
import { getSiteUrl, siteConfig } from "../lib/site";
4-
import "nextra-theme-docs/style.css";
5-
import "./globals.scss";
1+
import type {Metadata} from 'next'
2+
import {Inter, JetBrains_Mono} from 'next/font/google'
3+
import {getSiteUrl, siteConfig} from '../lib/site'
4+
import 'nextra-theme-docs/style.css'
5+
import './globals.scss'
66

77
const sans = Inter({
8-
variable: "--font-sans",
8+
variable: '--font-sans',
99
preload: true,
10-
subsets: ["latin"],
11-
});
10+
subsets: ['latin']
11+
})
1212

1313
const mono = JetBrains_Mono({
14-
variable: "--font-mono",
15-
subsets: ["latin"],
16-
preload: true,
17-
});
14+
variable: '--font-mono',
15+
subsets: ['latin'],
16+
preload: true
17+
})
1818

1919
export const metadata: Metadata = {
2020
metadataBase: getSiteUrl(),
2121
title: {
2222
default: siteConfig.title,
23-
template: `%s | ${siteConfig.productName}`,
23+
template: `%s | ${siteConfig.productName}`
2424
},
2525
description: siteConfig.description,
2626
applicationName: siteConfig.shortName,
2727
alternates: {
28-
canonical: "/",
28+
canonical: '/'
2929
},
30-
category: "developer tools",
31-
manifest: "/manifest.webmanifest",
30+
category: 'developer tools',
31+
manifest: '/manifest.webmanifest',
3232
openGraph: {
33-
type: "website",
34-
url: "/",
33+
type: 'website',
34+
url: '/',
3535
title: siteConfig.title,
3636
description: siteConfig.description,
3737
siteName: siteConfig.title,
38-
locale: "zh_CN",
38+
locale: 'zh_CN'
3939
},
4040
twitter: {
41-
card: "summary_large_image",
41+
card: 'summary_large_image',
4242
title: siteConfig.title,
43-
description: siteConfig.description,
44-
},
45-
};
43+
description: siteConfig.description
44+
}
45+
}
4646

47-
export default function RootLayout({ children }: { readonly children: React.ReactNode }) {
47+
export default function RootLayout({children}: {readonly children: React.ReactNode}) {
4848
return (
49-
<html lang="zh-CN" className="dark" style={{ colorScheme: "dark", backgroundColor: "#0b0c10" }} suppressHydrationWarning>
49+
<html lang="zh-CN" className="dark" style={{colorScheme: 'dark', backgroundColor: '#0b0c10'}} suppressHydrationWarning>
5050
<body className={`${sans.variable} ${mono.variable}`} suppressHydrationWarning>
5151
{children}
5252
</body>
5353
</html>
54-
);
54+
)
5555
}

doc/components/docs-callout.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function getMeaningfulChildren(children: ReactNode): ReactNode[] {
4444
function stripMarkerFromChildren(children: ReactNode): ReactNode {
4545
const items = getMeaningfulChildren(children)
4646

47-
return items.map((item, index) => {
47+
return items.map(async (item, index) => {
4848
if (index !== 0) {
4949
return item
5050
}
@@ -74,14 +74,10 @@ function stripMarkerFromChildren(children: ReactNode): ReactNode {
7474
function resolveCalloutTone(children: ReactNode): CalloutTone | null {
7575
const firstChild = getMeaningfulChildren(children)[0]
7676
const firstText = extractText(firstChild).trimStart()
77-
const matched = firstText.match(CALLOUT_PATTERN)?.[1]?.toLowerCase()
77+
const matched = CALLOUT_PATTERN.exec(firstText)?.[1]?.toLowerCase()
7878

7979
if (
80-
matched === 'note'
81-
|| matched === 'tip'
82-
|| matched === 'important'
83-
|| matched === 'warning'
84-
|| matched === 'caution'
80+
new Set(['note', 'tip', 'important', 'warning', 'caution']).has(matched)
8581
) {
8682
return matched
8783
}

doc/components/home-contributors.tsx

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {siteConfig} from '../lib/site'
21
import {execFileSync} from 'node:child_process'
32
import path from 'node:path'
3+
import process from 'node:process'
4+
import {siteConfig} from '../lib/site'
45

56
interface GitHubContributor {
67
readonly avatar_url: string
@@ -44,10 +45,12 @@ const CONTRIBUTORS_PER_PAGE = 100
4445
const MAX_CONTRIBUTOR_PAGES = 10
4546
const CONTRIBUTORS_REVALIDATE_SECONDS = 60 * 60 * 12
4647
const REPO_ROOT = path.resolve(process.cwd(), '..')
48+
const LEADING_SLASHES_PATTERN = /^\/+/
49+
const CO_AUTHOR_PREFIX = 'co-authored-by:'
4750

4851
function getRepoCoordinates(repoUrl: string) {
4952
const url = new URL(repoUrl)
50-
const [owner, repo] = url.pathname.replace(/^\/+/, '').split('/')
53+
const [owner, repo] = url.pathname.replace(LEADING_SLASHES_PATTERN, '').split('/')
5154

5255
if (!owner || !repo) {
5356
throw new Error(`Invalid GitHub repository URL: ${repoUrl}`)
@@ -58,10 +61,13 @@ function getRepoCoordinates(repoUrl: string) {
5861

5962
function getGitHubHeaders() {
6063
const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
64+
const authorization = token != null && token !== ''
65+
? {Authorization: `Bearer ${token}`}
66+
: {}
6167

6268
return {
6369
Accept: 'application/vnd.github+json',
64-
...(token ? {Authorization: `Bearer ${token}`} : {})
70+
...authorization
6571
}
6672
}
6773

@@ -117,20 +123,36 @@ async function fetchGitHubUser(login: string): Promise<ResolvedGitHubUser | null
117123
}
118124

119125
function parseCoAuthors(message: string) {
120-
const matches = message.matchAll(/^Co-authored-by:\s+(.+?)\s+<(.+?)>$/gim)
121126
const coAuthors: CoAuthorIdentity[] = []
122127

123-
for (const match of matches) {
124-
const [, name, email] = match
128+
for (const rawLine of message.split('\n')) {
129+
const line = rawLine.trim()
125130

126-
if (!name || !email) {
131+
if (!line.toLowerCase().startsWith(CO_AUTHOR_PREFIX)) {
132+
continue
133+
}
134+
135+
const footer = line.slice(CO_AUTHOR_PREFIX.length).trim()
136+
const openAngleBracketIndex = footer.lastIndexOf('<')
137+
const closeAngleBracketIndex = footer.endsWith('>')
138+
? footer.length - 1
139+
: -1
140+
141+
if (openAngleBracketIndex <= 0 || closeAngleBracketIndex <= openAngleBracketIndex) {
142+
continue
143+
}
144+
145+
const name = footer.slice(0, openAngleBracketIndex).trim()
146+
const email = footer.slice(openAngleBracketIndex + 1, closeAngleBracketIndex).trim()
147+
148+
if (name === '' || email === '') {
127149
continue
128150
}
129151

130152
coAuthors.push({
131153
count: 1,
132-
email: email.trim(),
133-
name: name.trim()
154+
email,
155+
name
134156
})
135157
}
136158

@@ -167,7 +189,7 @@ function getCoAuthorSearchQueries(identity: CoAuthorIdentity) {
167189

168190
queries.push(`${identity.name} in:login`)
169191

170-
return Array.from(new Set(queries))
192+
return [...new Set(queries)]
171193
}
172194

173195
function getKnownCoAuthorProfile(identity: CoAuthorIdentity): KnownCoAuthorProfile | null {
@@ -252,7 +274,7 @@ async function getCoAuthors() {
252274
}
253275
}
254276

255-
return Array.from(coAuthors.values()).sort((left, right) => right.count - left.count)
277+
return [...coAuthors.values()].sort((left, right) => right.count - left.count)
256278
}
257279

258280
async function resolveCoAuthor(identity: CoAuthorIdentity) {
@@ -355,34 +377,33 @@ async function getContributorCards() {
355377
cards.set(key, value)
356378
}
357379

358-
return Array.from(cards.values())
359-
.map(contributor => {
360-
if (contributor.htmlUrl === 'https://github.com/cursoragent') {
361-
return {
362-
...contributor,
363-
kind: 'agent' as const,
364-
label: 'cursoragent'
365-
}
380+
return Array.from(cards.values(), contributor => {
381+
if (contributor.htmlUrl === 'https://github.com/cursoragent') {
382+
return {
383+
...contributor,
384+
kind: 'agent' as const,
385+
label: 'cursoragent'
366386
}
387+
}
367388

368-
if (contributor.htmlUrl === 'https://github.com/anthropics-claude-code') {
369-
return {
370-
...contributor,
371-
kind: 'agent' as const,
372-
label: 'Claude Code'
373-
}
389+
if (contributor.htmlUrl === 'https://github.com/anthropics-claude-code') {
390+
return {
391+
...contributor,
392+
kind: 'agent' as const,
393+
label: 'Claude Code'
374394
}
395+
}
375396

376-
if (contributor.htmlUrl === 'https://github.com/windsurf') {
377-
return {
378-
...contributor,
379-
kind: 'agent' as const,
380-
label: 'Windsurf'
381-
}
397+
if (contributor.htmlUrl === 'https://github.com/windsurf') {
398+
return {
399+
...contributor,
400+
kind: 'agent' as const,
401+
label: 'Windsurf'
382402
}
403+
}
383404

384-
return contributor
385-
})
405+
return contributor
406+
})
386407
.sort((left, right) => right.sortWeight - left.sortWeight)
387408
}
388409

doc/components/mermaid.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export function Mermaid({chart, title}: MermaidProps) {
153153
}, 1800)
154154
}
155155

156-
const hasTitle = title !== void 0 && title !== ''
157156
const hasSvg = svg !== void 0 && svg !== ''
158157
const hasError = error !== void 0 && error !== ''
159158
let diagramBody: ReactNode = <div className="mermaid-diagram__loading">Rendering diagram...</div>

doc/components/package-manager-tabs.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export function PackageManagerTabs({
3939
}: PackageManagerTabsProps): ReactNode {
4040
const instanceId = useId()
4141
const [selectedManager, setSelectedManager] = useState<PackageManager>(defaultManager)
42+
const hasTitle = title !== void 0 && title !== ''
43+
const hasDescription = description !== void 0 && description !== null && description !== false
4244
const tabs: PackageManagerTab[] = TAB_ORDER.map(id => ({
4345
command: commands[id],
4446
id,
@@ -55,12 +57,14 @@ export function PackageManagerTabs({
5557

5658
return (
5759
<section className="docs-package-manager-tabs">
58-
{title || description ? (
59-
<header className="docs-widget-header">
60-
{title ? <h3>{title}</h3> : null}
61-
{description ? <p>{description}</p> : null}
62-
</header>
63-
) : null}
60+
{hasTitle || hasDescription
61+
? (
62+
<header className="docs-widget-header">
63+
{hasTitle ? <h3>{title}</h3> : null}
64+
{hasDescription ? <p>{description}</p> : null}
65+
</header>
66+
)
67+
: null}
6468
<div className="docs-package-manager-tabs-list" role="tablist" aria-label="Package manager commands">
6569
{tabs.map(tab => {
6670
const isSelected = tab.id === activeTab.id
@@ -80,9 +84,9 @@ export function PackageManagerTabs({
8084
}}
8185
>
8286
{tab.label}
83-
{tab.id === recommendedManager ? (
84-
<span className="docs-package-manager-tab-badge">推荐</span>
85-
) : null}
87+
{tab.id === recommendedManager
88+
? <span className="docs-package-manager-tab-badge">推荐</span>
89+
: null}
8690
</button>
8791
)
8892
})}

doc/content/sdk/_meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
'index': '概览'
2+
index: '概览'
33
}

0 commit comments

Comments
 (0)