feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -65,11 +65,7 @@ const extractCommithashByDomain = {
return;
}
if (!type) {
commithash = hash;
} else {
commithash = "#" + commithash;
}
commithash = !type ? hash : `#${commithash}`;
if (project && project.endsWith(".git")) {
project = project.slice(0, -4);
@@ -155,7 +151,6 @@ const extractCommithashByDomain = {
/**
* extract commit hash from parsed url
*
* @inner
* @param {URL} urlParsed parsed url
* @returns {string} commithash
@@ -167,7 +162,7 @@ function getCommithash(urlParsed) {
try {
hash = decodeURIComponent(hash);
// eslint-disable-next-line no-empty
} catch (e) {}
} catch (_err) {}
if (
extractCommithashByDomain[
@@ -186,7 +181,6 @@ function getCommithash(urlParsed) {
/**
* make url right for URL parse
*
* @inner
* @param {string} gitUrl git url
* @returns {string} fixed url
@@ -199,7 +193,6 @@ function correctUrl(gitUrl) {
/**
* make url protocol right for URL parse
*
* @inner
* @param {string} gitUrl git url
* @returns {string} fixed url
@@ -220,7 +213,6 @@ function correctProtocol(gitUrl) {
/**
* extract git dep version from hash
*
* @inner
* @param {string} hash hash
* @returns {string} git dep version
@@ -233,7 +225,6 @@ function getVersionFromHash(hash) {
/**
* if string can be decoded
*
* @inner
* @param {string} str str to be checked
* @returns {boolean} if can be decoded
@@ -241,7 +232,7 @@ function getVersionFromHash(hash) {
function canBeDecoded(str) {
try {
decodeURIComponent(str);
} catch (e) {
} catch (_err) {
return false;
}
@@ -250,19 +241,16 @@ function canBeDecoded(str) {
/**
* get right dep version from git url
*
* @inner
* @param {string} gitUrl git url
* @returns {string} dep version
*/
function getGitUrlVersion(gitUrl) {
let oriGitUrl = gitUrl;
const oriGitUrl = gitUrl;
// github extreme shorthand
if (RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)) {
gitUrl = "github:" + gitUrl;
} else {
gitUrl = correctProtocol(gitUrl);
}
gitUrl = RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)
? `github:${gitUrl}`
: correctProtocol(gitUrl);
gitUrl = correctUrl(gitUrl);
@@ -270,7 +258,7 @@ function getGitUrlVersion(gitUrl) {
try {
parsed = new URL(gitUrl);
// eslint-disable-next-line no-empty
} catch (e) {}
} catch (_err) {}
if (!parsed) {
return "";
@@ -312,7 +300,7 @@ function isRequiredVersion(str) {
return VERSION_PATTERN_REGEXP.test(str);
}
exports.isRequiredVersion = isRequiredVersion;
module.exports.isRequiredVersion = isRequiredVersion;
/**
* @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies
@@ -330,14 +318,15 @@ function normalizeVersion(versionDesc) {
return getGitUrlVersion(versionDesc.toLowerCase());
}
exports.normalizeVersion = normalizeVersion;
module.exports.normalizeVersion = normalizeVersion;
/** @typedef {{ data: JsonObject, path: string }} DescriptionFile */
/**
*
* @param {InputFileSystem} fs file system
* @param {string} directory directory to start looking into
* @param {string[]} descriptionFiles possible description filenames
* @param {function((Error | null)=, {data: object, path: string}=): void} callback callback
* @param {function((Error | null)=, DescriptionFile=): void} callback callback
*/
const getDescriptionFile = (fs, directory, descriptionFiles, callback) => {
let i = 0;
@@ -371,10 +360,9 @@ const getDescriptionFile = (fs, directory, descriptionFiles, callback) => {
};
tryLoadCurrent();
};
exports.getDescriptionFile = getDescriptionFile;
module.exports.getDescriptionFile = getDescriptionFile;
/**
*
* @param {JsonObject} data description file data i.e.: package.json
* @param {string} packageName name of the dependency
* @returns {string | undefined} normalized version
@@ -402,5 +390,5 @@ const getRequiredVersionFromDescriptionFile = (data, packageName) => {
}
}
};
exports.getRequiredVersionFromDescriptionFile =
module.exports.getRequiredVersionFromDescriptionFile =
getRequiredVersionFromDescriptionFile;