mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-28 08:49:38 +02:00
fix(cli): hide setup project banner
This commit is contained in:
parent
754e4a9039
commit
e50fef851f
5 changed files with 30 additions and 6 deletions
|
|
@ -162,6 +162,10 @@ function shouldSuppressProjectDirLine(path: string[], options: Record<string, un
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commandPathKey === 'ktx setup') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
commandPathKey === 'ktx status' &&
|
commandPathKey === 'ktx status' &&
|
||||||
typeof options.projectDir !== 'string' &&
|
typeof options.projectDir !== 'string' &&
|
||||||
|
|
|
||||||
|
|
@ -333,6 +333,22 @@ describe('runKtxCli', () => {
|
||||||
expect(testIo.stderr()).toBe(`Project: ${tempDir}\n`);
|
expect(testIo.stderr()).toBe(`Project: ${tempDir}\n`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not print the command-level project directory line for setup', async () => {
|
||||||
|
const setup = vi.fn(async () => 0);
|
||||||
|
const testIo = makeIo();
|
||||||
|
|
||||||
|
await expect(runKtxCli(['--project-dir', tempDir, 'setup', '--no-input'], testIo.io, { setup })).resolves.toBe(0);
|
||||||
|
|
||||||
|
expect(setup).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
command: 'run',
|
||||||
|
projectDir: tempDir,
|
||||||
|
}),
|
||||||
|
testIo.io,
|
||||||
|
);
|
||||||
|
expect(testIo.stderr()).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
it('skips the project directory line for JSON and TUI output modes', async () => {
|
it('skips the project directory line for JSON and TUI output modes', async () => {
|
||||||
const ingest = vi.fn(async () => 0);
|
const ingest = vi.fn(async () => 0);
|
||||||
const jsonIo = makeIo();
|
const jsonIo = makeIo();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ describe('project directory defaults', () => {
|
||||||
argv: ['setup', '--no-input'],
|
argv: ['setup', '--no-input'],
|
||||||
spy: setup,
|
spy: setup,
|
||||||
expected: { command: 'run', projectDir: '/tmp/ktx-env-project' },
|
expected: { command: 'run', projectDir: '/tmp/ktx-env-project' },
|
||||||
expectedStderr: 'Project: /tmp/ktx-env-project\n',
|
expectedStderr: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argv: ['scan', 'warehouse'],
|
argv: ['scan', 'warehouse'],
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,10 @@ function expectProjectStderr(result: CliResult, projectDir: string): void {
|
||||||
expect(result).toMatchObject({ code: 0, stderr: `Project: ${projectDir}\n` });
|
expect(result).toMatchObject({ code: 0, stderr: `Project: ${projectDir}\n` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expectSetupStderr(result: CliResult): void {
|
||||||
|
expect(result).toMatchObject({ code: 0, stderr: '' });
|
||||||
|
}
|
||||||
|
|
||||||
async function runSetupNewProject(projectDir: string): Promise<CliResult> {
|
async function runSetupNewProject(projectDir: string): Promise<CliResult> {
|
||||||
return await runBuiltCli([
|
return await runBuiltCli([
|
||||||
'setup',
|
'setup',
|
||||||
|
|
@ -162,7 +166,7 @@ describe('standalone built ktx CLI smoke', () => {
|
||||||
const sourceDir = join(tempDir, 'source');
|
const sourceDir = join(tempDir, 'source');
|
||||||
|
|
||||||
const init = await runSetupNewProject(projectDir);
|
const init = await runSetupNewProject(projectDir);
|
||||||
expectProjectStderr(init, projectDir);
|
expectSetupStderr(init);
|
||||||
expect(init.stdout).toContain(`Project: ${projectDir}`);
|
expect(init.stdout).toContain(`Project: ${projectDir}`);
|
||||||
|
|
||||||
await writeWarehouseConfig(projectDir);
|
await writeWarehouseConfig(projectDir);
|
||||||
|
|
@ -207,7 +211,7 @@ describe('standalone built ktx CLI smoke', () => {
|
||||||
it('runs structural and enriched scans through the built binary with manifest artifacts', async () => {
|
it('runs structural and enriched scans through the built binary with manifest artifacts', async () => {
|
||||||
const projectDir = join(tempDir, 'scan-project');
|
const projectDir = join(tempDir, 'scan-project');
|
||||||
const init = await runSetupNewProject(projectDir);
|
const init = await runSetupNewProject(projectDir);
|
||||||
expectProjectStderr(init, projectDir);
|
expectSetupStderr(init);
|
||||||
|
|
||||||
const dbPath = join(projectDir, 'warehouse.db');
|
const dbPath = join(projectDir, 'warehouse.db');
|
||||||
createSqliteWarehouse(dbPath);
|
createSqliteWarehouse(dbPath);
|
||||||
|
|
@ -310,7 +314,7 @@ describe('standalone built ktx CLI smoke', () => {
|
||||||
it('rejects the removed connection add command through the built binary', async () => {
|
it('rejects the removed connection add command through the built binary', async () => {
|
||||||
const projectDir = join(tempDir, 'notion-project');
|
const projectDir = join(tempDir, 'notion-project');
|
||||||
const init = await runSetupNewProject(projectDir);
|
const init = await runSetupNewProject(projectDir);
|
||||||
expectProjectStderr(init, projectDir);
|
expectSetupStderr(init);
|
||||||
|
|
||||||
const add = await runBuiltCli([
|
const add = await runBuiltCli([
|
||||||
'connection',
|
'connection',
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ try {
|
||||||
'--skip-sources',
|
'--skip-sources',
|
||||||
'--skip-agents',
|
'--skip-agents',
|
||||||
]);
|
]);
|
||||||
requireProjectStderr('ktx setup', init, projectDir);
|
requireSuccess('ktx setup', init);
|
||||||
requireOutput('ktx setup', init, /Project: /);
|
requireOutput('ktx setup', init, /Project: /);
|
||||||
|
|
||||||
const emptyProjectDir = join(root, 'empty-project');
|
const emptyProjectDir = join(root, 'empty-project');
|
||||||
|
|
@ -637,7 +637,7 @@ try {
|
||||||
'--skip-sources',
|
'--skip-sources',
|
||||||
'--skip-agents',
|
'--skip-agents',
|
||||||
]);
|
]);
|
||||||
requireProjectStderr('ktx setup empty project', emptyInit, emptyProjectDir);
|
requireSuccess('ktx setup empty project', emptyInit);
|
||||||
await writeFile(
|
await writeFile(
|
||||||
join(projectDir, 'ktx.yaml'),
|
join(projectDir, 'ktx.yaml'),
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue