Skip to content

Commit

Permalink
Add created and updated columns, and date output
Browse files Browse the repository at this point in the history
  • Loading branch information
domoscargin committed Dec 19, 2024
1 parent 9566e65 commit 8fc95a4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions build-filtered-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function filterDeps() {
const builtData = []

console.log('Analysis BEGIN')
for (const repo of rawDeps.all_public_dependent_repos.slice(0, 100)) {
for (const repo of rawDeps.all_public_dependent_repos.slice(0, 20)) {
const repoOwner = repo.owner
const repoName = repo.repo_name
let builtByGovernment = false
Expand All @@ -52,6 +52,8 @@ async function filterDeps() {
let lockfileType = null
let versionDoubt = false
let couldntAccess = false
let lastUpdated = null
let repoCreated = null

try {
console.log(`Analysing ${repo.name}...`)
Expand All @@ -75,12 +77,20 @@ async function filterDeps() {

console.log('Getting repo data...')

const repoMetaData = await octokit.rest.repos.get({
owner: repoOwner,
repo: repoName,
})

const firstCommit = await octokit.rest.repos.listCommits({
owner: repoOwner,
repo: repoName,
per_page: 1,
})

lastUpdated = repoMetaData.data.pushed_at
repoCreated = repoMetaData.data.created_at

const repoTree = await octokit.rest.git.getTree({
owner: repoOwner,
repo: repoName,
Expand All @@ -98,6 +108,7 @@ async function filterDeps() {
lockfileType = 'yarn.lock'
}

// TODO: account for multiple package files
const packageFile = await octokit.rest.repos.getContent({
owner: repoOwner,
repo: repoName,
Expand Down Expand Up @@ -230,12 +241,16 @@ async function filterDeps() {
builtByGovernment,
indirectDependency,
isPrototype,
lastUpdated,
repoCreated,
})

console.log(`Analysis of ${repo.name} complete`)

const currentDate = new Date().toISOString().split('T')[0]

await writeFileSync(
'data/filtered-data.json',
`data/${currentDate}-filtered-data.json`,
JSON.stringify(builtData, null, 2)
)
console.log('Data updated')
Expand Down

0 comments on commit 8fc95a4

Please sign in to comment.