diff --git a/.gitignore b/.gitignore index 5535cf4..14d48a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ node_modules/ .settings/ .idea/ - +test/temp/ #npm devug npm-debug.log diff --git a/ts/index.ts b/ts/index.ts index 7133f9d..6584620 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,15 +1,46 @@ /// var path = require("path"); -var pr = require("pushrocks"); -var fs +var beautylog = require("beautylog")("os"); +var nodegit = require("nodegit"); -var smartfile:any = { - readFileToString: function(filePath) { - var fileString; - fileString = plugins.fs.readFileSync(filePath, "utf8"); - return fileString; +var smartgit:any = {}; + +smartgit.clone = function(cloneURL:string = "undefined" ,dest:string = "undefined"){ + if (cloneURL == "undefined" || dest == "undefined") { + beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function"); + return; } + + 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) { -module.exports = smartfile; +}; + +smartgit.init = 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 + nodegit.Repository.init(dest, isBare).then(function (repo) { + // do something with repo here. + }); +}; + +module.exports = smartgit; diff --git a/ts/smartgit.interfaces.ts b/ts/smartgit.interfaces.ts new file mode 100644 index 0000000..e69de29 diff --git a/ts/test.ts b/ts/test.ts index e69de29..7a6c7c4 100644 --- a/ts/test.ts +++ b/ts/test.ts @@ -0,0 +1,3 @@ +/// +var smartgit = require("./index.js"); +var beautylog = require("beautylog"); \ No newline at end of file diff --git a/ts/tsd.json b/ts/tsd.json index 0764c2c..b3361fd 100644 --- a/ts/tsd.json +++ b/ts/tsd.json @@ -7,6 +7,9 @@ "installed": { "node/node.d.ts": { "commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63" + }, + "colors/colors.d.ts": { + "commit": "785c18f0c897c44ea7fa1a47f3bcb48110658520" } } } diff --git a/ts/typings/colors/colors.d.ts b/ts/typings/colors/colors.d.ts new file mode 100644 index 0000000..5aa2855 --- /dev/null +++ b/ts/typings/colors/colors.d.ts @@ -0,0 +1,123 @@ +// Type definitions for Colors.js 0.6.0-1 +// Project: https://github.com/Marak/colors.js +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "colors" { + interface Color { + (text: string): string; + + black: Color; + red: Color; + green: Color; + yellow: Color; + blue: Color; + magenta: Color; + cyan: Color; + white: Color; + gray: Color; + grey: Color; + + bgBlack: Color; + bgRed: Color; + bgGreen: Color; + bgYellow: Color; + bgBlue: Color; + bgMagenta: Color; + bgCyan: Color; + bgWhite: Color; + + reset: Color; + bold: Color; + dim: Color; + italic: Color; + underline: Color; + inverse: Color; + hidden: Color; + strikethrough: Color; + + rainbow: Color; + zebra: Color; + america: Color; + trap: Color; + random: Color; + } + + module e { + export function setTheme(theme:any): void; + + export var black: Color; + export var red: Color; + export var green: Color; + export var yellow: Color; + export var blue: Color; + export var magenta: Color; + export var cyan: Color; + export var white: Color; + export var gray: Color; + export var grey: Color; + + export var bgBlack: Color; + export var bgRed: Color; + export var bgGreen: Color; + export var bgYellow: Color; + export var bgBlue: Color; + export var bgMagenta: Color; + export var bgCyan: Color; + export var bgWhite: Color; + + export var reset: Color; + export var bold: Color; + export var dim: Color; + export var italic: Color; + export var underline: Color; + export var inverse: Color; + export var hidden: Color; + export var strikethrough: Color; + + export var rainbow: Color; + export var zebra: Color; + export var america: Color; + export var trap: Color; + export var random: Color; + } + + export = e; +} + +interface String { + black: string; + red: string; + green: string; + yellow: string; + blue: string; + magenta: string; + cyan: string; + white: string; + gray: string; + grey: string; + + bgBlack: string; + bgRed: string; + bgGreen: string; + bgYellow: string; + bgBlue: string; + bgMagenta: string; + bgCyan: string; + bgWhite: string; + + reset: string; + bold: string; + dim: string; + italic: string; + underline: string; + inverse: string; + hidden: string; + strikethrough: string; + + rainbow: string; + zebra: string; + america: string; + trap: string; + random: string; +} diff --git a/ts/typings/tsd.d.ts b/ts/typings/tsd.d.ts index 4bd49f3..088fea2 100644 --- a/ts/typings/tsd.d.ts +++ b/ts/typings/tsd.d.ts @@ -1 +1,2 @@ /// +///