Détail du package

lazyrepo

ds3006.5kMIT0.0.0-alpha.27

lazyrepo is a caching task runner for npm/yarn/pnpm monorepos

readme

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,
      },
    },
  },
}

changelog

v0.0.0-alpha.27 (Mon Jun 05 2023)

💥 Breaking Change

🐛 Bug Fix

⚠️ Pushed to main

  • make windows tests run in band (@ds300)
  • reinstate setup action (@ds300)

Authors: 2


v0.0.0-alpha.26 (Tue May 02 2023)

🐛 Bug Fix

  • [fix] allow top-level scripts to run after other scripts #98 (@ds300)

Authors: 1


v0.0.0-alpha.25 (Tue May 02 2023)

🐛 Bug Fix

Authors: 1


v0.0.0-alpha.24 (Tue May 02 2023)

Release Notes

Cache console output (#92)

  • Add support for a logMode option with the following options:
    • 'none' – console output from tasks is only written to log files, never printed.
    • 'new-only' (default) – console output from tasks is only printed if the task actually runs (i.e. is a cache miss or has cache disabled)
    • 'errors-only' – only log the output if the task fails
    • 'full' – always log the output, including the cached output if the task was a cache hit.
  • Changes the output paths of manifests and diffs.

🚀 Enhancement

🐛 Bug Fix

Authors: 1


v0.0.0-alpha.23 (Fri Apr 28 2023)

💥 Breaking Change

  • Rename "tasks" config option to "scripts" #83 (@ds300)

🚀 Enhancement

  • Log full diff + manifest on CI #85 (@ds300)

⚠️ Pushed to main

🏠 Internal

  • add pr-label-enforcer worker to repo #82 (@ds300)

Authors: 1


v0.0.0-alpha.22 (Tue Apr 25 2023)

🐛 Bug Fix

  • tests(manifest constructor): add property-based-tests & fix bugs #80 (@ds300)

⚠️ Pushed to main

🏠 Internal

  • Run Label Enforcer on Cloudflare worker #81 (@ds300)

🧪 Tests

  • tests: use memfs in ManifestConstructor.test #78 (@ds300)

Authors: 1


v0.0.0-alpha.21 (Sat Apr 22 2023)

🐛 Bug Fix

⚠️ Pushed to main

  • fix prettier usage in publish-new.js (@ds300)
  • update logo (@ds300)

🏠 Internal

  • run prettier before committing changelog #76 (@ds300)

Authors: 2


v0.0.0-alpha.20 (Fri Apr 21 2023)

🐛 Bug Fix

Authors: 1


v0.0.0-alpha.19 (Fri Apr 21 2023)


v0.0.0-alpha.18 (Fri Apr 21 2023)

🐛 Bug Fix

🏠 Internal

  • don't run check-pr-labels on merged/closed PRs #73 (@ds300)
  • Improve check-pr-labels script #71 (@ds300)
  • add check-pr-labels script #70 (@ds300)

🧪 Tests

Authors: 3


v0.0.0-alpha.17 (Thu Apr 20 2023)

🚀 Enhancement

Authors: 1


v0.0.0-alpha.16 (Thu Apr 20 2023)

🚀 Enhancement

🐛 Bug Fix

Authors: 2


v0.0.0-alpha.15 (Thu Apr 20 2023)

🐛 Bug Fix

  • Set latest tag when publishing 0.0.0-alpha releases #65 (@ds300)

Authors: 1


v0.0.0-alpha.14 (Thu Apr 20 2023)

💥 Breaking Change

🚀 Enhancement

🐛 Bug Fix

⚠️ Pushed to main

🏠 Internal

📝 Documentation

🧪 Tests

Authors: 6