mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-13 11:22:11 +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
72
packages/cli/test/community-cta.test.ts
Normal file
72
packages/cli/test/community-cta.test.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
SLACK_HELP_FOOTER,
|
||||
SLACK_SETUP_NOTE,
|
||||
writeErrorCommunityHint,
|
||||
} from '../src/community-cta.js';
|
||||
import type { KtxCliIo } 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('community CTA', () => {
|
||||
it('writes the error hint to TTY stderr', () => {
|
||||
const testIo = makeIo(true);
|
||||
|
||||
writeErrorCommunityHint(testIo.io, 'error');
|
||||
|
||||
expect(testIo.stderr()).toContain('Stuck? The ktx community can help');
|
||||
expect(testIo.stderr()).toContain('https://ktx.sh/slack');
|
||||
});
|
||||
|
||||
it('suppresses the error hint for non-TTY stderr', () => {
|
||||
const testIo = makeIo(false);
|
||||
|
||||
writeErrorCommunityHint(testIo.io, 'error');
|
||||
|
||||
expect(testIo.stderr()).toBe('');
|
||||
});
|
||||
|
||||
it('uses stronger crash copy for crash hints', () => {
|
||||
const testIo = makeIo(true);
|
||||
|
||||
writeErrorCommunityHint(testIo.io, 'crash');
|
||||
|
||||
expect(testIo.stderr()).toContain('This may be a bug');
|
||||
expect(testIo.stderr()).toContain('https://ktx.sh/slack');
|
||||
});
|
||||
|
||||
it('exports setup and help copy with the stable Slack URL', () => {
|
||||
expect(SLACK_HELP_FOOTER).toBe('Community & support: https://ktx.sh/slack');
|
||||
expect(SLACK_SETUP_NOTE).toEqual({
|
||||
title: 'Community',
|
||||
body: 'Questions or feedback? Join the ktx Slack: https://ktx.sh/slack',
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue