1- import { main } from "effection" ;
1+ import { call , main } from "effection" ;
22import { parser } from "npm:zod-opts" ;
33import { z } from "npm:zod" ;
44import { staticalize } from "./staticalize.ts" ;
5+ import { join } from "jsr:@std/path" ;
56
67const url = ( ) =>
78 z . string ( ) . refine ( ( str ) => str . match ( / ^ h t t p / ) , {
@@ -10,24 +11,24 @@ const url = () =>
1011
1112await main ( function * ( args ) {
1213 let options = parser ( )
13- . name ( "statical " )
14+ . name ( "staticalize " )
1415 . description (
1516 "Create a static version of a website by traversing a dynamically evaluated sitemap.xml" ,
1617 )
17- . version ( "0.0.0" )
18+ . version ( yield * version ( ) )
1819 . options ( {
1920 site : {
2021 alias : "s" ,
2122 type : url ( ) ,
2223 description :
2324 "URL of the website to staticalize. E.g. http://localhost:8000" ,
2425 } ,
25- outputdir : {
26+ output : {
2627 type : z . string ( ) . default ( "dist" ) ,
2728 description : "Directory to place the downloaded site" ,
2829 alias : "o" ,
2930 } ,
30- "base-url " : {
31+ "base" : {
3132 type : url ( ) ,
3233 description :
3334 "Base URL of the public website. E.g. http://frontside.com" ,
@@ -36,8 +37,16 @@ await main(function* (args) {
3637 . parse ( args ) ;
3738
3839 yield * staticalize ( {
39- base : new URL ( options [ " base-url" ] ) ,
40+ base : new URL ( options . base ) ,
4041 host : new URL ( options . site ) ,
41- dir : options . outputdir ,
42+ dir : options . output ,
4243 } ) ;
4344} ) ;
45+
46+ function * version ( ) {
47+ try {
48+ return yield * call ( ( ) => Deno . readTextFile ( join ( import . meta. dirname ?? "./" , "VERSION" ) ) ) ;
49+ } catch {
50+ return "0.0.0"
51+ }
52+ }
0 commit comments