Skip to content

Commit 3e40151

Browse files
committed
feat: provide more feedback to the users while running CLI commands
1 parent c19e483 commit 3e40151

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/cli/checks.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async function runCheckCommand (knex, options = {}) {
4040

4141
debug('Running check with code_name:', answers.name)
4242
await checks[answers.name](knex)
43+
logger.info(`Check (${answers.name}) ran successfully`)
4344
}
4445

4546
module.exports = {

src/cli/project.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { stringToArray } = require('@ulisesgascon/string-to-array')
33
const isSlug = require('validator/lib/isSlug.js')
44
const debug = require('debug')('cli')
55
const { getConfig } = require('../config')
6-
const { validateGithubUrl } = require('../utils')
6+
const { validateGithubUrl, logger } = require('../utils')
77
const { initializeStore } = require('../store')
88

99
const { projectCategories } = getConfig()
@@ -102,6 +102,7 @@ async function runAddProjectCommand (knex, options = {}) {
102102
})))
103103

104104
debug(`All orgs were stored and linked to (${answers.name}) added successfully!`)
105+
logger.info(`Project (${answers.name}) added successfully!`)
105106

106107
return answers
107108
}

src/providers/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const performScorecardAnalysis = async (repo) => {
6565
const start = new Date().getTime()
6666
const { stdout, stderr } = await exec(`docker run -e GITHUB_AUTH_TOKEN=${process.env.GITHUB_TOKEN} --rm ${ossfScorecardSettings.dockerImage} --repo=${repo.html_url} --show-details --format=json`)
6767
if (stderr) {
68-
throw new Error(`Error running OSSF Scorecard for repository (${repo.full_name})`)
68+
throw new Error(`Error running analysis with OSSF Scorecard for repository (${repo.full_name}): ${stderr}`)
6969
}
7070
const data = JSON.parse(stdout)
7171
const end = new Date().getTime()

src/workflows/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ const upsertGithubRepositories = async (knex) => {
4040

4141
await Promise.all(organizations.map(async (org) => {
4242
debug(`Fetching repositories for org (${org.login})`)
43+
logger.info(`Fetching repositories for org (${org.login})`)
4344
const repoList = await github.fetchOrgReposListByLogin(org.login)
4445
debug(`Got ${repoList.length} repositories for org (${org.login})`)
4546
debug('Validating data')
4647
validateGithubListOrgRepos(repoList)
4748
debug(`Enriching all repositories for org (${org.login})`)
49+
logger.info(`Enriching all repositories for org (${org.login})`)
4850

4951
// Enrich and upsert each repository in parallel
5052
await Promise.all(repoList.map(async (repo) => {
@@ -58,6 +60,7 @@ const upsertGithubRepositories = async (knex) => {
5860
await upsertGithubRepository(mappedData, org.id)
5961
}))
6062
}))
63+
logger.info('GitHub repositories updated successfully')
6164
}
6265

6366
const runAllTheComplianceChecks = async (knex) => {
@@ -98,6 +101,7 @@ const upsertOSSFScorecardAnalysis = async (knex) => {
98101
await upsertOSSFScorecard({ ...mappedData, github_repository_id: repo.id })
99102
} catch (error) {
100103
logger.warn(`Error running OSSF Scorecard for repository (${repo.full_name}). Skipping...`)
104+
logger.warn(error.message)
101105
}
102106
}))
103107
}

0 commit comments

Comments
 (0)