mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-01 00:45:55 +00:00
Slim down unused functionality
This commit is contained in:
parent
11033683fd
commit
57319f26a6
@ -1,9 +1,5 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, form, path, resin, vcs, visuals;
|
||||
|
||||
path = require('path');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
var async, commandOptions, form, resin, vcs, visuals;
|
||||
|
||||
async = require('async');
|
||||
|
||||
@ -122,7 +118,7 @@
|
||||
exports.associate = {
|
||||
signature: 'app associate <name>',
|
||||
description: 'associate a resin project',
|
||||
help: 'Use this command to associate a project directory with a resin application.\n\nThis command adds a \'resin\' git remote to the directory and runs git init if necessary.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app associate MyApp\n $ resin app associate MyApp --project my/app/directory',
|
||||
help: 'Use this command to associate a project directory with a resin application.\n\nThis command adds a \'resin\' git remote to the directory and runs git init if necessary.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app associate MyApp',
|
||||
options: [commandOptions.yes],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
@ -166,39 +162,4 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = {
|
||||
signature: 'init',
|
||||
description: 'init an application',
|
||||
help: 'Use this command to initialise a directory as a resin application.\n\nThis command performs the following steps:\n - Create a resin.io application.\n - Initialize the current directory as a git repository.\n - Add the corresponding git remote to the application.\n\nExamples:\n\n $ resin init\n $ resin init --project my/app/directory',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var currentDirectory;
|
||||
currentDirectory = process.cwd();
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
var currentDirectoryBasename;
|
||||
currentDirectoryBasename = path.basename(currentDirectory);
|
||||
return form.ask({
|
||||
message: 'What is the name of your application?',
|
||||
type: 'input',
|
||||
"default": currentDirectoryBasename
|
||||
}).nodeify(callback);
|
||||
}, function(applicationName, callback) {
|
||||
return exports.create.action({
|
||||
name: applicationName
|
||||
}, options, function(error) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return callback(null, applicationName);
|
||||
});
|
||||
}, function(applicationName, callback) {
|
||||
return exports.associate.action({
|
||||
name: applicationName
|
||||
}, options, callback);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
open = require('open');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
_ = require('lodash');
|
||||
|
||||
url = require('url');
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
(function() {
|
||||
var _, async, capitano, commandOptions, deviceConfig, drivelist, form, fse, htmlToText, image, inject, manager, os, path, pine, registerDevice, resin, tmp, vcs, visuals;
|
||||
|
||||
fse = require('fs-extra');
|
||||
var _, async, capitano, commandOptions, deviceConfig, drivelist, form, htmlToText, image, inject, manager, os, path, pine, registerDevice, resin, vcs, visuals;
|
||||
|
||||
capitano = require('capitano');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
_ = require('lodash');
|
||||
|
||||
path = require('path');
|
||||
|
||||
@ -27,8 +25,6 @@
|
||||
|
||||
pine = require('resin-pine');
|
||||
|
||||
tmp = require('tmp');
|
||||
|
||||
deviceConfig = require('resin-device-config');
|
||||
|
||||
form = require('resin-cli-form');
|
||||
@ -39,8 +35,6 @@
|
||||
|
||||
os = require('os');
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
exports.list = {
|
||||
@ -347,28 +341,6 @@
|
||||
return resin.models.device.get(params.uuid).nodeify(callback);
|
||||
}, function(device, callback) {
|
||||
console.info("Device created: " + device.name);
|
||||
return callback(null, device.name);
|
||||
}, function(deviceName, callback) {
|
||||
var instructions, osSpecificInstructions, platform, platformHash;
|
||||
if (params.manifest.instructions == null) {
|
||||
instructions = '';
|
||||
}
|
||||
if (_.isArray(params.manifest.instructions)) {
|
||||
instructions = htmlToText.fromString(params.manifest.instructions.join('\n'));
|
||||
}
|
||||
platformHash = {
|
||||
darwin: 'osx',
|
||||
linux: 'linux',
|
||||
win32: 'windows'
|
||||
};
|
||||
platform = platformHash[os.platform()];
|
||||
osSpecificInstructions = params.manifest.instructions[platform];
|
||||
if (osSpecificInstructions == null) {
|
||||
instructions = '';
|
||||
} else {
|
||||
instructions = htmlToText.fromString(osSpecificInstructions.join('\n'));
|
||||
}
|
||||
console.log('\n' + instructions);
|
||||
return callback(null, params.uuid);
|
||||
}
|
||||
], done);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
async = require('async');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
_ = require('lodash');
|
||||
|
||||
resin = require('resin-sdk');
|
||||
|
||||
|
@ -95,7 +95,9 @@
|
||||
}
|
||||
console.log(getCommandHelp(command));
|
||||
}
|
||||
if (!_.isEmpty(capitano.state.globalOptions)) {
|
||||
console.log('\nGlobal Options:\n');
|
||||
}
|
||||
options = _.map(capitano.state.globalOptions, function(option) {
|
||||
option.signature = buildOptionSignatureHelp(option);
|
||||
return option;
|
||||
|
@ -1,7 +1,5 @@
|
||||
(function() {
|
||||
var packageJSON, settings;
|
||||
|
||||
settings = require('resin-settings-client');
|
||||
var packageJSON;
|
||||
|
||||
packageJSON = require('../../package.json');
|
||||
|
||||
@ -15,19 +13,4 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.config = {
|
||||
signature: 'config',
|
||||
description: 'see your current configuration',
|
||||
help: 'See your current Resin CLI configuration.\n\nConfiguration lives in $HOME/.resin/config.',
|
||||
action: function(params, options, done) {
|
||||
var key, ref, value;
|
||||
ref = settings.get();
|
||||
for (key in ref) {
|
||||
value = ref[key];
|
||||
console.log(key + ": " + value);
|
||||
}
|
||||
return done();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
var Promise, _, async, capitano, form, mkdirp, path, resin, userHome, visuals;
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
_ = require('lodash');
|
||||
|
||||
Promise = require('bluebird');
|
||||
|
||||
@ -97,7 +97,7 @@
|
||||
}, function(made, callback) {
|
||||
console.log("Associating " + params.name + " with " + params.directory + "...");
|
||||
process.chdir(params.directory);
|
||||
return capitano.run("app associate " + params.name + " --project " + params.directory, callback);
|
||||
return capitano.run("app associate " + params.name, callback);
|
||||
}, function(remoteUrl, callback) {
|
||||
console.log("Resin git remote added: " + remoteUrl);
|
||||
console.log('Please type "git push resin master" into your project directory now!');
|
||||
|
51
build/app.js
51
build/app.js
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, actions, async, capitano, changeProjectDirectory, errors, plugins, resin;
|
||||
var _, actions, async, capitano, errors, plugins, resin;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
@ -32,37 +32,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'quiet',
|
||||
description: 'quiet (no output)',
|
||||
boolean: true,
|
||||
alias: 'q'
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'project',
|
||||
parameter: 'path',
|
||||
description: 'project path',
|
||||
alias: 'j'
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'version',
|
||||
description: actions.info.version.description,
|
||||
boolean: true,
|
||||
alias: 'v'
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'no-color',
|
||||
description: 'disable colour highlighting',
|
||||
boolean: true
|
||||
});
|
||||
|
||||
capitano.command(actions.info.version);
|
||||
|
||||
capitano.command(actions.info.config);
|
||||
|
||||
capitano.command(actions.help.help);
|
||||
|
||||
capitano.command(actions.wizard.wizard);
|
||||
@ -85,8 +56,6 @@
|
||||
|
||||
capitano.command(actions.app.associate);
|
||||
|
||||
capitano.command(actions.app.init);
|
||||
|
||||
capitano.command(actions.app.info);
|
||||
|
||||
capitano.command(actions.device.list);
|
||||
@ -135,32 +104,14 @@
|
||||
|
||||
capitano.command(actions.plugin.remove);
|
||||
|
||||
changeProjectDirectory = function(directory) {
|
||||
try {
|
||||
return process.chdir(directory);
|
||||
} catch (_error) {
|
||||
return errors.handle(new Error("Invalid project: " + directory));
|
||||
}
|
||||
};
|
||||
|
||||
async.waterfall([
|
||||
function(callback) {
|
||||
return plugins.register('resin-plugin-', callback);
|
||||
}, function(callback) {
|
||||
var cli;
|
||||
cli = capitano.parse(process.argv);
|
||||
if (cli.global.quiet || !process.stdout.isTTY) {
|
||||
console.info = _.noop;
|
||||
}
|
||||
if (cli.global.project != null) {
|
||||
changeProjectDirectory(cli.global.project);
|
||||
}
|
||||
if (cli.global.version) {
|
||||
return actions.info.version.action(null, null, callback);
|
||||
} else {
|
||||
return capitano.execute(cli, callback);
|
||||
}
|
||||
}
|
||||
], errors.handle);
|
||||
|
||||
}).call(this);
|
||||
|
@ -22,7 +22,6 @@ Now you have access to all the commands referenced below.
|
||||
- [app restart <name>](#app-restart-60-name-62-)
|
||||
- [app rm <name>](#app-rm-60-name-62-)
|
||||
- [app associate <name>](#app-associate-60-name-62-)
|
||||
- [init](#init)
|
||||
|
||||
- Authentication
|
||||
|
||||
@ -56,7 +55,6 @@ Now you have access to all the commands referenced below.
|
||||
- Information
|
||||
|
||||
- [version](#version)
|
||||
- [config](#config)
|
||||
|
||||
- Keys
|
||||
|
||||
@ -165,7 +163,6 @@ You can avoid this by passing the `--yes` boolean option.
|
||||
Examples:
|
||||
|
||||
$ resin app associate MyApp
|
||||
$ resin app associate MyApp --project my/app/directory
|
||||
|
||||
### Options
|
||||
|
||||
@ -173,20 +170,6 @@ Examples:
|
||||
|
||||
confirm non interactively
|
||||
|
||||
## init
|
||||
|
||||
Use this command to initialise a directory as a resin application.
|
||||
|
||||
This command performs the following steps:
|
||||
- Create a resin.io application.
|
||||
- Initialize the current directory as a git repository.
|
||||
- Add the corresponding git remote to the application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin init
|
||||
$ resin init --project my/app/directory
|
||||
|
||||
# Authentication
|
||||
|
||||
## login [token]
|
||||
@ -195,7 +178,7 @@ Use this command to login to your resin.io account.
|
||||
|
||||
To login, you need your token, which is accesible from the preferences page:
|
||||
|
||||
https://dashboard.resin.io/preferences
|
||||
https://dashboard.resinstaging.io/preferences
|
||||
|
||||
Examples:
|
||||
|
||||
@ -517,12 +500,6 @@ Examples:
|
||||
|
||||
Display the Resin CLI version.
|
||||
|
||||
## config
|
||||
|
||||
See your current Resin CLI configuration.
|
||||
|
||||
Configuration lives in $HOME/.resin/config.
|
||||
|
||||
# Keys
|
||||
|
||||
## keys
|
||||
|
@ -1,5 +1,3 @@
|
||||
path = require('path')
|
||||
_ = require('lodash-contrib')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
@ -177,7 +175,6 @@ exports.associate =
|
||||
Examples:
|
||||
|
||||
$ resin app associate MyApp
|
||||
$ resin app associate MyApp --project my/app/directory
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
permission: 'user'
|
||||
@ -217,47 +214,3 @@ exports.associate =
|
||||
return done(error) if error?
|
||||
console.info("git repository added: #{remoteUrl}")
|
||||
return done(null, remoteUrl)
|
||||
|
||||
exports.init =
|
||||
signature: 'init'
|
||||
description: 'init an application'
|
||||
help: '''
|
||||
Use this command to initialise a directory as a resin application.
|
||||
|
||||
This command performs the following steps:
|
||||
- Create a resin.io application.
|
||||
- Initialize the current directory as a git repository.
|
||||
- Add the corresponding git remote to the application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin init
|
||||
$ resin init --project my/app/directory
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
|
||||
currentDirectory = process.cwd()
|
||||
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
currentDirectoryBasename = path.basename(currentDirectory)
|
||||
form.ask
|
||||
message: 'What is the name of your application?'
|
||||
type: 'input'
|
||||
default: currentDirectoryBasename
|
||||
.nodeify(callback)
|
||||
|
||||
(applicationName, callback) ->
|
||||
|
||||
# TODO: Make resin.models.application.create return
|
||||
# the whole application instead of just the id
|
||||
exports.create.action name: applicationName, options, (error) ->
|
||||
return callback(error) if error?
|
||||
return callback(null, applicationName)
|
||||
|
||||
(applicationName, callback) ->
|
||||
exports.associate.action(name: applicationName, options, callback)
|
||||
|
||||
], done
|
||||
|
@ -1,5 +1,5 @@
|
||||
open = require('open')
|
||||
_ = require('lodash-contrib')
|
||||
_ = require('lodash')
|
||||
url = require('url')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
|
@ -1,6 +1,5 @@
|
||||
fse = require('fs-extra')
|
||||
capitano = require('capitano')
|
||||
_ = require('lodash-contrib')
|
||||
_ = require('lodash')
|
||||
path = require('path')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
@ -11,16 +10,12 @@ image = require('resin-image')
|
||||
inject = require('resin-config-inject')
|
||||
registerDevice = require('resin-register-device')
|
||||
pine = require('resin-pine')
|
||||
tmp = require('tmp')
|
||||
deviceConfig = require('resin-device-config')
|
||||
form = require('resin-cli-form')
|
||||
drivelist = require('drivelist')
|
||||
htmlToText = require('html-to-text')
|
||||
os = require('os')
|
||||
|
||||
# Cleanup the temporary files even when an uncaught exception occurs
|
||||
tmp.setGracefulCleanup()
|
||||
|
||||
commandOptions = require('./command-options')
|
||||
|
||||
exports.list =
|
||||
@ -423,28 +418,6 @@ exports.init =
|
||||
|
||||
(device, callback) ->
|
||||
console.info("Device created: #{device.name}")
|
||||
return callback(null, device.name)
|
||||
|
||||
(deviceName, callback) ->
|
||||
instructions = '' if not params.manifest.instructions?
|
||||
|
||||
if _.isArray(params.manifest.instructions)
|
||||
instructions = htmlToText.fromString(params.manifest.instructions.join('\n'))
|
||||
|
||||
platformHash =
|
||||
darwin: 'osx'
|
||||
linux: 'linux'
|
||||
win32: 'windows'
|
||||
|
||||
platform = platformHash[os.platform()]
|
||||
osSpecificInstructions = params.manifest.instructions[platform]
|
||||
|
||||
if not osSpecificInstructions?
|
||||
instructions = ''
|
||||
else
|
||||
instructions = htmlToText.fromString(osSpecificInstructions.join('\n'))
|
||||
|
||||
console.log('\n' + instructions)
|
||||
return callback(null, params.uuid)
|
||||
|
||||
], done
|
||||
|
@ -1,5 +1,5 @@
|
||||
async = require('async')
|
||||
_ = require('lodash-contrib')
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
commandOptions = require('./command-options')
|
||||
|
@ -67,6 +67,7 @@ general = ->
|
||||
continue if command.isWildcard()
|
||||
console.log(getCommandHelp(command))
|
||||
|
||||
if not _.isEmpty(capitano.state.globalOptions)
|
||||
console.log('\nGlobal Options:\n')
|
||||
|
||||
options = _.map capitano.state.globalOptions, (option) ->
|
||||
|
@ -1,4 +1,3 @@
|
||||
settings = require('resin-settings-client')
|
||||
packageJSON = require('../../package.json')
|
||||
|
||||
exports.version =
|
||||
@ -10,16 +9,3 @@ exports.version =
|
||||
action: (params, options, done) ->
|
||||
console.log(packageJSON.version)
|
||||
return done()
|
||||
|
||||
exports.config =
|
||||
signature: 'config'
|
||||
description: 'see your current configuration'
|
||||
help: '''
|
||||
See your current Resin CLI configuration.
|
||||
|
||||
Configuration lives in $HOME/.resin/config.
|
||||
'''
|
||||
action: (params, options, done) ->
|
||||
for key, value of settings.get()
|
||||
console.log("#{key}: #{value}")
|
||||
return done()
|
||||
|
@ -1,4 +1,4 @@
|
||||
_ = require('lodash-contrib')
|
||||
_ = require('lodash')
|
||||
Promise = require('bluebird')
|
||||
capitano = Promise.promisifyAll(require('capitano'))
|
||||
path = require('path')
|
||||
@ -112,7 +112,7 @@ exports.wizard =
|
||||
(made, callback) ->
|
||||
console.log("Associating #{params.name} with #{params.directory}...")
|
||||
process.chdir(params.directory)
|
||||
capitano.run("app associate #{params.name} --project #{params.directory}", callback)
|
||||
capitano.run("app associate #{params.name}", callback)
|
||||
|
||||
(remoteUrl, callback) ->
|
||||
console.log("Resin git remote added: #{remoteUrl}")
|
||||
|
@ -17,36 +17,8 @@ capitano.command
|
||||
action: ->
|
||||
capitano.execute(command: 'help')
|
||||
|
||||
# ---------- Options ----------
|
||||
capitano.globalOption
|
||||
signature: 'quiet'
|
||||
description: 'quiet (no output)'
|
||||
boolean: true
|
||||
alias: 'q'
|
||||
|
||||
capitano.globalOption
|
||||
signature: 'project'
|
||||
parameter: 'path'
|
||||
description: 'project path'
|
||||
alias: 'j'
|
||||
|
||||
capitano.globalOption
|
||||
signature: 'version'
|
||||
description: actions.info.version.description
|
||||
boolean: true
|
||||
alias: 'v'
|
||||
|
||||
# We don't do anything in response to this options
|
||||
# explicitly. We use InquirerJS to provide CLI widgets,
|
||||
# and that module understands --no-color automatically.
|
||||
capitano.globalOption
|
||||
signature: 'no-color'
|
||||
description: 'disable colour highlighting'
|
||||
boolean: true
|
||||
|
||||
# ---------- Info Module ----------
|
||||
capitano.command(actions.info.version)
|
||||
capitano.command(actions.info.config)
|
||||
|
||||
# ---------- Help Module ----------
|
||||
capitano.command(actions.help.help)
|
||||
@ -66,7 +38,6 @@ capitano.command(actions.app.list)
|
||||
capitano.command(actions.app.remove)
|
||||
capitano.command(actions.app.restart)
|
||||
capitano.command(actions.app.associate)
|
||||
capitano.command(actions.app.init)
|
||||
capitano.command(actions.app.info)
|
||||
|
||||
# ---------- Device Module ----------
|
||||
@ -106,12 +77,6 @@ capitano.command(actions.plugin.install)
|
||||
capitano.command(actions.plugin.update)
|
||||
capitano.command(actions.plugin.remove)
|
||||
|
||||
changeProjectDirectory = (directory) ->
|
||||
try
|
||||
process.chdir(directory)
|
||||
catch
|
||||
errors.handle(new Error("Invalid project: #{directory}"))
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
@ -119,16 +84,6 @@ async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
cli = capitano.parse(process.argv)
|
||||
|
||||
if cli.global.quiet or not process.stdout.isTTY
|
||||
console.info = _.noop
|
||||
|
||||
if cli.global.project?
|
||||
changeProjectDirectory(cli.global.project)
|
||||
|
||||
if cli.global.version
|
||||
actions.info.version.action(null, null, callback)
|
||||
else
|
||||
capitano.execute(cli, callback)
|
||||
|
||||
], errors.handle)
|
||||
|
@ -45,12 +45,9 @@
|
||||
"bluebird": "^2.9.34",
|
||||
"capitano": "~1.6.1",
|
||||
"coffee-script": "^1.9.3",
|
||||
"conf.js": "^0.1.1",
|
||||
"drivelist": "^1.2.2",
|
||||
"fs-extra": "^0.22.1",
|
||||
"html-to-text": "^1.3.1",
|
||||
"lodash": "^3.10.0",
|
||||
"lodash-contrib": "^393.0.1",
|
||||
"mkdirp": "~0.5.0",
|
||||
"nplugm": "^2.2.0",
|
||||
"npm": "^2.13.0",
|
||||
@ -67,10 +64,7 @@
|
||||
"resin-settings-client": "^1.4.0",
|
||||
"resin-vcs": "^2.0.0",
|
||||
"selfupdate": "^1.1.0",
|
||||
"through2": "^2.0.0",
|
||||
"tmp": "0.0.26",
|
||||
"underscore.string": "^3.1.1",
|
||||
"update-notifier": "^0.3.1",
|
||||
"user-home": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user