From c2f38bc39a910882cec99fce90f97dad9cfa8a6c Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 25 Mar 2025 20:06:50 +0100 Subject: [PATCH] [Build] Improve rendering, add fs parsing FS parsing needs a lot of improvements (namely ignoring gitignore files). Probably gonna migrate to a library for this --- build/render.js | 14 +++++++++++--- build/util.js | 17 +++++++++++------ config/fish/fish_variables | 33 --------------------------------- 3 files changed, 22 insertions(+), 42 deletions(-) delete mode 100755 config/fish/fish_variables diff --git a/build/render.js b/build/render.js index 9028278..879b4b9 100644 --- a/build/render.js +++ b/build/render.js @@ -50,7 +50,7 @@ const build = ( wallpaper, lockpaper, theme ) => { console.log( view ); try { - fs.mkdir( path.join( __dirname + '../dist' ) ); + fs.mkdir( path.join( __dirname, '/dist' ) ); } catch ( e ) { } @@ -58,6 +58,7 @@ const build = ( wallpaper, lockpaper, theme ) => { // recursively index files from config directory -> Maybe add a file to each // directory to indicate whether or not to index files in it? const fileList = util.treeWalker( path.join( __dirname, '/../config/' ), '*' ); + console.log( fileList ); for (let index = 0; index < fileList; index++) { try { render( fileList[ index ], view ); @@ -65,7 +66,8 @@ const build = ( wallpaper, lockpaper, theme ) => { console.error( '=> Render failed for ' + fileList[ index ] ); } } - } ).catch( () => { + } ).catch( e => { + console.error( e ); console.error( '\n=> Failed to load image or retrieve colour palette from it' ); } ); } @@ -135,7 +137,13 @@ const yaziThemes = { const render = ( templatePath, view ) => { // Load template from disk (all can be found in /config) const template = '' + fs.readFileSync( path.join( __dirname, '/../config/', templatePath ) ); - const outPath = ''; + const outPath = path.join( __dirname, 'dist', templatePath ) + console.log( '=> Rendering to ' + outPath ); + try { + fs.mkdir( path.dirname( outPath ) ); + } catch ( _ ) { + + } fs.writeFileSync( outPath, mustache.render( template, view ) ); } diff --git a/build/util.js b/build/util.js index fcc48b5..cae1b7f 100644 --- a/build/util.js +++ b/build/util.js @@ -1,4 +1,6 @@ const convert = require( 'color-convert' ); +const fs = require( 'fs' ); +const path = require( 'path' ); /** * Recursively find all HTML files in a directory @@ -10,15 +12,18 @@ const treeWalker = ( dir, extension ) => { const ls = fs.readdirSync( dir ); const fileList = []; for ( let file in ls ) { - if ( !ls[ file ].includes( '.' ) ) { - const newFiles = treeWalker( dir + '/' + ls[ file ], extension ); - for ( let file in newFiles ) { - fileList.push( newFiles[ file ] ); + if ( fs.statSync( path.join( dir, ls[ file ] ) ).isDirectory() ) { + const newFiles = treeWalker( path.join( dir, ls[ file ] ), extension ); + // TODO: Ignore files in .gitignore, as well as .gitignore + if ( !newFiles.includes( '.configbuildignore' ) ) { + for ( let file in newFiles ) { + fileList.push( newFiles[ file ] ); + } } } else if ( extension == '*' ) { - fileList.push( dir + '/' + ls[ file ] ); + fileList.push( path.join( dir, ls[ file ] ) ); } else if ( ls[ file ].includes( extension ) ) { - fileList.push( dir + '/' + ls[ file ] ); + fileList.push( path.join( dir, ls[ file ] ) ); } } diff --git a/config/fish/fish_variables b/config/fish/fish_variables deleted file mode 100755 index 6d13aee..0000000 --- a/config/fish/fish_variables +++ /dev/null @@ -1,33 +0,0 @@ -# This file contains fish universal variable definitions. -# VERSION: 3.0 -SETUVAR __fish_initialized:3800 -SETUVAR fish_color_autosuggestion:555\x1ebrblack -SETUVAR fish_color_cancel:\x2dr -SETUVAR fish_color_command:blue -SETUVAR fish_color_comment:red -SETUVAR fish_color_cwd:green -SETUVAR fish_color_cwd_root:red -SETUVAR fish_color_end:green -SETUVAR fish_color_error:brred -SETUVAR fish_color_escape:brcyan -SETUVAR fish_color_history_current:\x2d\x2dbold -SETUVAR fish_color_host:normal -SETUVAR fish_color_host_remote:yellow -SETUVAR fish_color_normal:normal -SETUVAR fish_color_operator:brcyan -SETUVAR fish_color_param:cyan -SETUVAR fish_color_quote:yellow -SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold -SETUVAR fish_color_search_match:white\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_status:red -SETUVAR fish_color_user:brgreen -SETUVAR fish_color_valid_path:\x2d\x2dunderline -SETUVAR fish_greeting:\x1d -SETUVAR fish_key_bindings:fish_default_key_bindings -SETUVAR fish_pager_color_completion:normal -SETUVAR fish_pager_color_description:B3A06D\x1eyellow\x1e\x2di -SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline -SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan -SETUVAR fish_pager_color_selected_background:\x2dr -SETUVAR fish_user_paths:/usr/lib/python3\x2e11/site\x2dpackages\x1e/usr/lib/python3\x2e11\x1e/usr/lib/python3\x2e11/site\x2dpackages/\x1e/home/janis/\x2elocal/lib/python3\x2e11/site\x2dpackages/\x1e/home/janis/\x2elocal/lib/python3\x2e11/