Skip to content

Commit

Permalink
Merge pull request #956 from unknownskl/feature/flatpak2
Browse files Browse the repository at this point in the history
Experimental flatpak support
  • Loading branch information
unknownskl authored Sep 18, 2023
2 parents 94761ab + 1eb4a75 commit bfbc3ca
Show file tree
Hide file tree
Showing 9 changed files with 694 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
app
flatpak
xal-node/
35 changes: 35 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@next/next/recommended"
// "eslint:recommended"
// "plugin:@typescript-eslint/eslint-recommended",
// "plugin:@typescript-eslint/recommended"
]
// "rules": {
// "quotes": ["warn", "single"],
// "indent": ["warn", 4, { "SwitchCase": 1 }],
// "semi": ["error", "never"],
// "comma-dangle": ["warn", "always-multiline"],
// "dot-notation": "off",
// "eqeqeq": "warn",
// "curly": ["warn", "all"],
// "brace-style": ["warn"],
// "prefer-arrow-callback": ["warn"],
// "max-len": ["warn", 200],
// // "no-console": ["warn"],
// "no-non-null-assertion": ["off"],
// "comma-spacing": ["error"],
// "no-multi-spaces": ["warn", { "ignoreEOLComments": true }],
// "lines-between-class-members": ["warn", "always", {"exceptAfterSingleLine": true}],
// "@typescript-eslint/explicit-function-return-type": "off",
// "@typescript-eslint/no-non-null-assertion": "off",
// "@typescript-eslint/explicit-module-boundary-types": "off",
// "@typescript-eslint/no-explicit-any": "off",
// "@typescript-eslint/member-delimiter-style": ["warn"]
// }
}
117 changes: 117 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,125 @@ on:
# DEBUG: '*'

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3.8.1
with:
node-version: 18

- name: Set up node_modules cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
node_modules/
xal-node/node_modules/
key: ${{ runner.os }}-${{ runner.arch }}-npm-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-${{ runner.arch }}-npm-

- name: Install yarn dependencies
run: yarn

- name: Lint code
run: yarn lint


cachedeps:
name: Generate cached sources
runs-on: ubuntu-latest
needs: ['lint']

steps:
# Intsall node tools
- uses: actions/checkout@v4
with:
repository: 'flatpak/flatpak-builder-tools'

- name: Install Python deps
run: pip3 install aiohttp toml

- name: Install flatpak-builder-tools
run: pipx install ./node/

- name: Copy cargo script
run: cp cargo/flatpak-cargo-generator.py ../flatpak-cargo-generator.py

# Generate sources
- name: Checkout Git repository
uses: actions/checkout@v4
with:
submodules: recursive
# clean: true

- name: Prep artifacts dir
run: mkdir ./deps-dist/

- name: Build yarn cache
run: flatpak-node-generator yarn yarn.lock -o ./deps-dist/yarn-sources.json

- name: Build npm cache
run: flatpak-node-generator npm xal-node/package-lock.json -o ./deps-dist/npm-sources.json

- name: Build cargo cache
run: python3 ../flatpak-cargo-generator.py xal-node/Cargo.lock -o ./deps-dist/cargo-sources.json

- uses: actions/upload-artifact@master
with:
name: flatpak-sources
path: ./deps-dist/

flatpak:
name: Flatpak Build
runs-on: ubuntu-latest
needs: [cachedeps]

container:
image: bilelmoussaoui/flatpak-github-actions:gnome-44
options: --privileged

steps:
- name: Checkout Git repository
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/download-artifact@master
with:
name: flatpak-sources
path: flatpak/

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3.8.1
with:
node-version: 18

- name: Set up flatpak build cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
build/
.flatpak-builder/
key: ${{ runner.os }}-${{ runner.arch }}-flatpak-builder-${{ hashFiles('flatpak/*') }}
restore-keys: ${{ runner.os }}-${{ runner.arch }}-flatpak-builder-

- uses: flatpak/flatpak-github-actions/flatpak-builder@v4
with:
bundle: greenlight.flatpak
manifest-path: flatpak/dev.unknownskl.greenlight.yml
cache-key: flatpak-builder-${{ github.sha }}

release:
runs-on: ${{ matrix.os }}
needs: ['lint']

strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v2.0.0-beta13 - 2023-09-xx
- Added support for Free 2 play games on xCloud #918
- Added support for estimated waiting times (Experimental, times may be way off)
- Added (not-tested) experimental flatpak builds
- Rewrote stream IPC Communication backend for better data exchange and improved stream handling
- Rewrote all IPC Communications in the frontend code for better portability
- Upgraded electron base from v21 to v26
Expand Down
60 changes: 60 additions & 0 deletions flatpak/dev.unknownskl.greenlight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
app-id: dev.unknownskl.greenlight
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
base: org.electronjs.Electron2.BaseApp
base-version: '22.08'
sdk-extensions:
- org.freedesktop.Sdk.Extension.node18
- org.freedesktop.Sdk.Extension.rust-stable
command: run.sh
separate-locales: false
finish-args:
- --share=ipc
- --socket=x11
- --socket=pulseaudio
- --share=network
- --allow=bluetooth
- --device=all
- --device=dri
build-options:
append-path: /usr/lib/sdk/node18/bin:/usr/lib/sdk/rust-stable/bin
env:
NPM_CONFIG_LOGLEVEL: info
CARGO_HOME: /run/build/greenlight/cargo
modules:
- name: greenlight
buildsystem: simple
build-options:
env:
XDG_CACHE_HOME: /run/build/greenlight/flatpak-node/cache
npm_config_cache: /run/build/greenlight/flatpak-node/npm-cache
npm_config_offline: 'true'
yarn_config_cache: /run/build/greenlight/flatpak-node/yarn-mirror
build-commands:
- yarn --offline
- |
# . ../flatpak-node/electron-builder-arch-args.sh
yarn run flatpak-build --offline -- $ELECTRON_BUILDER_ARCH_ARGS --linux
# Bundle app and dependencies
- cp -a dist/linux*unpacked /app/main
# Install app wrapper
- install -Dm755 -t /app/bin/ ../run.sh
- ls -la /app /app/bin /app/main
subdir: main
sources:
- type: dir
path: ..
dest: main
- yarn-sources.json
- npm-sources.json
- cargo-sources.json
# Wrapper to launch the app
- type: file
path: yarnrc
dest-filename: .yarnrc
- type: script
dest-filename: run.sh
commands:
- ls -la /app/bin
- zypak-wrapper.sh /app/main/greenlight "$@"
7 changes: 7 additions & 0 deletions flatpak/yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


# yarn-offline-mirror "/run/build/greenlight/yarn-mirror"
yarn-offline-mirror "/run/build/greenlight/flatpak-node/yarn-mirror"
yarn-offline-mirror-pruning true
17 changes: 0 additions & 17 deletions main/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ import Application from './application'

const authStore = new Store()

const REQ_TYPE_STREAM_GET_CONSOLES = 'get_consoles'
const REQ_TYPE_STREAM_START_STREAM = 'start_stream'
const REQ_TYPE_STREAM_START_STREAM_SDP = 'start_stream_sdp'
const REQ_TYPE_STREAM_START_STREAM_ICE = 'start_stream_ice'
const REQ_TYPE_STREAM_STOP_STREAM = 'stop_stream'
const REQ_TYPE_STREAM_KEEPALIVE = 'keepalive'

const REQ_TYPE_XCLOUD_GET_TITLES = 'get_titles'

const REQ_TYPE_WEB_GET_RECENT_ACHIEVEMENTS = 'get_recent_achievements'
const REQ_TYPE_WEB_GET_RECENT_ACHIEVEMENTS_TITLEID = 'get_recent_achievements_titleid'

const REQ_TYPE_MARKET_GET_PRODUCT = 'get_product'


const RES_TYPE_ERROR = 'error'

export default class Events extends EventEmitter {
_application:Application

Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
"scripts": {
"dev": "yarn run build-deps && DEBUG=greenlight:* nextron",
"build": "yarn run build-deps && nextron build",
"lint": "eslint . --ext .ts",
"postinstall": "electron-builder install-app-deps",
"publish": "electron-builder -p onTag",
"build-deps": "ls xal-node/dist/xal-node.node || npm run rebuild-deps",
"rebuild-deps": "cd xal-node && npm ci"
"rebuild-deps": "cd xal-node && npm ci",
"flatpak-build": "yarn run build-deps && nextron build --no-pack && electron-builder --dir"
},
"dependencies": {
"@next/eslint-plugin-next": "^13.4.19",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"axios": "^1.5.0",
"compare-versions": "^6.1.0",
"debug": "^4.3.4",
"electron-serve": "^1.1.0",
"electron-store": "^8.0.1",
"eslint": "^8.49.0",
"github-url-to-object": "^4.0.6",
"uplot": "^1.6.25",
"xbox-webapi": "^1.4.1",
Expand Down
Loading

0 comments on commit bfbc3ca

Please sign in to comment.