This commit is contained in:
Jarek Krochmalski committed 2026-03-03 12:18:17 +01:00
1 parent a04040e1e9
commit bcd10c1407
2 files changed
+19 -12

No files matched your search

+9 -12
View File
@@ -9,6 +9,8 @@ import { readdirSync, existsSync, statSync, readFileSync } from 'node:fs';
import { join, basename, dirname, resolve } from 'node:path'; import { join, basename, dirname, resolve } from 'node:path';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { getExternalStackPaths, getStackSources, upsertStackSource, type StackSourceType } from './db'; import { getExternalStackPaths, getStackSources, upsertStackSource, type StackSourceType } from './db';
import { DockerConnectionError } from './docker';
import { normalizeStackName } from '$lib/utils/stack-name';
// Compose file patterns to detect (in order of priority - prefer new style first) // Compose file patterns to detect (in order of priority - prefer new style first)
const COMPOSE_PATTERNS = ['compose.yaml', 'compose.yml', 'docker-compose.yml', 'docker-compose.yaml']; const COMPOSE_PATTERNS = ['compose.yaml', 'compose.yml', 'docker-compose.yml', 'docker-compose.yaml'];
@@ -41,16 +43,8 @@ export interface ScanResult {
errors: { path: string; error: string }[]; errors: { path: string; error: string }[];
} }
/** // normalizeStackName re-exported for backward compatibility
* Normalize a stack name to be valid (lowercase alphanumeric with hyphens/underscores) export { normalizeStackName } from '$lib/utils/stack-name';
*/
export function normalizeStackName(name: string): string {
return name
.toLowerCase()
.replace(/[^a-z0-9_-]/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
}
/** /**
* Check if a file looks like a compose file (contains 'services:' key) * Check if a file looks like a compose file (contains 'services:' key)
@@ -488,8 +482,11 @@ export async function detectRunningStacks(
runningStacksMap.set(stack.name, existing); runningStacksMap.set(stack.name, existing);
} }
} catch (error) { } catch (error) {
// Environment might be offline - skip silently if (error instanceof DockerConnectionError) {
console.warn(`[Stack Scanner] Failed to query environment ${env.name}:`, error); console.warn(`[Stack Scanner] Skipping offline environment ${env.name}: ${error.message}`);
} else {
console.warn(`[Stack Scanner] Failed to query environment ${env.name}:`, error);
}
} }
}) })
); );
+10
View File
@@ -0,0 +1,10 @@
/**
* Normalize a stack name to be valid (lowercase alphanumeric with hyphens/underscores)
*/
export function normalizeStackName(name: string): string {
return name
.toLowerCase()
.replace(/[^a-z0-9_-]/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
}