@archoleat/validate-font-file-name 1.0.4 → 1.0.6
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 +9 -37
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -14,16 +14,9 @@
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
16
16
|
- [Installation](#installation)
|
|
17
|
-
|
|
18
17
|
- [Usage](#usage)
|
|
19
|
-
- [Your Regex](#your-regex)
|
|
20
|
-
|
|
21
18
|
- [Naming Convention](#naming-convention)
|
|
22
|
-
|
|
23
|
-
- [Troubleshooting](#troubleshooting)
|
|
24
|
-
|
|
25
19
|
- [Contributing](#contributing)
|
|
26
|
-
|
|
27
20
|
- [License](#license)
|
|
28
21
|
|
|
29
22
|
## Installation
|
|
@@ -46,31 +39,31 @@ yarn add -D @archoleat/validate-font-file-name
|
|
|
46
39
|
## Usage
|
|
47
40
|
|
|
48
41
|
```js
|
|
49
|
-
import validateFontFileName from '@archoleat/validate-font-file-name';
|
|
42
|
+
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
50
43
|
|
|
51
44
|
const validFontFileName = 'src/fonts/OpenSans-Regular.woff2';
|
|
52
45
|
const invalidFontFileName = 'src/fonts/OpenSans.woff2';
|
|
53
46
|
|
|
54
47
|
// returns: true
|
|
55
|
-
console.log(validateFontFileName(validFontFileName))
|
|
48
|
+
console.log(await validateFontFileName(validFontFileName));
|
|
56
49
|
|
|
57
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)$/'.
|
|
58
|
-
console.log(validateFontFileName(invalidFontFileName))
|
|
51
|
+
console.log(await validateFontFileName(invalidFontFileName));
|
|
59
52
|
```
|
|
60
53
|
|
|
61
54
|
or
|
|
62
55
|
|
|
63
56
|
```js
|
|
64
|
-
import validateFontFileName from '@archoleat/validate-font-file-name';
|
|
57
|
+
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
65
58
|
|
|
66
59
|
const validFontFileName = 'OpenSans-Regular.woff2';
|
|
67
60
|
const invalidFontFileName = 'OpenSans.woff2';
|
|
68
61
|
|
|
69
62
|
// returns: true
|
|
70
|
-
console.log(validateFontFileName(validFontFileName))
|
|
63
|
+
console.log(await validateFontFileName(validFontFileName));
|
|
71
64
|
|
|
72
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)$/'.
|
|
73
|
-
console.log(validateFontFileName(invalidFontFileName))
|
|
66
|
+
console.log(await validateFontFileName(invalidFontFileName));
|
|
74
67
|
```
|
|
75
68
|
|
|
76
69
|
### Your Regex
|
|
@@ -78,7 +71,7 @@ console.log(validateFontFileName(invalidFontFileName))
|
|
|
78
71
|
You can also specify your pattern:
|
|
79
72
|
|
|
80
73
|
```js
|
|
81
|
-
import validateFontFileName from '@archoleat/validate-font-file-name';
|
|
74
|
+
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
82
75
|
|
|
83
76
|
// You can also specify `new RegExp()` and a regular `string`
|
|
84
77
|
const yourPattern = /OpenSans-regular/;
|
|
@@ -87,10 +80,10 @@ const validFontFileName = 'OpenSans-regular';
|
|
|
87
80
|
const invalidFontFileName = 'OpenSans.woff2';
|
|
88
81
|
|
|
89
82
|
// returns: true
|
|
90
|
-
console.log(validateFontFileName(validFontFileName))
|
|
83
|
+
console.log(await validateFontFileName(validFontFileName, yourPattern));
|
|
91
84
|
|
|
92
85
|
// returns: 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
|
|
93
|
-
console.log(validateFontFileName(invalidFontFileName))
|
|
86
|
+
console.log(await validateFontFileName(invalidFontFileName, yourPattern));
|
|
94
87
|
```
|
|
95
88
|
|
|
96
89
|
## Naming Convention
|
|
@@ -102,27 +95,6 @@ Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
|
|
|
102
95
|
|
|
103
96
|
> `{FontFamily}-{FontWeight}.{ext}`
|
|
104
97
|
|
|
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
98
|
## Contributing
|
|
127
99
|
|
|
128
100
|
Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* It returns `true` if the file name matches the specified pattern,
|
|
17
17
|
* and `false` if it does not match.
|
|
18
18
|
*/
|
|
19
|
-
declare const validateFontFileName: (file: string, regex?:
|
|
19
|
+
declare const validateFontFileName: (file: string, regex?: string | RegExp) => Promise<boolean>;
|
|
20
20
|
|
|
21
|
-
export { validateFontFileName
|
|
21
|
+
export { validateFontFileName };
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse as N}from"node:path";import
|
|
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.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "archoleat@gmail.com",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"validate",
|
|
28
28
|
"validator"
|
|
29
29
|
],
|
|
30
|
-
"packageManager": "pnpm@8.15.
|
|
30
|
+
"packageManager": "pnpm@8.15.6",
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=20.0.0",
|
|
33
33
|
"npm": ">=10.0.0",
|
|
34
34
|
"pnpm": ">=8.0.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
|
-
"node": "20.
|
|
38
|
-
"pnpm": "8.15.
|
|
37
|
+
"node": "20.12.0",
|
|
38
|
+
"pnpm": "8.15.6"
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"types": "index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"index.js"
|
|
48
48
|
],
|
|
49
49
|
"scripts": {
|
|
50
|
-
"init": "pnpm i && husky
|
|
50
|
+
"init": "pnpm i && husky",
|
|
51
51
|
"test": "vitest",
|
|
52
52
|
"test:coverage": "vitest run --coverage",
|
|
53
53
|
"build": "rollup -c",
|
|
@@ -63,26 +63,27 @@
|
|
|
63
63
|
"chalk": "^5.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@archoleat/commitlint-define-config": "^1.0.
|
|
67
|
-
"@archoleat/
|
|
68
|
-
"@
|
|
66
|
+
"@archoleat/commitlint-define-config": "^1.0.3",
|
|
67
|
+
"@archoleat/eslint-flat-compatibility": "^1.1.1",
|
|
68
|
+
"@archoleat/semantic-release-define-config": "^1.1.2",
|
|
69
|
+
"@commitlint/cli": "^19.2.1",
|
|
69
70
|
"@commitlint/config-conventional": "^19.1.0",
|
|
70
71
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
71
72
|
"@semantic-release/changelog": "^6.0.3",
|
|
72
73
|
"@semantic-release/git": "^10.0.1",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
74
|
-
"@typescript-eslint/parser": "^7.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
75
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
75
76
|
"@vitest/coverage-v8": "^1.4.0",
|
|
76
77
|
"conventional-changelog-conventionalcommits": "^7.0.2",
|
|
77
78
|
"cz-conventional-changelog": "^3.3.0",
|
|
78
79
|
"editorconfig-checker": "^5.1.5",
|
|
79
80
|
"eslint": "^8.57.0",
|
|
80
|
-
"eslint-config-airbnb-typescript": "^
|
|
81
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
81
82
|
"eslint-define-config": "^2.1.0",
|
|
82
83
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
83
84
|
"eslint-plugin-import": "^2.29.1",
|
|
84
85
|
"eslint-plugin-unicorn": "^51.0.1",
|
|
85
|
-
"globals": "^
|
|
86
|
+
"globals": "^15.0.0",
|
|
86
87
|
"husky": "^9.0.11",
|
|
87
88
|
"lint-staged": "^15.2.2",
|
|
88
89
|
"prettier": "^3.2.5",
|
|
@@ -91,11 +92,11 @@
|
|
|
91
92
|
"remark-preset-lint-consistent": "^5.1.2",
|
|
92
93
|
"remark-preset-lint-markdown-style-guide": "^5.1.3",
|
|
93
94
|
"remark-preset-lint-recommended": "^6.1.3",
|
|
94
|
-
"rollup": "^4.
|
|
95
|
+
"rollup": "^4.14.0",
|
|
95
96
|
"rollup-plugin-dts": "^6.1.0",
|
|
96
97
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
97
|
-
"semantic-release": "^23.0.
|
|
98
|
-
"typescript": "^5.4.
|
|
98
|
+
"semantic-release": "^23.0.7",
|
|
99
|
+
"typescript": "^5.4.3",
|
|
99
100
|
"vitest": "^1.4.0"
|
|
100
101
|
}
|
|
101
102
|
}
|