55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
|
|
var _api = require('./api');
|
|
|
|
var _updateNotifier = require('update-notifier');
|
|
|
|
var _updateNotifier2 = _interopRequireDefault(_updateNotifier);
|
|
|
|
var _index = require('./utils/index.js');
|
|
|
|
var _package = require('../package.json');
|
|
|
|
var _package2 = _interopRequireDefault(_package);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
(0, _updateNotifier2.default)({ pkg: _package2.default }).notify({ isGlobal: true });
|
|
|
|
function printUsage({ args }) {
|
|
// const commandName = args[0];
|
|
// TODO: print usage of commandName, or print global usage.
|
|
|
|
console.log('Usage is under development now.');
|
|
console.log('Visit `https://github.com/reactnativecn/react-native-pushy` for early document.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const commands = _extends({}, require('./user').commands, require('./bundle').commands, require('./app').commands, require('./package').commands, require('./versions').commands, {
|
|
help: printUsage
|
|
});
|
|
|
|
function run() {
|
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
(0, _index.printVersionCommand)();
|
|
process.exit();
|
|
}
|
|
|
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
global.USE_ACC_OSS = argv.options['acc'];
|
|
|
|
(0, _api.loadSession)().then(() => commands[argv.command](argv)).catch(err => {
|
|
if (err.status === 401) {
|
|
console.log('尚未登录。\n请在项目目录中运行`pushy login`命令来登录');
|
|
return;
|
|
}
|
|
console.error(err.stack);
|
|
process.exit(-1);
|
|
});
|
|
}
|
|
|
|
run(); |