1
1
<?php
2
- namespace Native \Electron \Traits ;
3
2
4
- use Illuminate \ Support \ Facades \ Storage ;
3
+ namespace Native \ Electron \ Traits ;
5
4
6
5
use function Laravel \Prompts \select ;
7
- trait OsAndArch {
8
6
7
+ trait OsAndArch
8
+ {
9
9
// Available OS in Build and Publish commands
10
- protected function getAvailableOs (): array {
10
+ protected function getAvailableOs (): array
11
+ {
11
12
return $ this ->availableOs ;
12
13
}
13
14
@@ -21,7 +22,8 @@ protected function getDefaultOs(): string
21
22
};
22
23
}
23
24
24
- protected function selectOs (string |null $ os ): string {
25
+ protected function selectOs (?string $ os ): string
26
+ {
25
27
$ os = $ os ?? false ;
26
28
if (! in_array ($ this ->argument ('os ' ), $ this ->getAvailableOs ()) || ! $ os ) {
27
29
$ os = select (
@@ -30,6 +32,7 @@ protected function selectOs(string|null $os): string {
30
32
default: $ this ->getDefaultOs (),
31
33
);
32
34
}
35
+
33
36
return $ os ;
34
37
}
35
38
@@ -38,25 +41,29 @@ protected function selectOs(string|null $os): string {
38
41
*
39
42
* Make this dynamic at some point
40
43
*/
41
- protected function getArchitectureForOs (string $ os ): array {
44
+ protected function getArchitectureForOs (string $ os ): array
45
+ {
42
46
$ archs = match ($ os ) {
43
47
'win ' => ['x64 ' ],
44
48
'mac ' => ['x86 ' , 'arm64 ' ],
45
49
'linux ' => ['x64 ' ]
46
50
};
51
+
47
52
return [...$ archs , 'all ' ];
48
53
}
49
54
50
55
// Depends on the currenty available php executables
51
- protected function selectArchitectureForOs (string $ os , string |null $ arch ): string {
56
+ protected function selectArchitectureForOs (string $ os , ?string $ arch ): string
57
+ {
52
58
$ arch = $ arch ?? false ;
53
- if (!in_array ($ this ->argument ('arch ' ), ($ a = $ this ->getArchitectureForOs ($ os ))) || ! $ arch ) {
59
+ if (! in_array ($ this ->argument ('arch ' ), ($ a = $ this ->getArchitectureForOs ($ os ))) || ! $ arch ) {
54
60
$ arch = select (
55
61
label: 'Please select Processor Architecture ' ,
56
62
options: $ a ,
57
63
default: 'all '
58
64
);
59
65
}
66
+
60
67
return $ arch ;
61
68
}
62
69
}
0 commit comments