UNPKG

ask-cli-x

Version:

Alexa Skills Kit (ASK) Command Line Interfaces

29 lines (28 loc) 1.29 kB
"use strict"; const acdl = require("@alexa/acdl"); const { COMPILER } = require("../../utils/constants"); const Messenger = require("../../view/messenger"); module.exports = class Decompiler { constructor(configuration) { const { profile } = configuration; this.profile = profile; } decompile(decompilerInput, cb) { const project = acdl.loadProjectSync(acdl.loadProjectConfigSync(decompilerInput.rootDir, this.profile)); Messenger.getInstance().info("************ Decompiling Skill ************"); Messenger.getInstance().info(`Skill package directory: ${project.config.sourceRootDir}`); // TODO: set isSkill to true when brazil pkg get updated with the fix const errors = acdl.validateProject(project, true); const syntaxErrors = errors.filter((e) => e.code.category === "SyntaxError"); if (syntaxErrors.length > 0) { acdl.logProjectErrors(syntaxErrors); throw new Error(`${COMPILER.ASK_COMPILER} Decompilation Failed.`); } acdl .decompileProject(project, { outDir: decompilerInput.outDir }) .then((files) => cb(files)) .catch((error) => { throw new Error(`${COMPILER.ASK_DECOMPILER} ${error}`); }); } };