Skip to content

Commit

Permalink
Upgrade deps (#306)
Browse files Browse the repository at this point in the history
* update scripts

* upgrade deps
  • Loading branch information
an-lee authored Feb 14, 2024
1 parent f57a5de commit ac4d327
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 136 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ nmHoistingLimits: workspaces
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.0.cjs

enableInlineBuilds: true
33 changes: 17 additions & 16 deletions enjoy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"main": ".vite/build/main.js",
"types": "./src/types.d.ts",
"scripts": {
"dev": "rimraf .vite && WEB_API_URL=http://localhost:3000 electron-forge start",
"start": "rimraf .vite && electron-forge start",
"package": "rimraf .vite && electron-forge package",
"make": "rimraf .vite && electron-forge make",
"publish": "rimraf .vite && electron-forge publish",
"predev": "yarn run download",
"dev": "rimraf .vite && yarn run download && WEB_API_URL=http://localhost:3000 electron-forge start",
"start": "rimraf .vite && yarn run download && electron-forge start",
"package": "rimraf .vite && yarn run download && electron-forge package",
"make": "rimraf .vite && yarn run download && electron-forge make",
"publish": "rimraf .vite && yarn run download && electron-forge publish",
"lint": "eslint --ext .ts,.tsx .",
"test": "playwright test",
"test": "yarn run package && playwright test",
"create-migration": "zx ./src/main/db/create-migration.mjs",
"download-whisper-model": "zx ./scripts/download-whisper-model.mjs",
"download-ffmpeg-wasm": "zx ./scripts/download-ffmpeg-wasm.mjs",
"postinstall": "zx ./scripts/download-whisper-model.mjs && zx ./scripts/download-ffmpeg-wasm.mjs"
"download": "yarn run download-whisper-model && yarn run download-ffmpeg-wasm"
},
"keywords": [],
"author": {
Expand Down Expand Up @@ -48,8 +49,8 @@
"@types/react-dom": "^18.2.19",
"@types/validator": "^13.11.9",
"@types/wavesurfer.js": "^6.0.12",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"electron": "^28.2.0",
Expand All @@ -74,7 +75,7 @@
"@ffmpeg/ffmpeg": "^0.12.10",
"@ffmpeg/util": "^0.12.1",
"@hookform/resolvers": "^3.3.4",
"@langchain/google-genai": "^0.0.8",
"@langchain/google-genai": "^0.0.10",
"@mozilla/readability": "^0.5.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
Expand Down Expand Up @@ -121,20 +122,20 @@
"fluent-ffmpeg": "^2.1.2",
"fs-extra": "^11.2.0",
"html-to-text": "^9.0.5",
"https-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.3",
"i18next": "^23.8.2",
"intl-tel-input": "^19.2.16",
"js-md5": "^0.8.3",
"langchain": "^0.1.17",
"lodash": "^4.17.21",
"lucide-react": "^0.323.0",
"lucide-react": "^0.330.0",
"mark.js": "^8.11.1",
"microsoft-cognitiveservices-speech-sdk": "^1.35.0",
"next-themes": "^0.2.1",
"openai": "^4.27.0",
"openai": "^4.28.0",
"pitchfinder": "^2.3.2",
"postcss": "^8.4.35",
"proxy-agent": "^6.3.1",
"proxy-agent": "^6.4.0",
"react": "^18.2.0",
"react-activity-calendar": "^2.2.7",
"react-dom": "^18.2.0",
Expand All @@ -143,10 +144,10 @@
"react-i18next": "^14.0.5",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.22.0",
"react-tooltip": "^5.26.0",
"react-tooltip": "^5.26.2",
"reflect-metadata": "^0.2.1",
"rimraf": "^5.0.5",
"sequelize": "^6.36.0",
"sequelize": "^6.37.0",
"sequelize-typescript": "^2.1.6",
"sonner": "^1.4.0",
"sqlite3": "^5.1.7",
Expand Down
35 changes: 17 additions & 18 deletions enjoy/scripts/download-ffmpeg-wasm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from "axios";
import { createHash } from "crypto";
import { HttpsProxyAgent } from "https-proxy-agent";

console.log(chalk.blue("=> Download ffmpeg wasm files"));
console.info(chalk.blue("=> Download ffmpeg wasm files"));

const files = [
{
Expand All @@ -28,15 +28,15 @@ await Promise.all(
files.map(async (file) => {
try {
if (fs.statSync(path.join(dir, file.name)).isFile()) {
console.log(chalk.green(`=> File ${file.name} already exists`));
console.info(chalk.green(` File ${file.name} already exists`));

const hash = await hashFile(path.join(dir, file.name), { algo: "md5" });
if (hash === file.md5) {
console.log(chalk.green(`=> File ${file.name} MD5 match`));
console.info(chalk.green(` File ${file.name} valid`));
} else {
console.log(
console.warn(
chalk.yellow(
`=> File ${file.name} MD5 not match, start to redownload`
` File ${file.name} not valid, start to redownload`
)
);
fs.removeSync(path.join(dir, file.name));
Expand All @@ -47,7 +47,7 @@ await Promise.all(
}
} catch (err) {
if (err && err.code !== "ENOENT") {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
process.exit(1);
}
pendingFiles.push(file);
Expand All @@ -56,10 +56,10 @@ await Promise.all(
);

if (pendingFiles.length === 0) {
console.log(chalk.green("=> All files already exist"));
console.info(chalk.green(" All files already exist"));
process.exit(0);
} else {
console.log(chalk.blue(`=> Start to download ${pendingFiles.length} files`));
console.info(chalk.blue(`=> Start to download ${pendingFiles.length} files`));
}

const proxyUrl =
Expand All @@ -77,12 +77,12 @@ if (proxyUrl) {
protocol: protocol,
};
axios.defaults.httpsAgent = httpsAgent;
console.log(chalk.blue(`=> Use proxy: ${proxyUrl}`));
console.info(chalk.blue(`=> Use proxy: ${proxyUrl}`));
}

const download = async (url, dest, md5) => {
return spinner(async () => {
console.log(chalk.blue(`=> Start to download file ${url}`));
console.info(chalk.blue(`=> Start to download file ${url}`));
await axios
.get(url, {
responseType: "arraybuffer",
Expand All @@ -92,20 +92,19 @@ const download = async (url, dest, md5) => {

fs.writeFileSync(dest, data);
const hash = await hashFile(dest, { algo: "md5" });
console.log(chalk.blue(`=> File ${dest}(MD5: ${hash})`));
if (hash === md5) {
console.log(chalk.green(`=> ${dest} downloaded successfully`));
console.info(chalk.green(` ${dest} downloaded successfully`));
} else {
console.log(
console.error(
chalk.red(
`=> Error: ${dest} MD5 not match, ${hash} should be ${md5}`
` Error: ${dest} MD5 not match, ${hash} should be ${md5}`
)
);
process.exit(1);
}
})
.catch((err) => {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
process.exit(1);
});
});
Expand All @@ -127,7 +126,7 @@ const cleanup = () => {
try {
fs.removeSync(path.join(dir, file.name));
} catch (err) {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
}
});
};
Expand All @@ -140,10 +139,10 @@ try {
)
);
} catch (err) {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
cleanup();
process.exit(1);
}

console.log(chalk.green("=> All files downloaded successfully"));
console.info(chalk.green(" All files downloaded successfully"));
process.exit(0);
18 changes: 9 additions & 9 deletions enjoy/scripts/download-whisper-model.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ const md5 = "55309cc6613788f07ac7988985210734";

const dir = path.join(process.cwd(), "lib/whisper.cpp/models");

console.log(chalk.blue(`=> Download whisper model ${model}`));
console.info(chalk.blue(`=> Download whisper model ${model}`));

fs.ensureDirSync(dir);
try {
if (fs.statSync(path.join(dir, model)).isFile()) {
console.log(chalk.green(`=> Model ${model} already exists`));
console.info(chalk.green(` Model ${model} already exists`));
const hash = await hashFile(path.join(dir, model), { algo: "md5" });
if (hash === md5) {
console.log(chalk.green(`=> Model ${model} MD5 match`));
console.info(chalk.green(` Model ${model} valid`));
process.exit(0);
} else {
console.log(
chalk.red(`=> Model ${model} MD5 not match, start to redownload`)
console.error(
chalk.red(` Model ${model} not valid, start to redownload`)
);
fs.removeSync(path.join(dir, model));
}
}
} catch (err) {
if (err && err.code !== "ENOENT") {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
process.exit(1);
} else {
console.log(chalk.blue(`=> Start to download model ${model}`));
console.info(chalk.blue(`=> Start to download model ${model}`));
}
}

Expand Down Expand Up @@ -83,12 +83,12 @@ const download = async (url, dest) => {
});

response.data.pipe(fs.createWriteStream(dest)).on("close", () => {
console.log(chalk.green(`=> Model ${model} downloaded successfully`));
console.info(chalk.green(` Model ${model} downloaded successfully`));
process.exit(0);
});
})
.catch((err) => {
console.log(chalk.red(`=> Error: ${err}`));
console.error(chalk.red(` Error: ${err}`));
process.exit(1);
});
};
Expand Down
Loading

0 comments on commit ac4d327

Please sign in to comment.