Merge pull request #211 from pythoninthegrass/main

refactor: tooling
This commit is contained in:
Roy 2024-02-20 23:58:24 -08:00 committed by GitHub
commit 6177b9c363
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 4362 additions and 37 deletions

View File

@ -3,7 +3,7 @@
{
"name": "Dev Environment",
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {

View File

@ -1,21 +0,0 @@
asttokens==2.2.1
backcall==0.2.0
decorator==5.1.1
executing==1.2.0
ipython==8.14.0
jedi==0.19.0
markdown-it-py==3.0.0
matplotlib-inline==0.1.6
mdurl==0.1.2
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.39
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.16.1
rich==13.5.2
six==1.16.0
stack-data==0.6.2
traitlets==5.9.0
wcwidth==0.2.6

25
.github/workflows/release-please.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Release Please
on:
push:
branches:
- 'main'
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: Release with release-please
uses: google-github-actions/release-please-action@v4
with:
# PAT with write access to the repository
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
# optional. customize path to release-please-config.json
config-file: release-please-config.json
# optional. customize path to .release-please-manifest.json
manifest-file: .release-please-manifest.json

131
.gitignore vendored
View File

@ -161,3 +161,134 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

43
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,43 @@
fail_fast: true
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=1024']
- id: check-docstring-first
exclude: |
(?x)^(
hello.py
)$
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: pretty-format-json
# https://pre-commit.com/#regular-expressions
exclude: |
(?x)^(
.devcontainer/devcontainer.json|
.vscode/launch.json|
.vscode/settings.json|
.vscode/extensions.json
)$
args: ['--autofix', '--indent=2', '--no-sort-keys']
- id: requirements-txt-fixer

View File

@ -0,0 +1,3 @@
{
".": "3.8.0"
}

View File

@ -1,2 +1,3 @@
python 3.11.4
poetry 1.5.1
python 3.11.6
poetry 1.7.1
nodejs 21.4.0

18
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"recommendations": [
"aaron-bond.better-comments",
"codezombiech.gitignore",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"GitHub.copilot-chat",
"GitHub.copilot",
"mads-hartmann.bash-ide-vscode",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-vscode.atom-keybindings",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
"timonwong.shellcheck",
"yzhang.markdown-all-in-one"
]
}

View File

@ -170,32 +170,105 @@ source .venv/bin/activate
python -m pip install -r requirements.txt
```
### Pre-commit hooks
Pre-commit hooks are installed via `pre-commit` and are run automatically on `git commit`.
Most importantly, `ruff` is used to lint all python code.
* Install [pre-commit](https://pre-commit.com/#install)
* Install pre-commit hooks
```bash
pre-commit install
```
* Trigger pre-commit hooks automatically on `git commit`
```bash
git add .
git commit -m "commit message"
```
* Bypass pre-commit hooks
* Sometimes, it's necessary to bypass pre-commit hooks. This can be done with the `--no-verify` flag.
```bash
git commit -m "commit message" --no-verify
```
### Conventional Commits
While not currently enforced, by using [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary), it's possible to automatically generate changelogs and version numbers via [release-please](https://github.com/googleapis/release-please).
To help with that, the [commitizen](https://commitizen-tools.github.io/commitizen/) tool can be installed.
#### Usage
```bash
# install cz
npm install -g commitizen cz-conventional-changelog
# make repo cz friendly
commitizen init cz-conventional-changelog --save-dev --save-exact
npm install
# add file to commit
git add .gitignore
# run cz
λ git cz
cz-cli@4.3.0, cz-conventional-changelog@3.3.0
? Select the type of change that you're committing: chore: Other changes that don't modify src or test files
? What is the scope of this change (e.g. component or file name): (press enter to skip) .gitignore
? Write a short, imperative tense description of the change (max 81 chars):
(17) update .gitignore
? Provide a longer description of the change: (press enter to skip)
? Are there any breaking changes? No
? Does this change affect any open issues? No
[main 0a9920d] chore(.gitignore): update .gitignore
1 file changed, 131 insertions(+)
λ git push
```
### Formatting
> **TL;DR**: The [Ruff formatter](https://astral.sh/blog/the-ruff-formatter) is an extremely fast Python formatter, written in Rust. Its over 30x faster than Black and 100x faster than YAPF, formatting large-scale Python projects in milliseconds — all while achieving >99.9% Black compatibility.
* While it runs automatically on commits, it can also be run manually
```bash
# check for errors
ruff check .
# fix (some) errors automatically
ruff check . --fix
```
### Additional tooling
Additional tooling includes but is not limited to:
#### TODO
* Add [devbox](https://www.jetpack.io/devbox/) 👌
#### asdf
* Install [asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf)
* Usage
* Add plugins
```bash
# add python plugin
asdf plugin-add python
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
```
* Usage
* Install local plugins in repo
```bash
asdf install
```
* Install specific plugins
```bash
# install stable python
asdf install python <latest|3.11.4>
# set stable to system python
asdf global python latest
# add poetry asdf plugin
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
# install latest version via asdf
asdf install poetry <latest|1.5.1>
# set latest version as default
asdf global poetry latest
```
#### shellcheck

2
config.env Normal file
View File

@ -0,0 +1,2 @@
# TODO: export all dynamic vars from NonSteamLaunchers.sh here
# TODO: read into main.py or config.py (latter's preferable)

135
config.py Normal file
View File

@ -0,0 +1,135 @@
#!/usr/bin/env python3
from decouple import config
from pathlib import Path
# paths
logged_in_home = str(Path.home())
steam_apps = f"{logged_in_home}/.local/share/Steam/steamapps"
compat_data = f"{steam_apps}/compatdata"
compat_data_path = f"{compat_data}/NonSteamLaunchers/pfx/drive_c"
steamuser_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/NonSteamLaunchers/pfx/drive_c/users/steamuser/AppData/Local"
# launchers
amazongames_path1 = f"{compat_data_path}/Program Files/Amazon Games/App/Amazon Games.exe"
amazongames_path2 = f"{steamuser_path}/Amazon Games/App/Amazon Games.exe"
battlenet_path1 = f"{compat_data_path}/Program Files (x86)/Battle.net/Battle.net Launcher.exe"
battlenet_path2 = f"{steamuser_path}/Program Files (x86)/Battle.net/Battle.net Launcher.exe"
dmm_path1 = f"{compat_data_path}/Program Files/DMMGamePlayer/DMMGamePlayer.exe"
dmm_path2 = f"{steamuser_path}/Program Files/DMMGamePlayer/DMMGamePlayer.exe"
eaapp_path1 = f"{compat_data_path}/Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe"
eaapp_path2 = f"{steamuser_path}/Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe"
epic_games_launcher_path1 = f"{compat_data_path}/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe"
epic_games_launcher_path2 = f"{steamuser_path}/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe"
glyph_path1 = f"{compat_data_path}/Program Files (x86)/Glyph/GlyphClient.exe"
glyph_path2 = f"{steamuser_path}/Program Files (x86)/Glyph/GlyphClient.exe"
gog_galaxy_path1 = f"{compat_data_path}/Program Files (x86)/GOG Galaxy/GalaxyClient.exe"
gog_galaxy_path2 = f"{steamuser_path}/Program Files (x86)/GOG Galaxy/GalaxyClient.exe"
humblegames_path1 = f"{compat_data_path}/Program Files/Humble App/Humble App.exe"
humblegames_path2 = f"{steamuser_path}/Program Files/Humble App/Humble App.exe"
indiegala_path1 = f"{compat_data_path}/Program Files/IGClient/IGClient.exe"
indiegala_path2 = f"{steamuser_path}/Program Files/IGClient/IGClient.exe"
itchio_path1 = f"{compat_data_path}/users/steamuser/AppData/Local/itch/app-25.6.2/itch.exe"
itchio_path2 = f"{steamuser_path}/itch/app-25.6.2/itch.exe"
legacygames_path1 = f"{compat_data_path}/Program Files/Legacy Games/Legacy Games Launcher/Legacy Games Launcher.exe"
legacygames_path2 = f"{steamuser_path}/Program Files/Legacy Games/Legacy Games Launcher/Legacy Games Launcher.exe"
minecraft_path1 = f"{compat_data_path}/Program Files (x86)/Minecraft Launcher/MinecraftLauncher.exe"
minecraft_path2 = f"{steamuser_path}/Program Files (x86)/Minecraft Launcher/MinecraftLauncher.exe"
origin_path1 = f"{compat_data_path}/Program Files (x86)/Origin/Origin.exe"
origin_path2 = f"{steamuser_path}/Program Files (x86)/Origin/Origin.exe"
psplus_path1 = f"{compat_data_path}/Program Files (x86)/PlayStationPlus/pspluslauncher.exe"
psplus_path2 = f"{steamuser_path}/Program Files (x86)/PlayStationPlus/pspluslauncher.exe"
rockstar_path1 = f"{compat_data_path}/Program Files/Rockstar Games/Launcher/Launcher.exe"
rockstar_path2 = f"{steamuser_path}/Program Files/Rockstar Games/Launcher/Launcher.exe"
uplay_path1 = f"{compat_data_path}/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/upc.exe"
uplay_path2 = f"{steamuser_path}/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/upc.exe"
# streaming
chromedirectory = "/usr/bin/flatpak"
# Define a dictionary of original folder names
folder_names = {
'Amazon Games': 'AmazonGamesLauncher',
'Battle.net': 'Battle.netLauncher',
'DMM Games': 'DMMGameLauncher',
'EA App': 'TheEAappLauncher',
'Epic Games': 'EpicGamesLauncher',
'Gog Galaxy': 'GogGalaxyLauncher',
'Humble Bundle': 'HumbleGamesLauncher',
'IndieGala Client': 'IndieGalaLauncher',
'itch.io': 'itchioLauncher',
'Legacy Games': 'LegacyGamesLauncher',
'Minecraft: Java Edition': 'MinecraftLauncher',
'Origin': 'OriginLauncher',
'Playstation Plus': 'PlaystationPlusLauncher',
'Rockstar Games Launcher': 'RockstarGamesLauncher',
'Ubisoft Connect': 'UplayLauncher',
'VK Play': 'VKPlayLauncher',
}
# Variables from NonSteamLaunchers.sh
steamid3 = config('steamid3', default='')
logged_in_home = config('logged_in_home')
compat_tool_name = config('compat_tool_name')
controller_config_path = config('controller_config_path')
python_version = config('python_version')
#Scanner Variables
epic_games_launcher = config('epic_games_launcher')
ubisoft_connect_launcher = config('ubisoft_connect_launcher')
ea_app_launcher = config('ea_app_launcher')
gog_galaxy_launcher = config('gog_galaxy_launcher')
bnet_launcher = config('bnet_launcher')
amazon_launcher = config('amazon_launcher')
# Variables of the Launchers
# Define the path of the Launchers
epicshortcutdirectory = config('epicshortcutdirectory')
gogshortcutdirectory = config('gogshortcutdirectory')
uplayshortcutdirectory = config('uplayshortcutdirectory')
battlenetshortcutdirectory = config('battlenetshortcutdirectory')
eaappshortcutdirectory = config('eaappshortcutdirectory')
amazonshortcutdirectory = config('amazonshortcutdirectory')
itchioshortcutdirectory = config('itchioshortcutdirectory')
legacyshortcutdirectory = config('legacyshortcutdirectory')
humbleshortcutdirectory = config('humbleshortcutdirectory')
indieshortcutdirectory = config('indieshortcutdirectory')
rockstarshortcutdirectory = config('rockstarshortcutdirectory')
glyphshortcutdirectory = config('glyphshortcutdirectory')
minecraftshortcutdirectory = config('minecraftshortcutdirectory')
psplusshortcutdirectory = config('psplusshortcutdirectory')
vkplayhortcutdirectory = config('vkplayhortcutdirectory')
# Streaming
chromedirectory = config('chromedirectory')
websites_str = config('custom_websites_str')
custom_websites = websites_str.split(', ') if websites_str else []
# Define your mapping
flavor_mapping = {
"Blizzard Arcade Collection": "RTRO",
"Call of Duty: Black Ops - Cold War": "ZEUS",
"Call of Duty: Black Ops 4": "VIPR",
"Call of Duty: Modern Warfare III": "SPOT",
"Call of Duty: Modern Warfare": "ODIN",
"Call of Duty: MW 2 Campaign Remastered": "LAZR",
"Call of Duty: Vanguard": "FORE",
"Call of Duty": "AUKS",
"Crash Bandicoot 4: It's About Time": "WLBY",
"Diablo II: Resurrected": "OSI",
"Diablo III": "D3",
"Diablo Immortal (PC)": "ANBS",
"Diablo IV": "Fen",
"Diablo": "D1",
"Hearthstone": "WTCG",
"Heroes of the Storm": "Hero",
"Overwatch 2": "Pro",
"Overwatch": "Pro",
"StarCraft 2": "S2",
"StarCraft": "S1",
"Warcraft Arclight Rumble": "GRY",
"Warcraft II: Battle.net Edition": "W2",
"Warcraft III: Reforged": "W3",
"Warcraft: Orcs & Humans": "W1",
"World of Warcraft Classic": "WoWC",
"World of Warcraft": "WoW",
}

2009
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"devDependencies": {
"cz-conventional-changelog": "^3.3.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}

1789
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

86
pyproject.toml Normal file
View File

@ -0,0 +1,86 @@
[tool.poetry]
name = "non-steam-launchers"
version = "3.8.0"
description = ""
authors = [
"moraroy <88516395+moraroy@users.noreply.github.com>",
"pythoninthegrass <4097471+pythoninthegrass@users.noreply.github.com>"
]
license = "MIT"
readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.11,<3.13"
python-decouple = "^3.8"
python-steamgriddb = "^1.0.5"
requests = "^2.31.0"
vdf = "^3.4"
[tool.poetry.group.dev.dependencies]
coverage = "^7.3.2"
hypothesis = {extras = ["cli"], version = "^6.88.4"}
icecream = "^2.1.3"
ipython = "^8.17.2"
poetry-plugin-export = "^1.6.0"
pytest = "^7.4.3"
pytest-asyncio = "^0.21.1"
pytest-cov = "^4.1.0"
pytest-datafiles = "^3.0.0"
pytest-xdist = "^3.4.0"
rich = "^13.6.0"
ruff = "^0.1.5"
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []
# Skip unused variable rules
extend-ignore = ["D203", "E203", "E251", "E266", "E401", "E402", "E501", "F401", "F403"]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
"dist",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
"__pycache__",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
# Black (default: 88)
line-length = 130
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.11.
target-version = "py311"
[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

View File

@ -0,0 +1,13 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "python",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

8
requirements.txt Normal file
View File

@ -0,0 +1,8 @@
certifi==2024.2.2 ; python_version >= "3.11" and python_version < "3.13"
charset-normalizer==3.3.2 ; python_version >= "3.11" and python_version < "3.13"
idna==3.6 ; python_version >= "3.11" and python_version < "3.13"
python-decouple==3.8 ; python_version >= "3.11" and python_version < "3.13"
python-steamgriddb==1.0.5 ; python_version >= "3.11" and python_version < "3.13"
requests==2.31.0 ; python_version >= "3.11" and python_version < "3.13"
urllib3==2.2.1 ; python_version >= "3.11" and python_version < "3.13"
vdf==3.4 ; python_version >= "3.11" and python_version < "3.13"