Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

export GRAPHQL_HOST='https://api.nes.herodevs.com';
export EOL_REPORT_URL='https://eol-report-card.apps.herodevs.com/reports';
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- windows-latest
name: "${{matrix.platform}} w/ Node.js ${{matrix.node}}.x"
runs-on: ${{matrix.platform}}
env:
GRAPHQL_HOST: ${{ secrets.GRAPHQL_HOST }}
EOL_REPORT_URL: ${{ secrets.EOL_REPORT_URL }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: "Use Node.js ${{matrix.node}}.x"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
test:
runs-on: ubuntu-latest
needs: check-version
env:
GRAPHQL_HOST: ${{ secrets.GRAPHQL_HOST }}
EOL_REPORT_URL: ${{ secrets.EOL_REPORT_URL }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
test:
runs-on: ubuntu-latest
needs: check-version
env:
GRAPHQL_HOST: ${{ secrets.GRAPHQL_HOST }}
EOL_REPORT_URL: ${{ secrets.EOL_REPORT_URL }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yarn.lock
pnpm-lock.yaml
**/packages/cli-*/bin/
**/tsconfig.tsbuildinfo
.envrc
3 changes: 0 additions & 3 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env node

process.env.GRAPHQL_HOST = 'https://api.dev.nes.herodevs.com';
process.env.EOL_REPORT_URL = 'https://eol-report-card.stage.apps.herodevs.io/reports';

import main from './main.js';

try {
Expand Down
40 changes: 15 additions & 25 deletions e2e/scan/eol.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { doesNotThrow } from 'node:assert';
import { doesNotThrow, notStrictEqual } from 'node:assert';
import { doesNotMatch, match, strictEqual } from 'node:assert/strict';
import { exec } from 'node:child_process';
import { existsSync, readFileSync, unlinkSync } from 'node:fs';
Expand All @@ -12,14 +12,19 @@ import { config } from '../../src/config/constants';

const execAsync = promisify(exec);

const GRAPHQL_HOST = 'https://api.dev.nes.herodevs.com';
describe('environment', () => {
it('should not be configured to run against the production environment', () => {
notStrictEqual(process.env.GRAPHQL_HOST, 'https://api.nes.herodevs.com');
notStrictEqual(process.env.EOL_REPORT_URL, 'https://eol-report-card.apps.herodevs.io/reports');
notStrictEqual(config.graphqlHost, 'https://api.nes.herodevs.com');
notStrictEqual(config.eolReportUrl, 'https://eol-report-card.apps.herodevs.io/reports');
});
});

describe('default arguments', () => {
it('defaults to scan:eol -t when no arguments are provided', async () => {
// Run the CLI directly with no arguments
const { stdout } = await execAsync('node bin/run.js', {
env: { ...process.env, GRAPHQL_HOST },
});
const { stdout } = await execAsync('node bin/run.js');

// Match table header
match(stdout, /┌.*┬.*┬.*┬.*┬.*┐/, 'Should show table top border');
Expand All @@ -42,29 +47,23 @@ describe('default arguments', () => {
});

it('runs scan:eol -a -t when -a -t is passed in', async () => {
const { stdout, stderr } = await execAsync('node bin/run.js -a -t', {
env: { ...process.env, GRAPHQL_HOST },
});
const { stdout, stderr } = await execAsync('node bin/run.js -a -t');

// Verify command executed successfully
match(stdout, /components scanned/, 'Should show components scanned message');
});

it('runs scan:eol --json when --json is passed in', async () => {
// Run the CLI with --json flag
const { stdout } = await execAsync('node bin/run.js --json', {
env: { ...process.env, GRAPHQL_HOST },
});
const { stdout } = await execAsync('node bin/run.js --json');

// Verify JSON output
doesNotMatch(stdout, /Here are the results of the scan:/, 'Should not show results header');
doesNotThrow(() => JSON.parse(stdout), 'Output should be valid JSON');
});

it('shows help for scan:eol when --help is passed in', async () => {
const { stdout } = await execAsync('node bin/run.js --help', {
env: { ...process.env, GRAPHQL_HOST },
});
const { stdout } = await execAsync('node bin/run.js --help');

// Verify help output
match(stdout, /USAGE/, 'Should show usage section');
Expand All @@ -73,9 +72,7 @@ describe('default arguments', () => {
});

it('shows global help when help is passed in', async () => {
const { stdout } = await execAsync('node bin/run.js help', {
env: { ...process.env, GRAPHQL_HOST },
});
const { stdout } = await execAsync('node bin/run.js help');

// Verify help output
match(stdout, /USAGE/, 'Should show usage section');
Expand All @@ -96,9 +93,6 @@ describe('scan:eol e2e', () => {
const angular17Purls = path.resolve(__dirname, '../fixtures/npm/angular-17.purls.json');

async function run(cmd: string) {
// Set up environment
process.env.GRAPHQL_HOST = GRAPHQL_HOST;

// Ensure fixtures directory exists and is clean
await mkdir(fixturesDir, { recursive: true });

Expand Down Expand Up @@ -159,7 +153,7 @@ describe('scan:eol e2e', () => {
unlinkSync(reportPath);
});

it('scans extra-large.purls.json for EOL components', async () => {
it.skip('scans extra-large.purls.json for EOL components', async () => {
const cmd = `scan:eol --purls ${extraLargePurlsPath}`;
const { stdout } = await run(cmd);

Expand Down Expand Up @@ -306,10 +300,6 @@ describe('scan:eol e2e directory', () => {
const reportPath = path.join(simpleDir, 'eol.report.json');

async function run(cmd: string) {
// Set up environment
process.env.GRAPHQL_HOST = GRAPHQL_HOST;
// process.env.GRAPHQL_HOST = 'http://localhost:3000';

// Ensure test directory exists and is clean
await mkdir(simpleDir, { recursive: true });

Expand Down
1 change: 1 addition & 0 deletions src/api/nes/nes.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function submitScan(purls: string[], options: ScanInputOptions): Promise<Insight
const host = config.graphqlHost;
const path = config.graphqlPath;
const url = host + path;
debugLogger('Submitting scan to %s', url);
const client = new NesApolloClient(url);
return client.scan.purls(purls, options);
}
Expand Down