# @jkga/opr

> online profile reader

Latest version **0.2.0** (published 2021-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jkga/opr
pnpm add @jkga/opr
yarn add @jkga/opr
bun add @jkga/opr
```

Provides the command `opr`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-03-25 |
| First published | 2021-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jkga |
| Maintainers | jkga |

## Links

- npm: https://www.npmjs.com/package/@jkga/opr
- npm.io page: https://npm.io/package/@jkga/opr

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Recent versions

- 0.2.0 (latest) — 2021-03-25
- 0.1.0 — 2021-03-24

## 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.   

[![JavaScript Style Guide](https://img.shields.io/badge/Code%20Style-Standard%20-green?style=for-the-badge&logo=javascript)](https://github.com/standard/standard) [![JSON RESUME](https://img.shields.io/badge/profile-JSON%20RESUME%20-yellow?style=for-the-badge&logo=json)](http://jsonresume.org)

   
> :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](https://dev.to/jkga/read-your-resume-from-github-gitlab-and-bitbucket-all-at-once-part-1-1b4g) to help you get started.
## Installing Dependency
### Installation via npm
```bash
  npm install @jkga/opr
```
   
### Installation via yarn
```bash
  yarn add opr
```

## Importing module
### CommonJS
```bash
  const { Opr } = require ('opr')
```
### ES Modules
```bash
  import { Opr } from 'opr'
```

## Basic Usage
```js
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
```js
  // 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
      },
    ],
  })
```

```js
  // 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
```js
  // 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'
      },
    }
  })
```
```js
  // SAMPLE
  {
    default: {
      github: {
        username: 'your_username',
        repository: 'your_repository'
      },
    }
  }
```

### OPR methods in a glance
:bulb: List of available methods available
```js
  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
```js
  // view all raw responses from all the servers
  opr.getRawResponses()
```

```js
  // 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
```js
  // read result from github server
  // allowed value : github, gitlab, bitbucket
  opr.getResponseFromRepository('github').then(res => console.log(res)).catch(e => {})
```

```js
  // SAMPLE RESPONSE
  // returns profile found in github server only
  {
    basics: {
      name: 'John Doe',
      label: 'Programmer',
      picture: 'https:...',
      ...
    }
  }
```

## CLI
1.) Install via npm or yarn
```bash
  npm install @jkga/opr -g  
``` 
2.) Lookup
```bash
  // ex. opr potvillage
  opr <yourUsernameHere>
```


## Local Testing
1.) Clone the repository
```bash
  git clone https://github.com/jkga/opr.git
```
2.) Go inside the directory
```bash
  cd opr
```
3.) Install Dependencies
```bash
  npm install
```
4.) Test lookup
```js 
  // 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](https://github.com/jkga/me#quick-setup)

---
_Source: https://npm.io/package/@jkga/opr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
