fix(types): improve TypeScript strictness compatibility and modernize test exports

This commit is contained in:
2026-05-01 11:28:39 +00:00
parent 0e0bd5cd6c
commit 94f994ee6c
21 changed files with 2582 additions and 2257 deletions
+11 -17
View File
@@ -1,5 +1,3 @@
import * as plugins from './smartstring.plugins.js';
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
@@ -7,11 +5,14 @@ export class GitRepo {
host: string;
user: string;
repo: string;
accessToken: string;
accessToken?: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string) {
let regexMatches = gitRegex(stringArg);
const regexMatches = gitRegex(stringArg);
if (!regexMatches) {
throw new Error(`Invalid git repository URL: ${stringArg}`);
}
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
@@ -24,10 +25,10 @@ export class GitRepo {
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
const gitRegex = function (stringArg: string) {
const gitRegex = function (stringArg: string): RegExpExecArray | null {
const regexString =
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg);
const regexMatches = regexString.exec(stringArg);
return regexMatches;
};
@@ -35,23 +36,16 @@ const gitLink = function (
hostArg: string,
userArg: string,
repoArg: string,
tokenArg: string = '',
linkTypeArg
tokenArg = '',
linkTypeArg: 'https' | 'ssh'
): string {
let returnString;
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case 'https':
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break;
return 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
case 'ssh':
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
break;
default:
console.error('Link Type ' + linkTypeArg + ' not known');
break;
return 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
}
return returnString;
};