mowojang-cli 0.4.5-dev.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 +21 -0
- package/README.md +50 -0
- package/dist/index.js +249 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pixelic
|
|
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,50 @@
|
|
|
1
|
+
# mowojang-cli
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
[`npm`](https://npmjs.com/) » `npm install -g mowojang-cli`<br/>
|
|
10
|
+
[`pnpm`](https://pnpm.io/) » `pnpm install -g mowojang-cli`<br/>
|
|
11
|
+
[`bun`](https://bun.sh/) » `bun install -g mowojang-cli`
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`mowojang-cli help`
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
mowojang/mowojang-cli
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
mowojang-cli <command> [args] [options]
|
|
22
|
+
or
|
|
23
|
+
mowojang <command> [args] [options]
|
|
24
|
+
|
|
25
|
+
Commands:
|
|
26
|
+
uuid <username> Get the UUID for a username
|
|
27
|
+
username <uuid> Get the username for a UUID
|
|
28
|
+
skin <player> Get skin metadata for a player
|
|
29
|
+
cape <player> Get cape metadata for a player
|
|
30
|
+
skin-buffer <player> Output a player's skin image as base64 or save it to file
|
|
31
|
+
cape-buffer <player> Output a player's cape image as base64 or save it to file
|
|
32
|
+
profile <player> Get a player's profile
|
|
33
|
+
profiles <player1> <player2> Get multiple player profiles
|
|
34
|
+
session <player> Get session details
|
|
35
|
+
sessions <player1> <player2> Get multiple player sessions
|
|
36
|
+
validate player <value> Validate a username or UUID
|
|
37
|
+
validate uuid <value> Validate a UUID
|
|
38
|
+
validate username <value> Validate a username
|
|
39
|
+
utils dash <uuid> Convert a UUID to dashed form
|
|
40
|
+
utils undash <uuid> Convert a UUID to undashed form
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
--debug Show debug messages
|
|
44
|
+
--no-validate Disable input validation
|
|
45
|
+
--validate Enable input validation
|
|
46
|
+
--base-url <url> Use a custom API base URL
|
|
47
|
+
--fallback Enable fallback host retry on connection errors
|
|
48
|
+
--output <path> Write buffer output to a file (only for skin-buffer/cape-buffer)
|
|
49
|
+
-h, --help Show this help message
|
|
50
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { Client, validate, utils } from "mowojang";
|
|
4
|
+
const help = `mowojang/mowojang-cli
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
mowojang-cli <command> [args] [options]
|
|
8
|
+
or
|
|
9
|
+
mowojang <command> [args] [options]
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
uuid <username> Get the UUID for a username
|
|
13
|
+
username <uuid> Get the username for a UUID
|
|
14
|
+
skin <player> Get skin metadata for a player
|
|
15
|
+
cape <player> Get cape metadata for a player
|
|
16
|
+
skin-buffer <player> Output a player's skin image as base64 or save it to file
|
|
17
|
+
cape-buffer <player> Output a player's cape image as base64 or save it to file
|
|
18
|
+
profile <player> Get a player's profile
|
|
19
|
+
profiles <player1> <player2> Get multiple player profiles
|
|
20
|
+
session <player> Get session details
|
|
21
|
+
sessions <player1> <player2> Get multiple player sessions
|
|
22
|
+
validate player <value> Validate a username or UUID
|
|
23
|
+
validate uuid <value> Validate a UUID
|
|
24
|
+
validate username <value> Validate a username
|
|
25
|
+
utils dash <uuid> Convert a UUID to dashed form
|
|
26
|
+
utils undash <uuid> Convert a UUID to undashed form
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--debug Show debug messages
|
|
30
|
+
--no-validate Disable input validation
|
|
31
|
+
--validate Enable input validation
|
|
32
|
+
--base-url <url> Use a custom API base URL
|
|
33
|
+
--fallback Enable fallback host retry on connection errors
|
|
34
|
+
--output <path> Write buffer output to a file (only for skin-buffer/cape-buffer)
|
|
35
|
+
-h, --help Show this help message
|
|
36
|
+
`;
|
|
37
|
+
const parseArgs = (argv) => {
|
|
38
|
+
const options = {
|
|
39
|
+
debug: false,
|
|
40
|
+
validate: true,
|
|
41
|
+
baseUrl: undefined,
|
|
42
|
+
fallback: true,
|
|
43
|
+
output: undefined,
|
|
44
|
+
args: [],
|
|
45
|
+
};
|
|
46
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
47
|
+
switch (argv[i]) {
|
|
48
|
+
case "--debug":
|
|
49
|
+
options.debug = true;
|
|
50
|
+
break;
|
|
51
|
+
case "--no-validate":
|
|
52
|
+
options.validate = false;
|
|
53
|
+
break;
|
|
54
|
+
case "--no-fallback":
|
|
55
|
+
options.fallback = false;
|
|
56
|
+
break;
|
|
57
|
+
case "--base-url":
|
|
58
|
+
options.baseUrl = argv[++i];
|
|
59
|
+
break;
|
|
60
|
+
case "--output":
|
|
61
|
+
options.output = argv[++i];
|
|
62
|
+
break;
|
|
63
|
+
case "-h":
|
|
64
|
+
case "--help":
|
|
65
|
+
options.args.push("help");
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
options.args.push(argv[i]);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return options;
|
|
73
|
+
};
|
|
74
|
+
const print = (text) => {
|
|
75
|
+
process.stdout.write(`${text}\n`);
|
|
76
|
+
};
|
|
77
|
+
const printJson = (value) => {
|
|
78
|
+
print(JSON.stringify(value, null, 2));
|
|
79
|
+
};
|
|
80
|
+
const writeBuffer = (buffer, outputPath) => {
|
|
81
|
+
if (outputPath) {
|
|
82
|
+
fs.writeFileSync(path.resolve(process.cwd(), outputPath), buffer);
|
|
83
|
+
console.log(`Saved to ${path.resolve(process.cwd(), outputPath)}`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.log(buffer.toString("base64"));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const { args, debug, validate: enableValidation, baseUrl, fallback, output } = parseArgs(process.argv.slice(2));
|
|
90
|
+
if (args.length === 0 || args[0] === "help") {
|
|
91
|
+
print(help);
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}
|
|
94
|
+
const [command, ...arg] = args;
|
|
95
|
+
const client = new Client({
|
|
96
|
+
logger: {
|
|
97
|
+
minLevel: debug ? "DEBUG" : undefined,
|
|
98
|
+
},
|
|
99
|
+
validation: { enabled: enableValidation },
|
|
100
|
+
baseURL: baseUrl,
|
|
101
|
+
fallback,
|
|
102
|
+
});
|
|
103
|
+
try {
|
|
104
|
+
switch (command) {
|
|
105
|
+
case "uuid": {
|
|
106
|
+
const [username] = arg;
|
|
107
|
+
if (!username)
|
|
108
|
+
throw new Error("Usage: uuid <username>");
|
|
109
|
+
print(await client.getUUID(username));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "username": {
|
|
113
|
+
const [uuid] = arg;
|
|
114
|
+
if (!uuid)
|
|
115
|
+
throw new Error("Usage: username <uuid>");
|
|
116
|
+
print(await client.getUsername(uuid));
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case "skin": {
|
|
120
|
+
const [player] = arg;
|
|
121
|
+
if (!player)
|
|
122
|
+
throw new Error("Usage: skin <player>");
|
|
123
|
+
const data = await client.getSkin(player);
|
|
124
|
+
if (data) {
|
|
125
|
+
printJson(data);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
print(null);
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "cape": {
|
|
133
|
+
const [player] = arg;
|
|
134
|
+
if (!player)
|
|
135
|
+
throw new Error("Usage: cape <player>");
|
|
136
|
+
const data = await client.getCape(player);
|
|
137
|
+
if (data) {
|
|
138
|
+
printJson(data);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
print(null);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "skin-buffer": {
|
|
146
|
+
const [player] = arg;
|
|
147
|
+
if (!player)
|
|
148
|
+
throw new Error("Usage: skin-buffer <player>");
|
|
149
|
+
const data = await client.getSkinBuffer(player);
|
|
150
|
+
if (data) {
|
|
151
|
+
writeBuffer(data, output);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
print(null);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "cape-buffer": {
|
|
159
|
+
const [player] = arg;
|
|
160
|
+
if (!player)
|
|
161
|
+
throw new Error("Usage: cape-buffer <player>");
|
|
162
|
+
const data = await client.getCapeBuffer(player);
|
|
163
|
+
if (data) {
|
|
164
|
+
writeBuffer(data, output);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
print(null);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case "profile": {
|
|
172
|
+
const [player] = arg;
|
|
173
|
+
if (!player)
|
|
174
|
+
throw new Error("Usage: profile <player>");
|
|
175
|
+
const result = await client.getProfile(player);
|
|
176
|
+
if (result.error)
|
|
177
|
+
throw new Error(result.error);
|
|
178
|
+
printJson(result.data);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "profiles": {
|
|
182
|
+
if (arg.length === 0)
|
|
183
|
+
throw new Error("Usage: profiles <player1> <player2> <player3>");
|
|
184
|
+
const result = await client.getProfiles(arg);
|
|
185
|
+
if (result.error)
|
|
186
|
+
throw new Error(result.error);
|
|
187
|
+
printJson(result.data);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "session": {
|
|
191
|
+
const [player] = arg;
|
|
192
|
+
if (!player)
|
|
193
|
+
throw new Error("Usage: session <player>");
|
|
194
|
+
const result = await client.getSession(player);
|
|
195
|
+
if (result.error)
|
|
196
|
+
throw new Error(result.error);
|
|
197
|
+
printJson(result.data);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "sessions": {
|
|
201
|
+
if (arg.length === 0)
|
|
202
|
+
throw new Error("Usage: sessions <player1> <player2> <player3>");
|
|
203
|
+
const result = await client.getSessions(arg);
|
|
204
|
+
if (result.error)
|
|
205
|
+
throw new Error(result.error);
|
|
206
|
+
printJson(result.data);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case "validate": {
|
|
210
|
+
const [type, value] = arg;
|
|
211
|
+
if (!type || !value)
|
|
212
|
+
throw new Error("Usage: validate <player|username> <value>");
|
|
213
|
+
if (type === "player") {
|
|
214
|
+
printJson({ value, valid: validate.player(value) });
|
|
215
|
+
}
|
|
216
|
+
else if (type === "uuid") {
|
|
217
|
+
printJson({ value, valid: validate.UUID(value) });
|
|
218
|
+
}
|
|
219
|
+
else if (type === "username") {
|
|
220
|
+
printJson({ value, valid: validate.username(value) });
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
throw new Error("Validation type must be 'player' or 'username'.");
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "utils": {
|
|
228
|
+
const [action, value] = arg;
|
|
229
|
+
if (!action || !value)
|
|
230
|
+
throw new Error("Usage: utils <dash|undash> <uuid>");
|
|
231
|
+
if (action === "dash") {
|
|
232
|
+
printJson({ input: value, output: utils.dashUUID(value) });
|
|
233
|
+
}
|
|
234
|
+
else if (action === "undash") {
|
|
235
|
+
printJson({ input: value, output: utils.undashUUID(value) });
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
throw new Error("Utils action must be 'dash' or 'undash'.");
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
default:
|
|
243
|
+
throw new Error(`Unknown command: ${command}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mowojang-cli",
|
|
3
|
+
"version": "0.4.5-dev.0",
|
|
4
|
+
"description": "CLI Wrapper for the mowojang npm package.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mowojang": "./dist/index.js",
|
|
8
|
+
"mowojang-cli": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"mowojang": "0.4.5"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^25.9.1",
|
|
18
|
+
"typescript": "^6.0.3"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "pnpm tsc",
|
|
25
|
+
"test": "pnpm build && pnpm i -g ."
|
|
26
|
+
}
|
|
27
|
+
}
|