ag-toolkit 0.5.0 → 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 +16 -9
- 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
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { formatConfigValue, formatDate } from "../lib/format.js";
|
|
3
|
-
describe("formatDate", () => {
|
|
4
|
-
test("should format valid date to ISO date string", () => {
|
|
5
|
-
const date = new Date("2024-01-15T10:30:00Z");
|
|
6
|
-
expect(formatDate(date)).toBe("2024-01-15");
|
|
7
|
-
});
|
|
8
|
-
test("should handle different dates", () => {
|
|
9
|
-
expect(formatDate(new Date("2023-12-31T00:00:00Z"))).toBe("2023-12-31");
|
|
10
|
-
expect(formatDate(new Date("2024-06-15T23:59:59Z"))).toBe("2024-06-15");
|
|
11
|
-
});
|
|
12
|
-
test("should return '--' for null", () => {
|
|
13
|
-
expect(formatDate(null)).toBe("--");
|
|
14
|
-
});
|
|
15
|
-
test("should handle dates at year boundaries", () => {
|
|
16
|
-
expect(formatDate(new Date("2024-01-01T00:00:00Z"))).toBe("2024-01-01");
|
|
17
|
-
expect(formatDate(new Date("2024-12-31T23:59:59Z"))).toBe("2024-12-31");
|
|
18
|
-
});
|
|
19
|
-
test("should handle dates with different times on same day", () => {
|
|
20
|
-
expect(formatDate(new Date("2024-03-15T00:00:00Z"))).toBe("2024-03-15");
|
|
21
|
-
expect(formatDate(new Date("2024-03-15T12:00:00Z"))).toBe("2024-03-15");
|
|
22
|
-
expect(formatDate(new Date("2024-03-15T23:59:59Z"))).toBe("2024-03-15");
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe("formatConfigValue", () => {
|
|
26
|
-
describe("arrays", () => {
|
|
27
|
-
test("should join array elements with comma and space", () => {
|
|
28
|
-
expect(formatConfigValue(["item1", "item2", "item3"])).toBe("item1, item2, item3");
|
|
29
|
-
expect(formatConfigValue([1, 2, 3])).toBe("1, 2, 3");
|
|
30
|
-
});
|
|
31
|
-
test("should return '(not set)' for empty arrays", () => {
|
|
32
|
-
expect(formatConfigValue([])).toBe("(not set)");
|
|
33
|
-
});
|
|
34
|
-
test("should handle arrays with single element", () => {
|
|
35
|
-
expect(formatConfigValue(["single"])).toBe("single");
|
|
36
|
-
});
|
|
37
|
-
test("should handle arrays with mixed types", () => {
|
|
38
|
-
expect(formatConfigValue([1, "two", true])).toBe("1, two, true");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("null, undefined, and empty string", () => {
|
|
42
|
-
test("should return '(not set)' for undefined", () => {
|
|
43
|
-
expect(formatConfigValue(undefined)).toBe("(not set)");
|
|
44
|
-
});
|
|
45
|
-
test("should return '(not set)' for null", () => {
|
|
46
|
-
expect(formatConfigValue(null)).toBe("(not set)");
|
|
47
|
-
});
|
|
48
|
-
test("should return '(not set)' for empty string", () => {
|
|
49
|
-
expect(formatConfigValue("")).toBe("(not set)");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe("other values", () => {
|
|
53
|
-
test("should convert strings to string", () => {
|
|
54
|
-
expect(formatConfigValue("test")).toBe("test");
|
|
55
|
-
expect(formatConfigValue("hello world")).toBe("hello world");
|
|
56
|
-
});
|
|
57
|
-
test("should convert numbers to string", () => {
|
|
58
|
-
expect(formatConfigValue(42)).toBe("42");
|
|
59
|
-
expect(formatConfigValue(0)).toBe("0");
|
|
60
|
-
expect(formatConfigValue(-10)).toBe("-10");
|
|
61
|
-
expect(formatConfigValue(3.14)).toBe("3.14");
|
|
62
|
-
});
|
|
63
|
-
test("should convert booleans to string", () => {
|
|
64
|
-
expect(formatConfigValue(true)).toBe("true");
|
|
65
|
-
expect(formatConfigValue(false)).toBe("false");
|
|
66
|
-
});
|
|
67
|
-
test("should convert objects to string", () => {
|
|
68
|
-
expect(formatConfigValue({ a: 1, b: 2 })).toBe("[object Object]");
|
|
69
|
-
});
|
|
70
|
-
test("should handle special numeric values", () => {
|
|
71
|
-
expect(formatConfigValue(Number.NaN)).toBe("NaN");
|
|
72
|
-
expect(formatConfigValue(Number.POSITIVE_INFINITY)).toBe("Infinity");
|
|
73
|
-
expect(formatConfigValue(Number.NEGATIVE_INFINITY)).toBe("-Infinity");
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { isDeepEqual } from "../lib/isDeepEqual.js";
|
|
3
|
-
describe("isDeepEqual", () => {
|
|
4
|
-
describe("primitive values", () => {
|
|
5
|
-
test("should return true for identical primitive values", () => {
|
|
6
|
-
expect(isDeepEqual(1, 1)).toBe(true);
|
|
7
|
-
expect(isDeepEqual("hello", "hello")).toBe(true);
|
|
8
|
-
expect(isDeepEqual(true, true)).toBe(true);
|
|
9
|
-
expect(isDeepEqual(null, null)).toBe(true);
|
|
10
|
-
expect(isDeepEqual(undefined, undefined)).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
test("should return false for different primitive values", () => {
|
|
13
|
-
expect(isDeepEqual(1, 2)).toBe(false);
|
|
14
|
-
expect(isDeepEqual("hello", "world")).toBe(false);
|
|
15
|
-
expect(isDeepEqual(true, false)).toBe(false);
|
|
16
|
-
expect(isDeepEqual(null, undefined)).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
test("should handle NaN correctly", () => {
|
|
19
|
-
expect(isDeepEqual(Number.NaN, Number.NaN)).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
test("should handle +0 and -0 correctly", () => {
|
|
22
|
-
expect(isDeepEqual(0, 0)).toBe(true);
|
|
23
|
-
expect(isDeepEqual(+0, +0)).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe("arrays", () => {
|
|
27
|
-
test("should return true for identical arrays with strictOrder", () => {
|
|
28
|
-
expect(isDeepEqual([1, 2, 3], [1, 2, 3])).toBe(true);
|
|
29
|
-
expect(isDeepEqual(["a", "b", "c"], ["a", "b", "c"])).toBe(true);
|
|
30
|
-
expect(isDeepEqual([{ a: 1 }, { b: 2 }], [{ a: 1 }, { b: 2 }])).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
test("should return false for arrays with different order when strictOrder is true", () => {
|
|
33
|
-
expect(isDeepEqual([1, 2, 3], [3, 2, 1])).toBe(false);
|
|
34
|
-
expect(isDeepEqual(["a", "b", "c"], ["c", "b", "a"])).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
test("should return true for arrays with different order when strictOrder is false", () => {
|
|
37
|
-
expect(isDeepEqual([1, 2, 3], [3, 2, 1], { strictOrder: false })).toBe(true);
|
|
38
|
-
expect(isDeepEqual(["a", "b", "c"], ["c", "b", "a"], { strictOrder: false })).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
test("should return false when array elements don't match with strictOrder false", () => {
|
|
41
|
-
expect(isDeepEqual([1, 2, 3], [1, 2, 4], { strictOrder: false })).toBe(false);
|
|
42
|
-
expect(isDeepEqual([1, 2, 3], [1, 4, 5], { strictOrder: false })).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
test("should return false for arrays with different lengths", () => {
|
|
45
|
-
expect(isDeepEqual([1, 2], [1, 2, 3])).toBe(false);
|
|
46
|
-
expect(isDeepEqual([1, 2, 3], [1, 2])).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
test("should return false for arrays with different elements", () => {
|
|
49
|
-
expect(isDeepEqual([1, 2, 3], [1, 2, 4])).toBe(false);
|
|
50
|
-
expect(isDeepEqual(["a", "b"], ["a", "c"])).toBe(false);
|
|
51
|
-
});
|
|
52
|
-
test("should handle nested arrays", () => {
|
|
53
|
-
expect(isDeepEqual([
|
|
54
|
-
[1, 2],
|
|
55
|
-
[3, 4],
|
|
56
|
-
], [
|
|
57
|
-
[1, 2],
|
|
58
|
-
[3, 4],
|
|
59
|
-
])).toBe(true);
|
|
60
|
-
expect(isDeepEqual([
|
|
61
|
-
[1, 2],
|
|
62
|
-
[3, 4],
|
|
63
|
-
], [
|
|
64
|
-
[1, 2],
|
|
65
|
-
[3, 5],
|
|
66
|
-
])).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe("objects", () => {
|
|
70
|
-
test("should return true for identical objects", () => {
|
|
71
|
-
expect(isDeepEqual({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true);
|
|
72
|
-
expect(isDeepEqual({ b: 2, a: 1 }, { a: 1, b: 2 })).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
test("should return false for objects with different keys", () => {
|
|
75
|
-
expect(isDeepEqual({ a: 1 }, { b: 1 })).toBe(false);
|
|
76
|
-
expect(isDeepEqual({ a: 1, b: 2 }, { a: 1 })).toBe(false);
|
|
77
|
-
});
|
|
78
|
-
test("should return false for objects with different values", () => {
|
|
79
|
-
expect(isDeepEqual({ a: 1, b: 2 }, { a: 1, b: 3 })).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
test("should handle nested objects", () => {
|
|
82
|
-
expect(isDeepEqual({ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } })).toBe(true);
|
|
83
|
-
expect(isDeepEqual({ a: { b: { c: 1 } } }, { a: { b: { c: 2 } } })).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
test("should handle objects with arrays", () => {
|
|
86
|
-
expect(isDeepEqual({ a: [1, 2, 3], b: "test" }, { a: [1, 2, 3], b: "test" })).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
describe("Date objects", () => {
|
|
90
|
-
test("should return true for identical dates", () => {
|
|
91
|
-
const date1 = new Date("2024-01-01");
|
|
92
|
-
const date2 = new Date("2024-01-01");
|
|
93
|
-
expect(isDeepEqual(date1, date2)).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
test("should return false for different dates", () => {
|
|
96
|
-
const date1 = new Date("2024-01-01");
|
|
97
|
-
const date2 = new Date("2024-01-02");
|
|
98
|
-
expect(isDeepEqual(date1, date2)).toBe(false);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe("RegExp objects", () => {
|
|
102
|
-
test("should return true for identical regex patterns", () => {
|
|
103
|
-
expect(isDeepEqual(/test/g, /test/g)).toBe(true);
|
|
104
|
-
expect(isDeepEqual(/hello/i, /hello/i)).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
test("should return false for different regex patterns", () => {
|
|
107
|
-
expect(isDeepEqual(/test/g, /test/i)).toBe(false);
|
|
108
|
-
expect(isDeepEqual(/hello/, /world/)).toBe(false);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe("Set objects", () => {
|
|
112
|
-
test("should return true for identical sets", () => {
|
|
113
|
-
expect(isDeepEqual(new Set([1, 2, 3]), new Set([1, 2, 3]))).toBe(true);
|
|
114
|
-
expect(isDeepEqual(new Set([1, 2, 3]), new Set([3, 2, 1]))).toBe(true);
|
|
115
|
-
});
|
|
116
|
-
test("should return false for different sets", () => {
|
|
117
|
-
expect(isDeepEqual(new Set([1, 2, 3]), new Set([1, 2, 4]))).toBe(false);
|
|
118
|
-
expect(isDeepEqual(new Set([1, 2]), new Set([1, 2, 3]))).toBe(false);
|
|
119
|
-
});
|
|
120
|
-
test("should handle sets with objects", () => {
|
|
121
|
-
expect(isDeepEqual(new Set([{ a: 1 }, { b: 2 }]), new Set([{ a: 1 }, { b: 2 }]))).toBe(true);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
describe("Map objects", () => {
|
|
125
|
-
test("should return true for identical maps", () => {
|
|
126
|
-
expect(isDeepEqual(new Map([
|
|
127
|
-
["a", 1],
|
|
128
|
-
["b", 2],
|
|
129
|
-
]), new Map([
|
|
130
|
-
["a", 1],
|
|
131
|
-
["b", 2],
|
|
132
|
-
]))).toBe(true);
|
|
133
|
-
expect(isDeepEqual(new Map([
|
|
134
|
-
["a", 1],
|
|
135
|
-
["b", 2],
|
|
136
|
-
]), new Map([
|
|
137
|
-
["b", 2],
|
|
138
|
-
["a", 1],
|
|
139
|
-
]))).toBe(true);
|
|
140
|
-
});
|
|
141
|
-
test("should return false for different maps", () => {
|
|
142
|
-
expect(isDeepEqual(new Map([
|
|
143
|
-
["a", 1],
|
|
144
|
-
["b", 2],
|
|
145
|
-
]), new Map([
|
|
146
|
-
["a", 1],
|
|
147
|
-
["b", 3],
|
|
148
|
-
]))).toBe(false);
|
|
149
|
-
expect(isDeepEqual(new Map([["a", 1]]), new Map([
|
|
150
|
-
["a", 1],
|
|
151
|
-
["b", 2],
|
|
152
|
-
]))).toBe(false);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
describe("TypedArray", () => {
|
|
156
|
-
test("should return true for identical typed arrays", () => {
|
|
157
|
-
expect(isDeepEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3]))).toBe(true);
|
|
158
|
-
expect(isDeepEqual(new Int16Array([10, 20, 30]), new Int16Array([10, 20, 30]))).toBe(true);
|
|
159
|
-
});
|
|
160
|
-
test("should return false for different typed arrays", () => {
|
|
161
|
-
expect(isDeepEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 4]))).toBe(false);
|
|
162
|
-
});
|
|
163
|
-
test("should return false for typed arrays with different types", () => {
|
|
164
|
-
expect(isDeepEqual(new Uint8Array([1, 2, 3]), new Int8Array([1, 2, 3]))).toBe(false);
|
|
165
|
-
});
|
|
166
|
-
test("should return false for typed arrays with different lengths", () => {
|
|
167
|
-
expect(isDeepEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2]))).toBe(false);
|
|
168
|
-
expect(isDeepEqual(new Uint8Array([1, 2]), new Uint8Array([1, 2, 3]))).toBe(false);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
describe("circular references", () => {
|
|
172
|
-
test("should handle circular references", () => {
|
|
173
|
-
const obj1 = { a: 1 };
|
|
174
|
-
obj1.self = obj1;
|
|
175
|
-
const obj2 = { a: 1 };
|
|
176
|
-
obj2.self = obj2;
|
|
177
|
-
expect(isDeepEqual(obj1, obj2)).toBe(true);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
describe("mixed types", () => {
|
|
181
|
-
test("should return false for different types", () => {
|
|
182
|
-
expect(isDeepEqual(1, "1")).toBe(false);
|
|
183
|
-
expect(isDeepEqual([1], { 0: 1 })).toBe(false);
|
|
184
|
-
expect(isDeepEqual(null, {})).toBe(false);
|
|
185
|
-
expect(isDeepEqual(undefined, null)).toBe(false);
|
|
186
|
-
});
|
|
187
|
-
test("should handle complex nested structures", () => {
|
|
188
|
-
const obj1 = {
|
|
189
|
-
a: [1, 2, { b: 3 }],
|
|
190
|
-
c: new Set([4, 5]),
|
|
191
|
-
d: new Map([["e", 6]]),
|
|
192
|
-
f: new Date("2024-01-01"),
|
|
193
|
-
};
|
|
194
|
-
const obj2 = {
|
|
195
|
-
a: [1, 2, { b: 3 }],
|
|
196
|
-
c: new Set([4, 5]),
|
|
197
|
-
d: new Map([["e", 6]]),
|
|
198
|
-
f: new Date("2024-01-01"),
|
|
199
|
-
};
|
|
200
|
-
expect(isDeepEqual(obj1, obj2)).toBe(true);
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { isValidBranchName } from "../lib/isValidBranchName.js";
|
|
3
|
-
describe("isValidBranchName", () => {
|
|
4
|
-
describe("valid branch names", () => {
|
|
5
|
-
test("should return true for simple branch names", () => {
|
|
6
|
-
expect(isValidBranchName("main")).toBe(true);
|
|
7
|
-
expect(isValidBranchName("develop")).toBe(true);
|
|
8
|
-
expect(isValidBranchName("feature")).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
test("should return true for branch names with hyphens", () => {
|
|
11
|
-
expect(isValidBranchName("feature-branch")).toBe(true);
|
|
12
|
-
expect(isValidBranchName("bug-fix")).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
test("should return true for branch names with underscores", () => {
|
|
15
|
-
expect(isValidBranchName("feature_branch")).toBe(true);
|
|
16
|
-
expect(isValidBranchName("bug_fix")).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
test("should return true for branch names with dots", () => {
|
|
19
|
-
expect(isValidBranchName("release.1.0")).toBe(true);
|
|
20
|
-
expect(isValidBranchName("v1.2.3")).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
test("should return true for branch names with slashes", () => {
|
|
23
|
-
expect(isValidBranchName("feature/new-feature")).toBe(true);
|
|
24
|
-
expect(isValidBranchName("bugfix/issue-123")).toBe(true);
|
|
25
|
-
expect(isValidBranchName("release/v1.0.0")).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
test("should return true for branch names with numbers", () => {
|
|
28
|
-
expect(isValidBranchName("feature123")).toBe(true);
|
|
29
|
-
expect(isValidBranchName("v1.2.3")).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
test("should return true for mixed valid characters", () => {
|
|
32
|
-
expect(isValidBranchName("feature/ABC-123_test.v1")).toBe(true);
|
|
33
|
-
expect(isValidBranchName("release/2024.01.01")).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("invalid branch names", () => {
|
|
37
|
-
test("should return false for empty strings", () => {
|
|
38
|
-
expect(isValidBranchName("")).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
test("should return false for branch names with invalid characters", () => {
|
|
41
|
-
expect(isValidBranchName("feature@branch")).toBe(false);
|
|
42
|
-
expect(isValidBranchName("bug#fix")).toBe(false);
|
|
43
|
-
expect(isValidBranchName("test branch")).toBe(false);
|
|
44
|
-
expect(isValidBranchName("feature:branch")).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
test("should return false for branch names with double dots", () => {
|
|
47
|
-
expect(isValidBranchName("feature..branch")).toBe(false);
|
|
48
|
-
expect(isValidBranchName("test..test")).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
test("should return false for branch names starting with slash", () => {
|
|
51
|
-
expect(isValidBranchName("/feature")).toBe(false);
|
|
52
|
-
expect(isValidBranchName("/main")).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
test("should return false for branch names ending with slash", () => {
|
|
55
|
-
expect(isValidBranchName("feature/")).toBe(false);
|
|
56
|
-
expect(isValidBranchName("main/")).toBe(false);
|
|
57
|
-
});
|
|
58
|
-
test("should return false for branch names with double slashes", () => {
|
|
59
|
-
expect(isValidBranchName("feature//branch")).toBe(false);
|
|
60
|
-
expect(isValidBranchName("test//test")).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
test("should return false for branch names ending with dot", () => {
|
|
63
|
-
expect(isValidBranchName("feature.")).toBe(false);
|
|
64
|
-
expect(isValidBranchName("branch.")).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
test("should return false for components starting with dot", () => {
|
|
67
|
-
expect(isValidBranchName("feature/.hidden")).toBe(false);
|
|
68
|
-
expect(isValidBranchName(".hidden/branch")).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
test("should return false for components ending with .lock", () => {
|
|
71
|
-
expect(isValidBranchName("feature/branch.lock")).toBe(false);
|
|
72
|
-
expect(isValidBranchName("test.lock")).toBe(false);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe("edge cases", () => {
|
|
76
|
-
test("should handle single character branch names", () => {
|
|
77
|
-
expect(isValidBranchName("a")).toBe(true);
|
|
78
|
-
expect(isValidBranchName("1")).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
test("should handle very long branch names", () => {
|
|
81
|
-
const longName = "a".repeat(255);
|
|
82
|
-
expect(isValidBranchName(longName)).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
test("should handle branch names with multiple slashes", () => {
|
|
85
|
-
expect(isValidBranchName("feature/sub/branch")).toBe(true);
|
|
86
|
-
expect(isValidBranchName("a/b/c/d/e")).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/match.test.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { matchPattern } from "../lib/match.js";
|
|
3
|
-
describe("matchPattern", () => {
|
|
4
|
-
describe("exact string matching", () => {
|
|
5
|
-
test("should match identical strings", () => {
|
|
6
|
-
expect(matchPattern("hello", "hello")).toBe(true);
|
|
7
|
-
expect(matchPattern("test123", "test123")).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
test("should not match different strings", () => {
|
|
10
|
-
expect(matchPattern("hello", "world")).toBe(false);
|
|
11
|
-
expect(matchPattern("test", "test123")).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
test("should be case-sensitive for exact matches", () => {
|
|
14
|
-
expect(matchPattern("Hello", "hello")).toBe(false);
|
|
15
|
-
expect(matchPattern("TEST", "test")).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
test("should handle empty strings", () => {
|
|
18
|
-
expect(matchPattern("", "")).toBe(true);
|
|
19
|
-
expect(matchPattern("test", "")).toBe(false);
|
|
20
|
-
expect(matchPattern("", "test")).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe("regex pattern matching", () => {
|
|
24
|
-
test("should match regex patterns with delimiters", () => {
|
|
25
|
-
expect(matchPattern("hello", "/hello/")).toBe(true);
|
|
26
|
-
expect(matchPattern("test123", "/test\\d+/")).toBe(true);
|
|
27
|
-
expect(matchPattern("abc", "/[a-z]+/")).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
test("should not match when regex pattern doesn't match", () => {
|
|
30
|
-
expect(matchPattern("hello", "/world/")).toBe(false);
|
|
31
|
-
expect(matchPattern("abc", "/\\d+/")).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
test("should support regex flags", () => {
|
|
34
|
-
expect(matchPattern("Hello", "/hello/i")).toBe(true);
|
|
35
|
-
expect(matchPattern("TEST", "/test/i")).toBe(true);
|
|
36
|
-
expect(matchPattern("Hello", "/hello/")).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
test("should support global flag", () => {
|
|
39
|
-
expect(matchPattern("test test", "/test/g")).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
test("should support multiline flag", () => {
|
|
42
|
-
expect(matchPattern("line1\nline2", "/^line2/m")).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
test("should handle complex regex patterns", () => {
|
|
45
|
-
expect(matchPattern("email@example.com", "/^[\\w.-]+@[\\w.-]+\\.\\w+$/")).toBe(true);
|
|
46
|
-
expect(matchPattern("2024-01-01", "/^\\d{4}-\\d{2}-\\d{2}$/")).toBe(true);
|
|
47
|
-
expect(matchPattern("invalid-date", "/^\\d{4}-\\d{2}-\\d{2}$/")).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
test("should handle patterns with special characters", () => {
|
|
50
|
-
expect(matchPattern("(test)", "/\\(test\\)/")).toBe(true);
|
|
51
|
-
expect(matchPattern("[abc]", "/\\[abc\\]/")).toBe(true);
|
|
52
|
-
expect(matchPattern("a.b", "/a\\.b/")).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
test("should return false for invalid regex patterns", () => {
|
|
55
|
-
expect(matchPattern("test", "/(/")).toBe(false);
|
|
56
|
-
expect(matchPattern("test", "/[/")).toBe(false);
|
|
57
|
-
expect(matchPattern("test", "/*/")).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
test("should handle patterns with multiple slashes", () => {
|
|
60
|
-
expect(matchPattern("path/to/file", "/path\\/to\\/file/")).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe("edge cases", () => {
|
|
64
|
-
test("should treat patterns without proper delimiters as exact strings", () => {
|
|
65
|
-
expect(matchPattern("/test", "/test")).toBe(true);
|
|
66
|
-
expect(matchPattern("test/", "test/")).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
test("should handle patterns that look like regex but aren't properly formatted", () => {
|
|
69
|
-
expect(matchPattern("/test", "/test")).toBe(true);
|
|
70
|
-
expect(matchPattern("test/", "test/")).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
test("should handle empty regex pattern", () => {
|
|
73
|
-
expect(matchPattern("test", "//")).toBe(true);
|
|
74
|
-
expect(matchPattern("", "//")).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
test("should handle patterns with only opening slash", () => {
|
|
77
|
-
expect(matchPattern("/hello", "/hello")).toBe(true);
|
|
78
|
-
expect(matchPattern("hello", "/hello")).toBe(false);
|
|
79
|
-
});
|
|
80
|
-
test("should handle anchored patterns", () => {
|
|
81
|
-
expect(matchPattern("hello world", "/^hello/")).toBe(true);
|
|
82
|
-
expect(matchPattern("hello world", "/world$/")).toBe(true);
|
|
83
|
-
expect(matchPattern("hello world", "/^world/")).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import { writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { loadPackageJson } from "../lib/package.js";
|
|
6
|
-
describe("loadPackageJson", () => {
|
|
7
|
-
let testDir;
|
|
8
|
-
let testScriptPath;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
testDir = join(tmpdir(), `package-test-${Date.now()}`);
|
|
11
|
-
const scriptDir = join(testDir, "lib");
|
|
12
|
-
Bun.spawnSync(["mkdir", "-p", scriptDir]);
|
|
13
|
-
testScriptPath = join(scriptDir, "test-script.js");
|
|
14
|
-
});
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
Bun.spawnSync(["rm", "-rf", testDir]);
|
|
17
|
-
});
|
|
18
|
-
test("should load and parse package.json", () => {
|
|
19
|
-
const packageJson = {
|
|
20
|
-
name: "test-package",
|
|
21
|
-
version: "1.0.0",
|
|
22
|
-
description: "Test package",
|
|
23
|
-
};
|
|
24
|
-
writeFileSync(join(testDir, "package.json"), JSON.stringify(packageJson));
|
|
25
|
-
writeFileSync(testScriptPath, "");
|
|
26
|
-
const scriptUrl = `file://${testScriptPath}`;
|
|
27
|
-
const result = loadPackageJson(scriptUrl);
|
|
28
|
-
expect(result.name).toBe("test-package");
|
|
29
|
-
expect(result.version).toBe("1.0.0");
|
|
30
|
-
// biome-ignore lint/complexity/useLiteralKeys: ignore
|
|
31
|
-
expect(result["description"]).toBe("Test package");
|
|
32
|
-
});
|
|
33
|
-
test("should handle package.json with additional properties", () => {
|
|
34
|
-
const packageJson = {
|
|
35
|
-
name: "test-package",
|
|
36
|
-
version: "2.0.0",
|
|
37
|
-
author: "Test Author",
|
|
38
|
-
license: "MIT",
|
|
39
|
-
dependencies: {
|
|
40
|
-
"some-package": "^1.0.0",
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
writeFileSync(join(testDir, "package.json"), JSON.stringify(packageJson));
|
|
44
|
-
writeFileSync(testScriptPath, "");
|
|
45
|
-
const scriptUrl = `file://${testScriptPath}`;
|
|
46
|
-
const result = loadPackageJson(scriptUrl);
|
|
47
|
-
expect(result.name).toBe("test-package");
|
|
48
|
-
expect(result.version).toBe("2.0.0");
|
|
49
|
-
// biome-ignore lint/complexity/useLiteralKeys: ignore
|
|
50
|
-
expect(result["author"]).toBe("Test Author");
|
|
51
|
-
// biome-ignore lint/complexity/useLiteralKeys: ignore
|
|
52
|
-
expect(result["license"]).toBe("MIT");
|
|
53
|
-
});
|
|
54
|
-
test("should throw error when package.json doesn't exist", () => {
|
|
55
|
-
writeFileSync(testScriptPath, "");
|
|
56
|
-
const scriptUrl = `file://${testScriptPath}`;
|
|
57
|
-
expect(() => loadPackageJson(scriptUrl)).toThrow();
|
|
58
|
-
});
|
|
59
|
-
test("should throw error for invalid JSON in package.json", () => {
|
|
60
|
-
writeFileSync(join(testDir, "package.json"), "{ invalid json }");
|
|
61
|
-
writeFileSync(testScriptPath, "");
|
|
62
|
-
const scriptUrl = `file://${testScriptPath}`;
|
|
63
|
-
expect(() => loadPackageJson(scriptUrl)).toThrow();
|
|
64
|
-
});
|
|
65
|
-
test("should handle package.json with minimal required fields", () => {
|
|
66
|
-
const packageJson = {
|
|
67
|
-
name: "minimal-package",
|
|
68
|
-
version: "0.0.1",
|
|
69
|
-
};
|
|
70
|
-
writeFileSync(join(testDir, "package.json"), JSON.stringify(packageJson));
|
|
71
|
-
writeFileSync(testScriptPath, "");
|
|
72
|
-
const scriptUrl = `file://${testScriptPath}`;
|
|
73
|
-
const result = loadPackageJson(scriptUrl);
|
|
74
|
-
expect(result.name).toBe("minimal-package");
|
|
75
|
-
expect(result.version).toBe("0.0.1");
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { sanitizeString } from "../lib/sanitizeString.js";
|
|
3
|
-
describe("sanitizeString", () => {
|
|
4
|
-
test("should return unchanged string for printable ASCII characters", () => {
|
|
5
|
-
expect(sanitizeString("Hello World")).toBe("Hello World");
|
|
6
|
-
expect(sanitizeString("ABC123")).toBe("ABC123");
|
|
7
|
-
expect(sanitizeString("!@#$%^&*()")).toBe("!@#$%^&*()");
|
|
8
|
-
});
|
|
9
|
-
test("should preserve newlines", () => {
|
|
10
|
-
expect(sanitizeString("line1\nline2")).toBe("line1\nline2");
|
|
11
|
-
expect(sanitizeString("first\nsecond\nthird")).toBe("first\nsecond\nthird");
|
|
12
|
-
});
|
|
13
|
-
test("should preserve carriage returns", () => {
|
|
14
|
-
expect(sanitizeString("line1\rline2")).toBe("line1\rline2");
|
|
15
|
-
});
|
|
16
|
-
test("should preserve tabs", () => {
|
|
17
|
-
expect(sanitizeString("column1\tcolumn2")).toBe("column1\tcolumn2");
|
|
18
|
-
expect(sanitizeString("\tindented")).toBe("\tindented");
|
|
19
|
-
});
|
|
20
|
-
test("should remove non-printable characters", () => {
|
|
21
|
-
expect(sanitizeString("test\x00string")).toBe("teststring");
|
|
22
|
-
expect(sanitizeString("hello\x01world")).toBe("helloworld");
|
|
23
|
-
expect(sanitizeString("test\x1Bstring")).toBe("teststring");
|
|
24
|
-
});
|
|
25
|
-
test("should remove ANSI escape codes", () => {
|
|
26
|
-
expect(sanitizeString("\x1b[31mRed Text\x1b[0m")).toBe("[31mRed Text[0m");
|
|
27
|
-
expect(sanitizeString("\x1b[1;32mGreen\x1b[0m")).toBe("[1;32mGreen[0m");
|
|
28
|
-
});
|
|
29
|
-
test("should handle empty strings", () => {
|
|
30
|
-
expect(sanitizeString("")).toBe("");
|
|
31
|
-
});
|
|
32
|
-
test("should handle strings with only non-printable characters", () => {
|
|
33
|
-
expect(sanitizeString("\x00\x01\x02")).toBe("");
|
|
34
|
-
});
|
|
35
|
-
test("should handle mixed printable and non-printable characters", () => {
|
|
36
|
-
expect(sanitizeString("Hello\x00World\x01!")).toBe("HelloWorld!");
|
|
37
|
-
});
|
|
38
|
-
test("should preserve spaces", () => {
|
|
39
|
-
expect(sanitizeString(" spaces ")).toBe(" spaces ");
|
|
40
|
-
});
|
|
41
|
-
test("should handle unicode characters outside printable ASCII", () => {
|
|
42
|
-
expect(sanitizeString("Hello 世界")).toBe("Hello ");
|
|
43
|
-
expect(sanitizeString("Emoji 😀 test")).toBe("Emoji test");
|
|
44
|
-
});
|
|
45
|
-
test("should handle strings with newlines, tabs, and carriage returns mixed", () => {
|
|
46
|
-
expect(sanitizeString("line1\nline2\tcolumn\rend")).toBe("line1\nline2\tcolumn\rend");
|
|
47
|
-
});
|
|
48
|
-
});
|