Installation#

Rubin Style Dictionary is published as a Node package (@lsst-sqre/rubin-style-dictionary) on GitHub Packages, making it convenient to use from web projects. This page describes how to install the @lsst-sqre/rubin-style-dictionary package.

Inside the Squareone monorepo#

Projects within the Squareone monorepo should specify @lsst-sqre/rubin-style-dictionary as a workspace dependency in their package.json file:

package.json#
{
  "dependencies": {
    "@lsst-sqre/rubin-style-dictionary": "workspace:*",
  }
}

The following sections are for projects outside the Squareone monorepo.

Local authentication and installation#

You need to configure your package manager (npm as a specific example) to authenticate with GitHub Packages to install your package though.

Log into GitHub and create a new Personal Access Token. The token needs the read:packages scope.

Use the generated token value on the command line:

npm login --scope=@lsst-sqre --registry=https://npm.pkg.github.com

The username is your GitHub username, and password is your token. This command writes login information to your ~/.npmrc file.

Next, configure your project to use the @lsst-sqre scope. In the root of your project repository (directory that contains package.json), create a .npmrc file with the following contents:

@lsst-sqre:registry=https://npm.pkg.github.com/

Finally, install the package:

npm install @lsst-sqre/rubin-style-dictionary

Installing on GitHub Actions#

Your project’s CI service also needs to use to authenticate with GitHub Packages to download and install @lsst-sqre/rubin-style-dictionary. In the specific case of a GitHub Actions workflow, you can use the built-in $GITHUB_TOKEN environment variable.

name: CI

on: [push, pull_request]

jobs:

  build:
   runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Set up node
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'

      - name: Authenticate to GitHub Packages
        run: |
          echo "//npm.pkg.github.com/:_authToken=${NPM_PKG_TOKEN}" > ~/.npmrc
        env:
          NPM_PKG_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Install npm packages
        run: |
          npm install

      - name: Build site
        run: npm run build  # replace with your build command

Installing in a Docker image#

Docker builds outside the Squareone monorepo also need to authenticate with GitHub Packages to download and install @lsst-sqre/rubin-style-dictionary. In the Dockerfile, use a build argument to pass in a GitHub token, and use that token to authenticate with GitHub Packages using a technique similar to the GitHub Actions example above.