@@ -5,12 +5,12 @@ import { existsSync, readFileSync, unlinkSync } from 'node:fs';
5
5
import { mkdir } from 'node:fs/promises' ;
6
6
import path from 'node:path' ;
7
7
import { describe , it } from 'node:test' ;
8
- import { fileURLToPath } from 'node:url' ;
9
8
import { promisify } from 'node:util' ;
10
9
import { runCommand } from '@oclif/test' ;
11
10
import { config , filenamePrefix } from '../../src/config/constants' ;
12
11
13
12
const execAsync = promisify ( exec ) ;
13
+ const fixturesDir = path . resolve ( import . meta. dirname , '../fixtures' ) ;
14
14
15
15
describe ( 'environment' , ( ) => {
16
16
it ( 'should not be configured to run against the production environment' , ( ) => {
@@ -26,8 +26,7 @@ describe('default arguments', () => {
26
26
// Run the CLI directly with no arguments
27
27
const { stdout } = await execAsync ( 'node bin/run.js' ) ;
28
28
29
- // Match EOL count
30
- match ( stdout , / 1 ( .* ) E n d - o f - L i f e \( E O L \) / , 'Should show EOL count' ) ;
29
+ match ( stdout , / [ 1 - 9 ] \d * ( .* ) E n d - o f - L i f e \( E O L \) / , 'Should show non-zero EOL count' ) ;
31
30
} ) ;
32
31
33
32
it ( 'runs scan:eol --json when --json is passed in' , async ( ) => {
@@ -59,13 +58,10 @@ describe('default arguments', () => {
59
58
} ) ;
60
59
61
60
describe ( 'scan:eol e2e' , ( ) => {
62
- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
63
- const fixturesDir = path . resolve ( __dirname , '../fixtures' ) ;
64
- const simplePurls = path . resolve ( __dirname , '../fixtures/npm/simple.purls.json' ) ;
61
+ const simplePurls = path . resolve ( fixturesDir , 'npm/simple.purls.json' ) ;
65
62
const simpleSbom = path . join ( fixturesDir , `npm/${ filenamePrefix } .sbom.json` ) ;
66
63
const reportPath = path . resolve ( fixturesDir , `${ filenamePrefix } .report.json` ) ;
67
- const upToDatePurls = path . resolve ( __dirname , '../fixtures/npm/up-to-date.purls.json' ) ;
68
- const emptyPurlsPath = path . resolve ( __dirname , '../fixtures/npm/empty.purls.json' ) ;
64
+ const emptyPurlsPath = path . resolve ( fixturesDir , 'npm/empty.purls.json' ) ;
69
65
70
66
async function run ( cmd : string ) {
71
67
// Ensure fixtures directory exists and is clean
@@ -133,7 +129,7 @@ describe('scan:eol e2e', () => {
133
129
} ) ;
134
130
135
131
it . skip ( 'scans extra-large.purls.json for EOL components' , async ( ) => {
136
- const extraLargePurlsPath = path . resolve ( __dirname , '../fixtures/ npm/extra-large.purls.json' ) ;
132
+ const extraLargePurlsPath = path . resolve ( fixturesDir , 'npm/extra-large.purls.json' ) ;
137
133
const cmd = `scan:eol --purls ${ extraLargePurlsPath } ` ;
138
134
const { stdout } = await run ( cmd ) ;
139
135
@@ -171,19 +167,22 @@ describe('scan:eol e2e', () => {
171
167
172
168
const json = JSON . parse ( stdout ) ;
173
169
const bootstrap = json . components . find ( ( component ) => component . purl . startsWith ( 'pkg:npm/bootstrap@' ) ) ;
174
- strictEqual ( bootstrap ?. info . status , 'EOL' , 'Should match EOL count' ) ;
175
- strictEqual ( bootstrap ?. info . nesAvailable , true , 'Should match remediation count' ) ;
170
+ strictEqual ( bootstrap ?. metadata . isEol , true , 'Bootstrap should be marked as EOL' ) ;
171
+ strictEqual (
172
+ ! ! bootstrap ?. nesRemediation ?. remediations ?. length ,
173
+ true ,
174
+ 'Bootstrap should have NES remediation available' ,
175
+ ) ;
176
176
} ) ;
177
177
178
178
it ( 'correctly identifies Angular 17 as having a EOL date when using --json flag' , async ( ) => {
179
- const angular17Purls = path . resolve ( __dirname , '../fixtures/ npm/angular-17.purls.json' ) ;
179
+ const angular17Purls = path . resolve ( fixturesDir , 'npm/angular-17.purls.json' ) ;
180
180
const cmd = `scan:eol --purls=${ angular17Purls } --json` ;
181
181
const { stdout } = await run ( cmd ) ;
182
182
183
183
const json = JSON . parse ( stdout ) ;
184
184
const angular17 = json . components . find ( ( component ) => component . purl . startsWith ( 'pkg:npm/%40angular/core@' ) ) ;
185
- // Match EOL count
186
- strictEqual ( angular17 ?. info . status , 'EOL' , 'Should match EOL status' ) ;
185
+ strictEqual ( angular17 ?. metadata . isEol , true , 'Angular 17 should be marked as EOL' ) ;
187
186
} ) ;
188
187
189
188
describe ( 'web report URL' , ( ) => {
@@ -210,9 +209,7 @@ describe('scan:eol e2e', () => {
210
209
* Please see CONTRIBUTING.md before adding new tests to this section.
211
210
*/
212
211
describe ( 'with directory flag' , ( ) => {
213
- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
214
- const simpleDir = path . resolve ( __dirname , '../fixtures/npm/simple' ) ;
215
- const upToDateDir = path . resolve ( __dirname , '../fixtures/npm/up-to-date' ) ;
212
+ const simpleDir = path . resolve ( fixturesDir , 'npm/simple' ) ;
216
213
const reportPath = path . join ( simpleDir , `${ filenamePrefix } .report.json` ) ;
217
214
218
215
async function run ( cmd : string ) {
0 commit comments