2016-04-15 22:58:44 +00:00
|
|
|
"use strict";
|
2016-02-23 06:06:54 +00:00
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
var plugins = require("./smartstring.plugins");
|
|
|
|
/* ---------------------------------------------- *
|
|
|
|
* ------------------ classes ------------------- *
|
|
|
|
* ---------------------------------------------- */
|
|
|
|
var gitRepo = (function () {
|
|
|
|
function gitRepo(stringArg, tokenArg) {
|
|
|
|
var regexMatches = gitRegex(stringArg);
|
|
|
|
this.host = regexMatches[1];
|
|
|
|
this.user = regexMatches[2];
|
|
|
|
this.repo = regexMatches[3];
|
|
|
|
this.accessToken = tokenArg;
|
|
|
|
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "ssh");
|
|
|
|
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "https");
|
|
|
|
}
|
|
|
|
;
|
|
|
|
return gitRepo;
|
2016-04-15 22:58:44 +00:00
|
|
|
}());
|
2016-05-01 12:02:48 +00:00
|
|
|
exports.gitRepo = gitRepo;
|
2016-02-23 06:06:54 +00:00
|
|
|
/* ---------------------------------------------- *
|
|
|
|
* ------------------ helpers ------------------- *
|
|
|
|
* ---------------------------------------------- */
|
|
|
|
var gitRegex = function (stringArg) {
|
|
|
|
var regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
|
|
|
|
var regexMatches = regexString.exec(stringArg);
|
|
|
|
return regexMatches;
|
|
|
|
};
|
|
|
|
var gitLink = function (hostArg, userArg, repoArg, tokenArg, linkTypeArg) {
|
|
|
|
if (tokenArg === void 0) { tokenArg = ""; }
|
|
|
|
var returnString;
|
|
|
|
if (tokenArg !== "") {
|
|
|
|
tokenArg = tokenArg + "@";
|
|
|
|
}
|
|
|
|
switch (linkTypeArg) {
|
|
|
|
case "https":
|
|
|
|
returnString = "https://" +
|
|
|
|
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
|
|
|
|
break;
|
|
|
|
case "ssh":
|
|
|
|
returnString = "git@" +
|
|
|
|
hostArg + ":" + userArg + "/" + repoArg + ".git";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return returnString;
|
|
|
|
};
|
|
|
|
/* ---------------------------------------------- *
|
|
|
|
* ------------------ exports ------------------- *
|
|
|
|
* ---------------------------------------------- */
|
2016-05-01 12:02:48 +00:00
|
|
|
exports.git = function (stringArg, tokenArg) {
|
2016-02-23 06:06:54 +00:00
|
|
|
var localGitRepo = new gitRepo(stringArg, tokenArg);
|
|
|
|
return localGitRepo;
|
|
|
|
};
|
|
|
|
|
2016-05-16 22:02:29 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmdpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzVDLElBQU8sT0FBTyxXQUFXLHVCQUF1QixDQUFDLENBQUM7QUFFbEQ7O29EQUVvRDtBQUNwRDtJQU9JLGlCQUFZLFNBQWdCLEVBQUMsUUFBZ0I7UUFDekMsSUFBSSxZQUFZLEdBQUcsUUFBUSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxXQUFXLEdBQUcsUUFBUSxDQUFDO1FBQzVCLElBQUksQ0FBQyxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQ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