import {
  parseStructuredConfig,
  readStructuredFile,
  readStructuredFileIfPresent,
  stringifyStructuredConfig,
  writeStructuredFile
} from "./structured-config.mjs";

export const DEFAULT_DEPLOY_CONFIG_PATH = "deploy/deploy.yaml";

export {
  parseStructuredConfig,
  readStructuredFile,
  readStructuredFileIfPresent,
  stringifyStructuredConfig,
  writeStructuredFile
};

export async function readDeployConfig(repoRoot, relativePath = DEFAULT_DEPLOY_CONFIG_PATH) {
  return readStructuredFile(repoRoot, relativePath);
}

export async function readDeployConfigIfPresent(repoRoot, relativePath = DEFAULT_DEPLOY_CONFIG_PATH, fallback = null) {
  return readStructuredFileIfPresent(repoRoot, relativePath, fallback);
}

export async function writeDeployConfig(repoRoot, relativePath = DEFAULT_DEPLOY_CONFIG_PATH, value) {
  return writeStructuredFile(repoRoot, relativePath, value);
}
