Skip to content

Commit

Permalink
deps: bump proc-log from 3.0.0 to 4.2.0 (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed May 7, 2024
1 parent ad3b549 commit 1537ea4
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 53 deletions.
60 changes: 51 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions workspaces/data/bin/fetch-data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import timers from 'timers/promises'
import log from 'proc-log'
import pLog from 'proc-log'
import writeJson from '../lib/write-json.js'
import Api from '../lib/api/index.js'
import fetchData from '../lib/project-data.js'
Expand Down Expand Up @@ -74,25 +74,25 @@ const writeData = async ({ write, ...restConfig }) => {
const main = async (currentRun = 0) => {
currentRun++

log.info('='.repeat(80))
log.info('='.repeat(80))
log.info(`Starting: run number ${currentRun} at ${new Date().toISOString()}`)
log.info('='.repeat(80))
log.info('='.repeat(80))
pLog.log.info('='.repeat(80))
pLog.log.info('='.repeat(80))
pLog.log.info(`Starting: run number ${currentRun} at ${new Date().toISOString()}`)
pLog.log.info('='.repeat(80))
pLog.log.info('='.repeat(80))

try {
return await writeData(config)
} catch (err) {
log.error(err)
log.error('status', err.status)
pLog.log.error(err)
pLog.log.error('status', err.status)

if (err.status === 403 && currentRun <= 5) {
const retryDelay = config.delay ? (currentRun + 1) * config.delay * 60 * 10 : 0
log.warn('='.repeat(80))
log.warn('='.repeat(80))
log.warn(`Retrying: run number ${currentRun} fetch-data script in ${retryDelay}ms`)
log.warn('='.repeat(80))
log.warn('='.repeat(80))
pLog.log.warn('='.repeat(80))
pLog.log.warn('='.repeat(80))
pLog.log.warn(`Retrying: run number ${currentRun} fetch-data script in ${retryDelay}ms`)
pLog.log.warn('='.repeat(80))
pLog.log.warn('='.repeat(80))
return timers.setTimeout(retryDelay).then(() => main(currentRun))
}

Expand Down
8 changes: 4 additions & 4 deletions workspaces/data/bin/fetch-maintained.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import log from 'proc-log'
import pLog from 'proc-log'
import Api from '../lib/api/index.js'
import logger from '../lib/logger.js'
import writeJson from '../lib/write-json.js'
Expand Down Expand Up @@ -33,7 +33,7 @@ const exec = async ({ write, repoQuery, repoFilter }) => {
const allProjects = await api.searchReposWithManifests(repoQuery)

const maintainedProjects = allProjects.filter((project) => {
const logReason = (reason, include) => log.info(
const logReason = (reason, include) => pLog.log.info(
'fetch:maintained',
`${include ? '' : 'not'} including ${projectId(project)} due to: ${reason}`.trim()
)
Expand Down Expand Up @@ -99,7 +99,7 @@ const exec = async ({ write, repoQuery, repoFilter }) => {

maintained.sort((a, b) => sortKey(a).localeCompare(sortKey(b)))

log.info('fetch:maintained', `Found ${maintained.length} maintained projects`)
pLog.log.info('fetch:maintained', `Found ${maintained.length} maintained projects`)

if (!write) {
return JSON.stringify(maintained, null, 2)
Expand All @@ -119,7 +119,7 @@ exec(config)
return metadata.save({ status: 'success', update: res.update })
})
.catch(async (err) => {
log.error(err)
pLog.log.error(err)
await metadata.save({ status: 'error' })
throw err
})
4 changes: 2 additions & 2 deletions workspaces/data/bin/migrate-data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import fs from 'fs/promises'
import log from 'proc-log'
import pLog from 'proc-log'
import logger from '../lib/logger.js'
import getAllData from '../lib/all-data.js'
import wwwPaths from 'www'
Expand Down Expand Up @@ -59,6 +59,6 @@ main({
})
.then(console.log)
.catch(err => {
log.error(err)
pLog.log.error(err)
process.exitCode = 1
})
4 changes: 2 additions & 2 deletions workspaces/data/lib/api/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log from 'proc-log'
import pLog from 'proc-log'
import timers from 'timers/promises'

// A memory cache for expensive requests like check-runs
Expand All @@ -21,7 +21,7 @@ const cacheMethod = (fn, { delay } = {}) => {
const key = cacheKey(args)

if (CACHE.get(fn).has(key)) {
log.info('cache', 'returning', fn.name, key)
pLog.log.info('cache', 'returning', fn.name, key)
return CACHE.get(fn).get(key)
}

Expand Down
22 changes: 11 additions & 11 deletions workspaces/data/lib/api/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path'
import { graphql as Graphql } from '@octokit/graphql'
import { glob } from 'glob'
import lodash from 'lodash'
import log from 'proc-log'
import pLog from 'proc-log'
import packageApi from './package.js'

const { merge, get } = lodash
Expand All @@ -27,12 +27,12 @@ export default ({ auth }) => {
nodes.push(...res.nodes)

if (res.pageInfo.hasNextPage) {
log.verbose('graphql:paginate',
pLog.log.verbose('graphql:paginate',
`nodes: ${res.nodes.length}, cursor:${res.pageInfo.endCursor}`)
return paginatedQuery({ pageInfo: res.pageInfo, nodes })
}

log.verbose('graphql:paginate', `total: ${nodes.length}`)
pLog.log.verbose('graphql:paginate', `total: ${nodes.length}`)

return nodes
}
Expand All @@ -41,7 +41,7 @@ export default ({ auth }) => {
}

const getDiscussions = async (owner, name, query = '') => {
log.verbose(`graphql:discussions`, `${owner}/${name} ${query}`)
pLog.log.verbose(`graphql:discussions`, `${owner}/${name} ${query}`)

return paginateQuery(
`query ($owner: String!, $name: String!, $first: Int!, $after: String) {
Expand All @@ -66,7 +66,7 @@ export default ({ auth }) => {
* @returns {Promise<string[]>}
*/
const getSubTrees = async (owner, name, paths) => {
log.verbose(`graphql:subTrees`, `${owner}/${name}/{${paths.join(',')}}`)
pLog.log.verbose(`graphql:subTrees`, `${owner}/${name}/{${paths.join(',')}}`)

const { repository } = await GRAPHQL(
`query ($owner: String!, $name: String!) {
Expand Down Expand Up @@ -100,7 +100,7 @@ export default ({ auth }) => {
const isArray = Array.isArray(pathsOrPath)
const paths = isArray ? pathsOrPath : [pathsOrPath]

log.verbose(`graphql:pkg`, `${owner}/${name}/{${paths.join(',')}}`)
pLog.log.verbose(`graphql:pkg`, `${owner}/${name}/{${paths.join(',')}}`)

const { repository } = await GRAPHQL(
`query ($owner: String!, $name: String!) {
Expand All @@ -125,7 +125,7 @@ export default ({ auth }) => {
* @returns {Promise<({ repo: Record<string, any>, pkg: Record<string, any> })[]>}
*/
const getWorkspaces = async (owner, name, workspaces) => {
log.verbose(`graphql:workspaces`, `${owner}/${name}`)
pLog.log.verbose(`graphql:workspaces`, `${owner}/${name}`)

if (!Array.isArray(workspaces)) {
return []
Expand All @@ -152,7 +152,7 @@ export default ({ auth }) => {
wsDirs.push(...await getSubTrees(owner, name, validWsGlobs))
}

log.verbose(
pLog.log.verbose(
'graphql:workspaces',
`Looking for workspaces in ${owner}/${name} ${wsDirs.length} dirs`
)
Expand All @@ -170,7 +170,7 @@ export default ({ auth }) => {
* })[]>}
*/
const searchRepos = async (searchQuery) => {
log.verbose('graphql:search', searchQuery)
pLog.log.verbose('graphql:search', searchQuery)

const nodes = await paginateQuery(
`query ($searchQuery: String!, $first: Int!, $after: String) {
Expand Down Expand Up @@ -226,7 +226,7 @@ export default ({ auth }) => {
* })[]>}
*/
const searchReposWithWorkspaces = async (searchQuery) => {
log.verbose('graphql:searchWithWorkspaces', searchQuery)
pLog.log.verbose('graphql:searchWithWorkspaces', searchQuery)

const allRepos = await searchRepos(searchQuery)

Expand All @@ -246,7 +246,7 @@ export default ({ auth }) => {
* })[]>}
*/
const searchReposWithManifests = async (searchQuery) => {
log.verbose('graphql:searchWithManifests', searchQuery)
pLog.log.verbose('graphql:searchWithManifests', searchQuery)

const allRepos = await searchReposWithWorkspaces(searchQuery)

Expand Down
8 changes: 4 additions & 4 deletions workspaces/data/lib/api/package.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pacote from 'pacote'
import log from 'proc-log'
import pLog from 'proc-log'

export default {
manifest: (spec, opt) => {
log.verbose(`api:package:manifest`, spec)
pLog.log.verbose(`api:package:manifest`, spec)
return pacote.manifest(spec, opt).catch(() => null)
},
packument: (spec, opt) => {
log.verbose(`api:package:packument`, spec)
pLog.log.verbose(`api:package:packument`, spec)
return pacote.packument(spec, opt).catch(() => null)
},
downloads: (name) => {
log.verbose(`api:package:downloads`, name)
pLog.log.verbose(`api:package:downloads`, name)
return fetch(`https://api.npmjs.org/downloads/point/last-month/${name}`)
.then((res) => res.ok ? res.json() : null)
.catch(() => null)
Expand Down
14 changes: 7 additions & 7 deletions workspaces/data/lib/api/rest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Octokit } from '@octokit/rest'
import { retry } from '@octokit/plugin-retry'
import { throttling } from '@octokit/plugin-throttling'
import log from 'proc-log'
import pLog from 'proc-log'
import lodash from 'lodash'
import config from '../config.js'

Expand All @@ -10,7 +10,7 @@ const { groupBy, orderBy } = lodash
export default ({ auth }) => {
const REST = new (Octokit.plugin(retry, throttling))({
auth,
log,
log: pLog,
retry: {
doNotRetry: [404, 422],
},
Expand Down Expand Up @@ -43,12 +43,12 @@ export default ({ auth }) => {
})

const getRepo = (owner, repo) => {
log.verbose(`rest:repo:get`, `${owner}/${repo}`)
pLog.log.verbose(`rest:repo:get`, `${owner}/${repo}`)
return REST.repos.get({ owner, repo }).then(d => d.data)
}

const getCommit = async (owner, name, p) => {
log.verbose(`rest:repo:commit`, `${owner}/${name}${p ? `/${p}` : ''}`)
pLog.log.verbose(`rest:repo:commit`, `${owner}/${name}${p ? `/${p}` : ''}`)

return REST.repos.listCommits({
owner,
Expand All @@ -59,7 +59,7 @@ export default ({ auth }) => {
}

const getStatus = async (owner, name, ref) => {
log.verbose(`rest:repo:status`, `${owner}/${name}#${ref}`)
pLog.log.verbose(`rest:repo:status`, `${owner}/${name}#${ref}`)

const allCheckRuns = await REST.paginate(REST.checks.listForRef, {
owner,
Expand All @@ -85,7 +85,7 @@ export default ({ auth }) => {
return acc
}, [])

log.verbose(`rest:repo:status:names`, checkRuns.map(c => c.name).join('\n'))
pLog.log.verbose(`rest:repo:status:names`, checkRuns.map(c => c.name).join('\n'))

const failures = ['action_required', 'cancelled', 'failure', 'stale', 'timed_out', null]
const statuses = { neutral: false, success: false, skipped: false }
Expand All @@ -109,7 +109,7 @@ export default ({ auth }) => {
}

const getAllIssuesAndPullRequests = (owner, name, query = '') => {
log.verbose('rest:issues:getAll', `${owner}/${name}`)
pLog.log.verbose('rest:issues:getAll', `${owner}/${name}`)

return REST.paginate(REST.search.issuesAndPullRequests, {
q: `repo:${owner}/${name}+${query}`,
Expand Down
2 changes: 1 addition & 1 deletion workspaces/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"glob": "^10.3.4",
"lodash": "^4.17.21",
"pacote": "^18.0.3",
"proc-log": "^3.0.0",
"proc-log": "^4.2.0",
"semver": "^7.3.8",
"www": "^1.0.0"
},
Expand Down

0 comments on commit 1537ea4

Please sign in to comment.