loadOrmProjectConfig function

OrmProjectConfig loadOrmProjectConfig(
  1. File file
)

Loads OrmProjectConfig from file.

Throws when the file is missing so callers can instruct users to run ormed init.

Implementation

OrmProjectConfig loadOrmProjectConfig(File file) {
  if (!file.existsSync()) {
    throw StateError('Missing ormed.yaml at ${file.path}. Run `ormed init` first.');
  }
  final parsed = loadYaml(file.readAsStringSync());
  final env = _loadEnv(file.parent);
  final expanded = _expandEnv(parsed, env);
  return OrmProjectConfig.fromMap(expanded as Map<String, Object?>);
}