• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 11924655642

19 Nov 2024 12:37PM UTC coverage: 81.705% (-0.2%) from 81.946%
11924655642

push

github

web-flow
chore(core): framework installer improvements (#752)

1 of 17 new or added lines in 2 files covered. (5.88%)

56 existing lines in 5 files now uncovered.

7869 of 9631 relevant lines covered (81.7%)

51.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/src/Tempest/Framework/Installers/FrameworkInstaller.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Framework\Installers;
6

7
use Tempest\Core\Installer;
8
use Tempest\Core\PublishesFiles;
9
use function Tempest\root_path;
10
use function Tempest\Support\str;
11

12
final class FrameworkInstaller implements Installer
13
{
14
    use PublishesFiles;
15

16
    public function getName(): string
3✔
17
    {
18
        return 'framework';
3✔
19
    }
20

21
    public function install(): void
2✔
22
    {
23
        $this->installMainNamespace();
2✔
24

25
        $this->publish(
2✔
26
            source: __DIR__ . '/../../../../.env.example',
2✔
27
            destination: root_path('.env.example'),
2✔
28
        );
2✔
29

30
        $this->publish(
1✔
31
            source: __DIR__ . '/../../../../.env.example',
1✔
32
            destination: root_path('.env'),
1✔
33
        );
1✔
34

35
        $this->publish(
1✔
36
            source: __DIR__ . '/index.php',
1✔
37
            destination: root_path('public/index.php'),
1✔
38
        );
1✔
39

40
        $this->publish(
1✔
41
            source: __DIR__ . '/tempest',
1✔
42
            destination: root_path('tempest'),
1✔
43
            callback: function (string $source, string $destination): void {
1✔
44
                if (PHP_OS_FAMILY !== 'Windows') {
1✔
45
                    /** @phpstan-ignore-next-line */
46
                    exec("chmod +x {$destination}");
1✔
47
                }
48
            },
1✔
49
        );
1✔
50
    }
51

52
    private function installMainNamespace(): void
2✔
53
    {
54
        if ($this->composer->mainNamespace !== null) {
2✔
55
            return;
2✔
56
        }
57

UNCOV
58
        if (! $this->confirm('Tempest detected no main project namespace. Do you want to create it?', default: true)) {
×
UNCOV
59
            return;
×
60
        }
61

NEW
62
        $appPath = root_path($this->ask('Which path do you wish to use as your main project directory?', default: 'app/'));
×
63

NEW
64
        $defaultAppNamespace = str($appPath)
×
NEW
65
            ->replaceStart(root_path(), '')
×
NEW
66
            ->trim('/')
×
NEW
67
            ->explode('/')
×
NEW
68
            ->map(fn (string $part) => ucfirst($part))
×
NEW
69
            ->implode('\\')
×
NEW
70
            ->append('\\')
×
NEW
71
            ->toString();
×
72

NEW
73
        $appNamespace = str($this->ask('Which namespace do you wish to use?', default: $defaultAppNamespace))
×
NEW
74
            ->trim('\\')
×
NEW
75
            ->append('\\')
×
NEW
76
            ->toString();
×
77

UNCOV
78
        if (! is_dir($appPath)) {
×
NEW
79
            mkdir($appPath, recursive: true);
×
80
        }
81

UNCOV
82
        $this->composer
×
UNCOV
83
            ->addNamespace(
×
NEW
84
                $appNamespace,
×
UNCOV
85
                $appPath,
×
UNCOV
86
            )
×
UNCOV
87
            ->save();
×
88

UNCOV
89
        $this->success("Project namespace created: {$appPath}");
×
90
    }
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc