@@ -5,6 +5,7 @@ import yaml from "yaml";
5
5
import { DockgeSocket , fileExists , ValidationError } from "./util-server" ;
6
6
import path from "path" ;
7
7
import {
8
+ acceptedComposeFileNames ,
8
9
COMBINED_TERMINAL_COLS ,
9
10
COMBINED_TERMINAL_ROWS ,
10
11
CREATED_FILE ,
@@ -40,8 +41,7 @@ export class Stack {
40
41
41
42
if ( ! skipFSOperations ) {
42
43
// Check if compose file name is different from compose.yaml
43
- const supportedFileNames = [ "compose.yaml" , "compose.yml" , "docker-compose.yml" , "docker-compose.yaml" ] ;
44
- for ( const filename of supportedFileNames ) {
44
+ for ( const filename of acceptedComposeFileNames ) {
45
45
if ( fs . existsSync ( path . join ( this . path , filename ) ) ) {
46
46
this . _composeFileName = filename ;
47
47
break ;
@@ -222,6 +222,26 @@ export class Stack {
222
222
}
223
223
}
224
224
225
+ /**
226
+ * Checks if a compose file exists in the specified directory.
227
+ * @async
228
+ * @static
229
+ * @param {string } stacksDir - The directory of the stack.
230
+ * @param {string } filename - The name of the directory to check for the compose file.
231
+ * @returns {Promise<boolean> } A promise that resolves to a boolean indicating whether any compose file exists.
232
+ */
233
+ static async composeFileExists ( stacksDir : string , filename : string ) : Promise < boolean > {
234
+ let filenamePath = path . join ( stacksDir , filename ) ;
235
+ // Check if any compose file exists
236
+ for ( const filename of acceptedComposeFileNames ) {
237
+ let composeFile = path . join ( filenamePath , filename ) ;
238
+ if ( await fileExists ( composeFile ) ) {
239
+ return true ;
240
+ }
241
+ }
242
+ return false ;
243
+ }
244
+
225
245
static async getStackList ( server : DockgeServer , useCacheForManaged = false ) : Promise < Map < string , Stack > > {
226
246
let stacksDir = server . stacksDir ;
227
247
let stackList : Map < string , Stack > ;
@@ -242,6 +262,10 @@ export class Stack {
242
262
if ( ! stat . isDirectory ( ) ) {
243
263
continue ;
244
264
}
265
+ // If no compose file exists, skip it
266
+ if ( ! await Stack . composeFileExists ( stacksDir , filename ) ) {
267
+ continue ;
268
+ }
245
269
let stack = await this . getStack ( server , filename ) ;
246
270
stack . _status = CREATED_FILE ;
247
271
stackList . set ( filename , stack ) ;
0 commit comments