feat(smartgulp): modernize file glob handling and refresh package metadata

This commit is contained in:
2026-05-01 22:17:09 +00:00
parent fa76cec8b4
commit 63c5e20391
22 changed files with 7806 additions and 5150 deletions
+38
View File
@@ -0,0 +1,38 @@
{
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
},
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartgulp",
"shortDescription": "Gulp-style stream utilities",
"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"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\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 or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or 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"
}
}
+106
View File
@@ -0,0 +1,106 @@
# Changelog
## 2026-05-01 - 3.1.0 - feat(smartgulp)
modernize file glob handling and refresh package metadata
- reworks src() to resolve glob base directories and match files with minimatch, including dotfiles
- simplifies dest() by writing SmartFile objects directly with writeToDir() and keeps replace() based on SmartFile.write()
- adds an exports entry, updates build/test tooling and dependencies, and replaces the legacy test suite with NodeNext-compatible tests and improved documentation
## 2024-03-10 - 3.0.4 - maintenance
Release 3.0.4 with project metadata and configuration updates.
- Updated TypeScript configuration
- Updated npmextra.json githost settings
- Refined project description
- Summarizes trivial maintenance commits across 2024-03-30 to 2024-05-29
## 2023-11-25 - 3.0.3 - core
Patch release with a core update.
- Fixed and updated core behavior
## 2023-11-25 - 3.0.2 - core
Patch release with a core update.
- Fixed and updated core behavior
## 2023-11-25 - 3.0.1 - core
Patch release with a core update.
- Fixed and updated core behavior
## 2022-06-09 - 3.0.0 - breaking
Major release introducing a new organization scheme and core breaking changes.
- Switched to a new organization scheme
- Introduced a breaking core update
- Summarizes related changes through 2023-07-10
## 2019-02-20 - 2.0.2 - core
Release with a breaking core update.
- Introduced a breaking change in core
## 2018-09-02 - 2.0.1 - core
Patch release with a core fix.
- Fixed and updated core behavior
## 2018-09-02 - 2.0.0 - dependencies
Major release focused on dependency updates.
- Updated dependencies to latest versions
## 2018-02-16 - 1.0.11 - breaking
Release with scope and system-level changes.
- Introduced a breaking scope update
- Applied a system change
## 2018-02-16 - 1.0.10 - fix
Patch release with a replace fix.
- Fixed replace behavior
## 2018-02-16 - 1.0.9 - maintenance
Patch release with internal maintenance updates.
- Updated smartfile support
## 2018-02-16 - 1.0.8 - fix
Patch release with npm metadata fixes.
- Fixed npmextra.json configuration
## 2018-02-15 - 1.0.7 - maintenance
Patch release with lockfile maintenance.
- Updated yarn.lock
## 2017-05-27 - 1.0.6 - feature
Release adding replace functionality.
- Added replace()
## 2017-05-01 - 1.0.3-1.0.5 - dependencies
Maintenance releases focused on dependency updates.
- Updated dependencies across versions 1.0.3 to 1.0.5
## 2017-04-29 - 1.0.2 - dependencies
Patch release with dependency maintenance.
- Updated dependencies
## 2017-04-29 - 1.0.1 - src
Patch release improving source handling.
- .src is now fully working
## 2017-04-28 - 1.0.0 - core
Initial release establishing expected read and runtime behavior.
- Added initial implementation
- Corrected reading behavior
- Brought functionality to expected working state
-1
View File
@@ -1 +0,0 @@
export * from './smartgulp.gulpapi';
-7
View File
@@ -1,7 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartgulp.gulpapi"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHlDQUFtQyJ9
-10
View File
@@ -1,10 +0,0 @@
/// <reference types="node" />
import { Smartfile } from 'smartfile';
import { Transform } from 'stream';
export declare class GulpStream {
stream: Transform;
/**
* allows you to pipe a SmartfileArray into the stream
*/
pipeSmartfileArray(smartfileArray: Smartfile[]): Promise<void>;
}
-43
View File
@@ -1,43 +0,0 @@
"use strict";
// this file contains the code to generate and handle the stream
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartgulp.plugins");
const stream_1 = require("stream");
class GulpStream {
constructor() {
this.stream = new stream_1.Transform({ objectMode: true });
}
/**
* allows you to pipe a SmartfileArray into the stream
*/
pipeSmartfileArray(smartfileArray) {
return __awaiter(this, void 0, void 0, function* () {
// ensure what we get is an array
if (!Array.isArray(smartfileArray)) {
throw new Error('fileArg has unknown format');
}
for (let smartfile of smartfileArray) {
let hasWritten = this.stream.push(smartfile);
if (!hasWritten) {
yield plugins.smartevent.once(this.stream, 'drain');
}
else {
// iterate
}
}
;
// signal end of stream;
this.stream.push(null);
});
}
}
exports.GulpStream = GulpStream;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRndWxwLmNsYXNzZXMuZ3VscHN0cmVhbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z3VscC5jbGFzc2VzLmd1bHBzdHJlYW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGdFQUFnRTs7Ozs7Ozs7OztBQUVoRSwrQ0FBOEM7QUFHOUMsbUNBQWtDO0FBRWxDO0lBQUE7UUFDRSxXQUFNLEdBQUcsSUFBSSxrQkFBUyxDQUFDLEVBQUUsVUFBVSxFQUFFLElBQUksRUFBRSxDQUFDLENBQUE7SUFxQjlDLENBQUM7SUFuQkM7O09BRUc7SUFDRyxrQkFBa0IsQ0FBQyxjQUEyQjs7WUFDbEQsaUNBQWlDO1lBQ2pDLEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ25DLE1BQU0sSUFBSSxLQUFLLENBQUMsNEJBQTRCLENBQUMsQ0FBQTtZQUMvQyxDQUFDO1lBQ0QsR0FBRyxDQUFDLENBQUMsSUFBSSxTQUFTLElBQUksY0FBYyxDQUFDLENBQUMsQ0FBQztnQkFDckMsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7Z0JBQzVDLEVBQUUsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQztvQkFDaEIsTUFBTSxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxDQUFBO2dCQUNyRCxDQUFDO2dCQUFDLElBQUksQ0FBQyxDQUFDO29CQUNOLFVBQVU7Z0JBQ1osQ0FBQztZQUNILENBQUM7WUFBQSxDQUFDO1lBQ0Ysd0JBQXdCO1lBQ3hCLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO1FBQ3hCLENBQUM7S0FBQTtDQUNGO0FBdEJELGdDQXNCQyJ9
-5
View File
@@ -1,5 +0,0 @@
/// <reference types="node" />
import { Transform } from 'stream';
export declare let src: (minimatchPathArrayArg: string[]) => Transform;
export declare let dest: (dirArg: string) => void;
export declare let replace: () => Transform;
-39
View File
@@ -1,39 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
// this file contains the implementation of the standard gulp api
const plugins = require("./smartgulp.plugins");
const smartgulp_classes_gulpstream_1 = require("./smartgulp.classes.gulpstream");
exports.src = (minimatchPathArrayArg) => {
let gulpStream = new smartgulp_classes_gulpstream_1.GulpStream();
let handleFiles = () => __awaiter(this, void 0, void 0, function* () {
let smartfileArray = [];
for (let minimatchPath of minimatchPathArrayArg) {
let localSmartfileArray = yield plugins.smartfile.fs.fileTreeToObject(process.cwd(), minimatchPath);
smartfileArray = plugins.lodash.concat(smartfileArray, localSmartfileArray);
}
gulpStream.pipeSmartfileArray(smartfileArray);
});
handleFiles().catch(err => {
console.log(err);
});
return gulpStream.stream;
};
exports.dest = (dirArg) => {
};
exports.replace = () => {
return plugins.through2.obj((file, enc, cb) => __awaiter(this, void 0, void 0, function* () {
yield file.write();
cb(null, file);
}), (cb) => {
cb();
});
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRndWxwLmd1bHBhcGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGd1bHAuZ3VscGFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsaUVBQWlFO0FBQ2pFLCtDQUE4QztBQUM5QyxpRkFBMkQ7QUFLaEQsUUFBQSxHQUFHLEdBQUcsQ0FBQyxxQkFBK0IsRUFBYSxFQUFFO0lBQzlELElBQUksVUFBVSxHQUFHLElBQUkseUNBQVUsRUFBRSxDQUFBO0lBQ2pDLElBQUksV0FBVyxHQUFHLEdBQVMsRUFBRTtRQUMzQixJQUFJLGNBQWMsR0FBZ0IsRUFBRSxDQUFBO1FBQ3BDLEdBQUcsQ0FBQyxDQUFDLElBQUksYUFBYSxJQUFJLHFCQUFxQixDQUFDLENBQUMsQ0FBQztZQUNoRCxJQUFJLG1CQUFtQixHQUFHLE1BQU0sT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLGFBQWEsQ0FBQyxDQUFBO1lBQ25HLGNBQWMsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxjQUFjLEVBQUUsbUJBQW1CLENBQUMsQ0FBQTtRQUM3RSxDQUFDO1FBQ0QsVUFBVSxDQUFDLGtCQUFrQixDQUFDLGNBQWMsQ0FBQyxDQUFBO0lBQy9DLENBQUMsQ0FBQSxDQUFBO0lBQ0QsV0FBVyxFQUFFLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxFQUFFO1FBQ3hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7SUFDbEIsQ0FBQyxDQUFDLENBQUE7SUFDRixNQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQTtBQUMxQixDQUFDLENBQUE7QUFFVSxRQUFBLElBQUksR0FBRyxDQUFDLE1BQWMsRUFBRSxFQUFFO0FBRXJDLENBQUMsQ0FBQTtBQUVVLFFBQUEsT0FBTyxHQUFHLEdBQUcsRUFBRTtJQUN4QixNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsQ0FBTyxJQUFlLEVBQUUsR0FBRyxFQUFFLEVBQUUsRUFBRSxFQUFFO1FBQzdELE1BQU0sSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ2xCLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUE7SUFDaEIsQ0FBQyxDQUFBLEVBQUUsQ0FBQyxFQUFFLEVBQUUsRUFBRTtRQUNSLEVBQUUsRUFBRSxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDLENBQUEifQ==
-6
View File
@@ -1,6 +0,0 @@
import * as smartevent from 'smartevent';
import * as smartfile from 'smartfile';
import * as smartstream from 'smartstream';
import * as lodash from 'lodash';
import * as through2 from 'through2';
export { lodash, smartevent, smartfile, smartstream, through2 };
-13
View File
@@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const smartevent = require("smartevent");
exports.smartevent = smartevent;
const smartfile = require("smartfile");
exports.smartfile = smartfile;
const smartstream = require("smartstream");
exports.smartstream = smartstream;
const lodash = require("lodash");
exports.lodash = lodash;
const through2 = require("through2");
exports.through2 = through2;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRndWxwLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGd1bHAucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlDQUF3QztBQVF0QyxnQ0FBVTtBQVBaLHVDQUFzQztBQVFwQyw4QkFBUztBQVBYLDJDQUEwQztBQVF4QyxrQ0FBVztBQVBiLGlDQUFnQztBQUk5Qix3QkFBTTtBQUhSLHFDQUFvQztBQU9sQyw0QkFBUSJ9
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
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.
+14 -6
View File
@@ -1,14 +1,15 @@
{
"npmci": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmRegistryUrl": "registry.npmjs.org"
},
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartevent",
"gitrepo": "smartgulp",
"shortDescription": "Gulp-style stream utilities",
"description": "A lightweight replacement for gulp, featuring smart stream handling and file manipulation.",
"npmPackagename": "@push.rocks/smartgulp",
"license": "MIT",
@@ -22,9 +23,16 @@
"pipeline",
"development tool"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"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"
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\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 or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or 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"
}
}
+18 -15
View File
@@ -3,11 +3,14 @@
"version": "3.0.4",
"private": false,
"description": "A lightweight replacement for gulp, featuring smart stream handling and file manipulation.",
"exports": {
".": "./dist_ts/index.js"
},
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)",
"test": "tstest test/",
"build": "tsbuild",
"buildDocs": "tsdoc"
},
"repository": {
@@ -24,27 +27,25 @@
"pipeline",
"development tool"
],
"author": "Lossless GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/push.rocks/smartevent/issues"
"url": "https://code.foss.global/push.rocks/smartgulp/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartgulp",
"devDependencies": {
"@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"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsdoc": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@push.rocks/gulp-function": "^3.0.7",
"@types/node": "^25.6.0"
},
"dependencies": {
"@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"
"@push.rocks/smartfile": "^13.1.3",
"@push.rocks/smartpromise": "^4.2.4",
"@push.rocks/smartstream": "^3.4.2",
"minimatch": "^10.2.5"
},
"type": "module",
"browserslist": [
@@ -59,6 +60,8 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
]
+7441 -4925
View File
File diff suppressed because it is too large Load Diff
+129 -67
View File
@@ -1,103 +1,165 @@
# @push.rocks/smartgulp
lightweight gulp replacement
## Install
To install `@push.rocks/smartgulp`, use the following command in your terminal:
`@push.rocks/smartgulp` is a tiny, modern Gulp-style file pipeline for TypeScript and Node.js projects. It gives you the familiar `src(...).pipe(...).pipe(dest(...))` workflow without pulling in the full Gulp task runner: read files by glob, process them as `SmartFile` objects, write them somewhere else, or replace them in place.
Use it when you want stream-based build steps that stay small, explicit, and easy to compose with regular Node streams.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Installation
Install it as a development dependency:
```bash
npm install @push.rocks/smartgulp --save-dev
pnpm add -D @push.rocks/smartgulp
```
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.
## What It Provides
## Usage
`@push.rocks/smartgulp` exports three pipeline primitives:
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.
| API | Purpose |
| --- | --- |
| `src(patterns)` | Reads matching files from disk and emits `SmartFile` objects into an object-mode stream. |
| `dest(directory)` | Writes incoming `SmartFile` objects to a target directory. |
| `replace()` | Writes incoming `SmartFile` objects back to their original location. |
### Basic Stream Creation and File Manipulation
The files flowing through a `smartgulp` pipeline are `SmartFile` instances from [`@push.rocks/smartfile`](https://www.npmjs.com/package/@push.rocks/smartfile). That means transforms can inspect paths, read or mutate contents, and then pass each file along to the next stream.
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.
## Quick Start
```typescript
// Import smartgulp methods
Copy Markdown files from one directory to another:
```ts
import { src, dest } from '@push.rocks/smartgulp';
// Create a stream from source files using the `src` function
src(['src/**/*.ts']) // Specify the glob pattern
src(['./docs/**/*.md']).pipe(dest('./dist/docs'));
```
`src()` accepts an array of glob patterns. Each matching file is emitted as a `SmartFile`, and `dest()` writes every received file to the target directory.
## Transform Files
Because `smartgulp` uses object-mode streams, you can use any transform that accepts and emits `SmartFile` objects. The companion package [`@push.rocks/gulp-function`](https://www.npmjs.com/package/@push.rocks/gulp-function) is a convenient fit:
```ts
import { src, dest } from '@push.rocks/smartgulp';
import * as gulpFunction from '@push.rocks/gulp-function';
import type { SmartFile } from '@push.rocks/smartfile';
src(['./src/**/*.txt'])
.pipe(
// Example transformation: Convert TypeScript to JavaScript
// Use your desired transformer here
ts() // Assuming `ts()` is a function returning a Transform stream
gulpFunction.forEach(async (fileArg: SmartFile) => {
const currentContent = fileArg.contents.toString();
fileArg.contents = Buffer.from(`Processed by smartgulp\n\n${currentContent}`);
})
)
.pipe(dest('./dist'));
```
This pattern keeps transformations focused: read files with `src()`, mutate or inspect each `SmartFile`, then write the result with `dest()`.
## Replace Files In Place
Use `replace()` when a transform should update the original files instead of writing to a new output directory:
```ts
import { src, replace } from '@push.rocks/smartgulp';
import * as gulpFunction from '@push.rocks/gulp-function';
import type { SmartFile } from '@push.rocks/smartfile';
src(['./content/**/*.md'])
.pipe(
// Save the transformed files to the 'dist' directory
dest('dist')
gulpFunction.forEach(async (fileArg: SmartFile) => {
fileArg.contents = Buffer.from(
fileArg.contents.toString().replaceAll('http://', 'https://')
);
```
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. Heres 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'));
.pipe(replace());
```
### Conclusion
`replace()` calls `write()` on each incoming `SmartFile`, so it persists the modified contents back to the file's known path.
`@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.
## Wait For A Pipeline To Finish
Node streams are asynchronous. If your script needs to wait for the final file before exiting or starting the next step, add an end-of-stream transform:
```ts
import { src, dest } from '@push.rocks/smartgulp';
import * as gulpFunction from '@push.rocks/gulp-function';
import * as smartpromise from '@push.rocks/smartpromise';
const done = smartpromise.defer<void>();
src(['./test/testfiles/**/*.md'])
.pipe(dest('./dist/testfiles'))
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
```
This is useful in tests, build scripts, and one-off automation where the surrounding code needs a promise.
## Glob Behavior
`src()` resolves each provided pattern from the current working directory. It derives the static base directory before the first glob segment, loads that directory, and filters files with `minimatch`.
Examples:
| Pattern | Base directory | Matched portion |
| --- | --- | --- |
| `./src/**/*.ts` | `./src` | `**/*.ts` |
| `./docs/*.md` | `./docs` | `*.md` |
| `./package.json` | `.` | `package.json` |
Dotfiles are included in matching, so patterns can pick up files such as `.config.json` when the glob allows them.
## Typical Use Cases
- Copy assets into build directories.
- Run text or metadata transformations across many files.
- Update generated files in place.
- Build small project-specific pipelines without a full task runner.
- Compose `SmartFile`-aware transforms with regular Node stream flow.
## API Reference
### `src(patterns: string[])`
Creates an object-mode `Transform` stream and asynchronously pushes every matching `SmartFile` into it. The stream ends after all matched files have been pushed.
### `dest(directory: string)`
Creates an object-mode writable stream. Each incoming `SmartFile` is written to `directory` through `SmartFile.writeToDir()`.
### `replace()`
Creates an object-mode writable stream. Each incoming `SmartFile` is persisted through `SmartFile.write()`.
## 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.
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
**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.
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 or third parties, 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 or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
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.
For any legal inquiries or 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.
+47
View File
@@ -0,0 +1,47 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartgulp from '../ts/index.js';
import * as gulpFunction from '@push.rocks/gulp-function';
import * as smartpromise from '@push.rocks/smartpromise';
import { SmartFile } from '@push.rocks/smartfile';
tap.test('smartgulp.src should read a directory', async () => {
const done = smartpromise.defer<void>();
const filePaths: string[] = [];
smartgulp
.src(['./test/testfiles/**/*.md'])
.pipe(
gulpFunction.forEach(async (fileArg: SmartFile) => {
filePaths.push(fileArg.path);
})
)
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
expect(filePaths.some((filePathArg) => filePathArg.endsWith('.md'))).toBeTrue();
});
tap.test('smartgulp should replace files', async () => {
const done = smartpromise.defer<void>();
const filePaths: string[] = [];
smartgulp
.src(['./test/testfiles/**/*.md'])
.pipe(
gulpFunction.forEach(async (fileArg: SmartFile) => {
filePaths.push(fileArg.path);
})
)
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
)
.pipe(smartgulp.replace());
await done.promise;
expect(filePaths.some((filePathArg) => filePathArg.endsWith('.md'))).toBeTrue();
});
export default tap.start();
-43
View File
@@ -1,43 +0,0 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartgulp from '../ts/index.js';
import * as smartstream from '@push.rocks/smartstream';
import * as gulpFunction from 'gulp-function';
import * as smartpromise from '@push.rocks/smartpromise';
tap.test('smartgulp.src -> should read a directoy', async (tools) => {
let done = smartpromise.defer();
smartgulp
.src(['./test/testfiles/**/*.md'])
.pipe(
gulpFunction.forEach(async (fileArg) => {
console.log(fileArg.path);
})
)
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
tap.test('smartgulp shoould replace files', async () => {
let done = smartpromise.defer();
smartgulp
.src(['./test/testfiles/**/*.md'])
.pipe(
gulpFunction.forEach(async (fileArg) => {
console.log(fileArg.path);
})
)
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
)
.pipe(smartgulp.replace());
await done.promise;
});
await tap.start();
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartgulp',
version: '3.0.4',
description: 'lightweight gulp replacement'
version: '3.1.0',
description: 'A lightweight replacement for gulp, featuring smart stream handling and file manipulation.'
}
+4 -4
View File
@@ -3,7 +3,7 @@
import * as plugins from './smartgulp.plugins.js';
import { SmartFile } from '@push.rocks/smartfile';
import { Transform } from 'stream';
import { Transform } from 'node:stream';
export class GulpStream {
stream = new Transform({ objectMode: true });
@@ -11,13 +11,13 @@ export class GulpStream {
/**
* allows you to pipe a SmartfileArray into the stream
*/
async pipeSmartfileArray(smartfileArray: SmartFile[]) {
async pipeSmartfileArray(smartfileArray: SmartFile[]): Promise<void> {
// ensure what we get is an array
if (!Array.isArray(smartfileArray)) {
throw new Error('fileArg has unknown format');
}
for (let smartfile of smartfileArray) {
let hasWritten = this.stream.push(smartfile);
for (const smartfile of smartfileArray) {
const hasWritten = this.stream.push(smartfile);
if (!hasWritten) {
await plugins.smartevent.once(this.stream, 'drain');
}
+36 -14
View File
@@ -1,22 +1,47 @@
// this file contains the implementation of the standard gulp api
import * as plugins from './smartgulp.plugins.js';
import { GulpStream } from './smartgulp.classes.gulpstream.js';
import { Transform } from 'stream';
import { Transform } from 'node:stream';
import { SmartFile } from '@push.rocks/smartfile';
const smartFileFactory = plugins.smartfile.SmartFileFactory.nodeFs();
const toPosixPath = (pathArg: string): string => pathArg.split(plugins.path.sep).join('/');
const getGlobBaseAndPattern = (globPatternArg: string): { baseDir: string; matchPattern: string } => {
const normalizedPattern = toPosixPath(globPatternArg);
const pathParts = normalizedPattern.split('/');
const firstGlobIndex = pathParts.findIndex((pathPartArg) => /[*?[\]{}]/.test(pathPartArg));
if (firstGlobIndex === -1) {
return {
baseDir: plugins.path.dirname(globPatternArg),
matchPattern: plugins.path.basename(globPatternArg),
};
}
return {
baseDir: pathParts.slice(0, firstGlobIndex).join('/') || '.',
matchPattern: pathParts.slice(firstGlobIndex).join('/'),
};
};
export let src = (minimatchPathArrayArg: string[]): Transform => {
let gulpStream = new GulpStream();
let handleFiles = async () => {
const gulpStream = new GulpStream();
const handleFiles = async (): Promise<void> => {
let smartfileArray: SmartFile[] = [];
for (let minimatchPath of minimatchPathArrayArg) {
let localSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
process.cwd(),
minimatchPath
for (const minimatchPath of minimatchPathArrayArg) {
const { baseDir, matchPattern } = getGlobBaseAndPattern(minimatchPath);
const virtualDirectory = await smartFileFactory.virtualDirectoryFromPath(
plugins.path.resolve(process.cwd(), baseDir)
);
const localSmartfileArray = virtualDirectory
.listFiles()
.filter((fileArg) => plugins.minimatch(toPosixPath(fileArg.relative), matchPattern, { dot: true }));
smartfileArray = [...smartfileArray, ...localSmartfileArray];
}
gulpStream.pipeSmartfileArray(smartfileArray);
await gulpStream.pipeSmartfileArray(smartfileArray);
};
handleFiles().catch((err) => {
console.log(err);
@@ -28,11 +53,8 @@ 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);
}
await fileArg.writeToDir(dirArg);
},
});
return stream;
};
@@ -42,7 +64,7 @@ export let replace = () => {
objectMode: true,
writeFunction: async (fileArg: SmartFile) => {
await fileArg.write();
}
},
});
return stream;
};
+3 -3
View File
@@ -1,5 +1,5 @@
// node native scope
import * as path from 'path';
import * as path from 'node:path';
export {
path
@@ -9,6 +9,6 @@ export {
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';
import { minimatch } from 'minimatch';
export { smartevent, smartfile, smartstream, through2 };
export { smartevent, smartfile, smartstream, minimatch };
+3 -1
View File
@@ -5,8 +5,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"