mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eec6993b95 | |||
| eb8e0a37d6 | |||
| 2a915f4fae | |||
| 26994000d7 | |||
| 78f143ea10 | |||
| 684a369fed | |||
| b19470ad0b | |||
| 6691cbf8c0 | |||
| 7ac98cf024 | |||
| 3d835fbeaa | |||
| d0824f52ea | |||
| 8c945100e2 | |||
| 68801c8e2b | |||
| a06eece4a0 | |||
| 873e093ff0 | |||
| 9c343d58ef | |||
| fed7a1df17 | |||
| 89d8907bc6 | |||
| 08d145b6fc | |||
| 57d3545701 | |||
| 08710558f5 | |||
| b80007bbd5 | |||
| ab0c93d443 | |||
| e84f045201 | |||
| 692b6b22aa | |||
| 954a58bcf5 | |||
| bce5b7d8eb | |||
| 736a706801 | |||
| 37cac19d9c | |||
| 4824dda5d5 | |||
| 3fa3c3ab9e | |||
| 058371ace8 | |||
| 430687f4d6 | |||
| 45f4b3bc28 | |||
| 7c12344d05 | |||
| 98213005d0 | |||
| db61589735 |
@ -9,6 +9,8 @@ jobs:
|
|||||||
osx_image: xcode11.3
|
osx_image: xcode11.3
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
|
services:
|
||||||
|
- xvfb
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
yarn: false
|
yarn: false
|
||||||
@ -18,6 +20,7 @@ cache:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
|
yarn test
|
||||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||||
yarn run release:linux
|
yarn run release:linux
|
||||||
else
|
else
|
||||||
|
|||||||
@ -21,6 +21,11 @@ install:
|
|||||||
# # https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
|
# # https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
|
||||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||||
|
|
||||||
|
# @FIXME: tests disabled because app fails to launch on AppVeyor/Windows
|
||||||
|
# os: unstable # https://github.com/electron-userland/spectron#on-appveyor
|
||||||
|
# test_script:
|
||||||
|
# - yarn test
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- yarn run release:win
|
- yarn run release:win
|
||||||
|
|
||||||
|
|||||||
19
index.js
19
index.js
@ -10,12 +10,15 @@ const {
|
|||||||
autoUpdate,
|
autoUpdate,
|
||||||
getEnabledPlugins,
|
getEnabledPlugins,
|
||||||
isAppVisible,
|
isAppVisible,
|
||||||
|
isTrayEnabled,
|
||||||
store,
|
store,
|
||||||
} = require("./store");
|
} = require("./store");
|
||||||
const { fileExists, injectCSS } = require("./plugins/utils");
|
const { fileExists, injectCSS } = require("./plugins/utils");
|
||||||
|
const { isTesting } = require("./utils/testing");
|
||||||
const { setUpTray } = require("./tray");
|
const { setUpTray } = require("./tray");
|
||||||
|
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
|
app.allowRendererProcessReuse = true; // https://github.com/electron/electron/issues/18397
|
||||||
|
|
||||||
// Adds debug features like hotkeys for triggering dev tools and reload
|
// Adds debug features like hotkeys for triggering dev tools and reload
|
||||||
require("electron-debug")();
|
require("electron-debug")();
|
||||||
@ -48,7 +51,7 @@ function createMainWindow() {
|
|||||||
backgroundColor: "#000",
|
backgroundColor: "#000",
|
||||||
show: false,
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: isTesting(), // Only necessary when testing with Spectron
|
||||||
preload: path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy
|
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy
|
||||||
affinity: "main-window", // main window, and addition windows should work in one process
|
affinity: "main-window", // main window, and addition windows should work in one process
|
||||||
@ -183,16 +186,20 @@ app.on("ready", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Optimized for Mac OS X
|
// Optimized for Mac OS X
|
||||||
if (process.platform === "darwin") {
|
if (is.macOS()) {
|
||||||
if (!isAppVisible()) {
|
if (!isAppVisible()) {
|
||||||
app.dock.hide();
|
app.dock.hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var forceQuit = false;
|
var forceQuit = false;
|
||||||
app.on("before-quit", () => {
|
app.on("before-quit", () => {
|
||||||
forceQuit = true;
|
forceQuit = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (is.macOS() || isTrayEnabled()) {
|
||||||
mainWindow.on("close", (event) => {
|
mainWindow.on("close", (event) => {
|
||||||
|
// Hide the window instead of quitting (quit is available in tray options)
|
||||||
if (!forceQuit) {
|
if (!forceQuit) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
|
|||||||
7
jest.config.js
Normal file
7
jest.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
globals: {
|
||||||
|
__APP__: undefined, // A different app will be launched in each test environment
|
||||||
|
},
|
||||||
|
testEnvironment: "./tests/environment",
|
||||||
|
testTimeout: 30000, // 30s
|
||||||
|
};
|
||||||
2
menu.js
2
menu.js
@ -71,7 +71,7 @@ module.exports.mainMenuTemplate = mainMenuTemplate;
|
|||||||
module.exports.setApplicationMenu = () => {
|
module.exports.setApplicationMenu = () => {
|
||||||
const menuTemplate = [...mainMenuTemplate];
|
const menuTemplate = [...mainMenuTemplate];
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
const name = app.getName();
|
const name = app.name;
|
||||||
menuTemplate.unshift({
|
menuTemplate.unshift({
|
||||||
label: name,
|
label: name,
|
||||||
submenu: [
|
submenu: [
|
||||||
|
|||||||
17
package.json
17
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "youtube-music",
|
"name": "youtube-music",
|
||||||
"productName": "YouTube Music",
|
"productName": "YouTube Music",
|
||||||
"version": "1.3.1",
|
"version": "1.3.3",
|
||||||
"description": "YouTube Music Desktop App - including custom plugins",
|
"description": "YouTube Music Desktop App - including custom plugins",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "th-ch/youtube-music",
|
"repository": "th-ch/youtube-music",
|
||||||
@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "xo",
|
"test": "jest",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated",
|
"icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated",
|
||||||
"generate:package": "node utils/generate-package-json.js",
|
"generate:package": "node utils/generate-package-json.js",
|
||||||
@ -46,22 +46,25 @@
|
|||||||
"npm": "Please use yarn and not npm"
|
"npm": "Please use yarn and not npm"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cliqz/adblocker-electron": "^1.14.1",
|
"@cliqz/adblocker-electron": "^1.15.0",
|
||||||
"YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.7.1",
|
"YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.7.1",
|
||||||
"electron-debug": "^3.0.1",
|
"electron-debug": "^3.1.0",
|
||||||
"electron-is": "^3.0.0",
|
"electron-is": "^3.0.0",
|
||||||
"electron-localshortcut": "^3.2.1",
|
"electron-localshortcut": "^3.2.1",
|
||||||
"electron-store": "^5.1.1",
|
"electron-store": "^5.2.0",
|
||||||
"electron-updater": "^4.2.2",
|
"electron-updater": "^4.3.2",
|
||||||
"node-fetch": "^2.6.0"
|
"node-fetch": "^2.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"devtron": "^1.4.0",
|
"devtron": "^1.4.0",
|
||||||
"electron": "^8.2.1",
|
"electron": "^8.2.4",
|
||||||
"electron-builder": "^22.4.1",
|
"electron-builder": "^22.4.1",
|
||||||
"electron-devtools-installer": "^3.0.0",
|
"electron-devtools-installer": "^3.0.0",
|
||||||
"electron-icon-maker": "0.0.4",
|
"electron-icon-maker": "0.0.4",
|
||||||
|
"get-port": "^5.1.1",
|
||||||
|
"jest": "^25.5.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
"spectron": "^10.0.1",
|
||||||
"xo": "^0.29.0"
|
"xo": "^0.29.0"
|
||||||
},
|
},
|
||||||
"xo": {
|
"xo": {
|
||||||
|
|||||||
10
readme.md
10
readme.md
@ -93,11 +93,19 @@ module.exports = () => {
|
|||||||
## Build
|
## Build
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
yarn run build
|
yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Builds the app for macOS, Linux, and Windows, using [electron-builder](https://github.com/electron-userland/electron-builder).
|
Builds the app for macOS, Linux, and Windows, using [electron-builder](https://github.com/electron-userland/electron-builder).
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn test
|
||||||
|
```
|
||||||
|
|
||||||
|
Uses [Spectron](https://www.electronjs.org/spectron) to test the app.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT © [th-ch](https://github.com/th-ch/youtube-music)
|
MIT © [th-ch](https://github.com/th-ch/youtube-music)
|
||||||
|
|||||||
47
tests/environment.js
Normal file
47
tests/environment.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const getPort = require("get-port");
|
||||||
|
const NodeEnvironment = require("jest-environment-node");
|
||||||
|
const { Application } = require("spectron");
|
||||||
|
|
||||||
|
class TestEnvironment extends NodeEnvironment {
|
||||||
|
constructor(config) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
async setup() {
|
||||||
|
await super.setup();
|
||||||
|
|
||||||
|
const electronPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"..",
|
||||||
|
"node_modules",
|
||||||
|
".bin",
|
||||||
|
"electron"
|
||||||
|
);
|
||||||
|
const appPath = path.resolve(__dirname, "..");
|
||||||
|
const port = await getPort();
|
||||||
|
|
||||||
|
this.global.__APP__ = new Application({
|
||||||
|
path: electronPath,
|
||||||
|
args: [appPath],
|
||||||
|
port,
|
||||||
|
});
|
||||||
|
await this.global.__APP__.start();
|
||||||
|
const { client } = this.global.__APP__;
|
||||||
|
await client.waitUntilWindowLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
async teardown() {
|
||||||
|
if (this.global.__APP__.isRunning()) {
|
||||||
|
await this.global.__APP__.stop();
|
||||||
|
}
|
||||||
|
await super.teardown();
|
||||||
|
}
|
||||||
|
|
||||||
|
runScript(script) {
|
||||||
|
return super.runScript(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TestEnvironment;
|
||||||
20
tests/index.test.js
Normal file
20
tests/index.test.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
describe("YouTube Music App", () => {
|
||||||
|
const app = global.__APP__;
|
||||||
|
|
||||||
|
test("With default settings, app is launched and visible", async () => {
|
||||||
|
expect(app.isRunning()).toBe(true);
|
||||||
|
|
||||||
|
const win = app.browserWindow;
|
||||||
|
|
||||||
|
const isVisible = await win.isVisible();
|
||||||
|
expect(isVisible).toBe(true);
|
||||||
|
|
||||||
|
const { width, height } = await win.getBounds();
|
||||||
|
expect(width).toBeGreaterThan(0);
|
||||||
|
expect(height).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const { client } = app;
|
||||||
|
const title = await client.getTitle();
|
||||||
|
expect(title).toEqual("YouTube Music");
|
||||||
|
});
|
||||||
|
});
|
||||||
4
tray.js
4
tray.js
@ -22,6 +22,10 @@ module.exports.setUpTray = (app, win) => {
|
|||||||
});
|
});
|
||||||
tray = new Tray(trayIcon);
|
tray = new Tray(trayIcon);
|
||||||
tray.setToolTip("Youtube Music");
|
tray.setToolTip("Youtube Music");
|
||||||
|
tray.setIgnoreDoubleClickEvents(true);
|
||||||
|
tray.on("click", () => {
|
||||||
|
win.isVisible() ? win.hide() : win.show();
|
||||||
|
});
|
||||||
|
|
||||||
const trayMenu = Menu.buildFromTemplate([
|
const trayMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
|
|||||||
3
utils/testing.js
Normal file
3
utils/testing.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const isTesting = () => process.env.NODE_ENV === "test";
|
||||||
|
|
||||||
|
module.exports = { isTesting };
|
||||||
Reference in New Issue
Block a user