fix(types): improve TypeScript strictness compatibility and modernize test exports
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"@git.zone/cli": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartstring",
|
||||||
|
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
|
||||||
|
"npmPackagename": "@push.rocks/smartstring",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"string manipulation",
|
||||||
|
"encode",
|
||||||
|
"decode",
|
||||||
|
"base64",
|
||||||
|
"indentation",
|
||||||
|
"normalization",
|
||||||
|
"regex",
|
||||||
|
"random string",
|
||||||
|
"cryptographic string",
|
||||||
|
"domain parsing",
|
||||||
|
"git repository parsing",
|
||||||
|
"docker environment parsing"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
},
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-05-01 - 4.1.1 - fix(types)
|
||||||
|
improve TypeScript strictness compatibility and modernize test exports
|
||||||
|
|
||||||
|
- enable stricter TypeScript compilation with explicit typings and safer null handling across base64, docker, domain, git, create, and indent modules
|
||||||
|
- update test files to export tap.start() for compatibility with the newer test tooling
|
||||||
|
- refresh build and test scripts and upgrade @git.zone tooling and Node type dependencies
|
||||||
|
- align project metadata and package contents with smartconfig-based release configuration
|
||||||
|
|
||||||
## 2025-09-12 - 4.1.0 - feat(core)
|
## 2025-09-12 - 4.1.0 - feat(core)
|
||||||
Introduce native implementations for Base64, random generation and normalization; remove runtime plugin dependencies; update tests, docs and package metadata
|
Introduce native implementations for Base64, random generation and normalization; remove runtime plugin dependencies; update tests, docs and package metadata
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014 Maurice Butler
|
Copyright (c) 2026 Task Venture Capital GmbH
|
||||||
Copyright (c) 2016 Lossless GmbH
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
+14
-12
@@ -1,14 +1,5 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@git.zone/cli": {
|
||||||
"npmGlobalTools": [],
|
|
||||||
"npmAccessLevel": "public"
|
|
||||||
},
|
|
||||||
"npmdocker": {
|
|
||||||
"baseImage": "hosttoday/ht-docker-node:npmci",
|
|
||||||
"command": "npmci node install stable && npmci npm install && npmci npm test",
|
|
||||||
"dockerSock": false
|
|
||||||
},
|
|
||||||
"gitzone": {
|
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
@@ -31,9 +22,20 @@
|
|||||||
"git repository parsing",
|
"git repository parsing",
|
||||||
"docker environment parsing"
|
"docker environment parsing"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsdoc": {
|
"@git.zone/tsdoc": {
|
||||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
},
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-8
@@ -7,8 +7,9 @@
|
|||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "tstest test/ --verbose",
|
||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "tsbuild --web",
|
||||||
|
"format": "gitzone format",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -29,17 +30,17 @@
|
|||||||
"git repository parsing",
|
"git repository parsing",
|
||||||
"docker environment parsing"
|
"docker environment parsing"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/push.rocks/smartstring/issues"
|
"url": "https://gitlab.com/push.rocks/smartstring/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/smartstring",
|
"homepage": "https://code.foss.global/push.rocks/smartstring",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.72",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@git.zone/tsrun": "^1.2.42",
|
"@git.zone/tsrun": "^2.0.3",
|
||||||
"@git.zone/tstest": "^2.3.7",
|
"@git.zone/tstest": "^3.6.3",
|
||||||
"@types/node": "^20.11.24"
|
"@types/node": "^25.6.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/isounique": "^1.0.5"
|
"@push.rocks/isounique": "^1.0.5"
|
||||||
@@ -53,11 +54,13 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
".smartconfig.json",
|
||||||
|
"license",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
],
|
],
|
||||||
"packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748"
|
"packageManager": "pnpm@10.28.2"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2443
-2167
File diff suppressed because it is too large
Load Diff
@@ -20,4 +20,4 @@ tap.test('should test for a valid base64 token', async () => {
|
|||||||
expect(result).toBeTrue();
|
expect(result).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ tap.test('expect create a Env Object', async () => {
|
|||||||
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
|
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -34,4 +34,4 @@ tap.test('should parse complex domains', async () => {
|
|||||||
console.log(testDomain2);
|
console.log(testDomain2);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ tap.test('expect return a .sshUrl', async () => {
|
|||||||
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
|
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ tap.test('expect indent', async () => {
|
|||||||
console.log(testString);
|
console.log(testString);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ tap.test('should normalize a string', async (toolsArg) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ tap.test('should state wether base64 string is valid', async () => {
|
|||||||
expect(smartstring.type.isBase64('hi there')).toBeFalse();
|
expect(smartstring.type.isBase64('hi there')).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartstring',
|
name: '@push.rocks/smartstring',
|
||||||
version: '4.1.0',
|
version: '4.1.1',
|
||||||
description: 'A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.'
|
description: 'A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ const universalBase64 = {
|
|||||||
*/
|
*/
|
||||||
export class Base64 {
|
export class Base64 {
|
||||||
private refString: string;
|
private refString: string;
|
||||||
constructor(inputStringArg, typeArg: TStringInputType) {
|
constructor(inputStringArg: string, typeArg: TStringInputType) {
|
||||||
switch (typeArg) {
|
switch (typeArg) {
|
||||||
case 'string': // easiest case
|
case 'string': // easiest case
|
||||||
this.refString = inputStringArg;
|
this.refString = inputStringArg;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ const getRandomInt = (min: number, max: number): number => {
|
|||||||
* ! - Special character
|
* ! - Special character
|
||||||
* * - Any character (A, a, 0, or !)
|
* * - Any character (A, a, 0, or !)
|
||||||
*/
|
*/
|
||||||
const customRandomatic = (pattern: string, length?: number, options?: any): string => {
|
const customRandomatic = (pattern: string, length?: number, options?: unknown): string => {
|
||||||
const charSets = {
|
const charSets: Record<string, string> = {
|
||||||
'A': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'A': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'a': 'abcdefghijklmnopqrstuvwxyz',
|
'a': 'abcdefghijklmnopqrstuvwxyz',
|
||||||
'0': '0123456789',
|
'0': '0123456789',
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ import * as plugins from './smartstring.plugins.js';
|
|||||||
* @param envArrayArg
|
* @param envArrayArg
|
||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
export const makeEnvObject = function (envArrayArg: string[]) {
|
export const makeEnvObject = function (envArrayArg: string[]): Record<string, string> {
|
||||||
let returnObject = {};
|
const returnObject: Record<string, string> = {};
|
||||||
let regexString = /(.*)=(.*)/;
|
const regexString = /(.*)=(.*)/;
|
||||||
if (typeof envArrayArg !== 'undefined') {
|
if (typeof envArrayArg !== 'undefined') {
|
||||||
for (let envKey in envArrayArg) {
|
for (const envString of envArrayArg) {
|
||||||
let regexMatches = regexString.exec(envArrayArg[envKey]);
|
const regexMatches = regexString.exec(envString);
|
||||||
returnObject[regexMatches[1]] = regexMatches[2];
|
if (regexMatches) {
|
||||||
|
returnObject[regexMatches[1]] = regexMatches[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnObject;
|
return returnObject;
|
||||||
|
|||||||
+25
-27
@@ -1,17 +1,17 @@
|
|||||||
export class Domain {
|
export class Domain {
|
||||||
public fullName: string;
|
public fullName: string;
|
||||||
public level1: string;
|
public level1?: string;
|
||||||
public level2: string;
|
public level2?: string;
|
||||||
public level3: string;
|
public level3?: string;
|
||||||
public level4: string;
|
public level4?: string;
|
||||||
public level5: string;
|
public level5?: string;
|
||||||
public protocol: string;
|
public protocol?: string;
|
||||||
public zoneName: string;
|
public zoneName: string;
|
||||||
// aliases
|
// aliases
|
||||||
public topLevel: string;
|
public topLevel?: string;
|
||||||
public domainName;
|
public domainName?: string;
|
||||||
public subDomain;
|
public subDomain?: string;
|
||||||
public port;
|
public port: string;
|
||||||
public nodeParsedUrl: URL;
|
public nodeParsedUrl: URL;
|
||||||
constructor(domainStringArg: string) {
|
constructor(domainStringArg: string) {
|
||||||
// lets do the node standard stuff first
|
// lets do the node standard stuff first
|
||||||
@@ -26,21 +26,16 @@ export class Domain {
|
|||||||
const regexMatches = this._domainRegex(
|
const regexMatches = this._domainRegex(
|
||||||
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
|
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
|
||||||
);
|
);
|
||||||
|
[this.level1, this.level2, this.level3, this.level4, this.level5] = regexMatches;
|
||||||
this.fullName = '';
|
this.fullName = '';
|
||||||
for (let i = 1; i <= 5; i++) {
|
for (const localMatch of regexMatches) {
|
||||||
if (regexMatches[i - 1]) {
|
if (this.fullName === '') {
|
||||||
const localMatch = regexMatches[i - 1];
|
this.fullName = localMatch;
|
||||||
this['level' + i.toString()] = localMatch;
|
|
||||||
if (this.fullName === '') {
|
|
||||||
this.fullName = localMatch;
|
|
||||||
} else {
|
|
||||||
this.fullName = localMatch + '.' + this.fullName;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this['level' + i.toString()] = undefined;
|
this.fullName = localMatch + '.' + this.fullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.zoneName = this.level2 + '.' + this.level1;
|
this.zoneName = [this.level2, this.level1].filter(Boolean).join('.');
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
this.topLevel = this.level1;
|
this.topLevel = this.level1;
|
||||||
@@ -51,19 +46,22 @@ export class Domain {
|
|||||||
// helper functions
|
// helper functions
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
private _domainRegex(stringArg: string) {
|
private _domainRegex(stringArg: string): string[] {
|
||||||
const regexString =
|
const regexString =
|
||||||
/([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
|
/([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
|
||||||
const regexMatches = regexString.exec(stringArg);
|
const regexMatches = regexString.exec(stringArg);
|
||||||
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
|
if (!regexMatches) {
|
||||||
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
return [];
|
||||||
const regexMatchesFiltered = regexMatches.filter(function (stringArg: string) {
|
}
|
||||||
|
const reversedMatches = [...regexMatches].reverse(); // make sure we build the domain from top level to subdomain
|
||||||
|
reversedMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
|
||||||
|
const regexMatchesFiltered = reversedMatches.filter(function (stringArg: string) {
|
||||||
return stringArg !== '';
|
return stringArg !== '';
|
||||||
});
|
});
|
||||||
return regexMatchesFiltered;
|
return regexMatchesFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _protocolRegex(stringArg: string) {
|
private _protocolRegex(stringArg: string): string | undefined {
|
||||||
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||||
const regexMatches = regexString.exec(stringArg);
|
const regexMatches = regexString.exec(stringArg);
|
||||||
if (regexMatches) {
|
if (regexMatches) {
|
||||||
@@ -73,7 +71,7 @@ export class Domain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _portRegex(stringArg: string) {
|
private _portRegex(stringArg: string): string | undefined {
|
||||||
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
const regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||||
const regexMatches = regexString.exec(stringArg);
|
const regexMatches = regexString.exec(stringArg);
|
||||||
if (regexMatches) {
|
if (regexMatches) {
|
||||||
|
|||||||
+11
-17
@@ -1,5 +1,3 @@
|
|||||||
import * as plugins from './smartstring.plugins.js';
|
|
||||||
|
|
||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ classes ------------------- *
|
* ------------------ classes ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
@@ -7,11 +5,14 @@ export class GitRepo {
|
|||||||
host: string;
|
host: string;
|
||||||
user: string;
|
user: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
accessToken: string;
|
accessToken?: string;
|
||||||
sshUrl: string;
|
sshUrl: string;
|
||||||
httpsUrl: string;
|
httpsUrl: string;
|
||||||
constructor(stringArg: string, tokenArg?: 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.host = regexMatches[1];
|
||||||
this.user = regexMatches[2];
|
this.user = regexMatches[2];
|
||||||
this.repo = regexMatches[3];
|
this.repo = regexMatches[3];
|
||||||
@@ -24,10 +25,10 @@ export class GitRepo {
|
|||||||
/* ---------------------------------------------- *
|
/* ---------------------------------------------- *
|
||||||
* ------------------ helpers ------------------- *
|
* ------------------ helpers ------------------- *
|
||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
const gitRegex = function (stringArg: string) {
|
const gitRegex = function (stringArg: string): RegExpExecArray | null {
|
||||||
const regexString =
|
const regexString =
|
||||||
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
|
/([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;
|
return regexMatches;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,23 +36,16 @@ const gitLink = function (
|
|||||||
hostArg: string,
|
hostArg: string,
|
||||||
userArg: string,
|
userArg: string,
|
||||||
repoArg: string,
|
repoArg: string,
|
||||||
tokenArg: string = '',
|
tokenArg = '',
|
||||||
linkTypeArg
|
linkTypeArg: 'https' | 'ssh'
|
||||||
): string {
|
): string {
|
||||||
let returnString;
|
|
||||||
if (tokenArg !== '') {
|
if (tokenArg !== '') {
|
||||||
tokenArg = tokenArg + '@';
|
tokenArg = tokenArg + '@';
|
||||||
}
|
}
|
||||||
switch (linkTypeArg) {
|
switch (linkTypeArg) {
|
||||||
case 'https':
|
case 'https':
|
||||||
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
|
return 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
|
||||||
break;
|
|
||||||
case 'ssh':
|
case 'ssh':
|
||||||
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
|
return 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.error('Link Type ' + linkTypeArg + ' not known');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return returnString;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,13 +69,14 @@ export const indentWithPrefix = (stringArg: string, prefixArg: string): string =
|
|||||||
export const normalize = (stringArg: string): string => {
|
export const normalize = (stringArg: string): string => {
|
||||||
let resultString: string;
|
let resultString: string;
|
||||||
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
|
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
|
||||||
let minCommonLeftOffset: number;
|
let minCommonLeftOffset: number | undefined;
|
||||||
|
|
||||||
const deIndentRegex = /^(\s*)/;
|
const deIndentRegex = /^(\s*)/;
|
||||||
const emptyLineRegex = /^(\s*)$/;
|
const emptyLineRegex = /^(\s*)$/;
|
||||||
|
|
||||||
for (let stringItem of splitStringArray) {
|
for (let stringItem of splitStringArray) {
|
||||||
let offsetString = deIndentRegex.exec(stringItem)[1];
|
const regexMatch = deIndentRegex.exec(stringItem);
|
||||||
|
let offsetString = regexMatch ? regexMatch[1] : '';
|
||||||
if (
|
if (
|
||||||
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset) &&
|
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset) &&
|
||||||
!emptyLineRegex.test(stringItem)
|
!emptyLineRegex.test(stringItem)
|
||||||
@@ -84,8 +85,9 @@ export const normalize = (stringArg: string): string => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let resultSplitStringArray = [];
|
let resultSplitStringArray = [];
|
||||||
|
const commonLeftOffset = minCommonLeftOffset || 0;
|
||||||
for (let stringItem of splitStringArray) {
|
for (let stringItem of splitStringArray) {
|
||||||
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
resultSplitStringArray.push(stringItem.substr(commonLeftOffset));
|
||||||
}
|
}
|
||||||
resultString = joinStringWithLineBreaks(resultSplitStringArray);
|
resultString = joinStringWithLineBreaks(resultSplitStringArray);
|
||||||
return resultString;
|
return resultString;
|
||||||
|
|||||||
+4
-4
@@ -5,10 +5,10 @@
|
|||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["dist_*/**/*.d.ts"]
|
||||||
"dist_*/**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user