'use strict';

var chunkD5HE46WD_cjs = require('./chunk-D5HE46WD.cjs');
var chunk4UERBOUH_cjs = require('./chunk-4UERBOUH.cjs');
var chunkAF3E2D32_cjs = require('./chunk-AF3E2D32.cjs');
var readFile = require('@stryke/fs/read-file');
var stormJson = require('@stryke/json/storm-json');
var exists = require('@stryke/path/exists');

async function writeDotenvReflection(log, context, reflection, name) {
  let reflectionObjectLiteral = (void 0).from({
    kind: (void 0).objectLiteral,
    description: `An object containing the dotenv variables used by the ${context.options.name ? `${context.options.name} application` : "application"}.`,
    types: []
  });
  const varsFilePath = chunkD5HE46WD_cjs.getDotenvReflectionsPath(context, name);
  if (exists.existsSync(varsFilePath)) {
    reflectionObjectLiteral = (void 0)((void 0)(await readFile.readJsonFile(varsFilePath)));
  }
  reflection.getProperties().map((prop) => {
    if (!reflectionObjectLiteral.hasProperty(prop.getName())) {
      reflectionObjectLiteral.addProperty(prop.property);
    }
  });
  const serialized = reflectionObjectLiteral.serializeType();
  return chunk4UERBOUH_cjs.writeFile(log, chunkD5HE46WD_cjs.getDotenvReflectionsPath(context, name), stormJson.StormJSON.stringify(serialized));
}
chunkAF3E2D32_cjs.__name(writeDotenvReflection, "writeDotenvReflection");
async function writeDotenvProperties(log, context, name, properties) {
  const varsFilePath = chunkD5HE46WD_cjs.getDotenvPath(context, name);
  let reflectionObjectLiteral = (void 0).from({
    kind: (void 0).objectLiteral,
    description: `An object containing the dotenv variables used by the ${context.options.name ? `${context.options.name} application` : "application"}.`,
    types: []
  });
  if (exists.existsSync(varsFilePath)) {
    reflectionObjectLiteral = (void 0)((void 0)(await readFile.readJsonFile(varsFilePath)));
  }
  properties.map((prop) => {
    if (!reflectionObjectLiteral.hasProperty(prop.getName())) {
      reflectionObjectLiteral.addProperty(prop.property);
    }
  });
  await chunk4UERBOUH_cjs.writeFile(log, varsFilePath, stormJson.StormJSON.stringify(reflectionObjectLiteral.serializeType()));
}
chunkAF3E2D32_cjs.__name(writeDotenvProperties, "writeDotenvProperties");

exports.writeDotenvProperties = writeDotenvProperties;
exports.writeDotenvReflection = writeDotenvReflection;
//# sourceMappingURL=chunk-DNBPSJZB.cjs.map
//# sourceMappingURL=chunk-DNBPSJZB.cjs.map