nekos 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.
@@ -0,0 +1,39 @@
1
+ # How to Contribute
2
+
3
+ We welcome contributions! If you want to add a new ASCII art, please follow these rules.
4
+
5
+ ## Adding New ASCII Art
6
+
7
+ You can add new cat ASCII art to the `aa/` directory. A pull request is required to add a file.
8
+
9
+ ### Contribution Rules
10
+
11
+ Our system will automatically check your pull request to ensure it follows these rules:
12
+
13
+ 1. **Do not modify or delete** existing files in the `aa/` directory.
14
+ 2. Please add **only one file** per pull request.
15
+ 3. The filename must be **unique** and end with the `.txt` extension.
16
+ 4. The filename (without the extension) can only contain **lowercase letters (a-z)**, **numbers (0-9)**, **underscores (_)**, and **hyphens (-)**.
17
+
18
+ Thank you for your contribution! 🐱
19
+
20
+ ---
21
+
22
+ ## コントリビューションの方法 (日本語)
23
+
24
+ コントリビューションを歓迎します!新しいアスキーアートを追加したい場合は、以下のルールに従ってください。
25
+
26
+ ### 新しいアスキーアートの追加
27
+
28
+ `aa/` ディレクトリに新しい猫のアスキーアートを追加できます。ファイルを追加するにはプルリクエストが必要です。
29
+
30
+ ### コントリビューションのルール
31
+
32
+ システムは、あなたのプルリクエストが以下のルールに従っているかを自動的にチェックします。
33
+
34
+ 1. **既存のファイルを変更・削除しないこと**:`aa/` ディレクトリ内の既存のファイルは変更したり削除したりしないでください。
35
+ 2. **プルリクエストごとに1ファイルのみ**:1回のプルリクエストで追加できるファイルは1つだけです。
36
+ 3. **ユニークなファイル名**:ファイル名は他と重複しないユニークなもので、必ず `.txt` で終わるようにしてください。
37
+ 4. **使用可能な文字**:ファイル名(拡張子を除く)には、**小文字の英字 (a-z)**、**数字 (0-9)**、**アンダースコア (_)**、**ハイフン (-)** のみ使用できます。
38
+
39
+ ご協力ありがとうございます! 🐱
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 [otoneko.]
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,129 @@
1
+ # nekos 🐱
2
+
3
+ [![npm version](https://badge.fury.io/js/nekos.svg)](https://badge.fury.io/js/nekos)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Validate AA Contribution](https://github.com/otoneko1102/nekos/actions/workflows/validate-aa.yml/badge.svg)](https://github.com/otoneko110/nekos/actions/workflows/validate-aa.yml)
6
+
7
+ A simple CLI tool to display cat ASCII art in your console.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install nekos
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```javascript
18
+ import nekos from "nekos";
19
+
20
+ // Log a random cat
21
+ nekos();
22
+
23
+ // Log a specific cat by ID
24
+ nekos({ id: "my_cat" });
25
+
26
+ // Log a cat with a rainbow gradient
27
+ nekos({ colors: "RAINBOW" });
28
+
29
+ // Log a cat with a single random color
30
+ nekos({ colors: "RANDOM" });
31
+
32
+ // Log a cat with a custom gradient
33
+ nekos({ colors: ["#ff00ff", "#00ffff"] });
34
+ ```
35
+
36
+ [Example - demo.js](test/demo.js)
37
+
38
+ ## API
39
+
40
+ `nekos(options)`
41
+
42
+ ### options
43
+
44
+ Type: `object`
45
+
46
+ #### id
47
+
48
+ Type: `string`
49
+
50
+ The ID of the ASCII art to display (the filename without the `.txt` extension). If not provided, a random cat will be shown.
51
+
52
+ #### colors
53
+
54
+ Type: `string | string[]`
55
+
56
+ Specify the color(s) for the ASCII art.
57
+
58
+ - **String Keywords:**
59
+ - `'RANDOM'`: Applies a single random solid color.
60
+ - `'RAINBOW'`: Applies a rainbow gradient.
61
+ - **String Array:** An array of color strings (e.g., hex codes, color names) to create a custom gradient.
62
+
63
+ ## Contributing
64
+
65
+ Contributions are welcome! Please see the [Contributing Guidelines](CONTRIBUTING.md) for more details.
66
+
67
+ ---
68
+
69
+ ## nekos 🐱 (日本語)
70
+
71
+ コンソールに猫のアスキーアートを表示する、シンプルな CLI ツールです。
72
+
73
+ ## インストール
74
+
75
+ ```bash
76
+ npm install nekos
77
+ ```
78
+
79
+ ## 使い方
80
+
81
+ ```javascript
82
+ import nekos from "nekos";
83
+
84
+ // ランダムな猫を表示
85
+ nekos();
86
+
87
+ // IDを指定して特定の猫を表示
88
+ nekos({ id: "my_cat" });
89
+
90
+ // 虹色のグラデーションで猫を表示
91
+ nekos({ colors: "RAINBOW" });
92
+
93
+ // ランダムな単色で猫を表示
94
+ nekos({ colors: "RANDOM" });
95
+
96
+ // カスタムグラデーションで猫を表示
97
+ nekos({ colors: ["#ff00ff", "#00ffff"] });
98
+ ```
99
+
100
+ [Example - demo.js](test/demo.js)
101
+
102
+ ## API
103
+
104
+ `nekos(options)`
105
+
106
+ ### options
107
+
108
+ 型: `object`
109
+
110
+ #### id
111
+
112
+ 型: `string`
113
+
114
+ 表示したいアスキーアートの ID(`.txt`を除いたファイル名)。指定しない場合は、ランダムな猫が表示されます。
115
+
116
+ #### colors
117
+
118
+ 型: `string | string[]`
119
+
120
+ アスキーアートの色を指定します。
121
+
122
+ - **文字列キーワード:**
123
+ - `'RANDOM'`: ランダムな単色を適用します。
124
+ - `'RAINBOW'`: 虹色のグラデーションを適用します。
125
+ - **文字列配列:** カスタムグラデーションを作成するための色の配列(例: HEX コード、色名)。
126
+
127
+ ## コントリビューション
128
+
129
+ コントリビューションを歓迎します!詳細は[コントリビューションガイドライン](CONTRIBUTING.md)をご覧ください。
package/aa/my_cat.txt ADDED
@@ -0,0 +1,2 @@
1
+ ^ ^
2
+ = ⠈ w⠈ =
package/aa/neko.txt ADDED
@@ -0,0 +1,5 @@
1
+ ⣄ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀ ⣄
2
+ ⢿⠀⠘⣄⠀ ⠀⠀⠀⠀⠀⠀⠀⠀ ⣄⠘⠀⢿ ⢿
3
+ ⢿⠀⠀⠀⠈⠇⠸⠘⠈⠈⠃⠸⠇⠈ ⢿
4
+ ⢿ ⠀⠀ ٍ ⠀ ⠈ ⠀w⠀ ⠈⠀ ٍ ⠀⠀⠀ ⠀⢿
5
+ ⢿ ⢿
package/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ // index.d.ts
2
+
3
+ /**
4
+ * An object of options for the nekos function.
5
+ */
6
+ interface NekosOptions {
7
+ /**
8
+ * The ID (filename without .txt) of a specific ASCII art file to display.
9
+ */
10
+ id?: string;
11
+
12
+ /**
13
+ * A single color, a keyword ("RANDOM", "RAINBOW"), or an array of colors/keywords for a gradient.
14
+ */
15
+ colors?: string | string[];
16
+ }
17
+
18
+ /**
19
+ * Logs a cat ASCII art to the console.
20
+ * @param options The options object.
21
+ *
22
+ * @example
23
+ * import nekos from 'nekos';
24
+ *
25
+ * // Log a cat with the ID 'my_cat'
26
+ * nekos({ id: 'my_cat' });
27
+ */
28
+ declare function nekos(options?: NekosOptions): void;
29
+
30
+ export default nekos;
package/index.js ADDED
@@ -0,0 +1,97 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import gradient from "gradient-string";
5
+
6
+ /**
7
+ * Generates a random HEX color code (e.g., #1a2b3c).
8
+ * @returns {string} A random color code.
9
+ */
10
+ function getRandomHexColor() {
11
+ const randomColor = Math.floor(Math.random() * 16777216).toString(16);
12
+ return `#${randomColor.padStart(6, "0")}`;
13
+ }
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+ const aaDir = path.join(__dirname, "aa");
18
+
19
+ /**
20
+ * Logs a cat ASCII art to the console.
21
+ * @param {object} [options={}] - The options object.
22
+ * @param {string|string[]} [options.colors] - A single color, a keyword ("RANDOM", "RAINBOW"), or an array of colors/keywords.
23
+ * @param {string} [options.id] - The ID (filename without .txt) of a specific ASCII art file to display.
24
+ */
25
+ function nekos(options = {}) {
26
+ const { id } = options;
27
+ let { colors } = options;
28
+ let catAscii = "";
29
+
30
+ try {
31
+ const files = fs.readdirSync(aaDir);
32
+ if (files.length === 0) {
33
+ console.error("Error: 'aa' directory is empty or does not exist.");
34
+ return;
35
+ }
36
+
37
+ let targetFile;
38
+
39
+ if (id && files.includes(`${id}.txt`)) {
40
+ targetFile = `${id}.txt`;
41
+ } else {
42
+ const randomIndex = Math.floor(Math.random() * files.length);
43
+ targetFile = files[randomIndex];
44
+ }
45
+
46
+ const filePath = path.join(aaDir, targetFile);
47
+ catAscii = fs.readFileSync(filePath, "utf-8");
48
+ } catch (error) {
49
+ console.error("Error reading ascii art file:", error);
50
+ return;
51
+ }
52
+
53
+ if (colors) {
54
+ let processedColors;
55
+ const rainbowColors = [
56
+ "red",
57
+ "orange",
58
+ "yellow",
59
+ "green",
60
+ "blue",
61
+ "violet",
62
+ ];
63
+
64
+ if (typeof colors === "string") {
65
+ const upperCaseColor = colors.toUpperCase();
66
+ if (upperCaseColor === "RAINBOW") {
67
+ processedColors = rainbowColors;
68
+ } else if (upperCaseColor === "RANDOM") {
69
+ processedColors = [getRandomHexColor()];
70
+ } else {
71
+ processedColors = [colors];
72
+ }
73
+ } else if (Array.isArray(colors)) {
74
+ processedColors = colors.map((color) =>
75
+ typeof color === "string" && color.toUpperCase() === "RANDOM"
76
+ ? getRandomHexColor()
77
+ : color
78
+ );
79
+ } else {
80
+ processedColors = colors;
81
+ }
82
+
83
+ if (Array.isArray(processedColors) && processedColors.length === 1) {
84
+ processedColors.push(processedColors[0]);
85
+ }
86
+
87
+ if (processedColors && processedColors.length > 0) {
88
+ console.log(gradient(processedColors)(catAscii));
89
+ } else {
90
+ console.log(catAscii);
91
+ }
92
+ } else {
93
+ console.log(catAscii);
94
+ }
95
+ }
96
+
97
+ export default nekos;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "nekos",
3
+ "version": "1.0.0",
4
+ "description": "Let's have cute cats mess around in the log!",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/otoneko1102/nekos.git"
14
+ },
15
+ "keywords": [
16
+ "log",
17
+ "kawaii",
18
+ "joke",
19
+ "cat",
20
+ "cats",
21
+ "neko",
22
+ "nekos"
23
+ ],
24
+ "author": "otoneko.",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/otoneko1102/nekos/issues"
28
+ },
29
+ "homepage": "https://github.com/otoneko1102/nekos#readme",
30
+ "dependencies": {
31
+ "gradient-string": "^3.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "jest": "^30.1.1"
35
+ }
36
+ }