mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-01 08:59:39 +02:00
feat(cli): offer connection URL paste first in database setup
Users most commonly paste a connection URL rather than entering fields individually, so surface that option first in the connection method prompt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcdf5234c6
commit
d567ffec48
2 changed files with 40 additions and 3 deletions
|
|
@ -142,8 +142,8 @@ describe('setup databases step', () => {
|
||||||
expect(prompts.select).toHaveBeenCalledWith({
|
expect(prompts.select).toHaveBeenCalledWith({
|
||||||
message: 'How do you want to connect to PostgreSQL?',
|
message: 'How do you want to connect to PostgreSQL?',
|
||||||
options: [
|
options: [
|
||||||
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
|
||||||
{ value: 'url', label: 'Paste a connection URL' },
|
{ value: 'url', label: 'Paste a connection URL' },
|
||||||
|
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
||||||
{ value: 'back', label: 'Back' },
|
{ value: 'back', label: 'Back' },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
@ -154,6 +154,43 @@ describe('setup databases step', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('offers connection URL paste first for URL-capable primary sources', async () => {
|
||||||
|
const cases: Array<{ driver: KtxSetupDatabaseDriver; label: string }> = [
|
||||||
|
{ driver: 'postgres', label: 'PostgreSQL' },
|
||||||
|
{ driver: 'mysql', label: 'MySQL' },
|
||||||
|
{ driver: 'clickhouse', label: 'ClickHouse' },
|
||||||
|
{ driver: 'sqlserver', label: 'SQL Server' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const testCase of cases) {
|
||||||
|
const prompts = makePromptAdapter({
|
||||||
|
selectValues: ['back'],
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await runKtxSetupDatabasesStep(
|
||||||
|
{
|
||||||
|
projectDir: tempDir,
|
||||||
|
inputMode: 'auto',
|
||||||
|
databaseDrivers: [testCase.driver],
|
||||||
|
skipDatabases: false,
|
||||||
|
databaseSchemas: [],
|
||||||
|
},
|
||||||
|
makeIo().io,
|
||||||
|
{ prompts },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.status).toBe('back');
|
||||||
|
expect(prompts.select).toHaveBeenCalledWith({
|
||||||
|
message: `How do you want to connect to ${testCase.label}?`,
|
||||||
|
options: [
|
||||||
|
{ value: 'url', label: 'Paste a connection URL' },
|
||||||
|
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
||||||
|
{ value: 'back', label: 'Back' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('lets Back leave database setup when the driver came from flags', async () => {
|
it('lets Back leave database setup when the driver came from flags', async () => {
|
||||||
const prompts = makePromptAdapter({ selectValues: ['back'] });
|
const prompts = makePromptAdapter({ selectValues: ['back'] });
|
||||||
|
|
||||||
|
|
@ -488,8 +525,8 @@ describe('setup databases step', () => {
|
||||||
expect(prompts.select).toHaveBeenNthCalledWith(1, {
|
expect(prompts.select).toHaveBeenNthCalledWith(1, {
|
||||||
message: 'How do you want to connect to PostgreSQL?',
|
message: 'How do you want to connect to PostgreSQL?',
|
||||||
options: [
|
options: [
|
||||||
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
|
||||||
{ value: 'url', label: 'Paste a connection URL' },
|
{ value: 'url', label: 'Paste a connection URL' },
|
||||||
|
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
||||||
{ value: 'back', label: 'Back' },
|
{ value: 'back', label: 'Back' },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -615,8 +615,8 @@ async function buildUrlConnectionConfig(input: {
|
||||||
const choice = await input.prompts.select({
|
const choice = await input.prompts.select({
|
||||||
message: `How do you want to connect to ${label}?`,
|
message: `How do you want to connect to ${label}?`,
|
||||||
options: [
|
options: [
|
||||||
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
|
||||||
{ value: 'url', label: 'Paste a connection URL' },
|
{ value: 'url', label: 'Paste a connection URL' },
|
||||||
|
{ value: 'fields', label: 'Enter connection details (host, port, database, user)' },
|
||||||
{ value: 'back', label: 'Back' },
|
{ value: 'back', label: 'Back' },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue