airship-cli 1.1.0 → 1.1.1
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 +15 -4
- package/out/AirshipTypes.d.ts +3 -3
- package/out/AirshipTypes.d.ts.map +1 -1
- package/out/cli.d.ts +8 -5
- package/out/cli.d.ts.map +1 -1
- package/out/cli.js +42 -21
- package/out/cli.js.map +1 -1
- package/out/commands/FetchGame.d.ts.map +1 -1
- package/out/commands/FetchGame.js +28 -54
- package/out/commands/FetchGame.js.map +1 -1
- package/out/commands/FetchProfilePhoto.d.ts +3 -0
- package/out/commands/FetchProfilePhoto.d.ts.map +1 -0
- package/out/commands/FetchProfilePhoto.js +31 -0
- package/out/commands/FetchProfilePhoto.js.map +1 -0
- package/out/commands/FetchUser.d.ts.map +1 -1
- package/out/commands/FetchUser.js +26 -52
- package/out/commands/FetchUser.js.map +1 -1
- package/out/commands/FetchUserPhoto.d.ts +3 -0
- package/out/commands/FetchUserPhoto.d.ts.map +1 -0
- package/out/commands/FetchUserPhoto.js +45 -0
- package/out/commands/FetchUserPhoto.js.map +1 -0
- package/out/util/TokenManager.d.ts.map +1 -1
- package/out/util/TokenManager.js +14 -1
- package/out/util/TokenManager.js.map +1 -1
- package/out/util/platform/FetchGame.d.ts +6 -0
- package/out/util/platform/FetchGame.d.ts.map +1 -0
- package/out/util/platform/FetchGame.js +14 -0
- package/out/util/platform/FetchGame.js.map +1 -0
- package/out/util/platform/FetchUser.d.ts +6 -0
- package/out/util/platform/FetchUser.d.ts.map +1 -0
- package/out/util/platform/FetchUser.js +14 -0
- package/out/util/platform/FetchUser.js.map +1 -0
- package/package.json +5 -2
- package/.github/workflows/npm-publish.yml +0 -22
- package/src/AirshipTypes.ts +0 -63
- package/src/cli.ts +0 -68
- package/src/commands/CommandTypes.ts +0 -8
- package/src/commands/FetchGame.ts +0 -77
- package/src/commands/FetchUser.ts +0 -75
- package/src/commands/Help.ts +0 -37
- package/src/util/Styles.ts +0 -20
- package/src/util/TokenManager.ts +0 -22
- package/tsconfig.json +0 -42
package/README.MD
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
# Airship CLI
|
|
2
|
-
|
|
2
|
+
Interact with the Airship.gg API from your Terminal!
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
## How to Use
|
|
5
|
+
Simply install the NPM Package
|
|
6
|
+
|
|
7
|
+
`npm install -g airship-cli`
|
|
8
|
+
|
|
9
|
+
and run the command, `airship`!
|
|
10
|
+
|
|
11
|
+
# Development Stats
|
|
12
|
+

|
|
13
|
+
[](https://www.npmjs.com/package/airship-cli)
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
5
17
|
|
|
6
18
|
# License
|
|
7
19
|
|
|
8
|
-
Copyright (c) 2026 Max McDaniel
|
|
9
|
-
Licensed under the GPL 3.0 license.
|
|
20
|
+
Copyright (c) 2026 Max McDaniel - Licensed under the GPL 3.0 license.
|
package/out/AirshipTypes.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export type AirshipUser = {
|
|
|
7
7
|
uid: string;
|
|
8
8
|
username: string;
|
|
9
9
|
usernameLower: string;
|
|
10
|
-
statusText
|
|
11
|
-
profileImageId
|
|
12
|
-
lastOnlineTime
|
|
10
|
+
statusText?: string;
|
|
11
|
+
profileImageId?: string;
|
|
12
|
+
lastOnlineTime?: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
export type AirshipError = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirshipTypes.d.ts","sourceRoot":"","sources":["../src/AirshipTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAA;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,aAA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ACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;QAC9C,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;QACpC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,KAAK,EAAE,QAAQ,EAAE,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,YAAY,EAAE,mBAAmB,CAAA;KACpC,CAAA;CACJ,CAAC"}
|
package/out/cli.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
2
|
+
import type { CLICommand } from './commands/CommandTypes.js';
|
|
3
|
+
interface CommandMap {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
[key: string]: CLICommand;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const commandMap: CommandMap;
|
|
7
9
|
export declare function StartTool(): Promise<void>;
|
|
8
10
|
export declare function RestartTool(): Promise<void>;
|
|
11
|
+
export {};
|
|
9
12
|
//# sourceMappingURL=cli.d.ts.map
|
package/out/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAUA,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,UAAU,UAAU;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAC5B,CAAA;CACJ;AAGD,eAAO,MAAM,UAAU,EAAE,UAWxB,CAAC;AAEF,wBAAsB,SAAS,kBAK9B;AAED,wBAAsB,WAAW,kBAYhC"}
|
package/out/cli.js
CHANGED
|
@@ -6,10 +6,20 @@ import { helpCommand } from './commands/Help.js';
|
|
|
6
6
|
import { fetchUserCommand } from './commands/FetchUser.js';
|
|
7
7
|
import { fetchGameCommand } from './commands/FetchGame.js';
|
|
8
8
|
import { setTimeout } from 'node:timers/promises';
|
|
9
|
+
import { FetchProfilePhotoCommand } from './commands/FetchProfilePhoto.js';
|
|
10
|
+
;
|
|
11
|
+
// TODO: Make default category
|
|
9
12
|
export const commandMap = {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/* "default": {
|
|
14
|
+
"Help": helpCommand
|
|
15
|
+
}, */
|
|
16
|
+
"Users": {
|
|
17
|
+
"Fetch User": fetchUserCommand,
|
|
18
|
+
"Fetch Profile Photo": FetchProfilePhotoCommand
|
|
19
|
+
},
|
|
20
|
+
"Games": {
|
|
21
|
+
"Fetch Game": fetchGameCommand
|
|
22
|
+
}
|
|
13
23
|
};
|
|
14
24
|
export async function StartTool() {
|
|
15
25
|
PrintTitle();
|
|
@@ -27,6 +37,7 @@ export async function RestartTool() {
|
|
|
27
37
|
;
|
|
28
38
|
}
|
|
29
39
|
catch (err) {
|
|
40
|
+
console.error(err);
|
|
30
41
|
process.exit(0);
|
|
31
42
|
}
|
|
32
43
|
;
|
|
@@ -34,36 +45,46 @@ export async function RestartTool() {
|
|
|
34
45
|
;
|
|
35
46
|
async function PromptCommand() {
|
|
36
47
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
PrintError("An authenticated Airship installation is required to run this command!");
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
;
|
|
48
|
-
await setTimeout(250);
|
|
49
|
-
cmdFunction.execute();
|
|
50
|
-
return;
|
|
48
|
+
const categoryAnswer = await select({ message: "Select a command category:", choices: Object.keys(commandMap) });
|
|
49
|
+
const cmdCategories = Object.entries(commandMap);
|
|
50
|
+
for (let [categoryName, commands] of cmdCategories) {
|
|
51
|
+
// TODO: Make back command
|
|
52
|
+
if (categoryAnswer === categoryName) {
|
|
53
|
+
const cmdAnswer = await select({ message: "What would you like to do?", choices: Object.keys(commands) });
|
|
54
|
+
HandleCommand(commands[cmdAnswer], cmdAnswer);
|
|
51
55
|
}
|
|
52
56
|
;
|
|
53
57
|
}
|
|
54
58
|
;
|
|
55
59
|
}
|
|
56
60
|
catch (err) {
|
|
61
|
+
console.error(err);
|
|
57
62
|
process.exit(0);
|
|
58
63
|
}
|
|
59
64
|
;
|
|
60
65
|
}
|
|
61
66
|
;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
async function HandleCommand(command, answer) {
|
|
68
|
+
const cmdName = command.displayName;
|
|
69
|
+
const requiresToken = command.requiresToken;
|
|
70
|
+
const cmdFunction = command;
|
|
71
|
+
if (answer === cmdName) {
|
|
72
|
+
if (AirshipToken === undefined && requiresToken) {
|
|
73
|
+
PrintError("An authenticated Airship installation is required to run this command!");
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
;
|
|
77
|
+
await setTimeout(250);
|
|
78
|
+
cmdFunction.execute();
|
|
79
|
+
return;
|
|
65
80
|
}
|
|
66
81
|
;
|
|
67
|
-
}
|
|
82
|
+
}
|
|
83
|
+
;
|
|
84
|
+
// process.on("exit", (signal) => {
|
|
85
|
+
// if (signal === 0) {
|
|
86
|
+
// console.clear();
|
|
87
|
+
// };
|
|
88
|
+
// });
|
|
68
89
|
StartTool();
|
|
69
90
|
//# sourceMappingURL=cli.js.map
|
package/out/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAO1E,CAAC;AAEF,8BAA8B;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAe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I,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAE1G,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAE,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC;YAAA,CAAC;QACN,CAAC;QAAA,CAAC;IACN,CAAC;IAAC,OAAM,GAAG,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAAA,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,KAAK,UAAU,aAAa,CAAC,OAAmB,EAAE,MAAc;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IACpC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC5C,MAAM,WAAW,GAAG,OAAO,CAAA;IAE3B,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACrB,IAAI,YAAY,KAAK,SAAS,IAAI,aAAa,EAAE,CAAC;YAC9C,UAAU,CAAC,wEAAwE,CAAC,CAAC;YACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QAAA,CAAC;QAEF,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACtB,WAAW,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO;IACX,CAAC;IAAA,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,mCAAmC;AACnC,0BAA0B;AAC1B,2BAA2B;AAC3B,SAAS;AACT,MAAM;AAEN,SAAS,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchGame.d.ts","sourceRoot":"","sources":["../../src/commands/FetchGame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchGame.d.ts","sourceRoot":"","sources":["../../src/commands/FetchGame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,eAAO,MAAM,gBAAgB,EAAE,UAsC9B,CAAC"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { input, select
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { setTimeout } from "node:timers/promises";
|
|
1
|
+
import { input, select } from '@inquirer/prompts';
|
|
2
|
+
import { RestartTool } from "../cli.js";
|
|
3
|
+
import { FetchGame, gameApiMap } from "../util/platform/FetchGame.js";
|
|
4
|
+
import { PrintError } from "../util/Styles.js";
|
|
6
5
|
import chalk from "chalk";
|
|
7
|
-
const apiMap = {
|
|
8
|
-
"Slug": "https://api.airship.gg/content/games/slug/",
|
|
9
|
-
"GameId": "https://api.airship.gg/content/games/game-id/"
|
|
10
|
-
};
|
|
11
6
|
export const fetchGameCommand = {
|
|
12
7
|
name: "fetch-game",
|
|
13
8
|
displayName: "Fetch Game",
|
|
@@ -15,54 +10,33 @@ export const fetchGameCommand = {
|
|
|
15
10
|
usage: "fetch-game <method: slug | gameId> <identifier: string>",
|
|
16
11
|
requiresToken: false,
|
|
17
12
|
execute: async () => {
|
|
18
|
-
|
|
19
|
-
PrintHeader("Fetch Game");
|
|
20
|
-
await setTimeout(250);
|
|
21
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
22
|
-
"Slug",
|
|
23
|
-
"GameId"
|
|
24
|
-
] });
|
|
25
|
-
const gameIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
13
|
+
const fetchMethod = await select({ message: "Which method would you like to use?", choices: Object.keys(gameApiMap) });
|
|
26
14
|
const dataType = await select({ message: "How would you like your data?", choices: ["Simple", "Verbose"] });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(`${chalk.green("Developer")}: ${userData.organization.name}`);
|
|
49
|
-
console.log(`${chalk.green("Description")}: ${userData.description || ""}\n`);
|
|
50
|
-
break;
|
|
51
|
-
case "Verbose":
|
|
52
|
-
console.dir(result, { depth: null });
|
|
53
|
-
console.log();
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
;
|
|
57
|
-
})).catch((err) => {
|
|
58
|
-
PrintError(err);
|
|
59
|
-
});
|
|
60
|
-
RestartTool();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
;
|
|
15
|
+
const gameIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
16
|
+
const result = await FetchGame(fetchMethod, gameIdentifier);
|
|
17
|
+
const entries = Object.entries(result);
|
|
18
|
+
const keys = Object.keys(result);
|
|
19
|
+
if (entries.length === 0 || keys.length === 0 || "error" in result) {
|
|
20
|
+
return PrintError(`Invalid ${fetchMethod}`);
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
const game = result.game;
|
|
24
|
+
switch (dataType) {
|
|
25
|
+
case "Simple":
|
|
26
|
+
console.log(`\n${chalk.green("Game Id")}: ${game.id}`);
|
|
27
|
+
console.log(`${chalk.green("Name")}: ${game.name}`);
|
|
28
|
+
console.log(`${chalk.green("Slug")}: ${game.slug || ""}`);
|
|
29
|
+
console.log(`${chalk.green("Developer")}: ${game.organization.name}`);
|
|
30
|
+
console.log(`${chalk.green("Description")}: ${game.description || ""}\n`);
|
|
31
|
+
break;
|
|
32
|
+
case "Verbose":
|
|
33
|
+
console.dir(result, { depth: null });
|
|
34
|
+
console.log();
|
|
35
|
+
break;
|
|
64
36
|
}
|
|
65
37
|
;
|
|
38
|
+
RestartTool();
|
|
39
|
+
return;
|
|
66
40
|
}
|
|
67
41
|
};
|
|
68
42
|
//# sourceMappingURL=FetchGame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchGame.js","sourceRoot":"","sources":["../../src/commands/FetchGame.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"FetchGame.js","sourceRoot":"","sources":["../../src/commands/FetchGame.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAe;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE,yDAAyD;IAChE,aAAa,EAAE,KAAK;IACpB,OAAO,EAAE,KAAK,IAAI,EAAE;QAChB,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,EAAE,OAAO,EAAE,qCAAqC,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAC,CAAC,CAAC;QACtH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,OAAO,EAAE,CAAE,QAAQ,EAAE,SAAS,CAAE,EAAE,CAAC,CAAC;QAC9G,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,oBAAoB,WAAW,GAAG,EAAE,CAAC,CAAC;QAEpF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,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@@
|
|
|
1
|
+
{"version":3,"file":"FetchProfilePhoto.d.ts","sourceRoot":"","sources":["../../src/commands/FetchProfilePhoto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,eAAO,MAAM,wBAAwB,EAAE,UA2BtC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PrintError } from "../util/Styles.js";
|
|
2
|
+
import { input, select } from "@inquirer/prompts";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { RestartTool } from "../cli.js";
|
|
5
|
+
import { FetchUser, userApiMap } from "../util/platform/FetchUser.js";
|
|
6
|
+
export const FetchProfilePhotoCommand = {
|
|
7
|
+
name: "fetch-profile-photo",
|
|
8
|
+
displayName: "Fetch Profile Photo",
|
|
9
|
+
description: "Returns the profile picture of the given user.",
|
|
10
|
+
usage: "<method: username | userId> <identifier: string>",
|
|
11
|
+
requiresToken: false,
|
|
12
|
+
execute: async () => {
|
|
13
|
+
const fetchMethod = await select({ message: "Which method would you like to use?", choices: Object.keys(userApiMap) });
|
|
14
|
+
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
15
|
+
const result = await FetchUser(fetchMethod, userIdentifier);
|
|
16
|
+
const entries = Object.entries(result);
|
|
17
|
+
const keys = Object.keys(result);
|
|
18
|
+
if (entries.length === 0 || keys.length === 0 || "error" in result) {
|
|
19
|
+
return PrintError(`Invalid ${fetchMethod}`);
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
const user = result.user;
|
|
23
|
+
const profileImageId = user.profileImageId;
|
|
24
|
+
if (!profileImageId)
|
|
25
|
+
return PrintError("User has no profile image!");
|
|
26
|
+
console.log(chalk.green(`\nhttps://cdn.airship.gg/images/${profileImageId}\n`));
|
|
27
|
+
RestartTool();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=FetchProfilePhoto.js.map
|
|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AAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC3C,IAAI,CAAC,cAAc;YAAE,OAAO,UAAU,CAAC,4BAA4B,CAAC,CAAC;QAErE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,mCAAmC,cAAc,IAAI,CAAC,CAAC,CAAC;QAEhF,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchUser.d.ts","sourceRoot":"","sources":["../../src/commands/FetchUser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchUser.d.ts","sourceRoot":"","sources":["../../src/commands/FetchUser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,eAAO,MAAM,gBAAgB,EAAE,UAmC9B,CAAC"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { input, select
|
|
2
|
-
import { PrintError
|
|
3
|
-
import {
|
|
4
|
-
import { RestartTool, StartTool } from "../cli.js";
|
|
1
|
+
import { input, select } from '@inquirer/prompts';
|
|
2
|
+
import { PrintError } from '../util/Styles.js';
|
|
3
|
+
import { RestartTool } from "../cli.js";
|
|
5
4
|
import chalk from "chalk";
|
|
6
|
-
import {
|
|
7
|
-
const apiMap = {
|
|
8
|
-
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
9
|
-
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
10
|
-
};
|
|
5
|
+
import { FetchUser, userApiMap } from "../util/platform/FetchUser.js";
|
|
11
6
|
export const fetchUserCommand = {
|
|
12
7
|
name: "fetch-user",
|
|
13
8
|
displayName: "Fetch User",
|
|
@@ -15,52 +10,31 @@ export const fetchUserCommand = {
|
|
|
15
10
|
usage: "fetch-user <method: username | userId> <identifier: string>",
|
|
16
11
|
requiresToken: false,
|
|
17
12
|
execute: async () => {
|
|
18
|
-
|
|
19
|
-
PrintHeader("Fetch User");
|
|
20
|
-
await setTimeout(250);
|
|
21
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
22
|
-
"Username",
|
|
23
|
-
"UserId"
|
|
24
|
-
] });
|
|
25
|
-
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
13
|
+
const fetchMethod = await select({ message: "Which method would you like to use?", choices: Object.keys(userApiMap) });
|
|
26
14
|
const dataType = await select({ message: "How would you like your data?", choices: ["Simple", "Verbose"] });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.log(`${chalk.green("Username")}: ${userData.username}`);
|
|
47
|
-
console.log(`${chalk.green("Status Text")}: ${userData.statusText || ""}\n`);
|
|
48
|
-
break;
|
|
49
|
-
case "Verbose":
|
|
50
|
-
console.dir(result, { depth: null });
|
|
51
|
-
console.log();
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
;
|
|
55
|
-
})).catch((err) => {
|
|
56
|
-
PrintError(err);
|
|
57
|
-
});
|
|
58
|
-
RestartTool();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
;
|
|
15
|
+
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
16
|
+
const result = await FetchUser(fetchMethod, userIdentifier);
|
|
17
|
+
const entries = Object.entries(result);
|
|
18
|
+
const keys = Object.keys(result);
|
|
19
|
+
if (entries.length === 0 || keys.length === 0 || "error" in result) {
|
|
20
|
+
return PrintError(`Invalid ${fetchMethod}`);
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
const user = result.user;
|
|
24
|
+
switch (dataType) {
|
|
25
|
+
case "Simple":
|
|
26
|
+
console.log(`\n${chalk.green("User Id")}: ${user.uid}`);
|
|
27
|
+
console.log(`${chalk.green("Username")}: ${user.username}`);
|
|
28
|
+
console.log(`${chalk.green("Status Text")}: ${user.statusText || ""}\n`);
|
|
29
|
+
break;
|
|
30
|
+
case "Verbose":
|
|
31
|
+
console.dir(result, { depth: null });
|
|
32
|
+
console.log();
|
|
33
|
+
break;
|
|
62
34
|
}
|
|
63
35
|
;
|
|
36
|
+
RestartTool();
|
|
37
|
+
return;
|
|
64
38
|
}
|
|
65
39
|
};
|
|
66
40
|
//# sourceMappingURL=FetchUser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchUser.js","sourceRoot":"","sources":["../../src/commands/FetchUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"FetchUser.js","sourceRoot":"","sources":["../../src/commands/FetchUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,CAAC,MAAM,gBAAgB,GAAe;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE,6DAA6D;IACpE,aAAa,EAAE,KAAK;IACpB,OAAO,EAAE,KAAK,IAAI,EAAE;QAChB,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,EAAE,OAA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GAAG,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrC,OAAO,CAAC,GAAG,EAAE,CAAC;gBACd,MAAM;QACd,CAAC;QAAA,CAAC;QAEF,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchUserPhoto.d.ts","sourceRoot":"","sources":["../../src/commands/FetchUserPhoto.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAYpD,eAAO,MAAM,qBAAqB,EAAE,UAuCnC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { setTimeout } from "node:timers/promises";
|
|
2
|
+
import { PrintError, PrintHeader } from "../util/Styles.js";
|
|
3
|
+
import { input, select } from "@inquirer/prompts";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { RestartTool } from "../cli.js";
|
|
6
|
+
const apiMap = {
|
|
7
|
+
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
8
|
+
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
9
|
+
};
|
|
10
|
+
export const FetchUserPhotoCommand = {
|
|
11
|
+
name: "fetch-profile-photo",
|
|
12
|
+
displayName: "Fetch Profile Photo",
|
|
13
|
+
description: "Returns the profile picture of the given user.",
|
|
14
|
+
usage: "<method: username | userId> <identifier: string>",
|
|
15
|
+
requiresToken: false,
|
|
16
|
+
execute: async () => {
|
|
17
|
+
const fetchMethod = await select({ message: "Which method would you like to use?", choices: Object.keys(apiMap) });
|
|
18
|
+
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
19
|
+
// for (let [ method, url ] of Object.entries(apiMap)) {
|
|
20
|
+
// if (method === fetchMethod) {
|
|
21
|
+
// fetch(url )
|
|
22
|
+
// };
|
|
23
|
+
// };
|
|
24
|
+
fetch(apiMap[fetchMethod] + userIdentifier, {
|
|
25
|
+
method: "GET"
|
|
26
|
+
}).then((raw) => raw.text().then((data) => {
|
|
27
|
+
const result = JSON.parse(data);
|
|
28
|
+
const keys = Object.keys(result);
|
|
29
|
+
const entries = Object.entries(result);
|
|
30
|
+
if (entries.length === 0 || "error" in result || keys.length === 0) {
|
|
31
|
+
PrintError(`Invalid ${fetchMethod}!`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
;
|
|
35
|
+
const user = result.user;
|
|
36
|
+
const profileImageId = user.profileImageId;
|
|
37
|
+
if (!profileImageId)
|
|
38
|
+
return PrintError("User has no profile image!");
|
|
39
|
+
console.log(chalk.green(`\nhttps://cdn.airship.gg/images/${profileImageId}\n`));
|
|
40
|
+
}));
|
|
41
|
+
RestartTool();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=FetchUserPhoto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchUserPhoto.js","sourceRoot":"","sources":["../../src/commands/FetchUserPhoto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,MAAM,GAA8B;IACtC,UAAU,EAAE,8DAA8D;IAC1E,QAAQ,EAAE,oDAAoD;CACjE,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAe;IAC7C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE,kDAAkD;IACzD,aAAa,EAAE,KAAK;IACpB,OAAO,EAA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EJ,WAAW,EAAE,CAAC;QAEd,OAAO;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenManager.d.ts","sourceRoot":"","sources":["../../src/util/TokenManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TokenManager.d.ts","sourceRoot":"","sources":["../../src/util/TokenManager.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,YAAY,oBAAsB,CAAC"}
|
package/out/util/TokenManager.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import { PrintError } from './Styles.js';
|
|
3
|
-
|
|
3
|
+
import path from 'path';
|
|
4
|
+
// Ya'know, this is probably horrific but who cares!
|
|
5
|
+
const platformPathMap = {
|
|
6
|
+
"win32": path.join(`${process.env.APPDATA}`, `../../LocalLow`),
|
|
7
|
+
"darwin": path.join(`${process.env.HOME}`, "Library", "Preferences"),
|
|
8
|
+
"linux": path.join(`${process.env.HOME}`, ".steam/steam/steamapps/compatdata/2381730/pfx/drive_c/users/steamuser/AppData/LocalLow")
|
|
9
|
+
};
|
|
10
|
+
function GetApplicationPath() {
|
|
11
|
+
const platform = process.platform;
|
|
12
|
+
const applicationPath = platformPathMap[platform];
|
|
13
|
+
return applicationPath;
|
|
14
|
+
}
|
|
15
|
+
;
|
|
4
16
|
function FetchAirshipToken() {
|
|
5
17
|
let jsonData;
|
|
18
|
+
const airshipAccountPath = path.join(GetApplicationPath() + `/Easy/Airship/account.json`);
|
|
6
19
|
try {
|
|
7
20
|
const accountsFile = fs.readFileSync(airshipAccountPath);
|
|
8
21
|
jsonData = JSON.parse(accountsFile.toString("utf8"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenManager.js","sourceRoot":"","sources":["../../src/util/TokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,UAAU,EAA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C;IAEF,OAAO,QAAQ,CAAC,YAAY,CAAC;AACjC,CAAC;AAAA,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AirshipError, AirshipGame } from "../../AirshipTypes.js";
|
|
2
|
+
export declare const gameApiMap: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function FetchGame(fetchMethod: string, gameIdentifier: string): Promise<AirshipGame | AirshipError>;
|
|
6
|
+
//# sourceMappingURL=FetchGame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchGame.d.ts","sourceRoot":"","sources":["../../../src/util/platform/FetchGame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEvE,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAG/C,CAAC;AAEF,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAQhH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const gameApiMap = {
|
|
2
|
+
"Slug": "https://api.airship.gg/content/games/slug/",
|
|
3
|
+
"GameId": "https://api.airship.gg/content/games/game-id/"
|
|
4
|
+
};
|
|
5
|
+
export async function FetchGame(fetchMethod, gameIdentifier) {
|
|
6
|
+
const request = await fetch(gameApiMap[fetchMethod] + gameIdentifier, {
|
|
7
|
+
method: "GET"
|
|
8
|
+
});
|
|
9
|
+
const data = await request.text();
|
|
10
|
+
const result = JSON.parse(data);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
;
|
|
14
|
+
//# sourceMappingURL=FetchGame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchGame.js","sourceRoot":"","sources":["../../../src/util/platform/FetchGame.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAA8B;IACjD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,+CAA+C;CAC5D,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,WAAmB,EAAE,cAAsB;IACvE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,cAAc,EAAE;QAClE,MAAM,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA+B,CAAC;IAE9D,OAAO,MAAM,CAAC;AAClB,CAAC;AAAA,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AirshipError, AirshipUser } from "../../AirshipTypes.js";
|
|
2
|
+
export declare const userApiMap: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function FetchUser(fetchMethod: string, userIdentifier: string): Promise<AirshipUser | AirshipError>;
|
|
6
|
+
//# sourceMappingURL=FetchUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchUser.d.ts","sourceRoot":"","sources":["../../../src/util/platform/FetchUser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEvE,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAG/C,CAAC;AAEF,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAQhH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const userApiMap = {
|
|
2
|
+
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
3
|
+
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
4
|
+
};
|
|
5
|
+
export async function FetchUser(fetchMethod, userIdentifier) {
|
|
6
|
+
const request = await fetch(userApiMap[fetchMethod] + userIdentifier, {
|
|
7
|
+
method: "GET"
|
|
8
|
+
});
|
|
9
|
+
const data = await request.text();
|
|
10
|
+
const result = JSON.parse(data);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
;
|
|
14
|
+
//# sourceMappingURL=FetchUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetchUser.js","sourceRoot":"","sources":["../../../src/util/platform/FetchUser.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAA8B;IACjD,UAAU,EAAE,8DAA8D;IAC1E,QAAQ,EAAE,oDAAoD;CACjE,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,WAAmB,EAAE,cAAsB;IACvE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,cAAc,EAAE;QAClE,MAAM,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA+B,CAAC;IAE9D,OAAO,MAAM,CAAC;AAClB,CAAC;AAAA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "airship-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A CLI Tool to interact with Airship's API endpoints.",
|
|
5
5
|
"main": "out/cli.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"airship": "out/cli.js"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"out/"
|
|
11
|
+
],
|
|
9
12
|
"type": "module",
|
|
10
13
|
"scripts": {
|
|
11
14
|
"tsc": "tsc --w"
|
|
@@ -21,4 +24,4 @@
|
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@types/node": "^25.0.10"
|
|
23
26
|
}
|
|
24
|
-
}
|
|
27
|
+
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: Public NPM Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
id-token: write
|
|
9
|
-
contents: read
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
publish:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
|
|
17
|
-
- uses: actions/setup-node@v4
|
|
18
|
-
with:
|
|
19
|
-
node-version: '24'
|
|
20
|
-
registry-url: 'https://registry.npmjs.org'
|
|
21
|
-
- run: npm ci
|
|
22
|
-
- run: npm publish
|
package/src/AirshipTypes.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export type AccountInfo = {
|
|
2
|
-
refreshToken: string,
|
|
3
|
-
time: number
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type AirshipUser = {
|
|
7
|
-
user: {
|
|
8
|
-
uid: string,
|
|
9
|
-
username: string,
|
|
10
|
-
usernameLower: string,
|
|
11
|
-
statusText: string,
|
|
12
|
-
profileImageId: string,
|
|
13
|
-
lastOnlineTime: string
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type AirshipError = {
|
|
18
|
-
message: string[],
|
|
19
|
-
error: string,
|
|
20
|
-
statusCode: number
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type AirshipOrganization = {
|
|
24
|
-
id: string,
|
|
25
|
-
slug: string,
|
|
26
|
-
slugProperCase: string,
|
|
27
|
-
name: string,
|
|
28
|
-
description: string | null,
|
|
29
|
-
iconImageId: string,
|
|
30
|
-
createdAt: string,
|
|
31
|
-
adminBanned: boolean
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type GameLink = {
|
|
35
|
-
type: "DISCORD",
|
|
36
|
-
url: string
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type AirshipGame = {
|
|
40
|
-
game: {
|
|
41
|
-
id: string,
|
|
42
|
-
slug: string | null,
|
|
43
|
-
slugProperCase: string | null,
|
|
44
|
-
name: string,
|
|
45
|
-
description: string | null,
|
|
46
|
-
iconImageId: string,
|
|
47
|
-
organizationId: string,
|
|
48
|
-
createdAt: string,
|
|
49
|
-
visibility: "PUBLIC" | "UNLISTED" | "PRIVATE",
|
|
50
|
-
lastVersionUpdate: string,
|
|
51
|
-
archivedAt: string | null,
|
|
52
|
-
loadingScreenImageId: string | null,
|
|
53
|
-
logoImageId: string | null,
|
|
54
|
-
videoId: string | null,
|
|
55
|
-
links: GameLink[],
|
|
56
|
-
plays: number,
|
|
57
|
-
favorites: number,
|
|
58
|
-
plays24h: number,
|
|
59
|
-
uniquePlays24h: number,
|
|
60
|
-
platforms: string[],
|
|
61
|
-
organization: AirshipOrganization
|
|
62
|
-
}
|
|
63
|
-
};
|
package/src/cli.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { confirm, input, select } from '@inquirer/prompts';
|
|
4
|
-
import { PrintHeader, PrintError, PrintTitle } from './util/Styles.js';
|
|
5
|
-
import { AirshipToken } from './util/TokenManager.js';
|
|
6
|
-
import { helpCommand } from './commands/Help.js';
|
|
7
|
-
import { fetchUserCommand } from './commands/FetchUser.js';
|
|
8
|
-
import { fetchGameCommand } from './commands/FetchGame.js';
|
|
9
|
-
import { setTimeout } from 'node:timers/promises';
|
|
10
|
-
|
|
11
|
-
export const commandMap = {
|
|
12
|
-
"Help": helpCommand,
|
|
13
|
-
"Fetch User": fetchUserCommand,
|
|
14
|
-
"Fetch Game": fetchGameCommand
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export async function StartTool() {
|
|
18
|
-
PrintTitle();
|
|
19
|
-
|
|
20
|
-
await setTimeout(250);
|
|
21
|
-
PromptCommand();
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export async function RestartTool() {
|
|
25
|
-
try {
|
|
26
|
-
await setTimeout(800);
|
|
27
|
-
const restartTool = await confirm({ message: "Would you like to anything else?" });
|
|
28
|
-
|
|
29
|
-
if (restartTool) {
|
|
30
|
-
StartTool();
|
|
31
|
-
};
|
|
32
|
-
} catch(err) {
|
|
33
|
-
process.exit(0);
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
async function PromptCommand() {
|
|
38
|
-
try {
|
|
39
|
-
const answer = await select({ message: "What would you like to do?", choices: Object.keys(commandMap)});
|
|
40
|
-
|
|
41
|
-
for (let command of Object.entries(commandMap)) {
|
|
42
|
-
const cmdName = command[0];
|
|
43
|
-
const requiresToken = command[1].requiresToken;
|
|
44
|
-
const cmdFunction = command[1];
|
|
45
|
-
|
|
46
|
-
if (answer === cmdName) {
|
|
47
|
-
if (AirshipToken === undefined && requiresToken) {
|
|
48
|
-
PrintError("An authenticated Airship installation is required to run this command!");
|
|
49
|
-
process.exit(1);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
await setTimeout(250);
|
|
53
|
-
cmdFunction.execute();
|
|
54
|
-
return;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
} catch(err) {
|
|
58
|
-
process.exit(0);
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
process.on("exit", (signal) => {
|
|
63
|
-
if (signal === 0) {
|
|
64
|
-
console.clear();
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
StartTool();
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { CLICommand } from "./CommandTypes.js";
|
|
2
|
-
import { input, select, confirm } from '@inquirer/prompts';
|
|
3
|
-
import { PrintHeader, PrintError, PrintTitle } from '../util/Styles.js';
|
|
4
|
-
import { AirshipToken } from '../util/TokenManager.js';
|
|
5
|
-
import type { AirshipError, AirshipGame } from "../AirshipTypes.js";
|
|
6
|
-
import { RestartTool, StartTool } from "../cli.js";
|
|
7
|
-
import { setTimeout } from "node:timers/promises";
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
|
|
10
|
-
const apiMap = {
|
|
11
|
-
"Slug": "https://api.airship.gg/content/games/slug/",
|
|
12
|
-
"GameId": "https://api.airship.gg/content/games/game-id/"
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const fetchGameCommand: CLICommand = {
|
|
16
|
-
name: "fetch-game",
|
|
17
|
-
displayName: "Fetch Game",
|
|
18
|
-
description: "Returns data related to the specified game.",
|
|
19
|
-
usage: "fetch-game <method: slug | gameId> <identifier: string>",
|
|
20
|
-
requiresToken: false,
|
|
21
|
-
execute: async () => {
|
|
22
|
-
console.clear();
|
|
23
|
-
PrintHeader("Fetch Game");
|
|
24
|
-
|
|
25
|
-
await setTimeout(250);
|
|
26
|
-
|
|
27
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
28
|
-
"Slug",
|
|
29
|
-
"GameId"
|
|
30
|
-
]});
|
|
31
|
-
|
|
32
|
-
const gameIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
33
|
-
const dataType = await select({ message: "How would you like your data?", choices: [ "Simple", "Verbose" ] });
|
|
34
|
-
|
|
35
|
-
for (let data of Object.entries(apiMap)) {
|
|
36
|
-
const method = data[0];
|
|
37
|
-
const url = data[1];
|
|
38
|
-
|
|
39
|
-
if (method === fetchMethod) {
|
|
40
|
-
fetch(url + gameIdentifier, {
|
|
41
|
-
method: "GET"
|
|
42
|
-
}).then(raw => raw.text().then(data => {
|
|
43
|
-
const result = JSON.parse(data) as AirshipGame | AirshipError | {};
|
|
44
|
-
const keys = Object.keys(result);
|
|
45
|
-
const entries = Object.entries(result);
|
|
46
|
-
|
|
47
|
-
if (entries.length === 0 || "error" in result || keys.length === 0) {
|
|
48
|
-
PrintError(`Invalid ${fetchMethod}!`);
|
|
49
|
-
return;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
switch(dataType) {
|
|
53
|
-
case "Simple":
|
|
54
|
-
const userData = (result as AirshipGame).game;
|
|
55
|
-
|
|
56
|
-
console.log(`\n${chalk.green("Game Id")}: ${userData.id}`);
|
|
57
|
-
console.log(`${chalk.green("Name")}: ${userData.name}`);
|
|
58
|
-
console.log(`${chalk.green("Slug")}: ${userData.slug || ""}`);
|
|
59
|
-
console.log(`${chalk.green("Developer")}: ${userData.organization.name}`);
|
|
60
|
-
console.log(`${chalk.green("Description")}: ${userData.description || ""}\n`);
|
|
61
|
-
break;
|
|
62
|
-
case "Verbose":
|
|
63
|
-
console.dir(result, { depth: null });
|
|
64
|
-
console.log();
|
|
65
|
-
break;
|
|
66
|
-
};
|
|
67
|
-
})).catch((err) => {
|
|
68
|
-
PrintError(err);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
RestartTool();
|
|
72
|
-
|
|
73
|
-
return;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { CLICommand } from "./CommandTypes.js";
|
|
2
|
-
import { input, select, confirm } from '@inquirer/prompts';
|
|
3
|
-
import { PrintError, PrintHeader, PrintTitle } from '../util/Styles.js';
|
|
4
|
-
import { AirshipToken } from '../util/TokenManager.js';
|
|
5
|
-
import type { AirshipUser, AirshipError } from "../AirshipTypes.js";
|
|
6
|
-
import { RestartTool, StartTool } from "../cli.js";
|
|
7
|
-
import chalk from "chalk";
|
|
8
|
-
import { setTimeout } from "node:timers/promises";
|
|
9
|
-
|
|
10
|
-
const apiMap = {
|
|
11
|
-
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
12
|
-
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const fetchUserCommand: CLICommand = {
|
|
16
|
-
name: "fetch-user",
|
|
17
|
-
displayName: "Fetch User",
|
|
18
|
-
description: "Returns data related to the specified user.",
|
|
19
|
-
usage: "fetch-user <method: username | userId> <identifier: string>",
|
|
20
|
-
requiresToken: false,
|
|
21
|
-
execute: async () => {
|
|
22
|
-
console.clear();
|
|
23
|
-
PrintHeader("Fetch User");
|
|
24
|
-
|
|
25
|
-
await setTimeout(250);
|
|
26
|
-
|
|
27
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
28
|
-
"Username",
|
|
29
|
-
"UserId"
|
|
30
|
-
]});
|
|
31
|
-
|
|
32
|
-
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
33
|
-
const dataType = await select({ message: "How would you like your data?", choices: [ "Simple", "Verbose" ] });
|
|
34
|
-
|
|
35
|
-
for (let data of Object.entries(apiMap)) {
|
|
36
|
-
const method = data[0];
|
|
37
|
-
const url = data[1];
|
|
38
|
-
|
|
39
|
-
if (method === fetchMethod) {
|
|
40
|
-
fetch(url + userIdentifier, {
|
|
41
|
-
method: "GET"
|
|
42
|
-
}).then(raw => raw.text().then(data => {
|
|
43
|
-
const result = JSON.parse(data) as AirshipUser | AirshipError | {};
|
|
44
|
-
const keys = Object.keys(result);
|
|
45
|
-
const entries = Object.entries(result);
|
|
46
|
-
|
|
47
|
-
if (entries.length === 0 || "error" in result || keys.length === 0) {
|
|
48
|
-
PrintError(`Invalid ${fetchMethod}!`);
|
|
49
|
-
return;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
switch(dataType) {
|
|
53
|
-
case "Simple":
|
|
54
|
-
const userData = (result as AirshipUser).user;
|
|
55
|
-
|
|
56
|
-
console.log(`\n${chalk.green("User Id")}: ${userData.uid}`);
|
|
57
|
-
console.log(`${chalk.green("Username")}: ${userData.username}`);
|
|
58
|
-
console.log(`${chalk.green("Status Text")}: ${userData.statusText || ""}\n`);
|
|
59
|
-
break;
|
|
60
|
-
case "Verbose":
|
|
61
|
-
console.dir(result, { depth: null });
|
|
62
|
-
console.log();
|
|
63
|
-
break;
|
|
64
|
-
};
|
|
65
|
-
})).catch((err) => {
|
|
66
|
-
PrintError(err);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
RestartTool();
|
|
70
|
-
|
|
71
|
-
return;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
};
|
package/src/commands/Help.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { CLICommand } from "./CommandTypes.js";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { input, select, confirm } from '@inquirer/prompts';
|
|
4
|
-
import { PrintHeader, PrintError, PrintTitle } from '../util/Styles.js';
|
|
5
|
-
import { AirshipToken } from '../util/TokenManager.js';
|
|
6
|
-
import { commandMap, StartTool } from "../cli.js";
|
|
7
|
-
|
|
8
|
-
export const helpCommand: CLICommand = {
|
|
9
|
-
name: "help",
|
|
10
|
-
displayName: "Help",
|
|
11
|
-
description: "Returns the usage of a command.",
|
|
12
|
-
usage: "help <command: string>",
|
|
13
|
-
requiresToken: false,
|
|
14
|
-
execute: async () => {
|
|
15
|
-
const commandSelect = await select({ message: "Which command do you need help with?", choices: Object.keys(commandMap).slice(1) });
|
|
16
|
-
|
|
17
|
-
for (let command of Object.entries(commandMap)) {
|
|
18
|
-
if (command[0] === commandSelect) {
|
|
19
|
-
console.log(`\n`);
|
|
20
|
-
console.log(`${chalk.bold(chalk.green(`${commandSelect} Help:`))}`);
|
|
21
|
-
console.log(`- Description: ${chalk.gray(command[1].description)}`);
|
|
22
|
-
console.log(`- Usage: ${chalk.gray(command[1].usage)}`);
|
|
23
|
-
console.log(`\n`);
|
|
24
|
-
|
|
25
|
-
setTimeout(async () => {
|
|
26
|
-
const restartTool = await confirm({ message: "Would you like to anything else?" });
|
|
27
|
-
|
|
28
|
-
if (restartTool) {
|
|
29
|
-
StartTool();
|
|
30
|
-
};
|
|
31
|
-
}, 0);
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
};
|
package/src/util/Styles.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import figlet from "figlet";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
|
|
4
|
-
export async function PrintHeader(message: string) {
|
|
5
|
-
const textArt = await figlet.text(message);
|
|
6
|
-
const coloredText = chalk.blue(textArt);
|
|
7
|
-
|
|
8
|
-
console.log(chalk.bold(coloredText));
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export async function PrintError(message: string) {
|
|
12
|
-
const coloredText = chalk.red(message);
|
|
13
|
-
|
|
14
|
-
console.log(chalk.bold(coloredText));
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function PrintTitle() {
|
|
18
|
-
console.clear();
|
|
19
|
-
PrintHeader(`Airship CLI\n\n`);
|
|
20
|
-
};
|
package/src/util/TokenManager.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import type { AccountInfo } from '../AirshipTypes.js';
|
|
3
|
-
import { PrintError } from './Styles.js';
|
|
4
|
-
|
|
5
|
-
const airshipAccountPath = process.env.APPDATA + `../../LocalLow/Easy/Airship/account.json`;
|
|
6
|
-
|
|
7
|
-
function FetchAirshipToken(): string | undefined {
|
|
8
|
-
let jsonData: AccountInfo;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const accountsFile = fs.readFileSync(airshipAccountPath);
|
|
12
|
-
|
|
13
|
-
jsonData = JSON.parse(accountsFile.toString("utf8"));
|
|
14
|
-
} catch(err) {
|
|
15
|
-
PrintError("No Airship Installation Found!");
|
|
16
|
-
return undefined;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return jsonData.refreshToken;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const AirshipToken = FetchAirshipToken();
|
package/tsconfig.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
// File Layout
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"outDir": "./out",
|
|
7
|
-
|
|
8
|
-
// Environment Settings
|
|
9
|
-
// See also https://aka.ms/tsconfig/module
|
|
10
|
-
"module": "nodenext",
|
|
11
|
-
"target": "esnext",
|
|
12
|
-
// For nodejs:
|
|
13
|
-
// "lib": ["esnext"],
|
|
14
|
-
"types": ["node"],
|
|
15
|
-
|
|
16
|
-
// Other Outputs
|
|
17
|
-
"sourceMap": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"declarationMap": true,
|
|
20
|
-
|
|
21
|
-
// Stricter Typechecking Options
|
|
22
|
-
"noUncheckedIndexedAccess": true,
|
|
23
|
-
"exactOptionalPropertyTypes": true,
|
|
24
|
-
|
|
25
|
-
// Style Options
|
|
26
|
-
// "noImplicitReturns": true,
|
|
27
|
-
// "noImplicitOverride": true,
|
|
28
|
-
// "noUnusedLocals": true,
|
|
29
|
-
// "noUnusedParameters": true,
|
|
30
|
-
// "noFallthroughCasesInSwitch": true,
|
|
31
|
-
// "noPropertyAccessFromIndexSignature": true,
|
|
32
|
-
|
|
33
|
-
// Recommended Options
|
|
34
|
-
"strict": true,
|
|
35
|
-
"jsx": "react-jsx",
|
|
36
|
-
"verbatimModuleSyntax": true,
|
|
37
|
-
"isolatedModules": true,
|
|
38
|
-
"noUncheckedSideEffectImports": true,
|
|
39
|
-
"moduleDetection": "force",
|
|
40
|
-
"skipLibCheck": true,
|
|
41
|
-
}
|
|
42
|
-
}
|