@macrulez/devtoolz 0.2.1 → 0.3.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/README.md +97 -8
- package/dist/cli.js +185 -9
- package/dist/cli.js.map +1 -1
- package/dist/commands/case-check/report.js +8 -6
- package/dist/commands/case-check/report.js.map +1 -1
- package/dist/commands/circular-imports/report.js +11 -12
- package/dist/commands/circular-imports/report.js.map +1 -1
- package/dist/commands/console-strip/report.js +9 -7
- package/dist/commands/console-strip/report.js.map +1 -1
- package/dist/commands/dead-exports/report.js +6 -4
- package/dist/commands/dead-exports/report.js.map +1 -1
- package/dist/commands/empty-catch/report.js +5 -3
- package/dist/commands/empty-catch/report.js.map +1 -1
- package/dist/commands/exports-doctor/report.js +7 -5
- package/dist/commands/exports-doctor/report.js.map +1 -1
- package/dist/commands/full-check/report.js +24 -30
- package/dist/commands/full-check/report.js.map +1 -1
- package/dist/commands/image-hash/cache.d.ts +14 -0
- package/dist/commands/image-hash/cache.js +40 -0
- package/dist/commands/image-hash/cache.js.map +1 -0
- package/dist/commands/image-hash/core.d.ts +56 -0
- package/dist/commands/image-hash/core.js +293 -0
- package/dist/commands/image-hash/core.js.map +1 -0
- package/dist/commands/image-hash/hash.d.ts +19 -0
- package/dist/commands/image-hash/hash.js +97 -0
- package/dist/commands/image-hash/hash.js.map +1 -0
- package/dist/commands/image-hash/report.d.ts +3 -0
- package/dist/commands/image-hash/report.js +94 -0
- package/dist/commands/image-hash/report.js.map +1 -0
- package/dist/commands/image-hash/run.d.ts +60 -0
- package/dist/commands/image-hash/run.js +315 -0
- package/dist/commands/image-hash/run.js.map +1 -0
- package/dist/commands/image-hash/sharp-loader.d.ts +59 -0
- package/dist/commands/image-hash/sharp-loader.js +79 -0
- package/dist/commands/image-hash/sharp-loader.js.map +1 -0
- package/dist/commands/orphan-tests/report.js +7 -5
- package/dist/commands/orphan-tests/report.js.map +1 -1
- package/dist/commands/readme-check/report.js +7 -5
- package/dist/commands/readme-check/report.js.map +1 -1
- package/dist/commands/scripts-check/report.js +7 -5
- package/dist/commands/scripts-check/report.js.map +1 -1
- package/dist/commands/stale-ts-ignore/report.js +7 -5
- package/dist/commands/stale-ts-ignore/report.js.map +1 -1
- package/dist/commands/strip-comments/report.js +6 -4
- package/dist/commands/strip-comments/report.js.map +1 -1
- package/dist/commands/todo-report/report.js +7 -5
- package/dist/commands/todo-report/report.js.map +1 -1
- package/dist/commands/unused-deps/report.js +7 -5
- package/dist/commands/unused-deps/report.js.map +1 -1
- package/dist/format/colors.d.ts +4 -0
- package/dist/format/colors.js +4 -3
- package/dist/format/colors.js.map +1 -1
- package/dist/format/diff-render.js +2 -2
- package/dist/format/diff-render.js.map +1 -1
- package/dist/format/file-list.d.ts +1 -9
- package/dist/format/file-list.js +5 -16
- package/dist/format/file-list.js.map +1 -1
- package/dist/format/findings-list.d.ts +1 -8
- package/dist/format/findings-list.js +5 -14
- package/dist/format/findings-list.js.map +1 -1
- package/dist/format/style.d.ts +20 -0
- package/dist/format/style.js +36 -0
- package/dist/format/style.js.map +1 -0
- package/dist/format/table.d.ts +8 -0
- package/dist/format/table.js +44 -0
- package/dist/format/table.js.map +1 -0
- package/dist/format/vibes.d.ts +4 -1
- package/dist/format/vibes.js +25 -10
- package/dist/format/vibes.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/walk.d.ts +2 -0
- package/dist/utils/walk.js +4 -3
- package/dist/utils/walk.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Components, type HashEntry, type HashType, type OutputFormat } from './core.js';
|
|
2
|
+
import { type SharpFactory } from './sharp-loader.js';
|
|
3
|
+
export interface ImageHashProgress {
|
|
4
|
+
done: number;
|
|
5
|
+
total: number;
|
|
6
|
+
cached: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ImageHashRunOptions {
|
|
9
|
+
paths: string[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
types: HashType[];
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
extensions?: string[];
|
|
14
|
+
ignoreGlobs?: string[];
|
|
15
|
+
respectGitignore?: boolean;
|
|
16
|
+
components?: Components;
|
|
17
|
+
size?: number;
|
|
18
|
+
maxPixels?: number;
|
|
19
|
+
format?: OutputFormat;
|
|
20
|
+
exportName?: string;
|
|
21
|
+
out?: string;
|
|
22
|
+
perFile?: boolean;
|
|
23
|
+
outDir?: string;
|
|
24
|
+
suffix?: string;
|
|
25
|
+
outExtension?: string;
|
|
26
|
+
keyBase?: string;
|
|
27
|
+
keyPrefix?: string;
|
|
28
|
+
cache?: string;
|
|
29
|
+
update?: boolean;
|
|
30
|
+
prune?: boolean;
|
|
31
|
+
check?: boolean;
|
|
32
|
+
concurrency?: number;
|
|
33
|
+
assumeYes?: boolean;
|
|
34
|
+
dryRun?: boolean;
|
|
35
|
+
sharp?: SharpFactory;
|
|
36
|
+
onProgress?: (progress: ImageHashProgress) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface ImageHashError {
|
|
39
|
+
file: string;
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
export interface OutdatedOutput {
|
|
43
|
+
file: string;
|
|
44
|
+
reason: 'missing' | 'changed';
|
|
45
|
+
}
|
|
46
|
+
export interface ImageHashReport {
|
|
47
|
+
filesScanned: number;
|
|
48
|
+
entries: HashEntry[];
|
|
49
|
+
written: string[];
|
|
50
|
+
errors: ImageHashError[];
|
|
51
|
+
stdout: string | null;
|
|
52
|
+
dryRun: boolean;
|
|
53
|
+
check: boolean;
|
|
54
|
+
checked: number;
|
|
55
|
+
outdated: OutdatedOutput[];
|
|
56
|
+
cached: number;
|
|
57
|
+
pruned: number;
|
|
58
|
+
exitCode: number;
|
|
59
|
+
}
|
|
60
|
+
export declare function runImageHash(options: ImageHashRunOptions): Promise<ImageHashReport>;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { walk } from '../../utils/walk.js';
|
|
4
|
+
import { ALL_TYPES, DEFAULT_BLURHASH_COMPONENTS, DEFAULT_EXPORT_NAME, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SAMPLE_SIZE, ImageHashUsageError, componentsLabel, formatAggregate, formatPerFile, isUrl, normalizeOutExtension, orderTypes, outputFileName, parseAggregate, splitPathArguments, validateExportName, validateSuffix, withUpperCaseVariants, } from './core.js';
|
|
5
|
+
import { cacheHit, emptyCache, loadCache, saveCache } from './cache.js';
|
|
6
|
+
import { computeHashes, friendlyMessage } from './hash.js';
|
|
7
|
+
import { loadSharp } from './sharp-loader.js';
|
|
8
|
+
const DOWNLOAD_TIMEOUT_MS = 30000;
|
|
9
|
+
const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
10
|
+
function toPosix(path) {
|
|
11
|
+
return path.split('\\').join('/');
|
|
12
|
+
}
|
|
13
|
+
function urlBaseName(url) {
|
|
14
|
+
try {
|
|
15
|
+
const name = basename(decodeURIComponent(new URL(url).pathname));
|
|
16
|
+
return name === '' ? 'image' : name;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return 'image';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function collectImages(options, errors) {
|
|
23
|
+
const extensions = withUpperCaseVariants(options.extensions ?? DEFAULT_IMAGE_EXTENSIONS);
|
|
24
|
+
const images = [];
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
for (const input of splitPathArguments(options.paths)) {
|
|
27
|
+
if (isUrl(input)) {
|
|
28
|
+
if (!seen.has(input)) {
|
|
29
|
+
seen.add(input);
|
|
30
|
+
images.push({ abs: input, root: '', url: true });
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const abs = resolve(options.cwd, input);
|
|
35
|
+
const stat = statSync(abs, { throwIfNoEntry: false });
|
|
36
|
+
if (!stat) {
|
|
37
|
+
errors.push({ file: input, message: 'path does not exist' });
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const root = stat.isDirectory() ? abs : dirname(abs);
|
|
41
|
+
const found = walk([abs], {
|
|
42
|
+
cwd: options.cwd,
|
|
43
|
+
extensions,
|
|
44
|
+
ignoreGlobs: options.ignoreGlobs ?? [],
|
|
45
|
+
recursive: options.recursive ?? false,
|
|
46
|
+
...(options.respectGitignore !== undefined
|
|
47
|
+
? { respectGitignore: options.respectGitignore }
|
|
48
|
+
: {}),
|
|
49
|
+
});
|
|
50
|
+
for (const file of found) {
|
|
51
|
+
if (seen.has(file))
|
|
52
|
+
continue;
|
|
53
|
+
seen.add(file);
|
|
54
|
+
images.push({ abs: file, root, url: false });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return images.sort((a, b) => a.abs.localeCompare(b.abs));
|
|
58
|
+
}
|
|
59
|
+
async function fetchImage(url) {
|
|
60
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) }).catch((error) => {
|
|
61
|
+
const cause = error.cause;
|
|
62
|
+
const reason = cause?.code ??
|
|
63
|
+
cause?.errors?.[0]?.code ??
|
|
64
|
+
(error instanceof Error ? error.message : String(error));
|
|
65
|
+
throw new Error(`download failed: ${reason}`);
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok)
|
|
68
|
+
throw new Error(`download failed: HTTP ${response.status}`);
|
|
69
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
70
|
+
if (bytes.length > MAX_DOWNLOAD_BYTES)
|
|
71
|
+
throw new Error('download is larger than 100 MB');
|
|
72
|
+
return bytes;
|
|
73
|
+
}
|
|
74
|
+
async function mapWithConcurrency(items, limit, task) {
|
|
75
|
+
const results = new Array(items.length);
|
|
76
|
+
let next = 0;
|
|
77
|
+
const workers = Array.from({ length: Math.max(1, Math.min(limit, items.length)) }, async () => {
|
|
78
|
+
while (next < items.length) {
|
|
79
|
+
const index = next++;
|
|
80
|
+
results[index] = await task(items[index]);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
await Promise.all(workers);
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
function writeText(path, content) {
|
|
87
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
88
|
+
writeFileSync(path, content);
|
|
89
|
+
}
|
|
90
|
+
function normalizeNewlines(text) {
|
|
91
|
+
return text.replace(/\r\n/g, '\n');
|
|
92
|
+
}
|
|
93
|
+
function pick(computed, key, types) {
|
|
94
|
+
const entry = { file: key, width: computed.width, height: computed.height };
|
|
95
|
+
for (const type of types) {
|
|
96
|
+
const value = computed[type];
|
|
97
|
+
if (value !== undefined)
|
|
98
|
+
entry[type] = value;
|
|
99
|
+
}
|
|
100
|
+
return entry;
|
|
101
|
+
}
|
|
102
|
+
function validate(options, perFile) {
|
|
103
|
+
if (options.out !== undefined && perFile) {
|
|
104
|
+
throw new ImageHashUsageError('--out cannot be combined with --per-file or --out-dir');
|
|
105
|
+
}
|
|
106
|
+
if (options.check) {
|
|
107
|
+
if (options.out === undefined && !perFile) {
|
|
108
|
+
throw new ImageHashUsageError('--check needs the output to compare against: pass -o, --per-file or --out-dir');
|
|
109
|
+
}
|
|
110
|
+
if (options.dryRun)
|
|
111
|
+
throw new ImageHashUsageError('--check cannot be combined with --dry-run');
|
|
112
|
+
if (options.update)
|
|
113
|
+
throw new ImageHashUsageError('--check cannot be combined with --update');
|
|
114
|
+
}
|
|
115
|
+
if (options.update && (options.out === undefined || perFile)) {
|
|
116
|
+
throw new ImageHashUsageError('--update merges into the single file given with -o');
|
|
117
|
+
}
|
|
118
|
+
if (options.prune && !options.update) {
|
|
119
|
+
throw new ImageHashUsageError('--prune only makes sense together with --update');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export async function runImageHash(options) {
|
|
123
|
+
const format = options.format ?? 'json';
|
|
124
|
+
const exportName = validateExportName(options.exportName ?? DEFAULT_EXPORT_NAME);
|
|
125
|
+
const perFile = Boolean(options.perFile) || options.outDir !== undefined;
|
|
126
|
+
const dryRun = Boolean(options.dryRun);
|
|
127
|
+
const check = Boolean(options.check);
|
|
128
|
+
validate(options, perFile);
|
|
129
|
+
const suffix = validateSuffix(options.suffix, options.types, format);
|
|
130
|
+
const outExtension = normalizeOutExtension(options.outExtension, format);
|
|
131
|
+
const size = options.size ?? DEFAULT_SAMPLE_SIZE;
|
|
132
|
+
const components = options.components ?? DEFAULT_BLURHASH_COMPONENTS;
|
|
133
|
+
const params = `${size}|${componentsLabel(components)}`;
|
|
134
|
+
const keyBase = resolve(options.cwd, options.keyBase ?? '.');
|
|
135
|
+
const keyPrefix = options.keyPrefix ?? '';
|
|
136
|
+
const keyOf = (source) => source.url ? source.abs : `${keyPrefix}${toPosix(relative(keyBase, source.abs))}`;
|
|
137
|
+
const errors = [];
|
|
138
|
+
const images = collectImages(options, errors);
|
|
139
|
+
const cachePath = options.cache !== undefined ? resolve(options.cwd, options.cache) : null;
|
|
140
|
+
const cache = cachePath ? loadCache(cachePath) : emptyCache();
|
|
141
|
+
const newRecords = {};
|
|
142
|
+
let sharpPromise = null;
|
|
143
|
+
const loadConfiguredSharp = async () => {
|
|
144
|
+
const loaded = options.sharp ??
|
|
145
|
+
(await loadSharp({ assumeYes: options.assumeYes ?? false, cwd: options.cwd }));
|
|
146
|
+
loaded.cache?.(false);
|
|
147
|
+
return loaded;
|
|
148
|
+
};
|
|
149
|
+
const getSharp = () => {
|
|
150
|
+
if (!sharpPromise)
|
|
151
|
+
sharpPromise = loadConfiguredSharp();
|
|
152
|
+
return sharpPromise;
|
|
153
|
+
};
|
|
154
|
+
const computeOptions = {
|
|
155
|
+
types: options.types,
|
|
156
|
+
size,
|
|
157
|
+
components,
|
|
158
|
+
...(options.maxPixels !== undefined ? { maxPixels: options.maxPixels } : {}),
|
|
159
|
+
};
|
|
160
|
+
let done = 0;
|
|
161
|
+
let cached = 0;
|
|
162
|
+
const total = images.length;
|
|
163
|
+
const entries = [];
|
|
164
|
+
const sources = new Map();
|
|
165
|
+
const results = await mapWithConcurrency(images, options.concurrency ?? 4, async (image) => {
|
|
166
|
+
const key = keyOf(image);
|
|
167
|
+
const display = image.url ? image.abs : toPosix(relative(options.cwd, image.abs));
|
|
168
|
+
try {
|
|
169
|
+
let computed;
|
|
170
|
+
if (image.url) {
|
|
171
|
+
const bytes = await fetchImage(image.abs);
|
|
172
|
+
computed = await computeHashes(await getSharp(), bytes, computeOptions);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const stat = statSync(image.abs);
|
|
176
|
+
const sig = `${stat.mtimeMs}:${stat.size}`;
|
|
177
|
+
const cacheKey = toPosix(relative(options.cwd, image.abs));
|
|
178
|
+
const previous = cache.files[cacheKey];
|
|
179
|
+
const hit = cachePath ? cacheHit(previous, sig, params, options.types) : null;
|
|
180
|
+
if (hit) {
|
|
181
|
+
computed = hit;
|
|
182
|
+
cached++;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
computed = await computeHashes(await getSharp(), image.abs, computeOptions);
|
|
186
|
+
const base = previous && previous.sig === sig && previous.params === params ? previous : {};
|
|
187
|
+
newRecords[cacheKey] = { ...base, ...computed, sig, params };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { image, entry: pick(computed, key, options.types) };
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return { image, error: { file: display, message: friendlyMessage(error, options.maxPixels) } };
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
done++;
|
|
197
|
+
options.onProgress?.({ done, total, cached });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
for (const result of results) {
|
|
201
|
+
if ('entry' in result) {
|
|
202
|
+
entries.push(result.entry);
|
|
203
|
+
sources.set(result.entry.file, result.image);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
errors.push(result.error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
entries.sort((a, b) => a.file.localeCompare(b.file));
|
|
210
|
+
const outputs = [];
|
|
211
|
+
let stdout = null;
|
|
212
|
+
let pruned = 0;
|
|
213
|
+
if (perFile) {
|
|
214
|
+
const claimed = new Set();
|
|
215
|
+
const outDirAbs = options.outDir !== undefined ? resolve(options.cwd, options.outDir) : null;
|
|
216
|
+
for (const entry of entries) {
|
|
217
|
+
const source = sources.get(entry.file);
|
|
218
|
+
if (source.url && outDirAbs === null) {
|
|
219
|
+
errors.push({
|
|
220
|
+
file: entry.file,
|
|
221
|
+
message: 'a URL input needs --out-dir for its output file',
|
|
222
|
+
});
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const targetDir = source.url
|
|
226
|
+
? outDirAbs
|
|
227
|
+
: outDirAbs !== null
|
|
228
|
+
? join(outDirAbs, relative(source.root, dirname(source.abs)))
|
|
229
|
+
: dirname(source.abs);
|
|
230
|
+
const imageName = source.url ? urlBaseName(source.abs) : source.abs;
|
|
231
|
+
for (const unit of formatPerFile(entry, options.types, format)) {
|
|
232
|
+
const target = join(targetDir, outputFileName(imageName, suffix, unit.token, outExtension));
|
|
233
|
+
if (claimed.has(target)) {
|
|
234
|
+
errors.push({ file: entry.file, message: `output ${target} is already taken` });
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
claimed.add(target);
|
|
238
|
+
outputs.push({ path: target, content: unit.content });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
let outputEntries = entries;
|
|
244
|
+
if (options.update) {
|
|
245
|
+
const target = resolve(options.cwd, options.out);
|
|
246
|
+
const existing = existsSync(target)
|
|
247
|
+
? parseAggregate(readFileSync(target, 'utf8'), format)
|
|
248
|
+
: [];
|
|
249
|
+
const merged = new Map(existing.map((entry) => [entry.file, entry]));
|
|
250
|
+
const freshKeys = new Set(entries.map((entry) => entry.file));
|
|
251
|
+
for (const entry of entries)
|
|
252
|
+
merged.set(entry.file, { ...merged.get(entry.file), ...entry });
|
|
253
|
+
if (options.prune) {
|
|
254
|
+
for (const key of [...merged.keys()]) {
|
|
255
|
+
if (freshKeys.has(key) || isUrl(key))
|
|
256
|
+
continue;
|
|
257
|
+
const local = key.startsWith(keyPrefix) ? key.slice(keyPrefix.length) : key;
|
|
258
|
+
if (!existsSync(resolve(keyBase, local))) {
|
|
259
|
+
merged.delete(key);
|
|
260
|
+
pruned++;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
outputEntries = [...merged.values()].sort((a, b) => a.file.localeCompare(b.file));
|
|
265
|
+
}
|
|
266
|
+
const outputTypes = options.update
|
|
267
|
+
? orderTypes([
|
|
268
|
+
...options.types,
|
|
269
|
+
...outputEntries.flatMap((entry) => ALL_TYPES.filter((type) => entry[type] !== undefined)),
|
|
270
|
+
])
|
|
271
|
+
: options.types;
|
|
272
|
+
const content = formatAggregate(outputEntries, outputTypes, format, exportName);
|
|
273
|
+
if (options.out !== undefined) {
|
|
274
|
+
outputs.push({ path: resolve(options.cwd, options.out), content });
|
|
275
|
+
}
|
|
276
|
+
else if (!dryRun && !check) {
|
|
277
|
+
stdout = content;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const written = [];
|
|
281
|
+
const outdated = [];
|
|
282
|
+
for (const output of outputs) {
|
|
283
|
+
const display = toPosix(relative(options.cwd, output.path));
|
|
284
|
+
if (check) {
|
|
285
|
+
if (!existsSync(output.path)) {
|
|
286
|
+
outdated.push({ file: display, reason: 'missing' });
|
|
287
|
+
}
|
|
288
|
+
else if (normalizeNewlines(readFileSync(output.path, 'utf8')) !== normalizeNewlines(output.content)) {
|
|
289
|
+
outdated.push({ file: display, reason: 'changed' });
|
|
290
|
+
}
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (!dryRun)
|
|
294
|
+
writeText(output.path, output.content);
|
|
295
|
+
written.push(display);
|
|
296
|
+
}
|
|
297
|
+
if (cachePath && !dryRun && !check && Object.keys(newRecords).length > 0) {
|
|
298
|
+
saveCache(cachePath, { version: 1, files: { ...cache.files, ...newRecords } });
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
filesScanned: images.length,
|
|
302
|
+
entries,
|
|
303
|
+
written,
|
|
304
|
+
errors,
|
|
305
|
+
stdout,
|
|
306
|
+
dryRun,
|
|
307
|
+
check,
|
|
308
|
+
checked: check ? outputs.length : 0,
|
|
309
|
+
outdated,
|
|
310
|
+
cached,
|
|
311
|
+
pruned,
|
|
312
|
+
exitCode: errors.length > 0 || outdated.length > 0 ? 1 : 0,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/image-hash/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACtF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EACL,SAAS,EACT,2BAA2B,EAC3B,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,aAAa,EACb,KAAK,EACL,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,GAKtB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAuB,MAAM,WAAW,CAAA;AAC/E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AC,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,UAAU,EAAE,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,MAAM;QAC3B,OAAO;QACP,OAAO;QACP,MAAM;QACN,MAAM;QACN,MAAM;QACN,KAAK;QACL,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnC,QAAQ;QACR,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const SHARP_SPEC = "sharp@^0.35.5";
|
|
2
|
+
export declare const MANAGED_DEPS_DIR: string;
|
|
3
|
+
export interface RawImage {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
info: {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface SharpImage {
|
|
11
|
+
metadata(): Promise<{
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
orientation?: number;
|
|
15
|
+
}>;
|
|
16
|
+
rotate(): SharpImage;
|
|
17
|
+
resize(options: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
fit: 'inside';
|
|
21
|
+
withoutEnlargement: boolean;
|
|
22
|
+
}): SharpImage;
|
|
23
|
+
toColourspace(colourspace: string): SharpImage;
|
|
24
|
+
ensureAlpha(): SharpImage;
|
|
25
|
+
raw(): SharpImage;
|
|
26
|
+
png(options?: {
|
|
27
|
+
compressionLevel?: number;
|
|
28
|
+
}): SharpImage;
|
|
29
|
+
toBuffer(): Promise<Uint8Array>;
|
|
30
|
+
toBuffer(options: {
|
|
31
|
+
resolveWithObject: true;
|
|
32
|
+
}): Promise<RawImage>;
|
|
33
|
+
}
|
|
34
|
+
export interface SharpInputOptions {
|
|
35
|
+
failOn?: 'none' | 'truncated';
|
|
36
|
+
limitInputPixels?: number | false;
|
|
37
|
+
raw?: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
channels: 4;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface SharpFactory {
|
|
44
|
+
(input: string | Uint8Array, options?: SharpInputOptions): SharpImage;
|
|
45
|
+
cache?: (options: boolean) => unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface SharpLoaderDeps {
|
|
48
|
+
resolveBundled: () => SharpFactory | null;
|
|
49
|
+
resolveFromCwd: (cwd: string) => SharpFactory | null;
|
|
50
|
+
resolveManaged: () => SharpFactory | null;
|
|
51
|
+
install: () => boolean;
|
|
52
|
+
confirm: (question: string) => Promise<boolean>;
|
|
53
|
+
interactive: boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare function defaultSharpLoaderDeps(): SharpLoaderDeps;
|
|
56
|
+
export declare function loadSharp(options: {
|
|
57
|
+
assumeYes?: boolean;
|
|
58
|
+
cwd?: string;
|
|
59
|
+
}, deps?: SharpLoaderDeps): Promise<SharpFactory>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
import { ImageHashUsageError } from './core.js';
|
|
8
|
+
export const SHARP_SPEC = 'sharp@^0.35.5';
|
|
9
|
+
export const MANAGED_DEPS_DIR = join(homedir(), '.devtoolz', 'deps');
|
|
10
|
+
function toFactory(loaded) {
|
|
11
|
+
if (typeof loaded === 'function')
|
|
12
|
+
return loaded;
|
|
13
|
+
return loaded.default;
|
|
14
|
+
}
|
|
15
|
+
function tryRequire(requireFrom) {
|
|
16
|
+
try {
|
|
17
|
+
return toFactory(createRequire(requireFrom)('sharp'));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function installIntoManagedDir() {
|
|
24
|
+
mkdirSync(MANAGED_DEPS_DIR, { recursive: true });
|
|
25
|
+
const manifest = join(MANAGED_DEPS_DIR, 'package.json');
|
|
26
|
+
if (!existsSync(manifest)) {
|
|
27
|
+
writeFileSync(manifest, JSON.stringify({ name: 'devtoolz-deps', private: true }, null, 2));
|
|
28
|
+
}
|
|
29
|
+
const result = spawnSync('npm', ['install', SHARP_SPEC, '--prefix', MANAGED_DEPS_DIR, '--no-audit', '--no-fund'], { stdio: ['ignore', 'inherit', 'inherit'], shell: process.platform === 'win32' });
|
|
30
|
+
return result.status === 0;
|
|
31
|
+
}
|
|
32
|
+
async function askYesNo(question) {
|
|
33
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
34
|
+
let answer;
|
|
35
|
+
try {
|
|
36
|
+
answer = (await rl.question(`${question} [Y/n]: `)).trim().toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
rl.close();
|
|
40
|
+
}
|
|
41
|
+
return answer === '' || answer === 'y' || answer === 'yes';
|
|
42
|
+
}
|
|
43
|
+
export function defaultSharpLoaderDeps() {
|
|
44
|
+
return {
|
|
45
|
+
resolveBundled: () => tryRequire(import.meta.url),
|
|
46
|
+
resolveFromCwd: (cwd) => tryRequire(join(cwd, 'package.json')),
|
|
47
|
+
resolveManaged: () => tryRequire(join(MANAGED_DEPS_DIR, 'package.json')),
|
|
48
|
+
install: installIntoManagedDir,
|
|
49
|
+
confirm: askYesNo,
|
|
50
|
+
interactive: Boolean(process.stdin.isTTY) && Boolean(process.stderr.isTTY),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export async function loadSharp(options, deps = defaultSharpLoaderDeps()) {
|
|
54
|
+
const existing = deps.resolveBundled() ??
|
|
55
|
+
(options.cwd !== undefined ? deps.resolveFromCwd(options.cwd) : null) ??
|
|
56
|
+
deps.resolveManaged();
|
|
57
|
+
if (existing)
|
|
58
|
+
return existing;
|
|
59
|
+
const manualHint = `Install it yourself with: npm install ${SHARP_SPEC}`;
|
|
60
|
+
if (!options.assumeYes) {
|
|
61
|
+
if (!deps.interactive) {
|
|
62
|
+
throw new ImageHashUsageError(`image-hash needs the "sharp" image library, and it is not installed. ` +
|
|
63
|
+
`Run with --yes to let devtoolz install it into ${MANAGED_DEPS_DIR}. ${manualHint}`);
|
|
64
|
+
}
|
|
65
|
+
const agreed = await deps.confirm(`image-hash needs the "sharp" image library (native, ~30 MB). Install it into ${MANAGED_DEPS_DIR}?`);
|
|
66
|
+
if (!agreed) {
|
|
67
|
+
throw new ImageHashUsageError(`"sharp" was not installed, nothing to do. ${manualHint}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!deps.install()) {
|
|
71
|
+
throw new ImageHashUsageError(`Installing "sharp" failed. ${manualHint}`);
|
|
72
|
+
}
|
|
73
|
+
const installed = deps.resolveManaged();
|
|
74
|
+
if (!installed) {
|
|
75
|
+
throw new ImageHashUsageError(`"sharp" was installed but could not be loaded on this platform. ${manualHint}`);
|
|
76
|
+
}
|
|
77
|
+
return installed;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=sharp-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharp-loader.js","sourceRoot":"","sources":["../../../src/commands/image-hash/sharp-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa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,OAA8C,EAC9C,OAAwB,sBAAsB,EAAE;IAEhD,MAAM,QAAQ,GACZ,IAAI,CAAC,cAAc,EAAE;QACrB,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE7B,MAAM,UAAU,GAAG,yCAAyC,UAAU,EAAE,CAAA;IACxE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,mBAAmB,CAC3B,uEAAuE;gBACrE,kDAAkD,gBAAgB,KAAK,UAAU,EAAE,CACtF,CAAA;QACH,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,gFAAgF,gBAAgB,GAAG,CACpG,CAAA;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAmB,CAAC,6CAA6C,UAAU,EAAE,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAAC,8BAA8B,UAAU,EAAE,CAAC,CAAA;IAC3E,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;IACvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,mBAAmB,CAC3B,mEAAmE,UAAU,EAAE,CAChF,CAAA;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { banner, cleanCelebration } from '../../format/vibes.js';
|
|
2
2
|
import { formatFindingsRows } from '../../format/findings-list.js';
|
|
3
|
+
import { createStyle } from '../../format/style.js';
|
|
3
4
|
export function renderOrphanTestsReport(report, options = {}) {
|
|
5
|
+
const s = createStyle(options);
|
|
4
6
|
if (report.error) {
|
|
5
7
|
const lines = [];
|
|
6
8
|
if (!options.quiet && !options.plain)
|
|
7
|
-
lines.push(banner(), '');
|
|
8
|
-
lines.push(`Could not run orphan-tests: ${report.error}`);
|
|
9
|
+
lines.push(banner(options), '');
|
|
10
|
+
lines.push(s.error(`Could not run orphan-tests: ${report.error}`));
|
|
9
11
|
return lines.join('\n');
|
|
10
12
|
}
|
|
11
13
|
const isClean = report.findings.length === 0;
|
|
@@ -13,13 +15,13 @@ export function renderOrphanTestsReport(report, options = {}) {
|
|
|
13
15
|
return '';
|
|
14
16
|
const lines = [];
|
|
15
17
|
if (!options.quiet && !options.plain)
|
|
16
|
-
lines.push(banner(), '');
|
|
17
|
-
lines.push(`Scanned ${report.filesScanned} file${report.filesScanned === 1 ? '' : 's'}
|
|
18
|
+
lines.push(banner(options), '');
|
|
19
|
+
lines.push(s.info(`Scanned ${report.filesScanned} file${report.filesScanned === 1 ? '' : 's'}.`), '');
|
|
18
20
|
if (isClean) {
|
|
19
21
|
lines.push(cleanCelebration(options));
|
|
20
22
|
return lines.join('\n');
|
|
21
23
|
}
|
|
22
|
-
lines.push(`${report.findings.length} orphan test${report.findings.length === 1 ? '' : 's'} found:`);
|
|
24
|
+
lines.push(s.problem(`${report.findings.length} orphan test${report.findings.length === 1 ? '' : 's'} found:`));
|
|
23
25
|
lines.push(...formatFindingsRows(report.findings.map((f) => ({
|
|
24
26
|
location: f.file,
|
|
25
27
|
name: 'orphan',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/commands/orphan-tests/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;
|
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C,CAAC,GAAG,GAAG,CAAC,EACrF,EAAE,CACH,CAAA;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;QACrC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,CAAC,CAAC,OAAO,CACP,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,eAAe,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CACzF,CACF,CAAA;IACD,KAAK,CAAC,IAAI,CACR,GAAG,kBAAkB,CACnB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,QAAQ,EAAE,CAAC,CAAC,IAAI;QAChB,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,mCAAmC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;KACxE,CAAC,CAAC,EACH,OAAO,CACR,CACF,CAAA;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { banner, cleanCelebration } from '../../format/vibes.js';
|
|
2
2
|
import { formatFindingsRows } from '../../format/findings-list.js';
|
|
3
|
+
import { createStyle } from '../../format/style.js';
|
|
3
4
|
export function renderReadmeCheckReport(report, options = {}) {
|
|
5
|
+
const s = createStyle(options);
|
|
4
6
|
if (report.error) {
|
|
5
7
|
const lines = [];
|
|
6
8
|
if (!options.quiet && !options.plain)
|
|
7
|
-
lines.push(banner(), '');
|
|
8
|
-
lines.push(`Could not run readme-check: ${report.error}`);
|
|
9
|
+
lines.push(banner(options), '');
|
|
10
|
+
lines.push(s.error(`Could not run readme-check: ${report.error}`));
|
|
9
11
|
return lines.join('\n');
|
|
10
12
|
}
|
|
11
13
|
const blocksChecked = report.fileResults.reduce((sum, f) => sum + f.blocksChecked, 0);
|
|
@@ -14,13 +16,13 @@ export function renderReadmeCheckReport(report, options = {}) {
|
|
|
14
16
|
return '';
|
|
15
17
|
const lines = [];
|
|
16
18
|
if (!options.quiet && !options.plain)
|
|
17
|
-
lines.push(banner(), '');
|
|
18
|
-
lines.push(`Typechecked ${blocksChecked} code block${blocksChecked === 1 ? '' : 's'} across ${report.fileResults.length} file${report.fileResults.length === 1 ? '' : 's'}
|
|
19
|
+
lines.push(banner(options), '');
|
|
20
|
+
lines.push(s.info(`Typechecked ${blocksChecked} code block${blocksChecked === 1 ? '' : 's'} across ${report.fileResults.length} file${report.fileResults.length === 1 ? '' : 's'}.`), '');
|
|
19
21
|
if (isClean) {
|
|
20
22
|
lines.push(cleanCelebration(options));
|
|
21
23
|
return lines.join('\n');
|
|
22
24
|
}
|
|
23
|
-
lines.push(`${report.findings.length} problem${report.findings.length === 1 ? '' : 's'} found:`);
|
|
25
|
+
lines.push(s.problem(`${report.findings.length} problem${report.findings.length === 1 ? '' : 's'} found:`));
|
|
24
26
|
lines.push(...formatFindingsRows(report.findings.map((f) => ({
|
|
25
27
|
location: `${f.file}:${f.line}:${f.column}`,
|
|
26
28
|
name: f.lang,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/commands/readme-check/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/commands/readme-check/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B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