work in progress
This commit is contained in:
parent
a5d7a9b550
commit
a2d9a3a3e5
49
index.js
49
index.js
@ -1,10 +1,47 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
var through = require("through2");
|
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
module.exports = function (jadeTemplate, mojo) {
|
var beautylog = require("beautylog")("os");
|
||||||
if (mojo === void 0) { mojo = undefined; }
|
var nodegit = require("nodegit");
|
||||||
return through.obj(function (file, enc, cb) {
|
var smartgit = {};
|
||||||
//run callback function to signal end of plugin process.
|
smartgit.clone = function (cloneURL, dest) {
|
||||||
return cb(null, file);
|
if (cloneURL === void 0) { cloneURL = "undefined"; }
|
||||||
|
if (dest === void 0) { dest = "undefined"; }
|
||||||
|
if (cloneURL == "undefined" || dest == "undefined") {
|
||||||
|
beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/^\/.*/.test(dest)) {
|
||||||
|
beautylog.error("It seems that the given path " + dest + " is not absolute.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
beautylog.log("Now cloning " + cloneURL);
|
||||||
|
var cloneOptions = {};
|
||||||
|
cloneOptions.remoteCallbacks = {
|
||||||
|
certificateCheck: function () { return 1; },
|
||||||
|
credentials: function (url, userName) {
|
||||||
|
return nodegit.Cred.sshKeyFromAgent(userName);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var cloneRepository = nodegit.Clone(cloneURL, dest, {});
|
||||||
|
var errorAndAttemptOpen = function () {
|
||||||
|
return nodegit.Repository.open(dest);
|
||||||
|
};
|
||||||
|
cloneRepository.catch(errorAndAttemptOpen)
|
||||||
|
.then(function (repository) {
|
||||||
|
// Access any repository methods here.
|
||||||
|
console.log("Is the repository bare? %s", Boolean(repository.isBare()));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
smartgit.commit = function (commitMessage) {
|
||||||
|
};
|
||||||
|
smartgit.init = function (dest) {
|
||||||
|
if (dest === void 0) { dest = "undefined"; }
|
||||||
|
if (dest == "undefined") {
|
||||||
|
return; // ...and return function here if not
|
||||||
|
}
|
||||||
|
var isBare = 0; //lets create a subfolder
|
||||||
|
nodegit.Repository.init(dest, isBare).then(function (repo) {
|
||||||
|
// do something with repo here.
|
||||||
|
});
|
||||||
|
};
|
||||||
|
module.exports = smartgit;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "an easy wrapper for nodegit",
|
"description": "an easy wrapper for nodegit",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && node compile.js)",
|
"test": "(cd ts/compile && node compile.js) && (node test.js)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"reinstall": "(rm -r node_modules && npm install)",
|
||||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
||||||
"startdev": "(git checkout master && git pull origin master)"
|
"startdev": "(git checkout master && git pull origin master)"
|
||||||
@ -26,7 +26,8 @@
|
|||||||
"homepage": "https://github.com/pushrocks/smartgit",
|
"homepage": "https://github.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^1.0.2",
|
"beautylog": "^1.0.2",
|
||||||
"nodegit": "^0.5.0"
|
"nodegit": "^0.5.0",
|
||||||
|
"q": "^1.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "3.9.0",
|
"gulp": "3.9.0",
|
||||||
|
1
test
Submodule
1
test
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit aad8492c55ae5911f23b763da11fff05f5f15f95
|
6
test.js
Normal file
6
test.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
|
var smartgit = require("./index.js");
|
||||||
|
var beautylog = require("beautylog")("os");
|
||||||
|
var path = require("path");
|
||||||
|
smartgit.clone("https://github.com/pushrocks/cooltest.git", path.resolve("./test/"));
|
||||||
|
beautylog.success("Test successfull");
|
52
ts/index.ts
52
ts/index.ts
@ -1,36 +1,25 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
var path = require("path");
|
/// <reference path="smartgit.clone.ts" />
|
||||||
var beautylog = require("beautylog")("os");
|
/// <reference path="smartgit.init.ts" />
|
||||||
var nodegit = require("nodegit");
|
/// <reference path="smartgit.commit.ts" />
|
||||||
|
|
||||||
|
var plugins = {
|
||||||
|
path: require("path"),
|
||||||
|
beautylog: require("beautylog")("os"),
|
||||||
|
nodegit: require("nodegit"),
|
||||||
|
Q: require("q")
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var smartgit:any = {};
|
var smartgit:any = {};
|
||||||
|
|
||||||
smartgit.clone = function(cloneURL:string = "undefined" ,dest:string = "undefined"){
|
smartgit.clone = SmartgitClone
|
||||||
if (cloneURL == "undefined" || dest == "undefined") {
|
|
||||||
beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
smartgit.commit = function(pathArg:string,commitMessage:string) {
|
||||||
return;
|
var result = plugins.nodegit.index.addByPath(pathArg);
|
||||||
|
if (result == 0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var cloneOptions:any = {};
|
|
||||||
cloneOptions.remoteCallbacks = {
|
|
||||||
certificateCheck: function() { return 1; },
|
|
||||||
credentials: function(url, userName) {
|
|
||||||
return nodegit.Cred.sshKeyFromAgent(userName);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var cloneRepository = nodegit.Clone(cloneURL, dest, cloneOptions);
|
|
||||||
var errorAndAttemptOpen = function() {
|
|
||||||
return nodegit.Repository.open(dest);
|
|
||||||
};
|
|
||||||
cloneRepository.catch(errorAndAttemptOpen)
|
|
||||||
.then(function(repository) {
|
|
||||||
// Access any repository methods here.
|
|
||||||
console.log("Is the repository bare? %s", Boolean(repository.isBare()));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
smartgit.commit = function(commitMessage:string) {
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
smartgit.init = function(dest:string = "undefined") {
|
smartgit.init = function(dest:string = "undefined") {
|
||||||
@ -38,9 +27,14 @@ smartgit.init = function(dest:string = "undefined") {
|
|||||||
return; // ...and return function here if not
|
return; // ...and return function here if not
|
||||||
}
|
}
|
||||||
var isBare = 0; //lets create a subfolder
|
var isBare = 0; //lets create a subfolder
|
||||||
nodegit.Repository.init(dest, isBare).then(function (repo) {
|
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
|
||||||
// do something with repo here.
|
// do something with repo here.
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
smartgit.check = function(repository) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = smartgit;
|
module.exports = smartgit;
|
||||||
|
0
ts/smartgit.add.ts
Normal file
0
ts/smartgit.add.ts
Normal file
34
ts/smartgit.clone.ts
Normal file
34
ts/smartgit.clone.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module SmartgitClone {
|
||||||
|
export function init() {
|
||||||
|
var clone = function(cloneURL:string = "undefined" ,dest:string = "undefined"){
|
||||||
|
|
||||||
|
/***** URL Checks ******/
|
||||||
|
if (cloneURL == "undefined" || dest == "undefined") {
|
||||||
|
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Path Checks ******/
|
||||||
|
if (!/^\/.*/.test(dest)){ //check wether path is absolute
|
||||||
|
plugins.beautylog.error("It seems that the given path " + dest + " is not absolute.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
plugins.beautylog.log("Now cloning " + cloneURL);
|
||||||
|
var cloneOptions:any = {};
|
||||||
|
cloneOptions.remoteCallbacks = {
|
||||||
|
certificateCheck: function() { return 1; },
|
||||||
|
credentials: function(url, userName) {
|
||||||
|
return plugins.nodegit.Cred.sshKeyFromAgent(userName);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var cloneRepository = plugins.nodegit.Clone(cloneURL, dest, cloneOptions);
|
||||||
|
smartgit.check(cloneRepository);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
}
|
0
ts/smartgit.init.ts
Normal file
0
ts/smartgit.init.ts
Normal file
@ -1,3 +1,10 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
var smartgit = require("./index.js");
|
var smartgit = require("./index.js");
|
||||||
var beautylog = require("beautylog");
|
var beautylog = require("beautylog")("os");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
smartgit.clone("https://github.com/pushrocks/cooltest.git",path.resolve("./test/"));
|
||||||
|
|
||||||
|
beautylog.success("Test successfull");
|
Loading…
x
Reference in New Issue
Block a user