airship-cli 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +21 -26
- package/LICENSE +673 -673
- package/README.MD +8 -56
- package/out/AirshipTypes.d.ts +1 -1
- package/out/AirshipTypes.d.ts.map +1 -1
- package/out/cli.d.ts +2 -2
- package/out/cli.d.ts.map +1 -1
- package/out/cli.js +47 -22
- 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 +28 -15
- package/out/commands/FetchGame.js.map +1 -1
- package/out/commands/FetchUser.d.ts.map +1 -1
- package/out/commands/FetchUser.js +27 -16
- package/out/commands/FetchUser.js.map +1 -1
- 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 +7 -4
- package/out/util/TokenManager.js.map +1 -1
- package/package.json +2 -3
- package/src/AirshipTypes.ts +62 -62
- package/src/cli.ts +68 -49
- package/src/commands/CommandTypes.ts +7 -6
- package/src/commands/FetchGame.ts +76 -60
- package/src/commands/FetchUser.ts +74 -60
- package/src/commands/Help.ts +36 -35
- package/src/util/Styles.ts +19 -19
- package/src/util/TokenManager.ts +21 -19
- package/tsconfig.json +42 -42
- 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
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
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
|
|
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
|
-
}
|
|
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
63
|
};
|
package/src/cli.ts
CHANGED
|
@@ -1,49 +1,68 @@
|
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
export const commandMap = {
|
|
12
|
-
"Help": helpCommand,
|
|
13
|
-
"Fetch User": fetchUserCommand,
|
|
14
|
-
"Fetch Game": fetchGameCommand
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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,7 +1,8 @@
|
|
|
1
|
-
export type CLICommand = {
|
|
2
|
-
name: string,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export type CLICommand = {
|
|
2
|
+
name: string,
|
|
3
|
+
displayName: string,
|
|
4
|
+
description: string,
|
|
5
|
+
usage: string,
|
|
6
|
+
requiresToken: boolean,
|
|
7
|
+
execute: () => void
|
|
7
8
|
};
|
|
@@ -1,61 +1,77 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
}
|
|
61
77
|
};
|
|
@@ -1,61 +1,75 @@
|
|
|
1
|
-
import type { CLICommand } from "./CommandTypes.js";
|
|
2
|
-
import { input, select, confirm } from '@inquirer/prompts';
|
|
3
|
-
import {
|
|
4
|
-
import { AirshipToken } from '../util/TokenManager.js';
|
|
5
|
-
import type { AirshipUser,
|
|
6
|
-
import { StartTool } from "../cli.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
}
|
|
61
75
|
};
|
package/src/commands/Help.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
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,
|
|
7
|
-
|
|
8
|
-
export const helpCommand: CLICommand = {
|
|
9
|
-
name: "help",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.log(
|
|
20
|
-
console.log(
|
|
21
|
-
console.log(`-
|
|
22
|
-
console.log(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
|
36
37
|
};
|
package/src/util/Styles.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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`);
|
|
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
20
|
};
|