@archoleat/validate-font-file-name 1.0.10 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +25 -44
  2. package/index.d.ts +11 -6
  3. package/index.js +1 -1
  4. package/package.json +40 -45
package/README.md CHANGED
@@ -2,38 +2,28 @@
2
2
 
3
3
  ![NPM Version](https://img.shields.io/npm/v/%40archoleat%2Fvalidate-font-file-name)
4
4
  ![NPM Downloads](https://img.shields.io/npm/dm/%40archoleat%2Fvalidate-font-file-name)
5
+ ![ESM](https://img.shields.io/badge/ESM-fe0)
6
+ ![Provenance](https://img.shields.io/badge/Provenance-fo0)
5
7
  ![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/codeql.yaml?label=CodeQL)
6
8
  ![Specs](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/spec.yaml?label=Specs)
7
9
  ![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/commitlint.yaml?label=Commitlint)
8
10
  ![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/editorconfig.yaml?label=Editorconfig)
9
11
  ![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/prettier.yaml?label=Prettier)
10
12
  ![ESLint](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/eslint.yaml?label=ESLint)
11
- ![Markdown](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/markdown.yaml?label=Markdown)
12
- ![ESM Only](https://img.shields.io/badge/ESM-only-gray?labelColor=fe0)
13
+ ![Remark](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/remark.yaml?label=Remark)
13
14
 
14
15
  ## Table of Contents
15
16
 
16
- - [Installation](#installation)
17
- - [Usage](#usage)
18
- - [Naming Convention](#naming-convention)
19
- - [Contributing](#contributing)
20
- - [License](#license)
17
+ - [Installation](#installation)
18
+ - [Usage](#usage)
19
+ - [Naming Convention](#naming-convention)
20
+ - [Contributing](#contributing)
21
+ - [License](#license)
21
22
 
22
23
  ## Installation
23
24
 
24
25
  ```shell
25
- # pnpm
26
- pnpm i -D @archoleat/validate-font-file-name
27
- ```
28
-
29
- ```shell
30
- # npm
31
- npm i -D @archoleat/validate-font-file-name
32
- ```
33
-
34
- ```shell
35
- # yarn
36
- yarn add -D @archoleat/validate-font-file-name
26
+ bun i -D @archoleat/validate-font-file-name
37
27
  ```
38
28
 
39
29
  ## Usage
@@ -41,49 +31,40 @@ yarn add -D @archoleat/validate-font-file-name
41
31
  ```js
42
32
  import { validateFontFileName } from '@archoleat/validate-font-file-name';
43
33
 
44
- const validFontFileName = 'src/fonts/OpenSans-Regular.woff2';
45
- const invalidFontFileName = 'src/fonts/OpenSans.woff2';
46
-
47
- // returns: true
48
- console.log(await validateFontFileName(validFontFileName));
49
-
50
- // returns: 'OpenSans.woff2' doesn't match with '/(^[A-Z][a-z]+([A-Z][a-z]+)?)-(Thin|Hairline|ExtraLight|UltraLight|Light|Regular|Medium|SemiBold|DemiBold|Bold|ExtraBold|UltraBold|Black|Heavy|ExtraBlack|UltraBlack)\.(otf|ttf|woff|woff2)$/'.
51
- console.log(await validateFontFileName(invalidFontFileName));
52
- ```
53
-
54
- or
55
-
56
- ```js
57
- import { validateFontFileName } from '@archoleat/validate-font-file-name';
58
-
59
34
  const validFontFileName = 'OpenSans-Regular.woff2';
60
35
  const invalidFontFileName = 'OpenSans.woff2';
61
36
 
62
37
  // returns: true
63
- console.log(await validateFontFileName(validFontFileName));
38
+ console.log(await validateFontFileName({ file: validFontFileName }));
64
39
 
65
- // returns: 'OpenSans.woff2' doesn't match with '/(^[A-Z][a-z]+([A-Z][a-z]+)?)-(Thin|Hairline|ExtraLight|UltraLight|Light|Regular|Medium|SemiBold|DemiBold|Bold|ExtraBold|UltraBold|Black|Heavy|ExtraBlack|UltraBlack)\.(otf|ttf|woff|woff2)$/'.
66
- console.log(await validateFontFileName(invalidFontFileName));
40
+ // returns: {current time} [ERROR] 'OpenSans.woff2' doesn't match with '/(^[A-Z][a-z]+([A-Z][a-z]+)?)-(Thin|Hairline|ExtraLight|UltraLight|Light|Regular|Medium|SemiBold|DemiBold|Bold|ExtraBold|UltraBold|Black|Heavy|ExtraBlack|UltraBlack)\.(otf|ttf|woff|woff2)$/'.
41
+ console.log(await validateFontFileName({ file: invalidFontFileName }));
67
42
  ```
68
43
 
69
44
  ### Your Regex
70
45
 
71
- You can also specify your pattern:
46
+ You can also specify your regex:
72
47
 
73
48
  ```js
74
49
  import { validateFontFileName } from '@archoleat/validate-font-file-name';
75
50
 
76
51
  // You can also specify `new RegExp()` and a regular `string`
77
- const yourPattern = /OpenSans-regular/;
52
+ const yourRegex = /OpenSans-regular/;
78
53
 
79
54
  const validFontFileName = 'OpenSans-regular';
80
55
  const invalidFontFileName = 'OpenSans.woff2';
81
56
 
82
57
  // returns: true
83
- console.log(await validateFontFileName(validFontFileName, yourPattern));
84
-
85
- // returns: 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
86
- console.log(await validateFontFileName(invalidFontFileName, yourPattern));
58
+ console.log(await validateFontFileName({
59
+ file: validFontFileName,
60
+ regex: yourRegex,
61
+ }));
62
+
63
+ // returns: {current time} [ERROR] 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
64
+ console.log(await validateFontFileName({
65
+ file: invalidFontFileName,
66
+ regex: yourRegex,
67
+ }));
87
68
  ```
88
69
 
89
70
  ## Naming Convention
@@ -93,7 +74,7 @@ and separated by a **hyphen**.
93
74
 
94
75
  Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
95
76
 
96
- > `{FontFamily}-{FontWeight}.{ext}`
77
+ > `{FontFamily}-{FontWeight}.{extension}`
97
78
 
98
79
  ## Contributing
99
80
 
package/index.d.ts CHANGED
@@ -1,21 +1,26 @@
1
+ type Parameters = {
2
+ file: string;
3
+ regex?: string | RegExp;
4
+ };
5
+
1
6
  /**
2
7
  * The asynchronous function `validateFontFileName` validates
3
- * if a given font file name matches a specific pattern.
8
+ * if a given font file name matches a specific regex.
4
9
  *
5
10
  * @param {string} file - The `file` parameter in the `validateFontFileName`
6
11
  * function is a string that represents the file name of a font file that
7
12
  * you want to validate.
8
13
  *
9
- * @param {string | RegExp} pattern - The `pattern` parameter in the
14
+ * @param {string | RegExp} regex - The `regex` parameter in the
10
15
  * `validateFontFileName` function is used to provide a custom regular
11
- * expression pattern for validating the font file name. If a custom
12
- * regex pattern is not provided, the function uses a default pattern
16
+ * expression for validating the font file name. If a custom
17
+ * regex is not provided, the function uses a default regex
13
18
  * to validate the font file name.
14
19
  *
15
20
  * @returns The function `validateFontFileName` is returning a boolean value.
16
- * It returns `true` if the file name matches the specified pattern,
21
+ * It returns `true` if the file name matches the specified regex,
17
22
  * and `false` if it does not match.
18
23
  */
19
- declare const validateFontFileName: (file: string, pattern?: string | RegExp) => Promise<boolean>;
24
+ declare const validateFontFileName: (parameters: Parameters) => Promise<boolean>;
20
25
 
21
26
  export { validateFontFileName };
package/index.js CHANGED
@@ -1 +1 @@
1
- import{parse as N}from"node:path";import f from"chalk";const _=async(n,t="")=>{const o="[A-Z][a-z]",a=`^${o}+(${o}+)?`,r=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),E=["otf","ttf","woff","woff2"].join("|"),c=`(${a})`,s=`(${r})`,l=`(${E})$`,i=new RegExp(`${c}-${s}\\.${l}`),e=N(n).base,T=typeof t=="string"&&t!==""?new RegExp(t):t||i;return T.test(e)?!0:(console.error(f.red.bold(`'${e}' doesn't match with '${T}'.`)),!1)};export{_ as validateFontFileName};
1
+ import{parse as n}from"node:path";import{FONT_FILE_NAME_REGEX as a}from"@archoleat/reglib";import{error as i}from"@archoleat/notifier";const m=async s=>{const{file:o,regex:e=""}=s,t=n(o).base,r=typeof e=="string"&&e!==""?new RegExp(e):e||a;return r.test(t)?!0:(await i({message:`'${t}' doesn't match with '${r}'.`,messageLength:1/0}),!1)};export{m as validateFontFileName};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@archoleat/validate-font-file-name",
3
3
  "description": "Checking font file names for standardization",
4
- "version": "1.0.10",
4
+ "version": "1.1.1",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "email": "archoleat@gmail.com",
@@ -11,34 +11,34 @@
11
11
  "homepage": "https://github.com/archoleat/validate-font-file-name#readme",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/archoleat/validate-font-file-name.git"
14
+ "url": "https://github.com/archoleat/validate-font-file-name.git"
15
15
  },
16
16
  "bugs": {
17
17
  "url": "https://github.com/archoleat/validate-font-file-name/issues"
18
18
  },
19
19
  "keywords": [
20
+ "archoleat-font-file-name",
20
21
  "archoleat",
21
22
  "font-file-name-standard",
22
23
  "font-file-name",
23
24
  "naming",
25
+ "plugin",
24
26
  "standard",
25
27
  "validate-font-file-name",
26
28
  "validate-name",
27
29
  "validate",
28
30
  "validator"
29
31
  ],
30
- "packageManager": "pnpm@8.15.6",
32
+ "packageManager": "pnpm@9.7.0",
31
33
  "engines": {
32
34
  "node": ">=20.0.0",
33
- "npm": ">=10.0.0",
34
- "pnpm": ">=8.0.0"
35
- },
36
- "volta": {
37
- "node": "20.12.0",
38
- "pnpm": "8.15.6"
35
+ "pnpm": ">=9.0.0"
39
36
  },
40
37
  "type": "module",
41
38
  "types": "index.d.ts",
39
+ "imports": {
40
+ "#src": "./src/index.ts"
41
+ },
42
42
  "exports": {
43
43
  ".": "./index.js"
44
44
  },
@@ -48,56 +48,51 @@
48
48
  ],
49
49
  "scripts": {
50
50
  "init": "pnpm i && husky",
51
- "spec": "vitest",
52
- "spec:coverage": "vitest run --coverage",
53
- "build": "rollup -c",
54
- "release": "semantic-release",
55
- "lint:editorconfig": "editorconfig-checker",
56
- "lint:formatting": "prettier . --check",
57
- "lint:md": "remark . --quiet",
58
- "lint:ts": "eslint src/index.ts --fix",
59
- "prettify": "prettier . --write",
60
- "commit": "cz"
51
+ "build": "rollup -c rollup.config.ts --configPlugin typescript"
61
52
  },
62
53
  "dependencies": {
63
- "chalk": "^5.3.0"
54
+ "@archoleat/notifier": "^1.0.0",
55
+ "@archoleat/reglib": "^1.1.0"
64
56
  },
65
57
  "devDependencies": {
66
- "@archoleat/commitlint-define-config": "^1.0.6",
67
- "@archoleat/eslint-flat-compatibility": "^1.1.5",
68
- "@archoleat/semantic-release-define-config": "^1.1.3",
69
- "@commitlint/cli": "^19.2.1",
70
- "@commitlint/config-conventional": "^19.1.0",
58
+ "@archoleat/commitlint-define-config": "^1.0.10",
59
+ "@archoleat/eslint-flat-compatibility": "^1.1.7",
60
+ "@archoleat/prettier-define-config": "^1.0.1",
61
+ "@archoleat/semantic-release-define-config": "^1.1.14",
62
+ "@commitlint/cli": "^19.4.0",
63
+ "@commitlint/config-conventional": "^19.2.2",
64
+ "@commitlint/types": "^19.0.3",
71
65
  "@rollup/plugin-typescript": "^11.1.6",
72
66
  "@semantic-release/changelog": "^6.0.3",
73
67
  "@semantic-release/git": "^10.0.1",
74
- "@typescript-eslint/eslint-plugin": "^7.6.0",
75
- "@typescript-eslint/parser": "^7.6.0",
76
- "@vitest/coverage-v8": "^1.4.0",
77
- "conventional-changelog-conventionalcommits": "^7.0.2",
78
- "cz-conventional-changelog": "^3.3.0",
79
- "editorconfig-checker": "^5.1.5",
68
+ "@types/node": "^22.4.1",
69
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
70
+ "@typescript-eslint/parser": "^7.18.0",
71
+ "@vitest/coverage-v8": "^2.0.5",
72
+ "conventional-changelog-conventionalcommits": "^8.0.0",
73
+ "editorconfig-checker": "^5.1.8",
80
74
  "eslint": "^8.57.0",
81
75
  "eslint-config-airbnb-typescript": "^18.0.0",
82
76
  "eslint-config-prettier": "^9.1.0",
83
77
  "eslint-define-config": "^2.1.0",
84
78
  "eslint-import-resolver-typescript": "^3.6.1",
85
79
  "eslint-plugin-import": "^2.29.1",
86
- "eslint-plugin-unicorn": "^52.0.0",
87
- "globals": "^15.0.0",
88
- "husky": "^9.0.11",
89
- "lint-staged": "^15.2.2",
90
- "prettier": "^3.2.5",
80
+ "eslint-plugin-unicorn": "^55.0.0",
81
+ "git-pull-run": "^1.4.0",
82
+ "globals": "^15.9.0",
83
+ "husky": "^9.1.4",
84
+ "lint-staged": "^15.2.9",
85
+ "prettier": "^3.3.3",
91
86
  "remark": "15.0.1",
92
- "remark-cli": "^12.0.0",
93
- "remark-preset-lint-consistent": "^5.1.2",
94
- "remark-preset-lint-markdown-style-guide": "^5.1.3",
95
- "remark-preset-lint-recommended": "^6.1.3",
96
- "rollup": "^4.14.1",
97
- "rollup-plugin-dts": "^6.1.0",
87
+ "remark-cli": "^12.0.1",
88
+ "remark-preset-lint-consistent": "^6.0.0",
89
+ "remark-preset-lint-markdown-style-guide": "^6.0.0",
90
+ "remark-preset-lint-recommended": "^7.0.0",
91
+ "rollup": "^4.21.0",
92
+ "rollup-plugin-dts": "^6.1.1",
98
93
  "rollup-plugin-esbuild": "^6.1.1",
99
- "semantic-release": "^23.0.7",
100
- "typescript": "^5.4.4",
101
- "vitest": "^1.4.0"
94
+ "semantic-release": "^24.1.0",
95
+ "typescript": "^5.5.4",
96
+ "vitest": "^2.0.5"
102
97
  }
103
98
  }