1
0
Fork 0
mirror of https://github.com/dilllxd/gitfolio.git synced 2024-08-14 22:28:09 +00:00
gitfolio/build.js

64 lines
4.1 KiB
JavaScript
Raw Normal View History

2019-05-08 15:42:29 +00:00
const program = require('commander');
const fs = require('fs');
const {updateHTML} = require('./populate')
2019-05-08 15:42:29 +00:00
program
.version('0.1.1')
2019-05-08 15:42:29 +00:00
.option('-n, --name [username]', 'get username')
.option('-d, --dark', 'enable dark mode')
.option('-b, --background [background]', 'set background image')
.parse(process.argv);
var dark;
var light;
function populateCSS(){
if (program.dark) {
fs.copyFile('./assets/index.css', 'index.css', (err) => {
if (err) throw err;
fs.appendFile('index.css', dark, function (err) {
if (err) throw err;
2019-05-13 04:10:24 +00:00
});
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
data[0].theme = "dark";
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
2019-05-08 15:42:29 +00:00
});
});
}else{
fs.copyFile('./assets/index.css', 'index.css', (err) => {
if (err) throw err;
fs.appendFile('index.css', light, function (err) {
if (err) throw err;
2019-05-13 04:10:24 +00:00
});
fs.readFile("config.json", function (error , data) {
if (error) throw err;
data = JSON.parse(data);
data[0].theme = "light";
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(error){
if (error) throw err;
});
2019-05-08 15:42:29 +00:00
});
});
}
}
if (program.background) {
dark = `:root {--bg-color: rgb(10, 10, 10);--text-color: #fff;--blog-gray-color:rgb(180, 180, 180);--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.6), rgb(10, 10, 10, 1)), url('${('%s', program.background)}');--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),url('${('%s', program.background)}') center center fixed;--height:50vh;} #display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;} #blog-display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;}#projects section {background:rgb(20, 20, 20);}#blog_section section {background:rgb(20, 20, 20);}@media (max-width: 800px){ --background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgb(10, 10, 10, 0)), url('${('%s', program.background)}') !important;}`;
light = `:root {--bg-color: #fff;--text-color: rgb(10, 10, 10);--blog-gray-color:rgb(80, 80, 80);--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.4), rgb(10, 10, 10, 0.4)), url('${('%s', program.background)}');--background-background: #fff;}`;
2019-05-08 15:42:29 +00:00
populateCSS();
}else{
dark = `:root {--bg-color: rgb(10, 10, 10);--text-color: #fff;--blog-gray-color:rgb(180, 180, 180);--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.6), rgb(10, 10, 10, 1)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450');--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') center center fixed;--height:50vh;} #display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;} #blog-display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;}#projects section {background:rgb(20, 20, 20);}#blog_section section {background:rgb(20, 20, 20);}@media (max-width: 800px){ :root {--background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgb(10, 10, 10, 0)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') !important;}}`;
2019-05-08 15:42:29 +00:00
light = `:root {--bg-color: #fff;--text-color: rgb(10, 10, 10);--blog-gray-color:rgb(80, 80, 80);--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.4), rgb(10, 10, 10, 0.4)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450');--background-background: #fff;}`;
populateCSS();
}
2019-05-08 15:42:29 +00:00
if (program.name) {
updateHTML(('%s', program.name));
2019-05-08 15:42:29 +00:00
} else {
console.log("Provide a username");
}