@dsh-workbench/module-tools 0.1.18 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/module-tools",
3
- "version": "0.1.18",
3
+ "version": "0.2.1",
4
4
  "description": "模块包的构建与门禁工具:build(单文件 ESM 宿主侧 + 套 loader 壳的浏览器侧)、check(契约/产物边界/源码边界/卡片渲染)。模块包不再各带一份构建脚本。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "esbuild": "^0.28.2",
24
- "@dsh-workbench/shared": "0.1.18"
24
+ "@dsh-workbench/shared": "0.2.1"
25
25
  },
26
26
  "scripts": {
27
27
  "selfcheck": "node scripts/selfcheck.mjs"
@@ -218,8 +218,25 @@ export async function run() {
218
218
  }
219
219
 
220
220
  const card = registered?.card;
221
+ // 清单说"没有卡片"(`"card": null`)与产物说"没有卡片"必须是同一件事 —— 两处说法不一致就是
222
+ // 声明与代码打架:登记了的那张卡没人会画(外壳只认清单),它只会一直烂在产物里。
223
+ // 这条判据的名字就是它防的事:gitops 当初为了哄旧判据挂了一张"我这张卡片就是说我没有卡片"的占位卡。
224
+ const declared = pkg.manifest.dsh?.workbench?.card ?? null;
225
+ const declaresCard =
226
+ declared !== null && typeof declared.titleKey === 'string' && declared.titleKey !== '';
227
+ if (!declaresCard) {
228
+ if (typeof card === 'function') {
229
+ problems.push(
230
+ `${name}: 清单写的是 "card": null,产物却登记了一张卡片 —— 两处说法不一致:` +
231
+ '要么把清单补成一张卡(titleKey + order),要么把这张卡从产物里去掉',
232
+ );
233
+ continue;
234
+ }
235
+ rows.push(`${name}: 清单写的是 "card": null —— 这个模块没有卡片,产物里也确实没登记(跳过渲染判定)`);
236
+ continue;
237
+ }
221
238
  if (typeof card !== 'function') {
222
- problems.push(`${name}: apply 之后没登记卡片(registerUnit 没拿到 card)`);
239
+ problems.push(`${name}: 清单写了 card.titleKey,apply 之后却没登记卡片(registerUnit 没拿到 card)`);
223
240
  continue;
224
241
  }
225
242
 
@@ -310,7 +327,11 @@ export async function run() {
310
327
  }
311
328
  return {
312
329
  status: 'pass',
313
- notes: [`${rows.length} 张卡片在**空数据**下都画得出来(不许抛);清单的 card.titleKey 在字典里都有落点`, ...rows],
330
+ notes: [
331
+ `${rows.length} 个模块过了卡片这一关:有卡片的都在**空数据**下画得出来(不许抛)、清单的 titleKey 在字典里都有落点;` +
332
+ '清单写 "card": null 的,产物里也确实没登记卡片(声明与代码同一句话)',
333
+ ...rows,
334
+ ],
314
335
  problems: [],
315
336
  };
316
337
  }
@@ -81,7 +81,7 @@ function shellKitOf(clientPath) {
81
81
  });
82
82
  };
83
83
  const window = { __ModuleLoader__: { load } };
84
- // eslint-disable-next-line no-new-func -- 要的就是"按浏览器加载器那样把这份产物跑一遍",静态解析会骗人
84
+ // 要的就是"按浏览器加载器那样把这份产物跑一遍",静态解析会骗人(no-new-func 在本仓的 eslint 配置里没开)
85
85
  new Function('window', readFileSync(clientPath, 'utf8'))(window);
86
86
  return exports?.kit ?? {};
87
87
  }