Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@sewing-kit/hooks
Advanced tools
@sewing-kit/hooks
Interfaces and types for sewing-kit
hooks.
yarn add @sewing-kit/hooks --dev
Hooks, along with plugins, form the functional heart of sewing-kit
. Inspired by webpack's tapable library (guide), hooks provide a way for plugins to tap into sewing-kit
tasks in order to impart functionality to your workspace's dev setup.
The two types of hooks provided are a SeriesHook
and a WaterfallHook
. Both of these clases provide a hook
and run
method
import {SeriesHook} from '@sewing-kit/hooks';
const dog = {
breed: new SeriesHook<string>(),
};
dog.breed.hook((breed) => {
console.log('Received changes on the breed: ', breed);
});
dog.breed.run('American Bully');
// Received changes on the breed: American Bully
When run
is called on a SeriesHook
all the conainted hooks are resolved in sequential order. With a Waterfall
hook, the result of a hook is passed in as the argument for the next hook.
A lot of your use cases can probably covered by the hooks provided by core sewing-kit
, but you can always add your own hooks via plugins and a task's configureHooks
hook (adding hooks with hooks). For example, if you add, say, a plugin that introduces Jest to your workspace's testing setup, that plugin can also add a hook to let other plugins hook into its Jest configuration.
// Code from @sewing-kit/plugin-jest
hooks.configureHooks.hook(
addHooks<JestWorkspaceHooks>(() => ({
jestSetupEnv: new WaterfallHook(),
jestSetupTests: new WaterfallHook(),
jestWatchPlugins: new WaterfallHook(),
jestConfig: new WaterfallHook(),
jestFlags: new WaterfallHook(),
})),
);
Following from the previous example, another plugin further down might then do something like:
createWorkspaceTestPlugin('CustomPlugin', ({hooks}) => {
hooks.configure.hook((hooks) => {
hooks.jestSetupEnv.hook((oldJestSetupEnv) => {
// Do something to oldJestSetupEnv and return the new value
});
hooks.jestConfig.hook((oldJestConfig) => {
// Do something to oldJestConfig and return the new value
});
// ..etc
});
});
When you run sk test
, sewing-kit
will pick up your configs and plugins and run Jest with your specified option/config values.
FAQs
Hook interfaces for sewing-kit-next
The npm package @sewing-kit/hooks receives a total of 72 weekly downloads. As such, @sewing-kit/hooks popularity was classified as not popular.
We found that @sewing-kit/hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.