Compare commits

...

91 Commits

Author SHA1 Message Date
979375f08d 3.0.10 2019-04-16 08:55:37 +02:00
95d5c6ceee fix(core): update 2019-04-16 08:55:37 +02:00
c92ece79ff 3.0.9 2019-04-16 08:54:27 +02:00
7c625c4390 fix(core): update 2019-04-16 08:54:27 +02:00
65fc64f6aa 3.0.8 2019-01-12 20:41:02 +01:00
8cda8c55c0 fix(core): update 2019-01-12 20:41:01 +01:00
ec0b82de00 3.0.7 2019-01-12 20:19:17 +01:00
5e69664f59 fix(core): update 2019-01-12 20:19:16 +01:00
f5838f6d6a 3.0.6 2019-01-12 20:12:59 +01:00
fb4a03ad37 fix(core): update 2019-01-12 20:12:58 +01:00
ceb6962a1c 3.0.5 2018-11-28 21:01:13 +01:00
ffe757d820 fix(dependencies and structure): update 2018-11-28 21:01:13 +01:00
60eb4b6b6e 3.0.4 2018-08-14 00:21:55 +02:00
f73d394d35 fix(ci): reduce build dependencies 2018-08-14 00:21:55 +02:00
212f41e00b 3.0.3 2018-08-14 00:19:32 +02:00
59847dd287 fix(ci): fix build step 2018-08-14 00:19:32 +02:00
7fa2fb1e74 3.0.2 2018-08-14 00:17:37 +02:00
355f7442ca fix(dependencies): update test framework 2018-08-14 00:17:37 +02:00
88af0ab9aa 3.0.1 2018-08-13 22:27:22 +02:00
5b5bcd804f fix(dependencies): fix obsolete dependency on typings-global 2018-08-13 22:27:21 +02:00
8c894ea1c1 3.0.0 2018-07-21 14:37:39 +02:00
62336aa2cf BREAKING CHANGE(scope): change scope to @pushrocks 2018-07-21 14:37:39 +02:00
e9899e5451 2.0.28 2017-10-26 15:24:13 +02:00
235f380139 refactor to const 2017-10-26 15:24:10 +02:00
4a94ce3038 2.0.27 2017-10-11 15:18:30 +02:00
7c4c787539 add npmextra.json 2017-10-11 15:18:26 +02:00
714e3a162c 2.0.26 2017-10-11 14:52:24 +02:00
099bf9b270 add create module 2017-10-11 14:52:22 +02:00
83279a9c19 2.0.25 2017-10-05 15:56:03 +02:00
55d679e5ee update normalize of smartstring 2017-10-05 15:55:59 +02:00
974bf90703 2.0.24 2017-02-19 14:34:04 +01:00
93029d1aae update README 2017-02-19 14:33:00 +01:00
3a7740024c 2.0.23 2017-02-19 14:30:51 +01:00
a412285862 update dependencies and allow dots in git user and repo names 2017-02-19 14:09:39 +01:00
a57bd446d0 2.0.22 2016-11-02 23:02:00 +01:00
afe8d5bc1b improve README 2016-11-02 23:01:56 +01:00
576e81588d 2.0.21 2016-11-02 22:55:20 +01:00
76c590b045 improve README 2016-11-02 22:55:17 +01:00
bb7caa36ea 2.0.20 2016-11-01 19:00:35 +01:00
a3a51bf0ca small export fix 2016-11-01 19:00:32 +01:00
1684eae1e8 expose base64 functions seperate from class 2016-11-01 18:59:43 +01:00
39ce541532 2.0.19 2016-11-01 00:37:47 +01:00
c2a4f05b33 2.0.18 2016-11-01 00:22:52 +01:00
3858127968 add Base64 handling 2016-11-01 00:22:38 +01:00
68d0124c24 2.0.17 2016-08-03 15:42:39 +02:00
16f41a7d63 Merge branch 'master' of gitlab.com:pushrocks/smartstring 2016-08-03 15:42:24 +02:00
d13dfc9e76 2.0.16 2016-08-03 15:41:54 +02:00
942f6b37cf fix docker env null problem 2016-08-03 15:41:36 +02:00
211c7c3308 Update .gitlab-ci.yml 2016-07-22 22:34:51 +00:00
a55d6d2221 Update README.md 2016-07-21 22:17:56 +00:00
98ca73d0c7 2.0.15 2016-07-17 17:30:35 +02:00
ffedc7f601 switched to ES6 2016-07-17 17:30:26 +02:00
8344fdf7b1 2.0.14 2016-07-08 01:49:41 +02:00
543dc98961 ignore empty lines for indent.normalize() 2016-07-08 01:49:32 +02:00
9c60105685 2.0.13 2016-07-08 00:57:27 +02:00
bdccf2c3a1 now has working indent module 2016-07-08 00:57:11 +02:00
34d6df0923 write some tests 2016-07-07 23:35:15 +02:00
3d3b07b7cb implement deindent 2016-07-07 19:53:14 +02:00
00004f70d6 2.0.12 2016-07-06 10:06:44 +02:00
2d263244c7 recompile 2016-07-06 10:06:39 +02:00
8cb1405d99 2.0.11 2016-07-06 10:06:15 +02:00
d357d6e52d merged 2016-07-06 10:06:10 +02:00
c124f90a91 prepare indent functionality 2016-07-06 10:04:25 +02:00
4bcf9f941e 2.0.10 2016-06-22 12:55:32 +02:00
afb204325b fix Domain Regex to include - and _ 2016-06-22 12:55:29 +02:00
cefbb6eecd 2.0.9 2016-06-21 18:59:08 +02:00
c6a1a45812 fix Domain.fullName 2016-06-21 18:59:05 +02:00
00a892ee82 2.0.8 2016-06-21 17:11:50 +02:00
0eb6d13be9 testing legacy 2016-06-21 17:11:19 +02:00
c34f9611f9 2.0.7 2016-06-21 17:09:26 +02:00
820360a220 now evealuating Domains that have no protocol specified 2016-06-21 17:09:17 +02:00
3893985bb2 2.0.6 2016-06-05 09:35:56 +02:00
33e19c54d9 fix gitlab.yml 2016-06-05 09:35:42 +02:00
074996433e 2.0.5 2016-06-05 09:31:14 +02:00
6a803f1db9 fix git regex 2016-06-05 09:31:10 +02:00
927262d6d4 update yml 2016-05-30 05:50:30 +02:00
df39887de9 update deps 2016-05-29 21:45:22 +02:00
2b52b76ac6 add gitlab ci 2016-05-29 21:37:49 +02:00
136a06ff68 2.0.4 2016-05-25 09:10:54 +02:00
44bb4fa9ae update README 2016-05-25 09:10:43 +02:00
93d5fc3070 2.0.3 2016-05-25 09:05:13 +02:00
08cd48b7bc Add authors note 2016-05-25 09:05:04 +02:00
bb17908ef5 2.0.2 2016-05-25 09:02:45 +02:00
3b8e31c8b0 improve README and add app veyor 2016-05-25 09:02:24 +02:00
a990c5ca32 2.0.1 2016-05-25 06:55:02 +02:00
2d4c480c1b now computes zoneName and finds protocol 2016-05-25 06:54:55 +02:00
05cd515824 2.0.0 2016-05-25 05:06:24 +02:00
bd4de36143 now correctly parsing a Domain 2016-05-25 05:06:19 +02:00
6a1fb1ec50 update structure 2016-05-17 00:02:29 +02:00
930f351626 1.0.3 2016-05-01 21:29:05 +02:00
9f6ab54a05 fixing issue with typings 2016-05-01 21:28:59 +02:00
49 changed files with 2451 additions and 5389 deletions

11
.gitignore vendored
View File

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

125
.gitlab-ci.yml Normal file
View 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

View File

@ -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

View File

@ -1,6 +1,7 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,2 +1,66 @@
# smartstring
handle strings in smart ways.
# @pushrocks/smartstring
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
[![build status](https://gitlab.com/pushrocks/smartstring/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartstring/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartstring.svg)](https://www.npmjs.com/package/@pushrocks/smartstring)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartstring/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartstring)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](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)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

10
dist/index.d.ts vendored
View File

@ -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
View File

@ -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==

View File

@ -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[]) => {};

View File

@ -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==

View File

@ -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;

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
/// <reference path="typings/main.d.ts" />
declare let plugins: {
beautylog: any;
};
export = plugins;

View File

@ -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=

View File

@ -1 +0,0 @@
export declare let regexReferencePath: RegExp;

View File

@ -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==

View File

@ -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" />

View File

@ -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;
}

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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" />

View File

@ -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;
}

View File

@ -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;

File diff suppressed because it is too large Load Diff

21
npmextra.json Normal file
View 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"
}
}
}

1649
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,17 @@
{
"name": "smartstring",
"version": "1.0.2",
"description": "bundles a bunch of (regex) matching and altering methods.",
"name": "@pushrocks/smartstring",
"version": "3.0.10",
"private": false,
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild)"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/smartstring.git"
"url": "git+https://gitlab.com/pushrocks/smartstring.git"
},
"keywords": [
"regex",
@ -17,14 +20,23 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://github.com/pushrocks/smartstring/issues"
"url": "https://gitlab.com/pushrocks/smartstring/issues"
},
"homepage": "https://github.com/pushrocks/smartstring#readme",
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": {
"npmts": "^5.0.4",
"should": "^8.3.1"
"@gitzone/tsbuild": "^2.1.4",
"@gitzone/tsrun": "^1.1.17",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.18",
"tslint": "^5.15.0",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"beautylog": "^4.1.2"
"crypto-random-string": "^1.0.0",
"js-base64": "^2.5.0",
"normalize-newline": "^3.0.0",
"randomatic": "^3.1.1",
"strip-indent": "^2.0.0"
}
}

16
test/test.base64.ts Normal file
View 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
View File

@ -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
View 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
View 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
View 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
View 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();

File diff suppressed because one or more lines are too long

View File

@ -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
View 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();

View File

@ -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();
})
})
})
});

View File

@ -1,12 +1,12 @@
/// <reference path="./typings/main.d.ts" />
import SmartstringGit = require("./smartstring.git");
import SmartstringDocker = require("./smartstring.docker");
import SmartstringTypescript = require("./smartstring.typescript");
import * as create from './smartstring.create';
import * as docker from './smartstring.docker';
import * as indent from './smartstring.indent';
import * as normalize from './smartstring.normalize';
let smartstring = {
git : SmartstringGit.git,
docker: SmartstringDocker,
typescript: SmartstringTypescript
};
export { create, docker, normalize, indent };
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
View File

@ -0,0 +1,69 @@
import * as plugins from './smartstring.plugins';
/**
* the type for base 64
*/
export type TBase64Input = 'string' | 'base64' | 'base64uri';
/**
* handle base64 strings
*/
export class Base64 {
private refString: string;
constructor(inputStringArg, typeArg: TBase64Input) {
switch (typeArg) {
case 'string': // easiest case
this.refString = inputStringArg;
break;
case 'base64':
this.refString = base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get 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
View 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);
};

View File

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

79
ts/smartstring.domain.ts Normal file
View 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;
}
}
}

View 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');
}
}

View File

@ -1,61 +1,56 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins';
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
export class gitRepo {
host:string;
user:string;
repo:string;
accessToken:string;
sshUrl:string;
httpsUrl:string;
constructor(stringArg:string,tokenArg?:string){
let regexMatches = gitRegex(stringArg);
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "ssh");
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "https");
};
export class GitRepo {
host: string;
user: string;
repo: string;
accessToken: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string) {
let regexMatches = gitRegex(stringArg);
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
}
}
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
let gitRegex = function(stringArg:string){
let regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
const gitRegex = function(stringArg: string) {
const regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
};
let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:string = "", linkTypeArg):string{
let returnString;
if (tokenArg !== ""){
tokenArg = tokenArg + "@"
}
switch (linkTypeArg) {
case "https":
returnString = "https://" +
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
break;
case "ssh":
returnString = "git@" +
hostArg + ":" + userArg + "/" + repoArg + ".git";
break;
default:
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
break;
}
return returnString;
const gitLink = function(
hostArg: string,
userArg: string,
repoArg: string,
tokenArg: string = '',
linkTypeArg
): string {
let returnString;
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case 'https':
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break;
case 'ssh':
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
break;
default:
console.error('Link Type ' + linkTypeArg + ' not known');
break;
}
return returnString;
};
/* ---------------------------------------------- *
* ------------------ exports ------------------- *
* ---------------------------------------------- */
export let git = function(stringArg:string,tokenArg?:string){
let localGitRepo = new gitRepo(stringArg,tokenArg);
return localGitRepo;
};

92
ts/smartstring.indent.ts Normal file
View 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;
};

View 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;
};

View File

@ -1,6 +1,13 @@
/// <reference path="./typings/main.d.ts" />
let plugins = {
beautylog: require("beautylog")
};
// node native
import * as crypto from 'crypto';
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');

View File

@ -1,3 +0,0 @@
import plugins = require("./smartstring.plugins");
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/

View File

@ -1,7 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
}
}

17
tslint.json Normal file
View 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"
}