airship-cli 1.0.1 → 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/LICENSE +673 -673
- package/README.MD +20 -57
- package/out/AirshipTypes.d.ts +4 -4
- package/out/AirshipTypes.d.ts.map +1 -1
- package/out/cli.d.ts +10 -7
- package/out/cli.d.ts.map +1 -1
- package/out/cli.js +72 -26
- package/out/cli.js.map +1 -1
- package/out/commands/CommandTypes.d.ts +1 -0
- package/out/commands/CommandTypes.d.ts.map +1 -1
- package/out/commands/FetchGame.d.ts.map +1 -1
- package/out/commands/FetchGame.js +30 -43
- 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 +28 -43
- 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/commands/{help.d.ts → Help.d.ts} +1 -1
- package/out/commands/Help.d.ts.map +1 -0
- package/out/commands/{help.js → Help.js} +4 -3
- package/out/commands/Help.js.map +1 -0
- package/out/util/TokenManager.d.ts +1 -1
- package/out/util/TokenManager.d.ts.map +1 -1
- package/out/util/TokenManager.js +21 -5
- 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 +4 -2
- package/.github/workflows/npm-publish.yml +0 -27
- package/out/Types.d.ts +0 -2
- package/out/Types.d.ts.map +0 -1
- package/out/Types.js +0 -2
- package/out/Types.js.map +0 -1
- package/out/commands/FetchUser copy.d.ts +0 -3
- package/out/commands/FetchUser copy.d.ts.map +0 -1
- package/out/commands/FetchUser copy.js +0 -46
- package/out/commands/FetchUser copy.js.map +0 -1
- package/out/commands/help.d.ts.map +0 -1
- package/out/commands/help.js.map +0 -1
- package/out/index.d.ts.map +0 -1
- package/out/index.js.map +0 -1
- package/src/AirshipTypes.ts +0 -63
- package/src/cli.ts +0 -49
- package/src/commands/CommandTypes.ts +0 -7
- package/src/commands/FetchGame.ts +0 -61
- package/src/commands/FetchUser.ts +0 -61
- package/src/commands/Help.ts +0 -36
- package/src/util/Styles.ts +0 -20
- package/src/util/TokenManager.ts +0 -20
- package/tsconfig.json +0 -42
|
@@ -2,14 +2,15 @@ import chalk from "chalk";
|
|
|
2
2
|
import { input, select, confirm } from '@inquirer/prompts';
|
|
3
3
|
import { PrintHeader, PrintError, PrintTitle } from '../util/Styles.js';
|
|
4
4
|
import { AirshipToken } from '../util/TokenManager.js';
|
|
5
|
-
import { commandMap,
|
|
5
|
+
import { commandMap, StartTool } from "../cli.js";
|
|
6
6
|
export const helpCommand = {
|
|
7
7
|
name: "help",
|
|
8
|
+
displayName: "Help",
|
|
8
9
|
description: "Returns the usage of a command.",
|
|
9
10
|
usage: "help <command: string>",
|
|
10
11
|
requiresToken: false,
|
|
11
12
|
execute: async () => {
|
|
12
|
-
const commandSelect = await select({ message: "Which command do you need help with?", choices:
|
|
13
|
+
const commandSelect = await select({ message: "Which command do you need help with?", choices: Object.keys(commandMap).slice(1) });
|
|
13
14
|
for (let command of Object.entries(commandMap)) {
|
|
14
15
|
if (command[0] === commandSelect) {
|
|
15
16
|
console.log(`\n`);
|
|
@@ -31,4 +32,4 @@ export const helpCommand = {
|
|
|
31
32
|
;
|
|
32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I,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;gBACpE,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACxD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAElB,UAAU,CAAC,KAAK,IAAI,EAAE;oBAClB,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC;oBAEnF,IAAI,WAAW,EAAE,CAAC;wBACd,SAAS,EAAE,CAAC;oBAChB,CAAC;oBAAA,CAAC;gBACN,CAAC,EAAE,CAAC,CAAC,CAAC;gBAEN,OAAO;YACX,CAAC;YAAA,CAAC;QACN,CAAC;QAAA,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const AirshipToken: string;
|
|
1
|
+
export declare const AirshipToken: string | undefined;
|
|
2
2
|
//# sourceMappingURL=TokenManager.d.ts.map
|
|
@@ -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,14 +1,30 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
17
|
+
let jsonData;
|
|
18
|
+
const airshipAccountPath = path.join(GetApplicationPath() + `/Easy/Airship/account.json`);
|
|
19
|
+
try {
|
|
20
|
+
const accountsFile = fs.readFileSync(airshipAccountPath);
|
|
21
|
+
jsonData = JSON.parse(accountsFile.toString("utf8"));
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
7
24
|
PrintError("No Airship Installation Found!");
|
|
8
|
-
|
|
25
|
+
return undefined;
|
|
9
26
|
}
|
|
10
27
|
;
|
|
11
|
-
const jsonData = JSON.parse(accountsFile.toString("utf8"));
|
|
12
28
|
return jsonData.refreshToken;
|
|
13
29
|
}
|
|
14
30
|
;
|
|
@@ -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,EAAE,MAAM,aAAa,CAAC;
|
|
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,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oDAAoD;AACpD,MAAM,eAAe,GAA8B;IAC/C,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC;IAC9D,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC;IACpE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAY,EAAE,wFAAwF,CAAC;CAChJ,CAAC;AAEF,SAAS,kBAAkB;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAElD,OAAO,eAAe,CAAC;AAC3B,CAAC;AAAA,CAAC;AAEF,SAAS,iBAAiB;IACtB,IAAI,QAAqB,CAAC;IAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,4BAA4B,CAAC,CAAC;IAE1F,IAAI,CAAC;QACD,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QAEzD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,CAAC;IAAC,OAAM,GAAG,EAAE,CAAC;QACV,UAAU,CAAC,gCAAgC,CAAC,CAAC;QAC7C,OAAO,SAAS,CAAC;IACrB,CAAC;IAAA,CAAC;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,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "airship-cli",
|
|
3
|
-
"version": "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
|
-
"test": "echo \"No test specified\"",
|
|
12
14
|
"tsc": "tsc --w"
|
|
13
15
|
},
|
|
14
16
|
"author": "Max McDaniel",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Public NPM Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
permissions:
|
|
11
|
-
id-token: write # Required for OIDC
|
|
12
|
-
contents: read
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
publish:
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: '24'
|
|
23
|
-
registry-url: 'https://registry.npmjs.org'
|
|
24
|
-
- run: npm ci
|
|
25
|
-
- run: npm run build --if-present
|
|
26
|
-
- run: npm test
|
|
27
|
-
- run: npm publish
|
package/out/Types.d.ts
DELETED
package/out/Types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../src/Types.ts"],"names":[],"mappings":""}
|
package/out/Types.js
DELETED
package/out/Types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../src/Types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FetchUser copy.d.ts","sourceRoot":"","sources":["../../src/commands/FetchUser copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,eAAO,MAAM,gBAAgB,EAAE,UAsC9B,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { input, select } from '@inquirer/prompts';
|
|
2
|
-
import { PrintHeader, PrintError, PrintTitle } from '../util/Styles.js';
|
|
3
|
-
import { AirshipToken } from '../util/TokenManager.js';
|
|
4
|
-
const apiMap = {
|
|
5
|
-
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
6
|
-
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
7
|
-
};
|
|
8
|
-
export const fetchUserCommand = {
|
|
9
|
-
name: "fetch-user",
|
|
10
|
-
description: "Returns data related to the specified user.",
|
|
11
|
-
usage: "fetch-user <method: username | userId> <identifier: string>",
|
|
12
|
-
requiresToken: false,
|
|
13
|
-
execute: async () => {
|
|
14
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
15
|
-
"Username",
|
|
16
|
-
"UserId"
|
|
17
|
-
] });
|
|
18
|
-
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
19
|
-
for (let data of Object.entries(apiMap)) {
|
|
20
|
-
const method = data[0];
|
|
21
|
-
const url = data[1];
|
|
22
|
-
if (method === fetchMethod) {
|
|
23
|
-
fetch(url + userIdentifier, {
|
|
24
|
-
method: "GET"
|
|
25
|
-
}).then(raw => raw.text().then(data => {
|
|
26
|
-
const userData = JSON.parse(data);
|
|
27
|
-
const entries = Object.entries(userData);
|
|
28
|
-
if (entries.length === 0) {
|
|
29
|
-
PrintError(`Invalid ${fetchMethod}!`);
|
|
30
|
-
}
|
|
31
|
-
else if (entries.length === 3) {
|
|
32
|
-
const styledError = `${entries[0]?.[1]}`.replaceAll("username", "Username").replaceAll(",", ", ");
|
|
33
|
-
PrintError(styledError);
|
|
34
|
-
}
|
|
35
|
-
;
|
|
36
|
-
})).catch((err) => {
|
|
37
|
-
PrintError(err);
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
;
|
|
42
|
-
}
|
|
43
|
-
;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=FetchUser%20copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FetchUser copy.js","sourceRoot":"","sources":["../../src/commands/FetchUser copy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,UAA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AAW,GAAG,CAAC,CAAC;oBAC1C,CAAC;yBAAM,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBAC9B,MAAM,WAAW,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;wBAClG,UAAU,CAAC,WAAW,CAAC,CAAC;oBAC5B,CAAC;oBAAA,CAAC;gBACN,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBACd,UAAU,CAAC,GAAG,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;gBAEH,OAAO;YACX,CAAC;YAAA,CAAC;QACN,CAAC;QAAA,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,eAAO,MAAM,WAAW,EAAE,UA4BzB,CAAC"}
|
package/out/commands/help.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,CAAC,MAAM,WAAW,GAAe;IACnC,IAAI,EA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
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU;;;;CAItB,CAAC;AAEF,eAAO,MAAM,WAAW,UAIvB,CAAC;AAEF,wBAAgB,SAAS,SAMxB"}
|
package/out/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,MAAM,EAAE,WAAW;IACnB,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,gBAAgB;CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,MAAM;IACN,YAAY;IACZ,YAAY;CACf,CAAC;AAEF,MAAM,UAAU,SAAS;IACrB,UAAU,EAAE,CAAC;IAEb,UAAU,CAAC,GAAG,EAAE;QACZ,aAAa,EAAE,CAAC;IACpB,CAAC,EAAE,GAAG,CAAC,CAAC;AACZ,CAAC;AAAA,CAAC;AAEF,SAAS,EAAE,CAAC;AAEZ,KAAK,UAAU,aAAa;IACxB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,WAAW,EAAC,CAAC,CAAC;IAE5F,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE/B,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACrB,UAAU,EAAE,CAAC;YAEb,UAAU,CAAC,GAAG,EAAE;gBACZ,WAAW,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC,EAAE,GAAG,CAAC,CAAC;YACR,OAAO;QACX,CAAC;QAAA,CAAC;IACN,CAAC;IAAA,CAAC;AACN,CAAC;AAAA,CAAC"}
|
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 AirshipUserError = {
|
|
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,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { input, select } from '@inquirer/prompts';
|
|
4
|
-
import { PrintHeader, PrintError, PrintTitle } from './util/Styles.js';
|
|
5
|
-
import { AirshipToken } from './util/TokenManager.js';
|
|
6
|
-
import { isInt16Array } from 'node:util/types';
|
|
7
|
-
import { helpCommand } from './commands/help.js';
|
|
8
|
-
import { fetchUserCommand } from './commands/FetchUser.js';
|
|
9
|
-
import { fetchGameCommand } from './commands/FetchGame.js';
|
|
10
|
-
|
|
11
|
-
export const commandMap = {
|
|
12
|
-
"Help": helpCommand,
|
|
13
|
-
"Fetch User": fetchUserCommand,
|
|
14
|
-
"Fetch Game": fetchGameCommand
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const commandList = [
|
|
18
|
-
"Help",
|
|
19
|
-
"Fetch User",
|
|
20
|
-
"Fetch Game"
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
export function StartTool() {
|
|
24
|
-
PrintTitle();
|
|
25
|
-
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
PromptCommand();
|
|
28
|
-
}, 250);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
StartTool();
|
|
32
|
-
|
|
33
|
-
async function PromptCommand() {
|
|
34
|
-
const answer = await select({ message: "What would you like to do?", choices: commandList});
|
|
35
|
-
|
|
36
|
-
for (let command of Object.entries(commandMap)) {
|
|
37
|
-
const cmdName = command[0];
|
|
38
|
-
const cmdFunction = command[1];
|
|
39
|
-
|
|
40
|
-
if (answer === cmdName) {
|
|
41
|
-
PrintTitle();
|
|
42
|
-
|
|
43
|
-
setTimeout(() => {
|
|
44
|
-
cmdFunction.execute();
|
|
45
|
-
}, 250);
|
|
46
|
-
return;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
};
|
|
@@ -1,61 +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 { AirshipGame } from "../AirshipTypes.js";
|
|
6
|
-
import { StartTool } from "../cli.js";
|
|
7
|
-
|
|
8
|
-
const apiMap = {
|
|
9
|
-
"Slug": "https://api.airship.gg/content/games/slug/",
|
|
10
|
-
"GameId": "https://api.airship.gg/content/games/game-id/"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const fetchGameCommand: CLICommand = {
|
|
14
|
-
name: "fetch-game",
|
|
15
|
-
description: "Returns data related to the specified game.",
|
|
16
|
-
usage: "fetch-game <method: slug | gameId> <identifier: string>",
|
|
17
|
-
requiresToken: false,
|
|
18
|
-
execute: async () => {
|
|
19
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
20
|
-
"Slug",
|
|
21
|
-
"GameId"
|
|
22
|
-
]});
|
|
23
|
-
|
|
24
|
-
const gameIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
25
|
-
|
|
26
|
-
for (let data of Object.entries(apiMap)) {
|
|
27
|
-
const method = data[0];
|
|
28
|
-
const url = data[1];
|
|
29
|
-
|
|
30
|
-
if (method === fetchMethod) {
|
|
31
|
-
fetch(url + gameIdentifier, {
|
|
32
|
-
method: "GET"
|
|
33
|
-
}).then(raw => raw.text().then(data => {
|
|
34
|
-
const gameData = JSON.parse(data) as AirshipGame | {};
|
|
35
|
-
const entries = Object.entries(gameData);
|
|
36
|
-
|
|
37
|
-
if (entries.length === 0) {
|
|
38
|
-
PrintError(`Invalid ${fetchMethod}!`);
|
|
39
|
-
} else if (entries.length === 3) {
|
|
40
|
-
// const styledError = `${entries[0]?.[1]}`.replaceAll("username", "Username").replaceAll(",", ", ");
|
|
41
|
-
// PrintError(styledError);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
console.log(gameData);
|
|
45
|
-
})).catch((err) => {
|
|
46
|
-
PrintError(err);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
setTimeout(async () => {
|
|
50
|
-
const restartTool = await confirm({ message: "Would you like to anything else?" });
|
|
51
|
-
|
|
52
|
-
if (restartTool) {
|
|
53
|
-
StartTool();
|
|
54
|
-
};
|
|
55
|
-
}, 1000);
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
|
@@ -1,61 +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 { AirshipUser, AirshipUserError } from "../AirshipTypes.js";
|
|
6
|
-
import { StartTool } from "../cli.js";
|
|
7
|
-
|
|
8
|
-
const apiMap = {
|
|
9
|
-
"Username": "https://api.airship.gg/game-coordinator/users/user?username=",
|
|
10
|
-
"UserId": "https://api.airship.gg/game-coordinator/users/uid/"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const fetchUserCommand: CLICommand = {
|
|
14
|
-
name: "fetch-user",
|
|
15
|
-
description: "Returns data related to the specified user.",
|
|
16
|
-
usage: "fetch-user <method: username | userId> <identifier: string>",
|
|
17
|
-
requiresToken: false,
|
|
18
|
-
execute: async () => {
|
|
19
|
-
const fetchMethod = await select({ message: "Which method would you like to use?", choices: [
|
|
20
|
-
"Username",
|
|
21
|
-
"UserId"
|
|
22
|
-
]});
|
|
23
|
-
|
|
24
|
-
const userIdentifier = await input({ message: `Please enter the ${fetchMethod}:` });
|
|
25
|
-
|
|
26
|
-
for (let data of Object.entries(apiMap)) {
|
|
27
|
-
const method = data[0];
|
|
28
|
-
const url = data[1];
|
|
29
|
-
|
|
30
|
-
if (method === fetchMethod) {
|
|
31
|
-
fetch(url + userIdentifier, {
|
|
32
|
-
method: "GET"
|
|
33
|
-
}).then(raw => raw.text().then(data => {
|
|
34
|
-
const userData = JSON.parse(data) as AirshipUser | AirshipUserError | {};
|
|
35
|
-
const entries = Object.entries(userData);
|
|
36
|
-
|
|
37
|
-
if (entries.length === 0) {
|
|
38
|
-
PrintError(`Invalid ${fetchMethod}!`);
|
|
39
|
-
} else if (entries.length === 3) {
|
|
40
|
-
const styledError = `${entries[0]?.[1]}`.replaceAll("username", "Username").replaceAll(",", ", ");
|
|
41
|
-
PrintError(styledError);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
console.log(userData);
|
|
45
|
-
})).catch((err) => {
|
|
46
|
-
PrintError(err);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
setTimeout(async () => {
|
|
50
|
-
const restartTool = await confirm({ message: "Would you like to anything else?" });
|
|
51
|
-
|
|
52
|
-
if (restartTool) {
|
|
53
|
-
StartTool();
|
|
54
|
-
};
|
|
55
|
-
}, 1000);
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
package/src/commands/Help.ts
DELETED
|
@@ -1,36 +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, commandList, StartTool } from "../cli.js";
|
|
7
|
-
|
|
8
|
-
export const helpCommand: CLICommand = {
|
|
9
|
-
name: "help",
|
|
10
|
-
description: "Returns the usage of a command.",
|
|
11
|
-
usage: "help <command: string>",
|
|
12
|
-
requiresToken: false,
|
|
13
|
-
execute: async () => {
|
|
14
|
-
const commandSelect = await select({ message: "Which command do you need help with?", choices: commandList.slice(1) });
|
|
15
|
-
|
|
16
|
-
for (let command of Object.entries(commandMap)) {
|
|
17
|
-
if (command[0] === commandSelect) {
|
|
18
|
-
console.log(`\n`);
|
|
19
|
-
console.log(`${chalk.bold(chalk.green(`${commandSelect} Help:`))}`);
|
|
20
|
-
console.log(`- Description: ${chalk.gray(command[1].description)}`);
|
|
21
|
-
console.log(`- Usage: ${chalk.gray(command[1].usage)}`);
|
|
22
|
-
console.log(`\n`);
|
|
23
|
-
|
|
24
|
-
setTimeout(async () => {
|
|
25
|
-
const restartTool = await confirm({ message: "Would you like to anything else?" });
|
|
26
|
-
|
|
27
|
-
if (restartTool) {
|
|
28
|
-
StartTool();
|
|
29
|
-
};
|
|
30
|
-
}, 0);
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
};
|
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,20 +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 {
|
|
8
|
-
const accountsFile = fs.readFileSync(airshipAccountPath);
|
|
9
|
-
if (!accountsFile) {
|
|
10
|
-
PrintError("No Airship Installation Found!");
|
|
11
|
-
|
|
12
|
-
process.exit(1);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const jsonData: AccountInfo = JSON.parse(accountsFile.toString("utf8"));
|
|
16
|
-
|
|
17
|
-
return jsonData.refreshToken;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const AirshipToken = FetchAirshipToken();
|