Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
fa76cec8b4 | |||
a2406be478 | |||
816ab19cb3 | |||
46b7d69b10 | |||
5926276c16 | |||
1bc3bc3b95 | |||
6dee2638c2 | |||
5580cb5e8f | |||
bcb8fd0901 | |||
16b16ee5d2 | |||
eca1dfb8d1 | |||
d34e9ab551 | |||
e00eaca362 | |||
a2dd2ab6f0 | |||
bd3ae675b0 | |||
9b4b081d9a | |||
8c0efd532f |
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
|
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,2 +1,20 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
150
.gitlab-ci.yml
150
.gitlab-ci.yml
@ -1,150 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
sast:
|
||||
stage: security
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
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
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -4,13 +4,27 @@
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartevent",
|
||||
"shortDescription": "lightweight gulp replacement",
|
||||
"npmPackagename": "@pushrocks/smartgulp",
|
||||
"license": "MIT"
|
||||
"description": "A lightweight replacement for gulp, featuring smart stream handling and file manipulation.",
|
||||
"npmPackagename": "@push.rocks/smartgulp",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"build tool",
|
||||
"gulp replacement",
|
||||
"stream manipulation",
|
||||
"file manipulation",
|
||||
"typescript",
|
||||
"task runner",
|
||||
"pipeline",
|
||||
"development tool"
|
||||
]
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
1590
package-lock.json
generated
1590
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
72
package.json
72
package.json
@ -1,41 +1,65 @@
|
||||
{
|
||||
"name": "@pushrocks/smartgulp",
|
||||
"version": "2.0.2",
|
||||
"name": "@push.rocks/smartgulp",
|
||||
"version": "3.0.4",
|
||||
"private": false,
|
||||
"description": "lightweight gulp replacement",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"description": "A lightweight replacement for gulp, featuring smart stream handling and file manipulation.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartgulp.git"
|
||||
"url": "https://code.foss.global/push.rocks/smartgulp.git"
|
||||
},
|
||||
"keywords": [
|
||||
"gulp"
|
||||
"build tool",
|
||||
"gulp replacement",
|
||||
"stream manipulation",
|
||||
"file manipulation",
|
||||
"typescript",
|
||||
"task runner",
|
||||
"pipeline",
|
||||
"development tool"
|
||||
],
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartgulp/issues"
|
||||
"url": "https://gitlab.com/push.rocks/smartevent/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartgulp#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartgulp",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.8",
|
||||
"@gitzone/tsrun": "^1.1.17",
|
||||
"@gitzone/tstest": "^1.0.18",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^11.9.4",
|
||||
"gulp-function": "^2.2.14"
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.88",
|
||||
"@push.rocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.11.25",
|
||||
"@push.rocks/gulp-function": "^2.2.14"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartevent": "^2.0.3",
|
||||
"@pushrocks/smartfile": "^7.0.0",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartstream": "^1.0.14",
|
||||
"@types/through2": "^2.0.34",
|
||||
"through2": "^3.0.0"
|
||||
}
|
||||
}
|
||||
"@push.rocks/smartevent": "^2.0.5",
|
||||
"@push.rocks/smartfile": "^11.0.4",
|
||||
"@push.rocks/smartpromise": "^4.0.2",
|
||||
"@push.rocks/smartstream": "^3.0.33",
|
||||
"@types/through2": "^2.0.41",
|
||||
"through2": "^4.0.2"
|
||||
},
|
||||
"type": "module",
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
5709
pnpm-lock.yaml
generated
Normal file
5709
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
113
readme.md
113
readme.md
@ -1,26 +1,103 @@
|
||||
# @pushrocks/smartevent
|
||||
# @push.rocks/smartgulp
|
||||
lightweight gulp replacement
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartgulp)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartevent)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartevent)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartevent/)
|
||||
## Install
|
||||
To install `@push.rocks/smartgulp`, use the following command in your terminal:
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartevent/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartevent/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartgulp)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartgulp)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
```bash
|
||||
npm install @push.rocks/smartgulp --save-dev
|
||||
```
|
||||
|
||||
This will add `smartgulp` to your project's `devDependencies`. `smartgulp` is designed to be a lightweight replacement for `gulp`, thus assuming its role in development processes rather than in production environments.
|
||||
|
||||
## Usage
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
In this section, we'll dive into how to effectively utilize `@push.rocks/smartgulp` within your project. `smartgulp` aims to present a simplified interface for handling file streams and processing, similar to traditional `gulp` but with a modernized API and reduced complexity.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
### Basic Stream Creation and File Manipulation
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
First, let's demonstrate how to create a stream from source files and then manipulate these files, ultimately saving the transformed files to a desired directory.
|
||||
|
||||
```typescript
|
||||
// Import smartgulp methods
|
||||
import { src, dest } from '@push.rocks/smartgulp';
|
||||
|
||||
// Create a stream from source files using the `src` function
|
||||
src(['src/**/*.ts']) // Specify the glob pattern
|
||||
.pipe(
|
||||
// Example transformation: Convert TypeScript to JavaScript
|
||||
// Use your desired transformer here
|
||||
ts() // Assuming `ts()` is a function returning a Transform stream
|
||||
)
|
||||
.pipe(
|
||||
// Save the transformed files to the 'dist' directory
|
||||
dest('dist')
|
||||
);
|
||||
```
|
||||
|
||||
In the example above, `src(['src/**/*.ts'])` creates a stream that reads all TypeScript files in the `src` directory. Each file is then transformed (for instance, compiled from TypeScript to JavaScript, though the actual transformation function `ts()` is illustrative) and finally written to the `dist` directory via `dest('dist')`.
|
||||
|
||||
### Advanced Usage: Custom Transformations
|
||||
|
||||
`smartgulp` can be extended with custom transformations, allowing you to perform virtually any file manipulation task. Here’s how you can create and use custom transform streams:
|
||||
|
||||
```typescript
|
||||
import { src, dest } from '@push.rocks/smartgulp';
|
||||
import { Transform } from 'stream';
|
||||
|
||||
// Creating a custom transform to prefix file contents
|
||||
const prefixTransform = new Transform({
|
||||
objectMode: true,
|
||||
transform(file, encoding, callback) {
|
||||
const prefix = '/* Prefixed content */\n';
|
||||
file.contents = Buffer.from(prefix + file.contents.toString());
|
||||
callback(null, file); // Pass the modified file along the stream
|
||||
}
|
||||
});
|
||||
|
||||
// Usage in a pipeline
|
||||
src(['src/**/*.js']) // Adjust glob pattern as needed
|
||||
.pipe(prefixTransform) // Apply custom prefixing
|
||||
.pipe(dest('dist')); // Output to 'dist' directory
|
||||
```
|
||||
|
||||
In this scenario, `prefixTransform` is a custom transformation that prepends a comment to the contents of each `.js` file fetched through `src(['src/**/*.js'])`. After transformation, the files are written to the `dist` directory.
|
||||
|
||||
### Combining with Other Libraries
|
||||
|
||||
`@push.rocks/smartgulp` can be seamlessly integrated with other libraries, making it easy to enhance your build pipeline with additional functionality like linting, minification, and more.
|
||||
|
||||
```typescript
|
||||
import { src, dest } from '@push.rocks/smartgulp';
|
||||
import someOtherLib from 'some-other-lib';
|
||||
|
||||
src(['src/**/*.css']) // Example with CSS files
|
||||
.pipe(
|
||||
// Assuming `someOtherLib` provides a method for CSS minification
|
||||
someOtherLib.minifyCSS()
|
||||
)
|
||||
.pipe(dest('dist'));
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
`@push.rocks/smartgulp` offers a simplified, promise-based approach to stream processing and file manipulation. By leveraging its functionality along with custom and third-party transforms, you can create powerful and efficient build pipelines tailored to your project's needs. Whether you're compiling, bundling, minifying, or simply copying files, `smartgulp` provides a lightweight, flexible foundation for your automated workflows.
|
||||
|
||||
## 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.
|
||||
|
20
test/test.ts
20
test/test.ts
@ -1,16 +1,16 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as smartgulp from '../ts/index';
|
||||
import * as smartstream from '@pushrocks/smartstream';
|
||||
import * as smartgulp from '../ts/index.js';
|
||||
import * as smartstream from '@push.rocks/smartstream';
|
||||
import * as gulpFunction from 'gulp-function';
|
||||
import * as smartq from 'smartq';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
tap.test('smartgulp.src -> should read a directoy', async tools => {
|
||||
let done = smartq.defer();
|
||||
tap.test('smartgulp.src -> should read a directoy', async (tools) => {
|
||||
let done = smartpromise.defer();
|
||||
smartgulp
|
||||
.src(['./test/testfiles/**/*.md'])
|
||||
.pipe(
|
||||
gulpFunction.forEach(async fileArg => {
|
||||
gulpFunction.forEach(async (fileArg) => {
|
||||
console.log(fileArg.path);
|
||||
})
|
||||
)
|
||||
@ -23,11 +23,11 @@ tap.test('smartgulp.src -> should read a directoy', async tools => {
|
||||
});
|
||||
|
||||
tap.test('smartgulp shoould replace files', async () => {
|
||||
let done = smartq.defer();
|
||||
let done = smartpromise.defer();
|
||||
smartgulp
|
||||
.src(['./test/testfiles/**/*.md'])
|
||||
.pipe(
|
||||
gulpFunction.forEach(async fileArg => {
|
||||
gulpFunction.forEach(async (fileArg) => {
|
||||
console.log(fileArg.path);
|
||||
})
|
||||
)
|
||||
@ -40,4 +40,4 @@ tap.test('smartgulp shoould replace files', async () => {
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
tap.start();
|
||||
await 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: '@push.rocks/smartgulp',
|
||||
version: '3.0.4',
|
||||
description: 'lightweight gulp replacement'
|
||||
}
|
@ -1 +1 @@
|
||||
export * from './smartgulp.gulpapi';
|
||||
export * from './smartgulp.gulpapi.js';
|
||||
|
@ -1,7 +1,7 @@
|
||||
// this file contains the code to generate and handle the stream
|
||||
|
||||
import * as plugins from './smartgulp.plugins';
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
import * as plugins from './smartgulp.plugins.js';
|
||||
import { SmartFile } from '@push.rocks/smartfile';
|
||||
|
||||
import { Transform } from 'stream';
|
||||
|
||||
@ -11,7 +11,7 @@ export class GulpStream {
|
||||
/**
|
||||
* allows you to pipe a SmartfileArray into the stream
|
||||
*/
|
||||
async pipeSmartfileArray(smartfileArray: Smartfile[]) {
|
||||
async pipeSmartfileArray(smartfileArray: SmartFile[]) {
|
||||
// ensure what we get is an array
|
||||
if (!Array.isArray(smartfileArray)) {
|
||||
throw new Error('fileArg has unknown format');
|
||||
@ -20,8 +20,6 @@ export class GulpStream {
|
||||
let hasWritten = this.stream.push(smartfile);
|
||||
if (!hasWritten) {
|
||||
await plugins.smartevent.once(this.stream, 'drain');
|
||||
} else {
|
||||
// iterate
|
||||
}
|
||||
}
|
||||
// signal end of stream;
|
||||
|
@ -1,14 +1,14 @@
|
||||
// this file contains the implementation of the standard gulp api
|
||||
import * as plugins from './smartgulp.plugins';
|
||||
import { GulpStream } from './smartgulp.classes.gulpstream';
|
||||
import * as plugins from './smartgulp.plugins.js';
|
||||
import { GulpStream } from './smartgulp.classes.gulpstream.js';
|
||||
import { Transform } from 'stream';
|
||||
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
import { SmartFile } from '@push.rocks/smartfile';
|
||||
|
||||
export let src = (minimatchPathArrayArg: string[]): Transform => {
|
||||
let gulpStream = new GulpStream();
|
||||
let handleFiles = async () => {
|
||||
let smartfileArray: Smartfile[] = [];
|
||||
let smartfileArray: SmartFile[] = [];
|
||||
for (let minimatchPath of minimatchPathArrayArg) {
|
||||
let localSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
||||
process.cwd(),
|
||||
@ -18,22 +18,31 @@ export let src = (minimatchPathArrayArg: string[]): Transform => {
|
||||
}
|
||||
gulpStream.pipeSmartfileArray(smartfileArray);
|
||||
};
|
||||
handleFiles().catch(err => {
|
||||
handleFiles().catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return gulpStream.stream;
|
||||
};
|
||||
|
||||
export let dest = (dirArg: string) => {};
|
||||
export let dest = (dirArg: string) => {
|
||||
const stream = new plugins.smartstream.SmartDuplex({
|
||||
objectMode: true,
|
||||
writeFunction: async (fileArg: SmartFile) => {
|
||||
const filePath = plugins.path.join(dirArg, fileArg.relative);
|
||||
const dirPath = plugins.path.dirname(filePath);
|
||||
await plugins.smartfile.fs.ensureDir(dirPath);
|
||||
await plugins.smartfile.memory.toFs(fileArg.contentBuffer, filePath);
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
};
|
||||
|
||||
export let replace = () => {
|
||||
return plugins.through2.obj(
|
||||
async (file: Smartfile, enc, cb) => {
|
||||
await file.write();
|
||||
cb(null, file);
|
||||
},
|
||||
cb => {
|
||||
cb();
|
||||
const stream = new plugins.smartstream.SmartDuplex({
|
||||
objectMode: true,
|
||||
writeFunction: async (fileArg: SmartFile) => {
|
||||
await fileArg.write();
|
||||
}
|
||||
);
|
||||
});
|
||||
return stream;
|
||||
};
|
||||
|
@ -1,6 +1,14 @@
|
||||
import * as smartevent from '@pushrocks/smartevent';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartstream from '@pushrocks/smartstream';
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
};
|
||||
|
||||
// @push.rocks scope
|
||||
import * as smartevent from '@push.rocks/smartevent';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartstream from '@push.rocks/smartstream';
|
||||
import * as through2 from 'through2';
|
||||
|
||||
export { smartevent, smartfile, smartstream, through2 };
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
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…
x
Reference in New Issue
Block a user