mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +02:00
feat(cli): add Slack community CTA on errors, crashes, setup, and help (#277)
* feat(cli): show Slack CTA on help and unexpected errors * feat(cli): show Slack CTA after crashes * feat(setup): show Slack community note after setup * chore: refresh Python lockfile versions
This commit is contained in:
parent
6b2f7c3365
commit
66517fc320
14 changed files with 350 additions and 29 deletions
53
packages/cli/test/cli-runtime.test.ts
Normal file
53
packages/cli/test/cli-runtime.test.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import type { KtxCliIo } from '../src/cli-runtime.js';
|
||||
import { writeGlobalExceptionToStderr } from '../src/cli-runtime.js';
|
||||
|
||||
function makeIo(stderrIsTty: boolean): { io: KtxCliIo; stderr: () => string } {
|
||||
let stderr = '';
|
||||
const stderrStream = stderrIsTty
|
||||
? {
|
||||
isTTY: true,
|
||||
columns: 80,
|
||||
on: () => undefined,
|
||||
write: (chunk: string) => {
|
||||
stderr += chunk;
|
||||
},
|
||||
}
|
||||
: {
|
||||
write: (chunk: string) => {
|
||||
stderr += chunk;
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
io: {
|
||||
stdout: {
|
||||
write: () => undefined,
|
||||
},
|
||||
stderr: stderrStream,
|
||||
},
|
||||
stderr: () => stderr,
|
||||
};
|
||||
}
|
||||
|
||||
describe('writeGlobalExceptionToStderr', () => {
|
||||
it('prints the crash Slack hint after a stack on TTY stderr', () => {
|
||||
const testIo = makeIo(true);
|
||||
|
||||
writeGlobalExceptionToStderr(testIo.io, new Error('global boom'));
|
||||
|
||||
expect(testIo.stderr()).toContain('Error: global boom');
|
||||
expect(testIo.stderr()).toContain('This may be a bug');
|
||||
expect(testIo.stderr()).toContain('https://ktx.sh/slack');
|
||||
});
|
||||
|
||||
it('prints crash details without the Slack hint on non-TTY stderr', () => {
|
||||
const testIo = makeIo(false);
|
||||
|
||||
writeGlobalExceptionToStderr(testIo.io, 'global boom');
|
||||
|
||||
expect(testIo.stderr()).toContain('global boom');
|
||||
expect(testIo.stderr()).not.toContain('https://ktx.sh/slack');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue