Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 36e2b6b

Browse files
authored
refactor: composer (#46)
1 parent 0db663b commit 36e2b6b

43 files changed

Lines changed: 521 additions & 384 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- uses: php-actions/composer@v6
27-
- uses: php-actions/phpstan@v3
2827
with:
29-
version: composer
28+
working_dir: "src/usr/local/php/unraid-tailscale-utils"
29+
- run: "vendor/bin/phpstan"
3030

3131
commitlint:
3232
name: Commitlint

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111

12+
- name: Install dependencies
13+
uses: "php-actions/composer@v6"
14+
with:
15+
dev: no
16+
working_dir: "src/usr/local/php/unraid-tailscale-utils"
17+
1218
- id: build_files
1319
run: |
1420
mkdir release

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.DS_Store
22
._.DS_Store
33
.php-cs-fixer.cache
4-
/vendor
4+
vendor

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
->in(__DIR__)
66
->name('*.php')
77
->name('*.page')
8+
->exclude(['vendor'])
89
;
910

1011
$config = new PhpCsFixer\Config();

composer

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
composer --working-dir src/usr/local/php/unraid-tailscale-utils/ "$@"

composer.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ parameters:
55
- page
66
paths:
77
- src
8+
excludePaths:
9+
- */vendor/*

src/usr/local/emhttp/plugins/tailscale/approve-nodes.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
namespace Tailscale;
55

66
require_once "include/common.php";
7+
if ( ! isset($utils)) {
8+
throw new \Exception("Utils not initialized.");
9+
}
710

811
$localAPI = new LocalAPI();
912

1013
foreach (array_slice($argv, 1) as $key => $value) {
11-
Utils::logmsg("Tailnet lock: signing {$value}");
14+
$utils->logmsg("Tailnet lock: signing {$value}");
1215
$localAPI->postTkaSign($value);
1316
}

src/usr/local/emhttp/plugins/tailscale/daily.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
77

88
require_once "{$docroot}/plugins/tailscale/include/common.php";
9+
if ( ! defined(__NAMESPACE__ . '\PLUGIN_ROOT') || ! defined(__NAMESPACE__ . '\PLUGIN_NAME')) {
10+
throw new \RuntimeException("Common file not loaded.");
11+
}
12+
$utils = new Utils(PLUGIN_NAME);
13+
914
$tailscaleConfig = $tailscaleConfig ?? new Config();
1015

11-
Utils::run_task('Tailscale\System::notifyOnKeyExpiration');
12-
Utils::run_task('Tailscale\System::refreshWebGuiCert');
16+
$utils->run_task('Tailscale\System::notifyOnKeyExpiration');
17+
$utils->run_task('Tailscale\System::refreshWebGuiCert');

src/usr/local/emhttp/plugins/tailscale/include/Pages/Dashboard.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace Tailscale;
44

5+
use EDACerton\PluginUtils\Translator;
6+
7+
if ( ! defined(__NAMESPACE__ . '\PLUGIN_ROOT') || ! defined(__NAMESPACE__ . '\PLUGIN_NAME')) {
8+
throw new \RuntimeException("Common file not loaded.");
9+
}
10+
11+
$tr = $tr ?? new Translator(PLUGIN_ROOT);
12+
513
$tailscaleConfig = $tailscaleConfig ?? new Config();
6-
$tr = $tr ?? new Translator();
714

815
$tailscale_dashboard = "<tr><td>" . $tr->tr("tailscale_disabled") . "</td></tr>";
916

0 commit comments

Comments
 (0)