diff --git a/src/cli.ts b/src/cli.ts index 42489d2..02ee2c8 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,7 +1,7 @@ import process from 'node:process'; import Yargs from 'yargs'; import { setGlobalDispatcher } from 'undici'; -import * as commands from './cli/index.js'; +import * as commands from './cli/commands.js'; import { checkUpdates } from './common/update.js'; import createDebug from './util/debug.js'; import { dev } from './util/product.js'; diff --git a/src/cli/commands.ts b/src/cli/commands.ts new file mode 100644 index 0000000..938d6c2 --- /dev/null +++ b/src/cli/commands.ts @@ -0,0 +1,10 @@ +export * as users from './users.js'; +export * as nso from './nso/index.js'; +export * as splatnet2 from './splatnet2/index.js'; +export * as nooklink from './nooklink/index.js'; +export * as splatnet3 from './splatnet3/index.js'; +export * as pctl from './pctl/index.js'; +export * as androidZncaApiServerFrida from './android-znca-api-server-frida.js'; +export * as presenceServer from './presence-server.js'; +export * as util from './util/index.js'; +export * as app from './app.js'; diff --git a/src/cli/index.ts b/src/cli/index.ts deleted file mode 100644 index 2eec2d7..0000000 --- a/src/cli/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * as users from './users.js'; -export * as nso from './nso.js'; -export * as splatnet2 from './splatnet2.js'; -export * as nooklink from './nooklink.js'; -export * as splatnet3 from './splatnet3.js'; -export * as pctl from './pctl.js'; -export * as androidZncaApiServerFrida from './android-znca-api-server-frida.js'; -export * as presenceServer from './presence-server.js'; -export * as util from './util.js'; -export * as app from './app.js'; diff --git a/src/cli/nooklink.ts b/src/cli/nooklink.ts deleted file mode 100644 index bea5e75..0000000 --- a/src/cli/nooklink.ts +++ /dev/null @@ -1,29 +0,0 @@ -import process from 'node:process'; -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import * as commands from './nooklink/index.js'; - -const debug = createDebug('cli:nooklink'); - -export const command = 'nooklink '; -export const desc = 'NookLink'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - // @ts-expect-error - yargs.command(command); - } - - return yargs.option('znc-proxy-url', { - describe: 'URL of Nintendo Switch Online app API proxy server to use', - type: 'string', - default: process.env.ZNC_PROXY_URL, - }).option('auto-update-session', { - describe: 'Automatically obtain and refresh the NookLink game web token and user token', - type: 'boolean', - default: true, - }); -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/nooklink/commands.ts b/src/cli/nooklink/commands.ts new file mode 100644 index 0000000..7d35b17 --- /dev/null +++ b/src/cli/nooklink/commands.ts @@ -0,0 +1,10 @@ +export * as users from './users.js'; +export * as user from './user.js'; +export * as island from './island.js'; +export * as newspapers from './newspapers.js'; +export * as newspaper from './newspaper.js'; +export * as dumpNewspapers from './dump-newspapers.js'; +export * as keyboard from './keyboard.js'; +export * as reactions from './reactions.js'; +export * as postReaction from './post-reaction.js'; +export * as userToken from './user-token.js'; diff --git a/src/cli/nooklink/dump-newspapers.ts b/src/cli/nooklink/dump-newspapers.ts index 75da4e3..0c177d7 100644 --- a/src/cli/nooklink/dump-newspapers.ts +++ b/src/cli/nooklink/dump-newspapers.ts @@ -1,6 +1,6 @@ import * as fs from 'node:fs/promises'; import * as path from 'node:path'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/index.ts b/src/cli/nooklink/index.ts index 7d35b17..2e0aa3c 100644 --- a/src/cli/nooklink/index.ts +++ b/src/cli/nooklink/index.ts @@ -1,10 +1,29 @@ -export * as users from './users.js'; -export * as user from './user.js'; -export * as island from './island.js'; -export * as newspapers from './newspapers.js'; -export * as newspaper from './newspaper.js'; -export * as dumpNewspapers from './dump-newspapers.js'; -export * as keyboard from './keyboard.js'; -export * as reactions from './reactions.js'; -export * as postReaction from './post-reaction.js'; -export * as userToken from './user-token.js'; +import process from 'node:process'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:nooklink'); + +export const command = 'nooklink '; +export const desc = 'NookLink'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + // @ts-expect-error + yargs.command(command); + } + + return yargs.option('znc-proxy-url', { + describe: 'URL of Nintendo Switch Online app API proxy server to use', + type: 'string', + default: process.env.ZNC_PROXY_URL, + }).option('auto-update-session', { + describe: 'Automatically obtain and refresh the NookLink game web token and user token', + type: 'boolean', + default: true, + }); +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/nooklink/island.ts b/src/cli/nooklink/island.ts index bab3e39..b90e5ea 100644 --- a/src/cli/nooklink/island.ts +++ b/src/cli/nooklink/island.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/keyboard.ts b/src/cli/nooklink/keyboard.ts index 742d19b..b52d236 100644 --- a/src/cli/nooklink/keyboard.ts +++ b/src/cli/nooklink/keyboard.ts @@ -1,5 +1,5 @@ import { read } from 'read'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/newspaper.ts b/src/cli/nooklink/newspaper.ts index 29aaf62..641e711 100644 --- a/src/cli/nooklink/newspaper.ts +++ b/src/cli/nooklink/newspaper.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/newspapers.ts b/src/cli/nooklink/newspapers.ts index f8aef86..2c94ef3 100644 --- a/src/cli/nooklink/newspapers.ts +++ b/src/cli/nooklink/newspapers.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/post-reaction.ts b/src/cli/nooklink/post-reaction.ts index 741063f..81bbf87 100644 --- a/src/cli/nooklink/post-reaction.ts +++ b/src/cli/nooklink/post-reaction.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nooklink.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/reactions.ts b/src/cli/nooklink/reactions.ts index 3de844b..dbedf4f 100644 --- a/src/cli/nooklink/reactions.ts +++ b/src/cli/nooklink/reactions.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/user-token.ts b/src/cli/nooklink/user-token.ts index 375ac73..4a3d6c7 100644 --- a/src/cli/nooklink/user-token.ts +++ b/src/cli/nooklink/user-token.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nooklink.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/user.ts b/src/cli/nooklink/user.ts index 3fc65fe..8b83f5d 100644 --- a/src/cli/nooklink/user.ts +++ b/src/cli/nooklink/user.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nooklink.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nooklink/users.ts b/src/cli/nooklink/users.ts index f594f5d..6f680e1 100644 --- a/src/cli/nooklink/users.ts +++ b/src/cli/nooklink/users.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nooklink.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso.ts b/src/cli/nso.ts deleted file mode 100644 index 341e65a..0000000 --- a/src/cli/nso.ts +++ /dev/null @@ -1,25 +0,0 @@ -import process from 'node:process'; -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import * as commands from './nso/index.js'; - -const debug = createDebug('cli:nso'); - -export const command = 'nso '; -export const desc = 'Nintendo Switch Online'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - // @ts-expect-error - yargs.command(command); - } - - return yargs.option('znc-proxy-url', { - describe: 'URL of Nintendo Switch Online app API proxy server to use', - type: 'string', - default: process.env.ZNC_PROXY_URL, - }); -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/nso/active-event.ts b/src/cli/nso/active-event.ts index 946e839..1d22a2b 100644 --- a/src/cli/nso/active-event.ts +++ b/src/cli/nso/active-event.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/add-friend.ts b/src/cli/nso/add-friend.ts index ad4a800..a9d09fa 100644 --- a/src/cli/nso/add-friend.ts +++ b/src/cli/nso/add-friend.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/announcements.ts b/src/cli/nso/announcements.ts index 5ec1083..55a5d02 100644 --- a/src/cli/nso/announcements.ts +++ b/src/cli/nso/announcements.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nso.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/auth.ts b/src/cli/nso/auth.ts index 91f1e4d..fa5cae1 100644 --- a/src/cli/nso/auth.ts +++ b/src/cli/nso/auth.ts @@ -1,5 +1,5 @@ import { read } from 'read'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/commands.ts b/src/cli/nso/commands.ts new file mode 100644 index 0000000..a849f3b --- /dev/null +++ b/src/cli/nso/commands.ts @@ -0,0 +1,16 @@ +export * as token from './token.js'; +export * as auth from './auth.js'; +export * as user from './user.js'; +export * as permissions from './permissions.js'; +export * as announcements from './announcements.js'; +export * as webservices from './webservices.js'; +export * as webservicetoken from './webservicetoken.js'; +export * as friends from './friends.js'; +export * as activeEvent from './active-event.js'; +export * as presence from './presence.js'; +export * as notify from './notify.js'; +export * as httpServer from './http-server.js'; +export * as zncProxyTokens from './znc-proxy-tokens.js'; +export * as friendcode from './friendcode.js'; +export * as lookup from './lookup.js'; +export * as addFriend from './add-friend.js'; diff --git a/src/cli/nso/friendcode.ts b/src/cli/nso/friendcode.ts index 862381f..b8d1b16 100644 --- a/src/cli/nso/friendcode.ts +++ b/src/cli/nso/friendcode.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/friends.ts b/src/cli/nso/friends.ts index 52535e2..bedde9d 100644 --- a/src/cli/nso/friends.ts +++ b/src/cli/nso/friends.ts @@ -1,6 +1,6 @@ -import Table from '../util/table.js'; +import Table from '../../util/table.js'; import { PresenceState } from '../../api/coral-types.js'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/http-server.ts b/src/cli/nso/http-server.ts index e5673a2..87fd5f4 100644 --- a/src/cli/nso/http-server.ts +++ b/src/cli/nso/http-server.ts @@ -4,7 +4,7 @@ import { randomUUID } from 'node:crypto'; import * as persist from 'node-persist'; import express, { Request, RequestHandler, Response } from 'express'; import bodyParser from 'body-parser'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import CoralApi, { CoralApiInterface, CoralErrorResponse } from '../../api/coral.js'; import { Announcement, CoralStatus, CurrentUser, Friend, FriendCodeUrl, FriendCodeUser, Presence } from '../../api/coral-types.js'; import { AuthPolicy, AuthToken, ZncPresenceEventStreamEvent } from '../../api/znc-proxy.js'; @@ -14,7 +14,7 @@ import { initStorage } from '../../util/storage.js'; import { product } from '../../util/product.js'; import { parseListenAddress } from '../../util/net.js'; import { addCliFeatureUserAgent } from '../../util/useragent.js'; -import { EventStreamResponse, HttpServer, ResponseError } from '../util/http-server.js'; +import { EventStreamResponse, HttpServer, ResponseError } from '../../util/http-server.js'; import { SavedToken } from '../../common/auth/coral.js'; import { NotificationManager, PresenceEvent, ZncNotifications } from '../../common/notify.js'; import Users, { CoralUser } from '../../common/users.js'; diff --git a/src/cli/nso/index.ts b/src/cli/nso/index.ts index a849f3b..cc61071 100644 --- a/src/cli/nso/index.ts +++ b/src/cli/nso/index.ts @@ -1,16 +1,25 @@ -export * as token from './token.js'; -export * as auth from './auth.js'; -export * as user from './user.js'; -export * as permissions from './permissions.js'; -export * as announcements from './announcements.js'; -export * as webservices from './webservices.js'; -export * as webservicetoken from './webservicetoken.js'; -export * as friends from './friends.js'; -export * as activeEvent from './active-event.js'; -export * as presence from './presence.js'; -export * as notify from './notify.js'; -export * as httpServer from './http-server.js'; -export * as zncProxyTokens from './znc-proxy-tokens.js'; -export * as friendcode from './friendcode.js'; -export * as lookup from './lookup.js'; -export * as addFriend from './add-friend.js'; +import process from 'node:process'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:nso'); + +export const command = 'nso '; +export const desc = 'Nintendo Switch Online'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + // @ts-expect-error + yargs.command(command); + } + + return yargs.option('znc-proxy-url', { + describe: 'URL of Nintendo Switch Online app API proxy server to use', + type: 'string', + default: process.env.ZNC_PROXY_URL, + }); +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/nso/lookup.ts b/src/cli/nso/lookup.ts index 5c22741..c0c5697 100644 --- a/src/cli/nso/lookup.ts +++ b/src/cli/nso/lookup.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/notify.ts b/src/cli/nso/notify.ts index 7c34f97..84d911b 100644 --- a/src/cli/nso/notify.ts +++ b/src/cli/nso/notify.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import persist from 'node-persist'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/permissions.ts b/src/cli/nso/permissions.ts index b061436..46b3608 100644 --- a/src/cli/nso/permissions.ts +++ b/src/cli/nso/permissions.ts @@ -1,5 +1,5 @@ import { PresencePermissions } from '../../api/coral-types.js'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/presence.ts b/src/cli/nso/presence.ts index f8e360d..82c0d39 100644 --- a/src/cli/nso/presence.ts +++ b/src/cli/nso/presence.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/token.ts b/src/cli/nso/token.ts index 5ba9002..0ec9bc8 100644 --- a/src/cli/nso/token.ts +++ b/src/cli/nso/token.ts @@ -1,5 +1,5 @@ import { read } from 'read'; -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/user.ts b/src/cli/nso/user.ts index 3aa3aed..d6c3a79 100644 --- a/src/cli/nso/user.ts +++ b/src/cli/nso/user.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/webservices.ts b/src/cli/nso/webservices.ts index ae37ab6..d419cb7 100644 --- a/src/cli/nso/webservices.ts +++ b/src/cli/nso/webservices.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nso.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/webservicetoken.ts b/src/cli/nso/webservicetoken.ts index 3488f5e..92cb19b 100644 --- a/src/cli/nso/webservicetoken.ts +++ b/src/cli/nso/webservicetoken.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../nso.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/nso/znc-proxy-tokens.ts b/src/cli/nso/znc-proxy-tokens.ts index ef46769..bc6629d 100644 --- a/src/cli/nso/znc-proxy-tokens.ts +++ b/src/cli/nso/znc-proxy-tokens.ts @@ -1,6 +1,6 @@ import { fetch } from 'undici'; -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../nso.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import { getToken } from '../../common/auth/coral.js'; import { AuthPolicy, AuthToken } from '../../api/znc-proxy.js'; import createDebug from '../../util/debug.js'; diff --git a/src/cli/pctl.ts b/src/cli/pctl.ts deleted file mode 100644 index f36856d..0000000 --- a/src/cli/pctl.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import * as commands from './pctl/index.js'; - -const debug = createDebug('cli:pctl'); - -export const command = 'pctl '; -export const desc = 'Nintendo Switch Parental Controls'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - // @ts-expect-error - yargs.command(command); - } - - return yargs; -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/pctl/auth.ts b/src/cli/pctl/auth.ts index 8b6a363..01fa84a 100644 --- a/src/cli/pctl/auth.ts +++ b/src/cli/pctl/auth.ts @@ -1,5 +1,5 @@ import { read } from 'read'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/commands.ts b/src/cli/pctl/commands.ts new file mode 100644 index 0000000..8a4d77d --- /dev/null +++ b/src/cli/pctl/commands.ts @@ -0,0 +1,8 @@ +export * as token from './token.js'; +export * as auth from './auth.js'; +export * as devices from './devices.js'; +export * as dailySummaries from './daily-summaries.js'; +export * as monthlySummaries from './monthly-summaries.js'; +export * as monthlySummary from './monthly-summary.js'; +export * as settings from './settings.js'; +export * as dumpSummaries from './dump-summaries.js'; diff --git a/src/cli/pctl/daily-summaries.ts b/src/cli/pctl/daily-summaries.ts index ad1c471..ba1e517 100644 --- a/src/cli/pctl/daily-summaries.ts +++ b/src/cli/pctl/daily-summaries.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/devices.ts b/src/cli/pctl/devices.ts index f4b7f00..2f93e2d 100644 --- a/src/cli/pctl/devices.ts +++ b/src/cli/pctl/devices.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/dump-summaries.ts b/src/cli/pctl/dump-summaries.ts index 92d67a1..01c2fdf 100644 --- a/src/cli/pctl/dump-summaries.ts +++ b/src/cli/pctl/dump-summaries.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/index.ts b/src/cli/pctl/index.ts index 8a4d77d..c77bf70 100644 --- a/src/cli/pctl/index.ts +++ b/src/cli/pctl/index.ts @@ -1,8 +1,20 @@ -export * as token from './token.js'; -export * as auth from './auth.js'; -export * as devices from './devices.js'; -export * as dailySummaries from './daily-summaries.js'; -export * as monthlySummaries from './monthly-summaries.js'; -export * as monthlySummary from './monthly-summary.js'; -export * as settings from './settings.js'; -export * as dumpSummaries from './dump-summaries.js'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:pctl'); + +export const command = 'pctl '; +export const desc = 'Nintendo Switch Parental Controls'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + // @ts-expect-error + yargs.command(command); + } + + return yargs; +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/pctl/monthly-summaries.ts b/src/cli/pctl/monthly-summaries.ts index 32e35fe..b956da6 100644 --- a/src/cli/pctl/monthly-summaries.ts +++ b/src/cli/pctl/monthly-summaries.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/monthly-summary.ts b/src/cli/pctl/monthly-summary.ts index 385f08c..f0c7156 100644 --- a/src/cli/pctl/monthly-summary.ts +++ b/src/cli/pctl/monthly-summary.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/settings.ts b/src/cli/pctl/settings.ts index 095cfba..7bc313f 100644 --- a/src/cli/pctl/settings.ts +++ b/src/cli/pctl/settings.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../pctl.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/token.ts b/src/cli/pctl/token.ts index 9ac5d57..54cf5c2 100644 --- a/src/cli/pctl/token.ts +++ b/src/cli/pctl/token.ts @@ -1,5 +1,5 @@ import { read } from 'read'; -import type { Arguments as ParentArguments } from '../pctl.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/pctl/user.ts b/src/cli/pctl/user.ts index d3fe397..02a711b 100644 --- a/src/cli/pctl/user.ts +++ b/src/cli/pctl/user.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../pctl.js'; +import type { Arguments as ParentArguments } from './index.js'; import { getPctlToken } from '../../common/auth/moon.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; diff --git a/src/cli/presence-server.ts b/src/cli/presence-server.ts index 29bf31a..a335fd4 100644 --- a/src/cli/presence-server.ts +++ b/src/cli/presence-server.ts @@ -19,12 +19,12 @@ import createDebug from '../util/debug.js'; import { initStorage } from '../util/storage.js'; import { addCliFeatureUserAgent, getUserAgent } from '../util/useragent.js'; import { parseListenAddress } from '../util/net.js'; -import { EventStreamResponse, HttpServer, ResponseError } from './util/http-server.js'; +import { EventStreamResponse, HttpServer, ResponseError } from '../util/http-server.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../util/yargs.js'; import { getTitleIdFromEcUrl } from '../util/misc.js'; import { getSettingForCoopRule, getSettingForVsMode } from '../discord/monitor/splatoon3.js'; import { CoralApiInterface } from '../api/coral.js'; -import { PresenceEmbedFormat, getUserEmbedOptionsFromRequest, renderUserEmbedImage, renderUserEmbedSvg } from './util/presence-embed.js'; +import { PresenceEmbedFormat, getUserEmbedOptionsFromRequest, renderUserEmbedImage, renderUserEmbedSvg } from '../common/presence-embed.js'; const debug = createDebug('cli:presence-server'); const debugSplatnet3Proxy = createDebug('cli:presence-server:splatnet3-proxy'); diff --git a/src/cli/splatnet2.ts b/src/cli/splatnet2.ts deleted file mode 100644 index 1ad7d70..0000000 --- a/src/cli/splatnet2.ts +++ /dev/null @@ -1,30 +0,0 @@ -import process from 'node:process'; -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import * as commands from './splatnet2/index.js'; - -const debug = createDebug('cli:splatnet2'); - -export const command = 'splatnet2 '; -export const desc = 'SplatNet 2'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - // @ts-expect-error - yargs.command(command); - } - - return yargs.option('znc-proxy-url', { - describe: 'URL of Nintendo Switch Online app API proxy server to use', - type: 'string', - default: process.env.ZNC_PROXY_URL, - }).option('auto-update-session', { - alias: ['auto-update-iksm-session'], - describe: 'Automatically obtain and refresh the iksm_session cookie', - type: 'boolean', - default: true, - }); -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/splatnet2/battles.ts b/src/cli/splatnet2/battles.ts index eb82e93..00679aa 100644 --- a/src/cli/splatnet2/battles.ts +++ b/src/cli/splatnet2/battles.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/challenges.ts b/src/cli/splatnet2/challenges.ts index 7aa7390..7bcb40a 100644 --- a/src/cli/splatnet2/challenges.ts +++ b/src/cli/splatnet2/challenges.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/commands.ts b/src/cli/splatnet2/commands.ts new file mode 100644 index 0000000..e99312c --- /dev/null +++ b/src/cli/splatnet2/commands.ts @@ -0,0 +1,12 @@ +export * as user from './user.js'; +export * as token from './token.js'; +export * as stages from './stages.js'; +export * as challenges from './challenges.js'; +export * as weapons from './weapons.js'; +export * as hero from './hero.js'; +export * as battles from './battles.js'; +export * as schedule from './schedule.js'; +export * as dumpResults from './dump-results.js'; +export * as dumpRecords from './dump-records.js'; +export * as monitor from './monitor.js'; +export * as xRankSeasons from './x-rank-seasons.js'; diff --git a/src/cli/splatnet2/dump-records.ts b/src/cli/splatnet2/dump-records.ts index ca4be25..41d1a3b 100644 --- a/src/cli/splatnet2/dump-records.ts +++ b/src/cli/splatnet2/dump-records.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/dump-results.ts b/src/cli/splatnet2/dump-results.ts index daf08a2..6d6c1d4 100644 --- a/src/cli/splatnet2/dump-results.ts +++ b/src/cli/splatnet2/dump-results.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/hero.ts b/src/cli/splatnet2/hero.ts index 970e43e..01ed37f 100644 --- a/src/cli/splatnet2/hero.ts +++ b/src/cli/splatnet2/hero.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/index.ts b/src/cli/splatnet2/index.ts index e99312c..8b3cd26 100644 --- a/src/cli/splatnet2/index.ts +++ b/src/cli/splatnet2/index.ts @@ -1,12 +1,30 @@ -export * as user from './user.js'; -export * as token from './token.js'; -export * as stages from './stages.js'; -export * as challenges from './challenges.js'; -export * as weapons from './weapons.js'; -export * as hero from './hero.js'; -export * as battles from './battles.js'; -export * as schedule from './schedule.js'; -export * as dumpResults from './dump-results.js'; -export * as dumpRecords from './dump-records.js'; -export * as monitor from './monitor.js'; -export * as xRankSeasons from './x-rank-seasons.js'; +import process from 'node:process'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:splatnet2'); + +export const command = 'splatnet2 '; +export const desc = 'SplatNet 2'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + // @ts-expect-error + yargs.command(command); + } + + return yargs.option('znc-proxy-url', { + describe: 'URL of Nintendo Switch Online app API proxy server to use', + type: 'string', + default: process.env.ZNC_PROXY_URL, + }).option('auto-update-session', { + alias: ['auto-update-iksm-session'], + describe: 'Automatically obtain and refresh the iksm_session cookie', + type: 'boolean', + default: true, + }); +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/splatnet2/monitor.ts b/src/cli/splatnet2/monitor.ts index d686ad1..7766a33 100644 --- a/src/cli/splatnet2/monitor.ts +++ b/src/cli/splatnet2/monitor.ts @@ -3,7 +3,7 @@ import { getIksmToken } from '../../common/auth/splatnet2.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; -import { Arguments as ParentArguments } from '../splatnet2.js'; +import { Arguments as ParentArguments } from './index.js'; import { SplatNet2RecordsMonitor } from '../../common/splatnet2/monitor.js'; const debug = createDebug('cli:splatnet2:monitor'); diff --git a/src/cli/splatnet2/schedule.ts b/src/cli/splatnet2/schedule.ts index 85272b5..1815d86 100644 --- a/src/cli/splatnet2/schedule.ts +++ b/src/cli/splatnet2/schedule.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/stages.ts b/src/cli/splatnet2/stages.ts index 23f215c..751fa2e 100644 --- a/src/cli/splatnet2/stages.ts +++ b/src/cli/splatnet2/stages.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/token.ts b/src/cli/splatnet2/token.ts index 7472d92..966bc17 100644 --- a/src/cli/splatnet2/token.ts +++ b/src/cli/splatnet2/token.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/user.ts b/src/cli/splatnet2/user.ts index bf0950e..7090cdc 100644 --- a/src/cli/splatnet2/user.ts +++ b/src/cli/splatnet2/user.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/weapons.ts b/src/cli/splatnet2/weapons.ts index ed0db96..dc5e935 100644 --- a/src/cli/splatnet2/weapons.ts +++ b/src/cli/splatnet2/weapons.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet2/x-rank-seasons.ts b/src/cli/splatnet2/x-rank-seasons.ts index def49bd..b8cdda3 100644 --- a/src/cli/splatnet2/x-rank-seasons.ts +++ b/src/cli/splatnet2/x-rank-seasons.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet2.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { getAllSeasons } from '../../api/splatnet2-xrank.js'; diff --git a/src/cli/splatnet3.ts b/src/cli/splatnet3.ts deleted file mode 100644 index 9778c39..0000000 --- a/src/cli/splatnet3.ts +++ /dev/null @@ -1,29 +0,0 @@ -import process from 'node:process'; -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import * as commands from './splatnet3/index.js'; - -const debug = createDebug('cli:splatnet3'); - -export const command = 'splatnet3 '; -export const desc = 'SplatNet 3'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - // @ts-expect-error - yargs.command(command); - } - - return yargs.option('znc-proxy-url', { - describe: 'URL of Nintendo Switch Online app API proxy server to use', - type: 'string', - default: process.env.ZNC_PROXY_URL, - }).option('auto-update-session', { - describe: 'Automatically obtain and refresh the SplatNet 3 access token', - type: 'boolean', - default: true, - }); -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/splatnet3/battles.ts b/src/cli/splatnet3/battles.ts index c9bf886..95de032 100644 --- a/src/cli/splatnet3/battles.ts +++ b/src/cli/splatnet3/battles.ts @@ -1,6 +1,6 @@ import { Judgement } from 'splatnet3-types/splatnet3'; -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/commands.ts b/src/cli/splatnet3/commands.ts new file mode 100644 index 0000000..74c0bf9 --- /dev/null +++ b/src/cli/splatnet3/commands.ts @@ -0,0 +1,12 @@ +export * as user from './user.js'; +export * as token from './token.js'; +export * as friends from './friends.js'; +export * as schedule from './schedule.js'; +export * as festivals from './festivals.js'; +export * as festival from './festival.js'; +export * as battles from './battles.js'; +export * as dumpRecords from './dump-records.js'; +export * as dumpFests from './dump-fests.js'; +export * as dumpAlbum from './dump-album.js'; +export * as dumpResults from './dump-results.js'; +export * as monitor from './monitor.js'; diff --git a/src/cli/splatnet3/dump-album.ts b/src/cli/splatnet3/dump-album.ts index 8923dfb..6496ae8 100644 --- a/src/cli/splatnet3/dump-album.ts +++ b/src/cli/splatnet3/dump-album.ts @@ -2,7 +2,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; import { fetch } from 'undici'; import { PhotoAlbumResult } from 'splatnet3-types/splatnet3'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/dump-fests.ts b/src/cli/splatnet3/dump-fests.ts index 4cf7027..1866619 100644 --- a/src/cli/splatnet3/dump-fests.ts +++ b/src/cli/splatnet3/dump-fests.ts @@ -1,7 +1,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; import { FestState, Fest_detail, RequestId } from 'splatnet3-types/splatnet3'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/dump-records.ts b/src/cli/splatnet3/dump-records.ts index d742ca1..d18153a 100644 --- a/src/cli/splatnet3/dump-records.ts +++ b/src/cli/splatnet3/dump-records.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/dump-results.ts b/src/cli/splatnet3/dump-results.ts index deb657d..3ab13c6 100644 --- a/src/cli/splatnet3/dump-results.ts +++ b/src/cli/splatnet3/dump-results.ts @@ -1,7 +1,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; import { BankaraBattleHistoriesRefetchResult, CoopHistoryResult, LatestBattleHistoriesRefetchResult, LatestBattleHistoriesResult, PrivateBattleHistoriesRefetchResult, RefetchableCoopHistory_CoopResultResult, RegularBattleHistoriesRefetchResult, RequestId, XBattleHistoriesRefetchResult } from 'splatnet3-types/splatnet3'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/festival.ts b/src/cli/splatnet3/festival.ts index 10b8287..33f1f95 100644 --- a/src/cli/splatnet3/festival.ts +++ b/src/cli/splatnet3/festival.ts @@ -1,6 +1,6 @@ import { FestState } from 'splatnet3-types/splatnet3'; -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/festivals.ts b/src/cli/splatnet3/festivals.ts index 3528554..783336f 100644 --- a/src/cli/splatnet3/festivals.ts +++ b/src/cli/splatnet3/festivals.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/friends.ts b/src/cli/splatnet3/friends.ts index e2939a8..68ca2c1 100644 --- a/src/cli/splatnet3/friends.ts +++ b/src/cli/splatnet3/friends.ts @@ -1,6 +1,6 @@ import { FriendOnlineState, Friend_friendList } from 'splatnet3-types/splatnet3'; -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/index.ts b/src/cli/splatnet3/index.ts index 74c0bf9..a65a72c 100644 --- a/src/cli/splatnet3/index.ts +++ b/src/cli/splatnet3/index.ts @@ -1,12 +1,29 @@ -export * as user from './user.js'; -export * as token from './token.js'; -export * as friends from './friends.js'; -export * as schedule from './schedule.js'; -export * as festivals from './festivals.js'; -export * as festival from './festival.js'; -export * as battles from './battles.js'; -export * as dumpRecords from './dump-records.js'; -export * as dumpFests from './dump-fests.js'; -export * as dumpAlbum from './dump-album.js'; -export * as dumpResults from './dump-results.js'; -export * as monitor from './monitor.js'; +import process from 'node:process'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:splatnet3'); + +export const command = 'splatnet3 '; +export const desc = 'SplatNet 3'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + // @ts-expect-error + yargs.command(command); + } + + return yargs.option('znc-proxy-url', { + describe: 'URL of Nintendo Switch Online app API proxy server to use', + type: 'string', + default: process.env.ZNC_PROXY_URL, + }).option('auto-update-session', { + describe: 'Automatically obtain and refresh the SplatNet 3 access token', + type: 'boolean', + default: true, + }); +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/splatnet3/monitor.ts b/src/cli/splatnet3/monitor.ts index 0c66e20..643a848 100644 --- a/src/cli/splatnet3/monitor.ts +++ b/src/cli/splatnet3/monitor.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/schedule.ts b/src/cli/splatnet3/schedule.ts index d4b7a42..05bef56 100644 --- a/src/cli/splatnet3/schedule.ts +++ b/src/cli/splatnet3/schedule.ts @@ -1,5 +1,5 @@ -import Table from '../util/table.js'; -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import Table from '../../util/table.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/token.ts b/src/cli/splatnet3/token.ts index c8e647e..354ac95 100644 --- a/src/cli/splatnet3/token.ts +++ b/src/cli/splatnet3/token.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/splatnet3/user.ts b/src/cli/splatnet3/user.ts index c039e1f..f2d8db9 100644 --- a/src/cli/splatnet3/user.ts +++ b/src/cli/splatnet3/user.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../splatnet3.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { initStorage } from '../../util/storage.js'; diff --git a/src/cli/users.ts b/src/cli/users.ts index 4254ec8..10ba01f 100644 --- a/src/cli/users.ts +++ b/src/cli/users.ts @@ -1,5 +1,5 @@ import * as persist from 'node-persist'; -import Table from './util/table.js'; +import Table from '../util/table.js'; import type { Arguments as ParentArguments } from '../cli.js'; import createDebug from '../util/debug.js'; import { Argv } from '../util/yargs.js'; diff --git a/src/cli/util.ts b/src/cli/util.ts deleted file mode 100644 index 35febf7..0000000 --- a/src/cli/util.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Arguments as ParentArguments } from '../cli.js'; -import createDebug from '../util/debug.js'; -import { Argv, YargsArguments } from '../util/yargs.js'; -import { dev } from '../util/product.js'; -import * as commands from './util/index.js'; - -const debug = createDebug('cli:util'); - -export const command = 'util '; -export const desc = 'Utilities'; - -export function builder(yargs: Argv) { - for (const command of Object.values(commands)) { - if (command.command === 'validate-discord-titles' && !dev) continue; - if (command.command === 'export-discord-titles' && !dev) continue; - - // @ts-expect-error - yargs.command(command); - } - - return yargs; -} - -export type Arguments = YargsArguments>; diff --git a/src/cli/util/captureid.ts b/src/cli/util/captureid.ts index 5acf11f..189c11b 100644 --- a/src/cli/util/captureid.ts +++ b/src/cli/util/captureid.ts @@ -1,6 +1,6 @@ import * as crypto from 'node:crypto'; import { Buffer } from 'node:buffer'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { Argv } from '../../util/yargs.js'; diff --git a/src/cli/util/commands.ts b/src/cli/util/commands.ts new file mode 100644 index 0000000..6857546 --- /dev/null +++ b/src/cli/util/commands.ts @@ -0,0 +1,9 @@ +export * as captureid from './captureid.js'; +export * as validateDiscordTitles from './validate-discord-titles.js'; +export * as exportDiscordTitles from './export-discord-titles.js'; +export * as discordActivity from './discord-activity.js'; +export * as discordRpc from './discord-rpc.js'; +export * as remoteConfig from './remote-config.js'; +export * as storage from './storage.js'; +export * as presenceEmbedRender from './presence-embed-render.js'; +export * as presenceEmbedServer from './presence-embed-server.js'; diff --git a/src/cli/util/discord-activity.ts b/src/cli/util/discord-activity.ts index c0fcae5..e55b281 100644 --- a/src/cli/util/discord-activity.ts +++ b/src/cli/util/discord-activity.ts @@ -2,7 +2,7 @@ import process from 'node:process'; import { fetch } from 'undici'; import { getPresenceFromUrl } from '../../api/znc-proxy.js'; import { ActiveEvent, CurrentUser, Friend, Game, Presence, PresenceState } from '../../api/coral-types.js'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import { getDiscordPresence, getInactiveDiscordPresence } from '../../discord/util.js'; import { DiscordPresenceContext, DiscordPresencePlayTime } from '../../discord/types.js'; import createDebug from '../../util/debug.js'; diff --git a/src/cli/util/discord-rpc.ts b/src/cli/util/discord-rpc.ts index f488345..46fdad3 100644 --- a/src/cli/util/discord-rpc.ts +++ b/src/cli/util/discord-rpc.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import { DiscordRpcClient, getAllIpcSockets } from '../../discord/rpc.js'; import { defaultTitle } from '../../discord/titles.js'; import createDebug from '../../util/debug.js'; diff --git a/src/cli/util/export-discord-titles.ts b/src/cli/util/export-discord-titles.ts index 886767c..b337fe3 100644 --- a/src/cli/util/export-discord-titles.ts +++ b/src/cli/util/export-discord-titles.ts @@ -1,5 +1,5 @@ import { fetch } from 'undici'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { titles as unsorted_titles } from '../../discord/titles.js'; diff --git a/src/cli/util/index.ts b/src/cli/util/index.ts index 6857546..0360670 100644 --- a/src/cli/util/index.ts +++ b/src/cli/util/index.ts @@ -1,9 +1,24 @@ -export * as captureid from './captureid.js'; -export * as validateDiscordTitles from './validate-discord-titles.js'; -export * as exportDiscordTitles from './export-discord-titles.js'; -export * as discordActivity from './discord-activity.js'; -export * as discordRpc from './discord-rpc.js'; -export * as remoteConfig from './remote-config.js'; -export * as storage from './storage.js'; -export * as presenceEmbedRender from './presence-embed-render.js'; -export * as presenceEmbedServer from './presence-embed-server.js'; +import type { Arguments as ParentArguments } from '../../cli.js'; +import createDebug from '../../util/debug.js'; +import { Argv, YargsArguments } from '../../util/yargs.js'; +import { dev } from '../../util/product.js'; +import * as commands from './commands.js'; + +const debug = createDebug('cli:util'); + +export const command = 'util '; +export const desc = 'Utilities'; + +export function builder(yargs: Argv) { + for (const command of Object.values(commands)) { + if (command.command === 'validate-discord-titles' && !dev) continue; + if (command.command === 'export-discord-titles' && !dev) continue; + + // @ts-expect-error + yargs.command(command); + } + + return yargs; +} + +export type Arguments = YargsArguments>; diff --git a/src/cli/util/presence-embed-render.ts b/src/cli/util/presence-embed-render.ts index d1db5e4..d05422d 100644 --- a/src/cli/util/presence-embed-render.ts +++ b/src/cli/util/presence-embed-render.ts @@ -1,11 +1,11 @@ import mimetypes from 'mime-types'; import { FestVoteState } from 'splatnet3-types/splatnet3'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { getPresenceFromUrl } from '../../api/znc-proxy.js'; import { PresenceResponse } from '../presence-server.js'; -import { PresenceEmbedFormat, PresenceEmbedTheme, renderUserEmbedImage, renderUserEmbedSvg } from './presence-embed.js'; +import { PresenceEmbedFormat, PresenceEmbedTheme, renderUserEmbedImage, renderUserEmbedSvg } from '../../common/presence-embed.js'; const debug = createDebug('cli:util:render-presence-embed'); diff --git a/src/cli/util/presence-embed-server.ts b/src/cli/util/presence-embed-server.ts index b81fc7d..faa29c4 100644 --- a/src/cli/util/presence-embed-server.ts +++ b/src/cli/util/presence-embed-server.ts @@ -4,17 +4,17 @@ import express, { Request, Response } from 'express'; import { createHash } from 'node:crypto'; import mimetypes from 'mime-types'; import { FestVoteState } from 'splatnet3-types/splatnet3'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { getPresenceFromUrl } from '../../api/znc-proxy.js'; import { PresenceResponse } from '../presence-server.js'; import { addCliFeatureUserAgent } from '../../util/useragent.js'; -import { HttpServer, ResponseError } from './http-server.js'; +import { HttpServer, ResponseError } from '../../util/http-server.js'; import { git, product, version } from '../../util/product.js'; import { parseListenAddress } from '../../util/net.js'; import { RawValueSymbol, htmlentities } from '../../util/misc.js'; -import { PresenceEmbedFormat, PresenceEmbedTheme, getUserEmbedOptionsFromRequest, renderUserEmbedImage, renderUserEmbedSvg } from './presence-embed.js'; +import { PresenceEmbedFormat, PresenceEmbedTheme, getUserEmbedOptionsFromRequest, renderUserEmbedImage, renderUserEmbedSvg } from '../../common/presence-embed.js'; const debug = createDebug('cli:util:presence-embed-server'); diff --git a/src/cli/util/remote-config.ts b/src/cli/util/remote-config.ts index f2e1e38..9ce45a0 100644 --- a/src/cli/util/remote-config.ts +++ b/src/cli/util/remote-config.ts @@ -1,4 +1,4 @@ -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; diff --git a/src/cli/util/storage.ts b/src/cli/util/storage.ts index b468e92..edb5ed5 100644 --- a/src/cli/util/storage.ts +++ b/src/cli/util/storage.ts @@ -1,9 +1,9 @@ import * as util from 'node:util'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { Argv } from '../../util/yargs.js'; import { initStorage, iterateLocalStorage } from '../../util/storage.js'; -import Table from './table.js'; +import Table from '../../util/table.js'; import { createHash } from 'node:crypto'; import { Storage } from '../../client/storage/index.js'; import { LocalStorageProvider } from '../../client/storage/local.js'; diff --git a/src/cli/util/validate-discord-titles.ts b/src/cli/util/validate-discord-titles.ts index 9cc2f14..66487f1 100644 --- a/src/cli/util/validate-discord-titles.ts +++ b/src/cli/util/validate-discord-titles.ts @@ -1,5 +1,5 @@ import process from 'node:process'; -import type { Arguments as ParentArguments } from '../util.js'; +import type { Arguments as ParentArguments } from './index.js'; import createDebug from '../../util/debug.js'; import { ArgumentsCamelCase } from '../../util/yargs.js'; import * as publishers from '../../discord/titles/index.js'; diff --git a/src/cli/util/presence-embed.ts b/src/common/presence-embed.ts similarity index 97% rename from src/cli/util/presence-embed.ts rename to src/common/presence-embed.ts index 9deb7fd..c7a373d 100644 --- a/src/cli/util/presence-embed.ts +++ b/src/common/presence-embed.ts @@ -3,13 +3,13 @@ import * as path from 'node:path'; import { Request } from 'express'; import sharp from 'sharp'; import { CoopRule, FestVoteState, FriendOnlineState, StageScheduleResult } from 'splatnet3-types/splatnet3'; -import { dir } from '../../util/product.js'; -import createDebug from '../../util/debug.js'; -import { Game, PresenceState } from '../../api/coral-types.js'; -import { RawValueSymbol, htmlentities } from '../../util/misc.js'; -import { PresenceResponse } from '../presence-server.js'; +import { dir } from '../util/product.js'; +import createDebug from '../util/debug.js'; +import { Game, PresenceState } from '../api/coral-types.js'; +import { RawValueSymbol, htmlentities } from '../util/misc.js'; +import { PresenceResponse } from '../cli/presence-server.js'; -const debug = createDebug('cli:util:presence-embed'); +const debug = createDebug('nxapi:common:presence-embed'); type VsSchedule_event = StageScheduleResult['eventSchedules']['nodes'][0]; type LeagueMatchSetting_schedule = VsSchedule_event['leagueMatchSetting']; diff --git a/src/cli/util/http-server.ts b/src/util/http-server.ts similarity index 97% rename from src/cli/util/http-server.ts rename to src/util/http-server.ts index 00d65be..edee1c1 100644 --- a/src/cli/util/http-server.ts +++ b/src/util/http-server.ts @@ -1,9 +1,9 @@ import { NextFunction, Request, RequestHandler, Response } from 'express'; -import { ErrorResponse } from '../../api/util.js'; -import createDebug from '../../util/debug.js'; -import { temporary_http_errors, temporary_system_errors } from '../../util/errors.js'; +import { ErrorResponse } from '../api/util.js'; +import createDebug from './debug.js'; +import { temporary_http_errors, temporary_system_errors } from './errors.js'; -const debug = createDebug('cli:util:http-server'); +const debug = createDebug('nxapi:util:http-server'); export class HttpServer { retry_after = 60; diff --git a/src/cli/util/table.ts b/src/util/table.ts similarity index 100% rename from src/cli/util/table.ts rename to src/util/table.ts