UNPKG

keycloak-testcontainer

Version:
69 lines (68 loc) 2.11 kB
export class CommandsBuilder { constructor() { this.features = []; this.disabledFeatures = []; this.isMetricsEnabled = false; this.shouldImportRealm = false; this.isHealthEnabled = false; this.isThemeCacheDisabled = false; } withHealth() { this.isHealthEnabled = true; return this; } withRealmImport() { this.shouldImportRealm = true; return this; } withDatabase(options) { this.database = options; return this; } withMetrics() { this.isMetricsEnabled = true; return this; } withFeatures(features) { this.features = features; return this; } withThemeCacheDisabled() { this.isThemeCacheDisabled = true; return this; } withDisabledFeatures(disabledFeatures) { this.disabledFeatures = disabledFeatures; return this; } build() { const commands = ['start-dev']; if (this.isMetricsEnabled) { commands.push('--metrics-enabled=true'); } if (this.features.length > 0) { commands.push(`--features=${this.features.join(',')}`); } if (this.disabledFeatures.length > 0) { commands.push(`--features-disabled=${this.disabledFeatures.join(',')}`); } if (this.database) { commands.push(`--db=${this.database.vendor}`); commands.push(`--db-url=${this.database.url}`); commands.push(`--db-username=${this.database.username}`); commands.push(`--db-password=${this.database.password}`); } if (this.shouldImportRealm) { commands.push('--import-realm'); } if (this.isHealthEnabled) { commands.push('--health-enabled=true'); } if (this.isThemeCacheDisabled) { commands.push('--spi-theme-static-max-age=-1'); commands.push('--spi-theme-cache-themes=false'); commands.push('--spi-theme-cache-templates=false'); } return commands; } }