Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lerna-script

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lerna-script

lerna extension for custom scripts

  • 0.8.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-71.18%
Maintainers
1
Weekly downloads
 
Created
Source

lerna-script

For usage scenarios documentation please see root of repo;

CLI

lerna-script exports a cli script:

lerna-script [options] <task>

where options:

  • loglevel - set's loglevel, defaults to info;

task:

  • one of exports defined in lerna.js file.

API

loadPackages({[log], [packageConfigs]}): LernaPackages[]

Returns list of packages/modules in repo - forward to lerna;

Parameters:

  • log, optional - npmlog logger;
  • packageConfigs - optional list of package config. defaults to default lerna package config.

loadRootPackage({[log]}): LernaPackage[]

Returns Package of root module.

Parameters:

  • log, optional - npmlog logger;

iter.forEach(lernaPackages, {[log], [build]})(task): Promise

Executed provided command for all lernaPackages in a serial fashion. taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.

Returns promise with task results.

iter.parallel(lernaPackages, {[log], [build]})(task): Promise

Executed provided command for all lernaPackages in a parallel fashion(Promise.all). taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.

Returns promise with task results.

iter.batched(lernaPackages, {[log], [build]})(task): Promise

Executed provided command for all lernaPackages in a batched fashion respecting dependency graph. taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.

Returns promise without results (undefined).

exec.command(lernaPackage, {silent = true})(command): Promise(stdout)

Executes given command for a package and returns collected stdout.

Note that command is a single command, meaning rm -f zzz and not ex. rm -f zzz && mkdir zzz. It's just for convenience you can provide command and args as a single string.

Argument list #1:

  • command - command to execute;

Argument list #2:

  • lernaPackage - package returned either by rootPackage() or packages();
  • silent - should command output be streamed to stdout/stderr or suppressed. Defaults to true;

Returns:

  • stdout - collected output;

exec.script(lernaPackage, {silent = true})(script): Promise(stdout)

Executes given npm script for a package and returns collected stdout.

Argument list #1:

  • script - npm script to execute;

Argument list #2:

  • lernaPackage - package returned either by rootPackage() or packages();
  • silent - should script output be streamed to stdout/stderr or suppressed. Defaults to true;

Returns:

  • stdout - collected output;

changes.build(lernaPackage, {[log]})([label]): undefined

Marks package as built.

Parameters:

  • lernaPackage - package to build;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label.

changes.unbuild(lernaPackage, {[log]})([label]): undefined

Marks package as unbuilt.

Parameters:

  • lernaPackage - package to unbuild;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

changes.isBuilt(lernaPackage)([label]): boolean

Returns true if package is build and false otherwise.

Parameters:

  • lernaPackage - package to unbuild;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

filters.removeBuilt(lernaPackages: [], {[log]})([label]: String): []

Filters-out packages that have been marked as built changes.build and were not changed since. Note that it filters-out also dependent packages, so if:

  • a, did not change, depends on b;
  • b, changed;
  • c, not changed, no inter-project dependencies.

Then it will return only c as b has changed and a depends on b, so it needs to be rebuilt/retested/re...

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

Note: this filter mutates built/unbuild state, meaning that it unbuilds dependents to get reproducible runs.

filters.gitSince(lernaPackages: [], {[log]})(refspec: String): []

Filters-out packages that have did not change since refspec - ex. master, brach, tag.

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • refspec - git refspec = master, branchname, tag...

filters.removeByGlob(lernaPackages: [], {[log]})(glob: String): []

Filters-out packages by provided glob pattern.

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • glob - glob pattern.

fs.readFile(lernaPackage)(relativePath, converter: buffer => ?): Promise[?]

Reads a file as string by default or accepts a custom converter.

Parameters:

  • lernaPackage - a lerna package for cwd of reading;
  • relativePath - file path relative to lernaPackage root.
  • converter - a function to convert content, ex. JSON.parse

fs.writeFile(lernaPackage)(relativePath, content, converter: type => string): Promise[String]

Writes string/buffer to file, accepts custom formatter.

Automatically detects and formats object.

Parameters:

  • lernaPackage - a lerna package for cwd of reading;
  • relativePath - file path relative to lernaPackage root.
  • content - content of file.
  • converter - function to convert provided type to string/buffer.

Keywords

FAQs

Package last updated on 27 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc