Skip to content

Commit 8567797

Browse files
committed
feat: add flag to exclude manifest.json files from dependency resolution
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: passed - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent dcf7676 commit 8567797

9 files changed

Lines changed: 72 additions & 27 deletions

File tree

lib/node_modules/@stdlib/_tools/pkgs/dep-list/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ Usage: stdlib-dep-list [options] [<pkg>]
101101
102102
Options:
103103
104-
-h, --help Print this message.
105-
-V, --version Print the package version.
106-
--dev Print development dependencies.
104+
-h, --help Print this message.
105+
-V, --version Print the package version.
106+
--dev Include development dependencies.
107+
--manifest Include manifest.json dependencies.
107108
```
108109

109110
</section>

lib/node_modules/@stdlib/_tools/pkgs/dep-list/bin/cli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ function main() {
6565
if ( flags.dev ) {
6666
opts.dev = flags.dev;
6767
}
68+
if ( flags.manifest ) {
69+
opts.manifest = flags.manifest;
70+
}
6871
if ( args[ 0 ] ) {
6972
opts.dir = args[ 0 ];
7073
}

lib/node_modules/@stdlib/_tools/pkgs/dep-list/docs/usage.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Usage: stdlib-dep-list [options] [<pkg>]
33

44
Options:
55

6-
-h, --help Print this message.
7-
-V, --version Print the package version.
8-
--dev Print development dependencies.
6+
-h, --help Print this message.
7+
-V, --version Print the package version.
8+
--dev Include development dependencies.
9+
--manifest Include manifest.json dependencies.
910

lib/node_modules/@stdlib/_tools/pkgs/dep-list/etc/cli_opts.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"boolean": [
33
"help",
44
"version",
5-
"dev"
5+
"dev",
6+
"manifest"
67
],
78
"alias": {
89
"help": [
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"dev": false
2+
"dev": false,
3+
"manifest": true
34
}

lib/node_modules/@stdlib/_tools/pkgs/dep-list/lib/deps.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ var RE_DATA_JSON = /\/data\/.+\.json$/;
4949
* @private
5050
* @param {string} pkg - package name
5151
* @param {boolean} dev - boolean indicating whether to return development dependencies
52+
* @param {boolean} includeManifest - boolean indicating whether to return dependencies from `manifest.json` files
5253
* @returns {(StringArray|EmptyArray)} dependencies array
5354
*/
54-
function depList( pkg, dev ) {
55+
function depList( pkg, dev, includeManifest ) {
5556
var namespacePkgs;
5657
var manifest;
5758
var fpath;
@@ -84,22 +85,24 @@ function depList( pkg, dev ) {
8485
} catch ( err ) {
8586
debug( 'Encountered an error while reading `index.d.ts` file: %s', err.message );
8687
}
87-
fpath = resolve( entry, '..', 'manifest.json' );
88-
manifest = readJSON( fpath );
89-
if ( !instanceOf( manifest, Error ) ) {
90-
if ( !dev ) {
91-
deps.push( '@stdlib/utils/library-manifest' );
92-
}
93-
task = manifest.options.task;
94-
for ( i = 0; i < manifest.confs.length; i++ ) {
95-
conf = manifest.confs[ i ];
96-
if ( !dev && conf.task === task ) {
97-
for ( j = 0; j < conf.dependencies.length; j++ ) {
98-
deps.push( conf.dependencies[ j ] );
99-
}
100-
} else if ( dev ) {
101-
for ( j = 0; j < conf.dependencies.length; j++ ) {
102-
deps.push( conf.dependencies[ j ] );
88+
if ( includeManifest ) {
89+
fpath = resolve( entry, '..', 'manifest.json' );
90+
manifest = readJSON( fpath );
91+
if ( !instanceOf( manifest, Error ) ) {
92+
if ( !dev ) {
93+
deps.push( '@stdlib/utils/library-manifest' );
94+
}
95+
task = manifest.options.task;
96+
for ( i = 0; i < manifest.confs.length; i++ ) {
97+
conf = manifest.confs[ i ];
98+
if ( !dev && conf.task === task ) {
99+
for ( j = 0; j < conf.dependencies.length; j++ ) {
100+
deps.push( conf.dependencies[ j ] );
101+
}
102+
} else if ( dev ) {
103+
for ( j = 0; j < conf.dependencies.length; j++ ) {
104+
deps.push( conf.dependencies[ j ] );
105+
}
103106
}
104107
}
105108
}

lib/node_modules/@stdlib/_tools/pkgs/dep-list/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ function ascending( a, b ) {
5656
*
5757
* @param {string} pkg - package name
5858
* @param {Options} [options] - function options
59-
* @param {string} [options.dev=false] - boolean indicating whether to return development dependencies
59+
* @param {boolean} [options.dev=false] - boolean indicating whether to return development dependencies
60+
* @param {boolean} [options.manifest=true] - boolean indicating whether to return dependencies from `manifest.json` files
6061
* @throws {TypeError} first argument must be a string
6162
* @returns {(StringArray|EmptyArray)} dependencies
6263
*/
@@ -74,7 +75,7 @@ function depList( pkg, options ) {
7475
throw err;
7576
}
7677
}
77-
return deps( pkg, opts.dev ).sort( ascending );
78+
return deps( pkg, opts.dev, opts.manifest ).sort( ascending );
7879
}
7980

8081

lib/node_modules/@stdlib/_tools/pkgs/dep-list/lib/validate.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var format = require( '@stdlib/string/format' );
3535
* @param {Object} opts - destination object
3636
* @param {Options} options - function options
3737
* @param {boolean} [options.dev] - boolean indicating whether to return development dependencies
38+
* @param {boolean} [options.manifest] - boolean indicating whether to return dependencies from `manifest.json` files
3839
* @returns {(Error|null)} error object or null
3940
*
4041
* @example
@@ -58,6 +59,12 @@ function validate( opts, options ) {
5859
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'dev', opts.dev ) );
5960
}
6061
}
62+
if ( hasOwnProp( options, 'manifest' ) ) {
63+
opts.manifest = options.manifest;
64+
if ( !isBoolean( opts.manifest ) ) {
65+
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'manifest', opts.manifest ) );
66+
}
67+
}
6168
return null;
6269
}
6370

lib/node_modules/@stdlib/_tools/pkgs/dep-list/test/test.validate.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ tape( 'if provided a `dev` option which is not a `boolean`, the function returns
8585
t.end();
8686
});
8787

88+
tape( 'if provided a `manifest` option which is not a `boolean`, the function returns a type error', function test( t ) {
89+
var values;
90+
var opts;
91+
var err;
92+
var i;
93+
94+
values = [
95+
'abc',
96+
5,
97+
NaN,
98+
null,
99+
void 0,
100+
[],
101+
{},
102+
function noop() {}
103+
];
104+
105+
for ( i = 0; i < values.length; i++ ) {
106+
opts = {};
107+
err = validate( opts, {
108+
'manifest': values[i]
109+
});
110+
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
111+
}
112+
t.end();
113+
});
114+
88115
tape( 'the function returns `null` if all options are valid', function test( t ) {
89116
var opts;
90117
var obj;

0 commit comments

Comments
 (0)