BREAKING CHANGE(core): switch to esm

This commit is contained in:
Philipp Kunz 2022-03-31 01:20:01 +02:00
parent 01f4a53b5b
commit e562e8f099
12 changed files with 17580 additions and 1076 deletions

20
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/
.nogit/
# artifacts
coverage/
public/
pages/
coverage/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,16 +1,19 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
@ -18,127 +21,114 @@ stages:
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
only:
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
- 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
- notpriv
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
- docker
allow_failure: true
services:
- docker:stable-dind
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
- 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
- priv
- docker
allow_failure: true
# ====================
# test stage
# ====================
testLTS:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- docker
testSTABLE:
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
only:
- tags
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- docker
- priv
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -146,5 +136,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

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,43 +0,0 @@
# @pushrocks/smartstream
simplifies access to node streams
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstream)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstream)
* [github.com (source mirror)](https://github.com/pushrocks/smartstream)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstream/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartstream/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstream/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartstream/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartstream/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartstream.svg)](https://www.npmjs.com/package/@pushrocks/smartstream)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartstream/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartstream)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```typescript
import { Smartstream } from 'smartstream'
import * as gUglify from 'gulp-uglify'
let mySmartstream = new Smartstream([
gulp.src(['./file1.js','./file2.js']),
gUglify(),
gulp.dest('./some/output/path')
])
mySmartstream.onError((err) => { /* handle error */ }) // handles all errors in stream
myStream.onCustomEvent('myeventname', (args...) => { /* Do something */ }) // emit an custom event anywhere in your stream
mySmartstream.run().then(() => {/* do something when stream is finished */})
```
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -4,11 +4,12 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartstream",
"shortDescription": "simplifies access to node streams",
"description": "simplifies access to node streams",
"npmPackagename": "@pushrocks/smartstream",
"license": "MIT"
}

18320
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,9 @@
"version": "1.0.14",
"private": false,
"description": "simplifies access to node streams",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
@ -20,15 +21,30 @@
},
"homepage": "https://gitlab.com/pushrocks/smartstream#README",
"devDependencies": {
"@gitzone/tsbuild": "^2.1.8",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/tapbundle": "^3.0.7",
"tslint": "^5.12.1",
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tstest": "^1.0.70",
"@pushrocks/tapbundle": "^5.0.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartpromise": "^2.0.5",
"@types/through2": "^2.0.34",
"through2": "^3.0.0"
}
"@pushrocks/smartpromise": "^3.1.7",
"@types/through2": "^2.0.36",
"through2": "^4.0.2"
},
"browserslist": [
"last 1 chrome versions"
],
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -1,13 +1,13 @@
import fs = require('fs');
import fs from 'fs';
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartstream from '../ts/index';
import * as smartstream from '../ts/index.js';
let testSmartstream: smartstream.Smartstream;
tap.test('should combine a stream', async () => {
testSmartstream = new smartstream.Smartstream([
fs.createReadStream('./test/assets/test.md'),
fs.createWriteStream('./test/assets/testCopy.md')
fs.createWriteStream('./test/assets/testCopy.md'),
]);
await testSmartstream.run();
});

View File

@ -1,10 +1,10 @@
import * as plugins from './smartstream.plugins';
import * as plugins from './smartstream.plugins.js';
// interfaces
import { Transform } from 'stream';
export interface IErrorFunction {
(err): any;
(err: Error): any;
}
export interface ICustomEventFunction {
@ -20,7 +20,7 @@ export interface ICustomEventObject {
* class Smartstream handles
*/
export class Smartstream {
private streamArray = [];
private streamArray: Array<plugins.stream.Duplex> = [];
private customEventObjectArray: ICustomEventObject[] = [];
private streamStartedDeferred = plugins.smartpromise.defer();
@ -44,7 +44,7 @@ export class Smartstream {
onCustomEvent(eventNameArg: string, eventFunctionArg: ICustomEventFunction) {
this.customEventObjectArray.push({
eventName: eventNameArg,
eventFunction: eventFunctionArg
eventFunction: eventFunctionArg,
});
}
@ -56,7 +56,7 @@ export class Smartstream {
const done = plugins.smartpromise.defer<void>();
// clone Array
const streamExecutionArray = [];
const streamExecutionArray: Array<plugins.stream.Duplex> = [];
for (const streamItem of this.streamArray) {
streamExecutionArray.push(streamItem);
}
@ -68,7 +68,7 @@ export class Smartstream {
if (firstIteration === true) {
finalStream = stream;
}
stream.on('error', err => {
stream.on('error', (err) => {
done.reject(err);
});
for (const customEventObject of this.customEventObjectArray) {
@ -100,7 +100,7 @@ export let cleanPipe = () => {
(file, enc, cb) => {
cb();
},
cb => {
(cb) => {
cb();
}
);

View File

@ -1,4 +1,12 @@
import * as stream from 'stream';
export { stream };
// pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
export { smartpromise };
// thirdparty
import * as through2 from 'through2';
export { smartpromise, through2 };
export { through2 };

View File

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