Compare commits

...

27 Commits

Author SHA1 Message Date
bb7caa36ea 2.0.20 2016-11-01 19:00:35 +01:00
a3a51bf0ca small export fix 2016-11-01 19:00:32 +01:00
1684eae1e8 expose base64 functions seperate from class 2016-11-01 18:59:43 +01:00
39ce541532 2.0.19 2016-11-01 00:37:47 +01:00
c2a4f05b33 2.0.18 2016-11-01 00:22:52 +01:00
3858127968 add Base64 handling 2016-11-01 00:22:38 +01:00
68d0124c24 2.0.17 2016-08-03 15:42:39 +02:00
16f41a7d63 Merge branch 'master' of gitlab.com:pushrocks/smartstring 2016-08-03 15:42:24 +02:00
d13dfc9e76 2.0.16 2016-08-03 15:41:54 +02:00
942f6b37cf fix docker env null problem 2016-08-03 15:41:36 +02:00
211c7c3308 Update .gitlab-ci.yml 2016-07-22 22:34:51 +00:00
a55d6d2221 Update README.md 2016-07-21 22:17:56 +00:00
98ca73d0c7 2.0.15 2016-07-17 17:30:35 +02:00
ffedc7f601 switched to ES6 2016-07-17 17:30:26 +02:00
8344fdf7b1 2.0.14 2016-07-08 01:49:41 +02:00
543dc98961 ignore empty lines for indent.normalize() 2016-07-08 01:49:32 +02:00
9c60105685 2.0.13 2016-07-08 00:57:27 +02:00
bdccf2c3a1 now has working indent module 2016-07-08 00:57:11 +02:00
34d6df0923 write some tests 2016-07-07 23:35:15 +02:00
3d3b07b7cb implement deindent 2016-07-07 19:53:14 +02:00
00004f70d6 2.0.12 2016-07-06 10:06:44 +02:00
2d263244c7 recompile 2016-07-06 10:06:39 +02:00
8cb1405d99 2.0.11 2016-07-06 10:06:15 +02:00
d357d6e52d merged 2016-07-06 10:06:10 +02:00
c124f90a91 prepare indent functionality 2016-07-06 10:04:25 +02:00
4bcf9f941e 2.0.10 2016-06-22 12:55:32 +02:00
afb204325b fix Domain Regex to include - and _ 2016-06-22 12:55:29 +02:00
34 changed files with 700 additions and 351 deletions

9
.gitignore vendored
View File

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

View File

@ -3,6 +3,8 @@ image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- trigger
- pages
testLEGACY:
stage: test
@ -10,6 +12,7 @@ testLEGACY:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
@ -32,4 +35,25 @@ release:
only:
- 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,12 +1,21 @@
# smartstring
handle strings in smart ways. TypeScript ready.
## Status
[![Build Status](https://travis-ci.org/pushrocks/smartstring.svg?branch=master)](https://travis-ci.org/pushrocks/smartstring)
[![Build status](https://ci.appveyor.com/api/projects/status/x4oe2xxwwcbxmk1h/branch/master?svg=true)](https://ci.appveyor.com/project/philkunz/smartstring/branch/master)
## 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)
[![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)
[![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)
[![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
Use TypeScript for intellisense.
@ -30,10 +39,6 @@ myDomain.level2 // "main"
// level3 , level 4 and so on...
myDomain.zoneName // "main.tld"
myDOmain.protocol // "https"
```
## About the authors:
[![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)
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

View File

@ -1,10 +0,0 @@
environment:
nodejs_version: "4"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- node --version
- npm --version
- npm test
build: off

14
dist/index.d.ts vendored
View File

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

17
dist/index.js vendored
View File

@ -1,12 +1,15 @@
"use strict";
require("typings-global");
var SmartstringDocker = require("./smartstring.docker");
var SmartstringTypescript = require("./smartstring.typescript");
const docker = require("./smartstring.docker");
exports.docker = docker;
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;
exports.base64 = smartstring_base64_1.base64;
var smartstring_domain_1 = require("./smartstring.domain");
exports.Domain = smartstring_domain_1.Domain;
var smartstring_git_1 = require("./smartstring.git");
exports.GitRepo = smartstring_git_1.GitRepo;
exports.docker = SmartstringDocker;
exports.typescript = SmartstringTypescript;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxpQkFBaUIsV0FBVyxzQkFBc0IsQ0FBQyxDQUFDO0FBQzNELElBQU8scUJBQXFCLFdBQVcsMEJBQTBCLENBQUMsQ0FBQztBQUVuRSxtQ0FBcUIsc0JBQXNCLENBQUM7QUFBcEMsNkNBQW9DO0FBQzVDLGdDQUFzQixtQkFBbUIsQ0FBQztBQUFsQyw0Q0FBa0M7QUFDL0IsY0FBTSxHQUFHLGlCQUFpQixDQUFDO0FBQzNCLGtCQUFVLEdBQUcscUJBQXFCLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXG5pbXBvcnQgU21hcnRzdHJpbmdEb2NrZXIgPSByZXF1aXJlKFwiLi9zbWFydHN0cmluZy5kb2NrZXJcIik7XG5pbXBvcnQgU21hcnRzdHJpbmdUeXBlc2NyaXB0ID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcudHlwZXNjcmlwdFwiKTtcblxuZXhwb3J0IHtEb21haW59IGZyb20gXCIuL3NtYXJ0c3RyaW5nLmRvbWFpblwiO1xuZXhwb3J0IHtHaXRSZXBvfSBmcm9tIFwiLi9zbWFydHN0cmluZy5naXRcIjtcbmV4cG9ydCBsZXQgZG9ja2VyID0gU21hcnRzdHJpbmdEb2NrZXI7XG5leHBvcnQgbGV0IHR5cGVzY3JpcHQgPSBTbWFydHN0cmluZ1R5cGVzY3JpcHQ7Il19
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQXFEO0FBQTVDLHNDQUFBLE1BQU0sQ0FBQTtBQUFFLHNDQUFBLE1BQU0sQ0FBQTtBQUN2QiwyREFBNkM7QUFBcEMsc0NBQUEsTUFBTSxDQUFBO0FBQ2YscURBQTJDO0FBQWxDLG9DQUFBLE9BQU8sQ0FBQSJ9

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

@ -0,0 +1,28 @@
/**
* 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;
}
export declare let base64: {
encode: (stringArg: string) => any;
encodeUri: (stringArg: string) => any;
decode: (stringArg: string) => any;
};

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

@ -0,0 +1,59 @@
"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 = exports.base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = exports.base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return exports.base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return exports.base64.encodeUri(this.refString);
}
}
exports.Base64 = Base64;
exports.base64 = {
/**
* encodes the string
*/
encode: (stringArg) => {
return plugins.jsBase64.encode(stringArg);
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg) => {
return plugins.jsBase64.encodeURI(stringArg);
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg) => {
return plugins.jsBase64.decode(stringArg);
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUFJLENBQUMsU0FBUyxHQUFHLGNBQU0sQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUE7Z0JBQzlDLEtBQUssQ0FBQTtZQUNULEtBQUssV0FBVztnQkFDWixJQUFJLENBQUMsU0FBUyxHQUFHLGNBQU0sQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUE7UUFDdEQsQ0FBQztJQUNMLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksWUFBWTtRQUNaLE1BQU0sQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFBO0lBQ3pCLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksWUFBWTtRQUNaLE1BQU0sQ0FBQyxjQUFNLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUN4QyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLGVBQWU7UUFDZixNQUFNLENBQUMsY0FBTSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDM0MsQ0FBQztDQUNKO0FBbkNELHdCQW1DQztBQUVVLFFBQUEsTUFBTSxHQUFHO0lBQ2hCOztPQUVHO0lBQ0gsTUFBTSxFQUFFLENBQUMsU0FBaUI7UUFDdEIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQzdDLENBQUM7SUFFRDs7T0FFRztJQUNILFNBQVMsRUFBRSxDQUFDLFNBQWlCO1FBQ3pCLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNoRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxNQUFNLEVBQUUsQ0FBQyxTQUFpQjtRQUN0QixNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDN0MsQ0FBQztDQUNKLENBQUEifQ==

View File

@ -1,4 +1,3 @@
import "typings-global";
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg

View File

@ -1,19 +1,19 @@
"use strict";
require("typings-global");
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
exports.makeEnvObject = function (envArrayArg) {
var returnObject = {};
var regexString = /(.*)=(.*)/;
for (var envKey in envArrayArg) {
var regexMatches = regexString.exec(envArrayArg[envKey]);
returnObject[regexMatches[1]] = regexMatches[2];
let returnObject = {};
let regexString = /(.*)=(.*)/;
if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[env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UFZLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkQsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -1,4 +1,3 @@
import "typings-global";
export declare class Domain {
fullName: string;
level1: string;

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
import "typings-global";
export declare class GitRepo {
host: string;
user: string;

View File

@ -1,51 +1,45 @@
"use strict";
require("typings-global");
var plugins = require("./smartstring.plugins");
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
var GitRepo = (function () {
function GitRepo(stringArg, tokenArg) {
var regexMatches = gitRegex(stringArg);
class GitRepo {
constructor(stringArg, tokenArg) {
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");
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;
}());
}
exports.GitRepo = GitRepo;
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
var gitRegex = function (stringArg) {
var regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
var regexMatches = regexString.exec(stringArg);
let gitRegex = function (stringArg) {
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
let 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 + "@";
let gitLink = function (hostArg, userArg, repoArg, tokenArg = '', linkTypeArg) {
let returnString;
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case "https":
returnString = "https://" +
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
case 'https':
returnString = 'https://' +
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break;
case "ssh":
returnString = "git@" +
hostArg + ":" + userArg + "/" + repoArg + ".git";
case 'ssh':
returnString = 'git@' +
hostArg + ':' + userArg + '/' + repoArg + '.git';
break;
default:
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
console.error('Link Type ' + linkTypeArg + ' not known');
break;
}
return returnString;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmdpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBQ3ZCLElBQU8sT0FBTyxXQUFXLHVCQUF1QixDQUFDLENBQUM7QUFFbEQ7O29EQUVvRDtBQUNwRDtJQU9JLGlCQUFZLFNBQWdCLEVBQUMsUUFBZ0I7UUFDekMsSUFBSSxZQUFZLEdBQUcsUUFBUSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxXQUFXLEdBQUcsUUFBUSxDQUFDO1FBQzVCLElBQUksQ0FBQyxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyx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sgPSBmdW5jdGlvbihob3N0QXJnOnN0cmluZywgdXNlckFyZzpzdHJpbmcsIHJlcG9Bcmc6c3RyaW5nLCB0b2tlbkFyZzpzdHJpbmcgPSBcIlwiLCBsaW5rVHlwZUFyZyk6c3RyaW5ne1xuICAgIGxldCByZXR1cm5TdHJpbmc7XG4gICAgaWYgKHRva2VuQXJnICE9PSBcIlwiKXtcbiAgICAgICAgdG9rZW5BcmcgPSB0b2tlbkFyZyArIFwiQFwiXG4gICAgfVxuICAgIHN3aXRjaCAobGlua1R5cGVBcmcpIHtcbiAgICAgICAgY2FzZSBcImh0dHBzXCI6XG4gICAgICAgICAgICByZXR1cm5TdHJpbmcgPSAgXCJodHRwczovL1wiICtcbiAgICAgICAgICAgICAgICB0b2tlbkFyZyArIGhvc3RBcmcgKyBcIi9cIiArIHVzZXJBcmcgKyBcIi9cIiArIHJlcG9BcmcgKyBcIi5naXRcIjtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlIFwic3NoXCI6XG4gICAgICAgICAgICByZXR1cm5TdHJpbmcgPSBcImdpdEBcIiArXG4gICAgICAgICAgICAgICAgaG9zdEFyZyArIFwiOlwiICsgdXNlckFyZyArIFwiL1wiICsgcmVwb0FyZyArIFwiLmdpdFwiO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcIkxpbmsgVHlwZSBcIiArIGxpbmtUeXBlQXJnICsgXCIgbm90IGtub3duXCIpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgfVxuICAgIHJldHVybiByZXR1cm5TdHJpbmc7XG59OyJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZ2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZ2l0LnRzIl0sIm5hb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UcsVUFBUyxPQUFlLEVBQUUsT0FBZSxFQUFFLE9BQWUsRUFBRSxXQUFtQixFQUFFLEVBQUUsV0FBVztJQUN4RyxJQUFJLFlBQVksQ0FBQTtJQUNoQixFQUFFLENBQUMsQ0FBQyxRQUFRLEtBQUssRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNsQixRQUFRLEdBQUcsUUFBUSxHQUFHLEdBQUcsQ0FBQTtJQUM3QixDQUFDO0lBQ0QsTUFBTSxDQUFDLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQixLQUFLLE9BQU87WUFDUixZQUFZLEdBQUcsVUFBVTtnQkFDckIsUUFBUSxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLEdBQUcsR0FBRyxPQUFPLEdBQUcsTUFBTSxDQUFBO1lBQy9ELEtBQUssQ0FBQTtRQUNULEtBQUssS0FBSztZQUNOLFlBQVksR0FBRyxNQUFNO2dCQUNqQixPQUFPLEdBQUcsR0FBRyxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLE1BQU0sQ0FBQztZQUNyRCxLQUFLLENBQUE7UUFDVDtZQUNJLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxHQUFHLFdBQVcsR0FBRyxZQUFZLENBQUMsQ0FBQTtZQUN4RCxLQUFLLENBQUE7SUFDYixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

3
dist/smartstring.indent.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export declare let indent: (stringArg: string, spaceAmount: number) => string;
export declare let indentWithPrefix: (stringArg: string, prefixArg: string) => string;
export declare let normalize: (stringArg: string) => string;

61
dist/smartstring.indent.js vendored Normal file
View File

@ -0,0 +1,61 @@
"use strict";
let splitString = (stringArg) => {
let resultArray = stringArg.split('\n');
return cleanStringArray(resultArray);
};
let joinString = (stringArrayArg) => {
let resultString = '';
for (let line of stringArrayArg) {
resultString = resultString + line + '\n';
}
return resultString;
};
let cleanStringArray = (stringArrayArg) => {
let testRegex = /^[\s]*$/;
if (testRegex.test(stringArrayArg[0])) {
stringArrayArg.shift();
}
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
stringArrayArg.pop();
}
;
return stringArrayArg;
};
exports.indent = (stringArg, spaceAmount) => {
let resultString;
return resultString;
};
exports.indentWithPrefix = (stringArg, prefixArg) => {
let resultString;
let stringArray = splitString(stringArg);
let resultArray = [];
for (let stringItem of stringArray) {
resultArray.push(prefixArg + stringItem);
}
;
resultString = joinString(resultArray);
return resultString;
};
exports.normalize = (stringArg) => {
let resultString;
let splitStringArray = splitString(stringArg);
let minCommonLeftOffset;
let deIndentRegex = /^(\s*)/;
let emptyLineRegex = /^(\s*)$/;
for (let stringItem of splitStringArray) {
let offsetString = deIndentRegex.exec(stringItem)[1];
if ((typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
&& !emptyLineRegex.test(stringItem)) {
minCommonLeftOffset = offsetString.length;
}
}
;
let resultSplitStringArray = [];
for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
}
;
resultString = joinString(resultSplitStringArray);
return resultString;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxDQUFDLFNBQWlCO0lBQ2hDLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFBO0FBQ3hDLENBQUMsQ0FBQztBQUVG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LENBQUM7SUFBQSxDQUFDO0lBQ0YsSUFBSSxzQkFBc0IsR0FBRyxFQUFFLENBQUE7SUFDL0IsR0FBRyxDQUFDLENBQUMsSUFBSSxVQUFVLElBQUksZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1FBQ3RDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQTtJQUN2RSxDQUFDO0lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUNqRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9

View File

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

View File

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

View File

@ -1,2 +1 @@
import "typings-global";
export declare let regexReferencePath: RegExp;

View File

@ -1,5 +1,3 @@
"use strict";
require("typings-global");
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUdaLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIiwiZmlsZSI6InNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLnBsdWdpbnNcIik7XG5cbmV4cG9ydCBsZXQgcmVnZXhSZWZlcmVuY2VQYXRoID0gL1xcL1xcL1xcL1xccyo8cmVmZXJlbmNlXFxzK3BhdGhcXHMqPVxccypbXCJ8J10uKltcInwnXVxccypcXC8+XFxzKltcXFxcbl0/LyJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==

View File

@ -1,6 +1,6 @@
{
"name": "smartstring",
"version": "2.0.9",
"version": "2.0.20",
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -22,12 +22,14 @@
},
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": {
"npmts-g": "^5.2.6",
"should": "^9.0.2",
"typings-test": "^1.0.1"
"@types/should": "^8.1.30",
"beautylog": "^6.0.0",
"npmts-g": "^5.2.8",
"should": "^11.1.1",
"typings-test": "^1.0.3"
},
"dependencies": {
"beautylog": "^5.0.12",
"typings-global": "^1.0.3"
"js-base64": "^2.1.9",
"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,83 +1,115 @@
import "typings-test"
import * as smartstring from "../dist/index";
let should = require("should");
import 'typings-test'
import * as smartstring from '../dist/index'
import * as should from 'should'
describe("smartstring",function(){
describe(".Domain class",function(){
let testDomain:smartstring.Domain;
let testDomain2:smartstring.Domain;
it("should create a new Domain object",function(){
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
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");
describe('smartstring',function(){
describe('.Base64 class', function(){
let testBase64: smartstring.Base64
it('should create a valid instance of Base64', function(){
testBase64 = new smartstring.Base64('somestring', 'string')
should(testBase64).be.instanceOf(smartstring.Base64)
})
it ("should have the correct protocol",function(){
testDomain.protocol.should.equal("https");
it('should read output a file as base64 and base64uri', function(){
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(){
let testGit:smartstring.GitRepo;
it("should create a new Git class GitRepo",function(){
testGit = new smartstring.GitRepo("git+https://github.com/pushrocks/smartstring.git");
testGit.should.be.instanceof(smartstring.GitRepo);
describe('.Domain class',function(){
let testDomain:smartstring.Domain
let testDomain2:smartstring.Domain
it('should create a new Domain object',function(){
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(".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('.Git class',function(){
let testGit:smartstring.GitRepo
it('should create a new Git class GitRepo',function(){
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git')
should(testGit).be.instanceof(smartstring.GitRepo)
})
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(".typescript",function(){
describe(".referenceRegex",function(){
it("should match reference paths",function(){
smartstring.typescript.regexReferencePath.test("/// <reference path=\"\" />")
.should.be.true();
describe('.indent',function(){
let testString = `
base
should be indented
some more
base
indented
`
describe('.normalize()',function(){
it('should normalize a string',function(){
testString = smartstring.indent.normalize(testString)
console.log(testString)
let zoneNameArg = 'test1'
let destinationIpArg = '111'
})
})
describe('.indentWithPrefix',function(){
it('should indent',function(){
testString = smartstring.indent.indentWithPrefix(testString,'>> ')
console.log(testString)
})
})
})
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();
.should.be.true()
smartstring.typescript.regexReferencePath.test('/// <referencepath=\"\" />')
.should.be.false()
})
})
})
});
})

View File

@ -1,8 +1,13 @@
import "typings-global"
import SmartstringDocker = require("./smartstring.docker");
import SmartstringTypescript = require("./smartstring.typescript");
import * as docker from './smartstring.docker'
import * as indent from './smartstring.indent'
import * as typescript from './smartstring.typescript'
export {Domain} from "./smartstring.domain";
export {GitRepo} from "./smartstring.git";
export let docker = SmartstringDocker;
export let typescript = SmartstringTypescript;
export {
docker,
typescript,
indent
}
export { Base64, base64 } from './smartstring.base64'
export { Domain } from './smartstring.domain'
export { GitRepo } from './smartstring.git'

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

@ -0,0 +1,69 @@
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 = base64.decode(inputStringArg)
break
case 'base64uri':
this.refString = base64.decode(inputStringArg)
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return base64.encode(this.refString)
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return base64.encodeUri(this.refString)
}
}
export let base64 = {
/**
* encodes the string
*/
encode: (stringArg: string) => {
return plugins.jsBase64.encode(stringArg)
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg: string) => {
return plugins.jsBase64.encodeURI(stringArg)
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg: string) => {
return plugins.jsBase64.decode(stringArg)
}
}

View File

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

View File

@ -1,63 +1,62 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins';
export class Domain {
fullName:string;
level1:string;
level2:string;
level3:string;
level4:string;
level5:string;
protocol:string;
zoneName:string;
//aliases
topLevel:string;
domainName;
subDomain;
fullName: string
level1: string
level2: string
level3: string
level4: string
level5: string
protocol: string
zoneName: string
// aliases
topLevel: string
domainName
subDomain
constructor(domainStringArg:string){
let regexMatches = domainRegex(domainStringArg);
this.fullName = "";
for(let i = 1; i <= 5; i++){
if(regexMatches[i - 1]) {
this.fullName = ''
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
let localMatch = regexMatches[i - 1]
this["level" + i.toString()] = localMatch;
if (this.fullName == ""){
this.fullName = localMatch;
this['level' + i.toString()] = localMatch
if (this.fullName === ''){
this.fullName = localMatch
} else {
this.fullName = localMatch + "." + this.fullName;
this.fullName = localMatch + '.' + this.fullName
}
} else {
this["level" + i.toString()] = undefined;
this['level' + i.toString()] = undefined
};
};
this.protocol = protocolRegex(domainStringArg);
this.zoneName = this.level2 + "." + this.level1;
this.protocol = protocolRegex(domainStringArg)
this.zoneName = this.level2 + '.' + this.level1
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
this.topLevel = this.level1
this.domainName = this.level2
this.subDomain = this.level3
}
}
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 regexMatches = regexString.exec(stringArg);
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
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)
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
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg != "");
return(stringArg !== '')
});
return regexMatchesFiltered;
return regexMatchesFiltered
};
let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//;
let regexMatches = regexString.exec(stringArg);
if(regexMatches){
return regexMatches[1];
let regexString = /^([a-zA-Z0-9]*):\/\//
let regexMatches = regexString.exec(stringArg)
if(regexMatches) {
return regexMatches[1]
} else {
return undefined;
return undefined
}
}
}

View File

@ -1,53 +1,52 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins'
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
export 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");
};
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 = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
};
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/
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 + "@"
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;
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;
console.error('Link Type ' + linkTypeArg + ' not known')
break
}
return returnString;
};
return returnString
}

64
ts/smartstring.indent.ts Normal file
View File

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

View File

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

View File

@ -1,4 +1,3 @@
import "typings-global"
import plugins = require("./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]?/

View File

@ -1,7 +0,0 @@
{
"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"
}
}

3
tslint.json Normal file
View File

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