ag-toolkit 0.4.1 → 0.6.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/dist/components/ConfigEditor.js +1 -1
- package/dist/git.d.ts +20 -5
- package/dist/git.js +14 -0
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/package.json +17 -10
- package/dist/lib/isDeepEqual.d.ts +0 -28
- package/dist/lib/isDeepEqual.js +0 -147
- package/dist/tests/arg-parser.test.d.ts +0 -1
- package/dist/tests/arg-parser.test.js +0 -404
- package/dist/tests/config.test.d.ts +0 -1
- package/dist/tests/config.test.js +0 -234
- package/dist/tests/format.test.d.ts +0 -1
- package/dist/tests/format.test.js +0 -76
- package/dist/tests/isDeepEqual.test.d.ts +0 -1
- package/dist/tests/isDeepEqual.test.js +0 -203
- package/dist/tests/isValidBranchName.test.d.ts +0 -1
- package/dist/tests/isValidBranchName.test.js +0 -89
- package/dist/tests/match.test.d.ts +0 -1
- package/dist/tests/match.test.js +0 -86
- package/dist/tests/package.test.d.ts +0 -1
- package/dist/tests/package.test.js +0 -77
- package/dist/tests/sanitizeString.test.d.ts +0 -1
- package/dist/tests/sanitizeString.test.js +0 -48
|
@@ -3,8 +3,8 @@ import { Box, Text, useApp, useInput } from "ink";
|
|
|
3
3
|
import SelectInput from "ink-select-input";
|
|
4
4
|
import Spinner from "ink-spinner";
|
|
5
5
|
import { useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { isDeepEqual } from "umt/Validate";
|
|
6
7
|
import { formatConfigValue } from "../lib/format.js";
|
|
7
|
-
import { isDeepEqual } from "../lib/isDeepEqual.js";
|
|
8
8
|
import { BooleanItem, Item } from "./ConfigEditorItem.js";
|
|
9
9
|
export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig, writeConfig, }) => {
|
|
10
10
|
const { exit } = useApp();
|
package/dist/git.d.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { type SchemaToInterface } from "umt/Validate";
|
|
2
|
+
export declare const BranchTypeSchema: (value: string) => import("umt/Validate").OneOfReturnType<"local" | "remote">;
|
|
3
|
+
export type BranchType = SchemaToInterface<typeof BranchTypeSchema>;
|
|
4
|
+
declare const BranchInfoSchema: import("umt/Validate").ObjectValidator<{
|
|
5
|
+
ref: (value: string) => import("umt/Validate").ValidateCoreReturnType<string>;
|
|
6
|
+
name: (value: string) => import("umt/Validate").ValidateCoreReturnType<string>;
|
|
7
|
+
type: (value: string) => import("umt/Validate").OneOfReturnType<"local" | "remote">;
|
|
8
|
+
remote: import("umt/Validate").OptionalValidator<string, import("umt/Validate").ValidateCoreReturnType<string>>;
|
|
9
|
+
lastCommitDate: (value: Date | null) => import("umt/Validate").NullReturn | import("umt/Validate").ValidateCoreReturnType<Date>;
|
|
10
|
+
lastCommitSha: (value: string | null) => import("umt/Validate").ValidateCoreReturnType<string> | import("umt/Validate").NullReturn;
|
|
11
|
+
lastCommitSubject: (value: string | null) => import("umt/Validate").ValidateCoreReturnType<string> | import("umt/Validate").NullReturn;
|
|
12
|
+
isMerged: (value: boolean) => import("umt/Validate").ValidateCoreReturnType<boolean>;
|
|
13
|
+
ahead: (value: number) => import("umt/Validate").ValidateCoreReturnType<number>;
|
|
14
|
+
behind: (value: number) => import("umt/Validate").ValidateCoreReturnType<number>;
|
|
15
|
+
}, {
|
|
3
16
|
ref: string;
|
|
4
17
|
name: string;
|
|
5
|
-
type:
|
|
6
|
-
remote
|
|
18
|
+
type: "local" | "remote";
|
|
19
|
+
remote: string | undefined;
|
|
7
20
|
lastCommitDate: Date | null;
|
|
8
21
|
lastCommitSha: string | null;
|
|
9
22
|
lastCommitSubject: string | null;
|
|
10
23
|
isMerged: boolean;
|
|
11
24
|
ahead: number;
|
|
12
25
|
behind: number;
|
|
13
|
-
}
|
|
26
|
+
}>;
|
|
27
|
+
export type BranchInfo = SchemaToInterface<typeof BranchInfoSchema>;
|
|
14
28
|
export declare class GitOperations {
|
|
15
29
|
private git;
|
|
16
30
|
constructor(workingDir?: string);
|
|
@@ -59,3 +73,4 @@ export declare class GitOperations {
|
|
|
59
73
|
popStash(stashRef: string): Promise<void>;
|
|
60
74
|
pushWithLease(branch: string): Promise<void>;
|
|
61
75
|
}
|
|
76
|
+
export {};
|
package/dist/git.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { simpleGit } from "simple-git";
|
|
2
|
+
import { boolean, date, nullable, number, object, oneOf, optional, string, } from "umt/Validate";
|
|
2
3
|
import { isValidBranchName } from "./lib/isValidBranchName.js";
|
|
4
|
+
export const BranchTypeSchema = oneOf(["local", "remote"]);
|
|
5
|
+
const BranchInfoSchema = object({
|
|
6
|
+
ref: string(),
|
|
7
|
+
name: string(),
|
|
8
|
+
type: BranchTypeSchema,
|
|
9
|
+
remote: optional(string()),
|
|
10
|
+
lastCommitDate: nullable(date()),
|
|
11
|
+
lastCommitSha: nullable(string()),
|
|
12
|
+
lastCommitSubject: nullable(string()),
|
|
13
|
+
isMerged: boolean(),
|
|
14
|
+
ahead: number(),
|
|
15
|
+
behind: number(),
|
|
16
|
+
});
|
|
3
17
|
const BRANCH_LIST_FORMAT = "%(refname)%00%(committerdate:iso8601)%00%(objectname)%00%(contents:subject)";
|
|
4
18
|
export class GitOperations {
|
|
5
19
|
git;
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Shared library for agbd and agrb",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,20 +33,27 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
36
|
+
"simple-git": "3.36.0",
|
|
37
|
+
"umt": "3.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"ink": ">=6.0.0",
|
|
41
|
+
"ink-select-input": ">=6.0.0",
|
|
42
|
+
"ink-spinner": ">=5.0.0",
|
|
43
|
+
"react": ">=18.0.0"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
|
-
"@biomejs/biome": "2.
|
|
46
|
+
"@biomejs/biome": "2.4.15",
|
|
44
47
|
"@sindresorhus/tsconfig": "8.1.0",
|
|
45
|
-
"@types/bun": "1.3.
|
|
46
|
-
"@types/react": "19.2.
|
|
48
|
+
"@types/bun": "1.3.13",
|
|
49
|
+
"@types/react": "19.2.14",
|
|
47
50
|
"chalk": "5.6.2",
|
|
51
|
+
"ink": "7.0.2",
|
|
52
|
+
"ink-select-input": "6.2.0",
|
|
53
|
+
"ink-spinner": "5.0.0",
|
|
48
54
|
"ink-testing-library": "4.0.0",
|
|
55
|
+
"react": "19.2.6",
|
|
49
56
|
"ts-node": "10.9.2",
|
|
50
|
-
"typescript": "
|
|
57
|
+
"typescript": "6.0.3"
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for isDeepEqual comparison
|
|
3
|
-
*/
|
|
4
|
-
export interface IsDeepEqualOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Whether to ignore array order when comparing arrays
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
strictOrder?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Performs a deep equality comparison between two values
|
|
13
|
-
*
|
|
14
|
-
* @param a - First value to compare
|
|
15
|
-
* @param b - Second value to compare
|
|
16
|
-
* @param options - Comparison options
|
|
17
|
-
* @returns true if values are deeply equal, false otherwise
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* isDeepEqual({ a: 1, b: [2, 3] }, { b: [2, 3], a: 1 }); // true
|
|
22
|
-
* isDeepEqual([1, 2, 3], [3, 2, 1]); // false
|
|
23
|
-
* isDeepEqual([1, 2, 3], [3, 2, 1], { strictOrder: false }); // true
|
|
24
|
-
* isDeepEqual(new Set([1, 2]), new Set([2, 1])); // true
|
|
25
|
-
* isDeepEqual(new Map([['a', 1]]), new Map([['a', 1]])); // true
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function isDeepEqual(a: unknown, b: unknown, options?: IsDeepEqualOptions): boolean;
|
package/dist/lib/isDeepEqual.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Performs a deep equality comparison between two values
|
|
3
|
-
*
|
|
4
|
-
* @param a - First value to compare
|
|
5
|
-
* @param b - Second value to compare
|
|
6
|
-
* @param options - Comparison options
|
|
7
|
-
* @returns true if values are deeply equal, false otherwise
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* isDeepEqual({ a: 1, b: [2, 3] }, { b: [2, 3], a: 1 }); // true
|
|
12
|
-
* isDeepEqual([1, 2, 3], [3, 2, 1]); // false
|
|
13
|
-
* isDeepEqual([1, 2, 3], [3, 2, 1], { strictOrder: false }); // true
|
|
14
|
-
* isDeepEqual(new Set([1, 2]), new Set([2, 1])); // true
|
|
15
|
-
* isDeepEqual(new Map([['a', 1]]), new Map([['a', 1]])); // true
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export function isDeepEqual(a, b, options = {}) {
|
|
19
|
-
const { strictOrder = true } = options;
|
|
20
|
-
const visited = new WeakSet();
|
|
21
|
-
function compare(x, y) {
|
|
22
|
-
if (Object.is(x, y)) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
if (x == null || y == null) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (typeof x !== typeof y) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
if (typeof x !== "object" || typeof y !== "object") {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (visited.has(x) || visited.has(y)) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
visited.add(x);
|
|
38
|
-
visited.add(y);
|
|
39
|
-
const ctorX = x.constructor;
|
|
40
|
-
const ctorY = y.constructor;
|
|
41
|
-
if (ctorX !== ctorY) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
if (x instanceof Date && y instanceof Date) {
|
|
45
|
-
return x.getTime() === y.getTime();
|
|
46
|
-
}
|
|
47
|
-
if (x instanceof RegExp && y instanceof RegExp) {
|
|
48
|
-
return x.toString() === y.toString();
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(x) && Array.isArray(y)) {
|
|
51
|
-
if (x.length !== y.length) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (strictOrder) {
|
|
55
|
-
for (const [index, element] of x.entries()) {
|
|
56
|
-
if (!compare(element, y[index])) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
const yCopy = [...y];
|
|
63
|
-
for (const itemX of x) {
|
|
64
|
-
let found = false;
|
|
65
|
-
for (let index = 0; index < yCopy.length; index++) {
|
|
66
|
-
if (compare(itemX, yCopy[index])) {
|
|
67
|
-
yCopy.splice(index, 1);
|
|
68
|
-
found = true;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!found) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return yCopy.length === 0;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
if (x instanceof Set && y instanceof Set) {
|
|
81
|
-
if (x.size !== y.size) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
for (const item of x) {
|
|
85
|
-
let found = false;
|
|
86
|
-
for (const otherItem of y) {
|
|
87
|
-
if (compare(item, otherItem)) {
|
|
88
|
-
found = true;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (!found) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
if (x instanceof Map && y instanceof Map) {
|
|
99
|
-
if (x.size !== y.size) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
for (const [key, value] of x) {
|
|
103
|
-
let found = false;
|
|
104
|
-
for (const [otherKey, otherValue] of y) {
|
|
105
|
-
if (compare(key, otherKey) && compare(value, otherValue)) {
|
|
106
|
-
found = true;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (!found) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
if (ArrayBuffer.isView(x) && ArrayBuffer.isView(y)) {
|
|
117
|
-
const xArray = x;
|
|
118
|
-
const yArray = y;
|
|
119
|
-
if (xArray.byteLength !== yArray.byteLength) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
for (let index = 0; index < xArray.byteLength; index++) {
|
|
123
|
-
if (xArray[index] !== yArray[index]) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
const keysX = Object.keys(x);
|
|
130
|
-
const keysY = Object.keys(y);
|
|
131
|
-
if (keysX.length !== keysY.length) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
for (const key of keysX) {
|
|
135
|
-
if (!(key in y)) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
for (const key of keysX) {
|
|
140
|
-
if (!compare(x[key], y[key])) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return compare(a, b);
|
|
147
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|