• Stars
    star
    528
  • Rank 83,941 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Caching task runner for npm/pnpm/yarn monorepos.
LAZYREPO

Warning Currently in the prototyping stage, expect breaking changes! Get help or join in development on discord.

lazyrepo is a zero-config caching task runner for npm/pnpm/yarn monorepos.

It fits right into the niche that turborepo carved out: making package.json "scripts" scale without adopting a big industrial-strength build system like nx, bazel, rush, or buck.

lazyrepo is scary fast, despite being written in TypeScript rather than some young handsome clever funny systems language.

Aside from perf, lazyrepo comes with some big quality-of-life improvements:

  • A human-friendly config format.
  • Concise and timely feedback to help you tweak and debug your build pipelines.
  • Palpably sensible defaults.
  • You don't need to learn Rust to contribute.

Trust me, the whole situation is so delightful it will make you reach for the :chefs-kiss: emoji. And then you'll realize that there is no such emoji, but you'll want it so badly that you'll draft a proposal to the Unicode Consortium to lobby for its introduction.

Installation

Install lazyrepo globally

npm install lazyrepo@alpha --global

And also as a dev dependency in the root of your repo

npm install lazyrepo@alpha --save-dev

And finally add .lazy to your .gitignore

echo "\n\n#lazyrepo\n.lazy" >> .gitignore

Basic Usage

Running Tasks

Run scripts defined in "scripts" entries using:

lazy run <script-name>

You can pass arguments to the task script after a --

lazy run test -- --runInBand

The default behavior is optimized for "test" scripts, where the order of execution matters if your packages depend on each other.

Let's say you have three packages: core, utils, and primitives. The core package depends on both utils and primitives, and they all have "test" scripts in their package.json files.

graph TD
    A[packages/core] -->|depends on| B[packages/utils]
    A -->|depends on| C[packages/primitives]

With no config, when you run lazy run test in the project root:

  • The tests for utils and primitives will begin concurrently. The tests for core will only be started if both utils and primitives finish successfully.
  • If you change a source file in core and run lazy run test again, only core's tests will be executed.
  • If you change a source file in utils and run lazy run test again, both utils and core's tests will be executed, in that order.

Other commands

  • lazy init

    Creates a config file.

  • lazy clean

    Deletes all local cache data.

  • lazy inherit

    In larger projects, you often end up with the same "script" entries duplicated in lots of package.json files. Keeping them in sync can be troublesome.

    lazyrepo lets you specify the command just once.

    Replace the scripts entries with lazy inherit:

     "scripts": {
    -  "test": "jest --runInBand --noCache --coverage",
    +  "test": "lazy inherit"
     }

    Then add this in your lazy config file:

     "scripts": {
       "test": {
    +    "baseCommand": "jest --runInBand --noCache --coverage"
       }
     }

    Now when you run npm test, or whatever, in one of your package directories, it will look up the actual command to run from your lazy config file and run that.

  • lazy run <script> [-- <forward-args>]

    Runs the given script, forwarding any args passed after the --

    You may filter the packages that a script should run in using the --filter option, which supports glob patterns.

    e.g. to test only packages that end in -utils

    lazy run test --filter="packages/*-utils"
    

    You may force all tasks to execute by passing the --force option.

    lazy run test --force
    

Configuration

Create a file called lazy.config.js or lazy.config.json

To create a .js config file, in your project root run:

lazy init
export default {
  scripts: {
    test: {
      cache: {
        // by default we consider all files in the package directory
        inputs: ['**/*'],
        // there are no outputs
        outputs: [],
        // a test invocation depends on the input files of any upstream packages
        inheritsInputFromDependencies: true,
      },
    },
  },
}

More Repositories

1

patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
TypeScript
10,288
star
2

react-native-typescript-transformer

Seamlessly use TypeScript with React Native
JavaScript
657
star
3

derivablejs

Functional Reactive State for JavaScript and TypeScript
JavaScript
515
star
4

jetzt

Speed reader extension for chrome
JavaScript
486
star
5

postinstall-postinstall

JavaScript
53
star
6

android-capture

Capture video and screenshots from Android devices and emulators.
JavaScript
34
star
7

code-in-motion

JavaScript
17
star
8

cfg

Option management for Clojure
Clojure
11
star
9

ddom

derivable dom
JavaScript
11
star
10

redux-mobx-connect

A simple alternative to react-redux
TypeScript
9
star
11

gudetama

Make your CI scripts as lazy as possible
TypeScript
7
star
12

prismic-react

Compiling Prismic.io content to ReactElements
JavaScript
5
star
13

lunch-time

TypeScript
5
star
14

apt

Anchored Packed Trees for compositional distributional semantics
Java
3
star
15

artsy-nonlocality

Chrome extension for artsy employees to launch zoom meetings more easily
TypeScript
3
star
16

patch-package-website-design

figma file for unused patch-package website design
3
star
17

derivables-talk-demo

Code demonstration of Derivables from my talk
JavaScript
2
star
18

rn-back

dual n-back in react native
JavaScript
2
star
19

postinstall-prepare

JavaScript
2
star
20

kfs

TypeScript
2
star
21

encrypt-and-decrypt

TypeScript
2
star
22

atom-gitnav

move forward and backward through git history with hotkeys
CoffeeScript
1
star
23

mental

super simple mental arithmetic game
JavaScript
1
star
24

loggy

dumb irc room logger
Go
1
star
25

norm

A suite of tools coalescing into a lexical normalisation system for tweets.
Clojure
1
star
26

TestCustomSourceExts

Objective-C
1
star
27

apt-py

python api for reading and manipulating APTs
Python
1
star
28

vimes

oh lisp
TypeScript
1
star
29

sicp

going through sicp in emacs
Scheme
1
star
30

nlp-trie

Immutable trie implementation for Clojure. Uses string keys. Optimised for lookups and traversal.
Clojure
1
star
31

gridster

JavaScript
1
star
32

FlowDoge

wow such flow
TypeScript
1
star