mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 10:46:34 +00:00
Merge pull request #248 from resin-io/jviotti/remove/associate
Remove app associate command
This commit is contained in:
commit
e962371b59
@ -1,7 +1,5 @@
|
||||
(function() {
|
||||
var _, commandOptions, events, helpers, patterns, resin, vcs, visuals;
|
||||
|
||||
_ = require('lodash');
|
||||
var commandOptions, events, patterns, resin, visuals;
|
||||
|
||||
resin = require('resin-sdk');
|
||||
|
||||
@ -9,12 +7,8 @@
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
events = require('resin-cli-events');
|
||||
|
||||
helpers = require('../utils/helpers');
|
||||
|
||||
patterns = require('../utils/patterns');
|
||||
|
||||
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);
|
||||
|
@ -56,8 +56,6 @@
|
||||
|
||||
capitano.command(actions.app.restart);
|
||||
|
||||
capitano.command(actions.app.associate);
|
||||
|
||||
capitano.command(actions.app.info);
|
||||
|
||||
capitano.command(actions.device.list);
|
||||
|
@ -1,10 +1,7 @@
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
commandOptions = require('./command-options')
|
||||
vcs = require('resin-vcs')
|
||||
events = require('resin-cli-events')
|
||||
helpers = require('../utils/helpers')
|
||||
patterns = require('../utils/patterns')
|
||||
|
||||
exports.create =
|
||||
@ -140,42 +137,3 @@ exports.remove =
|
||||
resin.models.application.get(params.name).then (application) ->
|
||||
events.send('application.delete', application: application.id)
|
||||
.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)
|
||||
|
@ -38,7 +38,6 @@ capitano.command(actions.app.create)
|
||||
capitano.command(actions.app.list)
|
||||
capitano.command(actions.app.remove)
|
||||
capitano.command(actions.app.restart)
|
||||
capitano.command(actions.app.associate)
|
||||
capitano.command(actions.app.info)
|
||||
|
||||
# ---------- Device Module ----------
|
||||
|
Loading…
Reference in New Issue
Block a user