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

Commit c7e3959

Browse files
committed
beta
1 parent 9f8bae6 commit c7e3959

File tree

10 files changed

+363
-84
lines changed

10 files changed

+363
-84
lines changed

app/Actions/APITokens.php

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,53 @@
77

88
class APITokens
99
{
10+
protected array $filesToDelete = [
11+
'app/Http/Controllers/TokenController.php',
12+
'app/Http/Resources/TokenResource.php',
13+
'tests/Feature/TokenTest.php',
14+
'database/migrations/2025_07_10_214649_create_personal_access_tokens_table.php',
15+
'app/Models/PersonalAccessToken.php',
16+
'app/Policies/PersonalAccessTokenPolicy.php',
17+
'resources/js/types/token.d.ts',
18+
];
19+
20+
protected array $directoriesToDelete = [
21+
'resources/js/pages/tokens',
22+
];
23+
24+
protected array $filesToRemoveBlocks = [
25+
'routes/settings.php',
26+
'resources/js/layouts/settings/layout.vue',
27+
'resources/js/layouts/settings/layout.tsx',
28+
'app/Models/User.php',
29+
];
30+
1031
/**
1132
* @throws FileNotFoundException
1233
*/
13-
public function setup(string $path, string $frontend, bool $enabled): void
34+
public function setup(string $path, bool $enabled): void
1435
{
1536
if ($enabled) {
1637
return;
1738
}
1839

19-
File::delete($path.'/app/Http/Controllers/TokenController.php');
20-
File::delete($path.'/app/Http/Resources/TokenResource.php');
21-
File::delete($path.'/tests/Feature/TokenTest.php');
22-
23-
$settingsRoutes = File::get($path.'/routes/settings.php');
24-
$settingsRoutes = remove_blocks($settingsRoutes, 'tokens-routes');
25-
File::put($path.'/routes/settings.php', $settingsRoutes);
26-
27-
File::deleteDirectory($path.'/resources/js/pages/tokens');
28-
29-
$tokensMenuPattern = '/\{\s*title:\s*\'API Tokens\',\s*href:\s*route\([^)]+\),\s*icon:\s*CommandIcon,\s*\},?\n?/m';
30-
31-
$settingsLayout = match ($frontend) {
32-
'Vue' => File::get($path.'/resources/js/layouts/settings/layout.vue'),
33-
'React' => File::get($path.'/resources/js/layouts/settings/layout.tsx'),
34-
default => throw new \RuntimeException("Unsupported frontend: {$frontend}"),
35-
};
36-
37-
$settingsLayout = preg_replace($tokensMenuPattern, '', $settingsLayout);
38-
File::put($path.'/resources/js/layouts/settings/layout.tsx', $settingsLayout);
40+
delete_files($path, $this->filesToDelete);
41+
delete_directories($path, $this->directoriesToDelete);
42+
remove_blocks($path, $this->filesToRemoveBlocks, 'tokens');
3943

44+
// manual removals
4045
$userModel = File::get($path.'/app/Models/User.php');
41-
$userModel = str_replace('use HasApiTokens;', '', $userModel);
42-
$userModel = str_replace('* @property Collection<int, PersonalAccessToken> $tokens', '', $userModel);
46+
$userModel = str_replace('@property Collection<int, PersonalAccessToken> $tokens', '', $userModel);
4347
File::put($path.'/app/Models/User.php', $userModel);
44-
45-
File::delete($path.'/database/migrations/2025_07_10_214649_create_personal_access_tokens_table.php');
46-
File::delete($path.'/app/Models/PersonalAccessToken.php');
4748
}
4849

50+
/**
51+
* @throws FileNotFoundException
52+
*/
4953
public function cleanup(string $path, bool $enabled): void
5054
{
55+
remove_block_tags($path, $this->filesToRemoveBlocks, 'tokens');
56+
5157
if ($enabled) {
5258
return;
5359
}

app/Actions/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public function setup(string $path, string $directory): void
1616
}
1717

1818
exec("composer install --working-dir={$path}");
19-
20-
exec("cd {$path} && php artisan key:generate");
2119
}
2220

2321
public function clone(string $directory): void

app/Actions/Billing.php

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,88 @@
22

33
namespace App\Actions;
44

5+
use Illuminate\Contracts\Filesystem\FileNotFoundException;
6+
use Illuminate\Support\Facades\File;
7+
58
class Billing
69
{
7-
public function setup(string $path, bool $enabled): void
10+
protected array $filesToDelete = [
11+
'config/billing.php',
12+
'app/DTOs/BillingPlanDTO.php',
13+
'app/Models/Subscription.php',
14+
'app/Providers/BillingServiceProvider.php',
15+
'resources/views/layouts/billing.blade.php',
16+
'database/migrations/2019_05_03_000001_create_customers_table.php',
17+
'database/migrations/2019_05_03_000002_create_subscriptions_table.php',
18+
'database/migrations/2019_05_03_000003_create_subscription_items_table.php',
19+
'database/migrations/2019_05_03_000004_create_transactions_table.php',
20+
'resources/js/types/plan.d.ts',
21+
'resources/js/types/subscription.d.ts',
22+
];
23+
24+
protected array $directoriesToDelete = [
25+
'app/Http/Controllers/Billing',
26+
'resources/views/billing',
27+
'tests/Feature/Billing',
28+
];
29+
30+
protected array $filesToRemoveBlocks = [
31+
'routes/web.php',
32+
'bootstrap/providers.php',
33+
'resources/js/components/app-sidebar.tsx',
34+
'resources/js/components/app-sidebar.vue',
35+
'resources/js/components/user-menu-content.tsx',
36+
'resources/js/components/user-menu-content.vue',
37+
'resources/views/index.blade.php',
38+
'resources/views/components/navbar.blade.php',
39+
'app/Models/User.php',
40+
'.env',
41+
'.env.example',
42+
];
43+
44+
/**
45+
* @throws FileNotFoundException
46+
*/
47+
public function setup(string $path, string $billing): void
848
{
9-
if ($enabled) {
49+
if ($billing === 'stripe') {
50+
throw new \RuntimeException('Stripe is not supported yet.');
51+
}
52+
53+
if ($billing !== 'none') {
1054
return;
1155
}
1256

13-
$billingRoutes = file_get_contents($path.'/routes/billing.php');
14-
$billingRoutes = remove_blocks($billingRoutes, 'billing-routes');
15-
file_put_contents($path.'/routes/billing.php', $billingRoutes);
57+
delete_files($path, $this->filesToDelete);
58+
delete_directories($path, $this->directoriesToDelete);
59+
remove_blocks($path, $this->filesToRemoveBlocks, 'billing');
1660

17-
$billingLayout = file_get_contents($path.'/resources/js/layouts/billing/layout.vue');
18-
$billingLayout = preg_replace('/\{\s*title:\s*\'Billing\',\s*href:\s*route\([^)]+\),\s*icon:\s*CreditCardIcon,\s*\},?\n?/m', '', $billingLayout);
19-
file_put_contents($path.'/resources/js/layouts/billing/layout.vue', $billingLayout);
61+
// manual removals
62+
$userModel = File::get($path.'/app/Models/User.php');
63+
$userModel = str_replace('@method Subscription|null subscription($type = \'default\')', '', $userModel);
64+
File::put($path.'/app/Models/User.php', $userModel);
2065
}
2166

22-
public function cleanup(string $path, bool $enabled): void
67+
/**
68+
* @throws FileNotFoundException
69+
*/
70+
public function cleanup(string $path, string $billing): void
2371
{
24-
if ($enabled) {
72+
remove_block_tags($path, $this->filesToRemoveBlocks, 'billing');
73+
74+
if ($billing === 'none') {
75+
exec('composer remove laravel/cashier --working-dir='.$path);
76+
exec('composer remove laravel/cashier-paddle --working-dir='.$path);
77+
2578
return;
2679
}
2780

28-
exec('composer remove laravel/cashier --working-dir='.$path);
29-
exec('composer remove laravel/cashier-paddle --working-dir='.$path);
81+
if ($billing === 'stripe') {
82+
exec('composer remove laravel/cashier-paddle --working-dir='.$path);
83+
}
84+
85+
if ($billing === 'paddle') {
86+
exec('composer remove laravel/cashier --working-dir='.$path);
87+
}
3088
}
3189
}

app/Actions/Frontend.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class Frontend
99
{
1010
public function setup(string $path, string $stack): void
1111
{
12+
if ($stack === 'vue') {
13+
throw new RuntimeException('Vue stack is not supported yet.');
14+
}
15+
1216
$renames = [
1317
'resources/js-%s' => 'resources/js',
1418
'vite-%s.config.ts' => 'vite.config.ts',

app/Actions/Npm.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Actions;
4+
5+
class Npm
6+
{
7+
public function setup(string $path, bool $enabled): void
8+
{
9+
if (! $enabled) {
10+
return;
11+
}
12+
13+
exec('npm install --prefix '.$path);
14+
exec('npm run lint --prefix '.$path);
15+
exec('npm run format --prefix '.$path);
16+
exec('npm run build --prefix '.$path);
17+
}
18+
}

app/Actions/Projects.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace App\Actions;
4+
5+
use Illuminate\Contracts\Filesystem\FileNotFoundException;
6+
7+
class Projects
8+
{
9+
protected array $filesToDelete = [
10+
'app/Enums/ProjectRole.php',
11+
'app/Http/Resources/ProjectResource.php',
12+
'app/Http/Resources/ProjectUserResource.php',
13+
'app/Mail/ProjectInvitation.php',
14+
'app/Models/Project.php',
15+
'app/Models/ProjectUser.php',
16+
'app/Policies/ProjectPolicy.php',
17+
'app/Providers/ProjectServiceProvider.php',
18+
'app/Traits/HasProjects.php',
19+
'database/factories/ProjectFactory.php',
20+
'database/migrations/2025_06_29_115509_create_projects_table.php',
21+
'database/migrations/2025_06_29_115510_create_project_user_table.php',
22+
'database/migrations/2025_07_12_212608_add_current_project_id_to_users_table.php',
23+
'resources/js/components/project-switch.tsx',
24+
'resources/js/components/project-switch.vue',
25+
'resources/js/types/project.d.ts',
26+
'resources/js/types/project-user.d.ts',
27+
'resources/emails/project-invitation.blade.php',
28+
];
29+
30+
protected array $directoriesToDelete = [
31+
'app/Actions/Project',
32+
'app/Http/Controllers/Project',
33+
'tests/Feature/Project',
34+
'resources/js/pages/projects',
35+
];
36+
37+
protected array $filesToRemoveBlocks = [
38+
'bootstrap/providers.php',
39+
'app/Models/User.php',
40+
'resources/js/components/nav-main.tsx',
41+
'resources/js/components/nav-main.vue',
42+
'resources/js/components/app-header.tsx',
43+
'resources/js/components/app-header.vue',
44+
'resources/js/layouts/settings/layout.tsx',
45+
'resources/js/layouts/settings/layout.vue',
46+
'routes/settings.php',
47+
];
48+
49+
protected array $filesToRename = [
50+
51+
];
52+
53+
protected array $directoriesToRename = [
54+
55+
];
56+
57+
protected array $filesToReplaceNames = [
58+
59+
];
60+
61+
/**
62+
* @throws FileNotFoundException
63+
*/
64+
public function setup(string $path, string $name): void
65+
{
66+
if ($name === 'projects') {
67+
return;
68+
}
69+
70+
if ($name === 'none') {
71+
delete_files($path, $this->filesToDelete);
72+
delete_directories($path, $this->directoriesToDelete);
73+
remove_blocks($path, $this->filesToRemoveBlocks, 'projects');
74+
75+
return;
76+
}
77+
78+
throw new \RuntimeException("$name is not supported yet!");
79+
}
80+
81+
/**
82+
* @throws FileNotFoundException
83+
*/
84+
public function cleanup(string $path): void
85+
{
86+
remove_block_tags($path, $this->filesToRemoveBlocks, 'projects');
87+
}
88+
}

app/Actions/Tests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function cleanup(string $path, string $stack): void
3131
File::deleteDirectory($path.'/tests-phpunit');
3232

3333
switch ($stack) {
34-
case 'Pest':
34+
case 'pest':
3535
exec('composer remove phpunit/phpunit --no-interaction --working-dir='.$path);
3636
break;
37-
case 'PHPUnit':
37+
case 'phpunit':
3838
exec('composer remove pestphp/pest --no-interaction --working-dir='.$path);
3939
break;
4040
default:

0 commit comments

Comments
 (0)