mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-10 04:39:54 +00:00
Make use of gitwrap
This commit is contained in:
parent
0cc1765a1e
commit
8fbde4c452
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, git, path, resin, visuals;
|
||||
var _, async, commandOptions, gitwrap, path, resin, visuals;
|
||||
|
||||
path = require('path');
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
git = require('../git');
|
||||
gitwrap = require('gitwrap');
|
||||
|
||||
exports.create = {
|
||||
signature: 'app create <name>',
|
||||
@ -108,20 +108,22 @@
|
||||
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\nExamples:\n\n $ resin app associate 91\n $ resin app associate 91 --project my/app/directory',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var currentDirectory;
|
||||
currentDirectory = process.cwd();
|
||||
var git;
|
||||
git = gitwrap.create(process.cwd());
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
return git.isGitDirectory(currentDirectory, callback);
|
||||
return git.isGitRepository(function(isGitDirectory) {
|
||||
return callback(null, isGitDirectory);
|
||||
});
|
||||
}, function(isGitDirectory, callback) {
|
||||
if (isGitDirectory) {
|
||||
return callback();
|
||||
}
|
||||
return git.execute('init', currentDirectory, _.unary(callback));
|
||||
return git.execute('init', _.unary(callback));
|
||||
}, function(callback) {
|
||||
return resin.models.application.get(params.id, callback);
|
||||
}, function(application, callback) {
|
||||
return git.execute("remote add resin " + application.git_repository, currentDirectory, function(error) {
|
||||
return git.execute("remote add resin " + application.git_repository, function(error) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
(function() {
|
||||
var git;
|
||||
|
||||
git = require('./git');
|
||||
|
||||
git.execute('status', process.cwd(), function(error, stdout, stderr) {
|
||||
console.log(arguments);
|
||||
return console.log(stdout);
|
||||
});
|
||||
|
||||
}).call(this);
|
18
build/git.js
18
build/git.js
@ -1,18 +0,0 @@
|
||||
(function() {
|
||||
var child_process;
|
||||
|
||||
child_process = require('child_process');
|
||||
|
||||
exports.isGitDirectory = function(directory, callback) {
|
||||
return exports.execute('status', directory, function(error, stdout, stderr) {
|
||||
return callback(null, error == null);
|
||||
});
|
||||
};
|
||||
|
||||
exports.execute = function(command, cwd, callback) {
|
||||
return child_process.exec("git " + command, {
|
||||
cwd: cwd
|
||||
}, callback);
|
||||
};
|
||||
|
||||
}).call(this);
|
@ -1,68 +0,0 @@
|
||||
{
|
||||
"name": "resin-cli",
|
||||
"version": "0.0.1",
|
||||
"description": "Git Push to your devices",
|
||||
"main": "./lib/actions/index.coffee",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@bitbucket.org:rulemotion/resin-cli.git"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"bundled_engine": "v0.12.0",
|
||||
"man": [
|
||||
"./man/resin.1",
|
||||
"./man/resin-completion.1",
|
||||
"./man/resin-plugins.1"
|
||||
],
|
||||
"bin": {
|
||||
"resin": "./bin/resin"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "gulp build",
|
||||
"test": "gult test",
|
||||
"install": "node build/install-node.js bin/node"
|
||||
},
|
||||
"keywords": [
|
||||
"resin",
|
||||
"git"
|
||||
],
|
||||
"author": "Juan Cruz Viotti <juanchiviotti@gmail.com>",
|
||||
"license": "MIT",
|
||||
"optionalDependencies": {
|
||||
"windosu": "^0.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.9.2",
|
||||
"gulp": "~3.8.9",
|
||||
"gulp-coffee": "^2.2.0",
|
||||
"gulp-coffeelint": "~0.4.0",
|
||||
"gulp-marked-man": "~0.3.1",
|
||||
"gulp-mocha": "~1.1.1",
|
||||
"gulp-shell": "^0.2.11",
|
||||
"gulp-util": "~3.0.1",
|
||||
"mocha": "~2.0.1",
|
||||
"mocha-notifier-reporter": "~0.1.0",
|
||||
"run-sequence": "~1.0.2",
|
||||
"sinon": "~1.12.1",
|
||||
"sinon-chai": "~2.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "~0.9.0",
|
||||
"capitano": "~1.5.0",
|
||||
"coffee-script": "~1.8.0",
|
||||
"conf.js": "^0.1.1",
|
||||
"diskio": "^1.0.0",
|
||||
"drivelist": "^1.2.0",
|
||||
"git-cli": "~0.8.2",
|
||||
"lodash": "~2.4.1",
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
"node-binary": "^1.0.1",
|
||||
"nplugm": "^2.0.0",
|
||||
"open": "0.0.5",
|
||||
"progress-stream": "^0.5.0",
|
||||
"resin-cli-visuals": "resin-io/resin-cli-visuals",
|
||||
"resin-sdk": "resin-io/resin-sdk",
|
||||
"underscore.string": "~2.4.0"
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
commandOptions = require('./command-options')
|
||||
git = require('../git')
|
||||
gitwrap = require('gitwrap')
|
||||
|
||||
exports.create =
|
||||
signature: 'app create <name>'
|
||||
@ -147,22 +147,23 @@ exports.associate =
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
currentDirectory = process.cwd()
|
||||
git = gitwrap.create(process.cwd())
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
git.isGitDirectory(currentDirectory, callback)
|
||||
git.isGitRepository (isGitDirectory) ->
|
||||
return callback(null, isGitDirectory)
|
||||
|
||||
(isGitDirectory, callback) ->
|
||||
return callback() if isGitDirectory
|
||||
git.execute('init', currentDirectory, _.unary(callback))
|
||||
git.execute('init', _.unary(callback))
|
||||
|
||||
(callback) ->
|
||||
resin.models.application.get(params.id, callback)
|
||||
|
||||
(application, callback) ->
|
||||
git.execute "remote add resin #{application.git_repository}", currentDirectory, (error) ->
|
||||
git.execute "remote add resin #{application.git_repository}", (error) ->
|
||||
return callback(error) if error?
|
||||
console.info("git repository added: #{application.git_repository}")
|
||||
return callback(null, application.git_repository)
|
||||
|
@ -1,8 +0,0 @@
|
||||
child_process = require('child_process')
|
||||
|
||||
exports.isGitDirectory = (directory, callback) ->
|
||||
exports.execute 'status', directory, (error, stdout, stderr) ->
|
||||
return callback(null, not error?)
|
||||
|
||||
exports.execute = (command, cwd, callback) ->
|
||||
child_process.exec("git #{command}", { cwd }, callback)
|
@ -54,6 +54,7 @@
|
||||
"diskio": "^1.0.0",
|
||||
"drivelist": "^1.2.1",
|
||||
"git-cli": "~0.8.2",
|
||||
"gitwrap": "^1.0.0",
|
||||
"lodash": "~2.4.1",
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user