Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error('Failed to find accordproject cicero version in package.json');
}
if(!semver.valid(semver.coerce(packageJson.accordproject.cicero))){
throw new Error('The cicero version must be a valid semantic version (semver) number.');
}
if(!semver.valid(semver.coerce(packageJson.version))){
throw new Error('The template version must be a valid semantic version (semver) number.');
}
this.ciceroVersion = packageJson.accordproject.cicero;
if (!this.satisfiesCiceroVersion(ciceroVersion)){
const msg = `The template targets Cicero version ${this.ciceroVersion} but the current Cicero version is ${ciceroVersion}.`;
Logger.error(msg);
throw new Error(msg);
}
// the runtime property is optional, and is only mandatory for templates that have been compiled
if (packageJson.accordproject.runtime && packageJson.accordproject.runtime !== 'ergo') {
ErgoCompiler.isValidTarget(packageJson.accordproject.runtime);
} else {
packageJson.accordproject.runtime = 'ergo';
}
this.runtime = packageJson.accordproject.runtime;
if(!samples || typeof(samples) !== 'object') {
throw new Error('sample.md is required');
}
if(request && typeof(request) !== 'object') {
grammarParser.feed(sourceCode);
const grammarAst = grammarParser.results[0]; // TODO check for errors
// Compile the AST into a set of rules
const grammarInfoObject = compile(grammarAst, {});
// Generate JavaScript code from the rules
const grammarJs = generate(grammarInfoObject, 'grammar');
// Pretend this is a CommonJS environment to catch exports from the grammar.
const module = {
exports: {}
};
eval(grammarJs);
return module.exports;
} catch (err) {
Logger.error(err);
throw err;
}
}
.catch((err) => {
Logger.error('Failed to load template index', err);
throw err;
});
}
}, (argv) => {
try {
argv = Commands.validateInvokeArgs(argv);
const options = {
warnings: argv.warnings,
};
return Commands.invoke(argv.template, argv.sample, argv.clauseName, argv.params, argv.state, argv.currentTime, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
.catch((err) => {
Logger.error(err.message);
});
} catch (err){
Logger.error(err.message);
}
})
.command('initialize', 'initialize a clause', (yargs) => {
}, (argv) => {
if (argv.verbose) {
Logger.info(`validate sample in ${argv.sample} against the models ${argv.ctoFiles}`);
}
try {
argv = Commands.validateValidateArgs(argv);
return Commands.validate(argv.sample, argv.ctoSystem, argv.ctoFiles)
.then((result) => {
Logger.info(result);
})
.catch((err) => {
Logger.error(err.message);
});
} catch (err){
Logger.error(err.message);
return;
}
})
.command('compile', 'generate code for a target platform', (yargs) => {
.catch((err) => {
Logger.error(err.message);
});
}
.catch((err) => {
Logger.error(err.message);
});
})
.catch((err) => {
Logger.error(err);
});
}
.catch((err) => {
Logger.error(err.message + ' ' + JSON.stringify(err));
});
} catch (err){
.catch((err) => {
Logger.error(err.message);
});
} catch (err){