-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actively used during development migrated from Github GraphQL to REST API removed user context, only works for orgs!
- Loading branch information
1 parent
55e8ab7
commit 17e68e7
Showing
13 changed files
with
3,050 additions
and
2,901 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const utils = require('../../logic/utils') | ||
|
||
function packageHandler (eventObject) { | ||
utils.flushCache() | ||
} | ||
|
||
module.exports = { | ||
packageHandler | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict' | ||
|
||
const { Octokit } = require('@octokit/core') | ||
const utils = require('./utils') | ||
const config = require('../../package.json').config | ||
|
||
async function getOrgPackageData (scope, token, host) { | ||
// This is the object all the data is added to and cached in memory once | ||
let resultObject = { | ||
all: {}, | ||
packages: {} | ||
} | ||
|
||
// Set-up octokit with PAT | ||
const octokit = new Octokit({ auth: token }) | ||
|
||
// Get all org packages | ||
const packages = await octokit.request('GET /orgs/{org}/packages', { | ||
org: scope, | ||
package_type: 'npm', | ||
per_page: 100 | ||
}) | ||
|
||
// Create all parallel requests | ||
const promises = packages.data.map(element => { | ||
return getPackage(scope, element.name, token, host, resultObject) | ||
}) | ||
|
||
// Run all parallel requests | ||
await Promise.all(promises) | ||
|
||
// Save the data in memory | ||
utils.cachePackageData(token, resultObject) | ||
|
||
// Return the data from memory | ||
return utils.getCachedLatestVersions(token) | ||
} | ||
|
||
async function getPackage (scope, packageName, token, host, resultObject) { | ||
// Run the async request | ||
const packageData = await utils.request(`${config.registry}/@${scope}/${packageName}`, token, host) | ||
|
||
// Append to the result object | ||
resultObject.all[`${packageName}`] = packageData['dist-tags'].latest | ||
resultObject.packages[`${packageName}`] = packageData | ||
return packageData | ||
} | ||
|
||
module.exports = { | ||
getOrgPackageData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.