UNPKG

@ibm-adw/skill-toolkit

Version:

Developing your own skills with IBM Automation Digital Worker Skill Toolkit

74 lines (58 loc) 2.26 kB
/* Licensed Materials - Property of IBM 5737-I23 Copyright IBM Corp. 2019. All Rights Reserved. U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ 'use strict'; const path = require('path'); module.exports = async function (req, res) { const SKILL_DIR_1 = process.argv[2]; const SKILL_DIR = path.resolve(process.env.PWD, SKILL_DIR_1); try { const specs = require(`${SKILL_DIR}/skill-spec`); const content = req.query.content; if (content === 'spec') { // const skill_final_schema = specs['config_schema']; // if (specs.config_schema) { if (specs.config_schema || specs.config_schema === {}) { res.status(200).json(specs.config_schema); } else { // res.status(501).json(skill_final_schema); console.log('The \'config_schema\' is not implemented in skill-spec'); res.status(404).send('The \'config_schema\' is not implemented in skill-spec'); } } else if (content === 'info') { try { const packageContent = require(`${SKILL_DIR}/package`); const info = { name: specs.name, description: specs.description, category: specs.category, level: specs.level, package_name: packageContent.name, package_version: packageContent.version, package_description: packageContent.description }; res.status(200).json(info); } catch (error) { console.log(error); res.status(500).json({ name: error.name, message: error.message }); } } else { console.log('The \'content\' should be \'spec\' or \'info\''); res.status(422).send('The \'type\' should be \'spec\' or \'info\''); } } catch (error) { console.log(error); res.status(500).json({ name: error.name, message: error.message }); } };