Skip to content

Commit

Permalink
⚙️ Chore(packages): prepare packages to publish, fix and add features
Browse files Browse the repository at this point in the history
  • Loading branch information
INeedJobToStartWork committed Oct 29, 2024
1 parent abd73b3 commit 60ec97d
Show file tree
Hide file tree
Showing 26 changed files with 97 additions and 127 deletions.
9 changes: 0 additions & 9 deletions .changeset/pre.json

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

7 changes: 7 additions & 0 deletions packages/semver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @betternpm/semver

## 1.0.0

### Major Changes

- add `PATTERN_STRICT_SEMVER`, `PATTERN_LOOSE_SEMVER`, `PATTERN_RANGE_MODE` and fixed `d.ts` file.
18 changes: 16 additions & 2 deletions packages/semver/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![image](https://github.com/user-attachments/assets/985f8c86-4dad-400f-a5fa-16f57d0546d8)
![image](https://github.com/user-attachments/assets/a8138f88-869d-4fae-9b2a-0021e6957aaa)

<h1 align="center">Semver versioning handler</h1>
<p align="center">semver</p>
Expand Down Expand Up @@ -35,7 +35,8 @@
- [Types](#types-1)
- [TReleases](#treleases)
- [Variables](#variables-1)
- [RELEASE\_TYPES](#release_types)
- [PATTERNS](#patterns)
- [RELEASE_TYPES](#release_types)

## Install

Expand Down Expand Up @@ -404,6 +405,19 @@ type with every possible release (from variable [RELEASE_TYPES](###RELEASE_TYPES

## Variables

### PATTERNS

| Name | Description |
| --------------------- | ------------------------------------ |
| PATTERN_STRICT_SEMVER | RegEx Pattern used for strict semver |
| PATTERN_LOOSE_SEMVER | RegEx Pattern used for loose semver |
| PATTERN_RANGE_MODE | RegEx Pattern used for range semver |

**Links:** <br>
[[📄File]](https://github.com/INeedJobToStartWork/BetterNPM/tree/main/packages/semver/src/functions/parseSemVer.ts)

[Scroll to List of Contest](#-list-of-contest)

### RELEASE_TYPES

Array with every possible
Expand Down
1 change: 0 additions & 1 deletion packages/semver/config/tsuprc/tsup.prod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import config from "./tsup.base";
import { copy } from "esbuild-plugin-copy";
import noInternalExportsPlugin from "@esplugins/no-internal-exports";

import { defineConfig } from "tsup";

export default defineConfig({
Expand Down
4 changes: 2 additions & 2 deletions packages/semver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@betternpm/semver",
"version": "1.0.0-prerelease",
"version": "1.0.0",
"description": "Rewritten semver by @betternpm",
"keywords": [
"semver",
Expand Down Expand Up @@ -44,7 +44,7 @@
"oh-my-error": "2.0.0-prerelease.0"
},
"devDependencies": {
"@esplugins/no-internal-exports": "1.0.0-prerelease.1",
"@esplugins/no-internal-exports": "^1.0.0",
"@ineedj/eslintrc": "~1.2.2",
"@ineedj/prettierrc": "^2.0.0",
"@ineedj/tsconfig": "^1.0.0",
Expand Down
9 changes: 1 addition & 8 deletions packages/semver/src/classes/semVer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @EslintImports/no-deprecated */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import type { TOptionsSemVer } from "@/functions";
import {
compareSemver,
Expand Down Expand Up @@ -38,14 +36,9 @@ export default class SemVer {
? inputVersion
: inputVersion.version();

// SPLITTING
// const { patch, buildmetadata, major, minor, prerelease, version } = isSemVer
// ? inputVersion
// : parseSemVer(this.raw, { rangeMode: false });

const { patch, buildmetadata, major, minor, prerelease, version } = isSemVer
? inputVersion
: (parseSemVer(this.raw, mergedOptions) as ReturnType<typeof parseSemVer<{ rangeMode: false }>>); //TODO:fix
: parseSemVer(this.raw, mergedOptions); //TODO:fix
this.version = version;
this.major = major;
this.minor = minor;
Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/compare.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @EslintSonar/no-duplicate-string */
import { describe, expect, it } from "vitest";
import compareSemver, { compareBuild, compareMinorMajorPatch, comparePrerelease } from "./compare";
import { myErrorWrapper } from "oh-my-error";
Expand Down
11 changes: 6 additions & 5 deletions packages/semver/src/functions/compare.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable curly */
/* eslint-disable complexity */
import type { TOptionsSemVer } from "./parseSemVer";
import { OptionsSemVerDefaults, parseSemVer } from "./parseSemVer";
import { isX } from "@/utils";
Expand Down Expand Up @@ -57,12 +55,15 @@ export const compareMinorMajorPatch = (
const checkX = (val1: number | string, val2: number | string): boolean =>
Boolean((mergedOptions.rangeMode && isX(val1)) || isX(val2));

if (!checkX(version1.major, version2.major) && version1.major !== version2.major)
if (!checkX(version1.major, version2.major) && version1.major !== version2.major) {
return version1.major > version2.major ? 1 : -1;
if (!checkX(version1.minor, version2.minor) && version1.minor !== version2.minor)
}
if (!checkX(version1.minor, version2.minor) && version1.minor !== version2.minor) {
return version1.minor > version2.minor ? 1 : -1;
if (!checkX(version1.patch, version2.patch) && version1.patch !== version2.patch)
}
if (!checkX(version1.patch, version2.patch) && version1.patch !== version2.patch) {
return version1.patch > version2.patch ? 1 : -1;
}

return 0;
};
Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/difference.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @EslintSonar/no-duplicate-string */
import { describe, expect, test } from "vitest";
import { difference } from "./difference";

Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/increase.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @EslintSonar/no-duplicate-string */
// import { SemVer } from "@/classes";
// import type { TOptionsSemVer } from "./parseSemVer";
// import { OptionsSemVerDefaults } from "./parseSemVer";
Expand Down
10 changes: 5 additions & 5 deletions packages/semver/src/functions/increase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ const MYERRORLIST = {

/**
* Possible update types for version increment.
* @intelType //TODO: no-internal-exports plugin need update to fix it
* @dontexport //TODO: no-internal-exports plugin need update to fix it
*/
type UpdateType = "buildmetadata" | "major" | "minor" | "patch" | "premajor" | "preminor" | "prepatch" | "prerelease";

/**
* Possible return types for the increase function.
* @intelType
* @dontexport
*/
type ReturnTypes = "object" | "SemVer" | "string";

/** @intelType */
/** @dontexport */
type TTTTT = "premajor" | "preminor" | "prepatch" | "prerelease";

/** @intelType */
/** @dontexport */
// eslint-disable-next-line @typescript-eslint/ban-types
type TOptionsForPrerelease = TOptionsSemVer & { value?: "alpha" | "beta" | "rc" | (Object & string) };

/** @intelType */
/** @dontexport */
// eslint-disable-next-line @typescript-eslint/ban-types
type OptionsForBuild = TOptionsSemVer & { value?: "BUILD" | (Object & string) };

Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/minVersion.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @EslintSonar/no-duplicate-string */
import { describe, it, expect } from "vitest";
import minVersion from "./minVersion";

Expand Down
2 changes: 0 additions & 2 deletions packages/semver/src/functions/minVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import type { IparseRange, satisfies, TCondition } from "@/functions";
import { compareSemver, increase, parseRange, parseSemVer } from "@/functions";
import { isX } from "@/utils";
Expand Down
30 changes: 12 additions & 18 deletions packages/semver/src/functions/parseSemVer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// TODO: optimize regex?
/* eslint-disable @EslintImports/no-deprecated */
/* eslint-disable @EslintOptRegConf/optimize-regex */
/* eslint-disable curly */
/* eslint-disable complexity */
/* eslint-disable no-nested-ternary */
/* eslint-disable @EslintUnicorn/no-nested-ternary */
/* eslint-disable @EslintSecurity/detect-unsafe-regex */
import { SemVer } from "@/classes";
import type { TMyErrorList } from "oh-my-error";
Expand All @@ -15,19 +9,13 @@ import { versionPostValidator, versionPreValidator } from "./versionValidator";
//----------------------
// Global CONST
//----------------------
/**
* @internal
*/

export const PATTERN_STRICT_SEMVER =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/u;
/**
* @internal
*/

export const PATTERN_LOOSE_SEMVER =
/^v?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][\da-z-]*))*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?$/iu;
/**
* @internal
*/

export const PATTERN_RANGE_MODE =
/^v?(0|[1-9]\d*|x|X|\*)(?:\.(0|[1-9]\d*|x|X|\*))?(?:\.(0|[1-9]\d*|x|X|\*))?(?:-((?:0|[1-9]\d*|\d*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][\da-z-]*))*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?$/iu;

Expand Down Expand Up @@ -63,6 +51,7 @@ export const formatVersion = (version: Required<IparseRange> | Required<IparseSe
return `${base}${prerelease}${buildmetadata}`;
};

/** @dontexport */
export interface IparseSemVer {
buildmetadata?: Array<number | string>;
major?: number;
Expand All @@ -73,6 +62,7 @@ export interface IparseSemVer {
version?: () => string;
}

/** @dontexport */
export interface IparseRange extends Omit<IparseSemVer, "major" | "minor" | "patch"> {
major?: number | "*" | "X" | "x";
minor?: number | "*" | "X" | "x";
Expand All @@ -81,6 +71,7 @@ export interface IparseRange extends Omit<IparseSemVer, "major" | "minor" | "pat

/**
* Options for parsing a semantic version string or range.
* @dontexport
*/
export type TOptionsSemVer = {
/** Accept and parse versions like `v1.2.3` etc*/
Expand Down Expand Up @@ -126,15 +117,17 @@ export function parseSemVer<T extends TOptionsSemVer>(
inputVersion: Required<IparseRange> | Required<IparseSemVer> | SemVer | string,
options: T = OptionsSemVerDefaults as T
): T | boolean extends { rangeMode: false } ? Required<IparseSemVer> : Required<IparseRange> {
if (typeof inputVersion != "string" && inputVersion instanceof SemVer)
if (typeof inputVersion != "string" && inputVersion instanceof SemVer) {
return resultsFormat(inputVersion) as Required<IparseSemVer>;
}

const mergedOptions: Required<TOptionsSemVer> = { ...OptionsSemVerDefaults, ...options };
const version = typeof inputVersion === "object" ? formatVersion(inputVersion) : inputVersion;

// PRE VALIDATION
if (mergedOptions.validators == true || mergedOptions.validators == "Pre")
if (mergedOptions.validators == true || mergedOptions.validators == "Pre") {
versionPreValidator(version, { returnType: mergedOptions.returnType });
}

// PARSING
const versionTrimmed = version.trim();
Expand Down Expand Up @@ -165,8 +158,9 @@ export function parseSemVer<T extends TOptionsSemVer>(
: []
}) as typeof mergedOptions extends { rangeMode: false } ? Required<IparseRange> : Required<IparseSemVer>;

if (mergedOptions.validators == true || mergedOptions.validators == "Pre")
if (mergedOptions.validators == true || mergedOptions.validators == "Pre") {
versionPostValidator(result, { returnType: mergedOptions.returnType });
}

return result;
}
Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/satisfies.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @EslintSonar/no-duplicate-string */
import { describe, it, expect } from "vitest";
import satisfies from "./satisfies";
import { myErrorWrapper } from "oh-my-error";
Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/satisfies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable complexity */
import type { TOptionsSemVer } from "@/functions";
import { compareSemver, OptionsSemVerDefaults, parseSemVer } from "@/functions";

Expand Down
1 change: 0 additions & 1 deletion packages/semver/src/functions/simplifyRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable complexity */
import { satisfies } from "./satisfies";
import { compareSemver } from "./compare";
import { OptionsSemVerDefaults } from "./parseSemVer";
Expand Down
4 changes: 0 additions & 4 deletions packages/semver/src/functions/versionValidator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable complexity */
/* eslint-disable @EslintSonar/no-duplicate-string */
import { MAX_SAFE_BUILD_LENGTH, MAX_SAFE_INTEGER } from "@/internals/constants";
import type { TValidationList } from "@/utils";
import { isX, validator } from "@/utils";
Expand Down
6 changes: 6 additions & 0 deletions packages/validate-npm-package-name/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @myutilia/env

## 1.0.1

### Patch Changes

- change error messages

## 1.0.0

### Major Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import config from "./tsup.base";
import { copy } from "esbuild-plugin-copy";
import noInternalExports from "@esplugins/no-internal-exports";
import { defineConfig } from "tsup";

export default defineConfig({
Expand Down Expand Up @@ -30,7 +31,7 @@ export default defineConfig({
{ from: "./.npmrc", to: "./.npmrc" },
{ from: "./.npmignore", to: "./.npmignore" },
{ from: "./README.md", to: "./README.md" },
{ from: "./LICENSE", to: "./LICENSE" }
{ from: "./LICENSE", to: "./" }
]
})
]
Expand Down
7 changes: 4 additions & 3 deletions packages/validate-npm-package-name/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@betternpm/validate-npm-package-name",
"version": "1.0.0",
"version": "1.0.1",
"description": "NPMs utility module",
"keywords": [
"utils",
Expand Down Expand Up @@ -42,10 +42,11 @@
]
},
"dependencies": {
"oh-my-error": "1.1.1"
"oh-my-error": "^2.0.0-prerelease.0"
},
"devDependencies": {
"@ineedj/eslintrc": "~1.2.0",
"@esplugins/no-internal-exports": "^1.0.0",
"@ineedj/eslintrc": "~1.2.2",
"@ineedj/prettierrc": "^2.0.0",
"@ineedj/tsconfig": "^1.0.0",
"@types/eslint": "~8.56.12",
Expand Down
Loading

0 comments on commit 60ec97d

Please sign in to comment.