import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  USER_CONFIG_FILENAME,
  userConfigSchema
} from "./chunk-YT5BPQDJ.js";
import {
  getDataDirPath
} from "./chunk-LU3R3EBR.js";
import {
  pathExists,
  readJson,
  writeJson
} from "./chunk-VASURI4S.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-user-config/src/index.ts
init_esm_shims();

// ../cli-user-config/src/user-config.ts
init_esm_shims();
import { join } from "node:path";
function getUserConfigPath() {
  return join(getDataDirPath(), USER_CONFIG_FILENAME);
}
async function readUserConfig() {
  const configPath = getUserConfigPath();
  const isConfigExist = await pathExists(configPath);
  const json = isConfigExist ? await readJson(configPath) : {};
  return userConfigSchema.parse(json);
}
async function updateUserConfig(config) {
  const currentConfig = await readUserConfig();
  const newConfig = {
    ...currentConfig,
    ...config
  };
  const configPath = getUserConfigPath();
  await writeJson(configPath, newConfig);
}

export {
  readUserConfig,
  updateUserConfig
};
//# sourceMappingURL=chunk-SVUXJRFD.js.map