@archoleat/validate-font-file-name 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Archoleat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Validate Font File Name
2
+
3
+ ![NPM Version](https://img.shields.io/npm/v/%40archoleat%2Fvalidate-font-file-name)
4
+ ![NPM Downloads](https://img.shields.io/npm/dm/%40archoleat%2Fvalidate-font-file-name)
5
+ ![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/codeql.yaml?label=CodeQL)
6
+ ![Test](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/test.yaml?label=Test)
7
+ ![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/commitlint.yaml?label=Commitlint)
8
+ ![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/editorconfig.yaml?label=Editorconfig)
9
+ ![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/validate-font-file-name/prettier.yaml?label=Prettier)
10
+ ![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
+
14
+ ## Table of Contents
15
+
16
+ - [Installation](#installation)
17
+ - [Usage](#usage)
18
+ - [Naming Convention](#naming-convention)
19
+ - [Troubleshooting](#troubleshooting)
20
+ - [Contributing](#contributing)
21
+ - [License](#license)
22
+
23
+ ## Installation
24
+
25
+ ```shell
26
+ # pnpm
27
+ pnpm i -D @archoleat/validate-font-file-name
28
+ ```
29
+
30
+ ```shell
31
+ # npm
32
+ npm i -D @archoleat/validate-font-file-name
33
+ ```
34
+
35
+ ```shell
36
+ # yarn
37
+ yarn add -D @archoleat/validate-font-file-name
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```js
43
+ import validateFontFileName from '@archoleat/validate-font-file-name';
44
+
45
+ const validFontFileName = 'src/fonts/OpenSans-Regular.woff2';
46
+ const invalidFontFileName = 'src/fonts/OpenSans.woff2';
47
+
48
+ console.log(validateFontFileName(validFontFileName))
49
+ // returns: true
50
+
51
+ console.log(validateFontFileName(invalidFontFileName))
52
+ // returns: 'OpenSans.woff2' doesn't match the '{FontFamily}-{FontWeight}.{ext}'.
53
+ ```
54
+
55
+ or
56
+
57
+ ```js
58
+ import validateFontFileName from '@archoleat/validate-font-file-name';
59
+
60
+ const validFontFileName = 'OpenSans-Regular.woff2';
61
+ const invalidFontFileName = 'OpenSans.woff2';
62
+
63
+ console.log(validateFontFileName(validFontFileName))
64
+ // returns: true
65
+
66
+ console.log(validateFontFileName(invalidFontFileName))
67
+ // returns: 'OpenSans.woff2' doesn't match the '{FontFamily}-{FontWeight}.{ext}'.
68
+ ```
69
+
70
+ ## Naming Convention
71
+
72
+ The **font family** and **font weight** must be in **Pascal Case**
73
+ and separated by a **hyphen**.
74
+
75
+ Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
76
+
77
+ > `{FontFamily}-{FontWeight}.{ext}`
78
+
79
+ ## Troubleshooting
80
+
81
+ > \[!WARNING]
82
+ > Developers Only.
83
+
84
+ If you are using **npm**, you may get a `peerDependency` error
85
+ that is related to these plugins:
86
+
87
+ - `typescript-eslint/eslint-plugin`.
88
+ - `typescript-eslint/parser`.
89
+
90
+ To fix this you can switch to **pnpm**(recommended) or install version `6.0.0`:
91
+
92
+ ```shell
93
+ typescript-eslint/eslint-plugin@6.0.0
94
+ ```
95
+
96
+ ```shell
97
+ typescript-eslint/parser@6.0.0
98
+ ```
99
+
100
+ ## Contributing
101
+
102
+ Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
103
+ to start contributing.
104
+
105
+ ## License
106
+
107
+ This project is licensed under the [**MIT license**](LICENSE).
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
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 ADDED
@@ -0,0 +1 @@
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};
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@archoleat/validate-font-file-name",
3
+ "description": "Checking font file names for standardization",
4
+ "version": "1.0.0",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "archoleat@gmail.com",
8
+ "name": "Archoleat",
9
+ "url": "https://github.com/archoleat"
10
+ },
11
+ "homepage": "https://github.com/archoleat/validate-font-file-name#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/archoleat/validate-font-file-name.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/archoleat/validate-font-file-name/issues"
18
+ },
19
+ "keywords": [
20
+ "archoleat",
21
+ "font-file-name-standard",
22
+ "font-file-name",
23
+ "naming",
24
+ "standard",
25
+ "validate-font-file-name",
26
+ "validate-name",
27
+ "validate",
28
+ "validator"
29
+ ],
30
+ "packageManager": "pnpm@8.15.5",
31
+ "engines": {
32
+ "node": ">=20.0.0",
33
+ "npm": ">=10.0.0",
34
+ "pnpm": ">=8.0.0"
35
+ },
36
+ "volta": {
37
+ "node": "20.11.1",
38
+ "pnpm": "8.15.5"
39
+ },
40
+ "type": "module",
41
+ "types": "index.d.ts",
42
+ "exports": {
43
+ ".": "./index.js",
44
+ "./*": "./commitlint.config.ts"
45
+ },
46
+ "files": [
47
+ "index.d.ts",
48
+ "index.js"
49
+ ],
50
+ "scripts": {
51
+ "init": "pnpm i && husky && git submodule update",
52
+ "test": "vitest",
53
+ "test:coverage": "vitest run --coverage",
54
+ "build": "rollup -c",
55
+ "release": "semantic-release",
56
+ "lint:editorconfig": "editorconfig-checker",
57
+ "lint:formatting": "prettier . --check",
58
+ "lint:md": "remark . --quiet",
59
+ "lint:ts": "eslint index.ts --fix",
60
+ "prettify": "prettier . --write",
61
+ "commit": "cz"
62
+ },
63
+ "dependencies": {
64
+ "chalk": "^5.3.0"
65
+ },
66
+ "devDependencies": {
67
+ "@archoleat/semantic-release-define-config": "^1.1.0",
68
+ "@commitlint/cli": "^18.6.1",
69
+ "@commitlint/config-conventional": "^18.6.3",
70
+ "@commitlint/types": "^18.6.1",
71
+ "@rollup/plugin-typescript": "^11.1.6",
72
+ "@semantic-release/changelog": "^6.0.3",
73
+ "@semantic-release/git": "^10.0.1",
74
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
75
+ "@typescript-eslint/parser": "^7.3.1",
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
+ "eslint": "^8.57.0",
81
+ "eslint-config-airbnb-typescript": "^17.1.0",
82
+ "eslint-define-config": "^2.1.0",
83
+ "eslint-import-resolver-typescript": "^3.6.1",
84
+ "eslint-plugin-import": "^2.29.1",
85
+ "eslint-plugin-unicorn": "^51.0.1",
86
+ "globals": "^14.0.0",
87
+ "husky": "^9.0.11",
88
+ "lint-staged": "^15.2.2",
89
+ "prettier": "^3.2.5",
90
+ "remark": "15.0.1",
91
+ "remark-cli": "^12.0.0",
92
+ "remark-preset-lint-consistent": "^5.1.2",
93
+ "remark-preset-lint-markdown-style-guide": "^5.1.3",
94
+ "remark-preset-lint-recommended": "^6.1.3",
95
+ "rollup": "^4.13.0",
96
+ "rollup-plugin-dts": "^6.1.0",
97
+ "rollup-plugin-esbuild": "^6.1.1",
98
+ "semantic-release": "^23.0.5",
99
+ "typescript": "^5.4.2",
100
+ "vitest": "^1.4.0"
101
+ }
102
+ }