Move to CLI

This commit is contained in:
TrainDoctor 2023-05-29 16:42:45 -07:00
commit e0778407f4
No known key found for this signature in database
GPG key ID: FFABB0E08B5CEDD9
5 changed files with 159 additions and 72 deletions

10
.vscode/build.sh vendored Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
CLI_LOCATION="$(pwd)/cli"
echo "Building plugin in $(pwd)"
printf "Please input sudo password to proceed.\n"
# read -s sudopass
# printf "\n"
echo $sudopass | sudo $CLI_LOCATION/decky plugin build $(pwd)

View file

@ -4,6 +4,7 @@
"deckpass" : "ssap",
"deckkey" : "-i ${env:HOME}/.ssh/id_rsa",
"deckdir" : "/home/deck",
"pluginname": "Example Plugin",
"python.analysis.extraPaths": [
"./py_modules"
]

48
.vscode/setup.sh vendored Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
PNPM_INSTALLED="$(which pnpm)"
DOCKER_INSTALLED="$(which docker)"
CLI_INSTALLED="$(test -f $(pwd)/cli/decky | echo "$?")"
# echo "$PNPM_INSTALLED"
# echo "$DOCKER_INSTALLED"
# echo "$CLI_INSTALLED"
echo "If you are using alpine linux, do not expect any support."
if [[ "$PNPM_INSTALLED" =~ "which" ]]; then
echo "pnpm is not currently installed, you can install it via your distro's package managment system or via a script that will attempt to do a manual install based on your system. If you wish to proceed with installing via the script then answer "no" (capitals do not matter) and proceed with the rest of the script. Otherwise, just hit enter to proceed and use the script."
read run_pnpm_script
if [[ "$run_pnpm_script" =~ "n" ]]; then
echo "You have chose to install pnpm via npm or your distros package manager. Please make sure to do so before attempting to build your plugin."
else
CURL_INSTALLED="$(which curl)"
WGET_INSTALLED="$(which wget)"
if [[ "$CURL_INSTALLED" =~ "which" ]]; then
printf "curl not found, attempting with wget.\n"
if [[ "$WGET_INSTALLED" =~ "which" ]]; then
printf "wget not found, please install wget or curl.\n"
printf "Could not install pnpm as curl and wget were not found.\n"
else
wget -qO- https://get.pnpm.io/install.sh | sh -
fi
else
curl -fsSL https://get.pnpm.io/install.sh | sh -
fi
fi
fi
if [[ "$DOCKER_INSTALLED" =~ "which" ]]; then
echo "Docker is not currently installed, in order build plugins with a backend you will need to have Docker installed. Please install Docker via the preferred method for your distribution."
fi
if [[ "$CLI_INSTALLED" > "0" ]] || [[ "$CLI_INSTALLED" < "0" ]]; then
echo "The Decky CLI tool (binary file is just called "decky") is used to build your plugin as a zip file which you can then install on your Steam Deck to perform testing. We highly recommend you install it. Hitting enter now will run the script to install Decky CLI and extract it to a folder called cli in the current plugin directory. You can also type 'no' and hit enter to skip this but keep in mind you will not have a usable plugin without building it."
read run_cli_script
if [[ "$run_cli_script" =~ "n" ]]; then
echo "You have chosen to not install the Decky CLI tool to build your plugins. Please install this tool to build and test your plugin before submitting it to the Plugin Database."
else
mkdir $(pwd)/cli
curl -L -o $(pwd)/cli/decky "https://github.com/SteamDeckHomebrew/cli/releases/download/0.0.1-alpha.11/decky"
chmod +x $(pwd)/cli/decky
echo "Decky CLI tool is now installed and you can build plugins into easy zip files using the "Build Zip" Task in vscodium."
fi
fi

162
.vscode/tasks.json vendored
View file

@ -1,116 +1,136 @@
{
"version": "2.0.0",
"tasks": [
// OTHER
//PRELIMINARY SETUP TASKS
//Dependency setup task
{
"label": "checkforsettings",
"label": "depsetup",
"type": "shell",
"group": "none",
"detail": "Check that settings.json has been created",
"command": "bash -c ${workspaceFolder}/.vscode/config.sh",
"detail": "Install depedencies for basic setup",
"linux": {
"command": "${workspaceFolder}/.vscode/setup.sh",
},
// // placeholder for windows scripts, not currently planned
// "windows": {
// "command": "call -c ${workspaceFolder}\\.vscode\\setup.bat",
// },
"problemMatcher": []
},
// BUILD
//pnpm setup task to grab all needed modules
{
"label": "pnpmsetup",
"type": "shell",
"group": "build",
"group": "none",
"detail": "Setup pnpm",
"command": "pnpm i",
"command": "which pnpm && pnpm i",
"problemMatcher": []
},
//Preliminary "All-in-one" setup task
{
"label": "updatefrontendlib",
"type": "shell",
"group": "build",
"detail": "Update deck-frontend-lib",
"command": "pnpm update decky-frontend-lib --latest",
"label": "setup",
"detail": "Set up depedencies, pnpm and update Decky Frontend Library.",
"dependsOrder": "sequence",
"dependsOn": [
"depsetup",
"pnpmsetup",
"updatedfrontendlib"
],
"problemMatcher": []
},
//Preliminary Deploy Config Setup
{
"label": "settingscheck",
"type": "shell",
"group": "none",
"detail": "Check that settings.json has been created",
"linux": {
"command": "${workspaceFolder}/.vscode/config.sh",
},
// // placeholder for windows scripts, not currently planned
// "windows": {
// "command": "call ${workspaceFolder}\\.vscode\\config.bat",
// },
"problemMatcher": []
},
//BUILD TASKS
{
"label": "cli-build",
"group": "build",
"detail": "Build plugin with CLI",
"linux": {
"command": "${workspaceFolder}/.vscode/build.sh",
},
// // placeholder for windows logic, not currently planned
// "windows": {
// "command": "call ${workspaceFolder}\\.vscode\\build.bat",
// },
"problemMatcher": []
},
//"All-in-one" build task
{
"label": "build",
"type": "npm",
"group": "build",
"detail": "rollup -c",
"script": "build",
"path": "",
"problemMatcher": []
},
{
"label": "buildall",
"group": "build",
"detail": "Build decky-plugin-template",
"dependsOrder": "sequence",
"dependsOn": [
"pnpmsetup",
"build"
"setup",
"settingscheck",
"cli-build",
],
"problemMatcher": []
},
// DEPLOY
//DEPLOY TASKS
//Copies the zip file of the built plugin to the plugins folder
{
"label": "createfolders",
"detail": "Create plugins folder in expected directory",
"label": "copyzip",
"detail": "Deploy plugin zip to deck",
"type": "shell",
"group": "none",
"dependsOn": [
"checkforsettings"
"chmodplugins"
],
"command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'mkdir -p ${config:deckdir}/homebrew/pluginloader && mkdir -p ${config:deckdir}/homebrew/plugins'",
"command": "rsync -azp --chmod=D0755,F0755 --rsh='ssh -p ${config:deckport} ${config:deckkey}' out/ deck@${config:deckip}:${config:deckdir}/homebrew/plugins",
"problemMatcher": []
},
//
{
"label": "extractzip",
"detail": "",
"type": "shell",
"group": "none",
"command": "echo '${config:deckdir}/homebrew/plugins/${config:pluginname}.zip' && ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo ${config:deckpass} | sudo -S unzip -j \"${config:deckdir}/homebrew/plugins/${config:pluginname}.zip\" -d \"$(echo \"${config:deckdir}/homebrew/plugins/${config:pluginname}\" | sed \"s| |-|\")\" '",
"problemMatcher": []
},
//"All-in-one" deploy task
{
"label": "deploy",
"detail": "Deploy dev plugin to deck",
"type": "shell",
"group": "none",
"dependsOn": [
"createfolders",
"chmodfolders"
],
"command": "rsync -azp --delete --chmod=D0755,F0755 --rsh='ssh -p ${config:deckport} ${config:deckkey}' --exclude='.git/' --exclude='.github/' --exclude='.vscode/' --exclude='node_modules/' --exclude='src/' --exclude='*.log' --exclude='.gitignore' . deck@${config:deckip}:${config:deckdir}/homebrew/plugins/${workspaceFolderBasename}",
"problemMatcher": []
},
{
"label": "restartloader",
"detail": "Restart the plugin loader (to load updated python code)",
"type": "shell",
"group": "none",
"dependsOn": [],
"command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo '${config:deckpass}' | sudo -S systemctl restart plugin_loader'",
"problemMatcher": []
},
{
"label": "chmodfolders",
"detail": "chmods folders to prevent perms issues",
"type": "shell",
"group": "none",
"command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo '${config:deckpass}' | sudo -S chmod -R ug+rw ${config:deckdir}/homebrew/'",
"problemMatcher": []
},
{
"label": "deployall",
"dependsOrder": "sequence",
"group": "none",
"dependsOn": [
"deploy",
"chmodfolders"
"copyzip",
"extractzip"
],
"problemMatcher": []
},
// ALL-IN-ONE
//GENERAL TASKS
//Update Decky Frontend Library, aka DFL
{
"label": "allinone",
"detail": "Build and deploy",
"dependsOrder": "sequence",
"group": "test",
"dependsOn": [
"buildall",
"deployall"
// Uncomment this line if you'd like your python code reloaded after deployment (this will restart Steam)
// ,"restartloader"
],
"label": "updatefrontendlib",
"type": "shell",
"group": "build",
"detail": "Update deck-frontend-lib aka DFL",
"command": "pnpm update decky-frontend-lib --latest",
"problemMatcher": []
}
},
//Used chmod plugins folder to allow copy-over of files
{
"label": "chmodplugins",
"detail": "chmods plugins folder to prevent perms issues",
"type": "shell",
"group": "none",
"command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo '${config:deckpass}' | sudo -S chmod -R ug+rw ${config:deckdir}/homebrew/plugins/'",
"problemMatcher": []
},
]
}

View file

@ -11,6 +11,8 @@ Reference example for using [decky-frontend-lib](https://github.com/SteamDeckHom
This template relies on the user having Node.js v16.14+ and `pnpm` (v8+) installed on their system.
pnpm can be downloaded from `npm` itself which is recommended.
If you would like to build plugins that have their own custom backends, Docker is required as it is used by the Decky CLI tool.
#### Linux
```bash
@ -19,6 +21,8 @@ sudo npm i -g pnpm
### Making your own plugin
If you use VSCode or it's derivatives (we suggest [VSCodium](https://vscodium.com/)!) just run the `setup` and `build` tasks. It's really that simple.
1. You can fork this repo or utilize the "Use this template" button on Github.
2. In your local fork/own plugin-repository run these commands:
1. ``pnpm i``
@ -27,7 +31,9 @@ sudo npm i -g pnpm
3. Consult the [decky-frontend-lib](https://github.com/SteamDeckHomebrew/decky-frontend-lib) repository for ways to accomplish your tasks.
- Documentation and examples are still rough,
- While decky-loader primarily targets Steam Deck hardware so keep this in mind when developing your plugin.
4. If you want an all encompassing demonstration of decky-frontend-lib's capabilities check out [decky-playground](https://github.com/SteamDeckHomebrew/decky-playground). It shows off almost all of decky-frontend-lib's features.
4. Run the `setup` and `build` and `deploy` vscode tasks, or you can derive your own makefile or just manually utilize the scripts for these commands as you see fit.
If you use VSCode or it's derivatives (we suggest [VSCodium](https://vscodium.com/)!) just run the `setup` and `build` tasks. It's really that simple.
#### Other important information
@ -56,6 +62,8 @@ hello:
The CI does create the `out` folder itself but we recommend creating it yourself if possible during your build process to ensure the build process goes smoothly.
Note: When locally building your plugin it will be placed into a folder called 'out' this is different from the concept described above.
The out folder is not sent to the final plugin, but is then put into a ``bin`` folder which is found at the root of the plugin's directory.
More information on the bin folder can be found below in the distribution section below.