lerna extension for custom scripts
npm install lerna-scriptFor usage scenarios documentation please see root of repo;
lerna-script exports a cli script:
``bash`
lerna-script [options]
where options:
- loglevel - set's loglevel, defaults to info;
task:
- one of exports defined in lerna.js file.
Returns list of packages/modules in repo - forward to lerna;
Parameters:
- log, optional - npmlog logger;
Returns Package of root module.
Parameters:
- log, optional - npmlog logger;
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;(lernaPackage, log) => Promise
- task - function to execute with signature .
Returns promise with task results.
Executed provided command for all lernaPackages in a parallel fashion(Promise.all). taskFn can be either sync taskPromise
or return a .
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;(lernaPackage, log) => Promise
- task - function to execute with signature .Infinity
- concurrency - number, defaults to . See bluebird#map API
Returns promise with task results.
Executed provided command for all lernaPackages in a batched fashion respecting dependency graph. taskFn can be eitherPromise
sync task or return a .
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;(lernaPackage, log) => Promise
- task - function to execute with signature .
Returns promise without results (undefined).
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();true
- silent - should command output be streamed to stdout/stderr or suppressed. Defaults to ;
Returns:
- stdout - collected output;
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();true
- silent - should script output be streamed to stdout/stderr or suppressed. Defaults to ;
Returns:
- stdout - collected output;
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.
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
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-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-out packages that have did not change since refspec - ex. master, brach, tag.
Parameters:
- lernaPackages - packages to filter;
- log, optional - npmlog logger;refspec
- refspec - git = master, branchname, tag...
- opts.ignoreChanges - optional array of glob expressions. files matching those globs will be ignored in the diff calculation.
Filters-out packages by provided glob pattern.
Parameters:
- lernaPackages - packages to filter;
- log, optional - npmlog logger;
- glob - glob pattern.
Returns a list of packages tgat includes dependencies of filteredPackages that are in lernaPackages.
Parameters:
- lernaPackages - all packages;
- log, optional - npmlog logger;lernaPackages
- filteredPackages - subset of .
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.JSON.parse
- converter - a function to convert content, ex.
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.