claude-yes 1.27.0 → 1.29.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/dist/claude-yes.js +11822 -426
- package/dist/cli.js +11822 -426
- package/dist/cli.js.map +163 -6
- package/dist/codex-yes.js +11822 -426
- package/dist/copilot-yes.js +11822 -426
- package/dist/cursor-yes.js +11822 -426
- package/dist/gemini-yes.js +11822 -426
- package/dist/grok-yes.js +11822 -426
- package/dist/index.js +11830 -361
- package/dist/index.js.map +163 -5
- package/dist/qwen-yes.js +11822 -426
- package/package.json +8 -8
- package/ts/ReadyManager.spec.ts +72 -0
- package/ts/cli.ts +4 -6
- package/ts/idleWaiter.spec.ts +55 -0
- package/ts/index.ts +19 -9
- package/ts/parseCliArgs.ts +5 -3
- package/ts/removeControlCharacters.spec.ts +74 -0
- package/ts/tryCatch.spec.ts +207 -0
- package/ts/utils.spec.ts +169 -0
- package/ts/yesLog.spec.ts +74 -0
package/ts/utils.spec.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { type DeepPartial, deepMixin, sleepms } from './utils';
|
|
3
|
+
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
describe('sleepms', () => {
|
|
6
|
+
it('should return a promise', () => {
|
|
7
|
+
const result = sleepms(100);
|
|
8
|
+
expect(result).toBeInstanceOf(Promise);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should resolve after some time', async () => {
|
|
12
|
+
const start = Date.now();
|
|
13
|
+
await sleepms(10);
|
|
14
|
+
const end = Date.now();
|
|
15
|
+
expect(end - start).toBeGreaterThanOrEqual(5); // Allow some margin
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should handle zero milliseconds', async () => {
|
|
19
|
+
const start = Date.now();
|
|
20
|
+
await sleepms(0);
|
|
21
|
+
const end = Date.now();
|
|
22
|
+
expect(end - start).toBeLessThan(50); // Should be quick
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('deepMixin', () => {
|
|
27
|
+
it('should merge simple properties', () => {
|
|
28
|
+
const target = { a: 1, b: 2 };
|
|
29
|
+
const source = { b: 3, c: 4 };
|
|
30
|
+
const result = deepMixin(target, source);
|
|
31
|
+
|
|
32
|
+
expect(result).toEqual({ a: 1, b: 3, c: 4 });
|
|
33
|
+
expect(result).toBe(target); // Should modify original object
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should merge nested objects', () => {
|
|
37
|
+
const target = {
|
|
38
|
+
user: { name: 'John', age: 30 },
|
|
39
|
+
settings: { theme: 'dark' },
|
|
40
|
+
};
|
|
41
|
+
const source: DeepPartial<typeof target> = {
|
|
42
|
+
user: { age: 31 },
|
|
43
|
+
settings: { language: 'en' } as any,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
deepMixin(target, source);
|
|
47
|
+
|
|
48
|
+
expect(target).toEqual({
|
|
49
|
+
user: { name: 'John', age: 31 },
|
|
50
|
+
settings: { theme: 'dark', language: 'en' },
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should create nested objects when target property is null', () => {
|
|
55
|
+
const target: any = { config: null };
|
|
56
|
+
const source = { config: { enabled: true } };
|
|
57
|
+
|
|
58
|
+
deepMixin(target, source);
|
|
59
|
+
|
|
60
|
+
expect(target).toEqual({
|
|
61
|
+
config: { enabled: true },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should create nested objects when target property is primitive', () => {
|
|
66
|
+
const target: any = { config: 'string' };
|
|
67
|
+
const source = { config: { enabled: true } };
|
|
68
|
+
|
|
69
|
+
deepMixin(target, source);
|
|
70
|
+
|
|
71
|
+
expect(target).toEqual({
|
|
72
|
+
config: { enabled: true },
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should handle arrays by replacing them', () => {
|
|
77
|
+
const target = { items: [1, 2, 3] };
|
|
78
|
+
const source = { items: [4, 5] };
|
|
79
|
+
|
|
80
|
+
deepMixin(target, source);
|
|
81
|
+
|
|
82
|
+
expect(target).toEqual({ items: [4, 5] });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should ignore undefined values', () => {
|
|
86
|
+
const target = { a: 1, b: 2 };
|
|
87
|
+
const source = { a: undefined, c: 3 };
|
|
88
|
+
|
|
89
|
+
deepMixin(target, source);
|
|
90
|
+
|
|
91
|
+
expect(target).toEqual({ a: 1, b: 2, c: 3 });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should handle null values', () => {
|
|
95
|
+
const target = { a: 1, b: 2 };
|
|
96
|
+
const source = { a: null, c: 3 };
|
|
97
|
+
|
|
98
|
+
deepMixin(target, source);
|
|
99
|
+
|
|
100
|
+
expect(target).toEqual({ a: null, b: 2, c: 3 });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should handle deeply nested structures', () => {
|
|
104
|
+
const target = {
|
|
105
|
+
level1: {
|
|
106
|
+
level2: {
|
|
107
|
+
level3: { value: 'old' },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const source = {
|
|
112
|
+
level1: {
|
|
113
|
+
level2: {
|
|
114
|
+
level3: { value: 'new', extra: 'added' },
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
deepMixin(target, source);
|
|
120
|
+
|
|
121
|
+
expect(target).toEqual({
|
|
122
|
+
level1: {
|
|
123
|
+
level2: {
|
|
124
|
+
level3: { value: 'new', extra: 'added' },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should handle empty objects', () => {
|
|
131
|
+
const target = {};
|
|
132
|
+
const source = {};
|
|
133
|
+
|
|
134
|
+
const result = deepMixin(target, source);
|
|
135
|
+
|
|
136
|
+
expect(result).toEqual({});
|
|
137
|
+
expect(result).toBe(target);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should handle complex mixed types', () => {
|
|
141
|
+
const target: any = {
|
|
142
|
+
string: 'value',
|
|
143
|
+
number: 42,
|
|
144
|
+
boolean: true,
|
|
145
|
+
object: { nested: 'value' },
|
|
146
|
+
array: [1, 2, 3],
|
|
147
|
+
};
|
|
148
|
+
const source: any = {
|
|
149
|
+
string: 'new value',
|
|
150
|
+
number: 100,
|
|
151
|
+
boolean: false,
|
|
152
|
+
object: { nested: 'new value', added: 'property' },
|
|
153
|
+
array: [4, 5],
|
|
154
|
+
newProp: 'added',
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
deepMixin(target, source);
|
|
158
|
+
|
|
159
|
+
expect(target).toEqual({
|
|
160
|
+
string: 'new value',
|
|
161
|
+
number: 100,
|
|
162
|
+
boolean: false,
|
|
163
|
+
object: { nested: 'new value', added: 'property' },
|
|
164
|
+
array: [4, 5],
|
|
165
|
+
newProp: 'added',
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
describe('yesLog', () => {
|
|
4
|
+
const originalVerbose = process.env.VERBOSE;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
// Reset modules to ensure fresh state
|
|
8
|
+
delete require.cache[require.resolve('./yesLog')];
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
// Restore original VERBOSE setting
|
|
13
|
+
if (originalVerbose !== undefined) {
|
|
14
|
+
process.env.VERBOSE = originalVerbose;
|
|
15
|
+
} else {
|
|
16
|
+
delete process.env.VERBOSE;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should not crash when VERBOSE is not set', async () => {
|
|
21
|
+
delete process.env.VERBOSE;
|
|
22
|
+
|
|
23
|
+
const { yesLog } = await import('./yesLog');
|
|
24
|
+
|
|
25
|
+
// Should not throw and returns undefined
|
|
26
|
+
const result = yesLog`Test message`;
|
|
27
|
+
expect(result).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should be callable with template literals', async () => {
|
|
31
|
+
delete process.env.VERBOSE;
|
|
32
|
+
|
|
33
|
+
const { yesLog } = await import('./yesLog');
|
|
34
|
+
|
|
35
|
+
// Should not throw with variables
|
|
36
|
+
const variable = 'test value';
|
|
37
|
+
const result = yesLog`Message with ${variable}`;
|
|
38
|
+
expect(result).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should handle multiple calls', async () => {
|
|
42
|
+
delete process.env.VERBOSE;
|
|
43
|
+
|
|
44
|
+
const { yesLog } = await import('./yesLog');
|
|
45
|
+
|
|
46
|
+
// Multiple calls should not throw
|
|
47
|
+
expect(yesLog`First message`).toBeUndefined();
|
|
48
|
+
expect(yesLog`Second message`).toBeUndefined();
|
|
49
|
+
expect(yesLog`Third message`).toBeUndefined();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should work when VERBOSE is set', async () => {
|
|
53
|
+
process.env.VERBOSE = '1';
|
|
54
|
+
|
|
55
|
+
const { yesLog } = await import('./yesLog');
|
|
56
|
+
|
|
57
|
+
// Should not throw even when verbose
|
|
58
|
+
expect(yesLog`Verbose message`).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should handle template literals with different types', async () => {
|
|
62
|
+
delete process.env.VERBOSE;
|
|
63
|
+
|
|
64
|
+
const { yesLog } = await import('./yesLog');
|
|
65
|
+
|
|
66
|
+
const number = 42;
|
|
67
|
+
const object = { key: 'value' };
|
|
68
|
+
const array = [1, 2, 3];
|
|
69
|
+
|
|
70
|
+
expect(yesLog`Number: ${number}`).toBeUndefined();
|
|
71
|
+
expect(yesLog`Object: ${object}`).toBeUndefined();
|
|
72
|
+
expect(yesLog`Array: ${array}`).toBeUndefined();
|
|
73
|
+
});
|
|
74
|
+
});
|