Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/vendor/
.cache
.tempest
.tempest
# testbench related files
.vite
vite-tempest
node_modules
public/build/
package.json
package-lock.json
log/
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"autoload-dev": {
"psr-4": {
"NeoIsRecursive\\Inertia\\Tests\\": "tests/"
"NeoIsRecursive\\Inertia\\Tests\\": "tests/",
"Testbench\\": "testbench/"
}
},
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Tempest\Discovery\DiscoveryLocation;
use Tempest\Router\HttpApplication;

require_once __DIR__ . '/../vendor/autoload.php';

HttpApplication::boot(__DIR__ . '/../', discoveryLocations: [
new DiscoveryLocation('Testbench\\', __DIR__ . '/../testbench/'),
])->run();

exit();
56 changes: 26 additions & 30 deletions src/Installer/InertiaInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,19 @@ private function installReact(string $clientPath, string $pagesPath): void
destination: (string) path($clientPath, $pagesPath, 'example-page.tsx'),
);

$this->write(
contents: <<<'CODE'
To make vite bundle jsx and enable fast refresh, you need the @vitejs/plugin-react plugin.
We have installed it for you, but you need to add it to your Vite config.

import react from '@vitejs/plugin-react';
// ...
export default defineConfig({
plugins: [
// ... other plugins
react(),
],
});
CODE,
);
$this->write(contents: <<<'CODE'
To make vite bundle jsx and enable fast refresh, you need the @vitejs/plugin-react plugin.
We have installed it for you, but you need to add it to your Vite config.

import react from '@vitejs/plugin-react';
// ...
export default defineConfig({
plugins: [
// ... other plugins
react(),
],
});
CODE);
}

private function installVue(string $clientPath, string $pagesPath): void
Expand Down Expand Up @@ -147,20 +145,18 @@ private function installVue(string $clientPath, string $pagesPath): void
destination: (string) path($clientPath, $pagesPath, 'example-page.vue'),
);

$this->write(
contents: <<<'CODE'
Vite requires a plugin to parse Vue files.
We have installed it for you, but you need to add it to your Vite config.

import vue from '@vitejs/plugin-vue';
// ...
export default defineConfig({
plugins: [
// ... other plugins
vue(),
],
});
CODE,
);
$this->write(contents: <<<'CODE'
Vite requires a plugin to parse Vue files.
We have installed it for you, but you need to add it to your Vite config.

import vue from '@vitejs/plugin-vue';
// ...
export default defineConfig({
plugins: [
// ... other plugins
vue(),
],
});
CODE);
}
}
13 changes: 13 additions & 0 deletions tempest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php

use Tempest\Console\ConsoleApplication;
use Tempest\Discovery\DiscoveryLocation;

require_once getcwd() . '/vendor/autoload.php';

ConsoleApplication::boot(discoveryLocations: [
new DiscoveryLocation('Testbench\\', getcwd() . '/testbench/'),
])->run();

exit;
21 changes: 21 additions & 0 deletions testbench/TestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Testbench;

use NeoIsRecursive\Inertia\Http\InertiaResponse;
use Tempest\Router\Get;

use function NeoIsRecursive\Inertia\inertia;

final readonly class TestController
{
#[Get('/')]
public function examplePage(): InertiaResponse
{
return inertia(
component: 'example-page',
);
}
}
36 changes: 36 additions & 0 deletions testbench/TestbenchCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Testbench;

use Tempest\Console\ConsoleCommand;

use function Tempest\root_path;
use function Tempest\src_path;
use function Tempest\Support\Filesystem\delete;
use function Tempest\Support\path;

final class TestbenchCommand
{

#[ConsoleCommand(
description: 'Remove files that installer created for testing purposes.',
)]
public function clean()
{
$files_to_delete = [
root_path('node_modules'),
(string) path(__DIR__, 'Client'),
src_path('app.view.php'),
src_path('Client'),
root_path('package.json'),
root_path('package-lock.json'),
root_path('vite.config.ts'),
];

foreach ($files_to_delete as $file) {
delete($file, recursive: is_dir($file));
}
}
}