dsh-hashcheck 0.1.0 → 0.1.2
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 +30 -0
- package/package.json +11 -2
- package/src/index.js +7 -1
package/README.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
A manifest records the SHA-256 of every file you delivered. Verification says which bytes moved since — a changed file, a missing file, and a file that was delivered but never listed are three different failures, and only the first two get caught by eyeballing a folder.
|
|
4
4
|
|
|
5
|
+
<!-- example:start -->
|
|
6
|
+
## 真实输入输出
|
|
7
|
+
|
|
8
|
+
输入:
|
|
9
|
+
|
|
10
|
+
```markdown
|
|
11
|
+
delivery/
|
|
12
|
+
├── report.md ← 交付后有人改了一个字
|
|
13
|
+
├── nested.csv
|
|
14
|
+
└── hashcheck.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
真实运行(逐字输出,由测试与工具保持同步):
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
$ dsh-hashcheck build ./delivery
|
|
21
|
+
delivery/hashcheck.json: 2 files, sha256
|
|
22
|
+
$ dsh-hashcheck verify delivery/hashcheck.json --dir ./delivery
|
|
23
|
+
ok: 2 checked, 0 errors, 1 warnings
|
|
24
|
+
|
|
25
|
+
# 有人改了 report.md 之后再验:
|
|
26
|
+
$ dsh-hashcheck verify delivery/hashcheck.json --dir ./delivery
|
|
27
|
+
error changed report.md changed: expected d2f56516fd6c…, found 99527e917f49…
|
|
28
|
+
warn unlisted hashcheck.json is on disk but not in the manifest
|
|
29
|
+
fail: 2 checked, 1 errors, 1 warnings
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
出口码:改前 0,改后 1。
|
|
33
|
+
<!-- example:start -->
|
|
34
|
+
|
|
5
35
|
```bash
|
|
6
36
|
npx dsh-hashcheck build ./delivery --out delivery/hashcheck.json --ignore node_modules
|
|
7
37
|
npx dsh-hashcheck verify delivery/hashcheck.json --dir ./delivery
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hashcheck",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "SHA-256 manifests for delivered files: build once, verify anywhere, and say exactly which bytes moved instead of 'looks fine'.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -26,7 +26,16 @@
|
|
|
26
26
|
"README.md",
|
|
27
27
|
"LICENSE"
|
|
28
28
|
],
|
|
29
|
-
"keywords": [
|
|
29
|
+
"keywords": [
|
|
30
|
+
"dsh",
|
|
31
|
+
"dsh-plugin",
|
|
32
|
+
"deepseek-harness",
|
|
33
|
+
"sha256",
|
|
34
|
+
"hash-manifest",
|
|
35
|
+
"delivery-verification",
|
|
36
|
+
"交付校验",
|
|
37
|
+
"文件哈希"
|
|
38
|
+
],
|
|
30
39
|
"license": "MIT",
|
|
31
40
|
"author": "zjukop3",
|
|
32
41
|
"repository": {
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
import { createHash } from 'node:crypto'
|
|
6
6
|
import { readdir, readFile, stat } from 'node:fs/promises'
|
|
7
7
|
import { join, relative, sep } from 'node:path'
|
|
8
|
+
import { createRequire } from 'node:module'
|
|
9
|
+
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
export const packageVersion = require('../package.json').version
|
|
8
12
|
|
|
9
13
|
export const name = 'hashcheck'
|
|
10
14
|
export const inject = ['webServer']
|
|
@@ -55,6 +59,7 @@ export async function buildManifest(directory, options = {}) {
|
|
|
55
59
|
// what was excluded would report every excluded file as unlisted.
|
|
56
60
|
ignore: [...(options.ignore || [])].sort(),
|
|
57
61
|
files: entries,
|
|
62
|
+
packageVersion,
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
|
@@ -107,7 +112,7 @@ export async function verifyManifest(manifest, directory, { reportExtra = true,
|
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
const errors = findings.filter(finding => finding.level === 'error').length
|
|
110
|
-
return { ok: errors === 0, checked: listed.length, errors, warnings: findings.length - errors, findings }
|
|
115
|
+
return { ok: errors === 0, checked: listed.length, errors, warnings: findings.length - errors, findings, packageVersion }
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
// The host route is a thin wrapper: the CLI and the route call the same
|
|
@@ -139,4 +144,5 @@ export function apply(ctx, config = {}) {
|
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
ctx.effect(() => ctx.webServer.register({ kind: 'prefix', path: prefix, handler }))
|
|
147
|
+
ctx.effect(() => ctx.logger.info(`hashcheck ${packageVersion} loaded`))
|
|
142
148
|
}
|