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

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 +18 -12
  2. package/index.d.ts +11 -6
  3. package/index.js +1 -1
  4. package/package.json +43 -36
package/README.md CHANGED
@@ -2,25 +2,31 @@
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
 
25
+ ```shell
26
+ # bun
27
+ bun i -D @archoleat/validate-font-file-name
28
+ ```
29
+
24
30
  ```shell
25
31
  # pnpm
26
32
  pnpm i -D @archoleat/validate-font-file-name
@@ -68,22 +74,22 @@ console.log(await validateFontFileName(invalidFontFileName));
68
74
 
69
75
  ### Your Regex
70
76
 
71
- You can also specify your pattern:
77
+ You can also specify your regex:
72
78
 
73
79
  ```js
74
80
  import { validateFontFileName } from '@archoleat/validate-font-file-name';
75
81
 
76
82
  // You can also specify `new RegExp()` and a regular `string`
77
- const yourPattern = /OpenSans-regular/;
83
+ const yourRegex = /OpenSans-regular/;
78
84
 
79
85
  const validFontFileName = 'OpenSans-regular';
80
86
  const invalidFontFileName = 'OpenSans.woff2';
81
87
 
82
88
  // returns: true
83
- console.log(await validateFontFileName(validFontFileName, yourPattern));
89
+ console.log(await validateFontFileName(validFontFileName, yourRegex));
84
90
 
85
91
  // returns: 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
86
- console.log(await validateFontFileName(invalidFontFileName, yourPattern));
92
+ console.log(await validateFontFileName(invalidFontFileName, yourRegex));
87
93
  ```
88
94
 
89
95
  ## Naming Convention
@@ -93,7 +99,7 @@ and separated by a **hyphen**.
93
99
 
94
100
  Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
95
101
 
96
- > `{FontFamily}-{FontWeight}.{ext}`
102
+ > `{FontFamily}-{FontWeight}.{extension}`
97
103
 
98
104
  ## Contributing
99
105
 
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.0",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "email": "archoleat@gmail.com",
@@ -17,28 +17,32 @@
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.4.0",
31
33
  "engines": {
32
34
  "node": ">=20.0.0",
33
- "npm": ">=10.0.0",
34
- "pnpm": ">=8.0.0"
35
+ "pnpm": ">=9.0.0"
35
36
  },
36
37
  "volta": {
37
- "node": "20.12.0",
38
- "pnpm": "8.15.6"
38
+ "node": "20.16.0",
39
+ "pnpm": "9.4.0"
39
40
  },
40
41
  "type": "module",
41
42
  "types": "index.d.ts",
43
+ "imports": {
44
+ "#src": "./src/index.ts"
45
+ },
42
46
  "exports": {
43
47
  ".": "./index.js"
44
48
  },
@@ -50,54 +54,57 @@
50
54
  "init": "pnpm i && husky",
51
55
  "spec": "vitest",
52
56
  "spec:coverage": "vitest run --coverage",
53
- "build": "rollup -c",
57
+ "build": "rollup -c rollup.config.ts --configPlugin typescript",
54
58
  "release": "semantic-release",
55
59
  "lint:editorconfig": "editorconfig-checker",
56
60
  "lint:formatting": "prettier . --check",
57
- "lint:md": "remark . --quiet",
61
+ "lint:md": "remark . --quiet --frail",
58
62
  "lint:ts": "eslint src/index.ts --fix",
59
- "prettify": "prettier . --write",
60
- "commit": "cz"
63
+ "prettify": "prettier . --write"
61
64
  },
62
65
  "dependencies": {
63
- "chalk": "^5.3.0"
66
+ "@archoleat/notifier": "^1.0.0",
67
+ "@archoleat/reglib": "^1.1.0"
64
68
  },
65
69
  "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",
70
+ "@archoleat/commitlint-define-config": "^1.0.9",
71
+ "@archoleat/eslint-flat-compatibility": "^1.1.6",
72
+ "@archoleat/prettier-define-config": "^1.0.1",
73
+ "@archoleat/semantic-release-define-config": "^1.1.14",
74
+ "@commitlint/cli": "^19.4.0",
75
+ "@commitlint/config-conventional": "^19.2.2",
76
+ "@commitlint/types": "^19.0.3",
71
77
  "@rollup/plugin-typescript": "^11.1.6",
72
78
  "@semantic-release/changelog": "^6.0.3",
73
79
  "@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",
80
+ "@types/node": "^22.3.0",
81
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
82
+ "@typescript-eslint/parser": "^7.18.0",
83
+ "@vitest/coverage-v8": "^2.0.5",
84
+ "conventional-changelog-conventionalcommits": "^8.0.0",
85
+ "editorconfig-checker": "^5.1.8",
80
86
  "eslint": "^8.57.0",
81
87
  "eslint-config-airbnb-typescript": "^18.0.0",
82
88
  "eslint-config-prettier": "^9.1.0",
83
89
  "eslint-define-config": "^2.1.0",
84
90
  "eslint-import-resolver-typescript": "^3.6.1",
85
91
  "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",
92
+ "eslint-plugin-unicorn": "^54.0.0",
93
+ "git-pull-run": "^1.4.0",
94
+ "globals": "^15.9.0",
95
+ "husky": "^9.1.4",
96
+ "lint-staged": "^15.2.9",
97
+ "prettier": "^3.3.3",
91
98
  "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",
99
+ "remark-cli": "^12.0.1",
100
+ "remark-preset-lint-consistent": "^6.0.0",
101
+ "remark-preset-lint-markdown-style-guide": "^6.0.0",
102
+ "remark-preset-lint-recommended": "^7.0.0",
103
+ "rollup": "^4.20.0",
104
+ "rollup-plugin-dts": "^6.1.1",
98
105
  "rollup-plugin-esbuild": "^6.1.1",
99
- "semantic-release": "^23.0.7",
100
- "typescript": "^5.4.4",
101
- "vitest": "^1.4.0"
106
+ "semantic-release": "^24.0.0",
107
+ "typescript": "^5.5.4",
108
+ "vitest": "^2.0.5"
102
109
  }
103
110
  }