Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sewing-kit/plugins

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sewing-kit/plugins

Provides API for building `sewing-kit` plugins.

  • 0.1.7-sk0-sk1-hybrid.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67
increased by168%
Maintainers
3
Weekly downloads
 
Created
Source

@sewing-kit/plugins

Provides API for building sewing-kit plugins.

For a more in-depth explanation of plugins and the philosophy behind them, check out these docs

@sewing-kit/plugins also re-exports numerous types and classes from other sewing-kit packages, such as core, tasks, and hooks.

Installation

yarn add @sewing-kit/plugins --dev

Overview

In sewing-kit, plugins are the things that actually "do" stuff. They piggyback off the architecture provided by sewing-kit's core (i.e. hooks) to inject actual actions into your workspace's tasks.

The @sewing-kit monorepo provides a suite of ready-made plugins for common use cases, like type-checking with TypeScript, transpiling with Babel, and testing with Jest. However, using sewing-kit's API you're able (and encouraged) to write your own to fit your specific needs.

Example

Below is an example sewing-kit.config.ts that sets up a sewing-kit workspace to lint with ESLint, test with Jest, and type-check with TypeScript. It also includes a custom plugin made with createWorkspaceTestPlugin that taps into the jestConfig hook introduced by the jest plugin to specify a coverage directory.

import {createWorkspace} from '@sewing-kit/config';

import {eslint} from '@sewing-kit/plugin-eslint';
import {jest} from '@sewing-kit/plugin-jest';
import {workspaceTypeScript} from '@sewing-kit/plugin-typescript';

import {createWorkspaceTestPlugin} from '@sewing-kit/plugins';

export default createWorkspace((workspace) => {
  workspace.use(
    eslint(),
    jest(),
    workspaceTypeScript(),
    createWorkspaceTestPlugin('JestCoveragePlugin', (taskContext) => {
      const {hooks: taskHooks} = taskContext;

      taskHooks.configure.hook((configHooks) => {
        configHooks.jestConfig?.hook((jestConfig) => ({
          ...jestConfig,
          coverageDirectory: './coverage',
        }));
      });
    }),
  );
});

Plugins can do anything from configuring hooks, adding steps to tasks, or introducing hooks for other plugins to hook into. Note that JestCoveragePlugin makes use of the jestConfig hook, which isn't provided by core sewing-kit but is introduced to the workspace by jest.

For more examples on how to write your own plugins, check out the source code for @sewing-kit/plugin-jest, @sewing-kit/plugin-eslint, @sewing-kit/plugin-typescript, among others.

Usage

Plugin creation

The following functions are provided by @sewing-kit/plugins to help make writing your own plugins easier:

For composing several plugins into one:

  • createComposedProjectPlugin()
  • createComposedWorkspacePlugin()

For project plugins:

  • createProjectBuildPlugin()
  • createProjectDevPlugin()
  • createProjectPlugin()
  • createProjectTestPlugin()

For workspace plugins:

  • createWorkspaceBuildPlugin()
  • createWorkspaceDevPlugin()
  • createWorkspaceLintPlugin()
  • createWorkspacePlugin()
  • createWorkspaceTestPlugin()
  • createWorkspaceTypeCheckPlugin()

FAQs

Package last updated on 01 Mar 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc