Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
ae861fa271 | |||
3e78466e5f | |||
eea19bcd89 | |||
1fc95fcf0e | |||
14ba4465d9 | |||
707e31d517 | |||
64d85e711a | |||
34a5cc9862 | |||
d43d1ba212 | |||
65e771f1ba | |||
5825a602ed | |||
5e961f7a5b | |||
36bcb9265a | |||
53bf2f3569 | |||
523ab7ee77 | |||
d60cc5430f | |||
c0035bb4f3 | |||
976f81420f | |||
1be144d099 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
|
140
.gitlab-ci.yml
140
.gitlab-ci.yml
@ -1,140 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- npm install -g @shipzone/npmci
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
@ -12,10 +12,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartstring",
|
"gitrepo": "smartstring",
|
||||||
"description": "handle strings in smart ways. TypeScript ready.",
|
"description": "handle strings in smart ways. TypeScript ready.",
|
||||||
"npmPackagename": "@pushrocks/smartstring",
|
"npmPackagename": "@push.rocks/smartstring",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19036
package-lock.json
generated
19036
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@push.rocks/smartstring",
|
||||||
"version": "4.0.0",
|
"version": "4.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "handle strings in smart ways. TypeScript ready.",
|
"description": "handle strings in smart ways. TypeScript ready.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -8,11 +8,12 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://gitlab.com/pushrocks/smartstring.git"
|
"url": "git+https://gitlab.com/push.rocks/smartstring.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"regex",
|
"regex",
|
||||||
@ -21,29 +22,27 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartstring/issues"
|
"url": "https://gitlab.com/push.rocks/smartstring/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
"homepage": "https://gitlab.com/push.rocks/smartstring#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.59",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.2.31",
|
"@git.zone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.69",
|
"@git.zone/tstest": "^1.0.84",
|
||||||
"@pushrocks/tapbundle": "^5.0.2",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^17.0.21",
|
"@types/node": "^20.10.5"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/isounique": "^1.0.5",
|
"@push.rocks/isounique": "^1.0.5",
|
||||||
"@pushrocks/smartenv": "^5.0.0",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@types/randomatic": "^3.1.3",
|
"@types/randomatic": "^3.1.5",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"crypto-random-string": "^4.0.0",
|
"crypto-random-string": "^5.0.0",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.5",
|
||||||
"normalize-newline": "^4.1.0",
|
"normalize-newline": "^4.1.0",
|
||||||
"randomatic": "^3.1.1",
|
"randomatic": "^3.1.1",
|
||||||
"strip-indent": "^4.0.0",
|
"strip-indent": "^4.0.0",
|
||||||
"url": "^0.11.0"
|
"url": "^0.11.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
5920
pnpm-lock.yaml
generated
Normal file
5920
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
readme.md
30
readme.md
@ -1,27 +1,26 @@
|
|||||||
# @pushrocks/smartstring
|
# @push.rocks/smartstring
|
||||||
handle strings in smart ways. TypeScript ready.
|
handle strings in smart ways. TypeScript ready.
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstring)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartstring)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstring)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartstring)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartstring)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartstring)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstring/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartstring/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -71,7 +70,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Base64
|
// Base64
|
||||||
let testBase64: smartstring.Base64;
|
let testBase64: smartstring.Base64;
|
||||||
|
|
||||||
tap.test('expect create a valid instance of Base64', async () => {
|
tap.test('expect create a valid instance of Base64', async () => {
|
||||||
testBase64 = new smartstring.Base64('somestring', 'string');
|
testBase64 = new smartstring.Base64('somestring', 'string');
|
||||||
expect(testBase64).toBeInstanceOf(smartstring.Base64);
|
expect(testBase64).toBeInstanceOf(smartstring.Base64);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('expect read output a file as base64 and base64uri', async () => {
|
tap.test('expect read output a file as base64 and base64uri', async () => {
|
||||||
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
|
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
|
||||||
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
|
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
|
||||||
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
|
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();
|
tap.start();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Docker
|
// Docker
|
||||||
tap.test('expect create a Env Object', async () => {
|
tap.test('expect create a Env Object', async () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Domain
|
// Domain
|
||||||
let testDomain: smartstring.Domain;
|
let testDomain: smartstring.Domain;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// git
|
// git
|
||||||
let testGit: smartstring.GitRepo;
|
let testGit: smartstring.GitRepo;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// indent
|
// indent
|
||||||
let testString = `
|
let testString = `
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
|
|
||||||
@ -9,8 +9,7 @@ tap.test('should normalize a string', async () => {
|
|||||||
`;
|
`;
|
||||||
const normalizedString = smartstring.normalize.standard(testString);
|
const normalizedString = smartstring.normalize.standard(testString);
|
||||||
expect(normalizedString).toEqual(
|
expect(normalizedString).toEqual(
|
||||||
`
|
`myawesome string;
|
||||||
myawesome string;
|
|
||||||
is indented with two spaces
|
is indented with two spaces
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('should state valuid utf8', async () => {
|
tap.test('should state valuid utf8', async () => {
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartstring',
|
||||||
|
version: '4.0.10',
|
||||||
|
description: 'handle strings in smart ways. TypeScript ready.'
|
||||||
|
}
|
@ -3,14 +3,14 @@ import * as plugins from './smartstring.plugins.js';
|
|||||||
/**
|
/**
|
||||||
* the type for base 64
|
* the type for base 64
|
||||||
*/
|
*/
|
||||||
export type TBase64Input = 'string' | 'base64' | 'base64uri';
|
export type TStringInputType = 'string' | 'base64' | 'base64uri';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle base64 strings
|
* handle base64 strings
|
||||||
*/
|
*/
|
||||||
export class Base64 {
|
export class Base64 {
|
||||||
private refString: string;
|
private refString: string;
|
||||||
constructor(inputStringArg, typeArg: TBase64Input) {
|
constructor(inputStringArg, typeArg: TStringInputType) {
|
||||||
switch (typeArg) {
|
switch (typeArg) {
|
||||||
case 'string': // easiest case
|
case 'string': // easiest case
|
||||||
this.refString = inputStringArg;
|
this.refString = inputStringArg;
|
||||||
@ -66,4 +66,14 @@ export let base64 = {
|
|||||||
decode: (stringArg: string) => {
|
decode: (stringArg: string) => {
|
||||||
return plugins.jsBase64.decode(stringArg);
|
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);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ export class GitRepo {
|
|||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
const gitRegex = function (stringArg: string) {
|
const gitRegex = function (stringArg: string) {
|
||||||
const regexString =
|
const regexString =
|
||||||
/([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/;
|
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
|
||||||
let regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg);
|
||||||
return regexMatches;
|
return regexMatches;
|
||||||
};
|
};
|
||||||
|
@ -10,13 +10,42 @@ export const replaceAll = (stringArg: string, searchPattern: string, replacement
|
|||||||
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
|
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface INormalizeOptions {
|
||||||
|
stripLeadingTrailingEmptyLines?: boolean;
|
||||||
|
stripAllEmptyLines?: boolean;
|
||||||
|
stripIndent?: boolean;
|
||||||
|
normalizeNewline?: boolean;
|
||||||
|
replaceTabs?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* normalizes a string
|
* Normalizes a string
|
||||||
* @param stringArg
|
* @param stringArg
|
||||||
|
* @param options
|
||||||
*/
|
*/
|
||||||
export const standard = (stringArg: string): string => {
|
export const standard = (stringArg: string, options?: INormalizeOptions): string => {
|
||||||
let fix1 = plugins.stripIndent(stringArg); // fix indention
|
let result = stringArg;
|
||||||
let fix2 = plugins.normalizeNewline(fix1); // fix newlines
|
|
||||||
let fix3 = replaceAll(fix2, '\t/', ' '); // fix tabs
|
if (!options || options.stripIndent) {
|
||||||
return fix3;
|
result = plugins.stripIndent(result); // fix indention
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options || options.normalizeNewline) {
|
||||||
|
result = plugins.normalizeNewline(result); // 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartenv from '@push.rocks/smartenv';
|
||||||
const smartenvInstance = new smartenv.Smartenv();
|
const smartenvInstance = new smartenv.Smartenv();
|
||||||
import * as isounique from '@pushrocks/isounique';
|
import * as isounique from '@push.rocks/isounique';
|
||||||
|
|
||||||
export { isounique };
|
export { isounique };
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"moduleResolution": "nodenext"
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user