Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
88af0ab9aa | |||
5b5bcd804f | |||
8c894ea1c1 | |||
62336aa2cf | |||
e9899e5451 | |||
235f380139 | |||
4a94ce3038 | |||
7c4c787539 | |||
714e3a162c | |||
099bf9b270 | |||
83279a9c19 | |||
55d679e5ee | |||
974bf90703 | |||
93029d1aae | |||
3a7740024c | |||
a412285862 | |||
a57bd446d0 | |||
afe8d5bc1b | |||
576e81588d | |||
76c590b045 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
coverage/
|
||||
.yarn/
|
||||
pages/
|
||||
public/
|
||||
node_modules/
|
||||
|
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@ -1,59 +1,142 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npmpage --host gitlab
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
allow_failure: true
|
||||
|
72
README.md
72
README.md
@ -1,15 +1,19 @@
|
||||
# smartstring
|
||||
|
||||
handle strings in smart ways. TypeScript ready.
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartstring)
|
||||
[](https://gitlab.com/pushrocks/smartstring)
|
||||
[](https://github.com/pushrocks/smartstring)
|
||||
[](https://pushrocks.gitlab.io/smartstring/)
|
||||
|
||||
[](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://GitLab.com/pushrocks/smartstring/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartstring/commits/master)
|
||||
[](https://www.npmjs.com/package/smartstring)
|
||||
[](https://david-dm.org/pushrocks/smartstring)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstring)
|
||||
@ -18,27 +22,49 @@ handle strings in smart ways. TypeScript ready.
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for intellisense.
|
||||
|
||||
```typescript
|
||||
import * as smartstring from "smartstring";
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
// smartstring.GitRepo class
|
||||
let myGitRepo = new smartstring.GitRepo("git@github.com:someorg/somerepo.git"); // takes https and git and npm repo URL versions
|
||||
myGitRepo.host // "github.com"
|
||||
myGitRepo.user // "someorg"
|
||||
myGitRepo.repo // "somerepo"
|
||||
myGitRepo.accessToken // accessToken if specified with https
|
||||
myGitRepo.sshUrl // "git@github.com:someorg/somerepo.git" (computed also from https)
|
||||
myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh)
|
||||
```javascript
|
||||
import * as smartstring from 'smartstring';
|
||||
|
||||
// classes
|
||||
|
||||
// smartstring.Domain class
|
||||
let myDomain = new smartstring.Domain("https://sub.main.tld");
|
||||
myDomain.level1 // "tld"
|
||||
myDomain.level2 // "main"
|
||||
let myDomain = new smartstring.Domain('https://sub.main.tld');
|
||||
myDomain.level1; // "tld"
|
||||
myDomain.level2; // "main"
|
||||
// level3 , level 4 and so on...
|
||||
myDomain.zoneName // "main.tld"
|
||||
myDOmain.protocol // "https"
|
||||
myDomain.zoneName; // "main.tld"
|
||||
myDOmain.protocol; // "https"
|
||||
|
||||
// smartstring.GitRepo class
|
||||
let myGitRepo = new smartstring.GitRepo('git@github.com:someorg/somerepo.git'); // takes https and git and npm repo URL versions
|
||||
myGitRepo.host; // "github.com"
|
||||
myGitRepo.user; // "someorg"
|
||||
myGitRepo.repo; // "somerepo"
|
||||
myGitRepo.accessToken; // accessToken if specified with https
|
||||
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.Base64
|
||||
let myBase64 = new smartstring.Base64('somestring', 'string'); // first arg is the string, second is string type (can be string, base64, base64uri)
|
||||
myBase64.simpleString; // 'somestring'
|
||||
myBase64.base64String; // base64 representation of 'somestring'
|
||||
myBase64.base64UriString; // base64uri representation of 'sometring'
|
||||
|
||||
// methods
|
||||
smartstring.base64.encode('somestring'); // encodes 'somestring' to base64
|
||||
smartstring.base64.encodeUri('sometring'); // encodes 'somestring' to base64uri
|
||||
smartstring.base64.decode(); // decodes base64 and base64uri to simple string respresentation
|
||||
|
||||
smartstring.indent.indent('somestringanotherstring', 4); // indents a string by 4
|
||||
smartstring.indent.indent('somestringanotherstring', '>>>> '); // indents a string with a prefix
|
||||
smartstring.indent.normalize(' somestring anotherstring', '>>>> '); // looks for the least amount of indention and removes superflouous space
|
||||
```
|
||||
|
||||
[](https://push.rocks)
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
||||
[](https://push.rocks)
|
||||
|
7
dist/index.d.ts
vendored
7
dist/index.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
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';
|
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
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;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQXFEO0FBQTVDLHNDQUFBLE1BQU0sQ0FBQTtBQUFFLHNDQUFBLE1BQU0sQ0FBQTtBQUN2QiwyREFBNkM7QUFBcEMsc0NBQUEsTUFBTSxDQUFBO0FBQ2YscURBQTJDO0FBQWxDLG9DQUFBLE9BQU8sQ0FBQSJ9
|
28
dist/smartstring.base64.d.ts
vendored
28
dist/smartstring.base64.d.ts
vendored
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* 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
59
dist/smartstring.base64.js
vendored
@ -1,59 +0,0 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQU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sQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDN0MsQ0FBQztDQUNKLENBQUEifQ==
|
6
dist/smartstring.docker.d.ts
vendored
6
dist/smartstring.docker.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* converts an erray of env strings from docker remote api to an usable object.
|
||||
* @param envArrayArg
|
||||
* @returns {}
|
||||
*/
|
||||
export declare let makeEnvObject: (envArrayArg: string[]) => {};
|
19
dist/smartstring.docker.js
vendored
19
dist/smartstring.docker.js
vendored
@ -1,19 +0,0 @@
|
||||
"use strict";
|
||||
/**
|
||||
* converts an erray of env strings from docker remote api to an usable object.
|
||||
* @param envArrayArg
|
||||
* @returns {}
|
||||
*/
|
||||
exports.makeEnvObject = function (envArrayArg) {
|
||||
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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsVUFBVSxXQUFxQjtJQUN0RCxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUE7SUFDckIsSUFBSSxXQUFXLEdBQUcsV0FBVyxDQUFBO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sV0FBVyxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDckMsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksV0FBVyxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBO1lBQ3hELFlBQVksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkQsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==
|
14
dist/smartstring.domain.d.ts
vendored
14
dist/smartstring.domain.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
export declare class Domain {
|
||||
fullName: string;
|
||||
level1: string;
|
||||
level2: string;
|
||||
level3: string;
|
||||
level4: string;
|
||||
level5: string;
|
||||
protocol: string;
|
||||
zoneName: string;
|
||||
topLevel: string;
|
||||
domainName: any;
|
||||
subDomain: any;
|
||||
constructor(domainStringArg: string);
|
||||
}
|
52
dist/smartstring.domain.js
vendored
52
dist/smartstring.domain.js
vendored
@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
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;
|
||||
}
|
||||
}
|
||||
exports.Domain = Domain;
|
||||
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;
|
||||
};
|
||||
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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9tYWluLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTtJQWFJLFlBQVksZUFBc0I7UUFDOUIsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ2hELElBQUksQ0FBQyxRQUFRLEdBQUcsRUFBRSxDQUFBO1FBQ2xCLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7WUFDMUIsRUFBRSxDQUFDLENBQUMsWUFBWSxDQUFDLENBQUMsR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ENBQUM7Q0FDSjtBQXJDRCx3QkFxQ0M7QUFHRCxJQUFJLFdBQVcsR0FBRyxVQUFTLFNBQWdCO0lBQ3ZDLElBQUksV0FBVyxHQUFHLGdJQUFnSSxDQUFBO0lBQ2xKLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDOUMsWUFBWSxDQUFDLE9BQU8sRUFBRSxDQUFBLENBQUMsMkVBQTJFO0lBQ2xHLFlBQVksQ0FBQyxHQUFHLEVBQUUsQ0FBQSxDQUFDLG1HQUFtRztJQUN0SCxJQUFJLG9CQUFvQixHQUFHLFlBQVksQ0FBQyxNQUFNLENBQUMsVUFBUyxTQUFnQjtRQUNwRSxNQUFNLENBQUEsQ0FBQyxTQUFTLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDNUIsQ0FBQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsb0JBQW9CLENBQUE7QUFDL0IsQ0FBQyxDQUFDO0FBRUYsSUFBSSxhQUFhLEdBQUcsVUFBUyxTQUFnQjtJQUN6QyxJQUFJLFdBQVcsR0FBRyxzQkFBc0IsQ0FBQTtJQUN4QyxJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQzlDLEVBQUUsQ0FBQSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7UUFDZCxNQUFNLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzFCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQSJ9
|
9
dist/smartstring.git.d.ts
vendored
9
dist/smartstring.git.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export declare class GitRepo {
|
||||
host: string;
|
||||
user: string;
|
||||
repo: string;
|
||||
accessToken: string;
|
||||
sshUrl: string;
|
||||
httpsUrl: string;
|
||||
constructor(stringArg: string, tokenArg?: string);
|
||||
}
|
45
dist/smartstring.git.js
vendored
45
dist/smartstring.git.js
vendored
@ -1,45 +0,0 @@
|
||||
"use strict";
|
||||
/* ---------------------------------------------- *
|
||||
* ------------------ classes ------------------- *
|
||||
* ---------------------------------------------- */
|
||||
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');
|
||||
}
|
||||
}
|
||||
exports.GitRepo = GitRepo;
|
||||
/* ---------------------------------------------- *
|
||||
* ------------------ helpers ------------------- *
|
||||
* ---------------------------------------------- */
|
||||
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;
|
||||
};
|
||||
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';
|
||||
break;
|
||||
case 'ssh':
|
||||
returnString = 'git@' +
|
||||
hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||
break;
|
||||
default:
|
||||
console.error('Link Type ' + linkTypeArg + ' not known');
|
||||
break;
|
||||
}
|
||||
return returnString;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxl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DLFNBQVMsQ0FBQyxDQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQsSUFBSSxPQUFPLEdBQUcsVUFBUyxPQUFlLEVBQUUsT0FBZSxFQUFFLE9BQWUsRUFBRSxXQUFtQixFQUFFLEVBQUUsV0FBVztJQUN4RyxJQUFJLFlBQVksQ0FBQTtJQUNoQixFQUFFLENBQUMsQ0FBQyxRQUFRLEtBQUssRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNsQixRQUFRLEdBQUcsUUFBUSxHQUFHLEdBQUcsQ0FBQTtJQUM3QixDQUFDO0lBQ0QsTUFBTSxDQUFDLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQixLQUFLLE9BQU87WUFDUixZQUFZLEdBQUcsVUFBVTtnQkFDckIsUUFBUSxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLEdBQUcsR0FBRyxPQUFPLEdBQUcsTUFBTSxDQUFBO1lBQy9ELEtBQUssQ0FBQTtRQUNULEtBQUssS0FBSztZQUNOLFlBQVksR0FBRyxNQUFNO2dCQUNqQixPQUFPLEdBQUcsR0FBRyxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLE1BQU0sQ0FBQztZQUNyRCxLQUFLLENBQUE7UUFDVDtZQUNJLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxHQUFHLFdBQVcsR0FBRyxZQUFZLENBQUMsQ0FBQTtZQUN4RCxLQUFLLENBQUE7SUFDYixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==
|
3
dist/smartstring.indent.d.ts
vendored
3
dist/smartstring.indent.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
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
61
dist/smartstring.indent.js
vendored
@ -1,61 +0,0 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxDQUFDLFNBQWlCO0lBQ2hDLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFBO0FBQ3hDLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLENBQUMsY0FBd0I7SUFDdEMsSUFBSSxZQUFZLEdBQVcsRUFBRSxDQUFBO0lBQzdCLEdBQUcsQ0FBQyxDQUFDLElBQUksSUFBSSxJQUFJLGNBQWMsQ0FBQyxDQUFBLENBQUM7UUFDN0IsWUFBWSxHQUFHLFlBQVksR0FBRyxJQUFJLEdBQUcsSUFBSSxDQUFBO0lBQzdDLENBQUM7SUFDRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQTtBQUVELElBQUksZ0JBQWdCLEdBQUcsQ0FBQyxjQUF3QjtJQUM1QyxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUE7SUFDekIsRUFBRSxDQUFDLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDcEMsY0FBYyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQzFCLENBQUM7SUFDRCxFQUFFLENBQUMsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQ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UIsSUFBSSxjQUFjLEdBQUcsU0FBUyxDQUFBO0lBQzlCLEdBQUcsQ0FBQyxDQUFDLElBQUksVUFBVSxJQUFJLGdCQUFnQixDQUFDLENBQUEsQ0FBQztRQUNyQyxJQUFJLFlBQVksR0FBRyxhQUFhLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ3BELEVBQUUsQ0FBQyxDQUNDLENBQUMsT0FBTyxtQkFBbUIsS0FBSyxXQUFXLElBQUksWUFBWSxDQUFDLE1BQU0sR0FBRyxtQkFBbUIsQ0FBQztlQUN0RixDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUN0QyxDQUFDLENBQUMsQ0FBQztZQUNDLG1CQUFtQixHQUFHLFlBQVksQ0FBQyxNQUFNLENBQUE7UUFDN0MsQ0FBQztJQUNMLENBQUM7SUFBQSxDQUFDO0lBQ0YsSUFBSSxzQkFBc0IsR0FBRyxFQUFFLENBQUE7SUFDL0IsR0FBRyxDQUFDLENBQUMsSUFBSSxVQUFVLElBQUksZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1FBQ3RDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQTtJQUN2RSxDQUFDO0lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUNqRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9
|
2
dist/smartstring.plugins.d.ts
vendored
2
dist/smartstring.plugins.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import 'typings-global';
|
||||
export declare let jsBase64: any;
|
4
dist/smartstring.plugins.js
vendored
4
dist/smartstring.plugins.js
vendored
@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
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 +0,0 @@
|
||||
export declare let regexReferencePath: RegExp;
|
3
dist/smartstring.typescript.js
vendored
3
dist/smartstring.typescript.js
vendored
@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==
|
13
npmextra.json
Normal file
13
npmextra.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"@gitzone/npmts"
|
||||
],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"npmdocker": {
|
||||
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||
"command": "npmci node install stable && npmci npm install && npmci npm test",
|
||||
"dockerSock": false
|
||||
}
|
||||
}
|
1143
package-lock.json
generated
Normal file
1143
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "smartstring",
|
||||
"version": "2.0.20",
|
||||
"name": "@pushrocks/smartstring",
|
||||
"version": "3.0.1",
|
||||
"private": false,
|
||||
"description": "handle strings in smart ways. TypeScript ready.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "tstest test/",
|
||||
"build": "(tstest)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -22,14 +24,17 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"beautylog": "^6.0.0",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.9",
|
||||
"@gitzone/tstest": "^1.0.13",
|
||||
"@pushrocks/tapbundle": "^3.0.1",
|
||||
"@types/node": "^10.5.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-base64": "^2.1.9",
|
||||
"typings-global": "^1.0.14"
|
||||
"crypto-random-string": "^1.0.0",
|
||||
"js-base64": "^2.4.8",
|
||||
"normalize-newline": "^3.0.0",
|
||||
"randomatic": "^3.0.0",
|
||||
"strip-indent": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
16
test/test.base64.ts
Normal file
16
test/test.base64.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import * as smartstring from '../ts/index';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
// Base64
|
||||
let testBase64: smartstring.Base64;
|
||||
tap.test('expect create a valid instance of Base64', async () => {
|
||||
testBase64 = new smartstring.Base64('somestring', 'string');
|
||||
expect(testBase64).be.instanceOf(smartstring.Base64);
|
||||
});
|
||||
tap.test('expect read output a file as base64 and base64uri', async () => {
|
||||
expect(testBase64.base64String).not.equal(testBase64.base64UriString);
|
||||
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
|
||||
expect(testBase64_2.simpleString).equal(testBase64.simpleString);
|
||||
});
|
||||
|
||||
tap.start();
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
12
test/test.docker.ts
Normal file
12
test/test.docker.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import * as smartstring from '../ts/index';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
// Docker
|
||||
tap.test('expect create a Env Object', async () => {
|
||||
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com'];
|
||||
let envObject: any = smartstring.docker.makeEnvObject(envStringArray);
|
||||
expect(envObject.VIRTUAL_HOST).to.equal('sub.domain.tld');
|
||||
expect(envObject.DEFAULT_HOST).to.equal('some.domain.com');
|
||||
});
|
||||
|
||||
tap.start();
|
32
test/test.domain.ts
Normal file
32
test/test.domain.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import * as smartstring from '../ts/index';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
// Domain
|
||||
let testDomain: smartstring.Domain;
|
||||
let testDomain2: smartstring.Domain;
|
||||
tap.test('expect create a new Domain object', async () => {
|
||||
testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
|
||||
expect(testDomain).be.instanceof(smartstring.Domain);
|
||||
console.log(testDomain);
|
||||
});
|
||||
tap.test('expect have a .topLevel', async () => {
|
||||
expect(testDomain.topLevel).equal('level1D');
|
||||
});
|
||||
tap.test('expect have a .level2', async () => {
|
||||
expect(testDomain.level2).equal('level2D');
|
||||
});
|
||||
tap.test('expect have a .level3', async () => {
|
||||
expect(testDomain.level3).equal('level3D');
|
||||
});
|
||||
tap.test('expect have the correct dns zone name', async () => {
|
||||
expect(testDomain.zoneName).equal('level2D.level1D');
|
||||
});
|
||||
tap.test('expect have the correct protocol', async () => {
|
||||
expect(testDomain.protocol).equal('https');
|
||||
});
|
||||
tap.test('testDomain2 expect be a basic domain', async () => {
|
||||
testDomain2 = new smartstring.Domain('bleu.de');
|
||||
console.log(testDomain2);
|
||||
});
|
||||
|
||||
tap.start();
|
26
test/test.git.ts
Normal file
26
test/test.git.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import * as smartstring from '../ts/index';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
// git
|
||||
let testGit: smartstring.GitRepo;
|
||||
tap.test('expect create a new Git class GitRepo', async () => {
|
||||
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git');
|
||||
expect(testGit).be.instanceof(smartstring.GitRepo);
|
||||
});
|
||||
tap.test('expect return a .host', async () => {
|
||||
expect(testGit.host).equal('github.com');
|
||||
});
|
||||
tap.test('expect return a .user', async () => {
|
||||
expect(testGit.user).equal('pushrocks');
|
||||
});
|
||||
tap.test('expect return a .repo', async () => {
|
||||
expect(testGit.repo).equal('smartstring');
|
||||
});
|
||||
tap.test('expect return a .httpsUrl', async () => {
|
||||
expect(testGit.httpsUrl).equal('https://github.com/pushrocks/smartstring.git');
|
||||
});
|
||||
tap.test('expect return a .sshUrl', async () => {
|
||||
expect(testGit.sshUrl).equal('git@github.com:pushrocks/smartstring.git');
|
||||
});
|
||||
|
||||
tap.start();
|
28
test/test.indent.ts
Normal file
28
test/test.indent.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as smartstring from '../ts/index';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
// indent
|
||||
let testString = `
|
||||
base
|
||||
expect be indented
|
||||
some more
|
||||
|
||||
base
|
||||
indented
|
||||
`;
|
||||
|
||||
// normalize
|
||||
tap.test('expect normalize a string', async () => {
|
||||
testString = smartstring.indent.normalize(testString);
|
||||
console.log(testString);
|
||||
let zoneNameArg = 'test1';
|
||||
let destinationIpArg = '111';
|
||||
});
|
||||
|
||||
// indent with prefix
|
||||
tap.test('expect indent', async () => {
|
||||
testString = smartstring.indent.indentWithPrefix(testString, '>> ');
|
||||
console.log(testString);
|
||||
});
|
||||
|
||||
tap.start();
|
115
test/test.js
115
test/test.js
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,QAAQ,EAAC;QACd,IAAI,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAClF,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2BAA2B,EAAC;YAC3B,OAAO,CAAC,QAAQ;iBACX,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,yBAAyB,EAAC;YACzB,OAAO,CAAC,MAAM;iBACT,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,SAAS,EAAC;QACf,QAAQ,CAAC,gBAAgB,EAAC;YACtB,EAAE,CAAC,4BAA4B,EAAC;gBAC5B,IAAI,cAAc,GAAG,CAAC,6BAA6B,EAAC,8BAA8B,CAAC,CAAC;gBACpF,IAAI,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;gBACjE,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBACtD,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}
|
115
test/test.ts
115
test/test.ts
@ -1,115 +0,0 @@
|
||||
import 'typings-test'
|
||||
import * as smartstring from '../dist/index'
|
||||
import * as should from 'should'
|
||||
|
||||
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 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('.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)
|
||||
})
|
||||
})
|
||||
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('.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()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
19
ts/index.ts
19
ts/index.ts
@ -1,13 +1,10 @@
|
||||
import * as docker from './smartstring.docker'
|
||||
import * as indent from './smartstring.indent'
|
||||
import * as typescript from './smartstring.typescript'
|
||||
import * as create from './smartstring.create';
|
||||
import * as docker from './smartstring.docker';
|
||||
import * as indent from './smartstring.indent';
|
||||
import * as normalize from './smartstring.normalize';
|
||||
|
||||
export {
|
||||
docker,
|
||||
typescript,
|
||||
indent
|
||||
}
|
||||
export { create, docker, normalize, indent };
|
||||
|
||||
export { Base64, base64 } from './smartstring.base64'
|
||||
export { Domain } from './smartstring.domain'
|
||||
export { GitRepo } from './smartstring.git'
|
||||
export { Base64, base64 } from './smartstring.base64';
|
||||
export { Domain } from './smartstring.domain';
|
||||
export { GitRepo } from './smartstring.git';
|
||||
|
@ -1,69 +1,69 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
import * as plugins from './smartstring.plugins';
|
||||
|
||||
/**
|
||||
* the type for base 64
|
||||
*/
|
||||
export type TBase64Input = 'string' | 'base64' | 'base64uri'
|
||||
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)
|
||||
}
|
||||
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 simple string (unencoded)
|
||||
*/
|
||||
get simpleString() {
|
||||
return this.refString;
|
||||
}
|
||||
|
||||
/**
|
||||
* the base64 encoded version of the original string
|
||||
*/
|
||||
get base64String() {
|
||||
return base64.encode(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)
|
||||
}
|
||||
/**
|
||||
* the base64uri encoded version of the original string
|
||||
*/
|
||||
get base64UriString() {
|
||||
return base64.encodeUri(this.refString);
|
||||
}
|
||||
}
|
||||
|
||||
export let base64 = {
|
||||
/**
|
||||
* encodes the string
|
||||
*/
|
||||
encode: (stringArg: string) => {
|
||||
return plugins.jsBase64.encode(stringArg)
|
||||
},
|
||||
/**
|
||||
* 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)
|
||||
},
|
||||
/**
|
||||
* 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)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* decodes a base64 encoded string
|
||||
*/
|
||||
decode: (stringArg: string) => {
|
||||
return plugins.jsBase64.decode(stringArg);
|
||||
}
|
||||
};
|
||||
|
13
ts/smartstring.create.ts
Normal file
13
ts/smartstring.create.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import * as plugins from './smartstring.plugins';
|
||||
|
||||
export const createRandomString = (
|
||||
patternArg: string,
|
||||
lengthArg: number,
|
||||
optionsArg: any
|
||||
): string => {
|
||||
return plugins.randomatic(patternArg, lengthArg, optionsArg);
|
||||
};
|
||||
|
||||
export const createCryptoRandomString = (lengthArg): string => {
|
||||
return plugins.cryptoRandomString(lengthArg);
|
||||
};
|
@ -1,18 +1,18 @@
|
||||
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.
|
||||
* @param envArrayArg
|
||||
* @returns {}
|
||||
*/
|
||||
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]
|
||||
};
|
||||
export const 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
|
||||
}
|
||||
}
|
||||
return returnObject;
|
||||
};
|
||||
|
@ -1,62 +1,61 @@
|
||||
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
|
||||
constructor(domainStringArg:string){
|
||||
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
|
||||
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]) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
|
||||
return(stringArg !== '')
|
||||
});
|
||||
return regexMatchesFiltered
|
||||
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 regexMatchesFiltered = regexMatches.filter(function(stringArg: string) {
|
||||
return stringArg !== '';
|
||||
});
|
||||
return regexMatchesFiltered;
|
||||
};
|
||||
|
||||
let protocolRegex = function(stringArg:string){
|
||||
let regexString = /^([a-zA-Z0-9]*):\/\//
|
||||
let regexMatches = regexString.exec(stringArg)
|
||||
if(regexMatches) {
|
||||
return regexMatches[1]
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
let protocolRegex = function(stringArg: string) {
|
||||
let regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||
let regexMatches = regexString.exec(stringArg);
|
||||
if (regexMatches) {
|
||||
return regexMatches[1];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
@ -1,52 +1,56 @@
|
||||
import * as plugins from './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
|
||||
}
|
||||
const gitRegex = function(stringArg: string) {
|
||||
const 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 + '@'
|
||||
}
|
||||
switch (linkTypeArg) {
|
||||
case 'https':
|
||||
returnString = 'https://' +
|
||||
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git'
|
||||
break
|
||||
case 'ssh':
|
||||
returnString = 'git@' +
|
||||
hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||
break
|
||||
default:
|
||||
console.error('Link Type ' + linkTypeArg + ' not known')
|
||||
break
|
||||
}
|
||||
return returnString
|
||||
}
|
||||
const gitLink = function(
|
||||
hostArg: string,
|
||||
userArg: string,
|
||||
repoArg: string,
|
||||
tokenArg: string = '',
|
||||
linkTypeArg
|
||||
): string {
|
||||
let returnString;
|
||||
if (tokenArg !== '') {
|
||||
tokenArg = tokenArg + '@';
|
||||
}
|
||||
switch (linkTypeArg) {
|
||||
case 'https':
|
||||
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
|
||||
break;
|
||||
case 'ssh':
|
||||
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||
break;
|
||||
default:
|
||||
console.error('Link Type ' + linkTypeArg + ' not known');
|
||||
break;
|
||||
}
|
||||
return returnString;
|
||||
};
|
||||
|
@ -1,64 +1,92 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
import * as plugins from './smartstring.plugins';
|
||||
|
||||
let splitString = (stringArg: string): string[] => {
|
||||
let resultArray = stringArg.split('\n')
|
||||
return cleanStringArray(resultArray)
|
||||
/**
|
||||
* splits a string into an array
|
||||
* @param stringArg
|
||||
*/
|
||||
const splitStringAtLineBreak = (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'
|
||||
/**
|
||||
* joins a string together again
|
||||
* @param stringArrayArg
|
||||
*/
|
||||
const joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
|
||||
let resultString: string = '';
|
||||
for (let line of stringArrayArg) {
|
||||
resultString = resultString + line + '\n'; // add new line at end
|
||||
}
|
||||
return resultString;
|
||||
};
|
||||
|
||||
/**
|
||||
* cleans first and last line in case they are empty
|
||||
* @param stringArrayArg
|
||||
*/
|
||||
const 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* indent an array
|
||||
* @param stringArg
|
||||
* @param spaceAmount
|
||||
*/
|
||||
export const indent = (stringArg: string, spaceAmount: number): string => {
|
||||
let localStringArray = splitStringAtLineBreak(stringArg);
|
||||
for (let stringArg of localStringArray) {
|
||||
stringArg = ' '.repeat(spaceAmount) + stringArg;
|
||||
}
|
||||
let resultString = joinStringWithLineBreaks(localStringArray);
|
||||
return resultString;
|
||||
};
|
||||
|
||||
/**
|
||||
* indents a string with prefix
|
||||
* @param stringArg
|
||||
* @param prefixArg
|
||||
*/
|
||||
export const indentWithPrefix = (stringArg: string, prefixArg: string): string => {
|
||||
let resultString: string;
|
||||
let stringArray = splitStringAtLineBreak(stringArg);
|
||||
let resultArray: string[] = [];
|
||||
for (let stringItem of stringArray) {
|
||||
resultArray.push(prefixArg + stringItem);
|
||||
}
|
||||
resultString = joinStringWithLineBreaks(resultArray);
|
||||
return resultString;
|
||||
};
|
||||
|
||||
export const normalize = (stringArg: string): string => {
|
||||
let resultString: string;
|
||||
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
|
||||
let minCommonLeftOffset: number;
|
||||
|
||||
const deIndentRegex = /^(\s*)/;
|
||||
const 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;
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
let resultSplitStringArray = [];
|
||||
for (let stringItem of splitStringArray) {
|
||||
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
||||
}
|
||||
resultString = joinStringWithLineBreaks(resultSplitStringArray);
|
||||
return resultString;
|
||||
};
|
||||
|
22
ts/smartstring.normalize.ts
Normal file
22
ts/smartstring.normalize.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import * as plugins from './smartstring.plugins';
|
||||
|
||||
/**
|
||||
* replaces all occurences of something in a string
|
||||
* @param stringArg
|
||||
* @param searchRegExp
|
||||
* @param replacementString
|
||||
*/
|
||||
export const replaceAll = (stringArg: string, searchRegExp: any, replacementString: string) => {
|
||||
return stringArg.replace(new RegExp(searchRegExp, 'g'), replacementString);
|
||||
};
|
||||
|
||||
/**
|
||||
* normalizes a string
|
||||
* @param stringArg
|
||||
*/
|
||||
export const standard = (stringArg: string): string => {
|
||||
let fix1 = plugins.stripIndent(stringArg); // fix indention
|
||||
let fix2 = plugins.normalizeNewline(fix1); // fix newlines
|
||||
let fix3 = replaceAll(fix2, /\t/, ' '); // fix tabs
|
||||
return fix3;
|
||||
};
|
@ -1,2 +1,6 @@
|
||||
import 'typings-global'
|
||||
export let jsBase64 = require('js-base64').Base64
|
||||
export let jsBase64 = require('js-base64').Base64;
|
||||
|
||||
export let stripIndent = require('strip-indent');
|
||||
export let normalizeNewline = require('normalize-newline');
|
||||
export let randomatic = require('randomatic');
|
||||
export let cryptoRandomString = require('crypto-random-string');
|
||||
|
@ -1,3 +0,0 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
|
||||
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
Reference in New Issue
Block a user