mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Compare commits
28 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 |
@ -9,6 +9,8 @@ jobs:
|
||||
osx_image: xcode11.3
|
||||
- os: linux
|
||||
dist: xenial
|
||||
services:
|
||||
- xvfb
|
||||
|
||||
cache:
|
||||
yarn: false
|
||||
@ -18,6 +20,7 @@ cache:
|
||||
|
||||
script:
|
||||
- |
|
||||
yarn test
|
||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
yarn run release:linux
|
||||
else
|
||||
|
||||
@ -21,6 +21,11 @@ install:
|
||||
# # 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'))
|
||||
|
||||
# @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:
|
||||
- yarn run release:win
|
||||
|
||||
|
||||
4
index.js
4
index.js
@ -14,9 +14,11 @@ const {
|
||||
store,
|
||||
} = require("./store");
|
||||
const { fileExists, injectCSS } = require("./plugins/utils");
|
||||
const { isTesting } = require("./utils/testing");
|
||||
const { setUpTray } = require("./tray");
|
||||
|
||||
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
|
||||
require("electron-debug")();
|
||||
@ -49,7 +51,7 @@ function createMainWindow() {
|
||||
backgroundColor: "#000",
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
nodeIntegration: isTesting(), // Only necessary when testing with Spectron
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
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
|
||||
|
||||
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 = () => {
|
||||
const menuTemplate = [...mainMenuTemplate];
|
||||
if (process.platform === "darwin") {
|
||||
const name = app.getName();
|
||||
const name = app.name;
|
||||
menuTemplate.unshift({
|
||||
label: name,
|
||||
submenu: [
|
||||
|
||||
15
package.json
15
package.json
@ -26,7 +26,7 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo",
|
||||
"test": "jest",
|
||||
"start": "electron .",
|
||||
"icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated",
|
||||
"generate:package": "node utils/generate-package-json.js",
|
||||
@ -46,22 +46,25 @@
|
||||
"npm": "Please use yarn and not npm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cliqz/adblocker-electron": "^1.14.1",
|
||||
"@cliqz/adblocker-electron": "^1.15.0",
|
||||
"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-localshortcut": "^3.2.1",
|
||||
"electron-store": "^5.1.1",
|
||||
"electron-updater": "^4.3.0",
|
||||
"electron-store": "^5.2.0",
|
||||
"electron-updater": "^4.3.2",
|
||||
"node-fetch": "^2.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"devtron": "^1.4.0",
|
||||
"electron": "^8.2.1",
|
||||
"electron": "^8.2.4",
|
||||
"electron-builder": "^22.4.1",
|
||||
"electron-devtools-installer": "^3.0.0",
|
||||
"electron-icon-maker": "0.0.4",
|
||||
"get-port": "^5.1.1",
|
||||
"jest": "^25.5.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"spectron": "^10.0.1",
|
||||
"xo": "^0.29.0"
|
||||
},
|
||||
"xo": {
|
||||
|
||||
10
readme.md
10
readme.md
@ -93,11 +93,19 @@ module.exports = () => {
|
||||
## Build
|
||||
|
||||
```sh
|
||||
yarn run build
|
||||
yarn build
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
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