airship-cli 1.1.0 → 1.2.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.
Files changed (89) hide show
  1. package/README.MD +28 -4
  2. package/out/AirshipTypes.d.ts +19 -3
  3. package/out/AirshipTypes.d.ts.map +1 -1
  4. package/out/AirshipTypes.js +2 -0
  5. package/out/AirshipTypes.js.map +1 -1
  6. package/out/cli.d.ts +11 -5
  7. package/out/cli.d.ts.map +1 -1
  8. package/out/cli.js +70 -23
  9. package/out/cli.js.map +1 -1
  10. package/out/commands/ExitCommand.d.ts +3 -0
  11. package/out/commands/ExitCommand.d.ts.map +1 -0
  12. package/out/commands/ExitCommand.js +13 -0
  13. package/out/commands/ExitCommand.js.map +1 -0
  14. package/out/commands/FavoriteGame.d.ts +3 -0
  15. package/out/commands/FavoriteGame.d.ts.map +1 -0
  16. package/out/commands/FavoriteGame.js +22 -0
  17. package/out/commands/FavoriteGame.js.map +1 -0
  18. package/out/commands/FetchGame.d.ts.map +1 -1
  19. package/out/commands/FetchGame.js +28 -54
  20. package/out/commands/FetchGame.js.map +1 -1
  21. package/out/commands/FetchProfilePhoto.d.ts +3 -0
  22. package/out/commands/FetchProfilePhoto.d.ts.map +1 -0
  23. package/out/commands/FetchProfilePhoto.js +31 -0
  24. package/out/commands/FetchProfilePhoto.js.map +1 -0
  25. package/out/commands/FetchUser.d.ts.map +1 -1
  26. package/out/commands/FetchUser.js +26 -52
  27. package/out/commands/FetchUser.js.map +1 -1
  28. package/out/commands/FetchUserPhoto.d.ts +3 -0
  29. package/out/commands/FetchUserPhoto.d.ts.map +1 -0
  30. package/out/commands/FetchUserPhoto.js +45 -0
  31. package/out/commands/FetchUserPhoto.js.map +1 -0
  32. package/out/commands/HelpCommand.d.ts +3 -0
  33. package/out/commands/HelpCommand.d.ts.map +1 -0
  34. package/out/commands/HelpCommand.js +39 -0
  35. package/out/commands/HelpCommand.js.map +1 -0
  36. package/out/commands/RestartCommand copy.d.ts +3 -0
  37. package/out/commands/RestartCommand copy.d.ts.map +1 -0
  38. package/out/commands/RestartCommand copy.js +14 -0
  39. package/out/commands/RestartCommand copy.js.map +1 -0
  40. package/out/commands/RestartCommand.d.ts +3 -0
  41. package/out/commands/RestartCommand.d.ts.map +1 -0
  42. package/out/commands/RestartCommand.js +14 -0
  43. package/out/commands/RestartCommand.js.map +1 -0
  44. package/out/commands/games/FavoriteGame.d.ts +3 -0
  45. package/out/commands/games/FavoriteGame.d.ts.map +1 -0
  46. package/out/commands/games/FavoriteGame.js +22 -0
  47. package/out/commands/games/FavoriteGame.js.map +1 -0
  48. package/out/commands/games/FetchGame.d.ts +3 -0
  49. package/out/commands/games/FetchGame.d.ts.map +1 -0
  50. package/out/commands/games/FetchGame.js +42 -0
  51. package/out/commands/games/FetchGame.js.map +1 -0
  52. package/out/commands/users/FetchProfilePhoto.d.ts +3 -0
  53. package/out/commands/users/FetchProfilePhoto.d.ts.map +1 -0
  54. package/out/commands/users/FetchProfilePhoto.js +31 -0
  55. package/out/commands/users/FetchProfilePhoto.js.map +1 -0
  56. package/out/commands/users/FetchUser.d.ts +3 -0
  57. package/out/commands/users/FetchUser.d.ts.map +1 -0
  58. package/out/commands/users/FetchUser.js +40 -0
  59. package/out/commands/users/FetchUser.js.map +1 -0
  60. package/out/util/IdentifierConversion.d.ts +2 -0
  61. package/out/util/IdentifierConversion.d.ts.map +1 -0
  62. package/out/util/IdentifierConversion.js +14 -0
  63. package/out/util/IdentifierConversion.js.map +1 -0
  64. package/out/util/TokenManager.d.ts.map +1 -1
  65. package/out/util/TokenManager.js +44 -3
  66. package/out/util/TokenManager.js.map +1 -1
  67. package/out/util/platform/FavoriteGame.d.ts +3 -0
  68. package/out/util/platform/FavoriteGame.d.ts.map +1 -0
  69. package/out/util/platform/FavoriteGame.js +28 -0
  70. package/out/util/platform/FavoriteGame.js.map +1 -0
  71. package/out/util/platform/FetchGame.d.ts +6 -0
  72. package/out/util/platform/FetchGame.d.ts.map +1 -0
  73. package/out/util/platform/FetchGame.js +14 -0
  74. package/out/util/platform/FetchGame.js.map +1 -0
  75. package/out/util/platform/FetchUser.d.ts +6 -0
  76. package/out/util/platform/FetchUser.d.ts.map +1 -0
  77. package/out/util/platform/FetchUser.js +14 -0
  78. package/out/util/platform/FetchUser.js.map +1 -0
  79. package/package.json +6 -2
  80. package/.github/workflows/npm-publish.yml +0 -22
  81. package/src/AirshipTypes.ts +0 -63
  82. package/src/cli.ts +0 -68
  83. package/src/commands/CommandTypes.ts +0 -8
  84. package/src/commands/FetchGame.ts +0 -77
  85. package/src/commands/FetchUser.ts +0 -75
  86. package/src/commands/Help.ts +0 -37
  87. package/src/util/Styles.ts +0 -20
  88. package/src/util/TokenManager.ts +0 -22
  89. package/tsconfig.json +0 -42
@@ -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,8 +0,0 @@
1
- export type CLICommand = {
2
- name: string,
3
- displayName: string,
4
- description: string,
5
- usage: string,
6
- requiresToken: boolean,
7
- execute: () => void
8
- };
@@ -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
- };
@@ -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
- };
@@ -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
- };
@@ -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
- }