@archoleat/validate-font-file-name 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -14,10 +14,16 @@
14
14
  ## Table of Contents
15
15
 
16
16
  - [Installation](#installation)
17
+
17
18
  - [Usage](#usage)
19
+ - [Your Regex](#your-regex)
20
+
18
21
  - [Naming Convention](#naming-convention)
22
+
19
23
  - [Troubleshooting](#troubleshooting)
24
+
20
25
  - [Contributing](#contributing)
26
+
21
27
  - [License](#license)
22
28
 
23
29
  ## Installation
@@ -45,11 +51,11 @@ import validateFontFileName from '@archoleat/validate-font-file-name';
45
51
  const validFontFileName = 'src/fonts/OpenSans-Regular.woff2';
46
52
  const invalidFontFileName = 'src/fonts/OpenSans.woff2';
47
53
 
48
- console.log(validateFontFileName(validFontFileName))
49
54
  // returns: true
55
+ console.log(validateFontFileName(validFontFileName))
50
56
 
57
+ // 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
58
  console.log(validateFontFileName(invalidFontFileName))
52
- // returns: 'OpenSans.woff2' doesn't match the '{FontFamily}-{FontWeight}.{ext}'.
53
59
  ```
54
60
 
55
61
  or
@@ -60,11 +66,31 @@ import validateFontFileName from '@archoleat/validate-font-file-name';
60
66
  const validFontFileName = 'OpenSans-Regular.woff2';
61
67
  const invalidFontFileName = 'OpenSans.woff2';
62
68
 
69
+ // returns: true
63
70
  console.log(validateFontFileName(validFontFileName))
71
+
72
+ // 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)$/'.
73
+ console.log(validateFontFileName(invalidFontFileName))
74
+ ```
75
+
76
+ ### Your Regex
77
+
78
+ You can also specify your pattern:
79
+
80
+ ```js
81
+ import validateFontFileName from '@archoleat/validate-font-file-name';
82
+
83
+ // You can also specify `new RegExp()` and a regular `string`
84
+ const yourPattern = /OpenSans-regular/;
85
+
86
+ const validFontFileName = 'OpenSans-regular';
87
+ const invalidFontFileName = 'OpenSans.woff2';
88
+
64
89
  // returns: true
90
+ console.log(validateFontFileName(validFontFileName))
65
91
 
92
+ // returns: 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
66
93
  console.log(validateFontFileName(invalidFontFileName))
67
- // returns: 'OpenSans.woff2' doesn't match the '{FontFamily}-{FontWeight}.{ext}'.
68
94
  ```
69
95
 
70
96
  ## Naming Convention
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.0",
4
+ "version": "1.0.1",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "email": "archoleat@gmail.com",
@@ -40,8 +40,7 @@
40
40
  "type": "module",
41
41
  "types": "index.d.ts",
42
42
  "exports": {
43
- ".": "./index.js",
44
- "./*": "./commitlint.config.ts"
43
+ ".": "./index.js"
45
44
  },
46
45
  "files": [
47
46
  "index.d.ts",
@@ -64,10 +63,10 @@
64
63
  "chalk": "^5.3.0"
65
64
  },
66
65
  "devDependencies": {
66
+ "@archoleat/commitlint-define-config": "^1.0.0",
67
67
  "@archoleat/semantic-release-define-config": "^1.1.0",
68
68
  "@commitlint/cli": "^18.6.1",
69
- "@commitlint/config-conventional": "^18.6.3",
70
- "@commitlint/types": "^18.6.1",
69
+ "@commitlint/config-conventional": "^19.1.0",
71
70
  "@rollup/plugin-typescript": "^11.1.6",
72
71
  "@semantic-release/changelog": "^6.0.3",
73
72
  "@semantic-release/git": "^10.0.1",
package/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * The function `validateFontFileName` checks if a given font
3
- * file name follows a specific naming convention.
4
- *
5
- * @param {string} file - The `validateFontFileName` function takes
6
- * a `file` parameter, which is expected to be a string representing
7
- * the file name of a font file.
8
- *
9
- * @returns The `validateFontFileName` function returns a boolean
10
- * value - `true` if the font file name matches the specified template
11
- * 'FontFamily-Fontweight.{otf|ttf|woff|woff2}', and `false` if it
12
- * doesn't match the template.
13
- */
14
- declare const validateFontFileName: (file: string) => Promise<boolean>;
15
-
16
- export { validateFontFileName as default };
package/index.js DELETED
@@ -1 +0,0 @@
1
- import{parse as i}from"node:path";import s from"chalk";const N=async e=>{const t="[A-Z][a-z]",a=`^${t}+(${t}+)?`,T=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),n=["otf","ttf","woff","woff2"].join("|"),r=`(${a})`,l=`(${T})`,E=`(${n})$`,c=new RegExp(`${r}-${l}\\.${E}`),o=i(e).base;return c.test(o)?!0:(console.error(s.red.bold(`'${o}' doesn't match the '{FontFamily}-{FontWeight}.{ext}'.`)),!1)};export{N as default};