UNPKG

@vortex.so/cli

Version:

CLI to interact with Vortex.

47 lines (41 loc) 1.29 kB
'use strict'; const fs = require('fs-extra'); const yaml = require('js-yaml'); const semver = require('semver'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const fs__default = /*#__PURE__*/_interopDefaultCompat(fs); const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml); async function getInput(operation) { const { name, namespace, handle, kind, type, description, version, build } = yaml__default.load(fs__default.readFileSync("vortex.yaml", "utf-8")); if (!name) throw new Error("Missing name."); if (!namespace) throw new Error("Missing namespace."); if (!handle) throw new Error("Missing handle."); if (!description) throw new Error("Missing description."); if (!version) throw new Error("Missing version."); if (build === void 0) throw new Error("Missing build."); if (!semver.valid(version)) { throw new Error("Version is invalid."); } if (typeof build != "number") { throw new TypeError("Build is invalid."); } return operation.update({ name, namespace, handle, description, kind, type, version, oldVersionSource: "vortex.yaml", oldVersion: version, oldBuild: build }); } exports.getInput = getInput;