-added cli support (thanks @rohit-smpx)
-arguments for fork
-you can now sort and order repos
-fixed bugs
This commit is contained in:
imfunny 2019-05-23 15:27:23 +05:30 committed by GitHub
parent 81e8302b22
commit 6fb6408534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1853 additions and 1056 deletions

View File

@ -11,31 +11,29 @@ Check out this [live demo](https://imfunniee.github.io/gitfolio/) to see gitfoli
# Getting Started
### Let's Install
Install gitfolio
```sh
npm i -g gitfolio
```
### Let's Build
a. Clone this repo or simply download it.
```sh
git clone https://github.com/imfunniee/gitfolio.git
gitfolio build <username>
```
This will build your website using your GitHub username and put it in the `/dist` folder.
b. `cd` into the repo you just cloned or downloaded.
```sh
cd gitfolio # Navigate into the project folder
npm i # Install the required dependencies
```
c. Gitfolio is now ready to be used. The command
To run your website use `run` command
```sh
node build --name [username]
gitfolio build <username>
```
Will build your website using your GitHub username and put it in the `dist/` folder.
d. To run your website navigate to `./dist/index.html` in your browser. [you won't see blogs until you are on localhost]
🎉 Congrats, you just made yourself a personal website!
> if you get stuck somewhere or get an error, please create an issue
### Let's Customize
@ -44,7 +42,7 @@ d. To run your website navigate to `./dist/index.html` in your browser. [you won
To include forks on your personal website just provide `-f` or `--fork` argument while building
```
$ node build --name username -f
$ gitfolio build username -f
```
#### Sorting Repos
@ -52,7 +50,7 @@ $ node build --name username -f
To sort repos provide `--sort [sortBy]` argument while building. Where `[sortBy]` can be `star`, `created`, `updated`, `pushed`,`full_name`. Default: `created`
```
$ node build --name username --sort star
$ gitfolio build username --sort star
```
#### Ordering Repos
@ -60,7 +58,7 @@ $ node build --name username --sort star
To order the sorted repos provide `--order [orderBy]` argument while building. Where `[orderBy]` can be `asc` or `desc`. Default: `asc`
```
$ node build --name username --sort star --order desc
$ gitfolio build username --sort star --order desc
```
#### Customize Themes
@ -73,7 +71,7 @@ Themes are specified using the `--theme [theme-name]` flag when running the `bui
For example, the following command will build the website with the dark theme
```
$ node build --name username --theme dark
$ gitfolio build username --theme dark
```
#### Customize background image
@ -81,7 +79,7 @@ $ node build --name username --theme dark
To customize the background image just provide `--background [url]` argument while building
```
$ node build --name username --background https://images.unsplash.com/photo-1557277770-baf0ca74f908?w=1634
$ gitfolio build username --background https://images.unsplash.com/photo-1557277770-baf0ca74f908?w=1634
```
You could also add in your custom CSS inside `index.css` to give it a more personal feel.
@ -99,7 +97,7 @@ Go To `username.github.io` your site should be up!!
To update your info, simply run
```
$ node update
$ gitfolio update
```
This will update your info and your repository info.
@ -111,7 +109,7 @@ To Update background or theme you need to run `build` command again.
To add your first blog run this command.
```
$ node blog --title my-first-blog
$ gitfolio blog my-first-blog
```
> (use "-" instead of spaces)
@ -142,11 +140,12 @@ More Arguments for Blog
> (use "-" instead of spaces)
## Support
Support me by buying me a coffee ☕
Support me to make more projects like this by Buying me a Coffee ☕
<a href="https://www.buymeacoffee.com/imfunniee" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
<a href="https://www.buymeacoffee.com/imfunniee" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;"></a>
## License
![GitHub](https://img.shields.io/github/license/imfunniee/gitfolio.svg)

View File

@ -1,9 +1,9 @@
[
{
"url_title": "FooBar",
"title": "FooBar",
"sub_title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"top_image": "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450",
"visible": true
}
[
{
"url_title": "FooBar",
"title": "FooBar",
"sub_title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"top_image": "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450",
"visible": true
}
]

View File

@ -287,6 +287,7 @@ body{
font-size:24px;
font-weight:bold;
margin:1vh 0px;
padding:0px 1px;
word-wrap: break-word;
}

View File

@ -1,44 +1,51 @@
#! /usr/bin/env node
/* Argument parser */
const program = require('commander');
process.env.OUT_DIR = process.env.OUT_DIR || process.cwd();
const {buildCommand} = require('../build');
const {updateCommand} = require('../update');
const {blogCommand} = require('../blog');
const {version} = require('../package.json');
program
.command('build <username>')
.description('Build site with your GitHub username. This will be used to customize your site')
.option('-t, --theme [theme]', 'specify a theme to use', 'light')
.option('-b, --background [background]', 'set the background image')
.option('-f, --fork', 'includes forks with repos')
.option('-s, --sort [sort]', 'set default sort for repository', 'created')
.option('-o, --order [order]', 'set default order on sort', 'asc')
.action(buildCommand)
program
.command('update')
.action(updateCommand);
program
.command('blog <title>')
.description('Create blog with specified title')
.option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
.option('-p, --pagetitle [pagetitle]', 'give blog page a title')
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)')
.action(blogCommand);
program.on('command:*', () => {
console.log('Unknown Command: ' + program.args.join(' '))
program.help()
});
program
.version(version, '-v --version')
.usage('<command> [options]')
.parse(process.argv);
if (program.args.length === 0) program.help();
/* Argument parser */
const program = require('commander');
process.env.OUT_DIR = process.env.OUT_DIR || process.cwd();
const {buildCommand} = require('../build');
const {updateCommand} = require('../update');
const {blogCommand} = require('../blog');
const {runCommand} = require('../run');
const {version} = require('../package.json');
program
.command('build <username>')
.description('Build site with your GitHub username. This will be used to customize your site')
.option('-t, --theme [theme]', 'specify a theme to use', 'light')
.option('-b, --background [background]', 'set the background image')
.option('-f, --fork', 'includes forks with repos')
.option('-s, --sort [sort]', 'set default sort for repository', 'created')
.option('-o, --order [order]', 'set default order on sort', 'asc')
.action(buildCommand)
program
.command('update')
.description('Update user and repository data')
.action(updateCommand);
program
.command('blog <title>')
.description('Create blog with specified title')
.option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
.option('-p, --pagetitle [pagetitle]', 'give blog page a title')
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)')
.action(blogCommand);
program
.command('run')
.description('Run build files')
.action(runCommand);
program.on('command:*', () => {
console.log('Unknown Command: ' + program.args.join(' '))
program.help()
});
program
.version(version, '-v --version')
.usage('<command> [options]')
.parse(process.argv);
if (program.args.length === 0) program.help();

View File

@ -64,5 +64,5 @@ function blogCommand(title, program) {
}
module.exports = {
blogCommand,
blogCommand
};

View File

@ -83,5 +83,5 @@ async function buildCommand(username, program) {
}
module.exports = {
buildCommand,
buildCommand
};

View File

@ -1,11 +1,11 @@
[
{
"username": null,
"name": null,
"userimg": null,
"sort": null,
"order": null,
"includeFork": null,
"theme": "light.css"
}
[
{
"username": null,
"name": null,
"userimg": null,
"sort": null,
"order": null,
"includeFork": null,
"theme": "light.css"
}
]

2610
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "gitfolio",
"version": "0.1.2",
"description": "portfolio website for showcasing your work",
"version": "0.1.3",
"description": "a portfolio website for everyone to showcase your work",
"main": "build.js",
"bin": "bin/gitfolio.js",
"scripts": {
@ -34,9 +34,13 @@
"dependencies": {
"bluebird": "^3.5.4",
"commander": "^2.20.0",
"express": "^4.17.0",
"github-emoji": "^1.1.0",
"got": "^9.6.0",
"handlebars": "^4.1.2",
"jsdom": "^15.1.0"
"jsdom": "^15.1.0",
"ncp": "^2.0.0",
"open": "^6.3.0",
"x-default-browser": "^0.4.0"
}
}

View File

@ -126,7 +126,7 @@ module.exports.updateHTML = (username, sort, order, includeFork) => {
});
fs.writeFile(`${outDir}/index.html`, '<!DOCTYPE html>' + window.document.documentElement.outerHTML, function (error) {
if (error) throw error;
console.log("Build Complete");
console.log(`Build Complete, Files can be Found @ ${outDir}`);
});
} catch (error) {
console.log(error);

25
run.js Normal file
View File

@ -0,0 +1,25 @@
const express = require('express');
const open = require('open');
const defaultBrowser = require('x-default-browser');
const app = express();
app.use(express.static(__dirname + '/dist'));
function runCommand(){
app.get('/',function(req,res){
res.sendFile('/index.html');
});
app.listen(3000);
defaultBrowser(function (err, res) {
if(err) throw err;
(async () => {
await open('http://localhost:3000', {app: res.commonName});
console.log("ctrl + c to exit");
})();
});
}
module.exports = {
runCommand
};

View File

@ -1,5 +1,4 @@
const fs = require('fs');
const {getConfig, outDir} = require('./utils');
const {getConfig} = require('./utils');
const {updateHTML} = require('./populate');
async function updateCommand() {
@ -16,5 +15,5 @@ async function updateCommand() {
}
module.exports = {
updateCommand,
updateCommand
};

View File

@ -1,39 +1,39 @@
const path = require('path');
const bluebird = require('bluebird');
const fs = bluebird.promisifyAll(require('fs'));
const outDir = path.resolve('./dist/' || process.env.OUT_DIR);
const configPath = path.join(outDir, 'config.json');
const blogPath = path.join(outDir, 'blog.json');
const defaultConfigPath = path.resolve(`${__dirname}/default/config.json`);
const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`);
/**
* Tries to read file from out dir,
* if not present returns default file contents
*/
async function getFileWithDefaults(file, defaultFile) {
try {
await fs.accessAsync(file, fs.constants.F_OK);
} catch (err) {
const defaultData = await fs.readFileAsync(defaultFile);
return JSON.parse(defaultData);
}
const data = await fs.readFileAsync(file);
return JSON.parse(data);
}
async function getConfig() {
return getFileWithDefaults(configPath, defaultConfigPath);
}
async function getBlog() {
return getFileWithDefaults(blogPath, defaultBlogPath);
}
module.exports = {
outDir,
getConfig,
getBlog,
};
const path = require('path');
const bluebird = require('bluebird');
const fs = bluebird.promisifyAll(require('fs'));
const outDir = path.resolve('./dist/' || process.env.OUT_DIR);
const configPath = path.join(outDir, 'config.json');
const blogPath = path.join(outDir, 'blog.json');
const defaultConfigPath = path.resolve(`${__dirname}/default/config.json`);
const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`);
/**
* Tries to read file from out dir,
* if not present returns default file contents
*/
async function getFileWithDefaults(file, defaultFile) {
try {
await fs.accessAsync(file, fs.constants.F_OK);
} catch (err) {
const defaultData = await fs.readFileAsync(defaultFile);
return JSON.parse(defaultData);
}
const data = await fs.readFileAsync(file);
return JSON.parse(data);
}
async function getConfig() {
return getFileWithDefaults(configPath, defaultConfigPath);
}
async function getBlog() {
return getFileWithDefaults(blogPath, defaultBlogPath);
}
module.exports = {
outDir,
getConfig,
getBlog
};