From d0b8f0daa0da33588b83643d4083877f49c2f643 Mon Sep 17 00:00:00 2001 From: bowenliang123 Date: Mon, 24 Aug 2026 17:16:40 +0800 Subject: [PATCH] chore(config): trim comments in build config, scripts and docs tooling Compress the CSS-channel note in tsdown.config.ts, the vitest lane explainer and the release workflow header; fix the install-hooks header (git only consults .git/hooks when core.hooksPath is unset); slim the social-preview generator and bundle-patch comments. --- .github/workflows/release.yml | 9 +++------ cordis.patch.yml | 10 +++------- docs/social-preview/generate.ts | 8 +++----- scripts/install-hooks.sh | 4 ++-- tsdown.config.ts | 12 +++--------- vitest.config.ts | 4 +--- 6 files changed, 15 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9333de6..29ac07d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,8 @@ name: Publish to npm -# Fires when a release tag (v*) is pushed — the same tag our release flow -# creates (`git tag vX.Y.Z && gh release create`). Publishing uses npm -# Trusted Publishing (OIDC): no long-lived token is needed, and provenance -# attestations are generated automatically (npm CLI >= 11.5.1 auto-detects -# the OIDC environment). The npm-side trusted publisher must be configured -# with this exact workflow filename: `release.yml`. +# Fires on a release tag (v*) push. Publishing uses npm Trusted Publishing +# (OIDC), so no long-lived token is needed — the npm-side trusted publisher +# must be configured with this exact workflow filename. on: push: tags: diff --git a/cordis.patch.yml b/cordis.patch.yml index e82dfb6..2cbb50f 100644 --- a/cordis.patch.yml +++ b/cordis.patch.yml @@ -1,10 +1,6 @@ -# dsh-context — bundle patch layer. -# -# Installing this package into a profile (`dsh plugin --profile add dsh-context`) -# appends it to `dsh.profile.bundles`; this patch is then applied as that -# bundle's layer. The row below loads the package's main entry as the host -# half (a plain Cordis plugin) and, because the package declares `dsh.client`, -# the web app also loads its `./client` bundle as the browser half. +# Bundle patch layer: the row loads the package's main entry as the host half +# (a plain Cordis plugin); the `dsh.client` declaration makes the web app load +# its ./client bundle as the browser half. - insert: - id: dsh-context name: dsh-context diff --git a/docs/social-preview/generate.ts b/docs/social-preview/generate.ts index e434d62..d5f53df 100644 --- a/docs/social-preview/generate.ts +++ b/docs/social-preview/generate.ts @@ -1,6 +1,6 @@ -// Renders social-preview.html to docs/social-preview.png (exactly 1280x640). -// Renders at 2x (2560x1280) first, then downsamples via Chromium's high-quality -// image smoothing, so text and the embedded screenshot stay sharp. +// Renders social-preview.html to docs/social-preview.png (exactly 1280x640): +// 2x first (2560x1280), then downsampled via Chromium's high-quality image +// smoothing so text and the embedded screenshot stay sharp. // Usage: node docs/social-preview/generate.ts (or: npm run social-preview) import { chromium } from 'playwright-core'; import { homedir } from 'node:os'; @@ -22,14 +22,12 @@ const executablePath = path.join( fs.mkdirSync(tmpDir, { recursive: true }); const browser = await chromium.launch({ executablePath }); -// Pass 1: render the design at 2x. const page1 = await browser.newPage({ viewport: { width: 1280, height: 640 }, deviceScaleFactor: 2 }); await page1.goto(pathToFileURL(htmlPath).href); await page1.waitForLoadState('load'); await page1.screenshot({ path: hiResPath, clip: { x: 0, y: 0, width: 1280, height: 640 } }); await page1.close(); -// Pass 2: downsample the 2x render to the final 1280x640. const dataUrl = `data:image/png;base64,${fs.readFileSync(hiResPath).toString('base64')}`; const page2 = await browser.newPage({ viewport: { width: 1280, height: 640 } }); await page2.setContent( diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh index 718eaf2..48d467d 100644 --- a/scripts/install-hooks.sh +++ b/scripts/install-hooks.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Installs the repo's git hooks natively (no husky), so `pnpm run typecheck` -# runs on every commit. Requires the repo to be a git working tree. +# Installs a native pre-commit hook that runs `pnpm run typecheck`. Git only +# executes .git/hooks when `core.hooksPath` is unset (husky sets it to .husky/_). set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" diff --git a/tsdown.config.ts b/tsdown.config.ts index b26048d..7325546 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -49,20 +49,15 @@ const isProductionDependency = (specifier: string): boolean => const NODE_ENV = process.env.NODE_ENV ?? 'production' -// ---- CSS channels, mirrored from the official preset --------------------- -// (packages/client/tsdown.client.ts). The virtual-id wrapper keeps stylesheets -// away from tsdown's own css pipeline: its guard matches ids ending in `.css`, -// so the virtual id must not. `.module.css` yields a hashed class map and -// injects a tagged style at factory execution; `.css?inline` exports compiled -// text; a plain `.css` import injects the sheet unhashed (the plugin's own -// lc-* namespace stays the anti-collision discipline). +// CSS channels, mirrored from packages/client/tsdown.client.ts. The virtual +// ids must NOT end in `.css` — tsdown's own css-pipeline guard matches on that +// suffix; the plugin's flat lc-* class namespace is the anti-collision rule. const CSS_VIRTUAL_PREFIX = '\0dsh-css:' const GLOBAL_CSS_VIRTUAL_PREFIX = '\0dsh-global-css:' const INLINE_CSS_VIRTUAL_PREFIX = '\0dsh-inline-css:' const CSS_VIRTUAL_SUFFIX = '.mjs' const INLINE_CSS_QUERY = '?inline' -/** Emit one plugin-owned style injector and an optional CSS Modules export. */ function styleInjectionModule( id: string, fileId: string, @@ -84,7 +79,6 @@ function styleInjectionModule( return source.join('\n') } -/** Resolve a stylesheet import against the importing source file. */ function sourceAssetPath(source: string, importer: string): string { return resolvePath(dirname(importer), source) } diff --git a/vitest.config.ts b/vitest.config.ts index b1c5120..13df8c6 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -2,9 +2,7 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { - // Specs exercise the BUILT artifacts (lib/), so `pnpm run build` first. - // `*.client.spec.ts` is the browser lane (jsdom pragma per file); the - // plain `*.spec.ts` files run in node with their own fakes. + // Specs exercise the built lib/ artifacts — `pnpm run build` first; *.client.spec.ts is the jsdom browser lane. include: ['tests/**/*.spec.ts'], }, })