Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
a57bd446d0 | |||
afe8d5bc1b | |||
576e81588d | |||
76c590b045 | |||
bb7caa36ea | |||
a3a51bf0ca | |||
1684eae1e8 | |||
39ce541532 | |||
c2a4f05b33 | |||
3858127968 | |||
68d0124c24 | |||
16f41a7d63 | |||
d13dfc9e76 | |||
942f6b37cf | |||
211c7c3308 | |||
a55d6d2221 | |||
98ca73d0c7 | |||
ffedc7f601 | |||
8344fdf7b1 | |||
543dc98961 |
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,7 +1,4 @@
|
|||||||
.idea/
|
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
pages/
|
||||||
node_modules
|
public/
|
||||||
ts/**/*.js
|
node_modules/
|
||||||
ts/**/*.js.map
|
|
||||||
ts/typings/
|
|
||||||
|
@ -3,6 +3,8 @@ image: hosttoday/ht-docker-node:npmts
|
|||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
|
- trigger
|
||||||
|
- pages
|
||||||
|
|
||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
@ -10,6 +12,7 @@ testLEGACY:
|
|||||||
- npmci test legacy
|
- npmci test legacy
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
@ -33,3 +36,24 @@ release:
|
|||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: trigger
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-node:npmpage
|
||||||
|
stage: pages
|
||||||
|
script:
|
||||||
|
- npmci command npmpage --host gitlab
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
51
README.md
51
README.md
@ -1,18 +1,38 @@
|
|||||||
# smartstring
|
# smartstring
|
||||||
handle strings in smart ways. TypeScript ready.
|
handle strings in smart ways. TypeScript ready.
|
||||||
|
|
||||||
## Status
|
## Availabililty
|
||||||
[](https://travis-ci.org/pushrocks/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://david-dm.org/pushrocks/smartstring)
|
[](https://david-dm.org/pushrocks/smartstring)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartstring)
|
[](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
|
## Usage
|
||||||
Use TypeScript for intellisense.
|
Use TypeScript for intellisense.
|
||||||
|
|
||||||
```typescript
|
```javascript
|
||||||
import * as smartstring from "smartstring";
|
import * as smartstring from "smartstring";
|
||||||
|
|
||||||
|
// classes
|
||||||
|
|
||||||
|
// smartstring.Domain class
|
||||||
|
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"
|
||||||
|
|
||||||
// smartstring.GitRepo class
|
// smartstring.GitRepo class
|
||||||
let myGitRepo = new smartstring.GitRepo("git@github.com:someorg/somerepo.git"); // takes https and git and npm repo URL versions
|
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.host // "github.com"
|
||||||
@ -22,17 +42,20 @@ myGitRepo.accessToken // accessToken if specified with https
|
|||||||
myGitRepo.sshUrl // "git@github.com:someorg/somerepo.git" (computed also from 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)
|
myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh)
|
||||||
|
|
||||||
// smartstring.Domain class
|
//smartstring.Base64
|
||||||
let myDomain = new smartstring.Domain("https://sub.main.tld");
|
let myBase64 = new smartstring.Base64('somestring','string') // first arg is the string, second is string type (can be string, base64, base64uri)
|
||||||
myDomain.level1 // "tld"
|
myBase64.simpleString // 'somestring'
|
||||||
myDomain.level2 // "main"
|
myBase64.base64String // base64 representation of 'somestring'
|
||||||
// level3 , level 4 and so on...
|
myBase64.base64UriString // base64uri representation of 'sometring'
|
||||||
myDomain.zoneName // "main.tld"
|
|
||||||
myDOmain.protocol // "https"
|
|
||||||
|
|
||||||
|
// 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('somestring\anotherstring', 4) // indents a string by 4
|
||||||
|
smartstring.indent.indent('somestring\anotherstring', '>>>> ') // indents a string with a prefix
|
||||||
|
smartstring.indent.normalize(' somestring\ anotherstring', '>>>> ') // looks for the least amount of indention and removes superflouous space
|
||||||
```
|
```
|
||||||
|
|
||||||
## About the authors:
|
[](https://push.rocks)
|
||||||
[](https://lossless.com/)
|
|
||||||
|
|
||||||
[](https://paypal.me/lossless)
|
|
||||||
|
15
dist/index.d.ts
vendored
15
dist/index.d.ts
vendored
@ -1,8 +1,7 @@
|
|||||||
import * as SmartstringDocker from "./smartstring.docker";
|
import * as docker from './smartstring.docker';
|
||||||
import * as SmartstringTypescript from "./smartstring.typescript";
|
import * as indent from './smartstring.indent';
|
||||||
import * as SmartstringIndent from "./smartstring.indent";
|
import * as typescript from './smartstring.typescript';
|
||||||
export { Domain } from "./smartstring.domain";
|
export { docker, typescript, indent };
|
||||||
export { GitRepo } from "./smartstring.git";
|
export { Base64, base64 } from './smartstring.base64';
|
||||||
export declare let docker: typeof SmartstringDocker;
|
export { Domain } from './smartstring.domain';
|
||||||
export declare let typescript: typeof SmartstringTypescript;
|
export { GitRepo } from './smartstring.git';
|
||||||
export declare let indent: typeof SmartstringIndent;
|
|
||||||
|
17
dist/index.js
vendored
17
dist/index.js
vendored
@ -1,12 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var SmartstringDocker = require("./smartstring.docker");
|
const docker = require("./smartstring.docker");
|
||||||
var SmartstringTypescript = require("./smartstring.typescript");
|
exports.docker = docker;
|
||||||
var SmartstringIndent = require("./smartstring.indent");
|
const indent = require("./smartstring.indent");
|
||||||
|
exports.indent = indent;
|
||||||
|
const typescript = require("./smartstring.typescript");
|
||||||
|
exports.typescript = typescript;
|
||||||
|
var smartstring_base64_1 = require("./smartstring.base64");
|
||||||
|
exports.Base64 = smartstring_base64_1.Base64;
|
||||||
|
exports.base64 = smartstring_base64_1.base64;
|
||||||
var smartstring_domain_1 = require("./smartstring.domain");
|
var smartstring_domain_1 = require("./smartstring.domain");
|
||||||
exports.Domain = smartstring_domain_1.Domain;
|
exports.Domain = smartstring_domain_1.Domain;
|
||||||
var smartstring_git_1 = require("./smartstring.git");
|
var smartstring_git_1 = require("./smartstring.git");
|
||||||
exports.GitRepo = smartstring_git_1.GitRepo;
|
exports.GitRepo = smartstring_git_1.GitRepo;
|
||||||
exports.docker = SmartstringDocker;
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQXFEO0FBQTVDLHNDQUFBLE1BQU0sQ0FBQTtBQUFFLHNDQUFBLE1BQU0sQ0FBQTtBQUN2QiwyREFBNkM7QUFBcEMsc0NBQUEsTUFBTSxDQUFBO0FBQ2YscURBQTJDO0FBQWxDLG9DQUFBLE9BQU8sQ0FBQSJ9
|
||||||
exports.typescript = SmartstringTypescript;
|
|
||||||
exports.indent = SmartstringIndent;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsSUFBWSxpQkFBaUIsV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQzFELElBQVkscUJBQXFCLFdBQU0sMEJBQTBCLENBQUMsQ0FBQTtBQUNsRSxJQUFZLGlCQUFpQixXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFFMUQsbUNBQXFCLHNCQUFzQixDQUFDO0FBQXBDLDZDQUFvQztBQUM1QyxnQ0FBc0IsbUJBQW1CLENBQUM7QUFBbEMsNENBQWtDO0FBQy9CLGNBQU0sR0FBRyxpQkFBaUIsQ0FBQztBQUMzQixrQkFBVSxHQUFHLHFCQUFxQixDQUFDO0FBQ25DLGNBQU0sR0FBRyxpQkFBaUIsQ0FBQyJ9
|
|
28
dist/smartstring.base64.d.ts
vendored
Normal file
28
dist/smartstring.base64.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* the type for base 64
|
||||||
|
*/
|
||||||
|
export declare type TBase64Input = 'string' | 'base64' | 'base64uri';
|
||||||
|
/**
|
||||||
|
* handle base64 strings
|
||||||
|
*/
|
||||||
|
export declare class Base64 {
|
||||||
|
private refString;
|
||||||
|
constructor(inputStringArg: any, typeArg: TBase64Input);
|
||||||
|
/**
|
||||||
|
* the simple string (unencoded)
|
||||||
|
*/
|
||||||
|
readonly simpleString: string;
|
||||||
|
/**
|
||||||
|
* the base64 encoded version of the original string
|
||||||
|
*/
|
||||||
|
readonly base64String: any;
|
||||||
|
/**
|
||||||
|
* the base64uri encoded version of the original string
|
||||||
|
*/
|
||||||
|
readonly base64UriString: any;
|
||||||
|
}
|
||||||
|
export declare let base64: {
|
||||||
|
encode: (stringArg: string) => any;
|
||||||
|
encodeUri: (stringArg: string) => any;
|
||||||
|
decode: (stringArg: string) => any;
|
||||||
|
};
|
59
dist/smartstring.base64.js
vendored
Normal file
59
dist/smartstring.base64.js
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
"use strict";
|
||||||
|
const plugins = require("./smartstring.plugins");
|
||||||
|
/**
|
||||||
|
* handle base64 strings
|
||||||
|
*/
|
||||||
|
class Base64 {
|
||||||
|
constructor(inputStringArg, typeArg) {
|
||||||
|
switch (typeArg) {
|
||||||
|
case 'string':
|
||||||
|
this.refString = inputStringArg;
|
||||||
|
break;
|
||||||
|
case 'base64':
|
||||||
|
this.refString = exports.base64.decode(inputStringArg);
|
||||||
|
break;
|
||||||
|
case 'base64uri':
|
||||||
|
this.refString = exports.base64.decode(inputStringArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* the simple string (unencoded)
|
||||||
|
*/
|
||||||
|
get simpleString() {
|
||||||
|
return this.refString;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* the base64 encoded version of the original string
|
||||||
|
*/
|
||||||
|
get base64String() {
|
||||||
|
return exports.base64.encode(this.refString);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* the base64uri encoded version of the original string
|
||||||
|
*/
|
||||||
|
get base64UriString() {
|
||||||
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUF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7SUFDN0MsQ0FBQztDQUNKLENBQUEifQ==
|
12
dist/smartstring.docker.js
vendored
12
dist/smartstring.docker.js
vendored
@ -5,13 +5,15 @@
|
|||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
exports.makeEnvObject = function (envArrayArg) {
|
exports.makeEnvObject = function (envArrayArg) {
|
||||||
var returnObject = {};
|
let returnObject = {};
|
||||||
var regexString = /(.*)=(.*)/;
|
let regexString = /(.*)=(.*)/;
|
||||||
for (var envKey in envArrayArg) {
|
if (typeof envArrayArg !== 'undefined') {
|
||||||
var regexMatches = regexString.exec(envArrayArg[envKey]);
|
for (let envKey in envArrayArg) {
|
||||||
|
let regexMatches = regexString.exec(envArrayArg[envKey]);
|
||||||
returnObject[regexMatches[1]] = regexMatches[2];
|
returnObject[regexMatches[1]] = regexMatches[2];
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
}
|
||||||
return returnObject;
|
return returnObject;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EscUJBQWEsR0FBRyxVQUFTLFdBQW9CO0lBQ3BELElBQUksWUFBWSxHQUFHLEVBQUUsQ0FBQztJQUN0QixJQUFJLFdBQVcsR0FBRyxXQUFXLENBQUM7SUFDOUIsR0FBRyxDQUFBLENBQUMsSUFBSSxNQUFNLElBQUksV0FBVyxDQUFDLENBQUEsQ0FBQztRQUMzQixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDO1FBQ3pELFlBQVksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEQsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsVUFBVSxXQUFxQjtJQUN0RCxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUE7SUFDckIsSUFBSSxXQUFXLEdBQUcsV0FBVyxDQUFBO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sV0FBVyxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDckMsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksV0FBVyxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBO1lBQ3hELFlBQVksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkQsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==
|
43
dist/smartstring.domain.js
vendored
43
dist/smartstring.domain.js
vendored
@ -1,48 +1,47 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var Domain = (function () {
|
class Domain {
|
||||||
function Domain(domainStringArg) {
|
constructor(domainStringArg) {
|
||||||
var regexMatches = domainRegex(domainStringArg);
|
let regexMatches = domainRegex(domainStringArg);
|
||||||
this.fullName = "";
|
this.fullName = '';
|
||||||
for (var i = 1; i <= 5; i++) {
|
for (let i = 1; i <= 5; i++) {
|
||||||
if (regexMatches[i - 1]) {
|
if (regexMatches[i - 1]) {
|
||||||
var localMatch = regexMatches[i - 1];
|
let localMatch = regexMatches[i - 1];
|
||||||
this["level" + i.toString()] = localMatch;
|
this['level' + i.toString()] = localMatch;
|
||||||
if (this.fullName == "") {
|
if (this.fullName === '') {
|
||||||
this.fullName = localMatch;
|
this.fullName = localMatch;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.fullName = localMatch + "." + this.fullName;
|
this.fullName = localMatch + '.' + this.fullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this["level" + i.toString()] = undefined;
|
this['level' + i.toString()] = undefined;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
this.protocol = protocolRegex(domainStringArg);
|
this.protocol = protocolRegex(domainStringArg);
|
||||||
this.zoneName = this.level2 + "." + this.level1;
|
this.zoneName = this.level2 + '.' + this.level1;
|
||||||
// aliases
|
// aliases
|
||||||
this.topLevel = this.level1;
|
this.topLevel = this.level1;
|
||||||
this.domainName = this.level2;
|
this.domainName = this.level2;
|
||||||
this.subDomain = this.level3;
|
this.subDomain = this.level3;
|
||||||
}
|
}
|
||||||
return Domain;
|
}
|
||||||
}());
|
|
||||||
exports.Domain = Domain;
|
exports.Domain = Domain;
|
||||||
var domainRegex = function (stringArg) {
|
let 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}$/;
|
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}$/;
|
||||||
var regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg);
|
||||||
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
|
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
|
||||||
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
||||||
var regexMatchesFiltered = regexMatches.filter(function (stringArg) {
|
let regexMatchesFiltered = regexMatches.filter(function (stringArg) {
|
||||||
return (stringArg != "");
|
return (stringArg !== '');
|
||||||
});
|
});
|
||||||
return regexMatchesFiltered;
|
return regexMatchesFiltered;
|
||||||
};
|
};
|
||||||
var protocolRegex = function (stringArg) {
|
let protocolRegex = function (stringArg) {
|
||||||
var regexString = /^([a-zA-Z0-9]*):\/\//;
|
let regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||||
var regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg);
|
||||||
if (regexMatches) {
|
if (regexMatches) {
|
||||||
return regexMatches[1];
|
return regexMatches[1];
|
||||||
}
|
}
|
||||||
@ -50,4 +49,4 @@ var protocolRegex = function (stringArg) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9tYWluLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTtJQWFJLGdCQUFZLGVBQXNCO1FBQzlCLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FB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FTLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDNUIsQ0FBQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsb0JBQW9CLENBQUE7QUFDL0IsQ0FBQyxDQUFDO0FBRUYsSUFBSSxhQUFhLEdBQUcsVUFBUyxTQUFnQjtJQUN6QyxJQUFJLFdBQVcsR0FBRyxzQkFBc0IsQ0FBQTtJQUN4QyxJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQzlDLEVBQUUsQ0FBQSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7UUFDZCxNQUFNLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzFCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQSJ9
|
46
dist/smartstring.git.js
vendored
46
dist/smartstring.git.js
vendored
@ -1,49 +1,45 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var plugins = require("./smartstring.plugins");
|
|
||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ classes ------------------- *
|
* ------------------ classes ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
var GitRepo = (function () {
|
class GitRepo {
|
||||||
function GitRepo(stringArg, tokenArg) {
|
constructor(stringArg, tokenArg) {
|
||||||
var regexMatches = gitRegex(stringArg);
|
let regexMatches = gitRegex(stringArg);
|
||||||
this.host = regexMatches[1];
|
this.host = regexMatches[1];
|
||||||
this.user = regexMatches[2];
|
this.user = regexMatches[2];
|
||||||
this.repo = regexMatches[3];
|
this.repo = regexMatches[3];
|
||||||
this.accessToken = tokenArg;
|
this.accessToken = tokenArg;
|
||||||
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "ssh");
|
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
|
||||||
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "https");
|
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return GitRepo;
|
|
||||||
}());
|
|
||||||
exports.GitRepo = GitRepo;
|
exports.GitRepo = GitRepo;
|
||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ helpers ------------------- *
|
* ------------------ helpers ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
var gitRegex = function (stringArg) {
|
let gitRegex = function (stringArg) {
|
||||||
var regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
|
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
|
||||||
var regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg);
|
||||||
return regexMatches;
|
return regexMatches;
|
||||||
};
|
};
|
||||||
var gitLink = function (hostArg, userArg, repoArg, tokenArg, linkTypeArg) {
|
let gitLink = function (hostArg, userArg, repoArg, tokenArg = '', linkTypeArg) {
|
||||||
if (tokenArg === void 0) { tokenArg = ""; }
|
let returnString;
|
||||||
var returnString;
|
if (tokenArg !== '') {
|
||||||
if (tokenArg !== "") {
|
tokenArg = tokenArg + '@';
|
||||||
tokenArg = tokenArg + "@";
|
|
||||||
}
|
}
|
||||||
switch (linkTypeArg) {
|
switch (linkTypeArg) {
|
||||||
case "https":
|
case 'https':
|
||||||
returnString = "https://" +
|
returnString = 'https://' +
|
||||||
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
|
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
|
||||||
break;
|
break;
|
||||||
case "ssh":
|
case 'ssh':
|
||||||
returnString = "git@" +
|
returnString = 'git@' +
|
||||||
hostArg + ":" + userArg + "/" + repoArg + ".git";
|
hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
|
console.error('Link Type ' + linkTypeArg + ' not known');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return returnString;
|
return returnString;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZ2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZ2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSx1QkFBdUIsQ0FBQyxDQUFBO0FBRWpEOztvREFFb0Q7QUFDcEQ7SUFPSSxpQkFBWSxTQUFnQixFQUFDLFFBQWdCO1FBQ3pDLElBQUksWUFBWSxHQUFHLFFBQVEsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUN2QyxJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsSUFBSSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM1QixJQUFJLENBQUMsV0FBVyxHQUFHLFFBQVEsQ0FBQztRQUM1QixJQUFJLENBQUMsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFDLElBQUksQ0FBQyxJQUFJLEVBQUMsSUFBSSxDQUFDLElBQUksRUFBQyxJQUFJLENBQUMsV0FBVyxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBQzdFLElBQUksQ0FB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BQztZQUNyRCxLQUFLLENBQUE7UUFDVDtZQUNJLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxHQUFHLFdBQVcsR0FBRyxZQUFZLENBQUMsQ0FBQTtZQUN4RCxLQUFLLENBQUE7SUFDYixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==
|
2
dist/smartstring.indent.d.ts
vendored
2
dist/smartstring.indent.d.ts
vendored
@ -1,3 +1,3 @@
|
|||||||
export declare let indent: (stringArg: string, spaceAmount: number) => string;
|
export declare let indent: (stringArg: string, spaceAmount: number) => string;
|
||||||
export declare let indentWithPrefix: (stringArg: string, prefixArg: string) => string;
|
export declare let indentWithPrefix: (stringArg: string, prefixArg: string) => string;
|
||||||
export declare let normalizeIndent: (stringArg: string) => string;
|
export declare let normalize: (stringArg: string) => string;
|
||||||
|
60
dist/smartstring.indent.js
vendored
60
dist/smartstring.indent.js
vendored
@ -1,19 +1,17 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var splitString = function (stringArg) {
|
let splitString = (stringArg) => {
|
||||||
var resultArray = stringArg.split("\n");
|
let resultArray = stringArg.split('\n');
|
||||||
return cleanStringArray(resultArray);
|
return cleanStringArray(resultArray);
|
||||||
};
|
};
|
||||||
var joinString = function (stringArrayArg) {
|
let joinString = (stringArrayArg) => {
|
||||||
var resultString = "";
|
let resultString = '';
|
||||||
for (var _i = 0, stringArrayArg_1 = stringArrayArg; _i < stringArrayArg_1.length; _i++) {
|
for (let line of stringArrayArg) {
|
||||||
var line = stringArrayArg_1[_i];
|
resultString = resultString + line + '\n';
|
||||||
resultString = resultString + line + "\n";
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return resultString;
|
return resultString;
|
||||||
};
|
};
|
||||||
var cleanStringArray = function (stringArrayArg) {
|
let cleanStringArray = (stringArrayArg) => {
|
||||||
var testRegex = /^[\s]*$/;
|
let testRegex = /^[\s]*$/;
|
||||||
if (testRegex.test(stringArrayArg[0])) {
|
if (testRegex.test(stringArrayArg[0])) {
|
||||||
stringArrayArg.shift();
|
stringArrayArg.shift();
|
||||||
}
|
}
|
||||||
@ -23,43 +21,41 @@ var cleanStringArray = function (stringArrayArg) {
|
|||||||
;
|
;
|
||||||
return stringArrayArg;
|
return stringArrayArg;
|
||||||
};
|
};
|
||||||
exports.indent = function (stringArg, spaceAmount) {
|
exports.indent = (stringArg, spaceAmount) => {
|
||||||
var resultString;
|
let resultString;
|
||||||
return resultString;
|
return resultString;
|
||||||
};
|
};
|
||||||
exports.indentWithPrefix = function (stringArg, prefixArg) {
|
exports.indentWithPrefix = (stringArg, prefixArg) => {
|
||||||
var resultString;
|
let resultString;
|
||||||
var stringArray = splitString(stringArg);
|
let stringArray = splitString(stringArg);
|
||||||
var resultArray = [];
|
let resultArray = [];
|
||||||
for (var _i = 0, stringArray_1 = stringArray; _i < stringArray_1.length; _i++) {
|
for (let stringItem of stringArray) {
|
||||||
var stringItem = stringArray_1[_i];
|
|
||||||
resultArray.push(prefixArg + stringItem);
|
resultArray.push(prefixArg + stringItem);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
resultString = joinString(resultArray);
|
resultString = joinString(resultArray);
|
||||||
return resultString;
|
return resultString;
|
||||||
};
|
};
|
||||||
exports.normalizeIndent = function (stringArg) {
|
exports.normalize = (stringArg) => {
|
||||||
var resultString;
|
let resultString;
|
||||||
var splitStringArray = splitString(stringArg);
|
let splitStringArray = splitString(stringArg);
|
||||||
var minCommonLeftOffset;
|
let minCommonLeftOffset;
|
||||||
var deIndentRegex = /^(\s*)/;
|
let deIndentRegex = /^(\s*)/;
|
||||||
for (var _i = 0, splitStringArray_1 = splitStringArray; _i < splitStringArray_1.length; _i++) {
|
let emptyLineRegex = /^(\s*)$/;
|
||||||
var stringItem = splitStringArray_1[_i];
|
for (let stringItem of splitStringArray) {
|
||||||
var offsetString = deIndentRegex.exec(stringItem)[1];
|
let offsetString = deIndentRegex.exec(stringItem)[1];
|
||||||
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset) {
|
if ((typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
|
||||||
|
&& !emptyLineRegex.test(stringItem)) {
|
||||||
minCommonLeftOffset = offsetString.length;
|
minCommonLeftOffset = offsetString.length;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
var resultSplitStringArray = [];
|
let resultSplitStringArray = [];
|
||||||
for (var _a = 0, splitStringArray_2 = splitStringArray; _a < splitStringArray_2.length; _a++) {
|
for (let stringItem of splitStringArray) {
|
||||||
var stringItem = splitStringArray_2[_a];
|
|
||||||
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
resultString = joinString(resultSplitStringArray);
|
resultString = joinString(resultSplitStringArray);
|
||||||
return resultString;
|
return resultString;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxVQUFDLFNBQWdCO0lBQy9CLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDeEMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ3pDLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLFVBQUMsY0FBdUI7SUFDckMsSUFBSSxZQUFZLEdBQVUsRUFBRSxDQUFDO0lBQzdCLEdBQUcsQ0FBQSxDQUFhLFVBQWMsRUFBZCxpQ0F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BQUMsQ0FBQSJ9
|
4
dist/smartstring.plugins.d.ts
vendored
4
dist/smartstring.plugins.d.ts
vendored
@ -1,2 +1,2 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
export import beautylog = require("beautylog");
|
export declare let jsBase64: any;
|
||||||
|
4
dist/smartstring.plugins.js
vendored
4
dist/smartstring.plugins.js
vendored
@ -1,4 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.jsBase64 = require('js-base64').Base64;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUNULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMifQ==
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUNaLFFBQUEsUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUEifQ==
|
2
dist/smartstring.typescript.js
vendored
2
dist/smartstring.typescript.js
vendored
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
|
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIn0=
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartstring",
|
"name": "smartstring",
|
||||||
"version": "2.0.13",
|
"version": "2.0.22",
|
||||||
"description": "handle strings in smart ways. TypeScript ready.",
|
"description": "handle strings in smart ways. TypeScript ready.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@ -22,12 +22,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@types/should": "^8.1.30",
|
||||||
"should": "^9.0.2",
|
"beautylog": "^6.0.0",
|
||||||
"typings-test": "^1.0.1"
|
"npmts-g": "^5.2.8",
|
||||||
|
"should": "^11.1.1",
|
||||||
|
"typings-test": "^1.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^5.0.13",
|
"js-base64": "^2.1.9",
|
||||||
"typings-global": "^1.0.6"
|
"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';
|
||||||
|
140
test/test.js
140
test/test.js
File diff suppressed because one or more lines are too long
186
test/test.ts
186
test/test.ts
@ -1,105 +1,115 @@
|
|||||||
import "typings-test"
|
import 'typings-test'
|
||||||
import * as smartstring from "../dist/index";
|
import * as smartstring from '../dist/index'
|
||||||
let should = require("should");
|
import * as should from 'should'
|
||||||
|
|
||||||
describe("smartstring",function(){
|
describe('smartstring',function(){
|
||||||
describe(".Domain class",function(){
|
describe('.Base64 class', function(){
|
||||||
let testDomain:smartstring.Domain;
|
let testBase64: smartstring.Base64
|
||||||
let testDomain2:smartstring.Domain;
|
it('should create a valid instance of Base64', function(){
|
||||||
it("should create a new Domain object",function(){
|
testBase64 = new smartstring.Base64('somestring', 'string')
|
||||||
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
|
should(testBase64).be.instanceOf(smartstring.Base64)
|
||||||
testDomain.should.be.instanceof(smartstring.Domain);
|
|
||||||
console.log(testDomain);
|
|
||||||
});
|
|
||||||
it("should have a .topLevel",function(){
|
|
||||||
testDomain.topLevel.should.equal("level1D");
|
|
||||||
});
|
|
||||||
it("should have a .level2",function(){
|
|
||||||
testDomain.level2.should.equal("level2D");
|
|
||||||
});
|
|
||||||
it("should have a .level3",function(){
|
|
||||||
testDomain.level3.should.equal("level3D");
|
|
||||||
});
|
|
||||||
it("should have the correct dns zone name",function(){
|
|
||||||
testDomain.zoneName.should.equal("level2D.level1D");
|
|
||||||
})
|
})
|
||||||
it ("should have the correct protocol",function(){
|
it('should read output a file as base64 and base64uri', function(){
|
||||||
testDomain.protocol.should.equal("https");
|
should(testBase64.base64String).not.equal(testBase64.base64UriString)
|
||||||
})
|
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri')
|
||||||
it("testDomain2 should be a basic domain",function(){
|
should(testBase64_2.simpleString).equal(testBase64.simpleString)
|
||||||
testDomain2 = new smartstring.Domain("bleu.de");
|
|
||||||
console.log(testDomain2);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
describe(".Git class",function(){
|
|
||||||
let testGit:smartstring.GitRepo;
|
|
||||||
it("should create a new Git class GitRepo",function(){
|
|
||||||
testGit = new smartstring.GitRepo("git+https://github.com/pushrocks/smartstring.git");
|
|
||||||
testGit.should.be.instanceof(smartstring.GitRepo);
|
|
||||||
})
|
|
||||||
it("should return a .host",function(){
|
|
||||||
testGit.host
|
|
||||||
.should.equal("github.com");
|
|
||||||
});
|
|
||||||
it("should return a .user",function(){
|
|
||||||
testGit.user
|
|
||||||
.should.equal("pushrocks");
|
|
||||||
});
|
|
||||||
it("should return a .repo",function(){
|
|
||||||
testGit.repo
|
|
||||||
.should.equal("smartstring");
|
|
||||||
});
|
|
||||||
it("should return a .httpsUrl",function(){
|
|
||||||
testGit.httpsUrl
|
|
||||||
.should.equal("https://github.com/pushrocks/smartstring.git");
|
|
||||||
});
|
|
||||||
it("should return a .sshUrl",function(){
|
|
||||||
testGit.sshUrl
|
|
||||||
.should.equal("git@github.com:pushrocks/smartstring.git");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
describe(".docker",function(){
|
|
||||||
describe(".makeEnvObject",function(){
|
|
||||||
it("should create a Env Object",function(){
|
|
||||||
let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"];
|
|
||||||
let envObject:any = smartstring.docker.makeEnvObject(envStringArray);
|
|
||||||
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld");
|
|
||||||
envObject.DEFAULT_HOST.should.equal("some.domain.com");
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
describe('.Domain class',function(){
|
||||||
describe(".indent",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 = `
|
let testString = `
|
||||||
base
|
base
|
||||||
should be indented
|
should be indented
|
||||||
some more
|
some more
|
||||||
|
|
||||||
base
|
base
|
||||||
indented
|
indented
|
||||||
`;
|
`
|
||||||
describe(".normalizeIndent()",function(){
|
describe('.normalize()',function(){
|
||||||
it("should normalizeIndent a string",function(){
|
it('should normalize a string',function(){
|
||||||
testString = smartstring.indent.normalizeIndent(testString);
|
testString = smartstring.indent.normalize(testString)
|
||||||
console.log(testString);
|
console.log(testString)
|
||||||
});
|
let zoneNameArg = 'test1'
|
||||||
});
|
let destinationIpArg = '111'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe(".indentWithPrefix",function(){
|
describe('.indentWithPrefix',function(){
|
||||||
it("should indent",function(){
|
it('should indent',function(){
|
||||||
testString = smartstring.indent.indentWithPrefix(testString,">> ");
|
testString = smartstring.indent.indentWithPrefix(testString,'>> ')
|
||||||
console.log(testString);
|
console.log(testString)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
describe(".typescript",function(){
|
describe('.typescript',function(){
|
||||||
describe(".referenceRegex",function(){
|
describe('.referenceRegex',function(){
|
||||||
it("should match reference paths",function(){
|
it('should match reference paths',function(){
|
||||||
smartstring.typescript.regexReferencePath.test("/// <reference path=\"\" />")
|
smartstring.typescript.regexReferencePath.test('/// <reference path=\"\" />')
|
||||||
.should.be.true();
|
.should.be.true()
|
||||||
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
|
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
|
||||||
.should.be.true();
|
.should.be.true()
|
||||||
smartstring.typescript.regexReferencePath.test("/// <referencepath=\"\" />")
|
smartstring.typescript.regexReferencePath.test('/// <referencepath=\"\" />')
|
||||||
.should.be.false();
|
.should.be.false()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
|
21
ts/index.ts
21
ts/index.ts
@ -1,10 +1,13 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as docker from './smartstring.docker'
|
||||||
import * as SmartstringDocker from "./smartstring.docker";
|
import * as indent from './smartstring.indent'
|
||||||
import * as SmartstringTypescript from "./smartstring.typescript";
|
import * as typescript from './smartstring.typescript'
|
||||||
import * as SmartstringIndent from "./smartstring.indent";
|
|
||||||
|
|
||||||
export {Domain} from "./smartstring.domain";
|
export {
|
||||||
export {GitRepo} from "./smartstring.git";
|
docker,
|
||||||
export let docker = SmartstringDocker;
|
typescript,
|
||||||
export let typescript = SmartstringTypescript;
|
indent
|
||||||
export let indent = SmartstringIndent;
|
}
|
||||||
|
|
||||||
|
export { Base64, base64 } from './smartstring.base64'
|
||||||
|
export { Domain } from './smartstring.domain'
|
||||||
|
export { GitRepo } from './smartstring.git'
|
||||||
|
69
ts/smartstring.base64.ts
Normal file
69
ts/smartstring.base64.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import * as plugins from './smartstring.plugins'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the type for base 64
|
||||||
|
*/
|
||||||
|
export type TBase64Input = 'string' | 'base64' | 'base64uri'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle base64 strings
|
||||||
|
*/
|
||||||
|
export class Base64 {
|
||||||
|
private refString: string
|
||||||
|
constructor(inputStringArg, typeArg: TBase64Input) {
|
||||||
|
switch (typeArg) {
|
||||||
|
case 'string': // easiest case
|
||||||
|
this.refString = inputStringArg
|
||||||
|
break
|
||||||
|
case 'base64':
|
||||||
|
this.refString = base64.decode(inputStringArg)
|
||||||
|
break
|
||||||
|
case 'base64uri':
|
||||||
|
this.refString = base64.decode(inputStringArg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the simple string (unencoded)
|
||||||
|
*/
|
||||||
|
get simpleString() {
|
||||||
|
return this.refString
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the base64 encoded version of the original string
|
||||||
|
*/
|
||||||
|
get base64String() {
|
||||||
|
return base64.encode(this.refString)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the base64uri encoded version of the original string
|
||||||
|
*/
|
||||||
|
get base64UriString() {
|
||||||
|
return base64.encodeUri(this.refString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let base64 = {
|
||||||
|
/**
|
||||||
|
* encodes the string
|
||||||
|
*/
|
||||||
|
encode: (stringArg: string) => {
|
||||||
|
return plugins.jsBase64.encode(stringArg)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* encodes a stringArg to base64 uri style
|
||||||
|
*/
|
||||||
|
encodeUri: (stringArg: string) => {
|
||||||
|
return plugins.jsBase64.encodeURI(stringArg)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* decodes a base64 encoded string
|
||||||
|
*/
|
||||||
|
decode: (stringArg: string) => {
|
||||||
|
return plugins.jsBase64.decode(stringArg)
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as plugins from './smartstring.plugins'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts an erray of env strings from docker remote api to an usable object.
|
* converts an erray of env strings from docker remote api to an usable object.
|
||||||
@ -6,11 +6,13 @@ import * as plugins from "./smartstring.plugins";
|
|||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
export let makeEnvObject = function (envArrayArg: string[]) {
|
export let makeEnvObject = function (envArrayArg: string[]) {
|
||||||
let returnObject = {};
|
let returnObject = {}
|
||||||
let regexString = /(.*)=(.*)/;
|
let regexString = /(.*)=(.*)/
|
||||||
|
if (typeof envArrayArg !== 'undefined') {
|
||||||
for (let envKey in envArrayArg) {
|
for (let envKey in envArrayArg) {
|
||||||
let regexMatches = regexString.exec(envArrayArg[envKey]);
|
let regexMatches = regexString.exec(envArrayArg[envKey])
|
||||||
returnObject[regexMatches[1]] = regexMatches[2];
|
returnObject[regexMatches[1]] = regexMatches[2]
|
||||||
};
|
|
||||||
return returnObject;
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
return returnObject
|
||||||
|
}
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
export class Domain {
|
export class Domain {
|
||||||
fullName:string;
|
fullName: string
|
||||||
level1:string;
|
level1: string
|
||||||
level2:string;
|
level2: string
|
||||||
level3:string;
|
level3: string
|
||||||
level4:string;
|
level4: string
|
||||||
level5:string;
|
level5: string
|
||||||
protocol:string;
|
protocol: string
|
||||||
zoneName:string;
|
zoneName: string
|
||||||
// aliases
|
// aliases
|
||||||
topLevel:string;
|
topLevel: string
|
||||||
domainName;
|
domainName
|
||||||
subDomain;
|
subDomain
|
||||||
constructor(domainStringArg:string){
|
constructor(domainStringArg:string){
|
||||||
let regexMatches = domainRegex(domainStringArg);
|
let regexMatches = domainRegex(domainStringArg);
|
||||||
this.fullName = "";
|
this.fullName = ''
|
||||||
for (let i = 1; i <= 5; i++) {
|
for (let i = 1; i <= 5; i++) {
|
||||||
if (regexMatches[i - 1]) {
|
if (regexMatches[i - 1]) {
|
||||||
let localMatch = regexMatches[i - 1]
|
let localMatch = regexMatches[i - 1]
|
||||||
this["level" + i.toString()] = localMatch;
|
this['level' + i.toString()] = localMatch
|
||||||
if (this.fullName == ""){
|
if (this.fullName === ''){
|
||||||
this.fullName = localMatch;
|
this.fullName = localMatch
|
||||||
} else {
|
} else {
|
||||||
this.fullName = localMatch + "." + this.fullName;
|
this.fullName = localMatch + '.' + this.fullName
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this["level" + i.toString()] = undefined;
|
this['level' + i.toString()] = undefined
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
this.protocol = protocolRegex(domainStringArg);
|
this.protocol = protocolRegex(domainStringArg)
|
||||||
this.zoneName = this.level2 + "." + this.level1;
|
this.zoneName = this.level2 + '.' + this.level1
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
this.topLevel = this.level1;
|
this.topLevel = this.level1
|
||||||
this.domainName = this.level2;
|
this.domainName = this.level2
|
||||||
this.subDomain = this.level3;
|
this.subDomain = this.level3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let domainRegex = function(stringArg:string){
|
let domainRegex = function(stringArg:string){
|
||||||
let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
|
let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/
|
||||||
let regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg)
|
||||||
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
|
regexMatches.reverse() //make sure we build the domain from toplevel to subdomain (reversed order)
|
||||||
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
regexMatches.pop() // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
||||||
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
|
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
|
||||||
return(stringArg != "");
|
return(stringArg !== '')
|
||||||
});
|
});
|
||||||
return regexMatchesFiltered;
|
return regexMatchesFiltered
|
||||||
};
|
};
|
||||||
|
|
||||||
let protocolRegex = function(stringArg:string){
|
let protocolRegex = function(stringArg:string){
|
||||||
let regexString = /^([a-zA-Z0-9]*):\/\//;
|
let regexString = /^([a-zA-Z0-9]*):\/\//
|
||||||
let regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg)
|
||||||
if(regexMatches) {
|
if(regexMatches) {
|
||||||
return regexMatches[1];
|
return regexMatches[1]
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,52 +1,52 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as plugins from './smartstring.plugins'
|
||||||
|
|
||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ classes ------------------- *
|
* ------------------ classes ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
export class GitRepo {
|
export class GitRepo {
|
||||||
host:string;
|
host: string
|
||||||
user:string;
|
user: string
|
||||||
repo:string;
|
repo: string
|
||||||
accessToken:string;
|
accessToken: string
|
||||||
sshUrl:string;
|
sshUrl: string
|
||||||
httpsUrl:string;
|
httpsUrl: string
|
||||||
constructor(stringArg: string,tokenArg?: string) {
|
constructor(stringArg: string,tokenArg?: string) {
|
||||||
let regexMatches = gitRegex(stringArg);
|
let regexMatches = gitRegex(stringArg)
|
||||||
this.host = regexMatches[1];
|
this.host = regexMatches[1]
|
||||||
this.user = regexMatches[2];
|
this.user = regexMatches[2]
|
||||||
this.repo = regexMatches[3];
|
this.repo = regexMatches[3]
|
||||||
this.accessToken = tokenArg;
|
this.accessToken = tokenArg
|
||||||
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "ssh");
|
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'ssh')
|
||||||
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "https");
|
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'https')
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ helpers ------------------- *
|
* ------------------ helpers ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
let gitRegex = function(stringArg:string){
|
let gitRegex = function(stringArg:string){
|
||||||
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
|
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/
|
||||||
let regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg)
|
||||||
return regexMatches;
|
return regexMatches
|
||||||
};
|
}
|
||||||
|
|
||||||
let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:string = "", linkTypeArg):string{
|
let gitLink = function(hostArg: string, userArg: string, repoArg: string, tokenArg: string = '', linkTypeArg): string{
|
||||||
let returnString;
|
let returnString
|
||||||
if (tokenArg !== ""){
|
if (tokenArg !== '') {
|
||||||
tokenArg = tokenArg + "@"
|
tokenArg = tokenArg + '@'
|
||||||
}
|
}
|
||||||
switch (linkTypeArg) {
|
switch (linkTypeArg) {
|
||||||
case "https":
|
case 'https':
|
||||||
returnString = "https://" +
|
returnString = 'https://' +
|
||||||
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
|
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git'
|
||||||
break;
|
break
|
||||||
case "ssh":
|
case 'ssh':
|
||||||
returnString = "git@" +
|
returnString = 'git@' +
|
||||||
hostArg + ":" + userArg + "/" + repoArg + ".git";
|
hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
|
console.error('Link Type ' + linkTypeArg + ' not known')
|
||||||
break;
|
break
|
||||||
|
}
|
||||||
|
return returnString
|
||||||
}
|
}
|
||||||
return returnString;
|
|
||||||
};
|
|
@ -1,60 +1,64 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as plugins from './smartstring.plugins'
|
||||||
|
|
||||||
let splitString = (stringArg: string): string[] => {
|
let splitString = (stringArg: string): string[] => {
|
||||||
let resultArray = stringArg.split("\n");
|
let resultArray = stringArg.split('\n')
|
||||||
return cleanStringArray(resultArray);
|
return cleanStringArray(resultArray)
|
||||||
};
|
};
|
||||||
|
|
||||||
let joinString = (stringArrayArg: string[]): string => {
|
let joinString = (stringArrayArg: string[]): string => {
|
||||||
let resultString:string = "";
|
let resultString: string = ''
|
||||||
for (let line of stringArrayArg){
|
for (let line of stringArrayArg){
|
||||||
resultString = resultString + line + "\n";
|
resultString = resultString + line + '\n'
|
||||||
};
|
}
|
||||||
return resultString;
|
return resultString
|
||||||
};
|
}
|
||||||
|
|
||||||
let cleanStringArray = (stringArrayArg: string[]): string[] => {
|
let cleanStringArray = (stringArrayArg: string[]): string[] => {
|
||||||
let testRegex = /^[\s]*$/;
|
let testRegex = /^[\s]*$/
|
||||||
if (testRegex.test(stringArrayArg[0])) {
|
if (testRegex.test(stringArrayArg[0])) {
|
||||||
stringArrayArg.shift();
|
stringArrayArg.shift()
|
||||||
}
|
}
|
||||||
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
|
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
|
||||||
stringArrayArg.pop();
|
stringArrayArg.pop()
|
||||||
};
|
};
|
||||||
return stringArrayArg;
|
return stringArrayArg
|
||||||
}
|
}
|
||||||
|
|
||||||
export let indent = (stringArg: string, spaceAmount: number): string => {
|
export let indent = (stringArg: string, spaceAmount: number): string => {
|
||||||
let resultString:string;
|
let resultString: string
|
||||||
return resultString;
|
return resultString
|
||||||
};
|
}
|
||||||
|
|
||||||
export let indentWithPrefix = (stringArg: string,prefixArg: string): string => {
|
export let indentWithPrefix = (stringArg: string,prefixArg: string): string => {
|
||||||
let resultString:string;
|
let resultString: string
|
||||||
let stringArray = splitString(stringArg);
|
let stringArray = splitString(stringArg)
|
||||||
let resultArray:string[] = [];
|
let resultArray: string[] = []
|
||||||
for (let stringItem of stringArray){
|
for (let stringItem of stringArray){
|
||||||
resultArray.push(prefixArg + stringItem);
|
resultArray.push(prefixArg + stringItem)
|
||||||
};
|
};
|
||||||
resultString = joinString(resultArray);
|
resultString = joinString(resultArray)
|
||||||
return resultString;
|
return resultString
|
||||||
};
|
}
|
||||||
|
|
||||||
export let normalizeIndent = (stringArg:string):string => {
|
export let normalize = (stringArg: string): string => {
|
||||||
let resultString:string;
|
let resultString: string
|
||||||
let splitStringArray:string[] = splitString(stringArg);
|
let splitStringArray: string[] = splitString(stringArg)
|
||||||
let minCommonLeftOffset:number;
|
let minCommonLeftOffset: number
|
||||||
let deIndentRegex = /^(\s*)/;
|
let deIndentRegex = /^(\s*)/
|
||||||
for(let stringItem of splitStringArray){
|
let emptyLineRegex = /^(\s*)$/
|
||||||
let offsetString = deIndentRegex.exec(stringItem)[1];
|
for (let stringItem of splitStringArray){
|
||||||
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset){
|
let offsetString = deIndentRegex.exec(stringItem)[1]
|
||||||
minCommonLeftOffset = offsetString.length;
|
if (
|
||||||
};
|
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
|
||||||
};
|
&& !emptyLineRegex.test(stringItem)
|
||||||
let resultSplitStringArray = [];
|
) {
|
||||||
for(let stringItem of splitStringArray){
|
minCommonLeftOffset = offsetString.length
|
||||||
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
}
|
||||||
};
|
};
|
||||||
resultString = joinString(resultSplitStringArray);
|
let resultSplitStringArray = []
|
||||||
return resultString;
|
for (let stringItem of splitStringArray) {
|
||||||
|
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset))
|
||||||
|
};
|
||||||
|
resultString = joinString(resultSplitStringArray)
|
||||||
|
return resultString
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
import "typings-global"
|
import 'typings-global'
|
||||||
export import beautylog = require("beautylog");
|
export let jsBase64 = require('js-base64').Base64
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import * as plugins from "./smartstring.plugins";
|
import * as plugins from './smartstring.plugins'
|
||||||
|
|
||||||
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint-config-standard"
|
||||||
|
}
|
Reference in New Issue
Block a user