Skip to content

Commit

Permalink
Merge pull request #155 from caorushizi/fix/adblocker
Browse files Browse the repository at this point in the history
Fix/adblocker
  • Loading branch information
caorushizi authored May 25, 2024
2 parents 7f71cd7 + 84299ac commit ab340f5
Show file tree
Hide file tree
Showing 35 changed files with 1,406 additions and 529 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-12]
os: [windows-latest, macos-latest, ubuntu-latest]

# create steps
steps:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "mediago",
"version": "0.1.0",
"description": "mediago",
"author": "caorushizi",
"homepage": "https://downloader.caorushizi.cn/",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -24,7 +26,6 @@
"lint-staged": "pnpm --recursive -F \"./packages/*\" run lint-staged"
},
"keywords": [],
"author": "",
"license": "MIT",
"config": {
"commitizen": {
Expand Down
4 changes: 3 additions & 1 deletion packages/main/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"version": "2.2.0",
"description": "在线视频下载器",
"main": "main/index.js",
"author": "",
"author": "caorushizi",
"homepage": "https://downloader.caorushizi.cn/",
"license": "MIT",
"dependencies": {
"@cliqz/adblocker-electron": "^1.27.3",
"@cliqz/adblocker-electron-preload": "^1.27.3",
"better-sqlite3": "^9.3.0",
"node-pty": "^1.0.0"
},
"devDependencies": {
Expand Down
Binary file modified packages/main/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file added packages/main/bin/linux/BBDown
Binary file not shown.
Binary file added packages/main/bin/linux/N_m3u8DL-RE
Binary file not shown.
Binary file added packages/main/bin/linux/ffmpeg
Binary file not shown.
Binary file removed packages/main/bin/win32/N_m3u8DL-CLI.exe
Binary file not shown.
Binary file added packages/main/bin/win32/N_m3u8DL-RE.exe
Binary file not shown.
1 change: 1 addition & 0 deletions packages/main/gulpfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { dev, build, release } from "./scripts/index.ts";
19 changes: 10 additions & 9 deletions packages/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"main": "main/index.js",
"scripts": {
"postinstall": "electron-rebuild -f -w",
"dev": "cross-env NODE_ENV=development VITE_CJS_IGNORE_WARNING=true tsx scripts/dev.ts",
"build": "cross-env NODE_ENV=production tsx scripts/build.ts",
"pack": "cross-env NODE_ENV=development tsx scripts/release.ts",
"dev": "cross-env NODE_ENV=development gulp dev",
"pack": "cross-env NODE_ENV=development gulp release",
"build": "cross-env NODE_ENV=production gulp build",
"release": "cross-env NODE_ENV=production gulp release",
"types": "tsc",
"types:watch": "tsc -w",
"release": "cross-env NODE_ENV=production tsx scripts/release.ts",
"lint-staged": "lint-staged"
},
"lint-staged": {
Expand All @@ -22,34 +22,35 @@
"@electron/rebuild": "^3.6.0",
"@rushstack/eslint-patch": "^1.7.0",
"@types/fs-extra": "^11.0.4",
"@types/gulp": "^4.0.17",
"@types/lodash": "^4.14.202",
"@types/mime-types": "^2.1.4",
"@types/node": "^20.11.5",
"@types/node-fetch": "^2.6.11",
"@types/semver": "^7.5.6",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"chokidar": "^3.5.3",
"consola": "^3.2.3",
"cross-env": "^7.0.3",
"del": "^7.1.0",
"dotenv": "^16.3.2",
"electron": "30.0.6",
"electron-builder": "^24.9.1",
"electron-updater": "^6.1.7",
"esbuild": "^0.19.11",
"esbuild-register": "^3.5.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-n": "16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "6.1.1",
"gulp": "^5.0.0",
"prebuild-install": "^7.1.1",
"prettier": "3.2.5",
"semver": "^7.5.4",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vite": "^5.0.12"
"typescript": "^5.3.3"
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.27.3",
Expand All @@ -72,6 +73,6 @@
"node-pty": "^1.0.0",
"reflect-metadata": "^0.2.1",
"strip-ansi": "^7.1.0",
"typeorm": "^0.3.19"
"typeorm": "0.3.17"
}
}
59 changes: 0 additions & 59 deletions packages/main/scripts/build.ts

This file was deleted.

139 changes: 138 additions & 1 deletion packages/main/scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,145 @@
export const external = [
import { Configuration } from "electron-builder";
import { Env, mainResolve } from "./utils";
import esbuild from "esbuild";

const external = [
"electron",
"nock",
"aws-sdk",
"mock-aws-s3",
"@cliqz/adblocker-electron-preload",
"node-pty",
"better-sqlite3",
];

function getConfig(): esbuild.BuildOptions {
const env = Env.getInstance().env;
return {
bundle: true,
sourcemap: process.env.NODE_ENV === "development",
external,
define:
process.env.NODE_ENV === "development"
? {
// 开发环境中二进制可执行文件的路径
__bin__: `"${mainResolve("app/bin").replace(/\\/g, "\\\\")}"`,
}
: {
...env,
"process.env.NODE_ENV": '"production"',
},
outdir: mainResolve("app/build/main"),
loader: { ".png": "file" },
minify: process.env.NODE_ENV === "production",
};
}

function buildOptions(
entry: string,
platform: esbuild.Platform,
target: string,
): esbuild.BuildOptions {
return {
...getConfig(),
entryPoints: [mainResolve(entry)],
platform: platform,
target: [target],
};
}

export function browserOptions(entry: string): esbuild.BuildOptions {
return buildOptions(entry, "browser", "chrome89");
}

export function nodeOptions(entry: string): esbuild.BuildOptions {
return buildOptions(entry, "node", "node16.13");
}

export function getReleaseConfig(): Configuration {
return {
productName: process.env.APP_NAME,
buildVersion: process.env.APP_VERSION,
appId: process.env.APP_ID,
copyright: process.env.APP_COPYRIGHT,
artifactName: "${productName}-setup-${arch}-${buildVersion}.${ext}",
// FIXME: 这里屏蔽 node-pty 自动重构,因为会导致打包失败
npmRebuild: false,
directories: {
output: "./release",
},
asarUnpack: [
"**/better-sqlite3/build/Release/*.node",
"**/node-pty/build/Release/**",
],
files: [
{
from: "./build",
to: "./",
},
"./package.json",
],
extraResources: [
{
from: "./app/plugin",
to: "plugin",
},
{
from: "./app/bin/",
to: "bin",
},
],
win: {
icon: "../assets/icon.ico",
target: [
{
target: "nsis",
arch: ["x64"],
},
],
},
dmg: {
contents: [
{
x: 410,
y: 150,
type: "link",
path: "/Applications",
},
{
x: 130,
y: 150,
type: "file",
},
],
},
mac: {
icon: "../assets/icon.icns",
target: {
target: "dmg",
arch: ["x64"],
},
},
linux: {
category: "Utility",
icon: "../assets/icon.icns",
maintainer: "caorushizi <[email protected]>",
target: {
target: "deb",
arch: ["x64"],
},
},
nsis: {
oneClick: true,
allowElevation: true,
allowToChangeInstallationDirectory: false,
installerIcon: "",
uninstallerIcon: "",
installerHeaderIcon: "",
createDesktopShortcut: true,
createStartMenuShortcut: true,
shortcutName: "",
include: "",
script: "",
},
};
}
Loading

0 comments on commit ab340f5

Please sign in to comment.