@@ -49,21 +49,24 @@ export async function init(options: Options) {
49
49
50
50
const entry : string | undefined = await Input . prompt ( {
51
51
message : "Entry file:" ,
52
- default : currentConfig . entry ,
53
- } ) || undefined ;
52
+ default : currentConfig . entry ?? "./mod.ts" ,
53
+ } ) ;
54
+
54
55
const description : string | undefined = await Input . prompt ( {
55
56
message : "Description:" ,
56
- default : currentConfig . description || existing ?. description ,
57
- } ) || undefined ;
57
+ default : currentConfig . description ?? existing ?. description ?? "" ,
58
+ } ) ;
59
+
58
60
const homepage : string | undefined = await Input . prompt ( {
59
61
message : "Module homepage:" ,
60
- default : currentConfig . homepage || existing ?. repository ,
61
- validate : ( value ) => value === "" || validateURL ( value ) ,
62
- } ) || undefined ;
63
- let releaseType : string | undefined = await Select . prompt ( {
64
- message : "Semver increment:" ,
62
+ default : currentConfig . homepage ?? existing ?. repository ?? "" ,
63
+ validate : ( value : string ) => value === "" || validateURL ( value ) ,
64
+ } ) ;
65
+
66
+ let releaseType : string | null | undefined = await Select . prompt ( {
67
+ message : "Automatic semver increment:" ,
65
68
options : [
66
- { name : "none " , value : "none" } ,
69
+ { name : "disabled " , value : "none" } ,
67
70
Select . separator ( "--------" ) ,
68
71
{ name : "patch" , value : "patch" } ,
69
72
{ name : "minor" , value : "minor" } ,
@@ -75,97 +78,99 @@ export async function init(options: Options) {
75
78
{ name : "premajor" , value : "premajor" } ,
76
79
{ name : "prerelease" , value : "prerelease" } ,
77
80
] ,
81
+ default : "none" ,
78
82
keys : {
79
- previous : [ "up" , "8" , "u" ] ,
80
- next : [ "down" , "2" , "d" ] ,
83
+ previous : [ "up" , "8" , "u" , "k" ] ,
84
+ next : [ "down" , "2" , "d" , "j" ] ,
81
85
} ,
82
86
} ) ;
83
- if ( releaseType === "none" ) releaseType = undefined ;
87
+ if ( releaseType === "none" ) releaseType = null ;
84
88
85
89
const version : string | undefined = await Input . prompt ( {
86
90
message : "Version:" ,
87
- default : existing ?. getLatestVersion ( ) ,
88
- validate : ( value ) => value === "" || validateVersion ( value ) ,
89
- } ) || undefined ;
91
+ default : currentConfig . version ?? existing ?. getLatestVersion ( ) ?? "" ,
92
+ validate : ( value : string ) => value === "" || validateVersion ( value ) ,
93
+ } ) ;
90
94
91
95
const unstable : boolean | undefined = await Confirm . prompt ( {
92
96
message : "Is this an unstable version?" ,
93
97
default : currentConfig . unstable ?? false ,
94
- } ) || undefined ;
98
+ } ) ;
95
99
96
100
const unlisted : boolean | undefined = await Confirm . prompt ( {
97
101
message : "Should this module be hidden in the gallery?" ,
98
102
default : currentConfig . unlisted ?? false ,
99
- } ) || undefined ;
103
+ } ) ;
100
104
101
105
let files : string [ ] | undefined = await List . prompt ( {
102
106
message : "Files and relative directories to publish, separated by a comma:" ,
103
- default : currentConfig . files ,
107
+ default : currentConfig . files ?? [ ] ,
104
108
} ) ;
105
- if ( files . length === 1 && files [ 0 ] === "" ) files = undefined ;
109
+ if ( files ? .length === 1 && files [ 0 ] === "" ) files = [ ] ;
106
110
107
111
let ignore : string [ ] | undefined = await List . prompt ( {
108
112
message : "Files and relative directories to ignore, separated by a comma:" ,
109
- default : currentConfig . ignore ,
113
+ default : currentConfig . ignore ?? [ ] ,
110
114
} ) ;
111
- if ( ignore . length === 1 && ignore [ 0 ] === "" ) ignore = undefined ;
115
+ if ( ignore ? .length === 1 && ignore [ 0 ] === "" ) ignore = [ ] ;
112
116
113
117
const check : boolean | undefined = await Confirm . prompt ( {
114
118
message : "Perform all checks before publication?" ,
115
- default : currentConfig . check ?? true ,
119
+ default : currentConfig . check ?? false ,
116
120
} ) ;
117
121
const noCheck = ! check ;
118
122
119
- let checkFormat : boolean | string | undefined =
120
- noCheck && await Confirm . prompt ( {
123
+ let checkFormat : boolean | string | undefined = noCheck &&
124
+ ( await Confirm . prompt ( {
121
125
message : "Check source files formatting before publication?" ,
122
- default : ( ! ! currentConfig . checkFormat ) ?? false ,
123
- } )
124
- ? await Input . prompt ( {
125
- message : "Formatting command (leave blank for default):" ,
126
- default : typeof currentConfig . checkFormat === "string"
127
- ? currentConfig . checkFormat
128
- : undefined ,
129
- } )
130
- : false ;
126
+ default : ! ! currentConfig . checkFormat ?? false ,
127
+ } ) )
128
+ ? await Input . prompt ( {
129
+ message : "Formatting command (leave blank for default):" ,
130
+ default : typeof currentConfig . checkFormat === "string"
131
+ ? currentConfig . checkFormat
132
+ : undefined ,
133
+ } )
134
+ : false ;
131
135
if ( checkFormat === "" ) checkFormat = true ;
132
136
133
- let checkTests : boolean | string | undefined =
134
- noCheck && await Confirm . prompt ( {
137
+ let checkTests : boolean | string | undefined = noCheck &&
138
+ ( await Confirm . prompt ( {
135
139
message : "Test your code before publication?" ,
136
- default : ( ! ! currentConfig . checkTests ) ?? false ,
137
- } )
138
- ? await Input . prompt ( {
139
- message : "Testing command (leave blank for default):" ,
140
- default : typeof currentConfig . checkTests === "string"
141
- ? currentConfig . checkTests
142
- : undefined ,
143
- } )
144
- : false ;
140
+ default : ! ! currentConfig . checkTests ?? false ,
141
+ } ) )
142
+ ? await Input . prompt ( {
143
+ message : "Testing command (leave blank for default):" ,
144
+ default : typeof currentConfig . checkTests === "string"
145
+ ? currentConfig . checkTests
146
+ : undefined ,
147
+ } )
148
+ : false ;
145
149
if ( checkTests === "" ) checkTests = true ;
146
150
147
151
const checkInstallation : boolean | undefined = noCheck &&
148
- await Confirm . prompt ( {
152
+ ( await Confirm . prompt ( {
149
153
message : "Install module and check for missing files before publication?" ,
150
154
default : currentConfig . checkInstallation ?? false ,
151
- } ) ;
155
+ } ) ) ;
152
156
153
157
const format = await Select . prompt ( {
154
158
message : "Config format: " ,
155
- default : ( configPath ? configFormat ( configPath ) : ConfigFormat . JSON )
156
- . toUpperCase ( ) ,
159
+ default : configPath
160
+ ? configFormat ( configPath ) . toUpperCase ( )
161
+ : ConfigFormat . JSON ,
157
162
options : [
158
163
{ name : "YAML" , value : ConfigFormat . YAML } ,
159
164
{ name : "JSON" , value : ConfigFormat . JSON } ,
160
165
] ,
161
166
keys : {
162
- previous : [ "up" , "8" , "u" ] ,
163
- next : [ "down" , "2" , "d" ] ,
167
+ previous : [ "up" , "8" , "u" , "k" ] ,
168
+ next : [ "down" , "2" , "d" , "j" ] ,
164
169
} ,
165
170
} ) ;
166
171
167
172
const config : Partial < Config > = {
168
- " $schema" : `https://x.nest.land/eggs@${ eggsVersion } /src/schema.json` ,
173
+ $schema : `https://x.nest.land/eggs@${ eggsVersion } /src/schema.json` ,
169
174
name,
170
175
entry,
171
176
description,
0 commit comments