How to use the @accordproject/cicero-core.Template.fromArchive function in @accordproject/cicero-core

To help you get started, we’ve selected a few @accordproject/cicero-core 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 / template-studio / src / TemplateStudio / index.js View on Github external
async loadTemplateFromBuffer(buffer) {
        this.setState({ loading: true });
        console.log('Loading template from Buffer');
        let template;
        try {
            template = await Template.fromArchive(buffer);
        } catch (error) {
            console.log(`LOAD FAILED! ${error.message}`); // Error!
            this.handleLoadingFailed(error.message);
            return false;
        }
        try {
            const newState = {...this.state};
            newState.clause = new Clause(template);
            newState.templateName = newState.clause.getTemplate().getMetadata().getName();
            newState.templateVersion = newState.clause.getTemplate().getMetadata().getVersion();
            newState.templateType = newState.clause.getTemplate().getMetadata().getTemplateType();
            newState.package = JSON.stringify(template.getMetadata().getPackageJson(), null, 2);
            newState.grammar = template.getParserManager().getTemplatizedGrammar();
            newState.model = template.getModelManager().getModels();
            newState.logic = template.getScriptManager().getLogic();
            newState.text = template.getMetadata().getSamples().default;
github accordproject / cicero / packages / cicero-cli / lib / commands.js View on Github external
static loadTemplate(templatePath, options) {
        if (Commands.isTemplateArchive(templatePath)) {
            const buffer = fs.readFileSync(templatePath);
            return Template.fromArchive(buffer, options);
        } else {
            return Template.fromDirectory(templatePath, options);
        }
    }