Skip to content

Commit 351a242

Browse files
committed
fix(cli): allow unauthenticated access to help
1 parent 33453cf commit 351a242

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎src/main.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const NO_AUTH_SETUP = [
3232
['config', 'show'],
3333
['config', 'set'],
3434
['config', 'export-schema'],
35+
['help'],
3536
['update'],
3637
];
3738

‎test/commands/help.test.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
2+
import { mkdtempSync, rmSync } from 'fs';
3+
import { tmpdir } from 'os';
4+
import { join } from 'path';
5+
6+
describe('mmx help', () => {
7+
let home: string;
8+
let originalHome: string | undefined;
9+
10+
beforeEach(() => {
11+
home = mkdtempSync(join(tmpdir(), 'mmx-help-'));
12+
originalHome = process.env.HOME;
13+
process.env.HOME = home;
14+
});
15+
16+
afterEach(() => {
17+
if (originalHome === undefined) delete process.env.HOME;
18+
else process.env.HOME = originalHome;
19+
rmSync(home, { recursive: true, force: true });
20+
});
21+
22+
it('prints documentation links without requiring credentials', async () => {
23+
const child = Bun.spawn({
24+
cmd: [process.execPath, 'run', 'src/main.ts', 'help'],
25+
cwd: process.cwd(),
26+
env: {
27+
...process.env,
28+
HOME: home,
29+
MMX_CONFIG_DIR: join(home, '.mmx'),
30+
NO_COLOR: '1',
31+
MINIMAX_API_KEY: '',
32+
},
33+
stdout: 'pipe',
34+
stderr: 'pipe',
35+
});
36+
37+
const [stdout, stderr, exitCode] = await Promise.all([
38+
new Response(child.stdout).text(),
39+
new Response(child.stderr).text(),
40+
child.exited,
41+
]);
42+
43+
expect(exitCode).toBe(0);
44+
expect(stdout).toContain('MiniMax API Documentation Links');
45+
expect(stderr).not.toContain('No credentials found');
46+
expect(stderr).not.toContain('How would you like to authenticate');
47+
});
48+
});

0 commit comments

Comments
 (0)