@trusthab/composable-resources
Version:
migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable
59 lines (46 loc) • 1.27 kB
JavaScript
const _ = require("lodash");
const path = require("path");
const inquirer = require("inquirer");
const chalk = require("chalk");
const figlet = require("figlet");
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const config = require(path.resolve(
path.join(process.cwd(), 'package.json')
));
const nextVersion = getNextVersion();
presentPrompt(nextVersion)
.then(publish)
.catch(err => console.log(err, _.get(err, 'response.data')));
// ////////
function getNextVersion() {
const version = getCurrentVersion();
return _(version).split('.')
.map(i => parseInt(i))
.map((i, index) => (index === 2 ? i + 1 : i))
.join('.');
}
function getCurrentVersion() {
return config.version;
}
function presentPrompt(version) {
console.log(`Current Version: ${chalk.red(getCurrentVersion())}`);
const questions = [
{
type: "input",
name: "version",
default: version,
message: "Publish Version"
}
];
return inquirer.prompt(questions);
}
async function publish({ version }) {
const { stdout, stderr } = await exec(
`./bin/_dont_use_directly_called_from_tag_js.sh ${version}`
);
if (stderr) {
console.error(`error: ${stderr}`);
}
console.log(stdout);
}