npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

carpenterd-worker

v4.2.0

Published

Receives and runs builds received from nsqd

Downloads

28

Readme

carpenterd-worker

Version npm License npm Downloads Build Status Dependencies

carpenterd-worker is responsible for receiving job messages from carpenterd and executing the builds. After fetching a pre-installed npm tarball from a distributed storage like amazon s3. A workers-factory instance will build the bundle.

Install

npm install carpenterd-worker --save

Usage


const carpenterd = require('carpenterd-worker');

const app = new Map();
// Select the directory that contains a `config` directory so that `slay-config`
// works appropriately
app.rootDir = require('path').join(__dirname);

carpenterd(app)
  .start(carpenterd.worker);

Dependencies

  • nsq for job distribution to all the workers in given cluster.
  • amazon s3 or an s3 like store for storing built assets and for fetching tarballs stored by carpenterd.

Configuration

See the example config config.example.json in this repo.

notes

  • nsq config option is for a fork of nsq.js that has kubernetes support but otherwise has the same options. Note: there is an additional configuration option statusTopic for setting the nsq topic that should be written to for status updates.
  • assets.prefix in the config is the bucket name for where the public CDN assets are uploaded.
  • http is the http port the healhcheck listens on.
  • npm-tars the npm tarball bucket to fetch from.
  • database the configuration for the database.

Build Options

promote

When work is queued with carpenterd-worker it can optionally be marked to disable build promotion. Normally when a build completes it is marked as the build-head. Meaning it will be the build that is used for the given environment for that package. If the JSON status message used to queue the build contains "promote": false then it will be built only and not promoted / served for the given environment.

Status-Api

Carpenterd-worker supports posting messages to the [warehouse.ai] status-api via NSQ. It will post messages to the nsq topic configured at:

{
  // ...other configuration
  "nsq": {
    "statusTopic": "an-nsq-topic", // topic that you choose for the status-api to consume
    // ...other nsq setup
  },
  // ...other configuration
}

The NSQ payloads will be object that take the form:

{
    eventType: "event|error|complete", // The type of status event that occurred
    name: "package-name",
    env: "dev", // The environment that is being built
    version: "1.2.3", // The version of the build
    locale: "en-US", // (Optional) The locale that is being built
    buildType: "webpack", // The type of the build (typically just webpack)
    message: "Description of what happened"
  }

Event Types

In the status-api NSQ payload there is a field called eventType. The possible values that carpenterd-worker will send are:

  • event - Used for interim statuses that a user might care about, but doesn't affect/progress the overall build status
  • complete - Used to indicate that the build is completed
  • error - Used to indicate that carpenterd-worker encountered an error and wasn't able to complete the build

Build types

The buildType value is parsed from the package.json by carpenterd. The types of supported builds are webpack/browserify/babel. For a more detailed description see carpenterd build documentation.

Tests

Run an AWS local cloud stack, pull latest [localstack]. This requires docker to be setup.

docker pull localstack/localstack:latest
npm run localstack

Run tests in a separate terminal.

npm test