From 292d643e58b0e4bffc4b02bec4495c087428d15e Mon Sep 17 00:00:00 2001 From: Federico Bozzini Date: Tue, 4 Aug 2026 17:11:34 +0100 Subject: [PATCH] feat: only support compose.yaml for configure command Signed-off-by: Federico Bozzini --- src/actions/configure.test.ts | 20 +++++++++++++++----- src/actions/configure.ts | 9 ++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/actions/configure.test.ts b/src/actions/configure.test.ts index a3e5fa4f..24f9dea9 100644 --- a/src/actions/configure.test.ts +++ b/src/actions/configure.test.ts @@ -8,7 +8,7 @@ import { Configure, configure } from './configure'; describe('Configure', () => { const composeFileUri = vscode.Uri.file( - path.join(os.tmpdir(), 'demo', 'compose.yml'), + path.join(os.tmpdir(), 'demo', 'compose.yaml'), ); const projectPath = path.dirname(composeFileUri.fsPath); let taskExecutor: MockProxy; @@ -18,7 +18,7 @@ describe('Configure', () => { expect(task.name).toBe('Configure demo'); expect(task.execution).toMatchObject({ process: 'topo', - args: ['configure', '--file', 'compose.yml'], + args: ['configure', '--file', 'compose.yaml'], options: { cwd: projectPath }, }); } @@ -51,9 +51,7 @@ describe('Configure', () => { it('throws when the context command has no compose file', async () => { await expect( configureAction.configureContextCommandHandler(), - ).rejects.toThrow( - 'No compose.yaml or compose.yml selected for configuration', - ); + ).rejects.toThrow('No compose.yaml selected for configuration'); expect(taskExecutor.run).not.toHaveBeenCalled(); }); @@ -74,6 +72,18 @@ describe('Configure', () => { ); }); + it('rejects compose.yml without invoking topo', async () => { + const unsupportedComposeFile = path.join(projectPath, 'compose.yml'); + + await expect( + configure(taskExecutor, unsupportedComposeFile), + ).rejects.toThrow( + 'Unsupported compose file "compose.yml". Only compose.yaml is supported.', + ); + + expect(taskExecutor.run).not.toHaveBeenCalled(); + }); + it('reports task failure', async () => { taskExecutor.run.mockRejectedValueOnce(new Error('configure failed')); diff --git a/src/actions/configure.ts b/src/actions/configure.ts index 0e648ec8..4ac66b03 100644 --- a/src/actions/configure.ts +++ b/src/actions/configure.ts @@ -1,6 +1,7 @@ import path from 'node:path'; import * as vscode from 'vscode'; import { getErrorMessage } from '../util/getErrorMessage'; +import { assertComposeFilePath, COMPOSE_FILE_NAME } from '../util/composeFile'; import { createProcessTask } from '../util/task'; import { TaskExecutor } from '../util/taskExecutor'; import { assertProjectTreeItem } from '../views/treeItems/assertProjectTreeItem'; @@ -16,9 +17,7 @@ export class Configure { resource?: vscode.Uri, ): Promise { if (!resource) { - throw new Error( - 'No compose.yaml or compose.yml selected for configuration', - ); + throw new Error('No compose.yaml selected for configuration'); } await configure(this.taskExecutor, resource.fsPath); @@ -36,12 +35,12 @@ export async function configure( taskExecutor: TaskExecutor, composeFilePath: string, ): Promise { + assertComposeFilePath(composeFilePath); const composeFileDir = path.dirname(composeFilePath); - const composeFileName = path.basename(composeFilePath); const projectName = path.basename(composeFileDir); const task = createProcessTask( `Configure ${projectName}`, - ['topo', 'configure', '--file', composeFileName], + ['topo', 'configure', '--file', COMPOSE_FILE_NAME], { cwd: composeFileDir, },