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

lerna-script

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lerna-script - npm Package Compare versions

Comparing version 1.3.0 to 1.3.2

6

lib/detect-changes.js

@@ -78,7 +78,3 @@ const fs = require('fs'),

while (current !== process.cwd()) {
current =
current
.split(path.sep)
.slice(0, -1)
.join(path.sep) || '/'
current = current.split(path.sep).slice(0, -1).join(path.sep) || '/'
paths.push(current)

@@ -85,0 +81,0 @@ }

5

lib/filters.js

@@ -111,3 +111,6 @@ const _ = require('lodash'),

function diffPackages(before, after) {
return _.difference(before.map(p => p.name), after.map(p => p.name))
return _.difference(
before.map(p => p.name),
after.map(p => p.name)
)
}

@@ -114,0 +117,0 @@

@@ -26,3 +26,6 @@ const npmlog = require('npmlog'),

function parallel(lernaPackages, {log = npmlog, build, concurrency = Infinity} = {log: npmlog, concurrency: Infinity}) {
function parallel(
lernaPackages,
{log = npmlog, build, concurrency = Infinity} = {log: npmlog, concurrency: Infinity}
) {
return taskFn => {

@@ -34,15 +37,19 @@ const filteredLernaPackages = filterBuilt(lernaPackages, log, build)

return Promise.map(filteredLernaPackages, lernaPackage => {
const promiseTracker = forEachTracker.newItem(lernaPackage.name)
promiseTracker.pause()
return promisifiedTaskFn(lernaPackage, promiseTracker)
.then(res => {
build && markPackageBuilt(lernaPackage, {log: forEachTracker})(build)
return res
})
.finally(() => {
promiseTracker.resume()
promiseTracker.completeWork(1)
})
}, {concurrency}).finally(() => forEachTracker.finish())
return Promise.map(
filteredLernaPackages,
lernaPackage => {
const promiseTracker = forEachTracker.newItem(lernaPackage.name)
promiseTracker.pause()
return promisifiedTaskFn(lernaPackage, promiseTracker)
.then(res => {
build && markPackageBuilt(lernaPackage, {log: forEachTracker})(build)
return res
})
.finally(() => {
promiseTracker.resume()
promiseTracker.completeWork(1)
})
},
{concurrency}
).finally(() => forEachTracker.finish())
}

@@ -49,0 +56,0 @@ }

{
"name": "lerna-script",
"version": "1.3.0",
"version": "1.3.2",
"description": "lerna extension for custom scripts",

@@ -19,3 +19,4 @@ "main": "index.js",

"type": "git",
"url": "https://github.com/wix/lerna-script/tree/master/lerna-script"
"url": "git@github.com:wix/lerna-script.git",
"directory": "/lerna-script"
},

@@ -27,6 +28,5 @@ "author": "vilius@wix.com",

"intercept-stdout": "0.1.2",
"invert-promise": "1.0.1",
"lerna": "3.21.0",
"lerna-script-test-utils": "^1.3.0",
"mocha": "7.1.2",
"invert-promise": "^1.0.1",
"lerna-script-test-utils": "^1.3.2",
"mocha": "7.2.0",
"sinon": "9.0.2",

@@ -47,3 +47,3 @@ "sinon-chai": "3.5.0"

"fs-extra": "8.1.0",
"ignore": "5.1.4",
"ignore": "5.1.6",
"lodash": "4.17.15",

@@ -55,3 +55,3 @@ "npmlog": "4.1.2",

},
"gitHead": "ce2a94876e14253375cda17f322e3402274ac8e7"
"gitHead": "57f5ed70009c21a786ad6741c08abf8dfc8726c8"
}

@@ -15,7 +15,7 @@ # lerna-script

* loglevel - set's loglevel, defaults to `info`;
- loglevel - set's loglevel, defaults to `info`;
task:
* one of exports defined in `lerna.js` file.
- one of exports defined in `lerna.js` file.

@@ -30,3 +30,3 @@ # API

* log, optional - `npmlog` logger;
- log, optional - `npmlog` logger;

@@ -39,3 +39,3 @@ ### loadRootPackage({[log]}): Promise[LernaPackage[]]

* log, optional - `npmlog` logger;
- log, optional - `npmlog` logger;

@@ -48,6 +48,6 @@ ### iter.forEach(lernaPackages, {[log], [build]})(task): Promise

* 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`.
- 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`.

@@ -63,7 +63,7 @@ Returns promise with task results.

* 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`.
* concurrency - number, defaults to `Infinity`. See [bluebird#map API](http://bluebirdjs.com/docs/api/promise.map.html#map-option-concurrency)
- 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`.
- concurrency - number, defaults to `Infinity`. See [bluebird#map API](http://bluebirdjs.com/docs/api/promise.map.html#map-option-concurrency)

@@ -79,6 +79,6 @@ Returns promise with task results.

* 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`.
- 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`.

@@ -96,12 +96,12 @@ Returns promise without results (undefined).

* command - command to execute;
- 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`;
- 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;
- stdout - collected output;

@@ -114,12 +114,12 @@ ### exec.script(lernaPackage, {silent = true})(script): Promise(stdout)

* script - npm script to execute;
- 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`;
- 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;
- stdout - collected output;

@@ -132,5 +132,5 @@ ### changes.build(lernaPackage, {[log]})([label]): undefined

* 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.
- 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.

@@ -143,5 +143,5 @@ ### changes.unbuild(lernaPackage, {[log]})([label]): undefined

* 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
- 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

@@ -154,4 +154,4 @@ ### changes.isBuilt(lernaPackage)([label]): boolean

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

@@ -162,5 +162,5 @@ ### filters.removeBuilt(lernaPackages: [], {[log]})([label]: String): []

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

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

* 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
- 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

@@ -184,5 +184,5 @@ **Note:** this filter mutates built/unbuild state, meaning that it unbuilds dependents to get reproducible runs.

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

@@ -195,5 +195,5 @@ ### filters.removeByGlob(lernaPackages: [], {[log]})(glob: String): []

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

@@ -206,5 +206,5 @@ ### filters.includeFilteredDeps(lernaPackages: [], {[log]})(filteredPackages: []): []

* lernaPackages - all packages;
* log, optional - `npmlog` logger;
* filteredPackages - subset of `lernaPackages`.
- lernaPackages - all packages;
- log, optional - `npmlog` logger;
- filteredPackages - subset of `lernaPackages`.

@@ -217,5 +217,5 @@ ### fs.readFile(lernaPackage)(relativePath, converter: buffer => ?): Promise[?]

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

@@ -230,5 +230,5 @@ ### fs.writeFile(lernaPackage)(relativePath, content, converter: type => string): Promise[String]

* 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.
- 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.

@@ -106,4 +106,5 @@ const {expect} = require('chai'),

const toThrow = new Error(
`Command failed with status ${res.status} and output ${res.stdout.toString() +
res.stderr.toString()}`
`Command failed with status ${res.status} and output ${
res.stdout.toString() + res.stderr.toString()
}`
)

@@ -110,0 +111,0 @@ toThrow.output = res.stdout.toString() + res.stderr.toString()

@@ -7,3 +7,3 @@ const {expect} = require('chai').use(require('sinon-chai')),

describe('filters', function() {
describe('filters', function () {
this.timeout(5000)

@@ -10,0 +10,0 @@

@@ -7,6 +7,5 @@ const {EOL} = require('os'),

describe('fs', () => {
describe('readFile', () => {
it('should read a file in module dir and return content as string', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -24,3 +23,3 @@ const [lernaPackage] = await index.loadPackages()

it('should read a file as json by providing custom converter', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -40,3 +39,3 @@ const [lernaPackage] = await index.loadPackages()

it('should write string to file', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -53,3 +52,3 @@ const [lernaPackage] = await index.loadPackages()

it('should write object with a newline at the end of file', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -69,3 +68,3 @@ const [lernaPackage] = await index.loadPackages()

it('should accept custom serializer', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -72,0 +71,0 @@ const [lernaPackage] = await index.loadPackages()

@@ -10,7 +10,4 @@ const {expect} = require('chai'),

describe('iterators', () => {
['forEach', 'parallel', 'batched'].forEach(type => {
;['forEach', 'parallel', 'batched'].forEach(type => {
describe(type, () => {
it('should filter-out changed packages', async () => {

@@ -38,3 +35,3 @@ const project = await asBuilt(asGitCommited(aLernaProjectWith2Modules()), {label: type})

it('should mark modules as built if "build" is provided', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -52,9 +49,9 @@ const packages = await index.loadPackages()

it('should not mark as build on failure', async () => {
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {
const packages = await index.loadPackages()
return invertPromise(index.iter[type](packages, {build: type})(() =>
Promise.reject(new Error('woops'))
)).then(() => {
return invertPromise(
index.iter[type](packages, {build: type})(() => Promise.reject(new Error('woops')))
).then(() => {
packages.forEach(lernaPackage =>

@@ -74,3 +71,3 @@ expect(index.changes.isBuilt(lernaPackage)(type)).to.equal(false)

const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -97,3 +94,3 @@ const packages = await index.loadPackages()

const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()
return project.within(async () => {

@@ -115,3 +112,5 @@ const packages = await index.loadPackages()

// project with 20 modules
const project = await aLernaProject(Array.from(Array(20).keys()).reduce((acc, idx) => ({...acc, [`package${idx}`]: []}), {}))
const project = await aLernaProject(
Array.from(Array(20).keys()).reduce((acc, idx) => ({...acc, [`package${idx}`]: []}), {})
)
let concurrentExecutions = 0

@@ -136,3 +135,3 @@

const log = loggerMock()
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()

@@ -139,0 +138,0 @@ return project.within(async () => {

@@ -7,7 +7,6 @@ const {expect} = require('chai').use(require('sinon-chai')),

describe('packages', () => {
describe('loadPackages', () => {
it('should return a list of packages', async () => {
const log = loggerMock()
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()

@@ -32,3 +31,3 @@ return project.within(async () => {

})
return project.within(async () => {
return project.within(async () => {
const packages = await index.loadPackages()

@@ -43,3 +42,3 @@ expect(packages.map(p => p.name)).to.deep.equal(['d', 'c', 'b', 'a'])

const log = loggerMock()
const project = await aLernaProjectWith2Modules();
const project = await aLernaProjectWith2Modules()

@@ -46,0 +45,0 @@ return project.within(async () => {

@@ -5,3 +5,3 @@ const index = require('..'),

module.exports.asBuilt = async (project, {label, log} = {}) => {
const resolved = await project;
const resolved = await project
return resolved.inDir(async ctx => {

@@ -15,5 +15,7 @@ const lernaPackages = await index.loadPackages({log})

module.exports.asGitCommited = project => {
return Promise.resolve(project).then(resolved => resolved.inDir(ctx => {
ctx.exec('git add -A && git commit -am "init"')
}))
return Promise.resolve(project).then(resolved =>
resolved.inDir(ctx => {
ctx.exec('git add -A && git commit -am "init"')
})
)
}

@@ -20,0 +22,0 @@

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