How to use the @accordproject/ergo-compiler.Compiler.isValidTarget function in @accordproject/ergo-compiler

To help you get started, we’ve selected a few @accordproject/ergo-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accordproject / cicero / packages / cicero-core / src / metadata.js View on Github external
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 -');
        }