ancient-fences 0.3.0 → 0.3.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 +2 -2
- package/bin/ancient-fences.mjs +29 -4
- package/package.json +1 -1
- package/src/walk.mjs +6 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<picture>
|
|
2
|
-
<source media="(prefers-color-scheme: dark)" srcset="assets/readme-banner.png">
|
|
3
|
-
<img src="assets/readme-banner-light.png" alt="Ancient Fences" width="100%">
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Marcin1000/ancient-fences/main/assets/readme-banner.png">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Marcin1000/ancient-fences/main/assets/readme-banner-light.png" alt="Ancient Fences" width="100%">
|
|
4
4
|
</picture>
|
|
5
5
|
|
|
6
6
|
# Ancient Fences
|
package/bin/ancient-fences.mjs
CHANGED
|
@@ -72,6 +72,22 @@ if (positional.length > 1) {
|
|
|
72
72
|
process.exit(2);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const days = value('--max-age-days');
|
|
76
|
+
if (days !== null && (!Number.isFinite(Number(days)) || Number(days) < 0)) {
|
|
77
|
+
console.error(`ancient-fences: --max-age-days needs a number of days that is zero or more, not "${days}"`);
|
|
78
|
+
process.exit(2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// An empty value is almost always a shell mishap (--report=$FILE with FILE
|
|
82
|
+
// unset). Writing to the current directory, or crashing on it, are both worse
|
|
83
|
+
// than saying what happened.
|
|
84
|
+
for (const f of ['--report', '--tasks', '--cache', '--api-base']) {
|
|
85
|
+
if (flags.includes(`${f}=`)) {
|
|
86
|
+
console.error(`ancient-fences: ${f}= needs a value`);
|
|
87
|
+
process.exit(2);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
const target = resolve(positional[0] ?? process.cwd());
|
|
76
92
|
|
|
77
93
|
// Scanning a path that is not there used to print a clean report saying zero
|
|
@@ -153,15 +169,24 @@ const name = single ? basename(single) : basename(root);
|
|
|
153
169
|
const reportFlag = flags.find((f) => f === '--report' || f.startsWith('--report='));
|
|
154
170
|
if (reportFlag) {
|
|
155
171
|
const out = resolve(value('--report') ?? 'ancient-fences.html');
|
|
156
|
-
await
|
|
157
|
-
console.error(`report written to ${out}`);
|
|
172
|
+
await write(out, renderHtml(fences, summary, name, checking), 'report');
|
|
158
173
|
}
|
|
159
174
|
|
|
160
175
|
const tasksFlag = flags.find((f) => f === '--tasks' || f.startsWith('--tasks='));
|
|
161
176
|
if (tasksFlag) {
|
|
162
177
|
const out = resolve(value('--tasks') ?? 'ancient-fences-tasks.md');
|
|
163
|
-
await
|
|
164
|
-
|
|
178
|
+
await write(out, renderTasks(fences, name, checking), 'agent tasks');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A file that cannot be written is reported as such, not as a stack trace. */
|
|
182
|
+
async function write(out, body, what) {
|
|
183
|
+
try {
|
|
184
|
+
await writeFile(out, body, 'utf8');
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.error(`ancient-fences: could not write ${out}: ${err.message}`);
|
|
187
|
+
process.exit(2);
|
|
188
|
+
}
|
|
189
|
+
console.error(`${what} written to ${out}`);
|
|
165
190
|
}
|
|
166
191
|
|
|
167
192
|
if (has('--json')) {
|
package/package.json
CHANGED
package/src/walk.mjs
CHANGED
|
@@ -78,11 +78,15 @@ export async function* walkFiles(root, { includeGenerated = false, skipped = []
|
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
const generated = looksGenerated(e.name, text);
|
|
81
|
+
// One spelling of a path, whatever the operating system uses. A report
|
|
82
|
+
// that says app\\pwa\\lib on one machine and app/pwa/lib on another is
|
|
83
|
+
// the same report, and code that matches on "/" only works on one of them.
|
|
84
|
+
const path = relative(root, full).replace(/\\/g, '/');
|
|
81
85
|
if (generated && !includeGenerated) {
|
|
82
|
-
skipped.push({ path
|
|
86
|
+
skipped.push({ path, why: generated });
|
|
83
87
|
continue;
|
|
84
88
|
}
|
|
85
|
-
yield { path
|
|
89
|
+
yield { path, text };
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
}
|