@@ -41,16 +41,28 @@ seatFile: /home/icpc/Desktop/seat.txt
41
41
throw new Error ( 'no-config' ) ;
42
42
}
43
43
44
- const serverSchema = Schema . object ( {
45
- viewPass : Schema . string ( ) . default ( String . random ( 8 ) ) ,
46
- server : Schema . string ( ) . role ( 'url' ) . required ( ) ,
47
- type : Schema . union ( [ 'server' , 'client' ] ) . required ( ) ,
48
- token : Schema . string ( ) . required ( ) ,
49
- username : Schema . string ( ) . required ( ) ,
50
- password : Schema . string ( ) . required ( ) ,
51
- secretRoute : Schema . string ( ) . default ( String . random ( 12 ) ) ,
52
- seatFile : Schema . string ( ) . default ( '/home/icpc/Desktop/seat.txt' ) ,
53
- } ) ;
44
+ const serverSchema = Schema . intersect ( [
45
+ Schema . object ( {
46
+ type : Schema . union ( [
47
+ Schema . const ( 'server' ) ,
48
+ Schema . const ( 'client' ) ,
49
+ ] as const ) . description ( 'server type' ) . required ( ) ,
50
+ viewPass : Schema . string ( ) . default ( String . random ( 8 ) ) ,
51
+ secretRoute : Schema . string ( ) . default ( String . random ( 12 ) ) ,
52
+ seatFile : Schema . string ( ) . default ( '/home/icpc/Desktop/seat.txt' ) ,
53
+ } ) . description ( 'setting_file' ) ,
54
+ Schema . union ( [
55
+ Schema . object ( {
56
+ type : Schema . const ( 'server' ) ,
57
+ token : Schema . string ( ) . required ( ) ,
58
+ } ) ,
59
+ Schema . object ( {
60
+ type : Schema . const ( 'client' ) ,
61
+ username : Schema . string ( ) . required ( ) ,
62
+ password : Schema . string ( ) . required ( ) ,
63
+ } ) ,
64
+ ] ) ,
65
+ ] ) ;
54
66
const clientSchema = Schema . object ( {
55
67
server : Schema . string ( ) . role ( 'url' ) . required ( ) ,
56
68
balloon : Schema . string ( ) . required ( ) ,
@@ -66,4 +78,4 @@ export const saveConfig = () => {
66
78
67
79
logger . info ( `Config loaded from ${ configPath } ` ) ;
68
80
logger . info ( `xcpc-tools version: ${ version } ` ) ;
69
- if ( ! isClient && ! exit ) logger . info ( `Server View User Info: admin/${ config . viewPassword } ` ) ;
81
+ if ( ! isClient && ! exit ) logger . info ( `Server View User Info: admin/${ config . viewPass } ` ) ;
0 commit comments