toolmenu 0.11.0 → 0.12.0
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 +77 -13
- package/dist/auth.js +8 -1
- package/dist/auto.d.ts +1 -1
- package/dist/auto.js +24 -1
- package/dist/breakdown.d.ts +33 -6
- package/dist/breakdown.js +129 -16
- package/dist/catalog.js +3 -3
- package/dist/cli.js +39 -11
- package/dist/compare.js +20 -5
- package/dist/diff.d.ts +13 -1
- package/dist/diff.js +671 -72
- package/dist/failures.d.ts +46 -0
- package/dist/failures.js +86 -0
- package/dist/init.d.ts +8 -3
- package/dist/init.js +14 -7
- package/dist/probe.d.ts +15 -3
- package/dist/probe.js +35 -11
- package/dist/rules/description.js +4 -1
- package/dist/rules/determinism.js +2 -1
- package/dist/rules/index.js +3 -1
- package/dist/rules/spec.d.ts +2 -0
- package/dist/rules/spec.js +29 -0
- package/dist/semver.js +1 -1
- package/dist/session.d.ts +42 -3
- package/dist/session.js +354 -40
- package/dist/snapshot.js +8 -5
- package/package.json +1 -1
package/dist/compare.js
CHANGED
|
@@ -35,18 +35,33 @@ export function toolDiff(before, after) {
|
|
|
35
35
|
kinds.push('serialization');
|
|
36
36
|
return kinds;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Each tool's identity in a list: its name, and for a name that repeats, which
|
|
40
|
+
* occurrence it is. The second `search` pairs with the second `search`, so a
|
|
41
|
+
* duplicate (menu/duplicate-name) isn't also read as a reorder.
|
|
42
|
+
*/
|
|
43
|
+
function identities(tools) {
|
|
44
|
+
const seen = new Map();
|
|
45
|
+
return tools.map((t) => {
|
|
46
|
+
const n = seen.get(t.name) ?? 0;
|
|
47
|
+
seen.set(t.name, n + 1);
|
|
48
|
+
return n === 0 ? t.name : `${t.name}\u0000${n}`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
38
51
|
export function compareMenus(before, after) {
|
|
39
52
|
const changes = [];
|
|
40
|
-
const
|
|
41
|
-
const
|
|
53
|
+
const beforeIds = identities(before);
|
|
54
|
+
const afterIds = identities(after);
|
|
55
|
+
const beforeById = new Map(before.map((t, i) => [beforeIds[i], { tool: t, index: i }]));
|
|
56
|
+
const afterIdSet = new Set(afterIds);
|
|
42
57
|
before.forEach((t, i) => {
|
|
43
|
-
if (!
|
|
58
|
+
if (!afterIdSet.has(beforeIds[i]))
|
|
44
59
|
changes.push({ kind: 'removed', tool: t.name, position: i });
|
|
45
60
|
});
|
|
46
61
|
// Tools present in both: the ones outside the longest run that kept its
|
|
47
62
|
// relative order are the ones that moved.
|
|
48
63
|
const common = after
|
|
49
|
-
.map((t, i) => ({ name: t.name, afterIndex: i, beforeIndex:
|
|
64
|
+
.map((t, i) => ({ name: t.name, afterIndex: i, beforeIndex: beforeById.get(afterIds[i])?.index }))
|
|
50
65
|
.filter((c) => c.beforeIndex !== undefined);
|
|
51
66
|
const kept = longestIncreasingRun(common.map((c) => c.beforeIndex));
|
|
52
67
|
common.forEach((c, i) => {
|
|
@@ -54,7 +69,7 @@ export function compareMenus(before, after) {
|
|
|
54
69
|
changes.push({ kind: 'moved', tool: c.name, position: c.afterIndex });
|
|
55
70
|
});
|
|
56
71
|
after.forEach((t, i) => {
|
|
57
|
-
const old =
|
|
72
|
+
const old = beforeById.get(afterIds[i]);
|
|
58
73
|
if (!old) {
|
|
59
74
|
changes.push({ kind: 'added', tool: t.name, position: i });
|
|
60
75
|
return;
|
package/dist/diff.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { Finding, Menu, Severity } from './types.js';
|
|
1
|
+
import type { Finding, JsonSchema, Menu, Severity } from './types.js';
|
|
2
2
|
export type ChangeClass = 'breaking' | 'minor' | 'notice';
|
|
3
3
|
export type Bump = 'major' | 'minor' | 'patch' | 'none';
|
|
4
4
|
export interface DiffFinding extends Finding {
|
|
5
5
|
class?: ChangeClass;
|
|
6
|
+
/** Every place one change was found, when it's reached from several (a shared definition). */
|
|
7
|
+
places?: string[];
|
|
6
8
|
}
|
|
7
9
|
interface DiffRule {
|
|
8
10
|
severity: Severity;
|
|
@@ -54,5 +56,15 @@ export interface DiffOptions {
|
|
|
54
56
|
serverVersionIsRelease?: boolean;
|
|
55
57
|
}
|
|
56
58
|
export declare function diffMenus(before: Menu, after: Menu, options?: DiffOptions): DiffResult;
|
|
59
|
+
/**
|
|
60
|
+
* The schema with local $refs (`#/$defs/…`, `#/definitions/…`) replaced by what
|
|
61
|
+
* they point to, and the root $defs dropped: two spellings of one schema compare
|
|
62
|
+
* equal. A recursive definition is unrolled MAX_UNROLL level, then left as a
|
|
63
|
+
* $ref: a change to it shows in the levels above, and its $defs entry needn't be
|
|
64
|
+
* kept (keeping it made a recursive schema compare unequal to its own refactor,
|
|
65
|
+
* with nothing reported). A $ref toolmenu can't follow (another document) stays as
|
|
66
|
+
* it is. Keywords next to a $ref (a description) win over the target's.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveRefs(schema: JsonSchema | undefined): JsonSchema | undefined;
|
|
57
69
|
export declare function versionBump(before: string | undefined, after: string | undefined): Bump | undefined;
|
|
58
70
|
export {};
|