2016-04-15 22:58:44 +00:00
|
|
|
"use strict";
|
2016-02-23 06:06:54 +00:00
|
|
|
var plugins = require("./smartstring.plugins");
|
|
|
|
/* ---------------------------------------------- *
|
|
|
|
* ------------------ classes ------------------- *
|
|
|
|
* ---------------------------------------------- */
|
2016-05-25 03:06:19 +00:00
|
|
|
var GitRepo = (function () {
|
|
|
|
function GitRepo(stringArg, tokenArg) {
|
2016-02-23 06:06:54 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
;
|
2016-05-25 03:06:19 +00:00
|
|
|
return GitRepo;
|
2016-04-15 22:58:44 +00:00
|
|
|
}());
|
2016-05-25 03:06:19 +00:00
|
|
|
exports.GitRepo = GitRepo;
|
2016-02-23 06:06:54 +00:00
|
|
|
/* ---------------------------------------------- *
|
|
|
|
* ------------------ helpers ------------------- *
|
|
|
|
* ---------------------------------------------- */
|
|
|
|
var gitRegex = function (stringArg) {
|
2016-06-05 07:31:10 +00:00
|
|
|
var regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
|
2016-02-23 06:06:54 +00:00
|
|
|
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;
|
|
|
|
};
|
2016-07-06 08:04:25 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZ2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZ2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSx1QkFBdUIsQ0FBQyxDQUFBO0FBRWpEOztvREFFb0Q7QUFDcEQ7SUFPSSxpQkFBWSxTQUFnQixFQUFDLFFBQWdCO1FBQ3pDLElBQUksWUFBWSxHQUFHLFFBQVEsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUN2QyxJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsV0FBVyxHQUFHLFFBQVEsQ0FBQztRQUM1QixJQUFJLENBQUMsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFDLElBQUksQ0FBQyxJQUFJLEVBQUMsSUFBSSxDQUFDLElBQUksRUFBQyxJQUFJLENBQUMsV0FBVyxFQUFFLEtBQUssQ0FBQyxDQ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