Compare commits

...

154 Commits

Author SHA1 Message Date
6a7570de7b update description 2024-05-29 14:16:41 +02:00
579e25fe5a update tsconfig 2024-04-14 18:26:18 +02:00
871a22a801 update tsconfig 2024-04-01 21:41:29 +02:00
aacb4a6873 update npmextra.json: githost 2024-04-01 19:59:52 +02:00
0ef1af7b86 update npmextra.json: githost 2024-03-30 21:48:52 +01:00
2af0329918 4.0.15 2024-03-03 12:36:00 +01:00
b65a460ef2 fix(core): update 2024-03-03 12:35:59 +01:00
3f5b0ebe1e 4.0.14 2024-03-01 23:34:44 +01:00
6f2cedc1dd fix(core): update 2024-03-01 23:34:43 +01:00
2c29ae3bf0 4.0.13 2024-01-08 14:41:44 +01:00
b26b8ed4a6 4.0.12 2024-01-08 14:24:22 +01:00
0e6877d2d1 fix(core): update 2024-01-08 14:24:21 +01:00
8a0c3fe906 4.0.11 2024-01-08 14:17:10 +01:00
ae861fa271 4.0.10 2023-12-27 21:57:45 +01:00
3e78466e5f fix(core): update 2023-12-27 21:57:45 +01:00
eea19bcd89 4.0.9 2023-08-31 16:31:24 +02:00
1fc95fcf0e fix(core): update 2023-08-31 16:31:23 +02:00
14ba4465d9 4.0.8 2023-08-18 13:12:26 +02:00
707e31d517 fix(core): update 2023-08-18 13:12:25 +02:00
64d85e711a 4.0.7 2023-06-26 10:01:24 +02:00
34a5cc9862 fix(core): update 2023-06-26 10:01:23 +02:00
d43d1ba212 4.0.6 2023-06-26 09:57:32 +02:00
65e771f1ba fix(core): update 2023-06-26 09:57:32 +02:00
5825a602ed 4.0.5 2022-09-13 19:23:11 +02:00
5e961f7a5b fix(core): update 2022-09-13 19:23:11 +02:00
36bcb9265a 4.0.4 2022-09-13 19:13:04 +02:00
53bf2f3569 fix(core): update 2022-09-13 19:13:04 +02:00
523ab7ee77 4.0.3 2022-09-13 18:47:19 +02:00
d60cc5430f fix(core): update 2022-09-13 18:47:19 +02:00
c0035bb4f3 4.0.2 2022-03-24 19:57:09 +01:00
976f81420f fix(core): update 2022-03-24 19:57:09 +01:00
1be144d099 4.0.1 2022-03-18 23:15:02 +01:00
9d4b7a5292 4.0.0 2022-03-18 23:05:32 +01:00
563d6f0ac3 3.0.26 2022-03-18 22:52:38 +01:00
4da0aeb871 fix(core): update 2022-03-18 22:52:38 +01:00
931defe98a 3.0.25 2022-03-18 22:50:25 +01:00
1e6077ce34 fix(core): update 2022-03-18 22:50:24 +01:00
8b1769d65e 3.0.24 2021-01-22 18:27:51 +00:00
48878c0b38 fix(core): update 2021-01-22 18:27:50 +00:00
76cfc8bec0 3.0.23 2021-01-22 14:46:04 +00:00
7f3118c525 fix(core): update 2021-01-22 14:46:02 +00:00
9d189d1b59 3.0.22 2020-12-31 04:42:47 +00:00
0266afca8e fix(core): update 2020-12-31 04:42:46 +00:00
bef836fc83 3.0.21 2020-12-31 04:25:31 +00:00
2bd1741893 fix(core): update 2020-12-31 04:25:31 +00:00
bd20512b10 3.0.20 2020-12-31 04:11:34 +00:00
25d0ba8036 fix(core): update 2020-12-31 04:11:33 +00:00
c517652122 3.0.19 2020-12-31 03:56:41 +00:00
bf3e640307 fix(core): update 2020-12-31 03:56:40 +00:00
08cb2392fa 3.0.18 2020-01-23 17:14:58 +00:00
4e1fa4efab fix(core): update 2020-01-23 17:14:57 +00:00
26d00bb9d3 3.0.17 2019-11-24 11:44:33 +00:00
fd27ed1a56 fix(core): update 2019-11-24 11:44:32 +00:00
1f31fe9dc5 3.0.16 2019-11-24 11:44:21 +00:00
bd7888f7ce fix(core): update 2019-11-24 11:44:21 +00:00
201812e182 3.0.15 2019-11-24 11:43:32 +00:00
8dfa3f8965 fix(core): update 2019-11-24 11:43:32 +00:00
43d50b746b 3.0.14 2019-10-10 18:24:04 +02:00
a1ee8f37d6 fix(core): update 2019-10-10 18:24:03 +02:00
8d9c75e113 3.0.13 2019-10-10 18:14:08 +02:00
8ff2a9d64a fix(core): update 2019-10-10 18:14:07 +02:00
8665464416 3.0.12 2019-10-10 18:03:05 +02:00
e773644256 fix(core): update 2019-10-10 18:03:04 +02:00
71fd0e614c 3.0.11 2019-10-10 17:28:24 +02:00
55a5948a51 fix(core): update 2019-10-10 17:28:23 +02:00
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
48 changed files with 7156 additions and 358 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

25
.gitignore vendored
View File

@ -1,7 +1,20 @@
.idea/
.nogit/
# artifacts
coverage/
docs/
node_modules
ts/**/*.js
ts/**/*.js.map
ts/typings/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

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

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,2 +0,0 @@
# smartstring
handle strings in smart ways.

9
dist/index.d.ts vendored
View File

@ -1,9 +0,0 @@
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,6 +0,0 @@
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
export declare let makeEnvObject: (envArrayArg: string[]) => {};

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,10 +0,0 @@
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,4 +0,0 @@
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,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

39
npmextra.json Normal file
View File

@ -0,0 +1,39 @@
{
"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": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartstring",
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
"npmPackagename": "@push.rocks/smartstring",
"license": "MIT",
"keywords": [
"string manipulation",
"encode",
"decode",
"base64",
"indentation",
"normalization",
"regex",
"random string",
"cryptographic string",
"domain parsing",
"git repository parsing",
"docker environment parsing"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -1,31 +1,70 @@
{
"name": "smartstring",
"version": "1.0.3",
"description": "bundles a bunch of (regex) matching and altering methods.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/smartstring",
"version": "4.0.15",
"private": false,
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/smartstring.git"
"url": "https://code.foss.global/push.rocks/smartstring.git"
},
"keywords": [
"string manipulation",
"encode",
"decode",
"base64",
"indentation",
"normalization",
"regex",
"string"
"random string",
"cryptographic string",
"domain parsing",
"git repository parsing",
"docker environment parsing"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://github.com/pushrocks/smartstring/issues"
"url": "https://gitlab.com/push.rocks/smartstring/issues"
},
"homepage": "https://github.com/pushrocks/smartstring#readme",
"homepage": "https://code.foss.global/push.rocks/smartstring",
"devDependencies": {
"npmts": "^5.1.4",
"should": "^8.3.1"
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.2.42",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.11.24"
},
"dependencies": {
"beautylog": "^4.1.2"
}
}
"@push.rocks/isounique": "^1.0.5",
"@push.rocks/smartenv": "^5.0.12",
"@types/randomatic": "^3.1.5",
"crypto-random-string": "^5.0.0",
"js-base64": "^3.7.7",
"randomatic": "^3.1.1",
"strip-indent": "^4.0.0",
"url": "^0.11.3"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

5953
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

151
readme.md Normal file
View File

@ -0,0 +1,151 @@
# @push.rocks/smartstring
handle strings in smart ways. TypeScript ready.
## Install
To install `@push.rocks/smartstring`, use the following npm command:
```bash
npm install @push.rocks/smartstring --save
```
This will add it to your project's dependencies.
## Usage
The `@push.rocks/smartstring` package provides a powerful set of utilities to handle and manipulate strings in various ways, ready for TypeScript usage. Here's an exhaustive guide to using this package.
### Working with Domain Strings
The `Domain` class helps in parsing and extracting information from domain URLs.
```typescript
import { Domain } from '@push.rocks/smartstring';
// Parse a domain URL
const myDomain = new Domain('https://sub.example.com');
console.log(myDomain.level1); // Output: "com"
console.log(myDomain.level2); // Output: "example"
console.log(myDomain.zoneName); // Output: "example.com"
console.log(myDomain.protocol); // Output: "https"
```
### Handling Git Repositories
The `GitRepo` class is designed for extracting information from Git repository URLs.
```typescript
import { GitRepo } from '@push.rocks/smartstring';
// Parse a Git repository URL
const myGitRepo = new GitRepo('git@github.com:user/repo.git');
console.log(myGitRepo.host); // Output: "github.com"
console.log(myGitRepo.user); // Output: "user"
console.log(myGitRepo.repo); // Output: "repo"
console.log(myGitRepo.sshUrl); // Output: "git@github.com:user/repo.git"
console.log(myGitRepo.httpsUrl); // Output: "https://github.com/user/repo.git"
```
### Encoding and Decoding Base64 Strings
`@push.rocks/smartstring` offers base64 encoding and decoding through the `Base64` class and utility functions.
```typescript
import { Base64, base64 } from '@push.rocks/smartstring';
// Using the Base64 class
const myBase64 = new Base64('hello world', 'string');
console.log(myBase64.base64String); // Encoded string
console.log(myBase64.base64UriString); // Encoded URI compatible string
// Using utility functions
const encoded = base64.encode('hello world');
const decoded = base64.decode(encoded);
console.log(encoded); // Encoded string
console.log(decoded); // "hello world"
```
### Applying Indentation
SmartString allows you to easily indent strings or normalize indentation across a multi-line string.
```typescript
import { indent } from '@push.rocks/smartstring';
// Indent a string by 4 spaces
const indentedString = indent.indent('Some text\nAnother line', 4);
console.log(indentedString);
// Indent using a prefix
const prefixedString = indent.indentWithPrefix('Line 1\nLine 2', '> ');
console.log(prefixedString);
// Normalize indentation
const normalizedString = indent.normalize(' Some indented text\n Another line');
console.log(normalizedString);
```
### Creating Random or Encrypted Strings
Create random strings based on patterns or generate cryptographically strong random strings.
```typescript
import { create } from '@push.rocks/smartstring';
// Create a random string
const randomString = create.createRandomString('aA0', 10);
console.log(randomString); // Example output: "a9mB8v2Dq1"
// Create a crypto-random string
const cryptoString = create.createCryptoRandomString(10);
console.log(cryptoString); // Example output: "f28Bb90aCc"
```
### Normalizing Strings
Normalize strings by removing leading/trailing whitespace, fixing indentation, and more.
```typescript
import { normalize } from '@push.rocks/smartstring';
// Normalize a multi-line string
const exampleString = `
This is an example.
The indentation will be fixed.
`;
const normalized = normalize.standard(exampleString);
console.log(normalized);
```
### Working with Docker Environment Variables
Transform an array of Docker environment variables into an object for easy access.
```typescript
import { docker } from '@push.rocks/smartstring';
const envVars = ['NODE_ENV=production', 'PORT=3000'];
const envObject = docker.makeEnvObject(envVars);
console.log(envObject.NODE_ENV); // Output: "production"
console.log(envObject.PORT); // Output: "3000"
```
This guide covers the primary features of `@push.rocks/smartstring`, making string manipulation and information extraction simple and efficient in your TypeScript projects.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

23
test/test.base64.both.ts Normal file
View File

@ -0,0 +1,23 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@push.rocks/tapbundle';
// Base64
let testBase64: smartstring.Base64;
tap.test('expect create a valid instance of Base64', async () => {
testBase64 = new smartstring.Base64('somestring', 'string');
expect(testBase64).toBeInstanceOf(smartstring.Base64);
});
tap.test('expect read output a file as base64 and base64uri', async () => {
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
});
tap.test('should test for a valid base64 token', async () => {
const result = smartstring.base64.isBase64('dGVzdA==');
expect(result).toBeTrue();
});
tap.start();

2
test/test.d.ts vendored
View File

@ -1,2 +0,0 @@
declare let smartstring: any;
declare let should: any;

12
test/test.docker.both.ts Normal file
View File

@ -0,0 +1,12 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@push.rocks/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).toEqual('sub.domain.tld');
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
});
tap.start();

37
test/test.domain.both.ts Normal file
View File

@ -0,0 +1,37 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@push.rocks/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).toBeInstanceOf(smartstring.Domain);
console.log(testDomain);
});
tap.test('expect have a .topLevel', async () => {
expect(testDomain.topLevel).toEqual('level1D');
});
tap.test('expect have a .level2', async () => {
expect(testDomain.level2).toEqual('level2D');
});
tap.test('expect have a .level3', async () => {
expect(testDomain.level3).toEqual('level3D');
});
tap.test('expect have the correct dns zone name', async () => {
expect(testDomain.zoneName).toEqual('level2D.level1D');
});
tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).toEqual('https');
});
tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2);
});
tap.start();

26
test/test.git.both.ts Normal file
View File

@ -0,0 +1,26 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@push.rocks/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).toBeInstanceOf(smartstring.GitRepo);
});
tap.test('expect return a .host', async () => {
expect(testGit.host).toEqual('github.com');
});
tap.test('expect return a .user', async () => {
expect(testGit.user).toEqual('pushrocks');
});
tap.test('expect return a .repo', async () => {
expect(testGit.repo).toEqual('smartstring');
});
tap.test('expect return a .httpsUrl', async () => {
expect(testGit.httpsUrl).toEqual('https://github.com/pushrocks/smartstring.git');
});
tap.test('expect return a .sshUrl', async () => {
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
});
tap.start();

28
test/test.indent.both.ts Normal file
View File

@ -0,0 +1,28 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@push.rocks/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"}

View File

@ -0,0 +1,20 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should normalize a string', async (toolsArg) => {
const testString = `
myawesome string;
is indented with two spaces
`;
const normalizedString = smartstring.normalize.standard(testString);
console.log(normalizedString);
expect(normalizedString).toEqual(
`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();
})
})
})
});

14
test/test.type.both.ts Normal file
View File

@ -0,0 +1,14 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should state valuid utf8', async () => {
expect(smartstring.type.isUtf8('hithere')).toBeTrue();
});
tap.test('should state wether base64 string is valid', async () => {
const base64String = smartstring.base64.encode('hi there');
expect(smartstring.type.isBase64(base64String)).toBeTrue();
expect(smartstring.type.isBase64('hi there')).toBeFalse();
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartstring',
version: '4.0.15',
description: 'handle strings in smart ways. TypeScript ready.'
}

View File

@ -1,12 +1,11 @@
/// <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.js';
import * as docker from './smartstring.docker.js';
import * as indent from './smartstring.indent.js';
import * as normalize from './smartstring.normalize.js';
import * as type from './smartstring.type.js';
let smartstring = {
git : SmartstringGit.git,
docker: SmartstringDocker,
typescript: SmartstringTypescript
};
export { create, docker, normalize, indent, type };
export = smartstring;
export { Base64, base64 } from './smartstring.base64.js';
export { Domain } from './smartstring.domain.js';
export { GitRepo } from './smartstring.git.js';

79
ts/smartstring.base64.ts Normal file
View File

@ -0,0 +1,79 @@
import * as plugins from './smartstring.plugins.js';
/**
* the type for base 64
*/
export type TStringInputType = 'string' | 'base64' | 'base64uri';
/**
* handle base64 strings
*/
export class Base64 {
private refString: string;
constructor(inputStringArg, typeArg: TStringInputType) {
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);
},
/**
*
* @param stringArg
* checks wether the string is base64 encoded
*/
isBase64: (stringArg: string) => {
const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/;
return regex.test(stringArg);
},
};

29
ts/smartstring.create.ts Normal file
View File

@ -0,0 +1,29 @@
import * as plugins from './smartstring.plugins.js';
/**
* 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 = (): string => {
return plugins.isounique.uni();
};

View File

@ -1,17 +1,18 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins.js';
/**
* 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;
};

87
ts/smartstring.domain.ts Normal file
View File

@ -0,0 +1,87 @@
import * as plugins from './smartstring.plugins.js';
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) {
// lets do the node standard stuff first
this.protocol = this._protocolRegex(domainStringArg);
if (!this.protocol) {
domainStringArg = `https://${domainStringArg}`;
}
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
// lets do the rest after
const regexMatches = this._domainRegex(
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
);
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.zoneName = this.level2 + '.' + this.level1;
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
// 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

@ -1,61 +1,57 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins.js';
/* ---------------------------------------------- *
* ------------------ 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.js';
/**
* 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,51 @@
import * as plugins from './smartstring.plugins.js';
/**
* 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);
};
export interface INormalizeOptions {
stripLeadingTrailingEmptyLines?: boolean;
stripAllEmptyLines?: boolean;
stripIndent?: boolean;
normalizeNewline?: boolean;
replaceTabs?: boolean;
}
/**
* Normalizes a string
* @param stringArg
* @param options
*/
export const standard = (stringArg: string, options?: INormalizeOptions): string => {
let result = stringArg;
if (!options || options.stripIndent) {
result = plugins.stripIndent(result); // fix indention
}
if (!options || options.normalizeNewline) {
result = result.replace(/\r\n/g, '\n'); // fix newlines
}
if (!options || options.replaceTabs) {
result = replaceAll(result, '\t/', ' '); // fix tabs
}
if (!options || options.stripLeadingTrailingEmptyLines) {
result = result.replace(/^\s*[\r\n]/gm, '').replace(/\s*[\r\n]$/gm, '');
}
if (!options || options.stripAllEmptyLines) {
result = result.replace(/^\s*[\r\n]/gm, '');
}
return result;
};

View File

@ -1,6 +1,17 @@
/// <reference path="./typings/main.d.ts" />
let plugins = {
beautylog: require("beautylog")
};
// node native
import * as smartenv from '@push.rocks/smartenv';
const smartenvInstance = new smartenv.Smartenv();
import * as isounique from '@push.rocks/isounique';
export = plugins;
export { isounique };
import * as url from 'url';
export { url };
// third party
import { Base64 as jsBase64 } from 'js-base64';
import stripIndent from 'strip-indent';
import randomatic from 'randomatic';
export { jsBase64, stripIndent, randomatic };

108
ts/smartstring.type.ts Normal file
View File

@ -0,0 +1,108 @@
import * as plugins from './smartstring.plugins.js';
import * as base64 from './smartstring.base64.js';
export const isUtf8 = (stringArg: string): boolean => {
// Convert string to a Uint8Array. In browsers, this will be a bit more complex
// because we need to convert the string to a binary representation first.
const encoder = new TextEncoder();
const bytes = encoder.encode(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;
};
export const isBase64 = (stringArg: string) => {
const notBase64 = /[^A-Z0-9+\/=]/i;
const len = stringArg.length;
if (!len || len % 4 !== 0 || notBase64.test(stringArg)) {
return false;
}
const firstPaddingChar = stringArg.indexOf('=');
return (
firstPaddingChar === -1 ||
firstPaddingChar === len - 1 ||
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=')
);
};

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"
}
}

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}