Gathering detailed insights and metrics for undertaker-registry
Gathering detailed insights and metrics for undertaker-registry
Gathering detailed insights and metrics for undertaker-registry
Gathering detailed insights and metrics for undertaker-registry
@types/undertaker-registry
TypeScript definitions for undertaker-registry
undertaker-lib-tasks
Bundle of generic [undertaker](https://github.com/phated/undertaker) application tasks, packaged as [undertaker-registry](https://github.com/phated/undertaker-registry) objects.
undertaker-app-tasks
Bundle of generic [undertaker](https://github.com/phated/undertaker) application tasks, packaged as [undertaker-registry](https://github.com/phated/undertaker-registry) objects.
undertaker
Task registry that allows composition through series/parallel methods.
npm install undertaker-registry
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
17 Stars
25 Commits
10 Forks
6 Watching
1 Branches
5 Contributors
Updated on 06 Nov 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.9%
308,321
Compared to previous day
Last week
3.4%
1,642,282
Compared to previous week
Last month
14.8%
6,557,410
Compared to previous month
Last year
9.2%
68,865,737
Compared to previous year
6
Default registry in gulp 4.
1var gulp = require('gulp'); 2var UndertakerRegistry = require('undertaker-registry'); 3 4var registry = new UndertakerRegistry(); 5 6gulp.registry(registry);
Constructor for the default registry. Inherit from this constructor to build custom registries.
No-op method that receives the undertaker instance. Useful to set pre-defined tasks using the
undertaker.task(taskName, fn)
method. Custom registries can override this method when inheriting
from this default registry.
Returns the task with that name or undefined if no task is registered with that name. Useful for custom task storage. Custom registries can override this method when inheriting from this default registry.
Adds a task to the registry. If set
modifies a task, it should return the new task so Undertaker can
properly maintain metadata for the task. Useful for adding custom behavior to every task as it is
registered in the system. Custom registries can override this method when inheriting from this default
registry.
Returns an object listing all tasks in the registry. Necessary to override if the get
method is overridden
for custom task storage. Custom registries can override this when when inheriting from this default
registry.
Custom registries are constructor functions allowing you to pre-define/share tasks or add custom functionality to your registries.
A registry's prototype should define:
init(taker)
: receives the undertaker instance to set pre-defined tasks using the task(taskName, fn)
method.get(taskName)
: returns the task with that name
or undefined
if no task is registered with that name.set(taskName, fn)
: add task to the registry. If set
modifies a task, it should return the new task.tasks()
: returns an object listing all tasks in the registry.You should not call these functions yourself; leave that to Undertaker, so it can keep its metadata consistent.
The easiest way to create a custom registry is to inherit from undertaker-registry:
1var util = require('util'); 2 3var DefaultRegistry = require('undertaker-registry'); 4 5function MyRegistry() { 6 DefaultRegistry.call(this); 7} 8 9util.inherits(MyRegistry, DefaultRegistry); 10 11module.exports = MyRegistry;
To share common tasks with all your projects, you can expose an init
method on the registry
prototype and it will receive the Undertaker instance as the only argument. You can then use
undertaker.task(name, fn)
to register pre-defined tasks.
For example you might want to share a clean
task:
1var fs = require('fs'); 2var util = require('util'); 3 4var DefaultRegistry = require('undertaker-registry'); 5var del = require('del'); 6 7function CommonRegistry(opts) { 8 DefaultRegistry.call(this); 9 10 opts = opts || {}; 11 12 this.buildDir = opts.buildDir || './build'; 13} 14 15util.inherits(CommonRegistry, DefaultRegistry); 16 17CommonRegistry.prototype.init = function (takerInst) { 18 var buildDir = this.buildDir; 19 var exists = fs.existsSync(buildDir); 20 21 if (exists) { 22 throw new Error( 23 'Cannot initialize common tasks. ' + buildDir + ' directory exists.' 24 ); 25 } 26 27 takerInst.task('clean', function () { 28 return del([buildDir]); 29 }); 30}; 31 32module.exports = CommonRegistry;
Then to use it in a project:
1var Undertaker = require('undertaker'); 2var CommonRegistry = require('myorg-common-tasks'); 3 4var taker = new Undertaker(CommonRegistry({ buildDir: '/dist' })); 5 6taker.task( 7 'build', 8 taker.series('clean', function build(cb) { 9 // do things 10 cb(); 11 }) 12);
By controlling how tasks are added to the registry, you can decorate them.
For example if you wanted all tasks to share some data, you can use a custom registry to bind them to that data. Be sure to return the altered task, as per the description of registry methods above:
1var util = require('util'); 2 3var Undertaker = require('undertaker'); 4var DefaultRegistry = require('undertaker-registry'); 5 6// Some task defined somewhere else 7var BuildRegistry = require('./build.js'); 8var ServeRegistry = require('./serve.js'); 9 10function ConfigRegistry(config) { 11 DefaultRegistry.call(this); 12 this.config = config; 13} 14 15util.inherits(ConfigRegistry, DefaultRegistry); 16 17ConfigRegistry.prototype.set = function set(name, fn) { 18 // The `DefaultRegistry` uses `this._tasks` for storage. 19 var task = (this._tasks[name] = fn.bind(this.config)); 20 return task; 21}; 22 23var taker = new Undertaker(); 24 25taker.registry(new BuildRegistry()); 26taker.registry(new ServeRegistry()); 27 28// `taker.registry` will reset each task in the registry with 29// `ConfigRegistry.prototype.set` which will bind them to the config object. 30taker.registry( 31 new ConfigRegistry({ 32 src: './src', 33 build: './build', 34 bindTo: '0.0.0.0:8888', 35 }) 36); 37 38taker.task( 39 'default', 40 taker.series('clean', 'build', 'serve', function (cb) { 41 console.log('Server bind to ' + this.bindTo); 42 console.log('Serving' + this.build); 43 cb(); 44 }) 45);
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/24 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More