Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use snake_case for file naming #416

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .erb/configs/webpack.config.renderer.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const configuration: webpack.Configuration = {
isBrowser: false,
isDevelopment: process.env.NODE_ENV !== "production",
}),

new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }),
],
};

Expand Down
4 changes: 2 additions & 2 deletions src/broadcast/broadcast.worker.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import electronLog from "electron-log";
import { Worker } from "threads";
import type { RegisteredWorker } from "utils/registerWorker";
import { registerWorker } from "utils/registerWorker";
import type { RegisteredWorker } from "utils/register_worker";
import { registerWorker } from "utils/register_worker";

import type { WorkerSpec as BroadcastWorkerSpec } from "./broadcast.worker";
import {
Expand Down Expand Up @@ -33,7 +33,7 @@
worker.getErrorObservable().subscribe((err) => {
log.error(err);
const errorMessage = err instanceof Error ? err.message : err;
ipc_broadcastErrorOccurredEvent.main!.trigger({ errorMessage }).catch(log.error);

Check warning on line 36 in src/broadcast/broadcast.worker.interface.ts

View workflow job for this annotation

GitHub Actions / Test on node 18.x and ubuntu-latest

Avoid using promises inside of callbacks
});
worker.getReconnectObservable().subscribe(({ config }) => {
ipc_broadcastReconnectEvent.main!.trigger({ config }).catch(log.error);
Expand Down
2 changes: 1 addition & 1 deletion src/broadcast/broadcast.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ModuleMethods } from "threads/dist/types/master";
import { Observable, Subject } from "threads/observable";
import { expose } from "threads/worker";

import { BroadcastManager } from "./broadcastManager";
import { BroadcastManager } from "./broadcast_manager";
import type { StartBroadcastConfig } from "./types";
import { BroadcastEvent } from "./types";

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/broadcast/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Preconditions } from "@common/preconditions";
import type { DolphinManager } from "@dolphin/manager";
import type { DolphinPlaybackClosedEvent } from "@dolphin/types";
import { DolphinEventType, DolphinLaunchType } from "@dolphin/types";
import type { SettingsManager } from "@settings/settingsManager";
import type { SettingsManager } from "@settings/settings_manager";
import log from "electron-log";

import type { BroadcastWorker } from "./broadcast.worker.interface";
Expand Down
4 changes: 2 additions & 2 deletions src/broadcast/spectate.worker.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { DolphinManager } from "@dolphin/manager";
import type { ReplayCommunication } from "@dolphin/types";
import electronLog from "electron-log";
import { Worker } from "threads";
import type { RegisteredWorker } from "utils/registerWorker";
import { registerWorker } from "utils/registerWorker";
import type { RegisteredWorker } from "utils/register_worker";
import { registerWorker } from "utils/register_worker";

import { ipc_broadcastListUpdatedEvent, ipc_spectateErrorOccurredEvent, ipc_spectateReconnectEvent } from "./ipc";
import type { WorkerSpec as SpectateWorkerSpec } from "./spectate.worker";
Expand Down
2 changes: 1 addition & 1 deletion src/broadcast/spectate.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ModuleMethods } from "threads/dist/types/master";
import { Observable, Subject } from "threads/observable";
import { expose } from "threads/worker";

import { SpectateManager } from "./spectateManager";
import { SpectateManager } from "./spectate_manager";
import type { BroadcasterItem } from "./types";
import { SpectateEvent } from "./types";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/console/mirror.worker.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { DolphinManager } from "@dolphin/manager";
import type { ReplayCommunication } from "@dolphin/types";
import electronLog from "electron-log";
import { Worker } from "threads";
import type { RegisteredWorker } from "utils/registerWorker";
import { registerWorker } from "utils/registerWorker";
import type { RegisteredWorker } from "utils/register_worker";
import { registerWorker } from "utils/register_worker";

import { ipc_consoleMirrorErrorMessageEvent, ipc_consoleMirrorStatusUpdatedEvent } from "./ipc";
import type { WorkerSpec as MirrorWorkerSpec } from "./mirror.worker";
Expand Down
2 changes: 1 addition & 1 deletion src/console/mirror.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ModuleMethods } from "threads/dist/types/master";
import { Observable, Subject } from "threads/observable";
import { expose } from "threads/worker";

import { MirrorManager } from "./mirrorManager";
import { MirrorManager } from "./mirror_manager";
import type { ConsoleMirrorStatusUpdate, MirrorConfig } from "./types";
import { MirrorEvent } from "./types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { EventEmitter } from "events";
import * as fs from "fs-extra";
import path from "path";

import { AutoSwitcher } from "./autoSwitcher";
import { ConsoleRelay } from "./consoleRelay";
import { AutoSwitcher } from "./auto_switcher";
import { ConsoleRelay } from "./console_relay";
import type { MirrorConfig, MirrorDetails } from "./types";
import { MirrorEvent } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion src/console/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DolphinPlaybackClosedEvent } from "@dolphin/types";
import { DolphinEventType, DolphinLaunchType } from "@dolphin/types";
import log from "electron-log";

import { connectionScanner } from "./connectionScanner";
import { connectionScanner } from "./connection_scanner";
import {
ipc_connectToConsoleMirror,
ipc_disconnectFromConsoleMirror,
Expand Down
4 changes: 2 additions & 2 deletions src/console/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConsoleConnection, SlpFileWriter } from "@slippi/slippi-js";

import type { AutoSwitcher } from "./autoSwitcher";
import type { ConsoleRelay } from "./consoleRelay";
import type { AutoSwitcher } from "./auto_switcher";
import type { ConsoleRelay } from "./console_relay";

export type ConsoleMirrorStatusUpdate = {
status: number;
Expand Down
2 changes: 1 addition & 1 deletion src/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Make any changes you need to the `src/database/schema.ts` file, such as defining

#### 2. Create a new migration file

Using the ISO timestamp format, create a new file in the `src/database/migrations` folder. Migrations are run in alphabetical order so it's imperative to follow the naming convention: `YYYYMMDDTHHMM-some-description.ts` to ensure the migrations are applied correctly. For example: `20231103T1139-add-foo-column.ts`
Using the ISO timestamp format, create a new file in the `src/database/migrations` folder. Migrations are run in alphabetical order so it's imperative to follow the naming convention: `YYYYMMDDTHHMM_some_description.ts` to ensure the migrations are applied correctly. For example: `20231103T1139_add_foo_column.ts`

#### 3. Write the migration code

Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-default-export */

import type { GeckoCode } from "./config/geckoCode";
import type { GeckoCode } from "./config/gecko_code";
import {
ipc_checkDesktopAppDolphin,
ipc_checkPlayKeyExists,
Expand Down
8 changes: 4 additions & 4 deletions src/dolphin/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defaultAppSettings } from "@settings/defaultSettings";
import { defaultAppSettings } from "@settings/default_settings";

import type { GeckoCode } from "./geckoCode";
import { loadGeckoCodes, setCodes } from "./geckoCode";
import type { IniFile } from "./iniFile";
import type { GeckoCode } from "./gecko_code";
import { loadGeckoCodes, setCodes } from "./gecko_code";
import type { IniFile } from "./ini_file";

export type SyncedDolphinSettings = {
useMonthlySubfolders: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IniFile } from "./iniFile";
import type { IniFile } from "./ini_file";

export type GeckoCode = {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import electronLog from "electron-log";
import fs from "fs";
import { ensureFile } from "fs-extra";
import readline from "readline";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

const log = electronLog.scope("iniFile");

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SyncedDolphinSettings } from "@dolphin/config/config";
import { addGamePath, getSlippiIshiiSettings, setSlippiIshiiSettings } from "@dolphin/config/config";
import { IniFile } from "@dolphin/config/iniFile";
import { IniFile } from "@dolphin/config/ini_file";
import { spawnSync } from "child_process";
import { app } from "electron";
import electronLog from "electron-log";
Expand All @@ -12,7 +12,7 @@ import { lt } from "semver";
import type { DolphinInstallation } from "../types";
import { DolphinLaunchType } from "../types";
import { downloadLatestDolphin } from "./download";
import type { DolphinVersionResponse } from "./fetchLatestVersion";
import type { DolphinVersionResponse } from "./fetch_latest_version";

const log = electronLog.scope("dolphin/ishiiInstallation");

Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/install/macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from "fs-extra";
import os from "os";
import path from "path";

import { extractDmg, mountDmg, unmountDmg } from "./extractDmg";
import { extractDmg, mountDmg, unmountDmg } from "./extract_dmg";

export async function installIshiirukaDolphinOnMac({
assetPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SyncedDolphinSettings } from "@dolphin/config/config";
import { addGamePath, getSlippiMainlineSettings, setSlippiMainlineSettings } from "@dolphin/config/config";
import { IniFile } from "@dolphin/config/iniFile";
import { IniFile } from "@dolphin/config/ini_file";
import { spawnSync } from "child_process";
import { app } from "electron";
import electronLog from "electron-log";
Expand All @@ -12,7 +12,7 @@ import { lt } from "semver";
import type { DolphinInstallation } from "../types";
import { DolphinLaunchType } from "../types";
import { downloadLatestDolphin } from "./download";
import type { DolphinVersionResponse } from "./fetchLatestVersion";
import type { DolphinVersionResponse } from "./fetch_latest_version";

const log = electronLog.scope("dolphin/mainlineInstallation");

Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EventEmitter } from "events";
import * as fs from "fs-extra";
import { debounce } from "lodash";
import path from "path";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

import type { ReplayCommunication } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { EmptyPayload, SuccessPayload } from "utils/ipc";
import { _, makeEndpoint } from "utils/ipc";

import type { GeckoCode } from "./config/geckoCode";
import type { GeckoCode } from "./config/gecko_code";
import type { DolphinEvent, DolphinLaunchType, PlayKey, ReplayQueueItem } from "./types";

// Handlers
Expand Down
10 changes: 5 additions & 5 deletions src/dolphin/manager.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Preconditions } from "@common/preconditions";
import type { SettingsManager } from "@settings/settingsManager";
import type { SettingsManager } from "@settings/settings_manager";
import { app } from "electron";
import electronLog from "electron-log";
import { move, remove } from "fs-extra";
import { Observable, Subject } from "observable-fns";
import os from "os";
import path from "path";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

import { type DolphinVersionResponse, fetchLatestVersion } from "./install/fetchLatestVersion";
import { IshiirukaDolphinInstallation } from "./install/ishiiInstallation";
import { MainlineDolphinInstallation } from "./install/mainlineInstallation";
import { type DolphinVersionResponse, fetchLatestVersion } from "./install/fetch_latest_version";
import { IshiirukaDolphinInstallation } from "./install/ishiiruka_installation";
import { MainlineDolphinInstallation } from "./install/mainline_installation";
import { DolphinInstance, PlaybackDolphinInstance } from "./instance";
import type { DolphinEvent, DolphinInstallation, ReplayCommunication } from "./types";
import { DolphinEventType, DolphinLaunchType } from "./types";
Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/playkey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DolphinInstallation, PlayKey } from "@dolphin/types";
import * as fs from "fs-extra";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

export async function writePlayKeyFile(installation: DolphinInstallation, playKey: PlayKey): Promise<void> {
const keyPath = await installation.findPlayKey();
Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import log from "electron-log";
import * as fs from "fs-extra";
import { isEqual } from "lodash";
import path from "path";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

import {
ipc_checkDesktopAppDolphin,
Expand Down
4 changes: 2 additions & 2 deletions src/dolphin/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SyncedDolphinSettings } from "./config/config";
import type { GeckoCode } from "./config/geckoCode";
import type { DolphinVersionResponse } from "./install/fetchLatestVersion";
import type { GeckoCode } from "./config/gecko_code";
import type { DolphinVersionResponse } from "./install/fetch_latest_version";

export type ReplayCommunication = {
mode: "normal" | "mirror" | "queue"; // default normal
Expand Down
6 changes: 3 additions & 3 deletions src/dolphin/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as fs from "fs-extra";
import path from "path";

import { setBootToCss } from "./config/config";
import type { GeckoCode } from "./config/geckoCode";
import { loadGeckoCodes, setCodes } from "./config/geckoCode";
import { IniFile } from "./config/iniFile";
import type { GeckoCode } from "./config/gecko_code";
import { loadGeckoCodes, setCodes } from "./config/gecko_code";
import { IniFile } from "./config/ini_file";
import type { DolphinInstallation } from "./types";
import { DolphinLaunchType } from "./types";

Expand Down
13 changes: 11 additions & 2 deletions src/main/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const MINUTE = 60 * SECOND;

const EXPIRES_IN = 10 * MINUTE;

export type GithubReleaseInfo = {
id: number;
name: string;
body: string;
published_at: string;
html_url: string;
tag_name: string;
};

// Let's cache our Github responses so we don't exceed the 60 requests/hour rate limit
type ResponseCacheEntry = {
time: number;
Expand All @@ -16,7 +25,7 @@ type ResponseCacheEntry = {

const githubResponseCache: Record<string, ResponseCacheEntry> = {};

export async function getLatestRelease(owner: string, repo: string): Promise<any> {
export async function getLatestRelease(owner: string, repo: string): Promise<GithubReleaseInfo> {
// We can re-use api calls by returning the first item in all releases
// since it already returns the newest release first.
const data = await getAllReleases(owner, repo);
Expand All @@ -26,7 +35,7 @@ export async function getLatestRelease(owner: string, repo: string): Promise<any
throw new Error(`No releases found for ${owner}/${repo}`);
}

export async function getAllReleases(owner: string, repo: string): Promise<any> {
export async function getAllReleases(owner: string, repo: string): Promise<GithubReleaseInfo[]> {
const url = `https://api.github.com/repos/${owner}/${repo}/releases`;
const data = await cachedFetch(url);
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/main/installModules.ts → src/main/install_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import setupConsoleIpc from "@console/setup";
import { DolphinManager } from "@dolphin/manager";
import setupDolphinIpc from "@dolphin/setup";
import setupReplaysIpc from "@replays/setup";
import { SettingsManager } from "@settings/settingsManager";
import { SettingsManager } from "@settings/settings_manager";
import setupSettingsIpc from "@settings/setup";

import type { ConfigFlags } from "./flags/flags";
Expand Down
10 changes: 5 additions & 5 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import last from "lodash/last";
import path from "path";
import url from "url";
import { download } from "utils/download";
import { fileExists } from "utils/fileExists";
import { fileExists } from "utils/file_exists";

import { getConfigFlags } from "./flags/flags";
import { installModules } from "./installModules";
import { installModules } from "./install_modules";
import { MenuBuilder } from "./menu";
import { resolveHtmlPath } from "./util";

const isDevelopment = process.env.NODE_ENV === "development" || process.env.DEBUG_PROD === "true";

const isMac = process.platform === "darwin";

let menu: CrossProcessExports.Menu | null = null;
Expand All @@ -40,6 +42,7 @@ let didFinishLoad = false;

log.initialize();
log.catchErrors();
log.transports.file.level = isDevelopment ? "info" : "warn";

// Only allow a single Slippi App instance
const lockObtained = app.requestSingleInstanceLock();
Expand All @@ -52,7 +55,6 @@ const { dolphinManager, settingsManager } = installModules(flags);

class AppUpdater {
constructor() {
log.transports.file.level = "info";
autoUpdater.logger = log;
autoUpdater.autoInstallOnAppQuit = settingsManager.get().settings.autoUpdateLauncher;
}
Expand All @@ -63,8 +65,6 @@ if (process.env.NODE_ENV === "production") {
sourceMapSupport.install();
}

const isDevelopment = process.env.NODE_ENV === "development" || process.env.DEBUG_PROD === "true";

if (isDevelopment) {
require("electron-debug")();
}
Expand Down
File renamed without changes.
Loading
Loading