fix(core): Refactor smartrequest usage, update dependency versions, and improve documentation and tests

This commit is contained in:
2025-08-08 12:17:25 +00:00
parent b6c13cc44d
commit 88e377c425
10 changed files with 5263 additions and 1393 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tspublish',
version: '1.10.0',
version: '1.10.1',
description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.'
}

View File

@@ -44,37 +44,42 @@ export class GiteaAssets {
branch?: string
): Promise<IRepoFile[]> {
try {
const response = await plugins.smartrequest.request(
this.baseUrl + `/repos/${owner}/${repo}/contents/${directory}`,
{
headers: this.headers,
method: 'GET',
queryParams: branch ? { ref: branch } : {},
}
)
if (!Array.isArray(response.body) && typeof response.body === 'object') {
response.body = [response.body];
} else if (Array.isArray(response.body)) {
for (const entry of response.body) {
const requestBuilder = plugins.smartrequest.SmartRequest.create()
.url(this.baseUrl + `/repos/${owner}/${repo}/contents/${directory}`)
.headers(this.headers);
if (branch) {
requestBuilder.query({ ref: branch });
}
const response = await requestBuilder.get();
let responseBody = await response.json();
if (!Array.isArray(responseBody) && typeof responseBody === 'object') {
responseBody = [responseBody];
} else if (Array.isArray(responseBody)) {
for (const entry of responseBody) {
if (entry.type === 'dir') {
continue;
} else if (entry.type === 'file') {
const response2 = await plugins.smartrequest.request(
this.baseUrl + `/repos/${owner}/${repo}/contents/${entry.path}`,
{
headers: this.headers,
method: 'GET',
queryParams: branch ? { ref: branch } : {},
}
);
entry.encoding = response2.body.encoding;
entry.content = response2.body.content;
const requestBuilder2 = plugins.smartrequest.SmartRequest.create()
.url(this.baseUrl + `/repos/${owner}/${repo}/contents/${entry.path}`)
.headers(this.headers);
if (branch) {
requestBuilder2.query({ ref: branch });
}
const response2 = await requestBuilder2.get();
const response2Body = await response2.json();
entry.encoding = response2Body.encoding;
entry.content = response2Body.content;
}
}
}
// lets map to the IRepoFile interface
response.body = response.body.map((entry: any) => {
responseBody = responseBody.map((entry: any) => {
return {
name: entry.name,
path: entry.path,
@@ -85,7 +90,7 @@ export class GiteaAssets {
};
});
return response.body;
return responseBody;
} catch (error) {
console.error('Error fetching repository files:', error);
throw error;