chore: update makefile and docs to allow using npm or yarn independently

This commit is contained in:
josselinonduty 2025-02-01 18:31:37 +01:00
parent 10aa5f2e66
commit 22dcfe4c54
No known key found for this signature in database
4 changed files with 46 additions and 34 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ flatpak
source
app
package-lock.json
yarn.lock
artifacts
package.json
.vscode/launch.json

View File

@ -38,7 +38,6 @@ Ensure you have all required dependencies:
- Node.js (20 recommended)
- npm
- yarn
- 7z
- make
- wget

View File

@ -5,32 +5,37 @@ BASE_URL = $(shell jq ".modules[0].sources[0].url" dev.aunetx.deezer.json)
SHA256 = $(shell jq ".modules[0].sources[0].sha256" dev.aunetx.deezer.json)
PKGVER = $(shell echo $(BASE_URL) | grep -Eo "([0-9]+\.[0-9]+\.[0-9]+)" | head -1)
VERSION_REGEX = ^v$(PKGVER)-[0-9]{1,}$$
SOURCE_DIR ?= ./source
APP_DIR ?= ./app
PACKAGE_MANAGER ?= npm
PACKAGE_MANAGER_SUBDIR_ARG ?= --prefix
PACKAGE_MANAGER_INSTALL_CMD ?= install
PACKAGE_MANAGER_ADD_CMD ?= install
install_build_deps:
@npm install --engine-strict @electron/asar@3.2.18
@npm install prettier@2.8.8
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_ADD_CMD) @electron/asar@3.2.18 --engine-strict
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_ADD_CMD) prettier@2.8.8
prepare: clean install_build_deps
@mkdir -p source
@mkdir -p $(SOURCE_DIR)
@echo "Download installer"
@wget -nv $(BASE_URL) -O source/deezer-setup-$(PKGVER).exe
@wget -nv $(BASE_URL) -O $(SOURCE_DIR)/deezer-setup-$(PKGVER).exe
@echo "Verify installer"
@echo "$(SHA256) source/deezer-setup-$(PKGVER).exe" | sha256sum -c --status || exit 1
@echo "$(SHA256) $(SOURCE_DIR)/deezer-setup-$(PKGVER).exe" | sha256sum -c --status || exit 1
@echo "Extract app archive from installer"
@cd source && 7z x -so deezer-setup-$(PKGVER).exe '$$PLUGINSDIR/app-32.7z' > app-32.7z
@cd $(SOURCE_DIR) && 7z x -so deezer-setup-$(PKGVER).exe '$$PLUGINSDIR/app-32.7z' > app-32.7z
@echo "Extract app from app archive"
@cd source && 7z x -y -bsp0 -bso0 app-32.7z
@cd $(SOURCE_DIR) && 7z x -y -bsp0 -bso0 app-32.7z
@echo "Extract app sources from the app"
@node_modules/@electron/asar/bin/asar.js extract source/resources/app.asar app
@node_modules/@electron/asar/bin/asar.js extract $(SOURCE_DIR)/resources/app.asar $(APP_DIR)
@echo "Prettier the sources to patch successfully"
@node_modules/prettier/bin-prettier.js --write "app/build/*.js"
@node_modules/prettier/bin-prettier.js --write "$(APP_DIR)/build/*.js"
@echo "Apply patches from ./patches:"
@echo "01 - Hide to tray when closing (https://github.com/SibrenVasse/deezer/issues/4)"
@ -42,75 +47,76 @@ prepare: clean install_build_deps
@echo "07 - Add Discord Rich Presence (https://github.com/aunetx/deezer-linux/pull/82)"
@echo "08 - Add option to disable Discord Rich Presence (https://github.com/aunetx/deezer-linux/pull/95)"
@echo "09 - Add environment variable to change log level (https://github.com/aunetx/deezer-linux/pull/95)"
$(foreach p, $(wildcard ./patches/*), patch -p1 -dapp < $(p);)
@echo "10 - Add track duration and url, various fixes (https://github.com/aunetx/deezer-linux/pull/95)"
$(foreach p, $(wildcard ./patches/*), patch -p 1 -d $(APP_DIR) < $(p);)
@echo "Append `package-append.json` to the `package.json` of the app"
@echo "Adds electron, elecron-builder dependencies, prod and build directives"
@jq -s '.[0] * .[1]' app/package.json package-append.json > app/tmp.json && mv app/tmp.json app/package.json
@jq -s '.[0] * .[1]' $(APP_DIR)/package.json package-append.json > $(APP_DIR)/tmp.json && mv $(APP_DIR)/tmp.json $(APP_DIR)/package.json
@echo "Download new packages"
@npm i
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_INSTALL_CMD)
#! PACKAGES
install_deps: prepare
@echo "Install yarn dependencies to pack them later"
@yarn --cwd=app install
@echo "Install $(PACKAGE_MANAGER) dependencies to pack them later"
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) $(PACKAGE_MANAGER_INSTALL_CMD)
build_tar.xz_x64:
@echo "Build tar.xz archive"
@yarn --cwd=app run build-tar.xz-x64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-tar.xz-x64
build_deb_x64:
@echo "Build deb package"
@yarn --cwd=app run build-deb-x64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-deb-x64
build_rpm_x64:
@echo "Build rpm package"
@yarn --cwd=app run build-rpm-x64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-rpm-x64
build_appimage_x64:
@echo "Build AppImage binary"
@yarn --cwd=app run build-appimage-x64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-appimage-x64
build_snap_x64:
@echo "Build Snap package"
@yarn --cwd=app run build-snap-x64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-snap-x64
build_tar.xz_arm64:
@echo "Build tar.xz archive"
@yarn --cwd=app run build-tar.xz-arm64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-tar.xz-arm64
build_deb_arm64:
@echo "Build deb package"
@yarn --cwd=app run build-deb-arm64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-deb-arm64
build_rpm_arm64:
@echo "Build rpm package"
@yarn --cwd=app run build-rpm-arm64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-rpm-arm64
build_appimage_arm64:
@echo "Build AppImage binary"
@yarn --cwd=app run build-appimage-arm64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-appimage-arm64
build_snap_arm64:
@echo "Build Snap package"
@yarn --cwd=app run build-snap-arm64
@$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-snap-arm64
#! DEV
patch-new: install_deps
@echo "Setting up the development environment..."
@cd app && echo "node_modules\n.vscode\n*.diff\n*.orig" > .gitignore && git init && git add .
@cd app && git commit -m "initial commit"
@echo "You can now edit the sources in the app directory"
@cd $(APP_DIR) && echo "node_modules\n.vscode\n*.diff\n*.orig" > .gitignore && git init && git add .
@cd $(APP_DIR) && git commit -m "initial commit"
@echo "You can now edit the sources in the $(APP_DIR) directory"
@echo "When you are done, commit your changes, run 'make patch-gen'."
@echo "Don't forget to rename your patch."
patch-gen:
@cd app && git format-patch -1 HEAD --stdout > ../patches/$(shell date +%y%m%d-%s).patch
@cd $(APP_DIR) && git format-patch -1 HEAD --stdout > ../patches/$(shell date +%y%m%d-%s).patch
#! UTILS
@ -130,4 +136,4 @@ release: prepare-release
clean:
@rm -rf app flatpak node_modules source artifacts package-lock.json package.json
@rm -rf ./$(APP_DIR) flatpak node_modules ./$(SOURCE_DIR) artifacts package.json

View File

@ -69,7 +69,6 @@ Other packages can be installed from you package manager, either by clicking on
- Node.js (20 recommended)
- npm
- yarn
- 7z (try installing `p7zip` and `p7zip-full`)
- make
- wget
@ -150,9 +149,16 @@ Please see [this issue](https://github.com/babluboy/bookworm/issues/178) or [thi
The source code of the Deezer app is not open-source. Reverse-engineering the app would be illegal and would violate the Deezer EULA. This project is a port of the official Windows app, and does not contain any reverse-engineered code, rather it bundles the official Windows app with a compatibility layer.
## Why do I need npm _and_ yarn?
### I want to use yarn instead of npm, is it possible?
That is a good question. Some kind of legacy choice, I guess.
Yes, you can use yarn instead of npm. Execute the following command before building the project:
```sh
export PACKAGE_MANAGER=yarn
export PACKAGE_MANAGER_SUBDIR_ARG=--cwd
export PACKAGE_MANAGER_ADD_CMD=add
export PACKAGE_MANAGER_INSTALL_CMD=install
```
## **LEGAL DISCLAIMER**