This commit is contained in:
2016-03-31 01:59:45 +02:00
commit 82b565e97f
27 changed files with 423 additions and 0 deletions

16
ts/index.ts Normal file
View File

@ -0,0 +1,16 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
import SmartgitClone = require("./smartgit.clone");
import SmartgitCommit = require("./smartgit.commit");
import SmartgitInit = require("./smartgit.init");
var smartgit:any = {};
smartgit.clone = SmartgitClone;
smartgit.commit = SmartgitCommit;
smartgit.check = SmartgitCheck;
smartgit.init = SmartgitInit;
module.exports = smartgit;

0
ts/smartgit.add.ts Normal file
View File

5
ts/smartgit.check.ts Normal file
View File

@ -0,0 +1,5 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(repoArg) {
return true;
};

26
ts/smartgit.clone.ts Normal file
View File

@ -0,0 +1,26 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
export = function(options){
let done = plugins.Q.defer();
/***** URL Checks ******/
if (options.from == "undefined" || options.to == "undefined") {
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
return;
}
/***** Path Checks ******/
if (!/^\/.*/.test(options.to)){ //check wether path is absolute
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
return;
}
plugins.beautylog.log("Now cloning " + options.from);
var cloneOptions:any = {};
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
SmartgitCheck(cloneRepository);
done.resolve();
return done.promise;
};

9
ts/smartgit.commit.ts Normal file
View File

@ -0,0 +1,9 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(pathArg:string,commitMessage:string) {
var result = plugins.nodegit.index.addByPath(pathArg);
if (result == 0) {
}
};

14
ts/smartgit.init.ts Normal file
View File

@ -0,0 +1,14 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(){
var gitinit = function(dest:string = "undefined") {
if (dest == "undefined") { //lets check if a destination is defined...
return; // ...and return function here if not
}
var isBare = 0; //lets create a subfolder
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
// do something with repo here.
});
};
}

View File

8
ts/smartgit.plugins.ts Normal file
View File

@ -0,0 +1,8 @@
/// <reference path="./typings/main.d.ts" />
export let path = require("path");
export let beautylog = require("beautylog");
export let nodegit = require("nodegit");
export let Q = require("q");

7
ts/typings.json Normal file
View File

@ -0,0 +1,7 @@
{
"ambientDependencies": {
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
"mocha": "registry:dt/mocha#2.2.5+20160317120654",
"node": "registry:dt/node#4.0.0+20160330064709"
}
}