add Base64 handling

This commit is contained in:
Philipp Kunz 2016-11-01 00:22:38 +01:00
parent 68d0124c24
commit 3858127968
27 changed files with 515 additions and 362 deletions

9
.gitignore vendored
View File

@ -1,7 +1,4 @@
.idea/
coverage/ coverage/
docs/ pages/
node_modules public/
ts/**/*.js node_modules/
ts/**/*.js.map
ts/typings/

View File

@ -3,6 +3,8 @@ image: hosttoday/ht-docker-node:npmts
stages: stages:
- test - test
- release - release
- trigger
- pages
testLEGACY: testLEGACY:
stage: test stage: test
@ -10,6 +12,7 @@ testLEGACY:
- npmci test legacy - npmci test legacy
tags: tags:
- docker - docker
allow_failure: true
testLTS: testLTS:
stage: test stage: test
@ -27,10 +30,30 @@ testSTABLE:
release: release:
stage: release stage: release
environment: npmjs-com_registry
script: script:
- npmci publish - npmci publish
only: only:
- tags - tags
tags: tags:
- docker - docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
script:
- npmci command npmpage --host gitlab
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

View File

@ -1,11 +1,21 @@
# smartstring # smartstring
handle strings in smart ways. TypeScript ready. handle strings in smart ways. TypeScript ready.
## Status ## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartstring)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartstring)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartstring)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartstring/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartstring/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstring/commits/master) [![build status](https://gitlab.com/pushrocks/smartstring/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartstring/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartstring.svg)](https://david-dm.org/pushrocks/smartstring) [![Dependency Status](https://david-dm.org/pushrocks/smartstring.svg)](https://david-dm.org/pushrocks/smartstring)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartstring/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm) [![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartstring/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartstring/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartstring) [![bitHound Code](https://www.bithound.io/github/pushrocks/smartstring/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartstring)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage ## Usage
Use TypeScript for intellisense. Use TypeScript for intellisense.
@ -29,10 +39,6 @@ myDomain.level2 // "main"
// level3 , level 4 and so on... // level3 , level 4 and so on...
myDomain.zoneName // "main.tld" myDomain.zoneName // "main.tld"
myDOmain.protocol // "https" myDOmain.protocol // "https"
``` ```
## About the authors: [![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
[![Project Phase](https://mediaserve.lossless.digital/lossless.com/img/createdby_github.svg)](https://lossless.com/)
[![PayPal](https://img.shields.io/badge/Support%20us-PayPal-blue.svg)](https://paypal.me/lossless)

15
dist/index.d.ts vendored
View File

@ -1,8 +1,7 @@
import * as SmartstringDocker from "./smartstring.docker"; import * as docker from './smartstring.docker';
import * as SmartstringTypescript from "./smartstring.typescript"; import * as indent from './smartstring.indent';
import * as SmartstringIndent from "./smartstring.indent"; import * as typescript from './smartstring.typescript';
export { Domain } from "./smartstring.domain"; export { docker, typescript, indent };
export { GitRepo } from "./smartstring.git"; export { Base64 } from './smartstring.base64';
export declare let docker: typeof SmartstringDocker; export { Domain } from './smartstring.domain';
export declare let typescript: typeof SmartstringTypescript; export { GitRepo } from './smartstring.git';
export declare let indent: typeof SmartstringIndent;

16
dist/index.js vendored
View File

@ -1,12 +1,14 @@
"use strict"; "use strict";
const SmartstringDocker = require("./smartstring.docker"); const docker = require("./smartstring.docker");
const SmartstringTypescript = require("./smartstring.typescript"); exports.docker = docker;
const SmartstringIndent = require("./smartstring.indent"); const indent = require("./smartstring.indent");
exports.indent = indent;
const typescript = require("./smartstring.typescript");
exports.typescript = typescript;
var smartstring_base64_1 = require("./smartstring.base64");
exports.Base64 = smartstring_base64_1.Base64;
var smartstring_domain_1 = require("./smartstring.domain"); var smartstring_domain_1 = require("./smartstring.domain");
exports.Domain = smartstring_domain_1.Domain; exports.Domain = smartstring_domain_1.Domain;
var smartstring_git_1 = require("./smartstring.git"); var smartstring_git_1 = require("./smartstring.git");
exports.GitRepo = smartstring_git_1.GitRepo; exports.GitRepo = smartstring_git_1.GitRepo;
exports.docker = SmartstringDocker; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQTZDO0FBQXBDLHNDQUFBLE1BQU0sQ0FBQTtBQUNmLDJEQUE2QztBQUFwQyxzQ0FBQSxNQUFNLENBQUE7QUFDZixxREFBMkM7QUFBbEMsb0NBQUEsT0FBTyxDQUFBIn0=
exports.typescript = SmartstringTypescript;
exports.indent = SmartstringIndent;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsTUFBWSxpQkFBaUIsV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQzFELE1BQVkscUJBQXFCLFdBQU0sMEJBQTBCLENBQUMsQ0FBQTtBQUNsRSxNQUFZLGlCQUFpQixXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFFMUQsbUNBQXFCLHNCQUFzQixDQUFDO0FBQXBDLDZDQUFvQztBQUM1QyxnQ0FBc0IsbUJBQW1CLENBQUM7QUFBbEMsNENBQWtDO0FBQy9CLGNBQU0sR0FBRyxpQkFBaUIsQ0FBQztBQUMzQixrQkFBVSxHQUFHLHFCQUFxQixDQUFDO0FBQ25DLGNBQU0sR0FBRyxpQkFBaUIsQ0FBQyJ9

23
dist/smartstring.base64.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
/**
* the type for base 64
*/
export declare type TBase64Input = 'string' | 'base64' | 'base64uri';
/**
* handle base64 strings
*/
export declare class Base64 {
private refString;
constructor(inputStringArg: any, typeArg: TBase64Input);
/**
* the simple string (unencoded)
*/
readonly simpleString: string;
/**
* the base64 encoded version of the original string
*/
readonly base64String: any;
/**
* the base64uri encoded version of the original string
*/
readonly base64StringUri: any;
}

39
dist/smartstring.base64.js vendored Normal file
View File

@ -0,0 +1,39 @@
"use strict";
const plugins = require("./smartstring.plugins");
/**
* handle base64 strings
*/
class Base64 {
constructor(inputStringArg, typeArg) {
switch (typeArg) {
case 'string':
this.refString = inputStringArg;
break;
case 'base64':
this.refString = plugins.jsBase64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = plugins.jsBase64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return plugins.jsBase64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return plugins.jsBase64.encodeURI(this.refString);
}
}
exports.Base64 = Base64;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUFJLENBQUMsU0FBUyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLGNBQWMsQ0FBQyxDQUFBO2dCQUN4RCxLQUFLLENBQUE7WUFDVCxLQUFLLFdBQVc7Z0JBQ1osSUFBSSxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxjQUFjLENBQUMsQ0FBQTtRQUNoRSxDQUFDO0lBQ0wsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSSxZQUFZO1FBQ1osTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUE7SUFDekIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSSxZQUFZO1FBQ1osTUFBTSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNsRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLGVBQWU7UUFDZixNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3JELENBQUM7Q0FDSjtBQW5DRCx3QkFtQ0MifQ==

View File

@ -7,7 +7,7 @@
exports.makeEnvObject = function (envArrayArg) { exports.makeEnvObject = function (envArrayArg) {
let returnObject = {}; let returnObject = {};
let regexString = /(.*)=(.*)/; let regexString = /(.*)=(.*)/;
if (typeof envArrayArg !== "undefined") { if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) { for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[envKey]); let regexMatches = regexString.exec(envArrayArg[envKey]);
returnObject[regexMatches[1]] = regexMatches[2]; returnObject[regexMatches[1]] = regexMatches[2];
@ -16,4 +16,4 @@ exports.makeEnvObject = function (envArrayArg) {
} }
return returnObject; return returnObject;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EscUJBQWEsR0FBRyxVQUFVLFdBQXFCO0lBQ3RELElBQUksWUFBWSxHQUFHLEVBQUUsQ0FBQztJQUN0QixJQUFJLFdBQVcsR0FBRyxXQUFXLENBQUM7SUFDOUIsRUFBRSxDQUFDLENBQUMsT0FBTyxXQUFXLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNyQyxHQUFHLENBQUMsQ0FBQyxJQUFJLE1BQU0sSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQzdCLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7WUFDekQsWUFBWSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNwRCxDQUFDO1FBQUEsQ0FBQztJQUNOLENBQUM7SUFDRCxNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsVUFBVSxXQUFxQjtJQUN0RCxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUE7SUFDckIsSUFBSSxXQUFXLEdBQUcsV0FBVyxDQUFBO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sV0FBVyxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDckMsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksV0FBVyxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBO1lBQ3hELFlBQVksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkQsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -2,26 +2,26 @@
class Domain { class Domain {
constructor(domainStringArg) { constructor(domainStringArg) {
let regexMatches = domainRegex(domainStringArg); let regexMatches = domainRegex(domainStringArg);
this.fullName = ""; this.fullName = '';
for (let i = 1; i <= 5; i++) { for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) { if (regexMatches[i - 1]) {
let localMatch = regexMatches[i - 1]; let localMatch = regexMatches[i - 1];
this["level" + i.toString()] = localMatch; this['level' + i.toString()] = localMatch;
if (this.fullName == "") { if (this.fullName === '') {
this.fullName = localMatch; this.fullName = localMatch;
} }
else { else {
this.fullName = localMatch + "." + this.fullName; this.fullName = localMatch + '.' + this.fullName;
} }
} }
else { else {
this["level" + i.toString()] = undefined; this['level' + i.toString()] = undefined;
} }
; ;
} }
; ;
this.protocol = protocolRegex(domainStringArg); this.protocol = protocolRegex(domainStringArg);
this.zoneName = this.level2 + "." + this.level1; this.zoneName = this.level2 + '.' + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
this.domainName = this.level2; this.domainName = this.level2;
@ -35,7 +35,7 @@ let domainRegex = function (stringArg) {
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order) regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
let regexMatchesFiltered = regexMatches.filter(function (stringArg) { let regexMatchesFiltered = regexMatches.filter(function (stringArg) {
return (stringArg != ""); return (stringArg !== '');
}); });
return regexMatchesFiltered; return regexMatchesFiltered;
}; };
@ -49,4 +49,4 @@ let protocolRegex = function (stringArg) {
return undefined; return undefined;
} }
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9tYWluLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTtJQWFJLFlBQVksZUFBc0I7UUFDOUIs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tBQUssRUFBRSxDQUFDLENBQUE7SUFDNUIsQ0FBQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsb0JBQW9CLENBQUE7QUFDL0IsQ0FBQyxDQUFDO0FBRUYsSUFBSSxhQUFhLEdBQUcsVUFBUyxTQUFnQjtJQUN6QyxJQUFJLFdBQVcsR0FBRyxzQkFBc0IsQ0FBQTtJQUN4QyxJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQzlDLEVBQUUsQ0FBQSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7UUFDZCxNQUFNLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzFCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQSJ9

View File

@ -1,5 +1,4 @@
"use strict"; "use strict";
const plugins = require("./smartstring.plugins");
/* ---------------------------------------------- * /* ---------------------------------------------- *
* ------------------ classes ------------------- * * ------------------ classes ------------------- *
* ---------------------------------------------- */ * ---------------------------------------------- */
@ -10,10 +9,9 @@ class GitRepo {
this.user = regexMatches[2]; this.user = regexMatches[2];
this.repo = regexMatches[3]; this.repo = regexMatches[3];
this.accessToken = tokenArg; this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "ssh"); this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "https"); this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
} }
;
} }
exports.GitRepo = GitRepo; exports.GitRepo = GitRepo;
/* ---------------------------------------------- * /* ---------------------------------------------- *
@ -24,24 +22,24 @@ let gitRegex = function (stringArg) {
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg);
return regexMatches; return regexMatches;
}; };
let gitLink = function (hostArg, userArg, repoArg, tokenArg = "", linkTypeArg) { let gitLink = function (hostArg, userArg, repoArg, tokenArg = '', linkTypeArg) {
let returnString; let returnString;
if (tokenArg !== "") { if (tokenArg !== '') {
tokenArg = tokenArg + "@"; tokenArg = tokenArg + '@';
} }
switch (linkTypeArg) { switch (linkTypeArg) {
case "https": case 'https':
returnString = "https://" + returnString = 'https://' +
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git"; tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break; break;
case "ssh": case 'ssh':
returnString = "git@" + returnString = 'git@' +
hostArg + ":" + userArg + "/" + repoArg + ".git"; hostArg + ':' + userArg + '/' + repoArg + '.git';
break; break;
default: default:
plugins.beautylog.error("Link Type " + linkTypeArg + " not known"); console.error('Link Type ' + linkTypeArg + ' not known');
break; break;
} }
return returnString; return returnString;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZ2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZ2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSx1QkFBdUIsQ0FBQyxDQUFBO0FBRWpEOztvREFFb0Q7QUFDcEQ7SUFPSSxZQUFZLFNBQWdCLEVBQUMsUUFBZ0I7UUFDekMsSUFBSSxZQUFZLEdBQUcsUUFBUSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQU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FPLEdBQUcsTUFBTSxDQUFBO1lBQy9ELEtBQUssQ0FBQTtRQUNULEtBQUssS0FBSztZQUNOLFlBQVksR0FBRyxNQUFNO2dCQUNqQixPQUFPLEdBQUcsR0FBRyxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLE1BQU0sQ0FBQztZQUNyRCxLQUFLLENBQUE7UUFDVDtZQUNJLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxHQUFHLFdBQVcsR0FBRyxZQUFZLENBQUMsQ0FBQTtZQUN4RCxLQUFLLENBQUE7SUFDYixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -1,14 +1,13 @@
"use strict"; "use strict";
let splitString = (stringArg) => { let splitString = (stringArg) => {
let resultArray = stringArg.split("\n"); let resultArray = stringArg.split('\n');
return cleanStringArray(resultArray); return cleanStringArray(resultArray);
}; };
let joinString = (stringArrayArg) => { let joinString = (stringArrayArg) => {
let resultString = ""; let resultString = '';
for (let line of stringArrayArg) { for (let line of stringArrayArg) {
resultString = resultString + line + "\n"; resultString = resultString + line + '\n';
} }
;
return resultString; return resultString;
}; };
let cleanStringArray = (stringArrayArg) => { let cleanStringArray = (stringArrayArg) => {
@ -45,11 +44,10 @@ exports.normalize = (stringArg) => {
let emptyLineRegex = /^(\s*)$/; let emptyLineRegex = /^(\s*)$/;
for (let stringItem of splitStringArray) { for (let stringItem of splitStringArray) {
let offsetString = deIndentRegex.exec(stringItem)[1]; let offsetString = deIndentRegex.exec(stringItem)[1];
if ((typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset) if ((typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
&& !emptyLineRegex.test(stringItem)) { && !emptyLineRegex.test(stringItem)) {
minCommonLeftOffset = offsetString.length; minCommonLeftOffset = offsetString.length;
} }
;
} }
; ;
let resultSplitStringArray = []; let resultSplitStringArray = [];
@ -60,4 +58,4 @@ exports.normalize = (stringArg) => {
resultString = joinString(resultSplitStringArray); resultString = joinString(resultSplitStringArray);
return resultString; return resultString;
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxDQUFDLFNBQWdCO0lBQy9CLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDeEMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ3pDLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLENBQUMsY0FBdUI7SUFDckMsSUFBSSxZQUFZLEdBQVUsRUFBRSxDQUFDO0lBQzdCLEdBQUcsQ0FBQSxDQUFDLElBQUksSUFBSSxJQUFJLGNBQWMsQ0FBQyxDQUFBLENBQUM7UUFDNUIsWUFBWSxHQUFHLFlBQVksR0FBRyxJQUFJLEdBQUcsSUFBSSxDQUFDO0lBQzlDLENBQUM7SUFBQSxDQUFDO0lBQ0YsTUFBTSxDQUFDLFlBQVksQ0FBQztBQUN4QixDQUFDLENBQUM7QUFFRixJQUFJLGdCQUFnQixHQUFHLENBQUMsY0FBdUI7SUFDM0MsSUFBSSxTQUFTLEdBQUcsU0FBUyxDQUFDO0lBQzFCLEVBQUUsQ0FBQSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ2xDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBQ0QsRUFBRSxDQUFBLENBQUMsU0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SxDQUFDLE1BQU0sR0FBRyxtQkFBbUIsQ0FBQztlQUN0RixDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUN0QyxDQUFDLENBQUMsQ0FBQztZQUNDLG1CQUFtQixHQUFHLFlBQVksQ0FBQyxNQUFNLENBQUE7UUFDN0MsQ0FBQztJQUNMLENBQUM7SUFBQSxDQUFDO0lBQ0YsSUFBSSxzQkFBc0IsR0FBRyxFQUFFLENBQUE7SUFDL0IsR0FBRyxDQUFDLENBQUMsSUFBSSxVQUFVLElBQUksZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1FBQ3RDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQTtJQUN2RSxDQUFDO0lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUNqRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9

View File

@ -1,2 +1,2 @@
import "typings-global"; import 'typings-global';
export import beautylog = require("beautylog"); export declare let jsBase64: any;

View File

@ -1,4 +1,4 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
exports.beautylog = require("beautylog"); exports.jsBase64 = require('js-base64').Base64;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUNULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUNaLFFBQUEsUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUEifQ==

View File

@ -1,3 +1,3 @@
"use strict"; "use strict";
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/; exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==

View File

@ -22,12 +22,14 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartstring#readme", "homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": { "devDependencies": {
"@types/should": "^8.1.30",
"beautylog": "^6.0.0",
"npmts-g": "^5.2.8", "npmts-g": "^5.2.8",
"should": "^10.0.0", "should": "^11.1.1",
"typings-test": "^1.0.1" "typings-test": "^1.0.3"
}, },
"dependencies": { "dependencies": {
"beautylog": "^5.0.20", "js-base64": "^2.1.9",
"typings-global": "^1.0.6" "typings-global": "^1.0.14"
} }
} }

2
test/test.d.ts vendored
View File

@ -1 +1 @@
import "typings-test"; import 'typings-test';

File diff suppressed because one or more lines are too long

View File

@ -1,74 +1,81 @@
import "typings-test" import 'typings-test'
import * as smartstring from "../dist/index"; import * as smartstring from '../dist/index'
let should = require("should"); import * as should from 'should'
describe("smartstring",function(){ describe('smartstring',function(){
describe(".Domain class",function(){ describe('.Base64 class', function(){
let testDomain:smartstring.Domain; let testBase64: smartstring.Base64
let testDomain2:smartstring.Domain; it('should create a valid instance of Base64', function(){
it("should create a new Domain object",function(){ testBase64 = new smartstring.Base64('somestring', 'string')
testDomain = new smartstring.Domain("https://level3D.level2D.level1D"); should(testBase64).be.instanceOf(smartstring.Base64)
testDomain.should.be.instanceof(smartstring.Domain);
console.log(testDomain);
});
it("should have a .topLevel",function(){
testDomain.topLevel.should.equal("level1D");
});
it("should have a .level2",function(){
testDomain.level2.should.equal("level2D");
});
it("should have a .level3",function(){
testDomain.level3.should.equal("level3D");
});
it("should have the correct dns zone name",function(){
testDomain.zoneName.should.equal("level2D.level1D");
}) })
it ("should have the correct protocol",function(){ it('should read output a file as base64 and base64uri', function(){
testDomain.protocol.should.equal("https"); should(testBase64.base64String).not.equal(testBase64.base64StringUri)
let testBase64_2 = new smartstring.Base64(testBase64.base64StringUri, 'base64uri')
should(testBase64_2.simpleString).equal(testBase64.simpleString)
}) })
it("testDomain2 should be a basic domain",function(){
testDomain2 = new smartstring.Domain("bleu.de");
console.log(testDomain2);
});
}) })
describe(".Git class",function(){ describe('.Domain class',function(){
let testGit:smartstring.GitRepo; let testDomain:smartstring.Domain
it("should create a new Git class GitRepo",function(){ let testDomain2:smartstring.Domain
testGit = new smartstring.GitRepo("git+https://github.com/pushrocks/smartstring.git"); it('should create a new Domain object',function(){
testGit.should.be.instanceof(smartstring.GitRepo); testDomain = new smartstring.Domain('https://level3D.level2D.level1D')
should(testDomain).be.instanceof(smartstring.Domain)
console.log(testDomain)
})
it('should have a .topLevel',function(){
should(testDomain.topLevel).equal('level1D')
})
it('should have a .level2',function(){
should(testDomain.level2).equal('level2D')
})
it('should have a .level3',function(){
should(testDomain.level3).equal('level3D')
})
it('should have the correct dns zone name',function(){
should(testDomain.zoneName).equal('level2D.level1D')
})
it ('should have the correct protocol',function(){
should(testDomain.protocol).equal('https')
})
it('testDomain2 should be a basic domain',function(){
testDomain2 = new smartstring.Domain('bleu.de')
console.log(testDomain2)
}) })
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");
});
}) })
describe(".docker",function(){ describe('.Git class',function(){
describe(".makeEnvObject",function(){ let testGit:smartstring.GitRepo
it("should create a Env Object",function(){ it('should create a new Git class GitRepo',function(){
let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"]; testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git')
let envObject:any = smartstring.docker.makeEnvObject(envStringArray); should(testGit).be.instanceof(smartstring.GitRepo)
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld"); })
envObject.DEFAULT_HOST.should.equal("some.domain.com"); it('should return a .host',function(){
should(testGit.host).equal('github.com')
})
it('should return a .user',function(){
should(testGit.user).equal('pushrocks')
})
it('should return a .repo',function(){
should(testGit.repo).equal('smartstring')
})
it('should return a .httpsUrl',function(){
should(testGit.httpsUrl).equal('https://github.com/pushrocks/smartstring.git')
})
it('should return a .sshUrl',function(){
should(testGit.sshUrl).equal('git@github.com:pushrocks/smartstring.git')
})
})
describe('.docker',function(){
describe('.makeEnvObject',function(){
it('should create a Env Object',function(){
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld','DEFAULT_HOST=some.domain.com']
let envObject:any = smartstring.docker.makeEnvObject(envStringArray)
envObject.VIRTUAL_HOST.should.equal('sub.domain.tld')
envObject.DEFAULT_HOST.should.equal('some.domain.com')
}) })
}) })
}); })
describe(".indent",function(){ describe('.indent',function(){
let testString = ` let testString = `
base base
should be indented should be indented
@ -76,33 +83,33 @@ describe("smartstring",function(){
base base
indented indented
`; `
describe(".normalize()",function(){ describe('.normalize()',function(){
it("should normalize a string",function(){ it('should normalize a string',function(){
testString = smartstring.indent.normalize(testString); testString = smartstring.indent.normalize(testString)
console.log(testString); console.log(testString)
let zoneNameArg = "test1"; let zoneNameArg = 'test1'
let destinationIpArg = "111"; let destinationIpArg = '111'
});
});
describe(".indentWithPrefix",function(){
it("should indent",function(){
testString = smartstring.indent.indentWithPrefix(testString,">> ");
console.log(testString);
}) })
}) })
});
describe(".typescript",function(){ describe('.indentWithPrefix',function(){
describe(".referenceRegex",function(){ it('should indent',function(){
it("should match reference paths",function(){ testString = smartstring.indent.indentWithPrefix(testString,'>> ')
smartstring.typescript.regexReferencePath.test("/// <reference path=\"\" />") console.log(testString)
.should.be.true();
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
.should.be.true();
smartstring.typescript.regexReferencePath.test("/// <referencepath=\"\" />")
.should.be.false();
}) })
}) })
}) })
}); describe('.typescript',function(){
describe('.referenceRegex',function(){
it('should match reference paths',function(){
smartstring.typescript.regexReferencePath.test('/// <reference path=\"\" />')
.should.be.true()
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
.should.be.true()
smartstring.typescript.regexReferencePath.test('/// <referencepath=\"\" />')
.should.be.false()
})
})
})
})

View File

@ -1,10 +1,13 @@
import * as plugins from "./smartstring.plugins"; import * as docker from './smartstring.docker'
import * as SmartstringDocker from "./smartstring.docker"; import * as indent from './smartstring.indent'
import * as SmartstringTypescript from "./smartstring.typescript"; import * as typescript from './smartstring.typescript'
import * as SmartstringIndent from "./smartstring.indent";
export {Domain} from "./smartstring.domain"; export {
export {GitRepo} from "./smartstring.git"; docker,
export let docker = SmartstringDocker; typescript,
export let typescript = SmartstringTypescript; indent
export let indent = SmartstringIndent; }
export { Base64 } from './smartstring.base64'
export { Domain } from './smartstring.domain'
export { GitRepo } from './smartstring.git'

46
ts/smartstring.base64.ts Normal file
View File

@ -0,0 +1,46 @@
import * as plugins from './smartstring.plugins'
/**
* the type for base 64
*/
export type TBase64Input = 'string' | 'base64' | 'base64uri'
/**
* handle base64 strings
*/
export class Base64 {
private refString: string
constructor(inputStringArg, typeArg: TBase64Input) {
switch (typeArg) {
case 'string': // easiest case
this.refString = inputStringArg
break
case 'base64':
this.refString = plugins.jsBase64.decode(inputStringArg)
break
case 'base64uri':
this.refString = plugins.jsBase64.decode(inputStringArg)
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return plugins.jsBase64.encode(this.refString)
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return plugins.jsBase64.encodeURI(this.refString)
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from "./smartstring.plugins"; import * as plugins from './smartstring.plugins'
/** /**
* converts an erray of env strings from docker remote api to an usable object. * converts an erray of env strings from docker remote api to an usable object.
@ -6,13 +6,13 @@ import * as plugins from "./smartstring.plugins";
* @returns {} * @returns {}
*/ */
export let makeEnvObject = function (envArrayArg: string[]) { export let makeEnvObject = function (envArrayArg: string[]) {
let returnObject = {}; let returnObject = {}
let regexString = /(.*)=(.*)/; let regexString = /(.*)=(.*)/
if (typeof envArrayArg !== "undefined") { if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) { for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[envKey]); let regexMatches = regexString.exec(envArrayArg[envKey])
returnObject[regexMatches[1]] = regexMatches[2]; returnObject[regexMatches[1]] = regexMatches[2]
}; };
} }
return returnObject; return returnObject
}; }

View File

@ -1,62 +1,62 @@
import * as plugins from "./smartstring.plugins"; import * as plugins from './smartstring.plugins';
export class Domain { export class Domain {
fullName:string; fullName: string
level1:string; level1: string
level2:string; level2: string
level3:string; level3: string
level4:string; level4: string
level5:string; level5: string
protocol:string; protocol: string
zoneName:string; zoneName: string
//aliases // aliases
topLevel:string; topLevel: string
domainName; domainName
subDomain; subDomain
constructor(domainStringArg:string){ constructor(domainStringArg:string){
let regexMatches = domainRegex(domainStringArg); let regexMatches = domainRegex(domainStringArg);
this.fullName = ""; this.fullName = ''
for(let i = 1; i <= 5; i++){ for (let i = 1; i <= 5; i++) {
if(regexMatches[i - 1]) { if (regexMatches[i - 1]) {
let localMatch = regexMatches[i - 1] let localMatch = regexMatches[i - 1]
this["level" + i.toString()] = localMatch; this['level' + i.toString()] = localMatch
if (this.fullName == ""){ if (this.fullName === ''){
this.fullName = localMatch; this.fullName = localMatch
} else { } else {
this.fullName = localMatch + "." + this.fullName; this.fullName = localMatch + '.' + this.fullName
} }
} else { } else {
this["level" + i.toString()] = undefined; this['level' + i.toString()] = undefined
}; };
}; };
this.protocol = protocolRegex(domainStringArg); this.protocol = protocolRegex(domainStringArg)
this.zoneName = this.level2 + "." + this.level1; this.zoneName = this.level2 + '.' + this.level1
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1
this.domainName = this.level2; this.domainName = this.level2
this.subDomain = this.level3; this.subDomain = this.level3
} }
} }
let domainRegex = function(stringArg:string){ let domainRegex = function(stringArg:string){
let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/; let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg)
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order) regexMatches.reverse() //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements regexMatches.pop() // pop the last element, which is, since we reversed the Array, the full String of matched elements
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){ let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg != ""); return(stringArg !== '')
}); });
return regexMatchesFiltered; return regexMatchesFiltered
}; };
let protocolRegex = function(stringArg:string){ let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//; let regexString = /^([a-zA-Z0-9]*):\/\//
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg)
if(regexMatches){ if(regexMatches) {
return regexMatches[1]; return regexMatches[1]
} else { } else {
return undefined; return undefined
} }
} }

View File

@ -1,52 +1,52 @@
import * as plugins from "./smartstring.plugins"; import * as plugins from './smartstring.plugins'
/* ---------------------------------------------- * /* ---------------------------------------------- *
* ------------------ classes ------------------- * * ------------------ classes ------------------- *
* ---------------------------------------------- */ * ---------------------------------------------- */
export class GitRepo { export class GitRepo {
host:string; host: string
user:string; user: string
repo:string; repo: string
accessToken:string; accessToken: string
sshUrl:string; sshUrl: string
httpsUrl:string; httpsUrl: string
constructor(stringArg:string,tokenArg?:string){ constructor(stringArg: string,tokenArg?: string) {
let regexMatches = gitRegex(stringArg); let regexMatches = gitRegex(stringArg)
this.host = regexMatches[1]; this.host = regexMatches[1]
this.user = regexMatches[2]; this.user = regexMatches[2]
this.repo = regexMatches[3]; this.repo = regexMatches[3]
this.accessToken = tokenArg; this.accessToken = tokenArg
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "ssh"); this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'ssh')
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "https"); this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'https')
}; }
} }
/* ---------------------------------------------- * /* ---------------------------------------------- *
* ------------------ helpers ------------------- * * ------------------ helpers ------------------- *
* ---------------------------------------------- */ * ---------------------------------------------- */
let gitRegex = function(stringArg:string){ let gitRegex = function(stringArg:string){
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/; let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg)
return regexMatches; return regexMatches
}; }
let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:string = "", linkTypeArg):string{ let gitLink = function(hostArg: string, userArg: string, repoArg: string, tokenArg: string = '', linkTypeArg): string{
let returnString; let returnString
if (tokenArg !== ""){ if (tokenArg !== '') {
tokenArg = tokenArg + "@" tokenArg = tokenArg + '@'
} }
switch (linkTypeArg) { switch (linkTypeArg) {
case "https": case 'https':
returnString = "https://" + returnString = 'https://' +
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git"; tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git'
break; break
case "ssh": case 'ssh':
returnString = "git@" + returnString = 'git@' +
hostArg + ":" + userArg + "/" + repoArg + ".git"; hostArg + ':' + userArg + '/' + repoArg + '.git';
break; break
default: default:
plugins.beautylog.error("Link Type " + linkTypeArg + " not known"); console.error('Link Type ' + linkTypeArg + ' not known')
break; break
} }
return returnString; return returnString
}; }

View File

@ -1,64 +1,64 @@
import * as plugins from "./smartstring.plugins"; import * as plugins from './smartstring.plugins'
let splitString = (stringArg:string):string[] => { let splitString = (stringArg: string): string[] => {
let resultArray = stringArg.split("\n"); let resultArray = stringArg.split('\n')
return cleanStringArray(resultArray); return cleanStringArray(resultArray)
}; };
let joinString = (stringArrayArg:string[]):string => { let joinString = (stringArrayArg: string[]): string => {
let resultString:string = ""; let resultString: string = ''
for(let line of stringArrayArg){ for (let line of stringArrayArg){
resultString = resultString + line + "\n"; resultString = resultString + line + '\n'
};
return resultString;
};
let cleanStringArray = (stringArrayArg:string[]):string[] => {
let testRegex = /^[\s]*$/;
if(testRegex.test(stringArrayArg[0])){
stringArrayArg.shift();
} }
if(testRegex.test(stringArrayArg[stringArrayArg.length - 1])){ return resultString
stringArrayArg.pop();
};
return stringArrayArg;
} }
export let indent = (stringArg:string,spaceAmount:number):string => { let cleanStringArray = (stringArrayArg: string[]): string[] => {
let resultString:string; let testRegex = /^[\s]*$/
return resultString; if (testRegex.test(stringArrayArg[0])) {
}; stringArrayArg.shift()
}
export let indentWithPrefix = (stringArg:string,prefixArg:string):string => { if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
let resultString:string; stringArrayArg.pop()
let stringArray = splitString(stringArg);
let resultArray:string[] = [];
for(let stringItem of stringArray){
resultArray.push(prefixArg + stringItem);
}; };
resultString = joinString(resultArray); return stringArrayArg
return resultString; }
};
export let normalize = (stringArg:string):string => { export let indent = (stringArg: string, spaceAmount: number): string => {
let resultString:string; let resultString: string
let splitStringArray:string[] = splitString(stringArg); return resultString
let minCommonLeftOffset:number; }
let deIndentRegex = /^(\s*)/;
export let indentWithPrefix = (stringArg: string,prefixArg: string): string => {
let resultString: string
let stringArray = splitString(stringArg)
let resultArray: string[] = []
for (let stringItem of stringArray){
resultArray.push(prefixArg + stringItem)
};
resultString = joinString(resultArray)
return resultString
}
export let normalize = (stringArg: string): string => {
let resultString: string
let splitStringArray: string[] = splitString(stringArg)
let minCommonLeftOffset: number
let deIndentRegex = /^(\s*)/
let emptyLineRegex = /^(\s*)$/ let emptyLineRegex = /^(\s*)$/
for(let stringItem of splitStringArray){ for (let stringItem of splitStringArray){
let offsetString = deIndentRegex.exec(stringItem)[1]; let offsetString = deIndentRegex.exec(stringItem)[1]
if ( if (
(typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset) (typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
&& !emptyLineRegex.test(stringItem) && !emptyLineRegex.test(stringItem)
){ ) {
minCommonLeftOffset = offsetString.length; minCommonLeftOffset = offsetString.length
}; }
}; };
let resultSplitStringArray = []; let resultSplitStringArray = []
for(let stringItem of splitStringArray){ for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset)); resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset))
}; };
resultString = joinString(resultSplitStringArray); resultString = joinString(resultSplitStringArray)
return resultString; return resultString
} }

View File

@ -1,2 +1,2 @@
import "typings-global" import 'typings-global'
export import beautylog = require("beautylog"); export let jsBase64 = require('js-base64').Base64

View File

@ -1,3 +1,3 @@
import * as plugins from "./smartstring.plugins"; import * as plugins from './smartstring.plugins'
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/ export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}