Merge pull request #248 from resin-io/jviotti/remove/associate

Remove app associate command
This commit is contained in:
Juan Cruz Viotti 2015-10-21 14:13:28 -04:00
commit e962371b59
4 changed files with 1 additions and 83 deletions

View File

@ -1,7 +1,5 @@
(function() { (function() {
var _, commandOptions, events, helpers, patterns, resin, vcs, visuals; var commandOptions, events, patterns, resin, visuals;
_ = require('lodash');
resin = require('resin-sdk'); resin = require('resin-sdk');
@ -9,12 +7,8 @@
commandOptions = require('./command-options'); commandOptions = require('./command-options');
vcs = require('resin-vcs');
events = require('resin-cli-events'); events = require('resin-cli-events');
helpers = require('../utils/helpers');
patterns = require('../utils/patterns'); patterns = require('../utils/patterns');
exports.create = { exports.create = {
@ -107,35 +101,4 @@
} }
}; };
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',
options: [commandOptions.yes],
permission: 'user',
action: function(params, options, done) {
var currentDirectory;
currentDirectory = process.cwd();
console.info("Associating " + params.name + " with " + currentDirectory);
return resin.models.application.has(params.name).then(function(hasApplication) {
if (!hasApplication) {
throw new Error("Invalid application: " + params.name);
}
}).then(function() {
var message;
message = "Are you sure you want to associate " + currentDirectory + " with " + params.name + "?";
return patterns.confirm(options.yes, message);
}).then(function() {
return resin.models.application.get(params.name).get('git_repository').then(function(gitRepository) {
return vcs.initialize(currentDirectory).then(function() {
return vcs.associate(currentDirectory, gitRepository);
}).then(function() {
console.info("git repository added: " + gitRepository);
return gitRepository;
});
});
}).nodeify(done);
}
};
}).call(this); }).call(this);

View File

@ -56,8 +56,6 @@
capitano.command(actions.app.restart); capitano.command(actions.app.restart);
capitano.command(actions.app.associate);
capitano.command(actions.app.info); capitano.command(actions.app.info);
capitano.command(actions.device.list); capitano.command(actions.device.list);

View File

@ -1,10 +1,7 @@
_ = require('lodash')
resin = require('resin-sdk') resin = require('resin-sdk')
visuals = require('resin-cli-visuals') visuals = require('resin-cli-visuals')
commandOptions = require('./command-options') commandOptions = require('./command-options')
vcs = require('resin-vcs')
events = require('resin-cli-events') events = require('resin-cli-events')
helpers = require('../utils/helpers')
patterns = require('../utils/patterns') patterns = require('../utils/patterns')
exports.create = exports.create =
@ -140,42 +137,3 @@ exports.remove =
resin.models.application.get(params.name).then (application) -> resin.models.application.get(params.name).then (application) ->
events.send('application.delete', application: application.id) events.send('application.delete', application: application.id)
.nodeify(done) .nodeify(done)
exports.associate =
signature: 'app associate <name>'
description: 'associate a resin project'
help: '''
Use this command to associate a project directory with a resin application.
This command adds a 'resin' git remote to the directory and runs git init if necessary.
Notice this command asks for confirmation interactively.
You can avoid this by passing the `--yes` boolean option.
Examples:
$ resin app associate MyApp
'''
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
currentDirectory = process.cwd()
console.info("Associating #{params.name} with #{currentDirectory}")
resin.models.application.has(params.name).then (hasApplication) ->
if not hasApplication
throw new Error("Invalid application: #{params.name}")
.then ->
message = "Are you sure you want to associate #{currentDirectory} with #{params.name}?"
patterns.confirm(options.yes, message)
.then ->
resin.models.application.get(params.name).get('git_repository').then (gitRepository) ->
vcs.initialize(currentDirectory).then ->
return vcs.associate(currentDirectory, gitRepository)
.then ->
console.info("git repository added: #{gitRepository}")
return gitRepository
.nodeify(done)

View File

@ -38,7 +38,6 @@ capitano.command(actions.app.create)
capitano.command(actions.app.list) capitano.command(actions.app.list)
capitano.command(actions.app.remove) capitano.command(actions.app.remove)
capitano.command(actions.app.restart) capitano.command(actions.app.restart)
capitano.command(actions.app.associate)
capitano.command(actions.app.info) capitano.command(actions.app.info)
# ---------- Device Module ---------- # ---------- Device Module ----------