diff --git a/lib/commands/scan.js b/lib/commands/scan.js index ea84c5a..60a6e5d 100644 --- a/lib/commands/scan.js +++ b/lib/commands/scan.js @@ -1,8 +1,8 @@ +import chalk from 'chalk'; import { Argument, InvalidArgumentError, Option } from 'commander'; import { pollScanStatus, startScan, } from '../aikidoApi.js'; import { getApiKey } from '../configuration.js'; import { outputError, outputHttpError, outputLog, startSpinner, } from '../output.js'; -import chalk from 'chalk'; async function cli(repoId, baseCommitId, headCommitId, branchName, options, command) { const apiKey = getApiKey(); if (!apiKey) { diff --git a/lib/index.d.ts b/lib/index.d.ts index 59f4b82..568c2bb 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node import { Command } from 'commander'; -export declare const pkgJson: any; export declare const program: Command; declare global { namespace NodeJS { diff --git a/lib/index.js b/lib/index.js index 37e735b..8da3f24 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,23 +2,15 @@ import chalk from 'chalk'; import { Command } from 'commander'; import dotenv from 'dotenv'; -import { readFileSync } from 'fs'; -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; import apiKey from './commands/apiKey.js'; import scan from './commands/scan.js'; import upload from './commands/upload.js'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); -const __rootdirname = dirname(__dirname); dotenv.config(process.env.NODE_ENV ? { path: `.env.${process.env.NODE_ENV}` } : {}); -const pkgJsonPath = join('/', __rootdirname, 'package.json'); -export const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8')); export const program = new Command(); program - .name(pkgJson.name) - .description(pkgJson.description) - .version(pkgJson.version); + .name('Aikido API Client') + .description('CLI api client to easily integrate the Aikido public CI API into custom deploy scripts') + .version('1.0.1'); apiKey.cliSetup(program); scan.cliSetup(program); upload.cliSetup(program); diff --git a/package.json b/package.json index 8405a12..20b77f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aikidosec/ci-api-client", - "version": "1.0.0", + "version": "1.0.1", "description": "CLI api client to easily integrate the Aikido public CI API into custom deploy scripts", "license": "MIT", "author": "Bert Devriese ", diff --git a/src/commands/scan.ts b/src/commands/scan.ts index dac3886..3a510f0 100644 --- a/src/commands/scan.ts +++ b/src/commands/scan.ts @@ -1,10 +1,12 @@ +import chalk from 'chalk'; import { Argument, Command, InvalidArgumentError, Option } from 'commander'; +import { Ora } from 'ora'; import { - TStartScanResult, TPollIsScanningResult, TPollScanCompletedDefaultBranchResult, TPollScanFeatureBranchCompletedResult, TScanApiOptions, + TStartScanResult, pollScanStatus, startScan, } from '../aikidoApi.js'; @@ -15,9 +17,6 @@ import { outputLog, startSpinner, } from '../output.js'; -import chalk from 'chalk'; -import { Ora } from 'ora'; -import { pkgJson } from '../index.js'; type TScanArguments = { repoId: string | number; diff --git a/src/index.ts b/src/index.ts index 447e98b..2af6472 100755 --- a/src/index.ts +++ b/src/index.ts @@ -2,34 +2,24 @@ import chalk from 'chalk'; import { Command } from 'commander'; import dotenv from 'dotenv'; -import { readFileSync } from 'fs'; -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; import apiKey from './commands/apiKey.js'; import scan from './commands/scan.js'; import upload from './commands/upload.js'; -// Determine current file location and path to -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); -const __rootdirname = dirname(__dirname); - // Load all .env configuration variables and auto-inject them into process.env dotenv.config( process.env.NODE_ENV ? { path: `.env.${process.env.NODE_ENV}` } : {} ); -// Set commander instance info from package.json -const pkgJsonPath = join('/', __rootdirname, 'package.json'); -export const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8')); - // Start up commander.js Command instance export const program = new Command(); program - .name(pkgJson.name) - .description(pkgJson.description) - .version(pkgJson.version); + .name('Aikido API Client') + .description( + 'CLI api client to easily integrate the Aikido public CI API into custom deploy scripts' + ) + .version('1.0.1'); // Load in all app commands and set them up in the `program` instance apiKey.cliSetup(program);