
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
gulp-factory
Advanced tools
a factory to create instant gulp-plugins and enforcing gulp plugin guidelines
a factory to create instant gulp-plugins and enforcing gulp plugin guidelines.
For simplicity & flexibility, API has changed as of V2.0.0. Now you'll pass pluginName
& pluginFn
as a part of options
.
flushFn
(refer through2 API) has been added.options.warnings
, that covered guidelines: 4, 5 & 13, as they seems no purpose served.Majority of gulp-plugins share the same boilerplate code (except its implementation that wrapped inside through.obj(...)
). gulp-factory
takes care of them all as per gulp plugin guidelines - including error handling
. All you need is just a few line of code to complete your gulp-plugins
.
// a fully functional plugin
var factory = require ('gulp-factory');
function plugin() {
return factory({
pluginName: 'gulp-text-changer',
pluginFn: (file) => {
file.contents = new Buffer('changed from plugin');
}
});
}
module.exports = plugin;
// and calling from gulpfile.js
var changer = require ('./plugins/changer.js');
var gulp = require('gulp');
gulp.task('default', function () {
return gulp.src('./fixtures/*.txt')
.pipe(changer())
.pipe(gulp.dest('dist'));
});
npm install --save gulp-factory
Currently gulp-factory
enforces / follows the below gulp plugin guidelines (gpg) by default:
homeMade
option set to true
, it won't) (8)file.contents
is null (non-read), it ignores the file and pass it along (9.1)file.contents
is a Stream and you don't support that (streamSupport: false
), emits an error (9.2)Your plugins could be either a module
or just a function
.
For example, you only need the below code to create a completely working front-matter
gulp-plugin.
// index.js
var gm = require('gray-matter');
var factory = require('gulp-factory');
module.exports = function (options) {
options = options || {};
// plugin implementation
function plugin(file, encode) {
var raw = gm(file.contents.toString(encode), options);
file.yml = raw.data || {};
file.contents = new Buffer(raw.content);
}
// return factory
return factory({
pluginName: 'gulpfactory-gray-matter',
pluginFn: plugin,
homeMade: true
});
};
Then from your gulpfile.js
// gulpfile.js
var gulp = require('gulp');
var grayMatter = require('./');
gulp.task('default', function yaml() {
return gulp.src('./fixtures/*.md')
.pipe(grayMatter({delims: '---'}))
.pipe(gulp.dest('./fixtures/output'));
})
or just turn any of your function
into a gulp-plugin
// gulpfile.js
var gulp = require('gulp');
var gm = require('gray-matter');
var factory = require('gulp-factory');
// plugin implementation
function plugin(file, encode) {
var raw = gm(file.contents.toString(encode), {delims: '---'});
file.yml = raw.data || {};
file.contents = new Buffer(raw.content);
}
gulp.task('default', function yaml() {
return gulp.src('./fixtures/*.md')
.pipe(factory({
pluginName: 'gulpfactory-gray-matter',
pluginFn: pluginFn,
homeMade: true
})
.pipe(gulp.dest('./fixtures/output'));
})
factory (options)
options
// default values
{
pluginName: '',
pluginFn: null,
flushFn: null,
streamSupport: false,
bufferSupport: true,
homeMade: false,
showStack: false,
showProperties: true
}
Type: string
, required
Default: Empty
Unless
homeMade
mode enabled, plugin must be prefixed withgulp-
. Will throw error otherwise.
Type: function
, required
Default: null
gulp-factory
supplies onlyfile & encode
arguments (both are optional) and takes care of calling yourcallback
. So, your plugin function could be in either one of the following signature.
function pluginFunction() {
// If you have no file based operations but
// Just wrapping a function
}
// or......
function pluginFunction(file) {
// Your file operations
// Remember that you do not have to return anything or callback
}
// or......
function pluginFunction(file, encode) {
// Your file/encode operations
try {
const fileData = file.contents.toString(encode);
file.contents = new Buffer('new content');
} catch (e) {
// Just throw your error and
// gulp-factory will catch and throw PluginError
// Along with your pluginName as it's prefix
throw e;
}
}
If needed, just
throw
an error as above andgulp-factory
will wrap it withPluginError
andpluginName
prefix.
Type: function
, optional
Default: null
This function will be passed to
through2's
flush argument. Also will call it'scallback
function. If needed, justthrow
an error as above andgulp-factory
will wrap it withPluginError
andpluginName
prefix.
Type: boolean
Default: false
Whether your plugin supports
stream
. Throws PluginError if thefile
isStream
.
Type: boolean
Default: true
Whether your plugin supports
buffer
. Throws PluginError if thefile
isBuffer
.
Type: boolean
Default: false
By default,
gulp-factory
operates infactory
mode:- that requires all your plugins prefixed withgulp-
. However if you would just like to test your plugins on your local repository or wrapping your existing functions as gulp-plugins and have no plan to list them under gulp plugin registry, just sethomeMade: true
andgulp-factory
won't enforcegulp-
prefix.
Type: boolean
Default: false
Refer gulp-util's PluginError
Type: boolean
Default: true
Refer gulp-util's PluginError
gulp-factory
exposes gulp-util for your plugins' convenience.
const gulpUtil = require('gulp-factory').gulpUtil;
gulp-factory
exposes lodash for your plugins' convenience.
const _ = require('gulp-factory')._;
FAQs
a factory to create instant gulp-plugins and enforcing gulp plugin guidelines
The npm package gulp-factory receives a total of 0 weekly downloads. As such, gulp-factory popularity was classified as not popular.
We found that gulp-factory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.