Skip to content

Common dev dependencies for Node.js projects used by the studio

License

Notifications You must be signed in to change notification settings

dimensionalpocket/development-js

Repository files navigation

@dimensionalpocket/development

build

This package includes common development packages, types, and/or configuration defaults used by other projects:

  • mocha
  • sinon
  • chai - along with sinon-chai and chai-as-promised
  • c8
  • standardx
  • babel
  • renovate - shared configuration

It also includes a reusable Github Action for Node builds, and a shared workflow for Release Please.

Configuration

Some libraries can use default configurations provided by this library. Add them to the project's package.json as follows:

{
  ...,
  "babel": {
    "extends": "./node_modules/@dimensionalpocket/development/babel"
  },
  "eslintConfig": {
    "extends": "./node_modules/@dimensionalpocket/development/eslint"
  },
  "c8": {
    "extends": "./node_modules/@dimensionalpocket/development/c8/default.json"
  }
}

Alongside extends, you can add extra configuration if you need settings to differ from defaults.

StandardX, Mocha, and packages not mentioned above do not properly support extends or custom configuration files and must be manually configured.

StandardX

If you are extending eslintConfig like the previous example, you don't need to configure StandardX. The provided ESLint configuration already uses mocha as environment, along with the Babel parser.

You can still extend configuration if needed:

{
  ...,
  "standardx": {
    "globals": ["WebSocket"]
  }
}

Renovate

To make renovate use the preset from this repository, add the following to the project's .github/renovate.json:

{
  "extends": [
    "github>dimensionalpocket/development-js//renovate/default"
  ]
}

Github Actions

This repository includes a reusable workflow for Node builds.

To use it, replace your workflow file with the following:

name: Node.js

on:
  pull_request:

jobs:
  default:
    uses: dimensionalpocket/development-js/.github/workflows/[email protected]

The workflow supports a number of input variables, including secrets. Check .github/workflows/default-node-build.yml for details.

Release Please

This package includes a shared workflow for Release Please.

To use it, create ./github/workflows/release.yml in the project with the following content:

name: Release

on:
  push:
    branches: main

jobs:
  default:
    uses: dimensionalpocket/development-js/.github/workflows/[email protected]

Next, create a version.js file with the following content:

export const VERSION = 'X.Y.Z' /* x-release-please-version */

Then:

  • Replace X.Y.Z with the current version of the package from package.json;
  • Keep the in-line comment, that's how Release Please will replace the version number when creating a release PR.

The version.js file can be placed in the root, src, or config folders.

Usage in Tests

In your test files, import and use expect, chai, and sinon from the library directly:

import { expect, sinon } from '@dimensionalpocket/development'

describe('Your Class', function () {
  // ...
})

Installation

Install the package directly from GitHub:

npm i -D -E github:dimensionalpocket/development-js#1.3.0

License

MIT