Skip to content

Commit b6a019b

Browse files
feat: add tw update self-update command (#46)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2cbfda commit b6a019b

File tree

16 files changed

+368
-101
lines changed

16 files changed

+368
-101
lines changed

src/__mocks__/chalk.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const passthrough = (text: string) => text
2+
3+
function createChalkProxy(): typeof passthrough {
4+
return new Proxy(passthrough, {
5+
get: () => createChalkProxy(),
6+
}) as typeof passthrough
7+
}
8+
9+
export default createChalkProxy()

src/__tests__/auth.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ vi.mock('node:readline', () => ({
5151
}))
5252

5353
// Mock chalk to avoid colors in tests
54-
vi.mock('chalk', () => ({
55-
default: {
56-
green: vi.fn((text) => text),
57-
yellow: vi.fn((text) => text),
58-
red: vi.fn((text) => text),
59-
blue: vi.fn((text) => text),
60-
dim: vi.fn((text) => text),
61-
},
62-
}))
54+
vi.mock('chalk')
6355

6456
import { createInterface, type Interface } from 'node:readline'
6557
import { type User } from '@doist/twist-sdk'

src/__tests__/channel.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,7 @@ vi.mock('../lib/public-channels.js', () => ({
1414
includePrivateChannels: vi.fn().mockReturnValue(true),
1515
}))
1616

17-
vi.mock('chalk', () => ({
18-
default: {
19-
bold: Object.assign(
20-
vi.fn((text: string) => text),
21-
{
22-
blue: vi.fn((text: string) => text),
23-
},
24-
),
25-
dim: vi.fn((text: string) => text),
26-
blue: vi.fn((text: string) => text),
27-
},
28-
}))
17+
vi.mock('chalk')
2918

3019
import { registerChannelCommand } from '../commands/channel.js'
3120

src/__tests__/conversation.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@ vi.mock('../lib/markdown.js', () => ({
1515
renderMarkdown: vi.fn((text: string) => text),
1616
}))
1717

18-
vi.mock('chalk', () => ({
19-
default: {
20-
bold: Object.assign(
21-
vi.fn((text: string) => text),
22-
{
23-
blue: vi.fn((text: string) => text),
24-
},
25-
),
26-
dim: vi.fn((text: string) => text),
27-
blue: vi.fn((text: string) => text),
28-
},
29-
}))
18+
vi.mock('chalk')
3019

3120
import { registerConversationCommand } from '../commands/conversation.js'
3221

src/__tests__/inbox.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@ vi.mock('../lib/public-channels.js', () => ({
1515
getPublicChannelIds: vi.fn(),
1616
}))
1717

18-
vi.mock('chalk', () => ({
19-
default: {
20-
bold: Object.assign(
21-
vi.fn((text: string) => text),
22-
{
23-
blue: vi.fn((text: string) => text),
24-
},
25-
),
26-
dim: vi.fn((text: string) => text),
27-
blue: vi.fn((text: string) => text),
28-
},
29-
}))
18+
vi.mock('chalk')
3019

3120
import { registerInboxCommand } from '../commands/inbox.js'
3221

src/__tests__/msg.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,7 @@ vi.mock('../lib/markdown.js', () => ({
1313
renderMarkdown: vi.fn((text: string) => text),
1414
}))
1515

16-
vi.mock('chalk', () => ({
17-
default: {
18-
bold: Object.assign(
19-
vi.fn((text: string) => text),
20-
{
21-
blue: vi.fn((text: string) => text),
22-
},
23-
),
24-
dim: vi.fn((text: string) => text),
25-
blue: vi.fn((text: string) => text),
26-
},
27-
}))
16+
vi.mock('chalk')
2817

2918
import { registerMsgCommand } from '../commands/msg.js'
3019

src/__tests__/search.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ vi.mock('../lib/public-channels.js', () => ({
2525

2626
vi.mock('../lib/search-api.js', () => searchApiMocks)
2727

28-
vi.mock('chalk', () => ({
29-
default: {
30-
bold: vi.fn((text: string) => text),
31-
dim: vi.fn((text: string) => text),
32-
},
33-
}))
28+
vi.mock('chalk')
3429

3530
import { registerSearchCommand } from '../commands/search.js'
3631

src/__tests__/skill.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ import { join } from 'node:path'
44
import { Command } from 'commander'
55
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
66

7-
vi.mock('chalk', () => ({
8-
default: {
9-
green: vi.fn((text) => text),
10-
red: vi.fn((text) => text),
11-
bold: vi.fn((text) => text),
12-
dim: vi.fn((text) => text),
13-
},
14-
}))
7+
vi.mock('chalk')
158

169
import { registerSkillCommand } from '../commands/skill.js'
1710
import { SKILL_FILE_CONTENT } from '../lib/skills/content.js'

src/__tests__/spinner.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@ vi.mock('yocto-spinner', () => ({
2222
}))
2323

2424
// Mock chalk to avoid colors in tests
25-
vi.mock('chalk', () => ({
26-
default: {
27-
green: vi.fn((text) => text),
28-
yellow: vi.fn((text) => text),
29-
blue: vi.fn((text) => text),
30-
red: vi.fn((text) => text),
31-
gray: vi.fn((text) => text),
32-
cyan: vi.fn((text) => text),
33-
magenta: vi.fn((text) => text),
34-
},
35-
}))
25+
vi.mock('chalk')
3626

3727
describe('withSpinner', () => {
3828
beforeEach(() => {

src/__tests__/thread.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@ vi.mock('../lib/input.js', () => ({
1818
openEditor: vi.fn().mockResolvedValue(''),
1919
}))
2020

21-
vi.mock('chalk', () => ({
22-
default: {
23-
bold: Object.assign(
24-
vi.fn((text: string) => text),
25-
{
26-
blue: vi.fn((text: string) => text),
27-
},
28-
),
29-
dim: vi.fn((text: string) => text),
30-
blue: vi.fn((text: string) => text),
31-
},
32-
}))
21+
vi.mock('chalk')
3322

3423
import { registerThreadCommand } from '../commands/thread.js'
3524

0 commit comments

Comments
 (0)