< Summary - Envilder CLI

Information
Class: src/envilder/core/application/validateEnvFile/ValidateEnvFileKeysCommandHandler.ts
Assembly: Default
File(s): src/envilder/core/application/validateEnvFile/ValidateEnvFileKeysCommandHandler.ts
Tag: 605_44106794472
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/application/validateEnvFile/ValidateEnvFileKeysCommandHandler.ts

#LineLine coverage
 1import { inject, injectable } from 'inversify';
 2import {
 3  compareEnvFileKeys,
 4  type EnvFileKeyComparison,
 5} from '../../domain/EnvFileComparison.js';
 6import { EnvironmentFileError } from '../../domain/errors/DomainErrors.js';
 7import type { IVariableStore } from '../../domain/ports/IVariableStore.js';
 8import { TYPES } from '../../types.js';
 9import type { ValidateEnvFileKeysCommand } from './ValidateEnvFileKeysCommand.js';
 10
 11/**
 12 * Compares the keys of a local env file with the variables a map file
 13 * declares, without calling any provider. Only keys are compared: the values
 14 * the env file holds are read by the parser and then dropped. Run it on a map
 15 * file that passed offline validation.
 16 */
 17@injectable()
 918export class ValidateEnvFileKeysCommandHandler {
 19  constructor(
 20    @inject(TYPES.IVariableStore)
 1621    private readonly variableStore: IVariableStore,
 22  ) {}
 23
 24  async handle(
 25    command: ValidateEnvFileKeysCommand,
 26  ): Promise<EnvFileKeyComparison> {
 1627    const mapping = await this.variableStore.getMapping(command.mapPath);
 1628    const entries = await this.variableStore.readEnvironmentEntries(
 29      command.envFilePath,
 30    );
 1631    if (entries === null) {
 232      throw new EnvironmentFileError(
 33        `Env file not found: ${command.envFilePath}`,
 34      );
 35    }
 1436    return compareEnvFileKeys(Object.keys(mapping), entries);
 37  }
 38}

Methods/Properties

constructor
handle