Skip to content

Commit

Permalink
feat: provide more feedback to the users while running CLI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon committed Dec 17, 2024
1 parent c19e483 commit 3e40151
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cli/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function runCheckCommand (knex, options = {}) {

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

module.exports = {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { stringToArray } = require('@ulisesgascon/string-to-array')
const isSlug = require('validator/lib/isSlug.js')
const debug = require('debug')('cli')
const { getConfig } = require('../config')
const { validateGithubUrl } = require('../utils')
const { validateGithubUrl, logger } = require('../utils')
const { initializeStore } = require('../store')

const { projectCategories } = getConfig()
Expand Down Expand Up @@ -102,6 +102,7 @@ async function runAddProjectCommand (knex, options = {}) {
})))

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

return answers
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const performScorecardAnalysis = async (repo) => {
const start = new Date().getTime()
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`)
if (stderr) {
throw new Error(`Error running OSSF Scorecard for repository (${repo.full_name})`)
throw new Error(`Error running analysis with OSSF Scorecard for repository (${repo.full_name}): ${stderr}`)
}
const data = JSON.parse(stdout)
const end = new Date().getTime()
Expand Down
4 changes: 4 additions & 0 deletions src/workflows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ const upsertGithubRepositories = async (knex) => {

await Promise.all(organizations.map(async (org) => {
debug(`Fetching repositories for org (${org.login})`)
logger.info(`Fetching repositories for org (${org.login})`)
const repoList = await github.fetchOrgReposListByLogin(org.login)
debug(`Got ${repoList.length} repositories for org (${org.login})`)
debug('Validating data')
validateGithubListOrgRepos(repoList)
debug(`Enriching all repositories for org (${org.login})`)
logger.info(`Enriching all repositories for org (${org.login})`)

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

const runAllTheComplianceChecks = async (knex) => {
Expand Down Expand Up @@ -98,6 +101,7 @@ const upsertOSSFScorecardAnalysis = async (knex) => {
await upsertOSSFScorecard({ ...mappedData, github_repository_id: repo.id })
} catch (error) {
logger.warn(`Error running OSSF Scorecard for repository (${repo.full_name}). Skipping...`)
logger.warn(error.message)
}
}))
}
Expand Down

0 comments on commit 3e40151

Please sign in to comment.