@@ -3,8 +3,8 @@ import os from "node:os";
33import path from "node:path" ;
44import { isEnoent } from "./error.js" ;
55
6- const observableConfigName = ".observablehq" ;
7- interface ObservableConfig {
6+ const userConfigName = ".observablehq" ;
7+ interface UserConfig {
88 auth ?: {
99 id : string ;
1010 key : string ;
@@ -20,14 +20,14 @@ export interface DeployConfig {
2020}
2121
2222export async function getObservableApiKey ( ) : Promise < string | null > {
23- const { config} = await loadObservableConfig ( ) ;
23+ const { config} = await loadUserConfig ( ) ;
2424 return config . auth ?. key ?? null ;
2525}
2626
2727export async function setObservableApiKey ( id : string , key : string ) : Promise < void > {
28- const { config, configPath} = await loadObservableConfig ( ) ;
28+ const { config, configPath} = await loadUserConfig ( ) ;
2929 config . auth = { id, key} ;
30- await writeObservableConfig ( { config, configPath} ) ;
30+ await writeUserConfig ( { config, configPath} ) ;
3131}
3232
3333export async function getDeployConfig ( sourceRoot : string ) : Promise < DeployConfig | null > {
@@ -48,10 +48,10 @@ export async function setDeployConfig(sourceRoot: string, newConfig: DeployConfi
4848 await fs . writeFile ( deployConfigPath , JSON . stringify ( merged , null , 2 ) ) ;
4949}
5050
51- async function loadObservableConfig ( ) : Promise < { configPath : string ; config : ObservableConfig } > {
51+ async function loadUserConfig ( ) : Promise < { configPath : string ; config : UserConfig } > {
5252 let cursor = path . resolve ( process . cwd ( ) ) ;
5353 while ( true ) {
54- const configPath = path . join ( cursor , observableConfigName ) ;
54+ const configPath = path . join ( cursor , userConfigName ) ;
5555 let content : string | null = null ;
5656 try {
5757 content = await fs . readFile ( configPath , "utf8" ) ;
@@ -71,15 +71,9 @@ async function loadObservableConfig(): Promise<{configPath: string; config: Obse
7171 }
7272 }
7373
74- return { config : { } , configPath : path . join ( os . homedir ( ) , observableConfigName ) } ;
74+ return { config : { } , configPath : path . join ( os . homedir ( ) , userConfigName ) } ;
7575}
7676
77- async function writeObservableConfig ( {
78- configPath,
79- config
80- } : {
81- configPath : string ;
82- config : ObservableConfig ;
83- } ) : Promise < void > {
77+ async function writeUserConfig ( { configPath, config} : { configPath : string ; config : UserConfig } ) : Promise < void > {
8478 await fs . writeFile ( configPath , JSON . stringify ( config , null , 2 ) ) ;
8579}
0 commit comments