UNPKG

@vulcan-sql/core

Version:
33 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalFileProfileReader = void 0; const tslib_1 = require("tslib"); const models_1 = require("../../../../models/index"); const path = require("path"); const fs = require("fs"); const jsYAML = require("js-yaml"); const utils_1 = require("../../../utils/index"); let LocalFileProfileReader = class LocalFileProfileReader extends models_1.ProfileReader { read(options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (!options.path) throw new utils_1.ConfigurationError('LocalFile profile reader needs options.path property'); const profilePath = path.resolve(process.cwd(), options.path); if (!fs.existsSync(profilePath)) return []; const profiles = jsYAML.load(yield fs.promises.readFile(profilePath, 'utf-8')); // validate profiles for (const profile of profiles) { if (!profile.name || !profile.type) throw new utils_1.ConfigurationError(`Invalid profile in ${profilePath}. Profile name and type are required.`); } return profiles; }); } }; LocalFileProfileReader = tslib_1.__decorate([ (0, models_1.VulcanInternalExtension)(), (0, models_1.VulcanExtensionId)(models_1.ProfilesLookupType.LocalFile) ], LocalFileProfileReader); exports.LocalFileProfileReader = LocalFileProfileReader; //# sourceMappingURL=localFile.js.map