diff --git a/src/commands/scan/fetch-create-org-full-scan.ts b/src/commands/scan/fetch-create-org-full-scan.ts index c490917e5..c8c5c57cb 100644 --- a/src/commands/scan/fetch-create-org-full-scan.ts +++ b/src/commands/scan/fetch-create-org-full-scan.ts @@ -20,7 +20,9 @@ export async function fetchCreateOrgFullScan( // Lazily access constants.spinner. const { spinner } = constants - spinner.start(`Creating a scan with ${packagePaths.length} packages...`) + spinner.start( + `Sending request to create a scan with ${packagePaths.length} packages...` + ) const result = await handleApiCall( sockSdk.createOrgFullScan( @@ -39,7 +41,7 @@ export async function fetchCreateOrgFullScan( 'Creating scan' ) - spinner.successAndStop('Scan created successfully') + spinner.successAndStop('Completed request to create a new scan.') if (!result.success) { handleUnsuccessfulApiResponse('CreateOrgFullScan', result) diff --git a/src/commands/scan/fetch-supported-scan-file-names.ts b/src/commands/scan/fetch-supported-scan-file-names.ts index 49d693be5..ff9267c51 100644 --- a/src/commands/scan/fetch-supported-scan-file-names.ts +++ b/src/commands/scan/fetch-supported-scan-file-names.ts @@ -1,3 +1,5 @@ +import { logger } from '@socketsecurity/registry/lib/logger' + import constants from '../../constants' import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api' import { setupSdk } from '../../utils/sdk' @@ -19,9 +21,8 @@ export async function fetchSupportedScanFileNames(): Promise< 'fetching supported scan file types' ) - spinner.successAndStop( - 'Received response while fetched supported scan file types.' - ) + spinner.stop() + logger.success('Received response while fetched supported scan file types.') if (!result.success) { handleUnsuccessfulApiResponse('getReportSupportedFiles', result) diff --git a/src/commands/scan/handle-create-new-scan.ts b/src/commands/scan/handle-create-new-scan.ts index ec7c0b252..f0d44883a 100644 --- a/src/commands/scan/handle-create-new-scan.ts +++ b/src/commands/scan/handle-create-new-scan.ts @@ -38,7 +38,6 @@ export async function handleCreateNewScan({ cwd, targets, supportedFileNames - // socketConfig ) handleBadInput({ diff --git a/src/utils/api.ts b/src/utils/api.ts index 91c8168db..172adcf84 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,5 +1,6 @@ import process from 'node:process' +import { debugLog } from '@socketsecurity/registry/lib/debug' import { logger } from '@socketsecurity/registry/lib/logger' import { isNonEmptyString } from '@socketsecurity/registry/lib/strings' @@ -27,7 +28,7 @@ export function handleUnsuccessfulApiResponse( throw new AuthError(message) } - logger.fail(failMsgWithBadge('API returned an error:', message)) + logger.fail(failMsgWithBadge('API returned an error', message)) // eslint-disable-next-line n/no-process-exit process.exit(1) } @@ -40,6 +41,7 @@ export async function handleApiCall( try { result = await value } catch (cause) { + debugLog('handleApiCall[', description, '] error:\n', cause) throw new Error(`Failed ${description}`, { cause }) } return result diff --git a/src/utils/path-resolve.ts b/src/utils/path-resolve.ts index a55cbf903..3e1fa873d 100644 --- a/src/utils/path-resolve.ts +++ b/src/utils/path-resolve.ts @@ -7,7 +7,7 @@ import micromatch from 'micromatch' import { glob as tinyGlob } from 'tinyglobby' import which from 'which' -import { debugLog } from '@socketsecurity/registry/lib/debug' +import { debugLog, isDebug } from '@socketsecurity/registry/lib/debug' import { resolveBinPath } from '@socketsecurity/registry/lib/npm' import { directoryPatterns } from './ignore-by-default' @@ -254,27 +254,43 @@ export async function getPackageFilesForScan( supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'], config?: SocketYml | undefined ): Promise { - debugLog(`Globbed resolving ${inputPaths.length} paths:`, inputPaths) + debugLog( + `getPackageFilesForScan: resolving ${inputPaths.length} paths:`, + inputPaths + ) + + // Lazily access constants.spinner. + const { spinner } = constants + + spinner.start('Searching for local files to include in scan...') const entries = await globWithGitIgnore(pathsToPatterns(inputPaths), { cwd, socketConfig: config }) - debugLog( - `Globbed resolved ${inputPaths.length} paths to ${entries.length} paths:`, - entries - ) + if (isDebug()) { + spinner.stop() + debugLog( + `Resolved ${inputPaths.length} paths to ${entries.length} local paths`, + entries + ) + spinner.start('Searching for files now...') + } else { + spinner.start( + `Resolved ${inputPaths.length} paths to ${entries.length} local paths, searching for files now...` + ) + } const packageFiles = await filterGlobResultToSupportedFiles( entries, supportedFiles ) - debugLog( - `Mapped ${entries.length} entries to ${packageFiles.length} files:`, - packageFiles + spinner.successAndStop( + `Found ${packageFiles.length} local file${packageFiles.length === 1 ? '' : 's'}` ) + debugLog('Absolute paths:', packageFiles) return packageFiles }