Skip to content

Commit 203e15e

Browse files
authored
Merge pull request #115 from TrueNine/dev
Refactor CLI packaging and docs routing for the SDK split
2 parents 8142f57 + ccac58b commit 203e15e

File tree

17 files changed

+235
-109
lines changed

17 files changed

+235
-109
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ 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
1620
default: "true"
21+
install-filter:
22+
description: Optional pnpm filter selector to limit install scope
23+
required: false
24+
default: ""
1725

1826
runs:
1927
using: composite
@@ -29,8 +37,16 @@ runs:
2937
node-version: ${{ inputs.node-version }}
3038
cache: pnpm
3139
cache-dependency-path: pnpm-lock.yaml
40+
registry-url: ${{ inputs.registry-url }}
3241

3342
- name: Install workspace dependencies
34-
if: inputs.install == 'true'
43+
if: inputs.install == 'true' && inputs['install-filter'] == ''
3544
shell: bash
3645
run: pnpm install --frozen-lockfile --ignore-scripts
46+
47+
- name: Install filtered workspace dependencies
48+
if: inputs.install == 'true' && inputs['install-filter'] != ''
49+
shell: bash
50+
run: pnpm install --frozen-lockfile --ignore-scripts --filter "$INSTALL_FILTER"
51+
env:
52+
INSTALL_FILTER: ${{ inputs['install-filter'] }}

.github/workflows/deploy-doc.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ on:
66
- main
77
paths:
88
- doc/**
9+
- .github/actions/setup-node-pnpm/action.yml
10+
- .github/workflows/deploy-doc.yml
11+
- .github/workflows/pull-request-doc.yml
12+
- package.json
13+
- pnpm-lock.yaml
14+
- pnpm-workspace.yaml
15+
- turbo.json
916
workflow_dispatch:
1017

1118
permissions:
@@ -25,9 +32,11 @@ jobs:
2532
runs-on: ubuntu-24.04
2633
timeout-minutes: 30
2734
steps:
28-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
2936

3037
- uses: ./.github/actions/setup-node-pnpm
38+
with:
39+
install-filter: "@truenine/memory-sync-docs..."
3140

3241
- name: Preflight Vercel secrets
3342
shell: bash
@@ -49,11 +58,20 @@ jobs:
4958
exit 1
5059
fi
5160
61+
- name: Lint docs
62+
run: pnpm -C doc run lint
63+
64+
- name: Typecheck docs
65+
run: pnpm -C doc run typecheck
66+
5267
- name: Pull Vercel production settings
68+
working-directory: ./doc
5369
run: pnpm dlx vercel@latest pull --yes --environment=production --token="$VERCEL_TOKEN"
5470

5571
- name: Build docs on Vercel
72+
working-directory: ./doc
5673
run: pnpm dlx vercel@latest build --prod --token="$VERCEL_TOKEN"
5774

5875
- name: Deploy docs to Vercel production
76+
working-directory: ./doc
5977
run: pnpm dlx vercel@latest deploy --prebuilt --prod --token="$VERCEL_TOKEN"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Pull Request Docs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
paths:
9+
- doc/**
10+
- .github/actions/setup-node-pnpm/action.yml
11+
- .github/workflows/deploy-doc.yml
12+
- .github/workflows/pull-request-doc.yml
13+
- package.json
14+
- pnpm-lock.yaml
15+
- pnpm-workspace.yaml
16+
- turbo.json
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
check-doc:
27+
if: github.event.pull_request.draft == false
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 30
30+
steps:
31+
- uses: actions/checkout@v6
32+
33+
- uses: ./.github/actions/setup-node-pnpm
34+
with:
35+
install-filter: "@truenine/memory-sync-docs..."
36+
37+
- name: Validate docs content
38+
run: pnpm -C doc run validate:content
39+
40+
- name: Lint docs
41+
run: pnpm -C doc run lint
42+
43+
- name: Typecheck docs
44+
run: pnpm -C doc run typecheck
45+
46+
- name: Build docs
47+
run: pnpm -C doc run build

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
- CODE_OF_CONDUCT.md
1515
- LICENSE
1616
- SECURITY.md
17+
- doc/**
18+
- .github/workflows/deploy-doc.yml
19+
- .github/workflows/pull-request-doc.yml
1720

1821
permissions:
1922
contents: read

.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: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type CalloutTone = 'note' | 'tip' | 'important' | 'warning' | 'caution'
66
type BlockquoteProps = ComponentPropsWithoutRef<'blockquote'>
77

88
const CALLOUT_PATTERN = /^\s*\[!(note|tip|important|warning|caution)\]\s*/i
9+
const CALLOUT_TONES = new Set<CalloutTone>(['note', 'tip', 'important', 'warning', 'caution'])
910

1011
const CALLOUT_LABELS: Record<CalloutTone, string> = {
1112
note: 'Note',
@@ -43,46 +44,51 @@ function getMeaningfulChildren(children: ReactNode): ReactNode[] {
4344

4445
function stripMarkerFromChildren(children: ReactNode): ReactNode {
4546
const items = getMeaningfulChildren(children)
47+
const strippedItems: ReactNode[] = []
4648

47-
return items.map((item, index) => {
49+
for (const [index, item] of items.entries()) {
4850
if (index !== 0) {
49-
return item
51+
strippedItems.push(item)
52+
continue
5053
}
5154

5255
if (typeof item === 'string') {
53-
return item.replace(CALLOUT_PATTERN, '')
56+
strippedItems.push(item.replace(CALLOUT_PATTERN, ''))
57+
continue
5458
}
5559

5660
if (!isValidElement(item)) {
57-
return item
61+
strippedItems.push(item)
62+
continue
5863
}
5964

6065
const element = item as ReactElement<{children?: ReactNode}>
6166
const text = extractText(element.props.children)
6267

6368
if (!CALLOUT_PATTERN.test(text)) {
64-
return item
69+
strippedItems.push(item)
70+
continue
6571
}
6672

67-
return cloneElement(element, {
73+
strippedItems.push(cloneElement(element, {
6874
...element.props,
6975
children: text.replace(CALLOUT_PATTERN, '')
70-
})
71-
})
76+
}))
77+
}
78+
79+
return strippedItems
80+
}
81+
82+
function isCalloutTone(value: string | undefined): value is CalloutTone {
83+
return value != null && CALLOUT_TONES.has(value as CalloutTone)
7284
}
7385

7486
function resolveCalloutTone(children: ReactNode): CalloutTone | null {
7587
const firstChild = getMeaningfulChildren(children)[0]
7688
const firstText = extractText(firstChild).trimStart()
77-
const matched = firstText.match(CALLOUT_PATTERN)?.[1]?.toLowerCase()
78-
79-
if (
80-
matched === 'note'
81-
|| matched === 'tip'
82-
|| matched === 'important'
83-
|| matched === 'warning'
84-
|| matched === 'caution'
85-
) {
89+
const matched = CALLOUT_PATTERN.exec(firstText)?.[1]?.toLowerCase()
90+
91+
if (isCalloutTone(matched)) {
8692
return matched
8793
}
8894

0 commit comments

Comments
 (0)