Skip to content

Commit

Permalink
Merge pull request #210 from projectsyn/fix/null-urls
Browse files Browse the repository at this point in the history
Do not crash when a package URL cannot be inferred
  • Loading branch information
HappyTetrahedron authored Aug 29, 2023
2 parents b3680eb + aa952cc commit b8e94c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/commodore/__fixtures__/1/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ parameters:
foo-test:
url: https://gitlab.com/projectsyn/component-foo-test.git
version: v2.2.0
bar-test:
version: v2.2.0
packages:
monitoring:
url: https://github.com/projectsyn/package-monitoring
Expand Down
28 changes: 18 additions & 10 deletions src/commodore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,23 @@ export async function extractPackageFile(
}

const githubBaseUrl = extraConfig.githubBaseUrl;
const deps = components.map((v: CommodoreDependency) => ({
depName: `${v.name} in ${fileName}`,
packageName: v.url.startsWith(githubBaseUrl)
? v.url.slice(githubBaseUrl.length).replace(/\.git$/, '')
: v.url,
currentValue: v.version,
datasource: v.url.startsWith(githubBaseUrl)
? githubRelease.GithubReleasesDatasource.id
: gitRef.GitRefsDatasource.id,
}));
const deps = components
.filter((dep: CommodoreDependency) => {
if (dep.url !== undefined) return true;
logger.warn(
`Could not infer package for dependency: ${dep.name} in ${fileName}. Skipping package.`
);
return false;
})
.map((v: CommodoreDependency) => ({
depName: `${v.name} in ${fileName}`,
packageName: v.url?.startsWith(githubBaseUrl)
? v.url.slice(githubBaseUrl.length).replace(/\.git$/, '')
: v.url,
currentValue: v.version,
datasource: v.url?.startsWith(githubBaseUrl)
? githubRelease.GithubReleasesDatasource.id
: gitRef.GitRefsDatasource.id,
}));
return { deps };
}

0 comments on commit b8e94c0

Please sign in to comment.