Compare commits
93 Commits
Author | SHA1 | Date | |
---|---|---|---|
71fd0e614c | |||
55a5948a51 | |||
979375f08d | |||
95d5c6ceee | |||
c92ece79ff | |||
7c625c4390 | |||
65fc64f6aa | |||
8cda8c55c0 | |||
ec0b82de00 | |||
5e69664f59 | |||
f5838f6d6a | |||
fb4a03ad37 | |||
ceb6962a1c | |||
ffe757d820 | |||
60eb4b6b6e | |||
f73d394d35 | |||
212f41e00b | |||
59847dd287 | |||
7fa2fb1e74 | |||
355f7442ca | |||
88af0ab9aa | |||
5b5bcd804f | |||
8c894ea1c1 | |||
62336aa2cf | |||
e9899e5451 | |||
235f380139 | |||
4a94ce3038 | |||
7c4c787539 | |||
714e3a162c | |||
099bf9b270 | |||
83279a9c19 | |||
55d679e5ee | |||
974bf90703 | |||
93029d1aae | |||
3a7740024c | |||
a412285862 | |||
a57bd446d0 | |||
afe8d5bc1b | |||
576e81588d | |||
76c590b045 | |||
bb7caa36ea | |||
a3a51bf0ca | |||
1684eae1e8 | |||
39ce541532 | |||
c2a4f05b33 | |||
3858127968 | |||
68d0124c24 | |||
16f41a7d63 | |||
d13dfc9e76 | |||
942f6b37cf | |||
211c7c3308 | |||
a55d6d2221 | |||
98ca73d0c7 | |||
ffedc7f601 | |||
8344fdf7b1 | |||
543dc98961 | |||
9c60105685 | |||
bdccf2c3a1 | |||
34d6df0923 | |||
3d3b07b7cb | |||
00004f70d6 | |||
2d263244c7 | |||
8cb1405d99 | |||
d357d6e52d | |||
c124f90a91 | |||
4bcf9f941e | |||
afb204325b | |||
cefbb6eecd | |||
c6a1a45812 | |||
00a892ee82 | |||
0eb6d13be9 | |||
c34f9611f9 | |||
820360a220 | |||
3893985bb2 | |||
33e19c54d9 | |||
074996433e | |||
6a803f1db9 | |||
927262d6d4 | |||
df39887de9 | |||
2b52b76ac6 | |||
136a06ff68 | |||
44bb4fa9ae | |||
93d5fc3070 | |||
08cd48b7bc | |||
bb17908ef5 | |||
3b8e31c8b0 | |||
a990c5ca32 | |||
2d4c480c1b | |||
05cd515824 | |||
bd4de36143 | |||
6a1fb1ec50 | |||
930f351626 | |||
9f6ab54a05 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,7 +1,4 @@
|
|||||||
.idea/
|
.yarn/
|
||||||
coverage/
|
pages/
|
||||||
docs/
|
public/
|
||||||
node_modules
|
node_modules/
|
||||||
ts/**/*.js
|
|
||||||
ts/**/*.js.map
|
|
||||||
ts/typings/
|
|
||||||
|
125
.gitlab-ci.yml
Normal file
125
.gitlab-ci.yml
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
# gitzone standard
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testLTS:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
testSTABLE:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- 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: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g typedoc typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- 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
|
12
.travis.yml
12
.travis.yml
@ -1,12 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '4.3.0'
|
|
||||||
- 'stable'
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: oKx1gdYYBnaoUcpxn3WM4SdZdInIYaa3ZgbXLSh88K+PjbcSw3NNbYEnAtWFV1eAQQchDjOHId4D1Ne68DtJb5umahvhYoejtZzawjPaa6Uyi46VPk31wXYzZJyadiyefuwOhLLMM4i3yzYwEC2BeTpbU8Tvaj6B42DoySKNGUnSF9+K2wsFNp13mRje6PLe+fjo+9H4CEKLwf74alwvAWd/PLzv47KKdCZ4/9zX7TxevrIBNie+n6VxjqXm/dTv9k7J3dCunojehBr9X9sn1sd8mR+FexjcgfCA2dz8ViP8qZCslzZixGVuasmjpQH9OabrlOfQ6e+Hs4puv+U7s53SVa9nWntiYHloT29UKCPG6ofuDFq5Nd+1PCNvPfrh99F87IKTOw9DQ9Lx7Q//To4LrbnsC85/uHgkWHhbr/ZGax7wuX9og1rem1MSjYr7gQ1sx9edtDSQe3Yjhi22xDREL5/uCbnThmrd1P44CtAU7UG4TQvnHADFqi4Oogf/VBQvsC+aUJPSfZuoxX31yCYuNToH65j1Vblj9tYuPdHSriPj2OdxbuWh68lpgsh7K64Imb++3oKjh3fKZEzeJsByI+QytyUwO/Qu1c6whlkyv8yMyoaD0WARufU+zcG4P7j4rFlAO/CoezSd6l5HBUiXJNe7XniIi6KZjA1zkZc=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/smartstring
|
|
3
LICENSE
3
LICENSE
@ -1,6 +1,7 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
Copyright (c) 2014 Maurice Butler
|
||||||
|
Copyright (c) 2016 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
68
README.md
68
README.md
@ -1,2 +1,66 @@
|
|||||||
# smartstring
|
# @pushrocks/smartstring
|
||||||
handle strings in smart ways.
|
handle strings in smart ways. TypeScript ready.
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstring)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstring)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartstring)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstring/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartstring/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartstring/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartstring)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartstring)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
```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"
|
||||||
|
// level3 , level 4 and so on...
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
10
dist/index.d.ts
vendored
10
dist/index.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
import SmartstringGit = require("./smartstring.git");
|
|
||||||
import SmartstringDocker = require("./smartstring.docker");
|
|
||||||
import SmartstringTypescript = require("./smartstring.typescript");
|
|
||||||
declare let smartstring: {
|
|
||||||
git: (stringArg: string, tokenArg?: string) => SmartstringGit.gitRepo;
|
|
||||||
docker: typeof SmartstringDocker;
|
|
||||||
typescript: typeof SmartstringTypescript;
|
|
||||||
};
|
|
||||||
export = smartstring;
|
|
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -1,13 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var SmartstringGit = require("./smartstring.git");
|
|
||||||
var SmartstringDocker = require("./smartstring.docker");
|
|
||||||
var SmartstringTypescript = require("./smartstring.typescript");
|
|
||||||
var smartstring = {
|
|
||||||
git: SmartstringGit.git,
|
|
||||||
docker: SmartstringDocker,
|
|
||||||
typescript: SmartstringTypescript
|
|
||||||
};
|
|
||||||
module.exports = smartstring;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxjQUFjLFdBQVcsbUJBQW1CLENBQUMsQ0FBQztBQUNyRCxJQUFPLGlCQUFpQixXQUFXLHNCQUFzQixDQUFDLENBQUM7QUFDM0QsSUFBTyxxQkFBcUIsV0FBVywwQkFBMEIsQ0FBQyxDQUFDO0FBRW5FLElBQUksV0FBVyxHQUFHO0lBQ2QsR0FBRyxFQUFHLGNBQWMsQ0FBQyxHQUFHO0lBQ3hCLE1BQU0sRUFBRSxpQkFBaUI7SUFDekIsVUFBVSxFQUFFLHFCQUFxQjtDQUNwQyxDQUFDO0FBRUYsaUJBQVMsV0FBVyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IFNtYXJ0c3RyaW5nR2l0ID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcuZ2l0XCIpO1xuaW1wb3J0IFNtYXJ0c3RyaW5nRG9ja2VyID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcuZG9ja2VyXCIpO1xuaW1wb3J0IFNtYXJ0c3RyaW5nVHlwZXNjcmlwdCA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHRcIik7XG5cbmxldCBzbWFydHN0cmluZyA9IHtcbiAgICBnaXQgOiBTbWFydHN0cmluZ0dpdC5naXQsXG4gICAgZG9ja2VyOiBTbWFydHN0cmluZ0RvY2tlcixcbiAgICB0eXBlc2NyaXB0OiBTbWFydHN0cmluZ1R5cGVzY3JpcHRcbn07XG5cbmV4cG9ydCA9IHNtYXJ0c3RyaW5nOyJdfQ==
|
|
7
dist/smartstring.docker.d.ts
vendored
7
dist/smartstring.docker.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
/**
|
|
||||||
* converts an erray of env strings from docker remote api to an usable object.
|
|
||||||
* @param envArrayArg
|
|
||||||
* @returns {}
|
|
||||||
*/
|
|
||||||
export declare let makeEnvObject: (envArrayArg: string[]) => {};
|
|
18
dist/smartstring.docker.js
vendored
18
dist/smartstring.docker.js
vendored
@ -1,18 +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) {
|
|
||||||
var returnObject = {};
|
|
||||||
var regexString = /(.*)=(.*)/;
|
|
||||||
for (var envKey in envArrayArg) {
|
|
||||||
var regexMatches = regexString.exec(envArrayArg[envKey]);
|
|
||||||
returnObject[regexMatches[1]] = regexMatches[2];
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return returnObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBR0E7Ozs7R0FJRztBQUNRLHFCQUFhLEdBQUcsVUFBUyxXQUFvQjtJQUNwRCxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUM7SUFDdEIsSUFBSSxXQUFXLEdBQUcsV0FBVyxDQUFDO0lBQzlCLEdBQUcsQ0FBQSxDQUFDLElBQUksTUFBTSxJQUFJLFdBQVcsQ0FBQyxDQUFBLENBQUM7UUFDM0IsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUN6RCxZQUFZLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQ3BELENBQUM7SUFBQSxDQUFDO0lBQ0YsTUFBTSxDQUFDLFlBQVksQ0FBQztBQUN4QixDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydHN0cmluZy5wbHVnaW5zXCIpO1xuXG4vKipcbiAqIGNvbnZlcnRzIGFuIGVycmF5IG9mIGVudiBzdHJpbmdzIGZyb20gZG9ja2VyIHJlbW90ZSBhcGkgdG8gYW4gdXNhYmxlIG9iamVjdC5cbiAqIEBwYXJhbSBlbnZBcnJheUFyZ1xuICogQHJldHVybnMge31cbiAqL1xuZXhwb3J0IGxldCBtYWtlRW52T2JqZWN0ID0gZnVuY3Rpb24oZW52QXJyYXlBcmc6c3RyaW5nW10pe1xuICAgIGxldCByZXR1cm5PYmplY3QgPSB7fTtcbiAgICBsZXQgcmVnZXhTdHJpbmcgPSAvKC4qKT0oLiopLztcbiAgICBmb3IobGV0IGVudktleSBpbiBlbnZBcnJheUFyZyl7XG4gICAgICAgIGxldCByZWdleE1hdGNoZXMgPSByZWdleFN0cmluZy5leGVjKGVudkFycmF5QXJnW2VudktleV0pO1xuICAgICAgICByZXR1cm5PYmplY3RbcmVnZXhNYXRjaGVzWzFdXSA9IHJlZ2V4TWF0Y2hlc1syXTtcbiAgICB9O1xuICAgIHJldHVybiByZXR1cm5PYmplY3Q7XG59OyJdfQ==
|
|
11
dist/smartstring.git.d.ts
vendored
11
dist/smartstring.git.d.ts
vendored
@ -1,11 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
export declare class gitRepo {
|
|
||||||
host: string;
|
|
||||||
user: string;
|
|
||||||
repo: string;
|
|
||||||
accessToken: string;
|
|
||||||
sshUrl: string;
|
|
||||||
httpsUrl: string;
|
|
||||||
constructor(stringArg: string, tokenArg?: string);
|
|
||||||
}
|
|
||||||
export declare let git: (stringArg: string, tokenArg?: string) => gitRepo;
|
|
58
dist/smartstring.git.js
vendored
58
dist/smartstring.git.js
vendored
File diff suppressed because one or more lines are too long
5
dist/smartstring.plugins.d.ts
vendored
5
dist/smartstring.plugins.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
declare let plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
};
|
|
||||||
export = plugins;
|
|
8
dist/smartstring.plugins.js
vendored
8
dist/smartstring.plugins.js
vendored
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog")
|
|
||||||
};
|
|
||||||
module.exports = plugins;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFJLE9BQU8sR0FBRztJQUNWLFNBQVMsRUFBRSxPQUFPLENBQUMsV0FBVyxDQUFDO0NBQ2xDLENBQUM7QUFFRixpQkFBUyxPQUFPLENBQUMiLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmxldCBwbHVnaW5zID0ge1xuICAgIGJlYXV0eWxvZzogcmVxdWlyZShcImJlYXV0eWxvZ1wiKVxufTtcblxuZXhwb3J0ID0gcGx1Z2luczsiXX0=
|
|
1
dist/smartstring.typescript.d.ts
vendored
1
dist/smartstring.typescript.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let regexReferencePath: RegExp;
|
|
4
dist/smartstring.typescript.js
vendored
4
dist/smartstring.typescript.js
vendored
@ -1,4 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIiwiZmlsZSI6InNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLnBsdWdpbnNcIik7XG5cbmV4cG9ydCBsZXQgcmVnZXhSZWZlcmVuY2VQYXRoID0gL1xcL1xcL1xcL1xccyo8cmVmZXJlbmNlXFxzK3BhdGhcXHMqPVxccypbXCJ8J10uKltcInwnXVxccypcXC8+XFxzKltcXFxcbl0/LyJdfQ==
|
|
3
dist/typings/browser.d.ts
vendored
3
dist/typings/browser.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="browser/ambient/colors/index.d.ts" />
|
|
||||||
/// <reference path="browser/ambient/mocha/index.d.ts" />
|
|
||||||
/// <reference path="browser/ambient/node/index.d.ts" />
|
|
126
dist/typings/browser/ambient/colors/index.d.ts
vendored
126
dist/typings/browser/ambient/colors/index.d.ts
vendored
@ -1,126 +0,0 @@
|
|||||||
// Generated by typings
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/colors/colors.d.ts
|
|
||||||
// Type definitions for Colors.js 0.6.0-1
|
|
||||||
// Project: https://github.com/Marak/colors.js
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module "colors" {
|
|
||||||
interface Color {
|
|
||||||
(text: string): string;
|
|
||||||
|
|
||||||
black: Color;
|
|
||||||
red: Color;
|
|
||||||
green: Color;
|
|
||||||
yellow: Color;
|
|
||||||
blue: Color;
|
|
||||||
magenta: Color;
|
|
||||||
cyan: Color;
|
|
||||||
white: Color;
|
|
||||||
gray: Color;
|
|
||||||
grey: Color;
|
|
||||||
|
|
||||||
bgBlack: Color;
|
|
||||||
bgRed: Color;
|
|
||||||
bgGreen: Color;
|
|
||||||
bgYellow: Color;
|
|
||||||
bgBlue: Color;
|
|
||||||
bgMagenta: Color;
|
|
||||||
bgCyan: Color;
|
|
||||||
bgWhite: Color;
|
|
||||||
|
|
||||||
reset: Color;
|
|
||||||
bold: Color;
|
|
||||||
dim: Color;
|
|
||||||
italic: Color;
|
|
||||||
underline: Color;
|
|
||||||
inverse: Color;
|
|
||||||
hidden: Color;
|
|
||||||
strikethrough: Color;
|
|
||||||
|
|
||||||
rainbow: Color;
|
|
||||||
zebra: Color;
|
|
||||||
america: Color;
|
|
||||||
trap: Color;
|
|
||||||
random: Color;
|
|
||||||
zalgo: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e {
|
|
||||||
export function setTheme(theme:any): void;
|
|
||||||
|
|
||||||
export var black: Color;
|
|
||||||
export var red: Color;
|
|
||||||
export var green: Color;
|
|
||||||
export var yellow: Color;
|
|
||||||
export var blue: Color;
|
|
||||||
export var magenta: Color;
|
|
||||||
export var cyan: Color;
|
|
||||||
export var white: Color;
|
|
||||||
export var gray: Color;
|
|
||||||
export var grey: Color;
|
|
||||||
|
|
||||||
export var bgBlack: Color;
|
|
||||||
export var bgRed: Color;
|
|
||||||
export var bgGreen: Color;
|
|
||||||
export var bgYellow: Color;
|
|
||||||
export var bgBlue: Color;
|
|
||||||
export var bgMagenta: Color;
|
|
||||||
export var bgCyan: Color;
|
|
||||||
export var bgWhite: Color;
|
|
||||||
|
|
||||||
export var reset: Color;
|
|
||||||
export var bold: Color;
|
|
||||||
export var dim: Color;
|
|
||||||
export var italic: Color;
|
|
||||||
export var underline: Color;
|
|
||||||
export var inverse: Color;
|
|
||||||
export var hidden: Color;
|
|
||||||
export var strikethrough: Color;
|
|
||||||
|
|
||||||
export var rainbow: Color;
|
|
||||||
export var zebra: Color;
|
|
||||||
export var america: Color;
|
|
||||||
export var trap: Color;
|
|
||||||
export var random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface String {
|
|
||||||
black: string;
|
|
||||||
red: string;
|
|
||||||
green: string;
|
|
||||||
yellow: string;
|
|
||||||
blue: string;
|
|
||||||
magenta: string;
|
|
||||||
cyan: string;
|
|
||||||
white: string;
|
|
||||||
gray: string;
|
|
||||||
grey: string;
|
|
||||||
|
|
||||||
bgBlack: string;
|
|
||||||
bgRed: string;
|
|
||||||
bgGreen: string;
|
|
||||||
bgYellow: string;
|
|
||||||
bgBlue: string;
|
|
||||||
bgMagenta: string;
|
|
||||||
bgCyan: string;
|
|
||||||
bgWhite: string;
|
|
||||||
|
|
||||||
reset: string;
|
|
||||||
bold: string;
|
|
||||||
dim: string;
|
|
||||||
italic: string;
|
|
||||||
underline: string;
|
|
||||||
inverse: string;
|
|
||||||
hidden: string;
|
|
||||||
strikethrough: string;
|
|
||||||
|
|
||||||
rainbow: string;
|
|
||||||
zebra: string;
|
|
||||||
america: string;
|
|
||||||
trap: string;
|
|
||||||
random: string;
|
|
||||||
}
|
|
40
dist/typings/browser/ambient/mocha/index.d.ts
vendored
40
dist/typings/browser/ambient/mocha/index.d.ts
vendored
@ -1,40 +0,0 @@
|
|||||||
// Generated by typings
|
|
||||||
// Source: https://raw.githubusercontent.com/Bartvds/tsd-deftools/master/typings/DefinitelyTyped/mocha/mocha.d.ts
|
|
||||||
// Type definitions for mocha 1.9.0
|
|
||||||
// Project: http://visionmedia.github.io/mocha/
|
|
||||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
|
||||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
|
||||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
declare var describe : {
|
|
||||||
(description: string, spec: () => void): void;
|
|
||||||
only(description: string, spec: () => void): void;
|
|
||||||
skip(description: string, spec: () => void): void;
|
|
||||||
timeout(ms: number);
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var it: {
|
|
||||||
(expectation: string, assertion?: () => void): void;
|
|
||||||
(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
only(expectation: string, assertion?: () => void): void;
|
|
||||||
only(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
skip(expectation: string, assertion?: () => void): void;
|
|
||||||
skip(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
timeout(ms: number);
|
|
||||||
};
|
|
||||||
|
|
||||||
declare function before(action: () => void): void;
|
|
||||||
|
|
||||||
declare function before(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function aftet(action: () => void): void;
|
|
||||||
|
|
||||||
declare function after(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: (done: () => void) => void): void;
|
|
2346
dist/typings/browser/ambient/node/index.d.ts
vendored
2346
dist/typings/browser/ambient/node/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
3
dist/typings/main.d.ts
vendored
3
dist/typings/main.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="main/ambient/colors/index.d.ts" />
|
|
||||||
/// <reference path="main/ambient/mocha/index.d.ts" />
|
|
||||||
/// <reference path="main/ambient/node/index.d.ts" />
|
|
126
dist/typings/main/ambient/colors/index.d.ts
vendored
126
dist/typings/main/ambient/colors/index.d.ts
vendored
@ -1,126 +0,0 @@
|
|||||||
// Generated by typings
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/colors/colors.d.ts
|
|
||||||
// Type definitions for Colors.js 0.6.0-1
|
|
||||||
// Project: https://github.com/Marak/colors.js
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module "colors" {
|
|
||||||
interface Color {
|
|
||||||
(text: string): string;
|
|
||||||
|
|
||||||
black: Color;
|
|
||||||
red: Color;
|
|
||||||
green: Color;
|
|
||||||
yellow: Color;
|
|
||||||
blue: Color;
|
|
||||||
magenta: Color;
|
|
||||||
cyan: Color;
|
|
||||||
white: Color;
|
|
||||||
gray: Color;
|
|
||||||
grey: Color;
|
|
||||||
|
|
||||||
bgBlack: Color;
|
|
||||||
bgRed: Color;
|
|
||||||
bgGreen: Color;
|
|
||||||
bgYellow: Color;
|
|
||||||
bgBlue: Color;
|
|
||||||
bgMagenta: Color;
|
|
||||||
bgCyan: Color;
|
|
||||||
bgWhite: Color;
|
|
||||||
|
|
||||||
reset: Color;
|
|
||||||
bold: Color;
|
|
||||||
dim: Color;
|
|
||||||
italic: Color;
|
|
||||||
underline: Color;
|
|
||||||
inverse: Color;
|
|
||||||
hidden: Color;
|
|
||||||
strikethrough: Color;
|
|
||||||
|
|
||||||
rainbow: Color;
|
|
||||||
zebra: Color;
|
|
||||||
america: Color;
|
|
||||||
trap: Color;
|
|
||||||
random: Color;
|
|
||||||
zalgo: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e {
|
|
||||||
export function setTheme(theme:any): void;
|
|
||||||
|
|
||||||
export var black: Color;
|
|
||||||
export var red: Color;
|
|
||||||
export var green: Color;
|
|
||||||
export var yellow: Color;
|
|
||||||
export var blue: Color;
|
|
||||||
export var magenta: Color;
|
|
||||||
export var cyan: Color;
|
|
||||||
export var white: Color;
|
|
||||||
export var gray: Color;
|
|
||||||
export var grey: Color;
|
|
||||||
|
|
||||||
export var bgBlack: Color;
|
|
||||||
export var bgRed: Color;
|
|
||||||
export var bgGreen: Color;
|
|
||||||
export var bgYellow: Color;
|
|
||||||
export var bgBlue: Color;
|
|
||||||
export var bgMagenta: Color;
|
|
||||||
export var bgCyan: Color;
|
|
||||||
export var bgWhite: Color;
|
|
||||||
|
|
||||||
export var reset: Color;
|
|
||||||
export var bold: Color;
|
|
||||||
export var dim: Color;
|
|
||||||
export var italic: Color;
|
|
||||||
export var underline: Color;
|
|
||||||
export var inverse: Color;
|
|
||||||
export var hidden: Color;
|
|
||||||
export var strikethrough: Color;
|
|
||||||
|
|
||||||
export var rainbow: Color;
|
|
||||||
export var zebra: Color;
|
|
||||||
export var america: Color;
|
|
||||||
export var trap: Color;
|
|
||||||
export var random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface String {
|
|
||||||
black: string;
|
|
||||||
red: string;
|
|
||||||
green: string;
|
|
||||||
yellow: string;
|
|
||||||
blue: string;
|
|
||||||
magenta: string;
|
|
||||||
cyan: string;
|
|
||||||
white: string;
|
|
||||||
gray: string;
|
|
||||||
grey: string;
|
|
||||||
|
|
||||||
bgBlack: string;
|
|
||||||
bgRed: string;
|
|
||||||
bgGreen: string;
|
|
||||||
bgYellow: string;
|
|
||||||
bgBlue: string;
|
|
||||||
bgMagenta: string;
|
|
||||||
bgCyan: string;
|
|
||||||
bgWhite: string;
|
|
||||||
|
|
||||||
reset: string;
|
|
||||||
bold: string;
|
|
||||||
dim: string;
|
|
||||||
italic: string;
|
|
||||||
underline: string;
|
|
||||||
inverse: string;
|
|
||||||
hidden: string;
|
|
||||||
strikethrough: string;
|
|
||||||
|
|
||||||
rainbow: string;
|
|
||||||
zebra: string;
|
|
||||||
america: string;
|
|
||||||
trap: string;
|
|
||||||
random: string;
|
|
||||||
}
|
|
40
dist/typings/main/ambient/mocha/index.d.ts
vendored
40
dist/typings/main/ambient/mocha/index.d.ts
vendored
@ -1,40 +0,0 @@
|
|||||||
// Generated by typings
|
|
||||||
// Source: https://raw.githubusercontent.com/Bartvds/tsd-deftools/master/typings/DefinitelyTyped/mocha/mocha.d.ts
|
|
||||||
// Type definitions for mocha 1.9.0
|
|
||||||
// Project: http://visionmedia.github.io/mocha/
|
|
||||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
|
||||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
|
||||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
declare var describe : {
|
|
||||||
(description: string, spec: () => void): void;
|
|
||||||
only(description: string, spec: () => void): void;
|
|
||||||
skip(description: string, spec: () => void): void;
|
|
||||||
timeout(ms: number);
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var it: {
|
|
||||||
(expectation: string, assertion?: () => void): void;
|
|
||||||
(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
only(expectation: string, assertion?: () => void): void;
|
|
||||||
only(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
skip(expectation: string, assertion?: () => void): void;
|
|
||||||
skip(expectation: string, assertion?: (done: () => void) => void): void;
|
|
||||||
timeout(ms: number);
|
|
||||||
};
|
|
||||||
|
|
||||||
declare function before(action: () => void): void;
|
|
||||||
|
|
||||||
declare function before(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function aftet(action: () => void): void;
|
|
||||||
|
|
||||||
declare function after(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: (done: () => void) => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: (done: () => void) => void): void;
|
|
2346
dist/typings/main/ambient/node/index.d.ts
vendored
2346
dist/typings/main/ambient/node/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
21
npmextra.json
Normal file
21
npmextra.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"npmdocker": {
|
||||||
|
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||||
|
"command": "npmci node install stable && npmci npm install && npmci npm test",
|
||||||
|
"dockerSock": false
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartstring",
|
||||||
|
"shortDescription": "handle strings in smart ways. TypeScript ready.",
|
||||||
|
"npmPackagename": "@pushrocks/smartstring",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1687
package-lock.json
generated
Normal file
1687
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "smartstring",
|
"name": "@pushrocks/smartstring",
|
||||||
"version": "1.0.2",
|
"version": "3.0.11",
|
||||||
"description": "bundles a bunch of (regex) matching and altering methods.",
|
"private": false,
|
||||||
|
"description": "handle strings in smart ways. TypeScript ready.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/pushrocks/smartstring.git"
|
"url": "git+https://gitlab.com/pushrocks/smartstring.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"regex",
|
"regex",
|
||||||
@ -17,14 +20,23 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/smartstring/issues"
|
"url": "https://gitlab.com/pushrocks/smartstring/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartstring#readme",
|
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts": "^5.0.4",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"should": "^8.3.1"
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
|
"@types/node": "^12.7.12",
|
||||||
|
"tslint": "^5.20.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^4.1.2"
|
"crypto-random-string": "^3.0.1",
|
||||||
|
"js-base64": "^2.5.1",
|
||||||
|
"normalize-newline": "^3.0.0",
|
||||||
|
"randomatic": "^3.1.1",
|
||||||
|
"strip-indent": "^3.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();
|
3
test/test.d.ts
vendored
3
test/test.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
|
||||||
declare let smartstring: any;
|
|
||||||
declare let should: any;
|
|
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();
|
52
test/test.js
52
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"}
|
|
19
test/test.normalize.ts
Normal file
19
test/test.normalize.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as smartstring from '../ts/index';
|
||||||
|
|
||||||
|
tap.test('should normalize a string', async () => {
|
||||||
|
const testString = `
|
||||||
|
myawesome string;
|
||||||
|
is indented with two spaces
|
||||||
|
`;
|
||||||
|
const normalizedString = smartstring.normalize.standard(testString);
|
||||||
|
expect(normalizedString).to.equal(
|
||||||
|
`
|
||||||
|
myawesome string;
|
||||||
|
is indented with two spaces
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
51
test/test.ts
51
test/test.ts
@ -1,51 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
|
||||||
let smartstring = require("../dist/index.js");
|
|
||||||
let should = require("should");
|
|
||||||
|
|
||||||
describe("smartstring",function(){
|
|
||||||
describe(".git()",function(){
|
|
||||||
let testGit = smartstring.git("git+https://github.com/pushrocks/smartstring.git");
|
|
||||||
it("should return a .host",function(){
|
|
||||||
testGit.host
|
|
||||||
.should.equal("github.com");
|
|
||||||
});
|
|
||||||
it("should return a .user",function(){
|
|
||||||
testGit.user
|
|
||||||
.should.equal("pushrocks");
|
|
||||||
});
|
|
||||||
it("should return a .repo",function(){
|
|
||||||
testGit.repo
|
|
||||||
.should.equal("smartstring");
|
|
||||||
});
|
|
||||||
it("should return a .httpsUrl",function(){
|
|
||||||
testGit.httpsUrl
|
|
||||||
.should.equal("https://github.com/pushrocks/smartstring.git");
|
|
||||||
});
|
|
||||||
it("should return a .sshUrl",function(){
|
|
||||||
testGit.sshUrl
|
|
||||||
.should.equal("git@github.com:pushrocks/smartstring.git");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
describe(".docker",function(){
|
|
||||||
describe(".makeEnvObject",function(){
|
|
||||||
it("should create a Env Object",function(){
|
|
||||||
let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"];
|
|
||||||
let envObject = smartstring.docker.makeEnvObject(envStringArray);
|
|
||||||
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld");
|
|
||||||
envObject.DEFAULT_HOST.should.equal("some.domain.com");
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe(".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();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
8
test/test.type.ts
Normal file
8
test/test.type.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
import * as smartstring from '../ts';
|
||||||
|
|
||||||
|
tap.test('should state valuid utf8', async () => {
|
||||||
|
expect(smartstring.type.isUtf8('hithere')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
21
ts/index.ts
21
ts/index.ts
@ -1,12 +1,13 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import * as create from './smartstring.create';
|
||||||
import SmartstringGit = require("./smartstring.git");
|
import * as docker from './smartstring.docker';
|
||||||
import SmartstringDocker = require("./smartstring.docker");
|
import * as indent from './smartstring.indent';
|
||||||
import SmartstringTypescript = require("./smartstring.typescript");
|
import * as normalize from './smartstring.normalize';
|
||||||
|
import * as type from './smartstring.type';
|
||||||
|
|
||||||
let smartstring = {
|
export { create, docker, normalize, indent, type };
|
||||||
git : SmartstringGit.git,
|
|
||||||
docker: SmartstringDocker,
|
|
||||||
typescript: SmartstringTypescript
|
|
||||||
};
|
|
||||||
|
|
||||||
export = smartstring;
|
export { Base64, base64 } from './smartstring.base64';
|
||||||
|
export { Domain } from './smartstring.domain';
|
||||||
|
export { GitRepo } from './smartstring.git';
|
||||||
|
|
||||||
|
export { Cryptr } from './smartstring.encryption';
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
29
ts/smartstring.create.ts
Normal file
29
ts/smartstring.create.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a random string
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* createRandomString('AAAA')
|
||||||
|
* //=> 'AGHR'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param patternArg the pattern argument to use, Aa0!* are viable pattern descritors
|
||||||
|
* @param lengthArg the length of the random string
|
||||||
|
* @param optionsArg options
|
||||||
|
*/
|
||||||
|
export const createRandomString = (
|
||||||
|
patternArg: string,
|
||||||
|
lengthArg?: number,
|
||||||
|
optionsArg?: any
|
||||||
|
): string => {
|
||||||
|
return plugins.randomatic(patternArg, lengthArg, optionsArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a crytic string in the speicifed length
|
||||||
|
* @param lengthArg the length of the crypto string
|
||||||
|
*/
|
||||||
|
export const createCryptoRandomString = (lengthArg: number): string => {
|
||||||
|
return plugins.cryptoRandomString(lengthArg);
|
||||||
|
};
|
@ -1,17 +1,18 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import * as plugins from './smartstring.plugins';
|
||||||
import plugins = require("./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.
|
||||||
* @param envArrayArg
|
* @param envArrayArg
|
||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
export let makeEnvObject = function(envArrayArg:string[]){
|
export const makeEnvObject = function(envArrayArg: string[]) {
|
||||||
let returnObject = {};
|
let returnObject = {};
|
||||||
let regexString = /(.*)=(.*)/;
|
let regexString = /(.*)=(.*)/;
|
||||||
for(let envKey in envArrayArg){
|
if (typeof envArrayArg !== 'undefined') {
|
||||||
let regexMatches = regexString.exec(envArrayArg[envKey]);
|
for (let envKey in envArrayArg) {
|
||||||
returnObject[regexMatches[1]] = regexMatches[2];
|
let regexMatches = regexString.exec(envArrayArg[envKey]);
|
||||||
};
|
returnObject[regexMatches[1]] = regexMatches[2];
|
||||||
return returnObject;
|
}
|
||||||
};
|
}
|
||||||
|
return returnObject;
|
||||||
|
};
|
||||||
|
79
ts/smartstring.domain.ts
Normal file
79
ts/smartstring.domain.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
|
export class Domain {
|
||||||
|
public fullName: string;
|
||||||
|
public level1: string;
|
||||||
|
public level2: string;
|
||||||
|
public level3: string;
|
||||||
|
public level4: string;
|
||||||
|
public level5: string;
|
||||||
|
public protocol: string;
|
||||||
|
public zoneName: string;
|
||||||
|
// aliases
|
||||||
|
public topLevel: string;
|
||||||
|
public domainName;
|
||||||
|
public subDomain;
|
||||||
|
public port;
|
||||||
|
public nodeParsedUrl: plugins.url.UrlWithStringQuery;
|
||||||
|
constructor(domainStringArg: string) {
|
||||||
|
const regexMatches = this._domainRegex(domainStringArg);
|
||||||
|
this.fullName = '';
|
||||||
|
for (let i = 1; i <= 5; i++) {
|
||||||
|
if (regexMatches[i - 1]) {
|
||||||
|
const 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 = this._protocolRegex(domainStringArg);
|
||||||
|
this.zoneName = this.level2 + '.' + this.level1;
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
this.topLevel = this.level1;
|
||||||
|
this.domainName = this.level2;
|
||||||
|
this.subDomain = this.level3;
|
||||||
|
|
||||||
|
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
|
||||||
|
this.port = this.nodeParsedUrl.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper functions
|
||||||
|
|
||||||
|
/** */
|
||||||
|
private _domainRegex(stringArg: string) {
|
||||||
|
const 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}$/;
|
||||||
|
const 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
|
||||||
|
const regexMatchesFiltered = regexMatches.filter(function(stringArg: string) {
|
||||||
|
return stringArg !== '';
|
||||||
|
});
|
||||||
|
return regexMatchesFiltered;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _protocolRegex(stringArg: string) {
|
||||||
|
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||||
|
const regexMatches = regexString.exec(stringArg);
|
||||||
|
if (regexMatches) {
|
||||||
|
return regexMatches[1];
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _portRegex(stringArg: string) {
|
||||||
|
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||||
|
const regexMatches = regexString.exec(stringArg);
|
||||||
|
if (regexMatches) {
|
||||||
|
return regexMatches[1];
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
ts/smartstring.encryption.ts
Normal file
43
ts/smartstring.encryption.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
|
const algorithm = 'aes-256-ctr';
|
||||||
|
|
||||||
|
export class Cryptr {
|
||||||
|
private key: Buffer;
|
||||||
|
|
||||||
|
constructor(secret) {
|
||||||
|
if (!secret || typeof secret !== 'string') {
|
||||||
|
throw new Error('Cryptr: secret must be a non-0-length string');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.key = plugins.crypto
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(String(secret))
|
||||||
|
.digest();
|
||||||
|
}
|
||||||
|
|
||||||
|
encrypt(value: string) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new Error('value must not be null or undefined');
|
||||||
|
}
|
||||||
|
|
||||||
|
const iv = plugins.crypto.randomBytes(16);
|
||||||
|
const cipher = plugins.crypto.createCipheriv(algorithm, this.key, iv);
|
||||||
|
const encrypted = cipher.update(String(value), 'utf8', 'hex') + cipher.final('hex');
|
||||||
|
|
||||||
|
return iv.toString('hex') + encrypted;
|
||||||
|
}
|
||||||
|
|
||||||
|
decrypt(value: string) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new Error('value must not be null or undefined');
|
||||||
|
}
|
||||||
|
|
||||||
|
const stringValue = String(value);
|
||||||
|
const iv = Buffer.from(stringValue.slice(0, 32), 'hex');
|
||||||
|
const encrypted = stringValue.slice(32);
|
||||||
|
|
||||||
|
const decipher = plugins.crypto.createDecipheriv(algorithm, this.key, iv);
|
||||||
|
return decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8');
|
||||||
|
}
|
||||||
|
}
|
@ -1,61 +1,56 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import * as plugins from './smartstring.plugins';
|
||||||
import plugins = require("./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){
|
const gitRegex = function(stringArg: string) {
|
||||||
let regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
|
const 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{
|
const gitLink = function(
|
||||||
let returnString;
|
hostArg: string,
|
||||||
if (tokenArg !== ""){
|
userArg: string,
|
||||||
tokenArg = tokenArg + "@"
|
repoArg: string,
|
||||||
}
|
tokenArg: string = '',
|
||||||
switch (linkTypeArg) {
|
linkTypeArg
|
||||||
case "https":
|
): string {
|
||||||
returnString = "https://" +
|
let returnString;
|
||||||
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
|
if (tokenArg !== '') {
|
||||||
break;
|
tokenArg = tokenArg + '@';
|
||||||
case "ssh":
|
}
|
||||||
returnString = "git@" +
|
switch (linkTypeArg) {
|
||||||
hostArg + ":" + userArg + "/" + repoArg + ".git";
|
case 'https':
|
||||||
break;
|
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
|
||||||
default:
|
break;
|
||||||
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
|
case 'ssh':
|
||||||
break;
|
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||||
}
|
break;
|
||||||
return returnString;
|
default:
|
||||||
|
console.error('Link Type ' + linkTypeArg + ' not known');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return returnString;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ---------------------------------------------- *
|
|
||||||
* ------------------ exports ------------------- *
|
|
||||||
* ---------------------------------------------- */
|
|
||||||
export let git = function(stringArg:string,tokenArg?:string){
|
|
||||||
let localGitRepo = new gitRepo(stringArg,tokenArg);
|
|
||||||
return localGitRepo;
|
|
||||||
};
|
|
92
ts/smartstring.indent.ts
Normal file
92
ts/smartstring.indent.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* splits a string into an array
|
||||||
|
* @param stringArg
|
||||||
|
*/
|
||||||
|
const splitStringAtLineBreak = (stringArg: string): string[] => {
|
||||||
|
let resultArray = stringArg.split('\n');
|
||||||
|
return cleanStringArray(resultArray);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 searchPattern
|
||||||
|
* @param replacementString
|
||||||
|
*/
|
||||||
|
export const replaceAll = (stringArg: string, searchPattern: string, replacementString: string) => {
|
||||||
|
return stringArg.replace(new RegExp(searchPattern, '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,6 +1,13 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
// node native
|
||||||
let plugins = {
|
import * as crypto from 'crypto';
|
||||||
beautylog: require("beautylog")
|
import * as url from 'url';
|
||||||
};
|
|
||||||
|
|
||||||
export = plugins;
|
export { crypto, url };
|
||||||
|
|
||||||
|
// third party
|
||||||
|
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');
|
||||||
|
77
ts/smartstring.type.ts
Normal file
77
ts/smartstring.type.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import * as plugins from './smartstring.plugins';
|
||||||
|
|
||||||
|
export const isUtf8 = (stringArg: string) => {
|
||||||
|
const bytes = Buffer.from(stringArg);
|
||||||
|
let i = 0;
|
||||||
|
while(i < bytes.length)
|
||||||
|
{
|
||||||
|
if( (// ASCII
|
||||||
|
bytes[i] === 0x09 ||
|
||||||
|
bytes[i] === 0x0A ||
|
||||||
|
bytes[i] === 0x0D ||
|
||||||
|
(0x20 <= bytes[i] && bytes[i] <= 0x7E)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (// non-overlong 2-byte
|
||||||
|
(0xC2 <= bytes[i] && bytes[i] <= 0xDF) &&
|
||||||
|
(0x80 <= bytes[i+1] && bytes[i+1] <= 0xBF)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
i += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (// excluding overlongs
|
||||||
|
bytes[i] === 0xE0 &&
|
||||||
|
(0xA0 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF)
|
||||||
|
) ||
|
||||||
|
(// straight 3-byte
|
||||||
|
((0xE1 <= bytes[i] && bytes[i] <= 0xEC) ||
|
||||||
|
bytes[i] === 0xEE ||
|
||||||
|
bytes[i] === 0xEF) &&
|
||||||
|
(0x80 <= bytes[i + 1] && bytes[i+1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
|
||||||
|
) ||
|
||||||
|
(// excluding surrogates
|
||||||
|
bytes[i] === 0xED &&
|
||||||
|
(0x80 <= bytes[i+1] && bytes[i+1] <= 0x9F) &&
|
||||||
|
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
i += 3;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (// planes 1-3
|
||||||
|
bytes[i] === 0xF0 &&
|
||||||
|
(0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
|
||||||
|
) ||
|
||||||
|
(// planes 4-15
|
||||||
|
(0xF1 <= bytes[i] && bytes[i] <= 0xF3) &&
|
||||||
|
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
|
||||||
|
) ||
|
||||||
|
(// plane 16
|
||||||
|
bytes[i] === 0xF4 &&
|
||||||
|
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8F) &&
|
||||||
|
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
i += 4;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
@ -1,3 +0,0 @@
|
|||||||
import plugins = require("./smartstring.plugins");
|
|
||||||
|
|
||||||
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"ambientDependencies": {
|
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
|
||||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
|
|
||||||
}
|
|
||||||
}
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
Reference in New Issue
Block a user