11import { filePathToRoutingPath } from "@/build/filepath-to-routing-path" ;
22import { get_user_pranx_config , load_user_pranx_config } from "@/config/index" ;
3- import { logger } from "@/utils /logger" ;
3+ import { logger } from "@/log /logger.js " ;
44import { measureTime } from "@/utils/time-perf" ;
55import fse from "fs-extra" ;
66import kleur from "kleur" ;
@@ -13,7 +13,6 @@ import type {
1313 PageModule ,
1414 SERVER_MANIFEST ,
1515 ServerEntryModule ,
16- ServerManifestRoute ,
1716} from "../../types/index.js" ;
1817import { bundle_browser } from "../build/bundle/browser.js" ;
1918import { bundle_server } from "../build/bundle/server.js" ;
@@ -25,6 +24,7 @@ import {
2524 SITE_MANIFEST_OUTPUT_PATH ,
2625} from "../build/constants.js" ;
2726import { generate_html_template } from "../build/generate_html_template.js" ;
27+ import { log_routes_tree } from "../log/log_routes_tree.js" ;
2828
2929export async function build ( ) {
3030 logger . log ( kleur . bold ( ) . magenta ( "Pranx Build\n" ) ) ;
@@ -335,59 +335,7 @@ export async function build() {
335335
336336 const BUILD_TIME = measureTime ( "build_measure_time" ) ;
337337
338- printRoutesTreeForUser ( server_site_manifest . routes ) ;
338+ log_routes_tree ( server_site_manifest . routes ) ;
339339
340340 logger . success ( `Project builded in ${ BUILD_TIME } ms\n` ) ;
341341}
342-
343- export function printRoutesTreeForUser ( input_routes : ServerManifestRoute [ ] ) {
344- // Loggin Routes
345- logger . log ( kleur . bold ( ) . blue ( ) . underline ( "Routes" ) ) ;
346-
347- function buildTree ( routes : ServerManifestRoute [ ] ) {
348- const tree : any = { } ;
349- for ( const route of routes ) {
350- const parts = route . path === "/" ? [ ] : route . path . split ( "/" ) . filter ( Boolean ) ;
351- let node = tree ;
352- for ( const part of parts ) {
353- node . children = node . children || { } ;
354- node . children [ part ] = node . children [ part ] || { } ;
355- node = node . children [ part ] ;
356- }
357- node . route = route ;
358- }
359- return tree ;
360- }
361-
362- function printTree ( node : any , prefix = "" , isLast = true ) {
363- if ( node . route ) {
364- const icon = node . route . rendering_kind === "static" ? "●" : kleur . yellow ( "λ" ) ;
365- let extra = "" ;
366- if (
367- node . route . rendering_kind === "static" &&
368- node . route . static_generated_routes &&
369- node . route . static_generated_routes . length > 0
370- ) {
371- extra = ` (${ kleur . cyan ( `${ node . route . static_generated_routes . length } ` ) } )` ;
372- }
373- logger . log (
374- `${ prefix } ${ isLast ? "└-" : "├-" } ${ icon } ${ kleur . white ( node . route . path ) } ${ extra } `
375- ) ;
376- }
377- if ( node . children ) {
378- const keys = Object . keys ( node . children ) ;
379- keys . forEach ( ( key , idx ) => {
380- printTree ( node . children [ key ] , prefix + ( node . route ? "| " : "" ) , idx === keys . length - 1 ) ;
381- } ) ;
382- }
383- }
384-
385- const tree = buildTree ( input_routes ) ;
386-
387- logger . log ( "." ) ;
388- printTree ( tree , "" , true ) ;
389-
390- logger . log ( `\n${ kleur . yellow ( "λ" ) } Server-side Page` ) ;
391- logger . log ( "● Static Page" ) ;
392- logger . log ( `${ kleur . cyan ( "(#)" ) } Count of Static Generated Routes\n` ) ;
393- }
0 commit comments