flora is a fast and secure runtime that lets you write discord bots for your servers, with a rich TypeScript SDK, without worrying about running infrastructure. [mirror]
1import { loadConfig as loadC12 } from 'c12'
2import Conf from 'conf'
3
4import { type CliConfig, DEFAULT_API_URL, type DeployProjectConfig } from './types'
5
6const store = new Conf<CliConfig>({
7 projectName: 'flora',
8 configName: 'cli',
9 defaults: {
10 apiUrl: DEFAULT_API_URL,
11 token: undefined
12 }
13})
14
15export function loadConfig(): CliConfig {
16 const apiUrl = store.get('apiUrl') ?? DEFAULT_API_URL
17 const token = store.get('token')
18 return { apiUrl, token }
19}
20
21export function saveConfig(config: CliConfig): void {
22 store.set(config)
23}
24
25export async function loadProjectConfig(cwd = process.cwd()): Promise<DeployProjectConfig> {
26 const { config } = await loadC12<{ deploy?: DeployProjectConfig }>({
27 cwd,
28 name: 'flora',
29 configFile: 'flora.config',
30 rcFile: false,
31 packageJson: false,
32 defaults: {
33 deploy: {}
34 }
35 })
36
37 return config.deploy ?? {}
38}