@dsh-workbench/module-tools 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,6 +26,8 @@ pnpm design check # 设计底稿有没有空格、README 有没有落后
26
26
  (沿用记录里的出口、版本与索引计划,产物没变就不重跑门禁)。
27
27
  这一版在 `CHANGELOG.md` 里没有记录、或 `package.json` 缺 `files` 里的 `CHANGELOG.md` 时,
28
28
  `release` 直接拦下并给出补的命令;`author` 没写时从本机 `git config` 补进 manifest,索引与产物都带上。
29
+ 要换署名时带 `--author "姓名 <邮箱>"`(或只给姓名):它写回 `package.json`,索引、产物与提交都用它,
30
+ `--refresh` 时也一样。
29
31
 
30
32
  骨架自带脚本,日常不用记长命令:`build` · `typecheck` · `test` · `selfcheck` · `check` · `lint` · `design`。
31
33
 
@@ -231,9 +233,10 @@ dsh-wb-module design accept # 在真卡片上逐条走通后打勾
231
233
 
232
234
  ```jsonc
233
235
  "workbench": {
234
- "apiVersion": 2,
236
+ "apiVersion": 3,
235
237
  "unit": "hello",
236
- "card": { "titleKey": "hello.cardTitle", "order": 90 },
238
+ "title": { "zh": "示例模块", "en": "Sample module" },
239
+ "card": { "order": 90 },
237
240
  "tools": [{ "name": "hello_read", "writes": false }],
238
241
  "host": { "inject": [] },
239
242
  "needs": [
@@ -252,8 +255,9 @@ dsh-wb-module design accept # 在真卡片上逐条走通后打勾
252
255
 
253
256
  五条口径:
254
257
 
255
- 1. **声明了 `apiVersion` = 静态半写全了**:`unit` / `card` / `tools` / `host` 四个键都要有
256
- (没有卡片写 `null`),`needs` 没有外部需要时省略。
258
+ 1. **声明了 `apiVersion` = 静态半写全了**:`unit` / `title` / `card` / `tools` / `host` 五个键都要有
259
+ (没有卡片写 `null`),`needs` 没有外部需要时省略。名字是包里的字面量(中英各一份),
260
+ 不是词表键 —— 宿主在模块载入之前就读得到它。
257
261
  `needs` 四种 `kind`:`bin` / `extension` / `lib` / `env`;每条必写 `purpose`;
258
262
  未知 `kind` 或 `sources[].kind` 判红,need 里未知字段只算警告(`x-` 前缀忽略)。
259
263
  2. **不许有协议不认识的键**:生字段会被外壳静默忽略(拼错一个键就等于那句话没写),
@@ -60,6 +60,7 @@ const RELEASE_HELP = `
60
60
  --version patch|minor|major|x.y.z 版本;省略时已存在就自动 patch
61
61
  --registry <url> --access restricted|public --npmrc <文件>
62
62
  --license <id> --out <目录> --git <remote>
63
+ --author <署名> 换署名(姓名,或 姓名 <邮箱>);写回 package.json
63
64
  --index auto|none|<目录|git 地址> 发布后要更新的索引源
64
65
  --index-ref <分支> --index-path <索引路径> --index-policy artifacts-in-repo|catalog-only
65
66
  --resume 上次中断后接着发(用记录里的出口与版本)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/module-tools",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "模块包的构建与门禁工具:build(单文件 ESM 宿主侧 + 套 loader 壳的浏览器侧)、check(契约/产物边界/源码边界/卡片渲染)。模块包不再各带一份构建脚本。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "semver": "^7.8.5",
34
34
  "typescript": "5.9.3",
35
35
  "typescript-eslint": "^8.71.0",
36
- "@dsh-workbench/shared": "1.0.1"
36
+ "@dsh-workbench/shared": "1.1.0"
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",
@@ -381,8 +381,7 @@ export async function run() {
381
381
  }
382
382
 
383
383
  const declared = pkg.manifest.dsh?.workbench?.card ?? null;
384
- const declaresCard =
385
- declared !== null && typeof declared.titleKey === 'string' && declared.titleKey !== '';
384
+ const declaresCard = declared !== null && typeof declared === 'object';
386
385
 
387
386
  const shellClient = shellClientPathOf(pkg.dir);
388
387
  const hasShell = shellClient !== undefined && existsSync(shellClient);
@@ -457,7 +456,7 @@ export async function run() {
457
456
  if (typeof card === 'function') {
458
457
  problems.push(
459
458
  `${name}: 清单写的是 "card": null,产物却登记了一张卡片 —— 两处说法不一致:` +
460
- '要么把清单补成一张卡(titleKey + order),要么把这张卡从产物里去掉',
459
+ '要么把清单补成一张卡(`"card": { "order": … }`),要么把这张卡从产物里去掉',
461
460
  );
462
461
  continue;
463
462
  }
@@ -465,29 +464,10 @@ export async function run() {
465
464
  continue;
466
465
  }
467
466
  if (typeof card !== 'function') {
468
- problems.push(`${name}: 清单写了 card.titleKey,apply 之后却没登记卡片(registerUnit 没拿到 card)`);
467
+ problems.push(`${name}: 清单写了 card,apply 之后却没登记卡片(registerUnit 没拿到 card)`);
469
468
  continue;
470
469
  }
471
470
 
472
- const titleKey = pkg.manifest.dsh?.workbench?.card?.titleKey;
473
- if (typeof titleKey === 'string' && titleKey !== '') {
474
- const messages = registered?.messages;
475
- if (messages === undefined || messages === null || typeof messages !== 'object') {
476
- problems.push(
477
- `${name}: 清单的 card.titleKey「${titleKey}」没有落点 —— registerUnit 交的面里没有 messages,` +
478
- '面板上那一格会显示原始键名',
479
- );
480
- } else {
481
- const missing = ['zh', 'en'].filter((one) => typeof messages[one]?.[titleKey] !== 'string');
482
- if (missing.length > 0) {
483
- problems.push(
484
- `${name}: 清单的 card.titleKey「${titleKey}」在模块字典的 ${missing.join(' / ')} 里没有 —— ` +
485
- '面板上那一格会显示原始键名。清单写了 titleKey,字典就得有这一条(zh / en 都要)',
486
- );
487
- }
488
- }
489
- }
490
-
491
471
  const props = {
492
472
  world: { current: { sessionId: null, workspace: null } },
493
473
  t: (key) => key,
@@ -664,7 +644,7 @@ export async function run() {
664
644
  ? `${SNAPSHOTS.length} 态 × zh/en 各渲染一遍`
665
645
  : `逐态那半这次有 ${degraded} 个模块跳过(没装外壳 / 取不出外壳,见下),其余 ${SNAPSHOTS.length} 态 × zh/en 各渲染一遍`) +
666
646
  ' —— 不抛、非空白、文字里没有 ' +
667
- 'undefined / NaN / [object Object] / null、没有裸键名、套了外壳的卡壳、清单的 titleKey 在两语字典里都有落点。' +
647
+ 'undefined / NaN / [object Object] / null、没有裸键名、套了外壳的卡壳;名字来自清单顶层的 title(协议判据管它中英都有)。' +
668
648
  `(断言的是"${SNAPSHOTS.length} 种外壳侧输入下都退化得漂亮",不是"画的是哪一态那一屏" —— 屏的对错归模块自己的 ` +
669
649
  'card-states.test.ts 与 design.json 状态矩阵)',
670
650
  ...(shellClients.length === 0
package/src/release.mjs CHANGED
@@ -246,6 +246,11 @@ export async function runRelease({
246
246
  const json = hasFlag(args, '--json');
247
247
  const dryRun = hasFlag(args, '--dry-run');
248
248
  const verify = hasFlag(args, '--verify');
249
+ const askedAuthor = argValue(args, '--author');
250
+ const explicitAuthor = askedAuthor === undefined ? undefined : askedAuthor.trim();
251
+ if (askedAuthor !== undefined && (explicitAuthor === '' || /[\r\n]/u.test(explicitAuthor))) {
252
+ throw new ReleaseError('--author 只认一行署名:姓名,或 姓名 <邮箱>');
253
+ }
249
254
  const manifest = readManifest(root);
250
255
  const unit = manifest?.dsh?.workbench?.unit;
251
256
  if (typeof unit !== 'string' || unit === '') throw new ReleaseError('这不是一个 wb 模块包(没有 dsh.workbench.unit)');
@@ -297,6 +302,11 @@ export async function runRelease({
297
302
  emit(out, json, summary);
298
303
  return summary;
299
304
  }
305
+ const explicitApplied = explicitAuthor !== undefined && !verify && !dryRun;
306
+ if (explicitApplied) {
307
+ manifest.author = explicitAuthor;
308
+ writeManifest(root, manifest);
309
+ }
300
310
  if (target === 'market') {
301
311
  if (indexPlan === undefined) {
302
312
  throw new ReleaseError('没有可写的 git 索引源 —— 用 --index <仓库> 指定,或先在「模块市场 → 发现」里初始化索引');
@@ -329,7 +339,10 @@ export async function runRelease({
329
339
  ...(result.branch === undefined ? {} : { branch: result.branch }),
330
340
  ...(result.commit === undefined ? {} : { commit: result.commit }),
331
341
  },
332
- changes: result.updated === true ? ['市集元数据已刷新'] : [],
342
+ changes:
343
+ result.updated === true
344
+ ? ['市集元数据已刷新', ...(explicitAuthor === undefined ? [] : ['author ← --author'])]
345
+ : [],
333
346
  install: '',
334
347
  text:
335
348
  result.updated === true
@@ -340,8 +353,8 @@ export async function runRelease({
340
353
  return summary;
341
354
  }
342
355
  const authored = authorChangeOf(root, manifest, exec);
343
- const authorChange = authored.change;
344
- if (!verify && !dryRun && authored.author !== undefined) {
356
+ const authorChange = explicitAuthor === undefined ? authored.change : 'author ← --author';
357
+ if (!explicitApplied && !verify && !dryRun && authored.author !== undefined) {
345
358
  manifest.author = authored.author;
346
359
  writeManifest(root, manifest);
347
360
  }
@@ -26,9 +26,10 @@
26
26
  "external": ["@dsh-workbench/core/client", "@deepseek-ai/dsh-client-ui-primitives"]
27
27
  },
28
28
  "workbench": {
29
- "apiVersion": 2,
29
+ "apiVersion": 3,
30
30
  "unit": "__UNIT__",
31
- "card": { "titleKey": "__UNIT__.cardTitle", "order": 90 },
31
+ "title": { "zh": "__UNIT__ 模块", "en": "__UNIT__ module" },
32
+ "card": { "order": 90 },
32
33
  "tools": [],
33
34
  "host": { "inject": [] }
34
35
  },
@@ -27,9 +27,10 @@
27
27
  "external": ["@dsh-workbench/core/client", "@deepseek-ai/dsh-client-ui-primitives"]
28
28
  },
29
29
  "workbench": {
30
- "apiVersion": 2,
30
+ "apiVersion": 3,
31
31
  "unit": "__UNIT__",
32
- "card": { "titleKey": "__UNIT__.cardTitle", "order": 90 },
32
+ "title": { "zh": "__UNIT__ 模块", "en": "__UNIT__ module" },
33
+ "card": { "order": 90 },
33
34
  "tools": [],
34
35
  "host": { "inject": [] }
35
36
  },