From 76e5cb0f3aa19940af25a240edaf39ca17cf1608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 1 Sep 2023 22:50:48 +0200 Subject: [PATCH] Initial commit --- .gitattributes | 2 + .github/ISSUE_TEMPLATE.md | 55 ++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 +++++++ .gitignore | 2 + conf/nginx.conf | 9 ++++ manifest.toml | 74 ++++++++++++++++++++++++++++++++ scripts/_common.sh | 67 +++++++++++++++++++++++++++++ scripts/install | 64 +++++++++++++++++++++++++++ scripts/remove | 25 +++++++++++ tests.toml | 12 ++++++ 10 files changed, 326 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .gitignore create mode 100644 conf/nginx.conf create mode 100644 manifest.toml create mode 100644 scripts/_common.sh create mode 100755 scripts/install create mode 100755 scripts/remove create mode 100644 tests.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6f9a98b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +tests.toml.example linguist-language=toml +config_panel.toml.example linguist-language=toml diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..783a4ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.sw[op] diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..c2b8e28 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,9 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __INSTALL_DIR__/www/; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..3a3da8b --- /dev/null +++ b/manifest.toml @@ -0,0 +1,74 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "jellyfin-vue" +name = "Jellyfin Vue Client" +description.en = "A modern web client for Jellyfin based on Vue." +description.fr = "Un client web moderne pour Jellyfin basé sur Vue." + +version = "0.3~ynh1" + +maintainers = ["johndoe"] + +[upstream] +license = "GPLv3" +website = "https://github.com/jellyfin/jellyfin-vue" +# admindoc = "https://yunohost.org/packaging_apps" +# userdoc = "https://yunohost.org/apps" +code = "https://github.com/jellyfin/jellyfin-vue" + +fund = "https://opencollective.com/jellyfin" + +[integration] +yunohost = ">= 11.1.21" +architectures = "all" +multi_instance = true +ldap = true +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "0M" + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by YunoHost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by YunoHost's core + type = "path" + default = "/jellyfin-vue" + + [install.init_main_permission] + # this is a generic question - ask strings are automatically handled by YunoHost's core + # This won't be saved as setting and will instead be used to initialize the SSOwat permission + type = "group" + default = "visitors" + +[resources] + # See the packaging documentation for the full set + # of explanation regarding the behavior and properties for each of those + + [resources.sources] + + [resources.sources.main] + # This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with : + # ynh_setup_source --dest_dir="$install_dir" + # You can also define other assets than "main" and add --source_id="foobar" in the previous command + url = "https://github.com/jellyfin/jellyfin-vue/archive/f1efc3cd0923d09af69debea1e19a08b24310afc.tar.gz" + sha256 = "7f3a81a44153b456012bb0c2a0d404eb0b4ac0db1c56768cef7e37ed4eb52c6f" + + # These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py + # to auto-update the previous asset urls and sha256sum + manifest version + # assuming the upstream's code repo is on github and relies on tags or releases + # See the 'sources' resource documentation for more details + + autoupdate.strategy = "latest_github_tag" + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..6823675 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +nodejs_version=18 + +#================================================= +# PERSONAL HELPERS +#================================================= + +_patch_config_json() { + sourcedir=$1 + + # Required for sub-path installation + sed -i \ + "s|'/config.json'|import.meta.env.BASE_URL + 'config.json'|" \ + "$1/frontend/src/utils/external-config.ts" +} + +_npm_build_install() { + sourcedir=$1 + targetdir=$2 + subpath=$3 + + pushd "$sourcedir" || ynh_die "Could not pushd $sourcedir" + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \ + "$ynh_npm" install + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \ + "$ynh_npm" run build -- --base="$subpath/" + popd || ynh_die "Could not popd" + + mv "$sourcedir/frontend/dist" "$targetdir" +} + + +_list_jellyfin_urls() { + yunohost app list --full --json \ + | jq -r '.apps[] | select(.manifest.id=="jellyfin") | .domain_path' +} + +PYTHON_APPEND_TO_SERVER_URLS=' +import sys +import json +file = sys.argv[1] +url = sys.argv[2] +with open(file, encoding="utf-8") as configfile: + data = json.load(configfile) +if url not in data["defaultServerURLs"]: + data["defaultServerURLs"].append(url) +with open(file, "w", encoding="utf-8") as configfile: + configfile.write(json.dumps(data, indent=2)) +' + +_append_to_server_urls() { + python3 -c "$PYTHON_APPEND_TO_SERVER_URLS" "$@" +} + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..5e50bad --- /dev/null +++ b/scripts/install @@ -0,0 +1,64 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 + +ynh_setup_source --dest_dir="$install_dir/source" + +chown -R $app:www-data "$install_dir" + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing NodeJS..." --weight=20 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# SPECIFIC SETUP +#================================================= +# Build Jellyfin-vue +#================================================= +ynh_script_progression --message="Building Jellyfin Vue... (this will take some time and resources!)" --weight=24 + +_patch_config_json "$install_dir/source" +_npm_build_install "$install_dir/source" "$install_dir/www" "$path/" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config using the conf/nginx.conf template +ynh_add_nginx_config + +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +# Check if Yunohost is installed, and configure it as defaultServerURL. +for url in $(_list_jellyfin_urls); do + _append_to_server_urls "$install_dir/www/config.json" "$url" +done + +#================================================= +# END OF SCRIPT +#================================================= +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove new file mode 100755 index 0000000..97dd83b --- /dev/null +++ b/scripts/remove @@ -0,0 +1,25 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# REMOVE SYSTEM CONFIGURATIONS +#================================================= +# REMOVE SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 + +ynh_remove_nginx_config + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..a7b4cee --- /dev/null +++ b/tests.toml @@ -0,0 +1,12 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + # test_upgrade_from.00a1a6e7.name = "Upgrade from 5.4" + # test_upgrade_from.00a1a6e7.args.foo = "bar"