Remove unpacked dependencies from app

This commit is contained in:
Samuel Elliott 2022-06-28 15:47:41 +01:00
parent 714b79c362
commit a2f3abaebd
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 31 additions and 11 deletions

View File

@ -84,12 +84,16 @@
"files": [ "files": [
"dist/app/bundle", "dist/app/bundle",
"dist/bundle", "dist/bundle",
"!dist/app/package" "!dist/app/package",
"!**/node_modules/**/*"
], ],
"asar": false, "asar": false,
"extraMetadata": { "extraMetadata": {
"name": "nxapi-app", "name": "nxapi-app",
"main": "dist/bundle/app-main-bundle.cjs" "main": "dist/bundle/app-main-bundle.cjs",
"dependencies": {},
"optionalDependencies": {},
"devDependencies": {}
}, },
"directories": { "directories": {
"output": "dist/app/package" "output": "dist/app/package"

View File

@ -1,7 +1,6 @@
import * as path from 'node:path'; import * as path from 'node:path';
import createDebug from 'debug'; import createDebug from 'debug';
import persist from 'node-persist'; import persist from 'node-persist';
import notifier from 'node-notifier';
import type { Arguments as ParentArguments } from '../nso.js'; import type { Arguments as ParentArguments } from '../nso.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js'; import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js'; import { initStorage } from '../../util/storage.js';
@ -105,6 +104,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const i = new ZncNotifications(storage, token, nso, data); const i = new ZncNotifications(storage, token, nso, data);
i.notifications = new TerminalNotificationManager(await import('node-notifier'));
i.user_notifications = argv.userNotifications; i.user_notifications = argv.userNotifications;
i.friend_notifications = argv.friendNotifications; i.friend_notifications = argv.friendNotifications;
i.update_interval = argv.updateInterval; i.update_interval = argv.updateInterval;
@ -127,10 +127,14 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
} }
export class TerminalNotificationManager extends NotificationManager { export class TerminalNotificationManager extends NotificationManager {
constructor(private readonly notifier: typeof import('node-notifier')) {
super();
}
onFriendOnline(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) { onFriendOnline(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) {
const currenttitle = friend.presence.game as Game; const currenttitle = friend.presence.game as Game;
notifier.notify({ this.notifier.notify({
title: friend.name, title: friend.name,
message: 'Playing ' + currenttitle.name + message: 'Playing ' + currenttitle.name +
(currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''), (currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''),
@ -140,7 +144,7 @@ export class TerminalNotificationManager extends NotificationManager {
} }
onFriendOffline(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) { onFriendOffline(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) {
notifier.notify({ this.notifier.notify({
title: friend.name, title: friend.name,
message: 'Offline', message: 'Offline',
icon: friend.imageUri, icon: friend.imageUri,
@ -150,7 +154,7 @@ export class TerminalNotificationManager extends NotificationManager {
onFriendPlayingChangeTitle(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) { onFriendPlayingChangeTitle(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) {
const currenttitle = friend.presence.game as Game; const currenttitle = friend.presence.game as Game;
notifier.notify({ this.notifier.notify({
title: friend.name, title: friend.name,
message: 'Playing ' + currenttitle.name + message: 'Playing ' + currenttitle.name +
(currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''), (currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''),
@ -162,7 +166,7 @@ export class TerminalNotificationManager extends NotificationManager {
onFriendTitleStateChange(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) { onFriendTitleStateChange(friend: CurrentUser | Friend, prev?: CurrentUser | Friend, naid?: string, ir?: boolean) {
const currenttitle = friend.presence.game as Game; const currenttitle = friend.presence.game as Game;
notifier.notify({ this.notifier.notify({
title: friend.name, title: friend.name,
message: 'Playing ' + currenttitle.name + message: 'Playing ' + currenttitle.name +
(currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''), (currenttitle.sysDescription ? '\n' + currenttitle.sysDescription : ''),

View File

@ -4,7 +4,7 @@ import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js'; import { initStorage } from '../../util/storage.js';
import { getToken } from '../../common/auth/nso.js'; import { getToken } from '../../common/auth/nso.js';
import { DiscordPresencePlayTime } from '../../discord/util.js'; import { DiscordPresencePlayTime } from '../../discord/util.js';
import { handleEnableSplatNet2Monitoring } from './notify.js'; import { handleEnableSplatNet2Monitoring, TerminalNotificationManager } from './notify.js';
import { ZncDiscordPresence, ZncProxyDiscordPresence } from '../../common/presence.js'; import { ZncDiscordPresence, ZncProxyDiscordPresence } from '../../common/presence.js';
const debug = createDebug('cli:nso:presence'); const debug = createDebug('cli:nso:presence');
@ -191,6 +191,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const i = new ZncDiscordPresence(storage, token, nso, data); const i = new ZncDiscordPresence(storage, token, nso, data);
i.notifications = new TerminalNotificationManager(await import('node-notifier'));
i.user_notifications = argv.userNotifications; i.user_notifications = argv.userNotifications;
i.friend_notifications = argv.friendNotifications; i.friend_notifications = argv.friendNotifications;
i.update_interval = argv.updateInterval; i.update_interval = argv.updateInterval;

View File

@ -1,15 +1,26 @@
import process from 'node:process'; import process from 'node:process';
import * as net from 'node:net'; import * as net from 'node:net';
import { createRequire } from 'node:module'; import { EventEmitter } from 'node:events';
import createDebug from 'debug'; import createDebug from 'debug';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import DiscordRPC from 'discord-rpc'; import DiscordRPC from 'discord-rpc';
// @ts-expect-error
import __BaseIpcTransport from 'discord-rpc/src/transports/ipc.js';
const debug = createDebug('nxapi:discord:rpc'); const debug = createDebug('nxapi:discord:rpc');
const require = createRequire(import.meta.url); declare class _BaseIpcTransport extends EventEmitter {
constructor(client: DiscordRPC.Client);
connect(): Promise<void>;
onClose(e: boolean): void;
send(data: unknown, op?: OPCode): void;
close(): Promise<boolean>;
ping(): void;
static encode(op: OPCode, data: unknown): Buffer;
static decode(socket: net.Socket, callback: (op: OPCode, data: unknown) => void): void;
}
const BaseIpcTransport = require('discord-rpc/src/transports/ipc.js'); const BaseIpcTransport = __BaseIpcTransport as typeof _BaseIpcTransport;
export async function getDiscordRpcClients() { export async function getDiscordRpcClients() {
const sockets = await getAllIpcSockets(); const sockets = await getAllIpcSockets();