dsh-host-plugin-kit 0.1.0 → 0.1.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/dev/bin-selftest.mjs +39 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// 脚手架自测:生成一个临时插件,跑它的两套测试,断言全绿。
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
|
|
7
|
+
const dir = mkdtempSync(join(tmpdir(), 'kit-selftest-'));
|
|
8
|
+
let pass = 0, fail = 0;
|
|
9
|
+
const t = (label, fn) => {
|
|
10
|
+
try { fn(); pass++; console.log('PASS ' + label); }
|
|
11
|
+
catch (e) { fail++; console.log('FAIL ' + label + '\n ' + e.message); }
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
t('生成骨架', () => {
|
|
15
|
+
const r = spawnSync(process.execPath, [join(import.meta.dirname, '..', 'new.mjs'), dir, '--name', 'dsh-kitdemo'], { encoding: 'utf8' });
|
|
16
|
+
if (r.status !== 0) throw new Error(r.stderr || r.stdout);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
t('生成的 dev/test.mjs 全绿', () => {
|
|
20
|
+
const r = spawnSync(process.execPath, [join(dir, 'dev', 'test.mjs')], { encoding: 'utf8' });
|
|
21
|
+
if (r.status !== 0) throw new Error((r.stdout || '') + (r.stderr || ''));
|
|
22
|
+
if (!/通过 6 项/.test(r.stdout)) throw new Error('输出不含「通过 6 项」:' + r.stdout.slice(-200));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
t('生成的 host-test/rt.mjs 全绿(真 cordis)', () => {
|
|
26
|
+
const r = spawnSync(process.execPath, [join(dir, 'host-test', 'rt.mjs')], { encoding: 'utf8' });
|
|
27
|
+
if (r.status !== 0) throw new Error((r.stdout || '') + (r.stderr || ''));
|
|
28
|
+
if (!/通过 5 项/.test(r.stdout)) throw new Error('输出不含「通过 5 项」:' + r.stdout.slice(-200));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
t('拒绝覆盖已有插件目录', () => {
|
|
32
|
+
const r = spawnSync(process.execPath, [join(import.meta.dirname, '..', 'new.mjs'), dir, '--name', 'dsh-kitdemo'], { encoding: 'utf8' });
|
|
33
|
+
if (r.status === 0) throw new Error('第二次生成应当失败');
|
|
34
|
+
if (!/已经有 package.json/.test(r.stderr || '')) throw new Error('错误信息不对:' + r.stderr);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
rmSync(dir, { recursive: true, force: true });
|
|
38
|
+
console.log(`\n通过 ${pass} 项${fail ? `,失败 ${fail} 项` : ''}`);
|
|
39
|
+
process.exit(fail ? 1 : 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-host-plugin-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "DSH host 侧插件脚手架:一条命令生成带三层验证(离线单测 / 真 cordis 冒烟 / 发布脚本)的插件骨架,含审批钩子与 dispose 清理模板",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "new.mjs",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"new.mjs",
|
|
12
|
-
"
|
|
12
|
+
"dev/bin-selftest.mjs",
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"engines": {
|