diff --git a/bin/dev.js b/bin/dev.js index 36cdccdc..6e6496d5 100755 --- a/bin/dev.js +++ b/bin/dev.js @@ -1,13 +1,7 @@ #!/usr/bin/env node -// Localhost -// process.env.GRAPHQL_HOST = 'http://localhost:3000'; - -// Dev process.env.GRAPHQL_HOST = 'https://api.dev.nes.herodevs.com'; - -// Prod -// process.env.GRAPHQL_HOST = 'https://api.nes.herodevs.com'; +process.env.EOL_REPORT_URL = 'https://eol-report-card.stage.apps.herodevs.io'; import main from './main.js'; diff --git a/src/api/nes/nes.client.ts b/src/api/nes/nes.client.ts index 22e1b00e..1b25ea39 100644 --- a/src/api/nes/nes.client.ts +++ b/src/api/nes/nes.client.ts @@ -6,6 +6,7 @@ import type { InsightsEolScanInput, InsightsEolScanResult, } from '../../api/types/nes.types.ts'; +import { config } from '../../config/constants.ts'; import { debugLogger } from '../../service/log.svc.ts'; import { SbomScanner, buildScanResult } from '../../service/nes/nes.svc.ts'; import { @@ -45,9 +46,8 @@ export class NesApolloClient implements NesClient { * Submit a scan for a list of purls after they've been batched by batchSubmitPurls */ function submitScan(purls: string[], options: ScanInputOptions): Promise { - // NOTE: GRAPHQL_HOST is set in `./bin/dev.js` or tests - const host = process.env.GRAPHQL_HOST || 'https://api.nes.herodevs.com'; - const path = process.env.GRAPHQL_PATH || '/graphql'; + const host = config.graphqlHost; + const path = config.graphqlPath; const url = host + path; const client = new NesApolloClient(url); return client.scan.purls(purls, options); diff --git a/src/commands/scan/eol.ts b/src/commands/scan/eol.ts index 90059898..46912f85 100644 --- a/src/commands/scan/eol.ts +++ b/src/commands/scan/eol.ts @@ -4,7 +4,7 @@ import { Command, Flags, ux } from '@oclif/core'; import { batchSubmitPurls } from '../../api/nes/nes.client.ts'; import type { ScanResult } from '../../api/types/hd-cli.types.js'; import type { ComponentStatus, InsightsEolScanComponent } from '../../api/types/nes.types.ts'; -import { getEolReportUrl } from '../../config/constants.ts'; +import { config } from '../../config/constants.ts'; import type { Sbom } from '../../service/eol/cdx.svc.ts'; import { getErrorMessage, isErrnoException } from '../../service/error.svc.ts'; import { extractPurls, parsePurlsFile } from '../../service/purls.svc.ts'; @@ -103,9 +103,9 @@ export default class ScanEol extends Command { private printWebReportUrl(scanId: string): void { this.logLine(); const id = scanId.split(SCAN_ID_KEY)[1]; - const reportCardUrl = getEolReportUrl(); + const reportCardUrl = config.eolReportUrl; const url = ux.colorize('blue', `${reportCardUrl}/${id}`); - this.log(`🌐 View your free EOL report at ${url}`); + this.log(`🌐 View your free EOL report at: ${ux.colorize('blue', url)}`); } private async scanSbom(sbom: Sbom): Promise { diff --git a/src/config/constants.ts b/src/config/constants.ts index 21c38721..e68ace84 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -1,5 +1,9 @@ -export const DEFAULT_EOL_REPORT_URL = 'https://eol-report-card.stage.apps.herodevs.io'; +export const EOL_REPORT_URL = ''; +export const GRAPHQL_HOST = 'https://api.nes.herodevs.com'; +export const GRAPHQL_PATH = '/graphql'; -export function getEolReportUrl() { - return process.env.EOL_REPORT_URL || DEFAULT_EOL_REPORT_URL; -} +export const config = { + eolReportUrl: process.env.EOL_REPORT_URL || EOL_REPORT_URL, + graphqlHost: process.env.GRAPHQL_HOST || GRAPHQL_HOST, + graphqlPath: process.env.GRAPHQL_PATH || GRAPHQL_PATH, +};