initial
This commit is contained in:
parent
6e684894d1
commit
49bf29e875
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.idea/
|
||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
node_modules
|
||||||
|
ts/**/*.js
|
||||||
|
ts/**/*.js.map
|
||||||
|
ts/typings/
|
12
.travis.yml
Normal file
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- '0.11'
|
||||||
|
- '0.10'
|
||||||
|
deploy:
|
||||||
|
provider: npm
|
||||||
|
email: npm@lossless.digital
|
||||||
|
api_key:
|
||||||
|
secure: oKx1gdYYBnaoUcpxn3WM4SdZdInIYaa3ZgbXLSh88K+PjbcSw3NNbYEnAtWFV1eAQQchDjOHId4D1Ne68DtJb5umahvhYoejtZzawjPaa6Uyi46VPk31wXYzZJyadiyefuwOhLLMM4i3yzYwEC2BeTpbU8Tvaj6B42DoySKNGUnSF9+K2wsFNp13mRje6PLe+fjo+9H4CEKLwf74alwvAWd/PLzv47KKdCZ4/9zX7TxevrIBNie+n6VxjqXm/dTv9k7J3dCunojehBr9X9sn1sd8mR+FexjcgfCA2dz8ViP8qZCslzZixGVuasmjpQH9OabrlOfQ6e+Hs4puv+U7s53SVa9nWntiYHloT29UKCPG6ofuDFq5Nd+1PCNvPfrh99F87IKTOw9DQ9Lx7Q//To4LrbnsC85/uHgkWHhbr/ZGax7wuX9og1rem1MSjYr7gQ1sx9edtDSQe3Yjhi22xDREL5/uCbnThmrd1P44CtAU7UG4TQvnHADFqi4Oogf/VBQvsC+aUJPSfZuoxX31yCYuNToH65j1Vblj9tYuPdHSriPj2OdxbuWh68lpgsh7K64Imb++3oKjh3fKZEzeJsByI+QytyUwO/Qu1c6whlkyv8yMyoaD0WARufU+zcG4P7j4rFlAO/CoezSd6l5HBUiXJNe7XniIi6KZjA1zkZc=
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
repo: pushrocks/smartstring
|
8
dist/index.js
vendored
Normal file
8
dist/index.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var git = require("./smartstring.git");
|
||||||
|
var smartstring = {
|
||||||
|
git: git
|
||||||
|
};
|
||||||
|
module.exports = smartstring;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFPLEdBQUcsV0FBVyxtQkFBbUIsQ0FBQyxDQUFDO0FBRTFDLElBQUksV0FBVyxHQUFHO0lBQ2QsR0FBRyxFQUFHLEdBQUc7Q0FDWixDQUFDO0FBRUYsaUJBQVMsV0FBVyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IGdpdCA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLmdpdFwiKTtcblxubGV0IHNtYXJ0c3RyaW5nID0ge1xuICAgIGdpdCA6IGdpdFxufTtcblxuZXhwb3J0ID0gc21hcnRzdHJpbmc7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
57
dist/smartstring.git.js
vendored
Normal file
57
dist/smartstring.git.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
dist/smartstring.plugins.js
vendored
Normal file
7
dist/smartstring.plugins.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = {
|
||||||
|
beautylog: require("beautylog")
|
||||||
|
};
|
||||||
|
module.exports = plugins;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDO0FBQzVDLElBQUksT0FBTyxHQUFHO0lBQ1YsU0FBUyxFQUFFLE9BQU8sQ0FBQyxXQUFXLENBQUM7Q0FDbEMsQ0FBQztBQUVGLGlCQUFTLE9BQU8sQ0FBQyIsImZpbGUiOiJzbWFydHN0cmluZy5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHBsdWdpbnMgPSB7XG4gICAgYmVhdXR5bG9nOiByZXF1aXJlKFwiYmVhdXR5bG9nXCIpXG59O1xuXG5leHBvcnQgPSBwbHVnaW5zOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "smartstring",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "bundles a bunch of (regex) matching and altering methods.",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "(npmts)"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/pushrocks/smartstring.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"regex",
|
||||||
|
"string"
|
||||||
|
],
|
||||||
|
"author": "Lossless GmbH",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/pushrocks/smartstring/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/pushrocks/smartstring#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"npmts": "^3.1.2",
|
||||||
|
"should": "^8.2.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"beautylog": "^3.0.2"
|
||||||
|
}
|
||||||
|
}
|
30
test/test.js
Normal file
30
test/test.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
var smartstring = require("../dist/index.js");
|
||||||
|
var should = require("should");
|
||||||
|
describe("smartstring", function () {
|
||||||
|
describe(".git()", function () {
|
||||||
|
var testGit = smartstring.git("git+https://github.com/pushrocks/smartstring.git");
|
||||||
|
it("should return a .host", function () {
|
||||||
|
testGit.host
|
||||||
|
.should.equal("github.com");
|
||||||
|
});
|
||||||
|
it("should return a .user", function () {
|
||||||
|
testGit.user
|
||||||
|
.should.equal("pushrocks");
|
||||||
|
});
|
||||||
|
it("should return a .repo", function () {
|
||||||
|
testGit.repo
|
||||||
|
.should.equal("smartstring");
|
||||||
|
});
|
||||||
|
it("should return a .httpsUrl", function () {
|
||||||
|
testGit.httpsUrl
|
||||||
|
.should.equal("https://github.com/pushrocks/smartstring.git");
|
||||||
|
});
|
||||||
|
it("should return a .sshUrl", function () {
|
||||||
|
testGit.sshUrl
|
||||||
|
.should.equal("git@github.com:pushrocks/smartstring.git");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksV0FBVyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzlDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUUvQixRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxRQUFRLEVBQUM7UUFDZCxJQUFJLE9BQU8sR0FBRyxXQUFXLENBQUMsR0FBRyxDQUFDLGtEQUFrRCxDQUFDLENBQUM7UUFDbEYsRUFBRSxDQUFDLHVCQUF1QixFQUFDO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Y3JpYmUoXCIuZ2l0KClcIixmdW5jdGlvbigpe1xuICAgICAgICBsZXQgdGVzdEdpdCA9IHNtYXJ0c3RyaW5nLmdpdChcImdpdCtodHRwczovL2dpdGh1Yi5jb20vcHVzaHJvY2tzL3NtYXJ0c3RyaW5nLmdpdFwiKTtcbiAgICAgICAgaXQoXCJzaG91bGQgcmV0dXJuIGEgLmhvc3RcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdEdpdC5ob3N0XG4gICAgICAgICAgICAgICAgLnNob3VsZC5lcXVhbChcImdpdGh1Yi5jb21cIik7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCByZXR1cm4gYSAudXNlclwiLGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICB0ZXN0R2l0LnVzZXJcbiAgICAgICAgICAgICAgICAuc2hvdWxkLmVxdWFsKFwicHVzaHJvY2tzXCIpO1xuICAgICAgICB9KTtcbiAgICAgICAgaXQoXCJzaG91bGQgcmV0dXJuIGEgLnJlcG9cIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdEdpdC5yZXBvXG4gICAgICAgICAgICAgICAgLnNob3VsZC5lcXVhbChcInNtYXJ0c3RyaW5nXCIpO1xuICAgICAgICB9KTtcbiAgICAgICAgaXQoXCJzaG91bGQgcmV0dXJuIGEgLmh0dHBzVXJsXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RHaXQuaHR0cHNVcmxcbiAgICAgICAgICAgICAgICAuc2hvdWxkLmVxdWFsKFwiaHR0cHM6Ly9naXRodWIuY29tL3B1c2hyb2Nrcy9zbWFydHN0cmluZy5naXRcIik7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCByZXR1cm4gYSAuc3NoVXJsXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RHaXQuc3NoVXJsXG4gICAgICAgICAgICAgICAgLnNob3VsZC5lcXVhbChcImdpdEBnaXRodWIuY29tOnB1c2hyb2Nrcy9zbWFydHN0cmluZy5naXRcIik7XG4gICAgICAgIH0pO1xuICAgIH0pXG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,QAAQ,EAAC;QACd,IAAI,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAClF,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2BAA2B,EAAC;YAC3B,OAAO,CAAC,QAAQ;iBACX,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,yBAAyB,EAAC;YACzB,OAAO,CAAC,MAAM;iBACT,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}
|
29
test/test.ts
Normal file
29
test/test.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
let smartstring = require("../dist/index.js");
|
||||||
|
let should = require("should");
|
||||||
|
|
||||||
|
describe("smartstring",function(){
|
||||||
|
describe(".git()",function(){
|
||||||
|
let testGit = smartstring.git("git+https://github.com/pushrocks/smartstring.git");
|
||||||
|
it("should return a .host",function(){
|
||||||
|
testGit.host
|
||||||
|
.should.equal("github.com");
|
||||||
|
});
|
||||||
|
it("should return a .user",function(){
|
||||||
|
testGit.user
|
||||||
|
.should.equal("pushrocks");
|
||||||
|
});
|
||||||
|
it("should return a .repo",function(){
|
||||||
|
testGit.repo
|
||||||
|
.should.equal("smartstring");
|
||||||
|
});
|
||||||
|
it("should return a .httpsUrl",function(){
|
||||||
|
testGit.httpsUrl
|
||||||
|
.should.equal("https://github.com/pushrocks/smartstring.git");
|
||||||
|
});
|
||||||
|
it("should return a .sshUrl",function(){
|
||||||
|
testGit.sshUrl
|
||||||
|
.should.equal("git@github.com:pushrocks/smartstring.git");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
8
ts/index.ts
Normal file
8
ts/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import git = require("./smartstring.git");
|
||||||
|
|
||||||
|
let smartstring = {
|
||||||
|
git : git
|
||||||
|
};
|
||||||
|
|
||||||
|
export = smartstring;
|
63
ts/smartstring.git.ts
Normal file
63
ts/smartstring.git.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartstring.plugins");
|
||||||
|
|
||||||
|
/* ---------------------------------------------- *
|
||||||
|
* ------------------ classes ------------------- *
|
||||||
|
* ---------------------------------------------- */
|
||||||
|
class gitRepo {
|
||||||
|
host:string;
|
||||||
|
user:string;
|
||||||
|
repo:string;
|
||||||
|
accessToken:string;
|
||||||
|
sshUrl:string;
|
||||||
|
httpsUrl:string;
|
||||||
|
constructor(stringArg:string,tokenArg?:string){
|
||||||
|
let 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");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------- *
|
||||||
|
* ------------------ helpers ------------------- *
|
||||||
|
* ---------------------------------------------- */
|
||||||
|
let gitRegex = function(stringArg:string){
|
||||||
|
let regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
|
||||||
|
let regexMatches = regexString.exec(stringArg);
|
||||||
|
return regexMatches;
|
||||||
|
};
|
||||||
|
|
||||||
|
let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:string = "", linkTypeArg):string{
|
||||||
|
let 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 ------------------- *
|
||||||
|
* ---------------------------------------------- */
|
||||||
|
let git = function(stringArg:string,tokenArg?:string){
|
||||||
|
let localGitRepo = new gitRepo(stringArg,tokenArg);
|
||||||
|
return localGitRepo;
|
||||||
|
};
|
||||||
|
|
||||||
|
export = git;
|
6
ts/smartstring.plugins.ts
Normal file
6
ts/smartstring.plugins.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
let plugins = {
|
||||||
|
beautylog: require("beautylog")
|
||||||
|
};
|
||||||
|
|
||||||
|
export = plugins;
|
7
ts/typings.json
Normal file
7
ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
||||||
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user