UNPKG

@amplitude/ampli

Version:

Amplitude CLI

41 lines (40 loc) 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("lodash"); const base_1 = require("../base"); const string_1 = require("../../util/string"); const PATH_VERIFIER_PROJECT_FILE = `${__dirname}/roslyn_itly_verifier/itly_verifier.csproj`; const PATH_VERIFIER_RUNNABLE = `--project "${PATH_VERIFIER_PROJECT_FILE}"`; class CSharpVerifier extends base_1.Verifier { constructor(ampliInstanceNames = ['Itly', 'Iteratively']) { super('cs', ampliInstanceNames); this.ampliInstanceNames = ampliInstanceNames; this.getReferenceName = (eventName) => string_1.upperCamelCase(eventName); } checkDependencies() { super.checkDependencies(); this.execSyncToString(`dotnet --version`); } async doVerify(eventNames, workingDirs) { return this.verifyBatch((filePaths, addReference, addError) => { const command = `dotnet run ${PATH_VERIFIER_RUNNABLE} -- ${this.ampliInstanceNames.map(name => `--instanceName "${name}"`).join(' ')} ${filePaths.map(path => `"${path}"`).join(' ')}`; const { errors, references: batchReferences, } = this.execSyncToJson(command); if (!lodash_1.isEmpty(errors)) { Object.entries(errors).forEach(([location, errs]) => { errs.forEach(message => addError({ location, message, })); }); } if (!lodash_1.isEmpty(batchReferences)) { Object.entries(batchReferences).forEach(([filePath, refs]) => { refs .map(r => (Object.assign(Object.assign({}, r), { filePath }))) .forEach(r => addReference(r)); }); } }, workingDirs); } } exports.default = CSharpVerifier;