()
| 55 | } |
| 56 | |
| 57 | private static async loadConfig(): Promise<void> { |
| 58 | if (this.config) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | const initialConfig = this.getDefaultConfig(); |
| 63 | |
| 64 | const config: Config = { |
| 65 | ...initialConfig, |
| 66 | }; |
| 67 | |
| 68 | try { |
| 69 | const configFromFile: Config = (await import(toFileUrl(join(Deno.cwd(), 'bewcloud.config.ts')).href)).default; |
| 70 | |
| 71 | this.config = { |
| 72 | ...config, |
| 73 | auth: { |
| 74 | ...config.auth, |
| 75 | ...configFromFile.auth, |
| 76 | }, |
| 77 | files: { |
| 78 | ...config.files, |
| 79 | ...configFromFile.files, |
| 80 | }, |
| 81 | core: { |
| 82 | ...config.core, |
| 83 | ...configFromFile.core, |
| 84 | }, |
| 85 | visuals: { |
| 86 | ...config.visuals, |
| 87 | ...configFromFile.visuals, |
| 88 | }, |
| 89 | email: { |
| 90 | ...config.email, |
| 91 | ...configFromFile.email, |
| 92 | }, |
| 93 | contacts: { |
| 94 | ...config.contacts, |
| 95 | ...configFromFile.contacts, |
| 96 | }, |
| 97 | calendar: { |
| 98 | ...config.calendar, |
| 99 | ...configFromFile.calendar, |
| 100 | }, |
| 101 | }; |
| 102 | |
| 103 | console.info('\nConfig loaded from bewcloud.config.ts', JSON.stringify(this.config, null, 2), '\n'); |
| 104 | |
| 105 | if (this.config.core.enabledApps.length === 0) { |
| 106 | throw new Error('At least one app must be enabled. Please check the config.core.enabledApps array.'); |
| 107 | } |
| 108 | |
| 109 | return; |
| 110 | } catch (error) { |
| 111 | console.error('Error loading config from bewcloud.config.ts. Using default config instead.', error); |
| 112 | } |
| 113 | |
| 114 | this.config = config; |
no test coverage detected