Skip to content

Commit

Permalink
update build tool
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Sep 18, 2024
1 parent 1579e30 commit 75990d5
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
tar -tzvf PowerControl.tar.gz
- name: Publish Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: PowerControl
path: PowerControl.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ yalc.lock

backend/out
backend/*.sh
Makefile
# Makefile

.history
110 changes: 110 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
ifneq (,$(wildcard ./.env))
include .env
export
endif

SHELL=bash

help: ## Display list of tasks with descriptions
@echo "+ $@"
@fgrep -h ": ## " $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed 's/-default//' | awk 'BEGIN {FS = ": ## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

vendor: ## Install project dependencies
@echo "+ $@"
@pnpm i

env: ## Create default .env file
@echo "+ $@"
@echo -e '# Makefile tools\nDECK_USER=deck\nDECK_HOST=\nDECK_PORT=22\nDECK_HOME=/home/deck\nDECK_KEY=~/.ssh/id_rsa' >> .env
@echo -n "PLUGIN_FOLDER=" >> .env
@jq -r .name package.json >> .env

init: ## Initialize project
@$(MAKE) env
@$(MAKE) vendor
@echo -e "\n\033[1;36m Almost ready! Just a few things left to do:\033[0m\n"
@echo -e "1. Open .env file and make sure every DECK_* variable matches your steamdeck's ip/host, user, etc"
@echo -e "2. Run \`\033[0;36mmake copy-ssh-key\033[0m\` to copy your public ssh key to steamdeck"
@echo -e "3. Build your code with \`\033[0;36mmake build\033[0m\` or \`\033[0;36mmake docker-build\033[0m\` to build inside a docker container"
@echo -e "4. Deploy your plugin code to steamdeck with \`\033[0;36mmake deploy\033[0m\`"

update-frontend-lib: ## Update decky-frontend-lib
@echo "+ $@"
@pnpm update decky-frontend-lib --latest

update-ui: ## Update @decky/api and @decky/ui
@echo "+ $@"
@pnpm update @decky/api @decky/ui --latest

build-front: ## Build frontend
@echo "+ $@"
@pnpm run build

build-back: ## Build backend
@echo "+ $@"
@make -C ./backend

build: ## Build everything
@$(MAKE) build-front build-back

copy-ssh-key: ## Copy public ssh key to steamdeck
@echo "+ $@"
@ssh-copy-id -i $(DECK_KEY) $(DECK_USER)@$(DECK_HOST)

deploy-steamdeck: ## Deploy plugin build to steamdeck
@echo "+ $@"
@ssh $(DECK_USER)@$(DECK_HOST) -p $(DECK_PORT) -i $(DECK_KEY) \
'chmod -v 755 $(DECK_HOME)/homebrew/plugins/ && mkdir -p $(DECK_HOME)/homebrew/plugins/$(PLUGIN_FOLDER)'
@rsync -azp --delete --progress -e "ssh -p $(DECK_PORT) -i $(DECK_KEY)" \
--chmod=Du=rwx,Dg=rx,Do=rx,Fu=rwx,Fg=rx,Fo=rx \
--exclude='.git/' \
--exclude='.github/' \
--exclude='.vscode/' \
--exclude='node_modules/' \
--exclude='.pnpm-store/' \
--exclude='src/' \
--exclude='*.log' \
--exclude='.gitignore' . \
--exclude='.idea' . \
--exclude='.env' . \
--exclude='Makefile' . \
./ $(DECK_USER)@$(DECK_HOST):$(DECK_HOME)/homebrew/plugins/$(PLUGIN_FOLDER)/
@ssh $(DECK_USER)@$(DECK_HOST) -p $(DECK_PORT) -i $(DECK_KEY) \
'chmod -v 755 $(DECK_HOME)/homebrew/plugins/'

restart-decky: ## Restart Decky on remote steamdeck
@echo "+ $@"
@ssh -t $(DECK_USER)@$(DECK_HOST) -p $(DECK_PORT) -i $(DECK_KEY) \
'sudo systemctl restart plugin_loader.service'
@echo -e '\033[0;32m+ all is good, restarting Decky...\033[0m'

deploy: ## Deploy code to steamdeck and restart Decky
@$(MAKE) deploy-steamdeck
@$(MAKE) restart-decky

it: ## Build all code, deploy it to steamdeck, restart Decky
@$(MAKE) build deploy

cleanup: ## Delete all generated files and folders
@echo "+ $@"
@rm -f .env
@rm -rf ./dist
@rm -rf ./tmp
@rm -rf ./node_modules
@rm -rf ./.pnpm-store
@rm -rf ./backend/out

uninstall-plugin: ## Uninstall plugin from steamdeck, restart Decky
@echo "+ $@"
@ssh -t $(DECK_USER)@$(DECK_HOST) -p $(DECK_PORT) -i $(DECK_KEY) \
"sudo sh -c 'rm -rf $(DECK_HOME)/homebrew/plugins/$(PLUGIN_FOLDER)/ && systemctl restart plugin_loader.service'"
@echo -e '\033[0;32m+ all is good, restarting Decky...\033[0m'

docker-rebuild-image: ## Rebuild docker image
@echo "+ $@"
@docker compose build --pull

docker-build: ## Build project inside docker container
@$(MAKE) build-back
@echo "+ $@"
@docker run --rm -i -v $(PWD):/plugin -v $(PWD)/tmp/out:/out ghcr.io/steamdeckhomebrew/builder:latest
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-typescript": "^11.1.6",
"@types/markdown-it": "^14.1.1",
"@types/markdown-it": "^14.1.2",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@types/webpack": "^5.28.5",
"markdown-it": "^14.1.0",
"rollup": "^4.18.0",
"rollup-plugin-delete": "^2.0.0",
"rollup": "^4.21.3",
"rollup-plugin-delete": "^2.1.0",
"rollup-plugin-external-globals": "^0.10.0",
"rollup-plugin-import-assets": "^1.1.1",
"shx": "^0.3.4",
"tslib": "^2.6.2",
"typescript": "^5.5.2"
"tslib": "^2.7.0",
"typescript": "^5.6.2"
},
"dependencies": {
"@decky/api": "^1.0.5",
"@decky/ui": "^4.2.1",
"i18next": "^23.11.2",
"@decky/api": "^1.1.2",
"@decky/ui": "^4.7.2",
"i18next": "^23.15.1",
"react-icons": "^4.12.0",
"typescript-json-serializer": "^4.3.0"
},
Expand Down
Loading

0 comments on commit 75990d5

Please sign in to comment.