Default paseo to start daemon and seed first-run config
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
import { createCli } from './cli.js'
|
import { createCli } from './cli.js'
|
||||||
|
|
||||||
const program = createCli()
|
const program = createCli()
|
||||||
|
if (process.argv.length <= 2) {
|
||||||
|
process.argv.push('start')
|
||||||
|
}
|
||||||
program.parse()
|
program.parse()
|
||||||
|
|||||||
@@ -144,6 +144,21 @@ export const PersistedConfigSchema = z
|
|||||||
export type PersistedConfig = z.infer<typeof PersistedConfigSchema>;
|
export type PersistedConfig = z.infer<typeof PersistedConfigSchema>;
|
||||||
|
|
||||||
const CONFIG_FILENAME = "config.json";
|
const CONFIG_FILENAME = "config.json";
|
||||||
|
const DEFAULT_PERSISTED_CONFIG: PersistedConfig = PersistedConfigSchema.parse({
|
||||||
|
version: 1,
|
||||||
|
daemon: {
|
||||||
|
listen: "127.0.0.1:6767",
|
||||||
|
cors: {
|
||||||
|
allowedOrigins: ["https://app.paseo.sh"],
|
||||||
|
},
|
||||||
|
relay: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
app: {
|
||||||
|
baseUrl: "https://app.paseo.sh",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
type LoggerLike = {
|
type LoggerLike = {
|
||||||
child(bindings: Record<string, unknown>): LoggerLike;
|
child(bindings: Record<string, unknown>): LoggerLike;
|
||||||
@@ -164,18 +179,16 @@ export function loadPersistedConfig(
|
|||||||
): PersistedConfig {
|
): PersistedConfig {
|
||||||
const log = getLogger(logger);
|
const log = getLogger(logger);
|
||||||
const configPath = getConfigPath(paseoHome);
|
const configPath = getConfigPath(paseoHome);
|
||||||
const defaultConfig = PersistedConfigSchema.parse({});
|
|
||||||
|
|
||||||
if (!existsSync(configPath)) {
|
if (!existsSync(configPath)) {
|
||||||
try {
|
try {
|
||||||
mkdirSync(path.dirname(configPath), { recursive: true });
|
mkdirSync(path.dirname(configPath), { recursive: true });
|
||||||
writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + "\n");
|
writeFileSync(configPath, JSON.stringify(DEFAULT_PERSISTED_CONFIG, null, 2) + "\n");
|
||||||
log?.info(`Initialized config file at ${configPath}`);
|
log?.info(`Initialized config file at ${configPath}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = err instanceof Error ? err.message : String(err);
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
throw new Error(`[Config] Failed to initialize ${configPath}: ${message}`);
|
throw new Error(`[Config] Failed to initialize ${configPath}: ${message}`);
|
||||||
}
|
}
|
||||||
return defaultConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let raw: string;
|
let raw: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user