docs(create-plugin): 按 route B 收缩到不漂移的部分,产物一律指向 buildPluginFiles() (#3715) - #3760
Merged
Merged
Conversation
… buildPluginFiles() (#3715) The page described a scaffolder that does not exist: it claimed the CLI installs dependencies and inits a git repo (it does neither), listed six prompts (there are two after the name), put the output in the current directory (it writes packages/plugin-NAME), told readers to run `npm run dev` against a build.lib config that has no dev server, and documented a whole `.create-plugin.config.js` configuration surface the generator never reads. Every one of those distortions came from transcribing generator output into prose, so per the triage ruling (route B) the transcriptions are deleted rather than rewritten: the generated tree, the four generated-file samples and the CLI's own dependency list are replaced with a pointer at buildPluginFiles() in packages/create-plugin/src/templates.ts, which is the single source of truth for what a scaffolded plugin contains. What survives is the invocation surface (install, name rules, where it writes, how to iterate, how to publish), plus the structural facts a reader needs and that cannot go stale on their own. No version literal is restated anywhere on the page, so doc-version-claims' KNOWN_CLAIMS needs no row deleted (it had none for this file).
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…nding (#3715) PR #3754 (#3742) landed while this branch was open and turned templates.test.ts from "the three testing ranges are sourced from the repo" into "every generated devDependency range is anchored, none unpinned". The page said "the testing ones", which was accurate at the fetch point and understated after that merge — exactly the drift this shrink exists to avoid, so the sentence now names the anchoring without naming a subset or a count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3715
按分诊裁决走 route B(收缩),不做 route A 全量重写:本页每一处失真都是「把生成器产物转写成散文」造成的,重写转写等于把同一把枪重新上膛(#3645 家族)。所以「产物长什么样」的整段一律删除并指路,只留下不会自己变旧的那部分。
真相锚:
packages/create-plugin/src/templates.ts与src/index.ts,对origin/main@0c28a0720逐条实测(#3733 已落 main,模板已在templates.ts)。全页 374 行 → 181 行(+123 / -315)。删除(照做即坏 / 纯虚构)
index.ts全文只有一处pnpm install字样,是打印给用户的 next step(:132),没有任何 exec / spawn / git 调用:82-95);不传名字才多问一个名字my-awesome-plugin/,列.gitignore,缺示例测试)path.join(process.cwd(), 'packages', fullPackageName)(:97);产物 9 个,不含.gitignore,含示例测试与vitest.setup.tssrc/AwesomeComponent.tsx、export * from './types'、Props/Schema 成对的types.ts)PascalImpl导入并在模块顶层注册,types.ts只有一个 Schema 接口npm run dev+ "starts Vite in dev mode with HMR"build.lib,没有 dev server 可启。照做得到 "Missing script: dev" —— 本单最重的一条.create-plugin.config.js的 template / defaults / prompts)0.3.117.3.0;按 #3711 的取向直接删字面量、改指 npm 页### package.json一节(#3726 刚订正过)src/index.ts改成src/templates.ts指路(取代转写)
buildPluginFiles()insrc/templates.ts—— 「一个插件包含哪些文件」的唯一真相,index.ts只是写盘循环。没有任何文件清单被手工维护(create-plugin 生成的插件跑不了自己的测试:模板写入 test 文件与test脚本,却没在 devDependencies 里声明 @testing-library/react 与 jest-dom #3716 席位的交接项 1)。src/__tests__/templates.test.ts机械锚定到仓内声明(交接项 3)。--help;脚本清单不转写,改为「新包里跑pnpm run看它到底有哪些」—— 两句都是自更新的真相。保留 / 新增(都是不会自己变旧的事实)
runner.mdx的写法(docs(runner): 删掉 runner.mdx 的幽灵目录与「内置示例 schema」断言,重写 Package Information #3616):只留名字 / binary / license,版本改指 npm 页。packages/下,依赖是workspace:*,tsconfig 往上两级 extends);一个名字同时决定四样东西(目录 / 包名 / 注册type键 / PascalCase 组件名),plugin-前缀会被剥掉;发布用pnpm publish(pnpm 打包时会把workspace:*改写成真实区间,npm publish会把字面量原样发出去)。第二个 commit:被 #3742 追上的那一句
b8b219bac是分支开着的时候 PR #3754(#3742)落 main 触发的:那个 PR 把templates.test.ts从「三条测试区间取自仓内」升级成「每一条 devDependency 区间都被锚定,没有未钉的」。本页原写「the testing ones are asserted…」在我的 fetch 点是准确的,合并后就变成了低估 —— 正是本次收缩要消灭的那种漂移,所以改成只说锚定这件事本身,不说子集、不说条数。因为禁止 force-push,这一句以追加 commit 落下而非 rebase 重写。Ledger(#3711 双向棘轮)
无需删任何 KNOWN_CLAIMS 行:该 ledger 里本就没有
create-plugin.mdx的登记行(仅在文件头注释中作为 #3709 的案例被提及,不是条目)。原因是它的匹配需要「包名与版本同行相邻」,而旧页的0.3.1单独一行,从未被扫成 claim。改动前后各跑一次确认:新写的散文也不含任何版本字面量,所以棘轮上行方向同样不会红。
验证
本地另外单独编译过 MDX(用仓内
@mdx-js/mdx@3.1.1直接compile()本页 → OK,16611 bytes JSX;对照编译未改动的runner.mdx同样 OK,证明这个检查不是空转)。订正一处我先前写错的话:这段最初写的是「
ci.yml的paths-ignore含content/**,纯 docs PR 不会启动 Build Docs」。错的,而且错得正是本单批评的那个模式 —— 我把 Build Docs job 里一段讲历史的注释读成了当前事实。实际上ci.yml的pull_request触发器自 #3523 起已经没有paths-ignore(只有push:还保留一份),路径判断移进了 job 内部;所以本 PR 确实拉起了 Build Docs,而它的 "Check for docs changes" 步看到content/有改动 →should_run=true→ 真的构建站点。本地那次 MDX 编译因此只是提前一步的自检,不是 CI 缺口的补丁。Changeset:无。 纯文档订正,依 AGENTS.md 与同族先例(PR #3698 / #3726 / #3616 都是 docs-only 且无 changeset)。
未触碰
packages/create-plugin/**(#3742 在途,现已落 main)、scripts/__tests__/doc-version-claims.test.ts(无行可删)、content/docs/releases/。与origin/main@e473b6c29实测无冲突(git merge-tree:0 处冲突标记)。越界发现
已另开 #3759(
finding,未排队、未指派):生成的src/types.ts是死产物 —— 没有任何生成源文件 import 它,生成的exportsmap 又只暴露.,那个 Schema 接口在包内无人用、包外不可达。与 #3742 / #3755 同族同文件但范围互不覆盖。有意思的是,本 PR 删掉的那段虚构文档写的export * from './types'恰好比真实模板更合理。本 PR 未改一行生成器代码。Generated by Claude Code