jdecool/scaleway-runtimepublic Fork
⑂ 934f5cd
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

feat: add scaleway-init writing the handler.php stubUnverified

Writes resources/handler.php at the application root and refuses to
replace a different file unless run with --force.
Jérémy DECOOL committed 2026-11-13T22:23:25+01:00 Browse files
934f5cd parent: b326a41
modified .php-cs-fixer.dist.php +1 -1
@@ -4,7 +4,7 @@ declare(strict_types=1);
44
55 $finder = (new PhpCsFixer\Finder())
66 ->in([__DIR__.'/src', __DIR__.'/tests'])
7- ->append([__FILE__]);
7+ ->append([__FILE__, __DIR__.'/bin/scaleway-init']);
88
99 return (new PhpCsFixer\Config())
1010 ->setRiskyAllowed(true)
@@ -4,7 +4,7 @@ declare(strict_types=1);
4 4
5 $finder = (new PhpCsFixer\Finder())5 $finder = (new PhpCsFixer\Finder())
6 ->in([__DIR__.'/src', __DIR__.'/tests'])6 ->in([__DIR__.'/src', __DIR__.'/tests'])
7- ->append([__FILE__]);7+ ->append([__FILE__, __DIR__.'/bin/scaleway-init']);
8 8
9 return (new PhpCsFixer\Config())9 return (new PhpCsFixer\Config())
10 ->setRiskyAllowed(true)10 ->setRiskyAllowed(true)
added bin/scaleway-init +21 -0
new file mode 100755
@@ -0,0 +1,21 @@
1+#!/usr/bin/env php
2+<?php
3+
4+declare(strict_types=1);
5+
6+use Composer\InstalledVersions;
7+
8+require $_composer_autoload_path ?? __DIR__.'/../vendor/autoload.php';
9+
10+$target = realpath(InstalledVersions::getRootPackage()['install_path']).'/handler.php';
11+$stub = (string) file_get_contents(__DIR__.'/../resources/handler.php');
12+
13+if (is_file($target) && file_get_contents($target) !== $stub && !in_array('--force', $argv ?? [], true)) {
14+ fwrite(\STDERR, "{$target} exists and differs from the stub; run with --force to overwrite it.".\PHP_EOL);
15+ exit(1);
16+}
17+
18+if (false === file_put_contents($target, $stub)) {
19+ exit(1);
20+}
21+echo "Wrote {$target}; set the function handler to \"handler.handle\" and commit the file.", \PHP_EOL;
new file mode 100755
@@ -0,0 +1,21 @@
1+#!/usr/bin/env php
2+<?php
3+
4+declare(strict_types=1);
5+
6+use Composer\InstalledVersions;
7+
8+require $_composer_autoload_path ?? __DIR__.'/../vendor/autoload.php';
9+
10+$target = realpath(InstalledVersions::getRootPackage()['install_path']).'/handler.php';
11+$stub = (string) file_get_contents(__DIR__.'/../resources/handler.php');
12+
13+if (is_file($target) && file_get_contents($target) !== $stub && !in_array('--force', $argv ?? [], true)) {
14+ fwrite(\STDERR, "{$target} exists and differs from the stub; run with --force to overwrite it.".\PHP_EOL);
15+ exit(1);
16+}
17+
18+if (false === file_put_contents($target, $stub)) {
19+ exit(1);
20+}
21+echo "Wrote {$target}; set the function handler to \"handler.handle\" and commit the file.", \PHP_EOL;
modified composer.json +3 -0
@@ -28,6 +28,9 @@
2828 "JDecool\\ScalewayRuntime\\": "src/"
2929 }
3030 },
31+ "bin": [
32+ "bin/scaleway-init"
33+ ],
3134 "autoload-dev": {
3235 "psr-4": {
3336 "JDecool\\ScalewayRuntime\\Tests\\": "tests/"
@@ -28,6 +28,9 @@
28 "JDecool\\ScalewayRuntime\\": "src/"28 "JDecool\\ScalewayRuntime\\": "src/"
29 }29 }
30 },30 },
31+ "bin": [
32+ "bin/scaleway-init"
33+ ],
31 "autoload-dev": {34 "autoload-dev": {
32 "psr-4": {35 "psr-4": {
33 "JDecool\\ScalewayRuntime\\Tests\\": "tests/"36 "JDecool\\ScalewayRuntime\\Tests\\": "tests/"
modified phpstan.neon.dist +1 -0
@@ -7,3 +7,4 @@ parameters:
77 paths:
88 - src
99 - tests
10+ - bin/scaleway-init
@@ -7,3 +7,4 @@ parameters:
7 paths:7 paths:
8 - src8 - src
9 - tests9 - tests
10+ - bin/scaleway-init