File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+ 'use strict'
3+
4+ const analyze = require ( './index.js' )
5+
6+ async function main ( ) {
7+ // Note: Replace with a valid NCM API token
8+ // Set via environment variable: NCM_TOKEN=your-token node test-local.js
9+ const token = process . env . NCM_TOKEN || 'accounts token'
10+
11+ const data = await analyze ( {
12+ dir : __dirname ,
13+ token : token ,
14+ onPkgs : pkgs => console . log ( `Analyzing ${ pkgs . size } modules...` )
15+ } )
16+
17+ for ( const pkg of data ) {
18+ console . log ( `${ pkg . name } @${ pkg . version } ` )
19+
20+ // Display scores if available
21+ if ( pkg . scores && pkg . scores . length > 0 ) {
22+ console . log ( ' Scores:' )
23+ for ( const score of pkg . scores ) {
24+ const status = score . pass ? '✓' : '✗'
25+ console . log ( ` ${ status } ${ score . title } (${ score . severity } )` )
26+ }
27+ }
28+
29+ // Display paths if available
30+ if ( pkg . paths && pkg . paths . length > 0 ) {
31+ console . log ( ' Dependency paths:' )
32+ for ( const path of pkg . paths ) {
33+ console . log ( ` ${ path . map ( p => `${ p . data . name } @${ p . data . version } ` ) . join ( ' > ' ) } ` )
34+ }
35+ }
36+
37+ console . log ( '' )
38+ }
39+ }
40+
41+ main ( ) . catch ( err => {
42+ console . error ( 'Error:' , err )
43+ process . exit ( 1 )
44+ } )
You can’t perform that action at this time.
0 commit comments