nekos 1.2.1 → 2.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/README.md +4 -0
- package/dist/index.cjs +101 -0
- package/dist/index.d.ts +13 -0
- package/{index.js → dist/index.js} +11 -26
- package/package.json +17 -9
- package/index.cjs +0 -4306
- package/index.d.ts +0 -32
package/README.md
CHANGED
|
@@ -135,3 +135,7 @@ nekos({ colors: ["#ff00ff", "#00ffff"] });
|
|
|
135
135
|
## コントリビューション
|
|
136
136
|
|
|
137
137
|
コントリビューションを歓迎します!詳細は[コントリビューションガイドライン](CONTRIBUTING.md)をご覧ください。
|
|
138
|
+
|
|
139
|
+
# Contributors
|
|
140
|
+
|
|
141
|
+
[](https://github.com/otoneko1102/nekos/graphs/contributors)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// cjs-source-ns:cjs-entry
|
|
30
|
+
var cjs_entry_exports = {};
|
|
31
|
+
__export(cjs_entry_exports, {
|
|
32
|
+
default: () => cjs_entry_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(cjs_entry_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_color = require("@randplus/color");
|
|
38
|
+
var import_gradient_string = __toESM(require("gradient-string"));
|
|
39
|
+
var aaDir = import_path.default.join(__dirname, "../aa");
|
|
40
|
+
function nekos(options = {}) {
|
|
41
|
+
const { id } = options;
|
|
42
|
+
let { colors } = options;
|
|
43
|
+
let catAscii = "";
|
|
44
|
+
try {
|
|
45
|
+
const files = import_fs.default.readdirSync(aaDir);
|
|
46
|
+
if (files.length === 0) {
|
|
47
|
+
console.error("Error: 'aa' directory is empty or does not exist.");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let targetFile;
|
|
51
|
+
if (id && files.includes(`${id}.txt`)) {
|
|
52
|
+
targetFile = `${id}.txt`;
|
|
53
|
+
} else {
|
|
54
|
+
const randomIndex = Math.floor(Math.random() * files.length);
|
|
55
|
+
targetFile = files[randomIndex];
|
|
56
|
+
}
|
|
57
|
+
const filePath = import_path.default.join(aaDir, targetFile);
|
|
58
|
+
catAscii = import_fs.default.readFileSync(filePath, "utf-8");
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("Error reading ascii art file:", error);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (colors) {
|
|
64
|
+
let processedColors;
|
|
65
|
+
const rainbowColors = [
|
|
66
|
+
"red",
|
|
67
|
+
"orange",
|
|
68
|
+
"yellow",
|
|
69
|
+
"green",
|
|
70
|
+
"blue",
|
|
71
|
+
"violet"
|
|
72
|
+
];
|
|
73
|
+
if (typeof colors === "string") {
|
|
74
|
+
const upperCaseColor = colors.toUpperCase();
|
|
75
|
+
if (upperCaseColor === "RAINBOW") {
|
|
76
|
+
processedColors = rainbowColors;
|
|
77
|
+
} else if (upperCaseColor === "RANDOM") {
|
|
78
|
+
processedColors = [(0, import_color.hex)("#")];
|
|
79
|
+
} else {
|
|
80
|
+
processedColors = [colors];
|
|
81
|
+
}
|
|
82
|
+
} else if (Array.isArray(colors)) {
|
|
83
|
+
processedColors = colors.map(
|
|
84
|
+
(color) => typeof color === "string" && color.toUpperCase() === "RANDOM" ? (0, import_color.hex)("#") : color
|
|
85
|
+
);
|
|
86
|
+
} else {
|
|
87
|
+
processedColors = colors;
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(processedColors) && processedColors.length === 1) {
|
|
90
|
+
processedColors.push(processedColors[0]);
|
|
91
|
+
}
|
|
92
|
+
if (processedColors && processedColors.length > 0) {
|
|
93
|
+
console.log((0, import_gradient_string.default)(processedColors)(catAscii));
|
|
94
|
+
} else {
|
|
95
|
+
console.log(catAscii);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
console.log(catAscii);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
var cjs_entry_default = nekos;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ColorKeyword = "RANDOM" | "RAINBOW";
|
|
2
|
+
type HexColor = `#${string}`;
|
|
3
|
+
type ColorValue = ColorKeyword | HexColor;
|
|
4
|
+
interface NekosOptions {
|
|
5
|
+
id?: string;
|
|
6
|
+
colors?: ColorValue | ColorValue[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Logs a cat ASCII art to the console.
|
|
10
|
+
* @param {NekosOptions} [options={}] - The options object.
|
|
11
|
+
*/
|
|
12
|
+
declare function nekos(options?: NekosOptions): void;
|
|
13
|
+
export default nekos;
|
|
@@ -1,47 +1,35 @@
|
|
|
1
|
+
// src/index.ts
|
|
1
2
|
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
4
5
|
import { hex } from "@randplus/color";
|
|
5
6
|
import gradient from "gradient-string";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const aaDir = path.join(__dirname, "aa");
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Logs a cat ASCII art to the console.
|
|
13
|
-
* @param {object} [options={}] - The options object.
|
|
14
|
-
* @param {string|string[]} [options.colors] - A single color, a keyword ("RANDOM", "RAINBOW"), or an array of colors/keywords.
|
|
15
|
-
* @param {string} [options.id] - The ID (filename without .txt) of a specific ASCII art file to display.
|
|
16
|
-
*/
|
|
7
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
var __dirname = path.dirname(__filename);
|
|
9
|
+
var aaDir = path.join(__dirname, "../aa");
|
|
17
10
|
function nekos(options = {}) {
|
|
18
11
|
const { id } = options;
|
|
19
12
|
let { colors } = options;
|
|
20
13
|
let catAscii = "";
|
|
21
|
-
|
|
22
14
|
try {
|
|
23
15
|
const files = fs.readdirSync(aaDir);
|
|
24
16
|
if (files.length === 0) {
|
|
25
17
|
console.error("Error: 'aa' directory is empty or does not exist.");
|
|
26
18
|
return;
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
let targetFile;
|
|
30
|
-
|
|
31
21
|
if (id && files.includes(`${id}.txt`)) {
|
|
32
22
|
targetFile = `${id}.txt`;
|
|
33
23
|
} else {
|
|
34
24
|
const randomIndex = Math.floor(Math.random() * files.length);
|
|
35
25
|
targetFile = files[randomIndex];
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
const filePath = path.join(aaDir, targetFile);
|
|
39
28
|
catAscii = fs.readFileSync(filePath, "utf-8");
|
|
40
29
|
} catch (error) {
|
|
41
30
|
console.error("Error reading ascii art file:", error);
|
|
42
31
|
return;
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
if (colors) {
|
|
46
34
|
let processedColors;
|
|
47
35
|
const rainbowColors = [
|
|
@@ -50,9 +38,8 @@ function nekos(options = {}) {
|
|
|
50
38
|
"yellow",
|
|
51
39
|
"green",
|
|
52
40
|
"blue",
|
|
53
|
-
"violet"
|
|
41
|
+
"violet"
|
|
54
42
|
];
|
|
55
|
-
|
|
56
43
|
if (typeof colors === "string") {
|
|
57
44
|
const upperCaseColor = colors.toUpperCase();
|
|
58
45
|
if (upperCaseColor === "RAINBOW") {
|
|
@@ -63,19 +50,15 @@ function nekos(options = {}) {
|
|
|
63
50
|
processedColors = [colors];
|
|
64
51
|
}
|
|
65
52
|
} else if (Array.isArray(colors)) {
|
|
66
|
-
processedColors = colors.map(
|
|
67
|
-
typeof color === "string" && color.toUpperCase() === "RANDOM"
|
|
68
|
-
? hex("#")
|
|
69
|
-
: color
|
|
53
|
+
processedColors = colors.map(
|
|
54
|
+
(color) => typeof color === "string" && color.toUpperCase() === "RANDOM" ? hex("#") : color
|
|
70
55
|
);
|
|
71
56
|
} else {
|
|
72
57
|
processedColors = colors;
|
|
73
58
|
}
|
|
74
|
-
|
|
75
59
|
if (Array.isArray(processedColors) && processedColors.length === 1) {
|
|
76
60
|
processedColors.push(processedColors[0]);
|
|
77
61
|
}
|
|
78
|
-
|
|
79
62
|
if (processedColors && processedColors.length > 0) {
|
|
80
63
|
console.log(gradient(processedColors)(catAscii));
|
|
81
64
|
} else {
|
|
@@ -85,5 +68,7 @@ function nekos(options = {}) {
|
|
|
85
68
|
console.log(catAscii);
|
|
86
69
|
}
|
|
87
70
|
}
|
|
88
|
-
|
|
89
|
-
export
|
|
71
|
+
var index_default = nekos;
|
|
72
|
+
export {
|
|
73
|
+
index_default as default
|
|
74
|
+
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nekos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Let's have cute cats mess around in the log!",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
7
8
|
"exports": {
|
|
8
|
-
"import": "./index.js",
|
|
9
|
-
"require": "./index.cjs"
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
10
11
|
},
|
|
11
|
-
"types": "index.d.ts",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
12
13
|
"scripts": {
|
|
13
|
-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
14
|
-
"
|
|
14
|
+
"test": "cross-env FORCE_COLOR=1 node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"build:types": "tsc",
|
|
17
|
+
"build:js": "node scripts/build.js",
|
|
18
|
+
"build": "npm run clean && npm run build:types && npm run build:js"
|
|
15
19
|
},
|
|
16
20
|
"repository": {
|
|
17
21
|
"type": "git",
|
|
@@ -33,11 +37,15 @@
|
|
|
33
37
|
},
|
|
34
38
|
"homepage": "https://github.com/otoneko1102/nekos#readme",
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@randplus/color": "^
|
|
40
|
+
"@randplus/color": "^3.0.0",
|
|
37
41
|
"gradient-string": "^3.0.0"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
44
|
+
"@types/node": "^24.3.0",
|
|
45
|
+
"cross-env": "^10.0.0",
|
|
40
46
|
"esbuild": "^0.25.9",
|
|
41
|
-
"jest": "^30.1.1"
|
|
47
|
+
"jest": "^30.1.1",
|
|
48
|
+
"rimraf": "^6.0.1",
|
|
49
|
+
"typescript": "^5.9.2"
|
|
42
50
|
}
|
|
43
51
|
}
|