From 106abcef2643db744a52fb502764743362101ee3 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Sat, 30 Apr 2022 18:38:15 +0100 Subject: [PATCH 1/6] Reverted 'config.yml' --- .circleci/config.yml | 153 ++++++++----------------------------------- 1 file changed, 28 insertions(+), 125 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 83d25acc..62dc1183 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,21 +1,18 @@ version: 2.1 - -executors: - cider-ci: - docker: - - image: circleci/node:16 - working_directory: ~/Cider - orbs: # adds orbs to your configuration jira: circleci/jira@1.0.5 # invokes the Jira orb, making its commands accessible - -# The jobs for this project +branches: + only: + - main + - develop jobs: - prepare-build: - executor: cider-ci + build: + working_directory: ~/Cider + docker: + - image: circleci/node:16 + steps: - checkout - - run: ls -la - run: name: Set App Version command: echo "export APP_VERSION=$(grep '"version":.*' package.json | cut -d '"' -f 4 | head -1)" >> $BASH_ENV @@ -35,144 +32,50 @@ jobs: paths: - ~/.cache/yarn - run: - name: TypeScript Compile - command: yarn build - - persist_to_workspace: - # Must be an absolute path, or relative path from working_directory. This is a directory on the container which is - # taken to be the root directory of the workspace. - root: . - # Must be relative path from root - paths: - - node_modules - - build - - resources - - yarn.lock - - package.json - - winget.json # winget.json is a file that is generated by the winget package manager - - LICENSE - - license.txt - - build-windows: - executor: cider-ci - steps: - - attach_workspace: - at: ~/Cider - - run: - name: Install Windows System Build Dependencies + name: Install system build dependencies command: | sudo apt-get update -y + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt-get install -y dpkg fakeroot wine64 sudo dpkg --add-architecture i386 sudo apt-get update -y sudo apt-get install -y wine32 + sudo apt install -y gh - run: name: Fix Versioning and Add Channel command: yarn circle:script - run: - name: Generate Builds (Windows) - command: yarn electron-builder -w --x64 -p never - post-steps: - - jira/notify - - persist_to_workspace: - root: . - paths: - - dist/*.exe - - dist/latest.yml - - build-linux: - executor: cider-ci - steps: - - attach_workspace: - at: ~/Cider - - run: - name: Fix Versioning and Add Channel - command: yarn circle:script + name: TypeScript Compile + command: yarn build - run: name: Generate Builds (Linux) command: yarn electron-builder -l -p never post-steps: - jira/notify - - persist_to_workspace: - root: . - paths: - - dist/*.deb - - dist/*.AppImage - - dist/*.snap - - dist/latest-linux.yml - - build-winget: - executor: cider-ci - steps: - - attach_workspace: - at: ~/Cider - run: - name: Install Windows System Build Dependencies - command: | - sudo apt-get update -y - sudo apt-get install -y dpkg fakeroot wine64 - sudo dpkg --add-architecture i386 - sudo apt-get update -y - sudo apt-get install -y wine32 - - run: - name: Fix Versioning and Add Channel - command: yarn circle:script + name: Generate Builds (Windows) + command: yarn electron-builder -w --x64 -p never + post-steps: + - jira/notify - run: name: Generate Builds (Winget) command: yarn electron-builder --win -c winget.json -p never post-steps: - jira/notify - - persist_to_workspace: - root: . - paths: - - dist/*.exe - # - dist/*.yml - - release: - executor: cider-ci - steps: - - attach_workspace: - at: ~/Cider/ - - run: - name: Installing GitHub Command Line Interface - command: | - sudo apt-get update -y - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null - sudo apt-get update -y - sudo apt install -y gh - run: name: Move Build Files command: | - mkdir ~/Cider/dist/artifacts/ - mv ~/Cider/dist/*.exe ~/Cider/dist/artifacts - mv ~/Cider/dist/*.deb ~/Cider/dist/artifacts - mv ~/Cider/dist/*.AppImage ~/Cider/dist/artifacts - mv ~/Cider/dist/*.snap ~/Cider/dist/artifacts - mv ~/Cider/dist/*.yml ~/Cider/dist/artifacts - mv ~/Cider/dist/*.blockmap ~/Cider/dist/artifacts + mkdir ~/Cider/dist/artifacts/ + mv ~/Cider/dist/*.exe ~/Cider/dist/artifacts + mv ~/Cider/dist/*.deb ~/Cider/dist/artifacts + mv ~/Cider/dist/*.AppImage ~/Cider/dist/artifacts + mv ~/Cider/dist/*.snap ~/Cider/dist/artifacts + mv ~/Cider/dist/*.yml ~/Cider/dist/artifacts + mv ~/Cider/dist/*.blockmap ~/Cider/dist/artifacts - store_artifacts: - path: ~/Cider/dist/artifacts + path: ~/Cider/dist/artifacts - run: name: Publish Release command: | - gh release create "v${APP_VERSION}.${CIRCLE_BUILD_NUM}" --title "Cider Version ${APP_VERSION} - Build ${CIRCLE_BUILD_NUM} (${CIRCLE_BRANCH})" --generate-notes -R ciderapp/cider-releases ~/Cider/dist/artifacts/*.deb ~/Cider/dist/artifacts/*.AppImage ~/Cider/dist/artifacts/*.snap ~/Cider/dist/artifacts/*.exe ~/Cider/dist/artifacts/*.yml ~/Cider/dist/artifacts/*.blockmap - -# Orchestrate our job run sequence -workflows: - build_and_release: - jobs: - - prepare-build - - build-windows: - requires: - - prepare-build - - build-linux: - requires: - - prepare-build - - build-winget: - requires: - - prepare-build - - release: - requires: - - build-windows - - build-linux - - build-winget + gh release create "v${APP_VERSION}.${CIRCLE_BUILD_NUM}" --title "Cider Version ${APP_VERSION} - Build ${CIRCLE_BUILD_NUM} (${CIRCLE_BRANCH})" --generate-notes -R ciderapp/cider-releases ~/Cider/dist/artifacts/*.deb ~/Cider/dist/artifacts/*.AppImage ~/Cider/dist/artifacts/*.snap ~/Cider/dist/artifacts/*.exe ~/Cider/dist/artifacts/*.yml ~/Cider/dist/artifacts/*.blockmap From 825d1b3bc2cb7ecdae6999228701f835c8cd503e Mon Sep 17 00:00:00 2001 From: child_duckling <19170969+quacksire@users.noreply.github.com> Date: Sun, 1 May 2022 17:54:37 -0700 Subject: [PATCH 2/6] [connect] untested sync backend --- src/main/base/browserwindow.ts | 12 +++++++-- src/main/base/store.ts | 46 +++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index 2089686c..bf63f4ea 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -37,6 +37,7 @@ export class BrowserWindow { platform: process.platform, dev: app.isPackaged, osRelease: os.release(), + updatable: !process.windowsStore || !process.mas, components: [ "pages/podcasts", "pages/apple-account-settings", @@ -1214,13 +1215,20 @@ export class BrowserWindow { shell.openPath(app.getPath('userData')); }); + + //#region Cider Connect ipcMain.on('cc-auth', (_event) => { shell.openExternal(String(utils.getStoreValue('cc_authURL'))); }); - ipcMain.on('cc-logout', (_event) => { + ipcMain.on('cc-logout', (_event) => { //Make sure to update the default store utils.setStoreValue('connectUser', { - auth: null + "auth": null, + "sync": { + themes: false, + plugins: false, + settings: false, + } }); utils.getWindow().reload(); }); diff --git a/src/main/base/store.ts b/src/main/base/store.ts index 1ffbc502..44c1b710 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -1,7 +1,7 @@ import * as ElectronStore from 'electron-store'; import * as electron from "electron"; import {app} from "electron"; - +import fetch from "electron-fetch"; export class Store { static cfg: ElectronStore; @@ -212,6 +212,11 @@ export class Store { }, "connectUser": { "auth": null, + "sync": { + themes: false, + plugins: false, + settings: false, + } }, } private migrations: any = { @@ -261,6 +266,7 @@ export class Store { return target } + /** * IPC Handler */ @@ -281,5 +287,43 @@ export class Store { Store.cfg.store = store }) } + + + pushToCloud(): void { + if (Store.cfg.get('connectUser.auth') === null) return; + var syncData = Object(); + if (Store.cfg.get('connectUser.sync.themes')) { + syncData.push({ + themes: Store.cfg.store.themes + }) + } + if (Store.cfg.get('connectUser.sync.plugins')) { + syncData.push({ + plugins: Store.cfg.store.plugins + }) + } + + if (Store.cfg.get('connectUser.sync.settings')) { + syncData.push({ + general: Store.cfg.get('general'), + home: Store.cfg.get('home'), + libraryPrefs: Store.cfg.get('libraryPrefs'), + advanced: Store.cfg.get('advanced'), + }) + } + let postBody = { + id: Store.cfg.get('connectUser.id'), + app: electron.app.getName(), + version: electron.app.isPackaged ? electron.app.getVersion() : 'dev', + syncData: syncData + } + fetch('https://connect.cidercollective.dev/api/v1/setttings/set', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(postBody) + }) + } } From 7006ba617578c71fceab9dc7dd4797aba130be1a Mon Sep 17 00:00:00 2001 From: maikirakiwi Date: Sun, 1 May 2022 18:17:08 -0700 Subject: [PATCH 3/6] electron18.2.0 bump --- package.json | 4 ++-- winget.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6cad8ece..b7347a4f 100644 --- a/package.json +++ b/package.json @@ -109,9 +109,9 @@ } ], "build": { - "electronVersion": "18.1.0", + "electronVersion": "18.2.0", "electronDownload": { - "version": "18.1.0+wvcus", + "version": "18.2.0+wvcus", "mirror": "https://github.com/castlabs/electron-releases/releases/download/v" }, "appId": "cider", diff --git a/winget.json b/winget.json index 351ef190..b184fd63 100644 --- a/winget.json +++ b/winget.json @@ -1,7 +1,7 @@ { - "electronVersion": "18.0.4", + "electronVersion": "18.2.0", "electronDownload": { - "version": "18.0.4+wvcus", + "version": "18.2.0+wvcus", "mirror": "https://github.com/castlabs/electron-releases/releases/download/v" }, "appId": "cider", From 5701aea255375c55ac151a2451777b9a8447af2a Mon Sep 17 00:00:00 2001 From: child_duckling <19170969+quacksire@users.noreply.github.com> Date: Sun, 1 May 2022 20:39:07 -0700 Subject: [PATCH 4/6] [connect] utils function --- src/main/base/app.ts | 1 - src/main/base/store.ts | 2 +- src/main/base/utils.ts | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/base/app.ts b/src/main/base/app.ts index 3ab49a66..9ae6b6a9 100644 --- a/src/main/base/app.ts +++ b/src/main/base/app.ts @@ -212,7 +212,6 @@ export class AppEvents { * Handles the creation of a new instance of the app */ private InstanceHandler() { - // Detects of an existing instance is running (So if the lock has been achieved, no existing instance has been found) const gotTheLock = app.requestSingleInstanceLock() diff --git a/src/main/base/store.ts b/src/main/base/store.ts index 44c1b710..fa8cbb2f 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -289,7 +289,7 @@ export class Store { } - pushToCloud(): void { + static pushToCloud(): void { if (Store.cfg.get('connectUser.auth') === null) return; var syncData = Object(); if (Store.cfg.get('connectUser.sync.themes')) { diff --git a/src/main/base/utils.ts b/src/main/base/utils.ts index 9889c4ff..e010cfe0 100644 --- a/src/main/base/utils.ts +++ b/src/main/base/utils.ts @@ -80,6 +80,7 @@ export class utils { return Store.cfg.store } + /** * Get the store instance * @returns {Store} @@ -97,6 +98,18 @@ export class utils { Store.cfg.set(key, value) } + /** + * Pushes Store to Connect + * @return Function + */ + static pushStoreToConnect(): Function { + return Store.pushToCloud + } + + + + + /** * Gets the browser window */ @@ -198,4 +211,6 @@ export class utils { autoUpdater.logger = log await autoUpdater.checkForUpdatesAndNotify() } + + } From 70677810414a8d4f48049d097132504be5cdc658 Mon Sep 17 00:00:00 2001 From: child_duckling <19170969+quacksire@users.noreply.github.com> Date: Sun, 1 May 2022 20:54:06 -0700 Subject: [PATCH 5/6] [connect] cc push --- src/main/base/browserwindow.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index bf63f4ea..2556d2d9 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -1232,6 +1232,10 @@ export class BrowserWindow { }); utils.getWindow().reload(); }); + + ipcMain.on('cc-push', (_event) => { + utils.pushStoreToConnect(); + }) /* ********************************************************************************************* * Window Events * **********************************************************************************************/ From 12be570a981a9e7233b0e523eb931b758bf39719 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Mon, 2 May 2022 05:09:38 +0100 Subject: [PATCH 6/6] Renamed config var to discordrpc because this migration shit is giving me a headache --- src/main/base/store.ts | 8 ++++---- src/main/plugins/discordrpc.ts | 16 ++++++++-------- src/renderer/views/pages/settings.ejs | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/base/store.ts b/src/main/base/store.ts index fa8cbb2f..6741395c 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -12,7 +12,7 @@ export class Store { }, "general": { "close_button_hide": false, - "discord_rpc": { + "discordrpc": { "enabled": false, "client": "Cider", "clear_on_pause": true, @@ -221,13 +221,13 @@ export class Store { } private migrations: any = { '>=1.4.3': (store: ElectronStore) => { - if (typeof store.get('general.discord_rpc') == 'number' || typeof store.get('general.discord_rpc') == 'string') { - store.delete('general.discord_rpc'); + if (typeof store.get('general.discordrpc') == 'number' || typeof store.get('general.discordrpc') == 'string') { + store.delete('general.discordrpc'); } }, } private schema: ElectronStore.Schema = { - "general.discord_rpc": { + "general.discordrpc": { type: 'object' }, } diff --git a/src/main/plugins/discordrpc.ts b/src/main/plugins/discordrpc.ts index 740a79b6..92f613e3 100644 --- a/src/main/plugins/discordrpc.ts +++ b/src/main/plugins/discordrpc.ts @@ -53,10 +53,10 @@ export default class DiscordRPC { * @private */ private connect() { - if (!this._utils.getStoreValue("general.discord_rpc.enabled")) { + if (!this._utils.getStoreValue("general.discordrpc.enabled")) { return; } - const clientId = this._utils.getStoreValue("general.discord_rpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'; + const clientId = this._utils.getStoreValue("general.discordrpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'; // Apparently needed for ask to join, join, spectate etc. RPC.register(clientId) @@ -187,7 +187,7 @@ export default class DiscordRPC { activity = DiscordRPC.filterActivity(activity, this._attributes) // Set the activity - if (!this._attributes.status && this._utils.getStoreValue("general.discord_rpc.clear_on_pause")) { + if (!this._attributes.status && this._utils.getStoreValue("general.discordrpc.clear_on_pause")) { this._client.clearActivity() } else if (this._activity && this._activityCache !== this._activity && this._activity.details) { this._client.setActivity(activity) @@ -200,7 +200,7 @@ export default class DiscordRPC { * @param {object} attributes */ private updateActivity(attributes: any) { - if (!this._utils.getStoreValue("general.discord_rpc.enabled") || this._utils.getStoreValue("general.privateEnabled")) { + if (!this._utils.getStoreValue("general.discordrpc.enabled") || this._utils.getStoreValue("general.privateEnabled")) { return } else if (!this._client || !this._connection) { this.connect() @@ -208,15 +208,15 @@ export default class DiscordRPC { // Check if show buttons is (true) or (false) this._activity = { - details: this._utils.getStoreValue("general.discord_rpc.details_format"), - state: this._utils.getStoreValue("general.discord_rpc.state_format"), + details: this._utils.getStoreValue("general.discordrpc.details_format"), + state: this._utils.getStoreValue("general.discordrpc.state_format"), largeImageKey: attributes?.artwork?.url?.replace('{w}', '1024').replace('{h}', '1024'), largeImageText: attributes.albumName, instance: false // Whether the activity is in a game session } // Add the buttons if people want them - if (!this._utils.getStoreValue("general.discord_rpc.hide_buttons")) { + if (!this._utils.getStoreValue("general.discordrpc.hide_buttons")) { this._activity.buttons = [ {label: 'Listen on Cider', url: attributes.url.cider}, {label: 'View on Apple Music', url: attributes.url.appleMusic} @@ -230,7 +230,7 @@ export default class DiscordRPC { } // If the user wants to keep the activity when paused - if (!this._utils.getStoreValue("general.discord_rpc.clear_on_pause")) { + if (!this._utils.getStoreValue("general.discordrpc.clear_on_pause")) { this._activity.smallImageKey = attributes.status ? 'play' : 'pause'; this._activity.smallImageText = attributes.status ? 'Playing' : 'Paused'; } diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 40e7439e..c0a32127 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -1013,18 +1013,18 @@
-
+
{{$root.getLz('settings.option.connectivity.discordRPC.clientName')}}
-
+
{{$root.getLz('settings.option.connectivity.discordRPC.clearOnPause')}}
-
+
{{$root.getLz('settings.option.connectivity.discordRPC.hideButtons')}}
-
+
{{$root.getLz('settings.option.connectivity.discordRPC.detailsFormat')}}
{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album}, @@ -1063,12 +1063,12 @@
-
+
{{$root.getLz('settings.option.connectivity.discordRPC.stateFormat')}} {{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album}, @@ -1076,7 +1076,7 @@