Cleecanth / lastrev-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LastRev Toolkit

This is a mono-repo with individually versioned packages for the tools and libraries used in LastRev projects.

Packages

@last-rev/adapter-contentful

The LastRev Contentful Adapter takes data out of contentful and adapts it to the shape epected by most LastRev components.

@last-rev/integration-contentful

The LastRev Contentful Integration is an implementation of the calls we use to the contentful API.

@last-rev/build-prefetch-content

The LastRev Content Prefetcher is a build script which prefetches some data from contentful to help reduce build times and enable component lookups.

@last-rev/content-validator

The LastRev Content Validator is module that provides a set of useful components to catch Content validation errors and provides a DOM API to expose validation errors to extensions.

Usage

This monorepo uses Lerna and Yarn Workspaces to manage the packages. Scripts are executed with Yarn. In general, run scripts from the workspace root to run accross all packages.

Getting Started

  1. Install yarn globally
npm install -g yarn
  1. Run yarn install on the project
yarn install
  1. When adding new dependencies, add them to the workspace from the root, or CD into the package and add them to the package
yarn workspace @last-rev/integration-contentful add lodash
# or
cd packages/lastrev-integration-contentful
yarn add lodash

How it works

yarn workspaces ensures that all modules are installed at the package root, and that package references are linked, meaning that if package-a depends on package-b, and you make changes to package-b, locally, package-a can see those changes immediately.

Lerna ensures that all packages that changed, plus those depending on them are versioned and published. Versions are independent.

commands

  • yarn run build - Cleans and builds each package in dependency order. We use Typescript to build the projects, as it allows for much safer code, and improved intellisense in VS Code
  • yarn run test - Runs all of the tests across all projects. We use Jest as our testing library.
  • yarn run test:watch - Runs tests in watch mode.
  • yarn run pub:prerelease - Determines which packages have changed, increments the patch version number to a prerelease version, and publishes to NPM.
  • yarn run pub:patch - Determines which packages have changed, increments the patch version number, and publishes to NPM.
  • yarn run pub:minor - Determines which packages have changed, increments the minor version number, and publishes to NPM.
  • yarn run pub:major - Determines which packages have changed, increments the major version number, and publishes to NPM.

Testing libraries locally

If you need to test some local changes to the toolkit against another local project, call yarn run build:external followed by the path to the root of the project you want to test against. This will build all the packages, and copy their dist files into the node_modules directory of the destination project. Note: You must already have built the destination project with the npm libraries for this to work (they need to be in node_modules).

yarn run build:external ../www.lastrev.com

Testing CLIs locally

To test a CLI locally, simply build the monorepo as usual, and instead of calling the global executable, call node with the path of the local executable:

cd ~/dev/lastrev-toolkit
yarn run build
cd ../SomeOtherProject
node ../lastrev-toolkit/packages/lastrev-build-prefetch-content/bin/lr-prefetch

About


Languages

Language:TypeScript 50.0%Language:CSS 27.3%Language:HTML 20.9%Language:JavaScript 1.6%Language:Handlebars 0.2%