@archoleat/validate-font-file-name 1.0.1 → 1.0.5

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 +9 -32
  2. package/index.d.ts +21 -0
  3. package/index.js +1 -0
  4. package/package.json +10 -10
package/README.md CHANGED
@@ -20,8 +20,6 @@
20
20
 
21
21
  - [Naming Convention](#naming-convention)
22
22
 
23
- - [Troubleshooting](#troubleshooting)
24
-
25
23
  - [Contributing](#contributing)
26
24
 
27
25
  - [License](#license)
@@ -46,31 +44,31 @@ yarn add -D @archoleat/validate-font-file-name
46
44
  ## Usage
47
45
 
48
46
  ```js
49
- import validateFontFileName from '@archoleat/validate-font-file-name';
47
+ import { validateFontFileName } from '@archoleat/validate-font-file-name';
50
48
 
51
49
  const validFontFileName = 'src/fonts/OpenSans-Regular.woff2';
52
50
  const invalidFontFileName = 'src/fonts/OpenSans.woff2';
53
51
 
54
52
  // returns: true
55
- console.log(validateFontFileName(validFontFileName))
53
+ console.log(await validateFontFileName(validFontFileName));
56
54
 
57
55
  // 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)$/'.
58
- console.log(validateFontFileName(invalidFontFileName))
56
+ console.log(await validateFontFileName(invalidFontFileName));
59
57
  ```
60
58
 
61
59
  or
62
60
 
63
61
  ```js
64
- import validateFontFileName from '@archoleat/validate-font-file-name';
62
+ import { validateFontFileName } from '@archoleat/validate-font-file-name';
65
63
 
66
64
  const validFontFileName = 'OpenSans-Regular.woff2';
67
65
  const invalidFontFileName = 'OpenSans.woff2';
68
66
 
69
67
  // returns: true
70
- console.log(validateFontFileName(validFontFileName))
68
+ console.log(await validateFontFileName(validFontFileName));
71
69
 
72
70
  // 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))
71
+ console.log(await validateFontFileName(invalidFontFileName));
74
72
  ```
75
73
 
76
74
  ### Your Regex
@@ -78,7 +76,7 @@ console.log(validateFontFileName(invalidFontFileName))
78
76
  You can also specify your pattern:
79
77
 
80
78
  ```js
81
- import validateFontFileName from '@archoleat/validate-font-file-name';
79
+ import { validateFontFileName } from '@archoleat/validate-font-file-name';
82
80
 
83
81
  // You can also specify `new RegExp()` and a regular `string`
84
82
  const yourPattern = /OpenSans-regular/;
@@ -87,10 +85,10 @@ const validFontFileName = 'OpenSans-regular';
87
85
  const invalidFontFileName = 'OpenSans.woff2';
88
86
 
89
87
  // returns: true
90
- console.log(validateFontFileName(validFontFileName))
88
+ console.log(await validateFontFileName(validFontFileName, yourPattern));
91
89
 
92
90
  // returns: 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
93
- console.log(validateFontFileName(invalidFontFileName))
91
+ console.log(await validateFontFileName(invalidFontFileName, yourPattern));
94
92
  ```
95
93
 
96
94
  ## Naming Convention
@@ -102,27 +100,6 @@ Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
102
100
 
103
101
  > `{FontFamily}-{FontWeight}.{ext}`
104
102
 
105
- ## Troubleshooting
106
-
107
- > \[!WARNING]
108
- > Developers Only.
109
-
110
- If you are using **npm**, you may get a `peerDependency` error
111
- that is related to these plugins:
112
-
113
- - `typescript-eslint/eslint-plugin`.
114
- - `typescript-eslint/parser`.
115
-
116
- To fix this you can switch to **pnpm**(recommended) or install version `6.0.0`:
117
-
118
- ```shell
119
- typescript-eslint/eslint-plugin@6.0.0
120
- ```
121
-
122
- ```shell
123
- typescript-eslint/parser@6.0.0
124
- ```
125
-
126
103
  ## Contributing
127
104
 
128
105
  Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
package/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The asynchronous function `validateFontFileName` validates
3
+ * if a given font file name matches a specific pattern.
4
+ *
5
+ * @param {string} file - The `file` parameter in the `validateFontFileName`
6
+ * function is a string that represents the file name of a font file that
7
+ * you want to validate.
8
+ *
9
+ * @param {RegExp | string} regex - The `regex` parameter in the
10
+ * `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
13
+ * to validate the font file name.
14
+ *
15
+ * @returns The function `validateFontFileName` is returning a boolean value.
16
+ * It returns `true` if the file name matches the specified pattern,
17
+ * and `false` if it does not match.
18
+ */
19
+ declare const validateFontFileName: (file: string, regex?: string | RegExp) => Promise<boolean>;
20
+
21
+ export { validateFontFileName };
package/index.js ADDED
@@ -0,0 +1 @@
1
+ import{parse as N}from"node:path";import _ from"chalk";const f=async(n,t="")=>{const o="[A-Z][a-z]",e=`^${o}+(${o}+)?`,E=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),c=["otf","ttf","woff","woff2"].join("|"),r=`(${e})`,l=`(${E})`,s=`(${c})$`,i=new RegExp(`${r}-${l}\\.${s}`),T=N(n).base,a=typeof t=="string"&&t!==""?new RegExp(t):t||i;return a.test(T)?!0:(console.error(_.red.bold(`'${T}' doesn't match with '${a}'.`)),!1)};export{f 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.1",
4
+ "version": "1.0.5",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "email": "archoleat@gmail.com",
@@ -63,26 +63,26 @@
63
63
  "chalk": "^5.3.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@archoleat/commitlint-define-config": "^1.0.0",
67
- "@archoleat/semantic-release-define-config": "^1.1.0",
66
+ "@archoleat/commitlint-define-config": "^1.0.2",
67
+ "@archoleat/semantic-release-define-config": "^1.1.1",
68
68
  "@commitlint/cli": "^18.6.1",
69
69
  "@commitlint/config-conventional": "^19.1.0",
70
70
  "@rollup/plugin-typescript": "^11.1.6",
71
71
  "@semantic-release/changelog": "^6.0.3",
72
72
  "@semantic-release/git": "^10.0.1",
73
- "@typescript-eslint/eslint-plugin": "^7.3.1",
74
- "@typescript-eslint/parser": "^7.3.1",
73
+ "@typescript-eslint/eslint-plugin": "^7.4.0",
74
+ "@typescript-eslint/parser": "^7.4.0",
75
75
  "@vitest/coverage-v8": "^1.4.0",
76
76
  "conventional-changelog-conventionalcommits": "^7.0.2",
77
77
  "cz-conventional-changelog": "^3.3.0",
78
78
  "editorconfig-checker": "^5.1.5",
79
79
  "eslint": "^8.57.0",
80
- "eslint-config-airbnb-typescript": "^17.1.0",
80
+ "eslint-config-airbnb-typescript": "^18.0.0",
81
81
  "eslint-define-config": "^2.1.0",
82
82
  "eslint-import-resolver-typescript": "^3.6.1",
83
83
  "eslint-plugin-import": "^2.29.1",
84
84
  "eslint-plugin-unicorn": "^51.0.1",
85
- "globals": "^14.0.0",
85
+ "globals": "^15.0.0",
86
86
  "husky": "^9.0.11",
87
87
  "lint-staged": "^15.2.2",
88
88
  "prettier": "^3.2.5",
@@ -91,11 +91,11 @@
91
91
  "remark-preset-lint-consistent": "^5.1.2",
92
92
  "remark-preset-lint-markdown-style-guide": "^5.1.3",
93
93
  "remark-preset-lint-recommended": "^6.1.3",
94
- "rollup": "^4.13.0",
94
+ "rollup": "^4.13.1",
95
95
  "rollup-plugin-dts": "^6.1.0",
96
96
  "rollup-plugin-esbuild": "^6.1.1",
97
- "semantic-release": "^23.0.5",
98
- "typescript": "^5.4.2",
97
+ "semantic-release": "^23.0.6",
98
+ "typescript": "^5.4.3",
99
99
  "vitest": "^1.4.0"
100
100
  }
101
101
  }