@@ -13,10 +13,11 @@ const commands = {
13
13
"init" : "Create a new app" ,
14
14
"dev" : "Start the app in `development` mode" ,
15
15
"start" : "Start the app in `production` mode" ,
16
- "build" : "Build the app into a worker" ,
16
+ "build" : "Build the app into a worker for serverless platform " ,
17
17
} ;
18
18
19
- const helpMessage = `Aleph.js v${ VERSION }
19
+ const commandsFmt = Object . entries ( commands ) . map ( ( [ n , d ] ) => n . padEnd ( 16 ) + d ) . join ( "\n" . padEnd ( 5 ) ) ;
20
+ const helpMessage = `${ bold ( "Aleph.js" ) } v${ VERSION }
20
21
The Full-stack Framework in Deno.
21
22
22
23
Docs: https://alephjs.org/docs
@@ -26,14 +27,12 @@ Usage:
26
27
deno run -A https://deno.land/x/aleph/cli.ts <command> [...options]
27
28
28
29
Commands:
29
- ${
30
- Object . entries ( commands ) . map ( ( [ name , desc ] ) => `${ name . padEnd ( 15 ) } ${ desc } ` )
31
- . join ( "\n " )
32
- }
30
+ ${ commandsFmt }
33
31
34
32
Options:
35
- -v, --version Prints version number
36
- -h, --help Prints help message
33
+ -r, --reload Reload source code cache (recompile TypeScript)
34
+ -v, --version Prints version number
35
+ -h, --help Prints help message
37
36
` ;
38
37
39
38
async function main ( ) {
@@ -58,7 +57,7 @@ async function main() {
58
57
}
59
58
60
59
// prints help message
61
- if ( options . h || options . help || ! ( args . length > 0 && args [ 0 ] in commands ) ) {
60
+ if ( options . h || options . help || args . length === 0 || ! ( args [ 0 ] in commands ) ) {
62
61
console . log ( helpMessage ) ;
63
62
Deno . exit ( 0 ) ;
64
63
}
@@ -86,6 +85,13 @@ async function main() {
86
85
}
87
86
p . close ( ) ;
88
87
88
+ // check `reload` flag
89
+ const reload = options . r ?? options . reload ;
90
+ if ( reload ) {
91
+ runOptions . reload = true ;
92
+ Deno . env . set ( "ALEPH_RELOAD_FLAG" , "true" ) ;
93
+ }
94
+
89
95
if ( Deno . env . get ( "ALEPH_DEV" ) ) {
90
96
runOptions . denoConfigFile = resolve ( "./deno.json" ) ;
91
97
runOptions . importMapFile = resolve ( "./import_map.json" ) ;
@@ -157,10 +163,11 @@ type RunOptions = {
157
163
isCanary ?: boolean ;
158
164
denoConfigFile ?: string ;
159
165
importMapFile ?: string ;
166
+ reload ?: boolean ;
160
167
} ;
161
168
162
169
async function run ( command : string , options : RunOptions ) {
163
- const { version, isCanary, denoConfigFile, importMapFile } = options ;
170
+ const { version, isCanary, denoConfigFile, importMapFile, reload } = options ;
164
171
const { esbuildBinDir, esbuildBinPath } = getEsbuildPath ( "0.14.36" ) ;
165
172
const devPort = Deno . env . get ( "ALEPH_DEV_PORT" ) ;
166
173
const rwDirs = [
@@ -180,9 +187,10 @@ async function run(command: string, options: RunOptions) {
180
187
"--location=http://localhost" ,
181
188
"--no-check" ,
182
189
"--unstable" ,
190
+ reload && "--reload" ,
191
+ ! reload && devPort && `--reload=http://localhost:${ devPort } ` ,
183
192
denoConfigFile && `--config=${ denoConfigFile } ` ,
184
193
importMapFile && `--import-map=${ importMapFile } ` ,
185
- devPort && `--reload=http://localhost:${ devPort } ` ,
186
194
] . filter ( Boolean ) as string [ ] ;
187
195
if ( version ) {
188
196
const pkgName = isCanary ? "aleph_canary" : "aleph" ;
0 commit comments