johnny-cli
Version:
CLI for Johnny Deps
38 lines (32 loc) • 1.07 kB
JavaScript
// @flow
import API from 'API';
import Dll from 'Dll';
import {cdnLinkPlugin, dllFactoryPlugin} from 'templates';
import fetch from 'node-fetch';
import fs from 'fs';
import JohnnyFile from '../JohnnyFile';
import {getDllHostPackages, logError} from 'helpers';
import PluginsConfig from '../PluginsConfig';
import promptly from 'promptly';
import R from 'ramda';
import settings from 'settings';
require('babel-polyfill');
export default async (username: ?string) => {
let
usernameResolved = username || await promptly.prompt('Username: '),
// WARN Hide password input
password = await promptly.prompt('Password: ');
try {
process.stdout.write('\x1b[1mObtaining token...\x1b[0m');
// Obtain token and save to config file
// WARN A good idea would be to keep token separately from config file
JohnnyFile().set({
token: await API({password: password, username: usernameResolved}).requestToken().then(token => token),
});
process.stdout.write('\x1b[1m\x1b[32mDone\x1b[0m\n');
} catch(error) {
console.log();
logError(error);
return;
}
};