nodely-cli
Version:
Console client for Nodely Platform
96 lines (77 loc) • 2.25 kB
JavaScript
/**
* Created by Ivan Soloviev <support@nodely.me>
* Date: 05/29/2018
*
* Copyright @ Nodely, 2018
*/
const figlet = require('figlet');
const program = require('commander');
const { prompt } = require('inquirer');
const ConfigStore = require('configstore');
const {
doCheckout, doPush, getStatus, doInit, doLink,
} = require('./repository');
const {
doLogin, doPublish, loginQuestions, publishOptions,
} = require('./common');
const pkg = require('./package');
const { init } = require('./network');
const conf = new ConfigStore(pkg.name);
module.exports.conf = conf;
init(conf);
program.version(pkg.version).description('Nodely Platform console client');
program.command('login')
.description(
'Login to Nodely Platform using key/secret. You need to obtain key on https://nodely.me/manager.',
)
.action(() => {
prompt(loginQuestions).then(answers => doLogin(answers, conf));
});
program.command('checkout <domain> [folder]')
.description('Checkout web site data from the cloud')
.action((domain, folder) => {
doCheckout({ domain, folder });
});
program.command('init <domain>')
.description(
'Initialize current directory as root of your web site',
)
.action((domain) => {
doInit({ domain });
});
// program.command('mv <src> <dst>')
// .description(
// 'Move/Rename file to another location',
// )
// .action(() => {
// console.log('Not implemented');
// });
program.command('publish')
.description('Publish web site to stage/production')
.action((build) => {
prompt(publishOptions).then(answers => doPublish(answers, { build }));
});
program.command('push')
.description('Push changes to the cloud')
.action(() => doPush());
program.command('status')
.description('Get status of repository')
.action(() => getStatus());
program.command('link <repo>')
.description('Link existing repository')
.action((repo) => {
doLink({ repo });
});
program.parse(process.argv);
if (!program.args.length) {
figlet.text('Nodely Platform', { font: 'Doom' }, (err, data) => {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(data);
program.help();
});
}