Skip to content

Commit

Permalink
Handle indirect dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
domoscargin committed Jan 6, 2025
1 parent 4f25cb2 commit 47fec86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions build-filtered-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,21 @@ export async function analyseRepo (repo) {
repoData.log('looks like an instance of the prototype kit.')
repoData.isPrototype = true
}

if (!repoData.checkDirectDependency(packageObjects)) {
repoData.log('govuk-frontend is not a direct dependency.')
repoData.log('searching for version in lockfile')
repoData.versionDoubt = true
const lockfileType = repoData.getLockfileType()
repoData.log(`using ${lockfileType}`)
repoData.lockfileFrontendVersion = await repoData.getVersionFromLockfile(lockfileType)
if (repoData.lockfileFrontendVersion) {
repoData.log(
`using GOV.UK Frontend version ${repoData.lockfileFrontendVersion}`
)
} else {
repoData.log('exact GOV.UK Frontend version could not be determined from lockfile.')
}
} else {
for (const versionData of repoData.frontendVersions) {
repoData.log(
Expand Down
4 changes: 2 additions & 2 deletions helpers/repo-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class RepoData {
* @throws {UnsupportedLockFileError} - If the lockfile is not supported
* @throws {RequestError} - If the request for the file data fails
*/
async getVersionFromLockfile (lockfileType, packagePath) {
async getVersionFromLockfile (lockfileType, packagePath = '') {
let lockfile
try {
lockfile = await this.getRepoFileContent(lockfileType)
Expand Down Expand Up @@ -280,7 +280,7 @@ export class RepoData {
if (packageData.dependencies?.['govuk-frontend']) {
deps.push({
parent: packageName,
version: packageData.dependencies['govuk-frontend'].version
version: packageData.dependencies['govuk-frontend']
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/repo-data.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('RepoData', () => {
packages: {
'parent-dependency': {
dependencies: {
'govuk-frontend': { version: '3.11.0' }
'govuk-frontend': '3.11.0'
}
}
}
Expand Down

0 comments on commit 47fec86

Please sign in to comment.