-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathValidatesAppConfig.php
More file actions
63 lines (50 loc) · 2.15 KB
/
Copy pathValidatesAppConfig.php
File metadata and controls
63 lines (50 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Native\Mobile\Traits;
use Native\Mobile\Support\AppIdValidator;
trait ValidatesAppConfig
{
private function validateAppVersion(string $buildType): void
{
$appVersion = config('nativephp.version');
// Check if this is a release build
if ($buildType === 'release') {
if ($appVersion === 'DEBUG') {
\Laravel\Prompts\error('Cannot create release build with DEBUG version!');
$this->line('Please set a proper version using: php artisan native:release patch|minor|major');
$this->line('Or manually update NATIVEPHP_APP_VERSION in your .env file');
exit(1);
}
if (empty($appVersion)) {
\Laravel\Prompts\error('NATIVEPHP_APP_VERSION is not set!');
$this->line('Please set a version using: php artisan native:release patch|minor|major');
$this->line('Or manually add NATIVEPHP_APP_VERSION to your .env file');
exit(1);
}
$this->components->twoColumnDetail('Release version', $appVersion);
}
}
protected function validateAppId(): void
{
$appId = config('nativephp.app_id');
if (str($appId)->isEmpty()) {
\Laravel\Prompts\error('Set your NATIVEPHP_APP_ID');
$this->line('Please add a NATIVEPHP_APP_ID to your .env file (e.g. com.example.myapp).');
exit(1);
}
if (str($appId)->startsWith('com.nativephp.')) {
\Laravel\Prompts\warning('Please change your NATIVEPHP_APP_ID. Must not contain "nativephp"');
}
$errors = AppIdValidator::validate($appId);
if ($errors['android']) {
\Laravel\Prompts\error('Invalid app ID for Android: '.$errors['android']);
}
if ($errors['ios']) {
\Laravel\Prompts\error('Invalid app ID for iOS: '.$errors['ios']);
}
if ($errors['android'] || $errors['ios']) {
$this->line('Please fix NATIVEPHP_APP_ID in your .env file.');
$this->line('A valid app ID looks like: com.yourcompany.yourapp');
exit(1);
}
}
}