Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
39ce541532 | |||
c2a4f05b33 | |||
3858127968 | |||
68d0124c24 | |||
16f41a7d63 | |||
d13dfc9e76 | |||
942f6b37cf | |||
211c7c3308 | |||
a55d6d2221 | |||
98ca73d0c7 | |||
ffedc7f601 | |||
8344fdf7b1 | |||
543dc98961 | |||
9c60105685 | |||
bdccf2c3a1 | |||
34d6df0923 | |||
3d3b07b7cb | |||
00004f70d6 | |||
2d263244c7 | |||
8cb1405d99 | |||
d357d6e52d | |||
c124f90a91 | |||
4bcf9f941e | |||
afb204325b | |||
cefbb6eecd | |||
c6a1a45812 | |||
00a892ee82 | |||
0eb6d13be9 | |||
c34f9611f9 | |||
820360a220 | |||
3893985bb2 | |||
33e19c54d9 | |||
074996433e | |||
6a803f1db9 | |||
927262d6d4 | |||
df39887de9 | |||
2b52b76ac6 | |||
136a06ff68 | |||
44bb4fa9ae |
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,7 +1,4 @@
|
||||
.idea/
|
||||
coverage/
|
||||
docs/
|
||||
node_modules
|
||||
ts/**/*.js
|
||||
ts/**/*.js.map
|
||||
ts/typings/
|
||||
pages/
|
||||
public/
|
||||
node_modules/
|
||||
|
59
.gitlab-ci.yml
Normal file
59
.gitlab-ci.yml
Normal file
@ -0,0 +1,59 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- 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
|
12
.travis.yml
12
.travis.yml
@ -1,12 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '4.3.0'
|
||||
- 'stable'
|
||||
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
|
25
README.md
25
README.md
@ -1,12 +1,21 @@
|
||||
# smartstring
|
||||
handle strings in smart ways. TypeScript ready.
|
||||
|
||||
## Status
|
||||
[](https://travis-ci.org/pushrocks/smartstring)
|
||||
[](https://ci.appveyor.com/project/philkunz/smartstring/branch/master)
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartstring)
|
||||
[](https://gitlab.com/pushrocks/smartstring)
|
||||
[](https://github.com/pushrocks/smartstring)
|
||||
[](https://pushrocks.gitlab.io/smartstring/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartstring/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartstring/commits/master)
|
||||
[](https://david-dm.org/pushrocks/smartstring)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstring)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for intellisense.
|
||||
@ -20,8 +29,8 @@ myGitRepo.host // "github.com"
|
||||
myGitRepo.user // "someorg"
|
||||
myGitRepo.repo // "somerepo"
|
||||
myGitRepo.accessToken // accessToken if specified with https
|
||||
myGitRepo.sshUrl // ssh URL (computed also from https)
|
||||
myGitRepo.httpsUrl // https URL (computed also from ssh)
|
||||
myGitRepo.sshUrl // "git@github.com:someorg/somerepo.git" (computed also from https)
|
||||
myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh)
|
||||
|
||||
// smartstring.Domain class
|
||||
let myDomain = new smartstring.Domain("https://sub.main.tld");
|
||||
@ -30,10 +39,6 @@ myDomain.level2 // "main"
|
||||
// level3 , level 4 and so on...
|
||||
myDomain.zoneName // "main.tld"
|
||||
myDOmain.protocol // "https"
|
||||
|
||||
```
|
||||
|
||||
## About the authors:
|
||||
[](https://lossless.com/)
|
||||
|
||||
[](https://paypal.me/lossless)
|
||||
[](https://push.rocks)
|
||||
|
10
appveyor.yml
10
appveyor.yml
@ -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
14
dist/index.d.ts
vendored
@ -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 } from './smartstring.base64';
|
||||
export { Domain } from './smartstring.domain';
|
||||
export { GitRepo } from './smartstring.git';
|
||||
|
16
dist/index.js
vendored
16
dist/index.js
vendored
@ -1,12 +1,14 @@
|
||||
"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;
|
||||
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxpQkFBaUIsV0FBVyxzQkFBc0IsQ0FBQyxDQUFDO0FBQzNELElBQU8scUJBQXFCLFdBQVcsMEJBQTBCLENBQUMsQ0FBQztBQUVuRSxtQ0FBcUIsc0JBQXNCLENBQUM7QUFBcEMsNkNBQW9DO0FBQzVDLGdDQUFzQixtQkFBbUIsQ0FBQztBQUFsQyw0Q0FBa0M7QUFDL0IsY0FBTSxHQUFHLGlCQUFpQixDQUFDO0FBQzNCLGtCQUFVLEdBQUcscUJBQXFCLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXHJcbmltcG9ydCBTbWFydHN0cmluZ0RvY2tlciA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLmRvY2tlclwiKTtcclxuaW1wb3J0IFNtYXJ0c3RyaW5nVHlwZXNjcmlwdCA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHRcIik7XHJcblxyXG5leHBvcnQge0RvbWFpbn0gZnJvbSBcIi4vc21hcnRzdHJpbmcuZG9tYWluXCI7XHJcbmV4cG9ydCB7R2l0UmVwb30gZnJvbSBcIi4vc21hcnRzdHJpbmcuZ2l0XCI7XHJcbmV4cG9ydCBsZXQgZG9ja2VyID0gU21hcnRzdHJpbmdEb2NrZXI7XHJcbmV4cG9ydCBsZXQgdHlwZXNjcmlwdCA9IFNtYXJ0c3RyaW5nVHlwZXNjcmlwdDsiXX0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQTZDO0FBQXBDLHNDQUFBLE1BQU0sQ0FBQTtBQUNmLDJEQUE2QztBQUFwQyxzQ0FBQSxNQUFNLENBQUE7QUFDZixxREFBMkM7QUFBbEMsb0NBQUEsT0FBTyxDQUFBIn0=
|
23
dist/smartstring.base64.d.ts
vendored
Normal file
23
dist/smartstring.base64.d.ts
vendored
Normal 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
39
dist/smartstring.base64.js
vendored
Normal 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==
|
1
dist/smartstring.docker.d.ts
vendored
1
dist/smartstring.docker.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
import "typings-global";
|
||||
/**
|
||||
* converts an erray of env strings from docker remote api to an usable object.
|
||||
* @param envArrayArg
|
||||
|
18
dist/smartstring.docker.js
vendored
18
dist/smartstring.docker.js
vendored
@ -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[envKey]);
|
||||
returnObject[regexMatches[1]] = regexMatches[2];
|
||||
}
|
||||
;
|
||||
}
|
||||
;
|
||||
return returnObject;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzI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FDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==
|
1
dist/smartstring.domain.d.ts
vendored
1
dist/smartstring.domain.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
import "typings-global";
|
||||
export declare class Domain {
|
||||
fullName: string;
|
||||
level1: string;
|
||||
|
68
dist/smartstring.domain.js
vendored
68
dist/smartstring.domain.js
vendored
@ -1,38 +1,52 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var Domain = (function () {
|
||||
function Domain(domainStringArg) {
|
||||
this.fullName = domainStringArg;
|
||||
var regexMatches = domainRegex(domainStringArg);
|
||||
this.level1 = regexMatches[0];
|
||||
this.level2 = regexMatches[1];
|
||||
this.level3 = regexMatches[2];
|
||||
this.level4 = regexMatches[3];
|
||||
this.level5 = regexMatches[4];
|
||||
this.protocol = protocolRegex(domainStringArg)[1];
|
||||
this.zoneName = this.level2 + "." + this.level1;
|
||||
class Domain {
|
||||
constructor(domainStringArg) {
|
||||
let regexMatches = domainRegex(domainStringArg);
|
||||
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;
|
||||
}
|
||||
else {
|
||||
this.fullName = localMatch + '.' + this.fullName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this['level' + i.toString()] = undefined;
|
||||
}
|
||||
;
|
||||
}
|
||||
;
|
||||
this.protocol = protocolRegex(domainStringArg);
|
||||
this.zoneName = this.level2 + '.' + this.level1;
|
||||
// aliases
|
||||
this.topLevel = this.level1;
|
||||
this.domainName = this.level2;
|
||||
this.subDomain = this.level3;
|
||||
}
|
||||
return Domain;
|
||||
}());
|
||||
}
|
||||
exports.Domain = Domain;
|
||||
var domainRegex = function (stringArg) {
|
||||
var 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}$/;
|
||||
var regexMatches = regexString.exec(stringArg);
|
||||
regexMatches.reverse();
|
||||
var regexMatchesFiltered = regexMatches.filter(function (stringArg) {
|
||||
return (stringArg != "");
|
||||
let domainRegex = function (stringArg) {
|
||||
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) {
|
||||
return (stringArg !== '');
|
||||
});
|
||||
return regexMatchesFiltered;
|
||||
};
|
||||
var protocolRegex = function (stringArg) {
|
||||
var regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||
var regexMatches = regexString.exec(stringArg);
|
||||
console.log(regexMatches);
|
||||
return regexMatches;
|
||||
let protocolRegex = function (stringArg) {
|
||||
let regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||
let regexMatches = regexString.exec(stringArg);
|
||||
if (regexMatches) {
|
||||
return regexMatches[1];
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvbWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBR3ZCO0lBYUksZ0JBQVksZUFBc0I7UUFDOUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFl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dist/smartstring.git.d.ts
vendored
1
dist/smartstring.git.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
import "typings-global";
|
||||
export declare class GitRepo {
|
||||
host: string;
|
||||
user: string;
|
||||
|
48
dist/smartstring.git.js
vendored
48
dist/smartstring.git.js
vendored
File diff suppressed because one or more lines are too long
3
dist/smartstring.indent.d.ts
vendored
Normal file
3
dist/smartstring.indent.d.ts
vendored
Normal 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
61
dist/smartstring.indent.js
vendored
Normal 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxDQUFDLFNBQWlCO0lBQ2hDLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFBO0FBQ3hDLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLENBQUMsY0FBd0I7SUFDdEMsSUFBSSxZQUFZLEdBQVcsRUFBRSxDQUFBO0lBQzdCLEdBQUcsQ0FBQyxDQUFDLElBQUksSUFBSSxJQUFJLGNBQWMsQ0FBQyxDQUFBLENBQUM7UUFDN0IsWUFBWSxHQUFHLFlBQVksR0FBRyxJQUFJLEdBQUcsSUFBSSxDQUFBO0lBQzdDLENBQUM7SUFDRCxNQUFNLENBQUMsWUF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lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUNqRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9
|
4
dist/smartstring.plugins.d.ts
vendored
4
dist/smartstring.plugins.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
import 'typings-global';
|
||||
export declare let jsBase64: any;
|
||||
|
5
dist/smartstring.plugins.js
vendored
5
dist/smartstring.plugins.js
vendored
@ -1,5 +1,4 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBRVAsQ0FBQyxDQUZzQjtBQUVULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcclxuXHJcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTsiXX0=
|
||||
exports.jsBase64 = require('js-base64').Base64;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUNaLFFBQUEsUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUEifQ==
|
1
dist/smartstring.typescript.d.ts
vendored
1
dist/smartstring.typescript.d.ts
vendored
@ -1,2 +1 @@
|
||||
import "typings-global";
|
||||
export declare let regexReferencePath: RegExp;
|
||||
|
4
dist/smartstring.typescript.js
vendored
4
dist/smartstring.typescript.js
vendored
@ -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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUdaLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIiwiZmlsZSI6InNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXHJcbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcucGx1Z2luc1wiKTtcclxuXHJcbmV4cG9ydCBsZXQgcmVnZXhSZWZlcmVuY2VQYXRoID0gL1xcL1xcL1xcL1xccyo8cmVmZXJlbmNlXFxzK3BhdGhcXHMqPVxccypbXCJ8J10uKltcInwnXVxccypcXC8+XFxzKltcXFxcbl0/LyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==
|
22
package.json
22
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "smartstring",
|
||||
"version": "2.0.3",
|
||||
"description": "bundles a bunch of (regex) matching and altering methods.",
|
||||
"version": "2.0.19",
|
||||
"description": "handle strings in smart ways. TypeScript ready.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pushrocks/smartstring.git"
|
||||
"url": "git+https://gitlab.com/pushrocks/smartstring.git"
|
||||
},
|
||||
"keywords": [
|
||||
"regex",
|
||||
@ -18,16 +18,18 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartstring/issues"
|
||||
"url": "https://gitlab.com/pushrocks/smartstring/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartstring#readme",
|
||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
||||
"devDependencies": {
|
||||
"npmts": "^5.1.13",
|
||||
"should": "^8.4.0",
|
||||
"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.6",
|
||||
"typings-global": "^1.0.3"
|
||||
"js-base64": "^2.1.9",
|
||||
"typings-global": "^1.0.14"
|
||||
}
|
||||
}
|
||||
|
2
test/test.d.ts
vendored
2
test/test.d.ts
vendored
@ -1 +1 @@
|
||||
import "typings-test";
|
||||
import 'typings-test';
|
||||
|
148
test/test.js
148
test/test.js
File diff suppressed because one or more lines are too long
166
test/test.ts
166
test/test.ts
@ -1,77 +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;
|
||||
it("should create a new Domain object",function(){
|
||||
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
|
||||
testDomain.should.be.instanceof(smartstring.Domain);
|
||||
});
|
||||
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)
|
||||
})
|
||||
})
|
||||
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 = 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()
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
})
|
||||
|
19
ts/index.ts
19
ts/index.ts
@ -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 } from './smartstring.base64'
|
||||
export { Domain } from './smartstring.domain'
|
||||
export { GitRepo } from './smartstring.git'
|
||||
|
46
ts/smartstring.base64.ts
Normal file
46
ts/smartstring.base64.ts
Normal 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)
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -1,51 +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){
|
||||
this.fullName = domainStringArg;
|
||||
let regexMatches = domainRegex(domainStringArg);
|
||||
this.level1 = regexMatches[0];
|
||||
this.level2 = regexMatches[1];
|
||||
this.level3 = regexMatches[2];
|
||||
this.level4 = regexMatches[3];
|
||||
this.level5 = regexMatches[4];
|
||||
this.protocol = protocolRegex(domainStringArg)[1];
|
||||
this.zoneName = this.level2 + "." + this.level1;
|
||||
|
||||
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
|
||||
} else {
|
||||
this.fullName = localMatch + '.' + this.fullName
|
||||
}
|
||||
} else {
|
||||
this['level' + i.toString()] = undefined
|
||||
};
|
||||
};
|
||||
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();
|
||||
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);
|
||||
console.log(regexMatches);
|
||||
return regexMatches;
|
||||
}
|
||||
let regexString = /^([a-zA-Z0-9]*):\/\//
|
||||
let regexMatches = regexString.exec(stringArg)
|
||||
if(regexMatches) {
|
||||
return regexMatches[1]
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
@ -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 = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
|
||||
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
64
ts/smartstring.indent.ts
Normal 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
|
||||
}
|
@ -1,3 +1,2 @@
|
||||
import "typings-global"
|
||||
|
||||
export import beautylog = require("beautylog");
|
||||
import 'typings-global'
|
||||
export let jsBase64 = require('js-base64').Base64
|
||||
|
@ -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]?/
|
||||
|
@ -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
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user