etymd 0.8.0 → 0.9.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/CHANGELOG.md +31 -0
- package/dist/{approve-MYOIDCAM.js → approve-HED3NCTE.js} +2 -2
- package/dist/{audit-HO56CZNV.js → audit-Y35XVD6Z.js} +4 -4
- package/dist/{brief-XI4RCNYS.js → brief-2CXAUDNN.js} +2 -2
- package/dist/{chunk-72Y2V7VF.js → chunk-AQM4GYGN.js} +1 -1
- package/dist/{chunk-PRIH2NZF.js → chunk-KGVRZ6WC.js} +772 -677
- package/dist/{chunk-KBYEWHYX.js → chunk-ULM25GWG.js} +1 -1
- package/dist/{chunk-CIRNG736.js → chunk-UN7IAYM6.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/{doctor-ZAAEVVB4.js → doctor-DXXQJ2L3.js} +4 -4
- package/dist/{fleet-6U6XW72I.js → fleet-DPJSZDEY.js} +4 -4
- package/dist/{gates-N25LGIR2.js → gates-RR3V4PII.js} +2 -2
- package/dist/index.js +775 -680
- package/dist/{init-SSAJVX52.js → init-RC35RS5J.js} +2 -2
- package/dist/scan-KX522VKV.js +5 -0
- package/dist/{scan-H2IPH4C3.js → scan-MBXSD5RO.js} +2 -2
- package/dist/{screen-6R6NXDSY.js → screen-EHNK6ANK.js} +28 -4
- package/package.json +1 -1
- package/dist/scan-LVJOAOUJ.js +0 -5
|
@@ -3,8 +3,8 @@ import { applyFiles } from './chunk-EF6BPBG6.js';
|
|
|
3
3
|
import { planWorkflow } from './chunk-WENIJMVV.js';
|
|
4
4
|
import './chunk-D2RI3CCT.js';
|
|
5
5
|
import { theme, renderFacts, print, renderPlan, section, glyph } from './chunk-5BVKFJWM.js';
|
|
6
|
-
import { scanProject } from './chunk-
|
|
7
|
-
import { VERSION } from './chunk-
|
|
6
|
+
import { scanProject } from './chunk-UN7IAYM6.js';
|
|
7
|
+
import { VERSION } from './chunk-AQM4GYGN.js';
|
|
8
8
|
import { writeCachedFacts, deriveProfile, writeBaseline, CACHE_DIR } from './chunk-C7LBUFNU.js';
|
|
9
9
|
import { PACK_VERSION } from './chunk-6DUDIVIC.js';
|
|
10
10
|
import { git, readText } from './chunk-IV3FYVTS.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { print, renderFacts, theme } from './chunk-5BVKFJWM.js';
|
|
3
|
-
import { scanProject } from './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import { scanProject } from './chunk-UN7IAYM6.js';
|
|
4
|
+
import './chunk-AQM4GYGN.js';
|
|
5
5
|
import { writeCachedFacts } from './chunk-C7LBUFNU.js';
|
|
6
6
|
import './chunk-6DUDIVIC.js';
|
|
7
7
|
import './chunk-IV3FYVTS.js';
|
|
@@ -58,6 +58,17 @@ async function walk(dir, out, depth = 0) {
|
|
|
58
58
|
else out.push(abs);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
var BINARY_SNIFF_BYTES = 8192;
|
|
62
|
+
async function readScreenable(p) {
|
|
63
|
+
let buf;
|
|
64
|
+
try {
|
|
65
|
+
buf = await promises.readFile(p);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (buf.subarray(0, BINARY_SNIFF_BYTES).includes(0)) return "binary";
|
|
70
|
+
return buf.toString("utf8");
|
|
71
|
+
}
|
|
61
72
|
async function run(opts) {
|
|
62
73
|
const patternPath = opts.patterns ?? process.env.ETYMD_SCREEN_PATTERNS ?? process.env.PUBLIC_REPO_PATTERNS ?? path.join(process.env.HOME ?? "", ".config", "etymd", "screen-patterns");
|
|
63
74
|
const rawPatterns = await readText(patternPath);
|
|
@@ -83,6 +94,7 @@ async function run(opts) {
|
|
|
83
94
|
const active = self ? patterns.filter((re) => !isSelfName(re, self)) : patterns;
|
|
84
95
|
const hits = [];
|
|
85
96
|
let scanned = 0;
|
|
97
|
+
let skippedBinary = 0;
|
|
86
98
|
if (opts.scope === "message") {
|
|
87
99
|
const file = opts.target;
|
|
88
100
|
if (!file) throw new Error("--message needs the message file path (the commit-msg hook's $1)");
|
|
@@ -97,8 +109,12 @@ async function run(opts) {
|
|
|
97
109
|
const files = [];
|
|
98
110
|
await walk(dir, files);
|
|
99
111
|
for (const f of files) {
|
|
100
|
-
const raw = await
|
|
112
|
+
const raw = await readScreenable(f);
|
|
101
113
|
if (raw === null) continue;
|
|
114
|
+
if (raw === "binary") {
|
|
115
|
+
skippedBinary++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
102
118
|
scanned++;
|
|
103
119
|
hits.push(...screenText(raw, path.relative(dir, f), active, allow));
|
|
104
120
|
}
|
|
@@ -109,14 +125,22 @@ async function run(opts) {
|
|
|
109
125
|
if (rel === ALLOW_FILE || rel === LEGACY_ALLOW_FILE) continue;
|
|
110
126
|
const abs = path.join(opts.cwd, rel);
|
|
111
127
|
if (!await pathExists(abs)) continue;
|
|
112
|
-
const raw = await
|
|
128
|
+
const raw = await readScreenable(abs);
|
|
113
129
|
if (raw === null) continue;
|
|
130
|
+
if (raw === "binary") {
|
|
131
|
+
skippedBinary++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
114
134
|
scanned++;
|
|
115
135
|
hits.push(...screenText(raw, rel, active, allow));
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
if (!hits.length) return;
|
|
119
|
-
section(
|
|
139
|
+
section(
|
|
140
|
+
`Content screen ${theme.dim(
|
|
141
|
+
`\xB7 ${opts.scope} \xB7 ${scanned} file(s)${skippedBinary ? ` \xB7 ${skippedBinary} binary skipped` : ""}`
|
|
142
|
+
)}`
|
|
143
|
+
);
|
|
120
144
|
for (const h of hits) {
|
|
121
145
|
print(` ${theme.warn(h.file)}${theme.dim(`:${h.line}`)} ${theme.dim(`(${h.reason})`)}`);
|
|
122
146
|
print(` ${h.text}`);
|
|
@@ -131,4 +155,4 @@ async function run(opts) {
|
|
|
131
155
|
if (!opts.advisory) process.exitCode = 1;
|
|
132
156
|
}
|
|
133
157
|
|
|
134
|
-
export { isSelfName, run, screenText };
|
|
158
|
+
export { isSelfName, readScreenable, run, screenText };
|
package/package.json
CHANGED