@@ -5,9 +5,9 @@ import { listenAndServe, path, ServerRequest, walk } from './std.ts'
5
5
import util , { existsDirSync , existsFileSync } from './util.ts'
6
6
import { version } from './version.ts'
7
7
8
- const commands = [ 'init' , 'fetch' , 'dev' , 'start' , 'build' ]
8
+ const commands = [ 'init' , 'fetch' , 'dev' , 'start' , 'build' , 'upgrade' ]
9
9
const helpMessage = `Aleph.js v${ version }
10
- The radical new Front-End Framework in deno.
10
+ The React Framework in deno.
11
11
12
12
Docs: https://alephjs.org/docs
13
13
Bugs: https://github.com/postui/aleph.js/issues
@@ -88,8 +88,28 @@ async function main() {
88
88
log . setLevel ( l )
89
89
}
90
90
91
+ if ( ! hasCommand ) {
92
+ const walkOptions = { includeDirs : false , exts : [ '.js' , '.jsx' , '.mjs' , '.ts' , '.tsx' ] , skip : [ / \. d \. t s $ / i] , dep : 1 }
93
+ const pagesDir = path . join ( path . resolve ( args [ 0 ] || '.' ) , 'pages' )
94
+ let hasIndexPage = false
95
+ if ( existsDirSync ( pagesDir ) ) {
96
+ for await ( const { path : p } of walk ( pagesDir , walkOptions ) ) {
97
+ if ( path . basename ( p ) . split ( '.' ) [ 0 ] === 'index' ) {
98
+ hasIndexPage = true
99
+ }
100
+ }
101
+ }
102
+ if ( ! hasIndexPage ) {
103
+ console . log ( helpMessage )
104
+ Deno . exit ( 0 )
105
+ }
106
+ }
107
+
108
+ // get command, default is 'dev'
109
+ const command = hasCommand ? String ( args . shift ( ) ) : 'dev'
110
+
91
111
// proxy https://deno.land/x/aleph
92
- if ( existsFileSync ( './import_map.json' ) ) {
112
+ if ( [ 'dev' , 'start' , 'build' ] . includes ( command ) && existsFileSync ( './import_map.json' ) ) {
93
113
const { imports } = JSON . parse ( Deno . readTextFileSync ( './import_map.json' ) )
94
114
Object . assign ( globalThis , { ALEPH_IMPORT_MAP : { imports } } )
95
115
if ( imports [ 'https://deno.land/x/aleph/' ] ) {
@@ -112,7 +132,7 @@ async function main() {
112
132
req . respond ( {
113
133
status : 200 ,
114
134
headers : new Headers ( {
115
- 'Content-Type' : getContentType ( '. html') ,
135
+ 'Content-Type' : 'text/ html',
116
136
'Content-Length' : info . size . toString ( )
117
137
} ) ,
118
138
body : createHtml ( {
@@ -146,25 +166,6 @@ async function main() {
146
166
}
147
167
}
148
168
149
- if ( ! hasCommand ) {
150
- const walkOptions = { includeDirs : false , exts : [ '.js' , '.jsx' , '.mjs' , '.ts' , '.tsx' ] , skip : [ / \. d \. t s $ / i] , dep : 1 }
151
- const pagesDir = path . join ( path . resolve ( args [ 0 ] || '.' ) , 'pages' )
152
- let hasIndexPage = false
153
- if ( existsDirSync ( pagesDir ) ) {
154
- for await ( const { path : p } of walk ( pagesDir , walkOptions ) ) {
155
- if ( path . basename ( p ) . split ( '.' ) [ 0 ] === 'index' ) {
156
- hasIndexPage = true
157
- }
158
- }
159
- }
160
- if ( ! hasIndexPage ) {
161
- console . log ( helpMessage )
162
- Deno . exit ( 0 )
163
- }
164
- }
165
-
166
- // execute command
167
- const command = hasCommand ? args . shift ( ) : 'dev'
168
169
import ( `./cli/${ command } .ts` ) . then ( ( { default : cmd } ) => {
169
170
const appDir = path . resolve ( args [ 0 ] || '.' )
170
171
if ( command !== 'init' && ! existsDirSync ( appDir ) ) {
0 commit comments