@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
76 lines • 2.7 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSkillSummaryLines = generateSkillSummaryLines;
const schema_1 = require("@sprucelabs/schema");
const AbstractAction_1 = __importDefault(require("../../AbstractAction"));
class RegisterAction extends AbstractAction_1.default {
optionsSchema = optionsSchema;
commandAliases = ['register.skill', 'register'];
invocationMessage = 'Registering your skill... ⚡️';
async execute(options) {
const { nameReadable, nameKebab, description } = this.validateAndNormalizeOptions(options);
try {
const skills = this.Store('skill');
const skill = await skills.register({
description,
name: nameReadable,
slug: nameKebab,
});
const summaryLines = generateSkillSummaryLines(skill);
return {
summaryLines,
hints: [
'Your skill is registered.',
'You can check your .env for more details.',
"If you're ready to deploy, try `spruce deploy`. 🚀",
],
meta: {
skill,
},
};
}
catch (err) {
return {
hints: [
`If you've already registered your skill, try 'spruce login.skill'!`,
],
errors: [err],
};
}
}
}
exports.default = RegisterAction;
function generateSkillSummaryLines(skill) {
return [
`Name: ${skill.name}`,
`Namespace: ${skill.slug}`,
`ID: ${skill.id}`,
`API Key: ${skill.apiKey}`,
];
}
const optionsSchema = (0, schema_1.buildSchema)({
id: 'registerSkillAction',
description: 'Register your skill with Mercury so you can start communicating with other skills.',
fields: {
nameReadable: {
type: 'text',
label: `What is your skill's name?`,
isRequired: true,
hint: 'The name people will see in the Marketplace!',
},
nameKebab: {
type: 'text',
label: 'Namespace',
isRequired: true,
hint: "The namespace of your skill in-kebab-case. It is what you will use in a lot of your code, don't start it with a number!",
},
description: {
type: 'text',
label: 'Describe your skill.',
},
},
});
//# sourceMappingURL=RegisterAction.js.map