Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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') {
throw new Error('request.json must be an object');
}
if (!packageJson.name || !this._validName(packageJson.name)) {
throw new Error ('template name can only contain lowercase alphanumerics, _ or -');
}