Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
/ tsed-api Public archive
generated from tsedio/tsed-example-formio

Commit 4c27833

Browse files
committed
fix(npm): enhance repository owner extraction and add logging for GitHub stars
1 parent 0ad3652 commit 4c27833

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/server/src/domain/npm/NpmPackage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ export class NpmPackage {
139139
set category(type: NpmPackageCategory) {}
140140

141141
getRepositoryOwner() {
142-
if (this.repository?.startsWith("https://github.com/")) {
143-
const [owner, repo] = this.repository.replace("https://github.com/", "").split("/");
142+
if (this.repository?.match("github.com")) {
143+
const url = new URL(this.repository);
144+
const [, owner, repo] = url.pathname.replace(/.git$/, "").split("/");
144145
return {owner, repo};
145146
}
146147

packages/server/src/services/WarehouseService.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,27 @@ export class WarehouseService extends FormioRepository {
8989
const meta = pkg.getRepositoryOwner();
9090

9191
if (!meta) {
92+
this.$ctx?.logger.warn({
93+
event: "GITHUB_REPO_META_NOT_FOUND",
94+
pkg: pkg.name,
95+
repository: pkg.repository
96+
});
9297
return 0;
9398
}
9499

95100
try {
96101
const {stargazers_count} = await this.githubClient.getInfo(meta.owner, meta.repo);
97102

103+
this.$ctx?.logger.debug({
104+
event: "GITHUB_REPO_STARS",
105+
stargazers_count,
106+
owner: meta.owner,
107+
repo: meta.repo
108+
});
109+
98110
return stargazers_count;
99111
} catch (er) {
100-
this.$ctx.logger.error({
112+
this.$ctx?.logger.error({
101113
event: "GITHUB_REPO_INFO_ERROR",
102114
error: er,
103115
owner: meta.owner,

0 commit comments

Comments
 (0)