Deps: upgrade deps & use ESM (#343)
* upgrade deps * upgrade forge * make app work in ESM * fix CI
This commit is contained in:
@@ -3,21 +3,12 @@ import path from "path";
|
||||
import settings from "@main/settings";
|
||||
import "@main/i18n";
|
||||
import mainWindow from "@main/window";
|
||||
import crypto from "crypto";
|
||||
import log from "electron-log/main";
|
||||
|
||||
log.transports.file.level = "info";
|
||||
log.transports.file.resolvePathFn = () =>
|
||||
path.join(settings.libraryPath(), "logs", "main.log");
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
// Fix "getRandomValues() not supported"
|
||||
global.crypto = crypto;
|
||||
import ElectronSquirrelStartup from "electron-squirrel-startup";
|
||||
|
||||
app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer");
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
if (require("electron-squirrel-startup")) {
|
||||
if (ElectronSquirrelStartup) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as sdk from "microsoft-cognitiveservices-speech-sdk";
|
||||
import fs from "fs-extra";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
const logger = log.scope("AZURE");
|
||||
export class AzureSpeechSdk {
|
||||
|
||||
@@ -8,7 +8,7 @@ const filename = path.resolve(
|
||||
);
|
||||
|
||||
const template = `
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
// code here
|
||||
@@ -18,8 +18,7 @@ async function down({ context: queryInterface }) {
|
||||
// code here
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
`;
|
||||
export { up, down };`;
|
||||
|
||||
await fs.mkdir(path.resolve(__dirname, "migrations"), { recursive: true });
|
||||
await fs.writeFile(filename, template.trim());
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { Audio, Transcription } from "@main/db/models";
|
||||
import { FindOptions, WhereOptions, Attributes } from "sequelize";
|
||||
import downloader from "@main/downloader";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { t } from "i18next";
|
||||
import youtubedr from "@main/youtubedr";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { Conversation, Message } from "@main/db/models";
|
||||
import { FindOptions, WhereOptions, Attributes } from "sequelize";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { t } from "i18next";
|
||||
|
||||
class ConversationsHandler {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { Message, Speech, Conversation } from "@main/db/models";
|
||||
import { FindOptions, WhereOptions, Attributes } from "sequelize";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { t } from "i18next";
|
||||
import db from "@main/db";
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from "sequelize";
|
||||
import dayjs from "dayjs";
|
||||
import { t } from "i18next";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
const logger = log.scope("db/handlers/recordings-handler");
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { Transcription, Audio, Video } from "@main/db/models";
|
||||
import { Attributes } from "sequelize";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
const logger = log.scope("db/handlers/transcriptions-handler");
|
||||
class TranscriptionsHandler {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { Video, Transcription } from "@main/db/models";
|
||||
import { FindOptions, WhereOptions, Attributes } from "sequelize";
|
||||
import downloader from "@main/downloader";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { t } from "i18next";
|
||||
import youtubedr from "@main/youtubedr";
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ import {
|
||||
transcriptionsHandler,
|
||||
videosHandler,
|
||||
} from "./handlers";
|
||||
import path from "path";
|
||||
import url from 'url';
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const db = {
|
||||
connection: null as Sequelize | null,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -78,4 +78,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("audios");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -78,4 +78,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("videos");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -73,4 +73,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("recordings");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -74,5 +74,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("pronunciation_assessments");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable("conversations", {
|
||||
@@ -35,5 +35,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("conversations");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable("messages", {
|
||||
@@ -34,4 +34,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("messages");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -59,4 +59,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("speeches");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -46,5 +46,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("cache_objects");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
|
||||
export { up, down };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
import { DataTypes } from "sequelize";
|
||||
|
||||
async function up({ context: queryInterface }) {
|
||||
queryInterface.createTable(
|
||||
@@ -64,5 +64,4 @@ async function down({ context: queryInterface }) {
|
||||
queryInterface.dropTable("transcriptions");
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
||||
|
||||
export { up, down };
|
||||
|
||||
@@ -22,7 +22,7 @@ import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import { t } from "i18next";
|
||||
import mainWindow from "@main/window";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import storage from "@main/storage";
|
||||
import Ffmpeg from "@main/ffmpeg";
|
||||
import { Client } from "@/api";
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
DataType,
|
||||
AllowNull,
|
||||
} from "sequelize-typescript";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
const logger = log.scope("cache-object");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import settings from "@main/settings";
|
||||
import db from "@main/db";
|
||||
import mainWindow from "@main/window";
|
||||
import { t } from "i18next";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import fs from "fs-extra";
|
||||
import path from "path";
|
||||
import Ffmpeg from "@main/ffmpeg";
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Recording } from "@main/db/models";
|
||||
import { Client } from "@/api";
|
||||
import { WEB_API_URL } from "@/constants";
|
||||
import settings from "@main/settings";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
@Table({
|
||||
modelName: "PronunciationAssessment",
|
||||
|
||||
@@ -20,7 +20,7 @@ import fs from "fs-extra";
|
||||
import path from "path";
|
||||
import settings from "@main/settings";
|
||||
import { hashFile } from "@main/utils";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import storage from "@main/storage";
|
||||
import { Client } from "@/api";
|
||||
import { WEB_API_URL } from "@/constants";
|
||||
|
||||
@@ -22,7 +22,7 @@ import OpenAI, { type ClientOptions } from "openai";
|
||||
import { t } from "i18next";
|
||||
import { hashFile } from "@main/utils";
|
||||
import { Audio, Message } from "@main/db/models";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { WEB_API_URL } from "@/constants";
|
||||
import proxyAgent from "@main/proxy-agent";
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "sequelize-typescript";
|
||||
import { Audio, Video } from "@main/db/models";
|
||||
import mainWindow from "@main/window";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { Client } from "@/api";
|
||||
import { WEB_API_URL, PROCESS_TIMEOUT } from "@/constants";
|
||||
import settings from "@main/settings";
|
||||
|
||||
@@ -22,7 +22,7 @@ import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import { t } from "i18next";
|
||||
import mainWindow from "@main/window";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import storage from "@main/storage";
|
||||
import Ffmpeg from "@main/ffmpeg";
|
||||
import { Client } from "@/api";
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ipcMain, app } from "electron";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import mainWin from "@main/window";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
|
||||
const logger = log.scope("downloader");
|
||||
class Downloader {
|
||||
|
||||
@@ -2,10 +2,14 @@ import { ipcMain } from "electron";
|
||||
import ffmpegPath from "ffmpeg-static";
|
||||
import ffprobePath from "@andrkrn/ffprobe-static";
|
||||
import Ffmpeg from "fluent-ffmpeg";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import settings from "./settings";
|
||||
import url from 'url';
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
Ffmpeg.setFfmpegPath(ffmpegPath);
|
||||
Ffmpeg.setFfprobePath(ffprobePath);
|
||||
|
||||
12
enjoy/src/main/logger.ts
Normal file
12
enjoy/src/main/logger.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import log from "electron-log/main";
|
||||
import path from "path";
|
||||
import settings from "@main/settings";
|
||||
|
||||
log.initialize({ preload: true });
|
||||
|
||||
log.transports.file.level = "info";
|
||||
log.transports.file.resolvePathFn = () =>
|
||||
path.join(settings.libraryPath(), "logs", "main.log");
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
export default log;
|
||||
@@ -1,4 +1,4 @@
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import $ from "cheerio";
|
||||
import { BrowserView, ipcMain } from "electron";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import $ from "cheerio";
|
||||
import { BrowserView, ipcMain } from "electron";
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { LIBRARY_PATH_SUFFIX, DATABASE_NAME } from "@/constants";
|
||||
import { ipcMain, app } from "electron";
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import log from "electron-log";
|
||||
import * as i18n from "i18next";
|
||||
|
||||
if (process.env.SETTINGS_PATH) {
|
||||
@@ -13,7 +12,6 @@ if (process.env.SETTINGS_PATH) {
|
||||
});
|
||||
}
|
||||
|
||||
const logger = log.scope("settings");
|
||||
const language = () => {
|
||||
const _language = settings.getSync("language");
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { STORAGE_WORKER_ENDPOINT } from "@/constants";
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import fs from "fs-extra";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
const logger = log.scope("STORAGE");
|
||||
|
||||
const ONE_MINUTE = 1000 * 60; // 1 minute
|
||||
|
||||
@@ -4,7 +4,11 @@ import path from "path";
|
||||
import { WHISPER_MODELS_OPTIONS, PROCESS_TIMEOUT } from "@/constants";
|
||||
import { exec, spawn } from "child_process";
|
||||
import fs from "fs-extra";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import url from 'url';
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const logger = log.scope("whisper");
|
||||
|
||||
|
||||
@@ -15,13 +15,16 @@ import downloader from "@main/downloader";
|
||||
import whisper from "@main/whisper";
|
||||
import fs from "fs-extra";
|
||||
import "@main/i18n";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import { WEB_API_URL, REPO_URL } from "@/constants";
|
||||
import { AudibleProvider, TedProvider } from "@main/providers";
|
||||
import Ffmpeg from "@main/ffmpeg";
|
||||
import { Waveform } from "./waveform";
|
||||
import url from 'url';
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
log.initialize({ preload: true });
|
||||
const logger = log.scope("window");
|
||||
|
||||
const audibleProvider = new AudibleProvider();
|
||||
|
||||
@@ -3,9 +3,13 @@ import path from "path";
|
||||
import { exec } from "child_process";
|
||||
import fs from "fs-extra";
|
||||
import os from "os";
|
||||
import log from "electron-log/main";
|
||||
import log from "@main/logger";
|
||||
import snakeCase from "lodash/snakeCase";
|
||||
import settings from "@main/settings";
|
||||
import url from 'url';
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const logger = log.scope("YOUTUBEDR");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user