[Build] Prep
This commit is contained in:
		| @@ -1,9 +1,52 @@ | ||||
| // Using commonjs instead of ejs, because more widely compatible | ||||
| const mustache = require( 'mustache' ); | ||||
| const inquirer = require( 'inquirer' ); | ||||
| const fs = require( 'fs' ); | ||||
| const path = require( 'path' ); | ||||
| const os = require( 'os' ); | ||||
| const render = require( './render' ); | ||||
|  | ||||
| // Define view options (for rendering with mustache) | ||||
| const view = { | ||||
|     // Colours | ||||
|     'colour_foreground': '', | ||||
|  | ||||
| // Prompt user to select a wallpaper (if no path is passed as argument) | ||||
| const wallpapers = fs.readdirSync( path.join( os.homedir(), '/NextCloud/Wallpapers' ) ); | ||||
| const wallpaperChoices = []; | ||||
| wallpapers.forEach(element => { | ||||
|     wallpaperChoices.push( { 'name': element.split( '.' )[ 0 ], 'value': element } ); | ||||
| }); | ||||
|  | ||||
|  | ||||
| // Selection options | ||||
| const chooseWallpaper = { | ||||
|     'type': 'list', | ||||
|     'name': 'wallpaper', | ||||
|     'message': 'Choose the wallpaper to be used', | ||||
|     'choices': wallpaperChoices, | ||||
| }; | ||||
|  | ||||
| const chooseLockpaper = { | ||||
|     'type': 'list', | ||||
|     'name': 'lockpaper', | ||||
|     'message': 'Choose the lockscreen wallpaper to be used', | ||||
|     'choices': wallpaperChoices, | ||||
| }; | ||||
|  | ||||
| const chooseTheme = { | ||||
|     'type': 'list', | ||||
|     'name': 'theme', | ||||
|     'message': 'Choose the general colourway to be used', | ||||
|     'choices': [ | ||||
|         { name: 'Nordic', value: 'nordic' }, | ||||
|         { name: 'Deep-Dark', value: 'deep-dark' }, | ||||
|         { name: 'Material-You', value: 'material' }, | ||||
|         { name: 'Light', value: 'light' }, | ||||
|         { name: 'Bright', value: 'bright' }, | ||||
|     ] | ||||
| } | ||||
|  | ||||
| // TODO: Add argument parsing | ||||
| const args = process.argv.slice( 2 ); | ||||
| inquirer.default.prompt( [ | ||||
|     chooseWallpaper, | ||||
|     chooseTheme | ||||
| ] ).then( answers => { | ||||
|     render( path.join( os.homedir(), '/NextCloud/Wallpapers', answers.wallpaper ), path.join( os.homedir(), '/NextCloud/Wallpapers', answers.lockpaper ), answers.theme ); | ||||
| } ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user