@jkga/opr
v0.2.0
Published
online profile reader
Downloads
2
Readme
OPR (Online Profile Reader)
Read your profile (json-resume) across various version control platforms such as :white_check_mark: Github :white_check_mark: Gitlab :white_check_mark: Bitbucket and more.
:bulb: If you are using this package for the first time, make sure you have a JSON Resume in your repository. Here is a short article to help you get started.
Installing Dependency
Installation via npm
npm install @jkga/opr
Installation via yarn
yarn add opr
Importing module
CommonJS
const { Opr } = require ('opr')
ES Modules
import { Opr } from 'opr'
Basic Usage
const { Opr } = require('./index')
// initialize Opr
const opr = new Opr({ username: 'yourUsername' })
// enable or disable debugging using the debug function
opr.debug(true)
// read profile from default platforms (github, gitlab, bitbucket)
opr.read()
// return the first successfull result in JSON format
// you can also link `getResponse` in the chain
// ex. opr.read().getResponse ()
opr.getResponse().then(res => {
console.log(res)
}).catch(e => {
console.log('No profile found in all servers')
})
Options
Parameters that you can use when defining your OPR
// sample option with a new server
const opr = new Opr({
username: 'yourUsername',
lang: 'ph',
servers: [
{
name: 'github',
url: 'https://raw.githubusercontent.com',
head: 'master',
repository: 'about.me' // optional
},
],
})
// if there is no server specified, this will be the default value
// excerpt from `./src/helpers/servers.js`
{
[{
{
name: 'github',
url: 'https://raw.githubusercontent.com',
head: 'HEAD'
},
{
name: 'gitlab',
url: 'https://gitlab.com',
head: '-/raw/HEAD'
},
{
name: 'bitbucket',
url: 'https://bitbucket.com',
head: 'raw/HEAD'
}
],
repository: 'about.me'
}
Advanced Usage
Overriding and Writing Server Variables
:bulb: Allows to change different information for each repository
// USAGE
// !IMPORTANT: This will change the username for bitbucket server only.
// Default username for github will remain unchanged
const opr = new Opr({
username: 'potvillage',
default: {
bitbucket: {
username: 'potvillage2'
},
}
})
// SAMPLE
{
default: {
github: {
username: 'your_username',
repository: 'your_repository'
},
}
}
OPR methods in a glance
:bulb: List of available methods available
const opr = new Opr({ ...options }) // initialize
opr.debug(true) // boolean: true | false
opr.getResponseFromRepository(repositoryName) // repositoryName: 'github' | 'bitbucket'
opr.getResponse () // return first successfull response
opr.getResponses() // view responses from all servers [Promise { <pending> }]
opr.getRawResponses() // raw response
Raw Response
// view all raw responses from all the servers
opr.getRawResponses()
// SAMPLE RESPONSE
[
{
name: 'github',
url: 'https://raw.githubusercontent.com',
head: 'master',
repository: '',
response: Promise { <pending> }
},
{
name: 'bitbucket',
url: 'https://bitbucket.com',
head: 'raw/HEAD',
response: Promise { <pending> }
}
]
Individual Response
// read result from github server
// allowed value : github, gitlab, bitbucket
opr.getResponseFromRepository('github').then(res => console.log(res)).catch(e => {})
// SAMPLE RESPONSE
// returns profile found in github server only
{
basics: {
name: 'John Doe',
label: 'Programmer',
picture: 'https:...',
...
}
}
CLI
1.) Install via npm or yarn
npm install @jkga/opr -g
2.) Lookup
// ex. opr potvillage
opr <yourUsernameHere>
Local Testing
1.) Clone the repository
git clone https://github.com/jkga/opr.git
2.) Go inside the directory
cd opr
3.) Install Dependencies
npm install
4.) Test lookup
// ex. npm run lookup potvillage
npm run lookup yourUsernameHere
:bulb: You must have an existing account in github or bitbucket to make it work. For setting-up your own profile please follow this link