fix: show setup destination paths (#63)

This commit is contained in:
Andrey Avtomonov 2026-05-13 14:27:29 +02:00 committed by GitHub
parent b75576279c
commit d4d8ad1724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 5 deletions

View file

@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { initKtxProject, parseKtxProjectConfig, readKtxSetupState } from '@ktx/context/project';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { gray } from './io/symbols.js';
import { type KtxSetupProjectPromptAdapter, runKtxSetupProjectStep } from './setup-project.js';
function makeIo(options: { stdoutIsTty?: boolean } = {}) {
@ -37,6 +38,12 @@ function makePromptAdapter(options: { choice?: string; choices?: string[]; textV
} satisfies KtxSetupProjectPromptAdapter;
}
function defaultSubfolderLabel(parentDir: string): string {
const childName = 'ktx-project';
const childDir = join(parentDir, childName);
return `New subfolder (${gray(childDir.slice(0, -childName.length))}${childName})`;
}
describe('setup project step', () => {
let tempDir: string;
@ -143,8 +150,11 @@ describe('setup project step', () => {
expect.objectContaining({
message: 'Where should KTX create the project?',
options: [
expect.objectContaining({ value: 'current', label: 'Current directory' }),
expect.objectContaining({ value: 'new-default', label: 'New subfolder (./ktx-project)' }),
expect.objectContaining({ value: 'current', label: `Current directory (${projectDir})` }),
expect.objectContaining({
value: 'new-default',
label: defaultSubfolderLabel(projectDir),
}),
expect.objectContaining({ value: 'new-custom', label: 'Custom path' }),
expect.objectContaining({ value: 'exit', label: 'Exit' }),
],
@ -174,7 +184,10 @@ describe('setup project step', () => {
expect.objectContaining({
message: 'Where should KTX create the project?',
options: expect.arrayContaining([
expect.objectContaining({ value: 'new-default', label: 'New subfolder (./ktx-project)' }),
expect.objectContaining({
value: 'new-default',
label: defaultSubfolderLabel(startDir),
}),
]),
}),
);