-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(explain): add workspaces support
- Add highlight style for workspaces items in human output - Add ability to filter results by workspace using `-w` config - Added tests and docs Fixes: npm/statusboard#300
- Loading branch information
Showing
7 changed files
with
250 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,3 +199,29 @@ exports[`test/lib/utils/explain-dep.js TAP prodDep > print nocolor 1`] = ` | |
[email protected] | ||
node_modules/prod-dep | ||
` | ||
|
||
exports[`test/lib/utils/explain-dep.js TAP workspaces > explain color deep 1`] = ` | ||
[[email protected][39m[2m[22m | ||
[2ma[22m | ||
[[email protected][39m[2m[22m | ||
[2mnode_modules/a[22m | ||
[32mworkspace[39m [1mtest/lib/utils/tap-testdir-explain-dep/ws-project/a[22m from the root project | ||
` | ||
|
||
exports[`test/lib/utils/explain-dep.js TAP workspaces > explain nocolor shallow 1`] = ` | ||
[email protected] | ||
a | ||
[email protected] | ||
node_modules/a | ||
workspace test/lib/utils/tap-testdir-explain-dep/ws-project/a from the root project | ||
` | ||
|
||
exports[`test/lib/utils/explain-dep.js TAP workspaces > print color 1`] = ` | ||
[[email protected][39m[2m[22m | ||
[2ma[22m | ||
` | ||
|
||
exports[`test/lib/utils/explain-dep.js TAP workspaces > print nocolor 1`] = ` | ||
[email protected] | ||
a | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,3 +175,129 @@ t.test('explain some nodes', t => { | |
}) | ||
t.end() | ||
}) | ||
|
||
t.test('workspaces', async t => { | ||
npm.localPrefix = npm.prefix = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
name: 'workspaces-project', | ||
version: '1.0.0', | ||
workspaces: ['packages/*'], | ||
dependencies: { | ||
abbrev: '^1.0.0', | ||
}, | ||
}), | ||
node_modules: { | ||
a: t.fixture('symlink', '../packages/a'), | ||
b: t.fixture('symlink', '../packages/b'), | ||
c: t.fixture('symlink', '../packages/c'), | ||
once: { | ||
'package.json': JSON.stringify({ | ||
name: 'once', | ||
version: '1.0.0', | ||
dependencies: { | ||
wrappy: '2.0.0', | ||
}, | ||
}), | ||
}, | ||
abbrev: { | ||
'package.json': JSON.stringify({ | ||
name: 'abbrev', | ||
version: '1.0.0', | ||
}), | ||
}, | ||
wrappy: { | ||
'package.json': JSON.stringify({ | ||
name: 'wrappy', | ||
version: '2.0.0', | ||
}), | ||
}, | ||
}, | ||
packages: { | ||
a: { | ||
'package.json': JSON.stringify({ | ||
name: 'a', | ||
version: '1.0.0', | ||
dependencies: { | ||
once: '1.0.0', | ||
}, | ||
}), | ||
}, | ||
b: { | ||
'package.json': JSON.stringify({ | ||
name: 'b', | ||
version: '1.0.0', | ||
dependencies: { | ||
abbrev: '^1.0.0', | ||
}, | ||
}), | ||
}, | ||
c: { | ||
'package.json': JSON.stringify({ | ||
name: 'c', | ||
version: '1.0.0', | ||
}), | ||
}, | ||
}, | ||
}) | ||
|
||
await new Promise((res, rej) => { | ||
explain.exec(['wrappy'], err => { | ||
if (err) | ||
rej(err) | ||
|
||
t.strictSame( | ||
OUTPUT, | ||
[['[email protected] depth=Infinity color=true']], | ||
'should explain workspaces deps' | ||
) | ||
OUTPUT.length = 0 | ||
res() | ||
}) | ||
}) | ||
|
||
await new Promise((res, rej) => { | ||
explain.execWorkspaces(['wrappy'], ['a'], err => { | ||
if (err) | ||
rej(err) | ||
|
||
t.strictSame( | ||
OUTPUT, | ||
[ | ||
['[email protected] depth=Infinity color=true'], | ||
], | ||
'should explain deps when filtering to a single ws' | ||
) | ||
OUTPUT.length = 0 | ||
res() | ||
}) | ||
}) | ||
|
||
await new Promise((res, rej) => { | ||
explain.execWorkspaces(['abbrev'], [], err => { | ||
if (err) | ||
rej(err) | ||
|
||
t.strictSame( | ||
OUTPUT, | ||
[ | ||
['[email protected] depth=Infinity color=true'], | ||
], | ||
'should explain deps of workspaces only' | ||
) | ||
OUTPUT.length = 0 | ||
res() | ||
}) | ||
}) | ||
|
||
await new Promise((res, rej) => { | ||
explain.execWorkspaces(['abbrev'], ['a'], err => { | ||
t.equal( | ||
err, | ||
'No dependencies found matching abbrev', | ||
'should throw usage if dep not found within filtered ws' | ||
) | ||
|
||
res() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters