@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.
- package/README.md +18 -12
- package/index.d.ts +11 -6
- package/index.js +1 -1
- package/package.json +43 -36
package/README.md
CHANGED
|
@@ -2,25 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
5
|
+

|
|
6
|
+

|
|
5
7
|

|
|
6
8
|

|
|
7
9
|

|
|
8
10
|

|
|
9
11
|

|
|
10
12
|

|
|
11
|
-

|
|
13
|
+

|
|
13
14
|
|
|
14
15
|
## Table of Contents
|
|
15
16
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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}.{
|
|
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
|
|
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}
|
|
14
|
+
* @param {string | RegExp} regex - The `regex` parameter in the
|
|
10
15
|
* `validateFontFileName` function is used to provide a custom regular
|
|
11
|
-
* expression
|
|
12
|
-
* regex
|
|
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
|
|
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: (
|
|
24
|
+
declare const validateFontFileName: (parameters: Parameters) => Promise<boolean>;
|
|
20
25
|
|
|
21
26
|
export { validateFontFileName };
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse as
|
|
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
|
|
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@
|
|
32
|
+
"packageManager": "pnpm@9.4.0",
|
|
31
33
|
"engines": {
|
|
32
34
|
"node": ">=20.0.0",
|
|
33
|
-
"
|
|
34
|
-
"pnpm": ">=8.0.0"
|
|
35
|
+
"pnpm": ">=9.0.0"
|
|
35
36
|
},
|
|
36
37
|
"volta": {
|
|
37
|
-
"node": "20.
|
|
38
|
-
"pnpm": "
|
|
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
|
-
"
|
|
66
|
+
"@archoleat/notifier": "^1.0.0",
|
|
67
|
+
"@archoleat/reglib": "^1.1.0"
|
|
64
68
|
},
|
|
65
69
|
"devDependencies": {
|
|
66
|
-
"@archoleat/commitlint-define-config": "^1.0.
|
|
67
|
-
"@archoleat/eslint-flat-compatibility": "^1.1.
|
|
68
|
-
"@archoleat/
|
|
69
|
-
"@
|
|
70
|
-
"@commitlint/
|
|
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
|
-
"@
|
|
75
|
-
"@typescript-eslint/
|
|
76
|
-
"@
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"editorconfig-checker": "^5.1.
|
|
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": "^
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
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.
|
|
93
|
-
"remark-preset-lint-consistent": "^
|
|
94
|
-
"remark-preset-lint-markdown-style-guide": "^
|
|
95
|
-
"remark-preset-lint-recommended": "^
|
|
96
|
-
"rollup": "^4.
|
|
97
|
-
"rollup-plugin-dts": "^6.1.
|
|
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": "^
|
|
100
|
-
"typescript": "^5.
|
|
101
|
-
"vitest": "^
|
|
106
|
+
"semantic-release": "^24.0.0",
|
|
107
|
+
"typescript": "^5.5.4",
|
|
108
|
+
"vitest": "^2.0.5"
|
|
102
109
|
}
|
|
103
110
|
}
|