@krizaka/config 0.11.0 → 0.11.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/bin/krizaka-ratchet.mjs +4 -1
- package/package.json +1 -1
- package/ratchet/ratchet.js +7 -1
package/bin/krizaka-ratchet.mjs
CHANGED
|
@@ -13,7 +13,7 @@ source file of app, components, src, lib, hooks and features; compares them with
|
|
|
13
13
|
|
|
14
14
|
(no flag) fail (exit 1) when a counter is above its recorded value
|
|
15
15
|
--init create lint-ratchet.json with the current counters
|
|
16
|
-
--update lower the recorded counters to the current values (never raises them), record the new ones
|
|
16
|
+
--update lower the recorded counters to the current values (never raises them), record the new ones, keep the counters it does not know
|
|
17
17
|
--json machine-readable report on stdout (for CI)
|
|
18
18
|
--root repository root (default: current directory)
|
|
19
19
|
--file ratchet file name (default: lint-ratchet.json)`;
|
|
@@ -82,6 +82,9 @@ try {
|
|
|
82
82
|
else if (result.written) console.log(`${result.decreased.length > 0 ? "Lowered" : "Completed"} ${result.file}: commit it.`);
|
|
83
83
|
else if (result.decreased.length > 0) console.log(`Debt went down: run krizaka-ratchet --update and commit ${result.file}.`);
|
|
84
84
|
else if (result.added.length > 0) console.log(`New counters (${result.added.join(", ")}): run krizaka-ratchet --update and commit ${result.file}.`);
|
|
85
|
+
if (result.unmeasured.length > 0) {
|
|
86
|
+
console.log(` ! not measured by this version, kept as recorded: ${result.unmeasured.join(", ")}`);
|
|
87
|
+
}
|
|
85
88
|
if (!result.ok) {
|
|
86
89
|
console.error(
|
|
87
90
|
`Debt went up (${result.increased.join(", ")}): roles of @krizaka/tailwind and cn() for the UI; @krizaka/query, @krizaka/ui/data-table and @krizaka/ui/form for the stack.`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krizaka/config",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "The shared configuration of every Krizaka JavaScript repository: ESLint flat configs (base, Next.js, the four UI rules, the stack rules, no locale ternary), the « Krizaka first » covered-domains map and the dependency-cruiser preset generated from it (refused imports, cycles, unresolvable imports, dev dependencies), tsconfig bases, Prettier, EditorConfig, and the krizaka-ratchet and krizaka-known-violations debt counters.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"krizaka",
|
package/ratchet/ratchet.js
CHANGED
|
@@ -237,6 +237,7 @@ export class RatchetError extends Error {}
|
|
|
237
237
|
* @property {CounterName[]} increased
|
|
238
238
|
* @property {CounterName[]} decreased
|
|
239
239
|
* @property {CounterName[]} added counters missing from the file (recorded at their current value by --update)
|
|
240
|
+
* @property {string[]} unmeasured counters of the file this version does not measure: kept as recorded by --update, never dropped
|
|
240
241
|
* @property {boolean} written the ratchet file was created, lowered or completed
|
|
241
242
|
*/
|
|
242
243
|
|
|
@@ -295,6 +296,8 @@ export async function runRatchet({ root, mode = "check", globs, file = RATCHET_F
|
|
|
295
296
|
});
|
|
296
297
|
/** @type {CounterName[]} */ const added = recordedFile ? COUNTERS.filter((n) => recordedFile.counters[n] === undefined) : [];
|
|
297
298
|
const recorded = /** @type {Counters} */ ({ ...current, ...recordedFile?.counters });
|
|
299
|
+
/** @type {string[]} */
|
|
300
|
+
const unmeasured = Object.keys(recordedFile?.counters ?? {}).filter((n) => !COUNTERS.includes(/** @type {CounterName} */ (n)));
|
|
298
301
|
|
|
299
302
|
const { report, increased, decreased } = compareCounters(current, recorded);
|
|
300
303
|
|
|
@@ -305,7 +308,9 @@ export async function runRatchet({ root, mode = "check", globs, file = RATCHET_F
|
|
|
305
308
|
} else if (mode === "update" && (decreased.length > 0 || added.length > 0) && recordedFile) {
|
|
306
309
|
const lowered = zero();
|
|
307
310
|
for (const name of COUNTERS) lowered[name] = Math.min(recorded[name], current[name]);
|
|
308
|
-
|
|
311
|
+
// a counter this version does not measure (a repository's own, or a newer preset's) is kept as recorded, never dropped
|
|
312
|
+
const counters = { ...lowered, ...Object.fromEntries(unmeasured.map((name) => [name, /** @type {Record<string, number>} */ (recordedFile?.counters)?.[name]])) };
|
|
313
|
+
writeRatchet(path, { ...recordedFile, stackGlobs: recordedFile.stackGlobs ?? stackGlobs, counters });
|
|
309
314
|
for (const name of decreased) report[name].recorded = lowered[name];
|
|
310
315
|
written = true;
|
|
311
316
|
}
|
|
@@ -323,6 +328,7 @@ export async function runRatchet({ root, mode = "check", globs, file = RATCHET_F
|
|
|
323
328
|
increased,
|
|
324
329
|
decreased,
|
|
325
330
|
added,
|
|
331
|
+
unmeasured,
|
|
326
332
|
written,
|
|
327
333
|
};
|
|
328
334
|
}
|