UNPKG

firmament-vita

Version:

Firmament module for automating VITA tasks

97 lines 4.97 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); var inversify_1 = require("inversify"); var cerialize_1 = require("cerialize"); var decrypt_and_untar_options_impl_1 = require("./decrypt-and-untar-options-impl"); var unzip_file_options_impl_1 = require("./unzip-file-options-impl"); var merge_pcap_files_options_impl_1 = require("./merge-pcap-files-options-impl"); var fileExists = require('file-exists'); var path = require('path'); var fs = require('fs'); var FullPipelineImpl = (function () { function FullPipelineImpl(_commandUtil, _decryptAndUnTarOptions, _unZipFileOptions, _mergePcapFilesOptions) { this.commandUtil = _commandUtil; this.decryptAndUnTarOptions = _decryptAndUnTarOptions; this.unZipFileOptions = _unZipFileOptions; this.mergePcapFilesOptions = _mergePcapFilesOptions; } FullPipelineImpl_1 = FullPipelineImpl; FullPipelineImpl.prototype.fromArgv = function (argv) { if (argv.jsonIn && fileExists(argv.jsonIn)) { var fullPipeline = this.fromJsonFile(argv.jsonIn); this.decryptAndUnTarOptions = fullPipeline.decryptAndUnTarOptions; this.unZipFileOptions = fullPipeline.unZipFileOptions; this.mergePcapFilesOptions = fullPipeline.mergePcapFilesOptions; return this; } this.decryptAndUnTarOptions.fromArgv(argv); this.mergePcapFilesOptions.fromArgv(argv); return this; }; FullPipelineImpl.prototype.fromJson = function (json) { cerialize_1.DeserializeInto(JSON.parse(json), FullPipelineImpl_1, this); return this; }; FullPipelineImpl.prototype.toJson = function () { var obj = cerialize_1.Serialize(this); var json = JSON.stringify(obj, undefined, 2); return json; }; FullPipelineImpl.prototype.fromJsonFile = function (jsonFile) { var fullInputPath = this.commandUtil.getConfigFilePath(jsonFile); var json = fs.readFileSync(fullInputPath, { encoding: 'utf-8' }); return this.fromJson(json); }; FullPipelineImpl.prototype.toJsonFile = function (jsonFile) { var fullOutputPath = this.commandUtil.getConfigFilePath(jsonFile); this.validate(); fs.writeFileSync(fullOutputPath, this.toJson()); }; FullPipelineImpl.prototype.validate = function () { this.decryptAndUnTarOptions.validate(); if (!this.unZipFileOptions.targetFolder) { this.unZipFileOptions.targetFolder = this.decryptAndUnTarOptions.targetFolder; } this.unZipFileOptions.validate(); if (!this.mergePcapFilesOptions.targetFolder) { this.mergePcapFilesOptions.targetFolder = this.decryptAndUnTarOptions.targetFolder; } this.mergePcapFilesOptions.validate(); }; __decorate([ cerialize_1.autoserializeAs(decrypt_and_untar_options_impl_1.DecryptAndUnTarOptionsImpl), __metadata("design:type", Object) ], FullPipelineImpl.prototype, "decryptAndUnTarOptions", void 0); __decorate([ cerialize_1.autoserializeAs(unzip_file_options_impl_1.UnZipFileOptionsImpl), __metadata("design:type", Object) ], FullPipelineImpl.prototype, "unZipFileOptions", void 0); __decorate([ cerialize_1.autoserializeAs(merge_pcap_files_options_impl_1.MergePcapFilesOptionsImpl), __metadata("design:type", Object) ], FullPipelineImpl.prototype, "mergePcapFilesOptions", void 0); FullPipelineImpl = FullPipelineImpl_1 = __decorate([ inversify_1.injectable(), __param(0, inversify_1.inject('CommandUtil')), __param(1, inversify_1.inject('DecryptAndUnTarOptions')), __param(2, inversify_1.inject('UnZipFileOptions')), __param(3, inversify_1.inject('MergePcapFilesOptions')), __metadata("design:paramtypes", [Object, Object, Object, Object]) ], FullPipelineImpl); return FullPipelineImpl; var FullPipelineImpl_1; }()); exports.FullPipelineImpl = FullPipelineImpl; //# sourceMappingURL=full-pipeline-impl.js.map