Skip to content

Commit dd47a2c

Browse files
authored
Merge pull request #526 from omdsh-dev/feat/dev-commands
feat(dev): 引入 Makefile 规范化命令面
2 parents f24f95f + 3d23ceb commit dd47a2c

7 files changed

Lines changed: 108 additions & 14 deletions

File tree

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig — https://editorconfig.org
2+
# 仓库统一编辑器基线;缩进等风格细节以各文件的既有约定为准。
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
# Makefile 的 recipe 必须用真实 tab(GNU Make 硬性要求)。
14+
[Makefile]
15+
indent_style = tab

.github/workflows/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ jobs:
2222
with:
2323
# Tests run git log against this repository and need the full history.
2424
fetch-depth: 0
25+
# pnpm version is pinned via packageManager in package.json; the action
26+
# reads it from there (specifying both makes action-setup fail on
27+
# purpose with ERR_PNPM_BAD_PM_VERSION).
2528
- uses: pnpm/action-setup@v6
26-
with:
27-
version: 11
2829
- uses: actions/setup-node@v7
2930
with:
3031
node-version: 22
@@ -69,9 +70,10 @@ jobs:
6970
with:
7071
# Tests run git log against this repository and need the full history.
7172
fetch-depth: 0
73+
# pnpm version is pinned via packageManager in package.json; the action
74+
# reads it from there (specifying both makes action-setup fail on
75+
# purpose with ERR_PNPM_BAD_PM_VERSION).
7276
- uses: pnpm/action-setup@v6
73-
with:
74-
version: 11
7577
- uses: actions/setup-node@v7
7678
with:
7779
node-version: 22
@@ -109,9 +111,10 @@ jobs:
109111
steps:
110112
- uses: actions/checkout@v7
111113

114+
# pnpm version is pinned via packageManager in package.json; the action
115+
# reads it from there (specifying both makes action-setup fail on
116+
# purpose with ERR_PNPM_BAD_PM_VERSION).
112117
- uses: pnpm/action-setup@v6
113-
with:
114-
version: 11
115118

116119
- uses: actions/setup-node@v7
117120
with:
@@ -146,7 +149,7 @@ jobs:
146149
- name: Aggregate double-mount regression
147150
env:
148151
DSH_CMD: dsh
149-
run: bash scripts/e2e-aggregate-mount.sh
152+
run: pnpm test:mount:aggregate
150153

151154
- name: Upload Playwright report on failure
152155
if: failure()

.github/workflows/release.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ jobs:
5151
# Tests run git log against this repository and need full history.
5252
fetch-depth: 0
5353

54+
# pnpm version is pinned via packageManager in package.json; the action
55+
# reads it from there (specifying both makes action-setup fail on
56+
# purpose with ERR_PNPM_BAD_PM_VERSION).
5457
- uses: pnpm/action-setup@v6
55-
with:
56-
version: 11
5758

5859
- uses: actions/setup-node@v7
5960
with:
@@ -84,15 +85,21 @@ jobs:
8485
exit 1
8586
fi
8687
87-
- name: Build
88-
run: pnpm build
89-
9088
- name: Typecheck
9189
run: pnpm typecheck
9290

9391
- name: Test
9492
run: pnpm test
9593

94+
- name: Build
95+
run: pnpm build
96+
97+
# The consumer-facing declaration surface guard — mirrors the ci.yml
98+
# verification order (typecheck → test → build → check:consumer-types)
99+
# so a release is gated on the same checks a PR runs.
100+
- name: Check consumer type surface
101+
run: pnpm check:consumer-types
102+
96103
- name: Dry-run publish (validation only)
97104
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true'
98105
run: pnpm publish --dry-run --no-git-checks

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# dsh-better-sidebar 命令面薄封装:目标仅转发 package.json scripts(唯一事实源),
2+
# 新增/改名 script 不需要动这里;本文件只补目标发现(help)与 CI 门禁聚合
3+
# (check / mount / mount-aggregate / registry)。
4+
# 注:lint 目标留给引入 ESLint 的后续 PR。
5+
6+
.DEFAULT_GOAL := help
7+
8+
help: ## 列出所有可用目标
9+
@awk -F':.*## ' '/^[a-zA-Z0-9_-]+:.*## / {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
10+
11+
install: ## 安装依赖(pnpm install)
12+
pnpm install
13+
14+
build: ## 构建(清 lib/ → tsc → tsdown)
15+
pnpm build
16+
17+
typecheck: ## 类型检查(tsc --noEmit)
18+
pnpm typecheck
19+
20+
test: ## 单元测试(vitest run)
21+
pnpm test
22+
23+
check: ## 聚合校验门禁:typecheck → build → test → check:consumer-types(对齐 CI)
24+
pnpm typecheck && pnpm build && pnpm test && pnpm check:consumer-types
25+
26+
clean: ## 清理构建产物与测试报告(lib/、*.tgz、playwright-report/、test-results/)
27+
rm -rf lib playwright-report test-results
28+
rm -f *.tgz
29+
30+
pack: ## 打 npm tarball(pnpm pack)
31+
pnpm pack
32+
33+
mount: ## 真机挂载冒烟:build + pack → Playwright Chromium → pnpm test:mount
34+
pnpm build && pnpm pack && pnpm exec playwright install chromium && pnpm test:mount
35+
36+
mount-aggregate: ## 聚合双挂载回归:build + pack → pnpm test:mount:aggregate
37+
pnpm build && pnpm pack && pnpm test:mount:aggregate
38+
39+
registry: ## 组装 plugin-registry 暂存(registry/,不入库):build → node scripts/package-registry.mjs
40+
pnpm build && node scripts/package-registry.mjs
41+
42+
.PHONY: help install build typecheck test check clean pack mount mount-aggregate registry

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ dsh plugin --profile web add dsh-better-sidebar@latest # 重跑即成功
8585
遇到报错先查 https://github.com/omdsh-dev/DSH-better-sidebar README 的常见问题表。
8686
```
8787

88+
**方式三:一键脚本**——克隆本仓库后执行 `bash scripts/install.sh`(macOS / Linux / Windows Git Bash;Windows 原生环境用 `install.ps1``-h` 查看参数),自动完成 add → 放行构建脚本 → 重跑安装。
89+
8890
<details>
8991
<summary><b>更新</b></summary>
9092

@@ -492,6 +494,16 @@ pnpm test # vitest(含 manifest 一致性守卫,需先 build)
492494
pnpm watch # tsdown --watch
493495
```
494496

497+
**Make 薄封装**`make help` 查看全部目标;package.json 仍是唯一事实源):
498+
499+
```sh
500+
make check # 聚合校验门禁:typecheck → build → test → check:consumer-types(对齐 CI)
501+
make mount # 真机挂载冒烟:build + pack → 安装 Chromium → pnpm test:mount
502+
make clean # 清理 lib/、*.tgz、playwright-report/、test-results/
503+
```
504+
505+
`pnpm check:consumer-types`:对外类型声明面守卫——以浏览器-only 消费者(无 `@types/node``skipLibCheck: false`)的视角对构建出的 `lib/types` 做类型检查,需先 `pnpm build`
506+
495507
**架构**:单 npm 包、host/client 双半结构——host(`src/index.ts`):`/sidebar/api/*` JSON API、`/sidebar/file` 媒体路由、`/sidebar/html` 预览路由、`/sidebar/ws/terminal` WebSocket(fs / git / pty / 预览,全部会话级 + 信任围栏);client(`src/client/index.tsx`):portal 侧边栏 + 各视图 + 拦截;状态按会话持久化 localStorage。插件按 DSH 官方规范组织(无 default 导出、双 client bundle),运行期不依赖 npm / checkout(`@deepseek-ai/*` 由 web profile 提供)。
496508

497509
## 🔐 安全
@@ -517,7 +529,7 @@ Windows / Linux / macOS 三平台适配(macOS 日常验证;其余经单元
517529

518530
- **代码改动走 PR**`feat/*` / `fix/*` 分支开发 → `gh pr create`;纯文档改动可直接推 main
519531
- **收录生态插件**:给仓库打 `dsh-better-sidebar` topic + 向 [`src/client/plugins-tabs.ts`](./src/client/plugins-tabs.ts) / [`plugins-viewers.ts`](./src/client/plugins-viewers.ts) 提 PR
520-
- **提交前自检**`pnpm typecheck && pnpm build && pnpm test`(CI 另有 npm 打包 → 真实挂载 → 无头渲染门禁 `pnpm test:mount`
532+
- **提交前自检**`pnpm typecheck && pnpm build && pnpm test``make check` 一键聚合;CI 另有 npm 打包 → 真实挂载 → 无头渲染门禁 `pnpm test:mount`,及聚合双挂载回归 `pnpm test:mount:aggregate`
521533
- 仓库工作规范见 [`AGENTS.md`](./AGENTS.md)(含仓库硬约束与 CI 说明)
522534

523535
## ⭐ Star History

README_EN.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Install the dsh-better-sidebar plugin (a sidebar workbench for DSH):
8585
If anything fails, check the troubleshooting table in the README at https://github.com/omdsh-dev/DSH-better-sidebar
8686
```
8787

88+
**Option 3: one-shot script** — from a clone of this repo, run `bash scripts/install.sh` (macOS / Linux / Windows Git Bash; native Windows uses `install.ps1`; `-h` for options) — it automates add → approve-builds → re-run.
89+
8890
<details>
8991
<summary><b>Updating</b></summary>
9092

@@ -487,6 +489,16 @@ pnpm test # vitest (includes manifest consistency guard; build first)
487489
pnpm watch # tsdown --watch
488490
```
489491

492+
**Make thin wrappers** (`make help` lists every target; package.json stays the single source of truth):
493+
494+
```sh
495+
make check # aggregate gate: typecheck → build → test → check:consumer-types (mirrors CI)
496+
make mount # real-mount smoke: build + pack → install Chromium → pnpm test:mount
497+
make clean # remove lib/, *.tgz, playwright-report/, test-results/
498+
```
499+
500+
`pnpm check:consumer-types`: the consumer-facing declaration-surface guard — type-checks the built `lib/types` from a browser-only consumer's perspective (no `@types/node`, `skipLibCheck: false`); run `pnpm build` first.
501+
490502
**Architecture**: a single npm package with host/client halves — host (`src/index.ts`): `/sidebar/api/*` JSON API, `/sidebar/file` media route, `/sidebar/html` preview route, `/sidebar/ws/terminal` WebSocket (fs / git / pty / preview, all session-scoped with a trust fence); client (`src/client/index.tsx`): portal sidebar + views + interception; state persisted per session in localStorage. Organized per DSH official conventions (no default export, dual client bundles); no dependency on npm / checkout at runtime (`@deepseek-ai/*` provided by the web profile).
491503

492504
## 🔐 Security
@@ -525,7 +537,7 @@ WeChat / QQ group QR codes will live here. After uploading the QR images (drag t
525537

526538
- **Code changes go through PRs**: develop on a `feat/*` / `fix/*` branch, then `gh pr create`; docs-only changes may be pushed to main directly
527539
- **Curate an ecosystem plugin**: tag your repo with `dsh-better-sidebar` + PR a `PluginEntry` into [`src/client/plugins-tabs.ts`](./src/client/plugins-tabs.ts) / [`plugins-viewers.ts`](./src/client/plugins-viewers.ts)
528-
- **Before submitting**: `pnpm typecheck && pnpm build && pnpm test` (CI additionally gates on npm-pack → real-mount → headless-render via `pnpm test:mount`)
540+
- **Before submitting**: `pnpm typecheck && pnpm build && pnpm test` (or `make check` for the one-shot aggregate; CI additionally gates on npm-pack → real-mount → headless-render via `pnpm test:mount`, plus the aggregate double-mount regression `pnpm test:mount:aggregate`)
529541
- See [`AGENTS.md`](./AGENTS.md) for the repository rules (hard constraints, CI lanes, release flow)
530542

531543
## ⭐ Star History

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"engines": {
4040
"node": ">=20"
4141
},
42+
"packageManager": "pnpm@11.8.0",
4243
"dsh": {
4344
"bundle": {
4445
"patch": "./cordis.patch.yml"
@@ -79,6 +80,8 @@
7980
"prepare": "tsdown",
8081
"test": "vitest run",
8182
"test:mount": "bash scripts/e2e-mount.sh",
83+
"test:mount:aggregate": "bash scripts/e2e-aggregate-mount.sh",
84+
"clean": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\"",
8285
"check:consumer-types": "bash scripts/check-consumer-types.sh"
8386
},
8487
"license": "MIT",

0 commit comments

Comments
 (0)