diff --git a/.trunk/configs/.bandit b/.trunk/configs/.bandit deleted file mode 100644 index d286ded89..000000000 --- a/.trunk/configs/.bandit +++ /dev/null @@ -1,2 +0,0 @@ -[bandit] -skips = B101 \ No newline at end of file diff --git a/.trunk/configs/.clang-format b/.trunk/configs/.clang-format deleted file mode 100644 index a0e638725..000000000 --- a/.trunk/configs/.clang-format +++ /dev/null @@ -1,6 +0,0 @@ -Language: Cpp -IndentWidth: 4 -ColumnLimit: 130 -PointerAlignment: Right -BreakBeforeBraces: Linux -AllowShortFunctionsOnASingleLine: Inline diff --git a/.trunk/configs/.flake8 b/.trunk/configs/.flake8 deleted file mode 100644 index 5ba6e2ffe..000000000 --- a/.trunk/configs/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -# Autoformatter friendly flake8 config (all formatting rules disabled) -[flake8] -extend-ignore = D1, D2, E1, E2, E3, E501, W1, W2, W3, W5 diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml deleted file mode 100644 index 98bf0cd2e..000000000 --- a/.trunk/configs/.hadolint.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Following source doesn't work in most setups -ignored: - - SC1090 - - SC1091 diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg deleted file mode 100644 index b9fb3f3e8..000000000 --- a/.trunk/configs/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml deleted file mode 100644 index fb940393d..000000000 --- a/.trunk/configs/.markdownlint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Autoformatter friendly markdownlint config (all formatting rules disabled) -default: true -blank_lines: false -bullet: false -html: false -indentation: false -line_length: false -spaces: false -url: false -whitespace: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc deleted file mode 100644 index b2e8a14cc..000000000 --- a/.trunk/configs/.shellcheckrc +++ /dev/null @@ -1,10 +0,0 @@ -enable=all -source-path=SCRIPTDIR -disable=SC2154 -disable=SC2248 -disable=SC2250 - -# If you're having issues with shellcheck following source, disable the errors via: -# disable=SC1090 -# disable=SC1091 -# \ No newline at end of file diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml deleted file mode 100644 index 790846156..000000000 --- a/.trunk/configs/.yamllint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -rules: - quoted-strings: - required: only-when-needed - extra-allowed: ["{|}"] - empty-values: - forbid-in-block-mappings: false - forbid-in-flow-mappings: true - key-duplicates: {} - octal-values: - forbid-implicit-octal: true diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml deleted file mode 100644 index 346b1d9aa..000000000 --- a/.trunk/configs/ruff.toml +++ /dev/null @@ -1,5 +0,0 @@ -# Generic, formatter-friendly config. -select = ["B", "D3", "D4", "E", "F"] - -# Never enforce `E501` (line length violations). This should be handled by formatters. -ignore = ["E501"] diff --git a/.trunk/configs/svgo.config.js b/.trunk/configs/svgo.config.js deleted file mode 100644 index b257d1349..000000000 --- a/.trunk/configs/svgo.config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - plugins: [ - { - name: "preset-default", - params: { - overrides: { - removeViewBox: false, // https://github.com/svg/svgo/issues/1128 - sortAttrs: true, - removeOffCanvasPaths: true, - }, - }, - }, - ], -}; diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index f2393592c..29d56ed1f 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,50 +1,11 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml version: 0.1 cli: - version: 1.22.8 + version: 1.22.2 +# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) plugins: sources: - id: trunk - ref: v1.6.6 - uri: https://github.com/trunk-io/plugins -lint: - enabled: - - prettier@3.4.2 - - trufflehog@3.86.1 - - yamllint@1.35.1 - - bandit@1.8.0 - - checkov@3.2.334 - - terrascan@1.19.9 - - trivy@0.58.0 - #- trufflehog@3.63.2-rc0 - - taplo@0.9.3 - - ruff@0.8.3 - - isort@5.13.2 - - markdownlint@0.43.0 - - oxipng@9.1.3 - - svgo@3.3.2 - - actionlint@1.7.4 - - flake8@7.1.1 - - hadolint@2.12.1-beta - - shfmt@3.6.0 - - shellcheck@0.10.0 - - black@24.10.0 - - git-diff-check - - gitleaks@8.21.2 - - clang-format@16.0.3 - #- prettier@3.3.3 - ignore: - - linters: [ALL] - paths: - - bin/** -runtimes: - enabled: - - python@3.10.8 - - go@1.21.0 - - node@18.20.5 -actions: - disabled: - - trunk-announce - enabled: - - trunk-fmt-pre-commit - - trunk-check-pre-push - - trunk-upgrade-available + ref: v1.6.1 + uri: https://github.com/trunk-io/plugins \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..8b3fe8084 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "firmware", + "version": "1.0.0", + "description": "![GitHub release downloads](https://img.shields.io/github/downloads/meshtastic/firmware/total) [![CI](https://img.shields.io/github/actions/workflow/status/meshtastic/firmware/main_matrix.yml?branch=master&label=actions&logo=github&color=yellow)](https://github.com/meshtastic/firmware/actions/workflows/ci.yml) [![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/firmware)](https://cla-assistant.io/meshtastic/firmware) [![Fiscal Contributors](https://opencollective.com/meshtastic/tiers/badge.svg?label=Fiscal%20Contributors&color=deeppink)](https://opencollective.com/meshtastic/) [![Vercel](https://img.shields.io/static/v1?label=Powered%20by&message=Vercel&style=flat&logo=vercel&color=000000)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "trunk": "trunk", + "lint": "trunk check", + "fmt": "trunk fmt" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/isseysandei/firmware.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/isseysandei/firmware/issues" + }, + "homepage": "https://github.com/isseysandei/firmware#readme" + +} diff --git a/trunk.ps1 b/trunk.ps1 new file mode 100644 index 000000000..9d20e6c7a --- /dev/null +++ b/trunk.ps1 @@ -0,0 +1,72 @@ +$ErrorActionPreference = 'Stop' + +$Env:TRUNK_LAUNCHER_VERSION="1.3.4" # warning: this line is auto-updated +$Env:TRUNK_LAUNCHER_PATH = $PSCommandPath + +# Try to get the version from trunk.yaml. +function TryGetTrunkVersion { + $currentDir = (Get-Location).Path + while ($currentDir -ne '') { + $trunkYamlPath = "$currentDir\.trunk\trunk.yaml" + if (Test-Path "$trunkYamlPath") { + $yamlContent = Get-Content "$trunkYamlPath" -Raw + return $yamlContent -replace '(?s).*\s+version:\s*([0-9a-z.-]+).*','$1' + } + $currentDir = Split-Path $currentDir -Parent + } + return $null +} + +# Get the latest version of trunk. +function GetLatestTrunkVersion { + $latestReleaseInfo = Invoke-RestMethod 'https://trunk.io/releases/latest' -UseBasicParsing + return $latestReleaseInfo -replace '(?s).*version:\s*([0-9a-z.-]+).*','$1' +} + +# Download a particular version of trunk to the specified directory. +function DownloadTrunk($version, $trunkDir) { + $null = New-Item -Type Directory -Force -Path (Split-Path $trunkDir -Parent) + $guid = [System.Guid]::NewGuid() + $downloadPath = "$trunkDir.$guid.zip" + $destinationPath = "$trunkDir.$guid" + try { + # Download the zip file. + $zipFile = "trunk-$version.windows.zip" + $zipFilePath = "$tempDir\$zipFile" + $downloadUrl = "https://trunk.io/releases/$version/$zipFile" + Invoke-RestMethod -Uri $downloadUrl -OutFile $downloadPath + # Extract the zip file to a uniquely named directory. + Expand-Archive -Path $downloadPath -DestinationPath $destinationPath + # Remove the trunk directory if it already exists. + if (Test-Path $trunkDir) { + Remove-Item -Path $trunkDir -Recurse -Force + } + # Move the uniquely named trunk directory to the final location. + Move-Item -Path $destinationPath -Destination $trunkDir + } + finally { + # Cleanup. + Remove-Item -Path $downloadPath -Force -ea 0 + Remove-Item -Path $destinationPath -Recurse -Force -ea 0 + } +} + +# Get the version to run. +$version = TryGetTrunkVersion +if ($version -eq $null) { + $version = GetLatestTrunkVersion +} + +# Determine the expected path to trunk.exe. +$localApplicationData = [Environment]::GetFolderPath('LocalApplicationData') +$trunkDir = "$localApplicationData\trunk\cli\trunk-${version}-windows" +$trunkExe = "$trunkDir\trunk.exe" + +# Download trunk.exe if it doesn't exist. +if (!(Test-Path $trunkExe)) { + DownloadTrunk $version $trunkDir +} + +# Execute trunk with all arguments +& $trunkExe $args +exit $LastExitCode