BREAKING CHANGE(core): switch to esm
This commit is contained in:
parent
bb7bee3b42
commit
143eef8781
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -36,6 +39,7 @@ auditProductionDependencies:
|
|||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
auditDevDependencies:
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
@ -96,10 +100,9 @@ codequality:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -119,11 +122,10 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
4
.snyk
4
.snyk
@ -1,4 +0,0 @@
|
|||||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
|
||||||
version: v1.13.3
|
|
||||||
ignore: {}
|
|
||||||
patch: {}
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
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
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@ -5,7 +5,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smarthash",
|
"gitrepo": "smarthash",
|
||||||
"shortDescription": "simplifies access to node hash functions",
|
"description": "simplifies access to node hash functions",
|
||||||
"npmPackagename": "@pushrocks/smarthash",
|
"npmPackagename": "@pushrocks/smarthash",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
18047
package-lock.json
generated
18047
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -7,7 +7,8 @@
|
|||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"pushrocks",
|
"pushrocks",
|
||||||
@ -21,17 +22,15 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.63",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.37",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.71",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"@types/node": "^14.14.31",
|
"@types/node": "^18.0.0"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartjson": "^4.0.6",
|
"@pushrocks/smartjson": "^5.0.1",
|
||||||
"@pushrocks/smartpromise": "^3.1.3",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@types/through2": "^2.0.36",
|
"@types/through2": "^2.0.36",
|
||||||
"through2": "^4.0.2"
|
"through2": "^4.0.2"
|
||||||
},
|
},
|
||||||
@ -49,5 +48,6 @@
|
|||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
],
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
20
test/test.ts
20
test/test.ts
@ -1,31 +1,31 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import fs = require('fs');
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import * as smarthash from '../ts/index';
|
import * as smarthash from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('sha256FromStringSync should convert a String to sha256 hash synchronously', async () => {
|
tap.test('sha256FromStringSync should convert a String to sha256 hash synchronously', async () => {
|
||||||
const testHash = smarthash.sha256FromStringSync('test');
|
const testHash = smarthash.sha256FromStringSync('test');
|
||||||
const testHash2 = smarthash.sha256FromStringSync('testString');
|
const testHash2 = smarthash.sha256FromStringSync('testString');
|
||||||
const testHash3 = smarthash.sha256FromStringSync('test');
|
const testHash3 = smarthash.sha256FromStringSync('test');
|
||||||
expect(testHash).to.equal(testHash3);
|
expect(testHash).toEqual(testHash3);
|
||||||
expect(testHash).to.not.equal('test');
|
expect(testHash).not.toEqual('test');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('sha256fromStringSync should convert a String to sha256 hash synchronously', async () => {
|
tap.test('sha256fromStringSync should convert a String to sha256 hash synchronously', async () => {
|
||||||
const resultString = await smarthash.sha256FromString('test');
|
const resultString = await smarthash.sha256FromString('test');
|
||||||
const compareString = smarthash.sha256FromStringSync('test');
|
const compareString = smarthash.sha256FromStringSync('test');
|
||||||
expect(resultString).to.equal(compareString);
|
expect(resultString).toEqual(compareString);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('sha256fromStream should convert a Stream to sha256', async (tools) => {
|
tap.test('sha256fromStream should convert a Stream to sha256', async (tools) => {
|
||||||
const readStream = fs.createReadStream('./test/testImageForHash.jpg');
|
const readStream = fs.createReadStream('./test/testImageForHash.jpg');
|
||||||
const resultString: string = await smarthash.sha256FromStream(readStream);
|
const resultString: string = await smarthash.sha256FromStream(readStream);
|
||||||
expect(resultString).to.equal('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
|
expect(resultString).toEqual('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('sha256fromFile should convert a Stream to sha256', async () => {
|
tap.test('sha256fromFile should convert a Stream to sha256', async () => {
|
||||||
const resultString = await smarthash.sha256FromFile('./test/testImageForHash.jpg');
|
const resultString = await smarthash.sha256FromFile('./test/testImageForHash.jpg');
|
||||||
expect(resultString).to.equal('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
|
expect(resultString).toEqual('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should produce reproducible hash from Object', async () => {
|
tap.test('should produce reproducible hash from Object', async () => {
|
||||||
@ -43,13 +43,13 @@ tap.test('should produce reproducible hash from Object', async () => {
|
|||||||
wow: 'twoe',
|
wow: 'twoe',
|
||||||
hithere: 1,
|
hithere: 1,
|
||||||
});
|
});
|
||||||
expect(hash1).to.equal(hash2);
|
expect(hash1).toEqual(hash2);
|
||||||
expect(hash1).to.not.equal(hash3);
|
expect(hash1).not.toEqual(hash3);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create md5hash from string', async () => {
|
tap.test('should create md5hash from string', async () => {
|
||||||
const md5Hash = await smarthash.md5FromString('hellothere');
|
const md5Hash = await smarthash.md5FromString('hellothere');
|
||||||
expect(md5Hash).to.equal('c6f7c372641dd25e0fddf0215375561f');
|
expect(md5Hash).toEqual('c6f7c372641dd25e0fddf0215375561f');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
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: '@pushrocks/smarthash',
|
||||||
|
version: '3.0.0',
|
||||||
|
description: 'simplified access to node hash functions'
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './nodehash.plugins';
|
import * as plugins from './nodehash.plugins.js';
|
||||||
|
|
||||||
export * from './nodehash.sha256';
|
export * from './nodehash.sha256.js';
|
||||||
export * from './nodehash.md5';
|
export * from './nodehash.md5.js';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './nodehash.plugins';
|
import * as plugins from './nodehash.plugins.js';
|
||||||
|
|
||||||
export const hashStreamPipeStop = (resolveFuntion) => {
|
export const hashStreamPipeStop = (resolveFuntion) => {
|
||||||
const forEach = (chunk: Buffer, enc, cb) => {
|
const forEach = (chunk: Buffer, enc, cb) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './nodehash.plugins';
|
import * as plugins from './nodehash.plugins.js';
|
||||||
|
|
||||||
export const md5FromString = async (stringToHash: string) => {
|
export const md5FromString = async (stringToHash: string) => {
|
||||||
return plugins.crypto.createHash('md5').update(stringToHash).digest('hex');
|
return plugins.crypto.createHash('md5').update(stringToHash).digest('hex');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './nodehash.plugins';
|
import * as plugins from './nodehash.plugins.js';
|
||||||
import * as helpers from './nodehash.helpers';
|
import * as helpers from './nodehash.helpers.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates sha256 Hash from Stream
|
* creates sha256 Hash from Stream
|
||||||
@ -56,7 +56,7 @@ export const sha256FromBuffer = async (bufferArg: Buffer): Promise<string> => {
|
|||||||
* computes sha265 Hash from Object
|
* computes sha265 Hash from Object
|
||||||
*/
|
*/
|
||||||
export const sha265FromObject = async (objectArg: any): Promise<string> => {
|
export const sha265FromObject = async (objectArg: any): Promise<string> => {
|
||||||
const stringifiedObject = plugins.smartjson.stringify(objectArg, {});
|
const stringifiedObject = plugins.smartjson.stringify(objectArg);
|
||||||
const hashResult = await sha256FromString(stringifiedObject);
|
const hashResult = await sha256FromString(stringifiedObject);
|
||||||
return hashResult;
|
return hashResult;
|
||||||
};
|
};
|
||||||
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user