Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
fix: run docs
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
  • Loading branch information
Charlike Mike Reagent committed Nov 6, 2018
1 parent e755f9e commit 73b29d8
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ $ yarn add {%= name %}
## API

<!-- docks-start -->
_Generated using [docks](http://npm.im/docks)._

### [src/index.js](/src/index.js)

#### [packageJson](/src/index.js#L26)
Get package metadata from the Unpkg instead of NPM registry.
Optionally you can pass `endpoint` function and return the build
the registry url. See the second test in `test/index.js`.

**Params**
- `packageName` **{string}** the package name, supports `pkg-name@1.2.2` and `pkg-name@next`
- `endpoint` **{function}** like `(name, tag) => url`

**Returns**
- `object` package metadata object

**Examples**
```javascript
import packageJson from '@tunnckocore/package-json';

async function main() {
console.log(await packageJson('eslint'));
console.log(await packageJson('package-json@4.0.0'));
console.log(await packageJson('ava@next'));
}

main().catch(console.error);
```

<!-- docks-end -->

**[back to top](#thetop)**
Expand Down
216 changes: 216 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# @tunnckocore/package-json [![npm version][npmv-img]][npmv-url] [![github release][ghrelease-img]][ghrelease-url] [![License][license-img]][license-url]

> Simple and fast getting of latest package.json metadata for a npm module, using axios and unpkg as a source, because npm registry is basically slow
Please consider following this project's author, [Charlike Mike Reagent](https://github.com/tunnckoCore), and :star: the project to show your :heart: and support.

<div id="thetop"></div>

[![Code style][codestyle-img]][codestyle-url]
[![CircleCI linux build][linuxbuild-img]][linuxbuild-url]
[![CodeCov coverage status][codecoverage-img]][codecoverage-url]
[![DavidDM dependency status][dependencies-img]][dependencies-url]
[![Renovate App Status][renovateapp-img]][renovateapp-url]
[![Make A Pull Request][prs-welcome-img]][prs-welcome-url]
[![Semantically Released][new-release-img]][new-release-url]

If you have any _how-to_ kind of questions, please read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) documents.
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
[@tunnckoCore](https://twitter.com/tunnckoCore) at Twitter.

[![Become a Patron][patreon-img]][patreon-url]
[![Conventional Commits][ccommits-img]][ccommits-url]
[![NPM Downloads Weekly][downloads-weekly-img]][npmv-url]
[![NPM Downloads Monthly][downloads-monthly-img]][npmv-url]
[![NPM Downloads Total][downloads-total-img]][npmv-url]
[![Share Love Tweet][shareb]][shareu]

Project is [semantically](https://semver.org) & automatically released on [CircleCI](https://circleci.com) with [new-release][] and its [New Release](https://github.com/apps/new-release) GitHub App.

<!-- Logo when needed:
<p align="center">
<a href="https://github.com/tunnckoCoreLabs/package-json">
<img src="./media/logo.png" width="85%">
</a>
</p>
-->

## Table of Contents

- [Install](#install)
- [API](#api)
* [src/index.js](#srcindexjs)
+ [packageJson](#packagejson)
- [See Also](#see-also)
- [Contributing](#contributing)
* [Follow the Guidelines](#follow-the-guidelines)
* [Support the project](#support-the-project)
* [OPEN Open Source](#open-open-source)
* [Wonderful Contributors](#wonderful-contributors)
- [License](#license)

_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

## Install

This project requires [**Node.js**](https://nodejs.org) **^8.11.0 || >=10.13.0**. Install it using
[**yarn**](https://yarnpkg.com) or [**npm**](https://npmjs.com).
_We highly recommend to use Yarn when you think to contribute to this project._

```bash
$ yarn add @tunnckocore/package-json
```

## API

<!-- docks-start -->
_Generated using [docks](http://npm.im/docks)._

### [src/index.js](/src/index.js)

#### [packageJson](/src/index.js#L26)
Get package metadata from the Unpkg instead of NPM registry.
Optionally you can pass `endpoint` function and return the build
the registry url. See the second test in `test/index.js`.

**Params**
- `packageName` **{string}** the package name, supports `pkg-name@1.2.2` and `pkg-name@next`
- `endpoint` **{function}** like `(name, tag) => url`

**Returns**
- `object` package metadata object

**Examples**
```javascript
import packageJson from '@tunnckocore/package-json';

async function main() {
console.log(await packageJson('eslint'));
console.log(await packageJson('package-json@4.0.0'));
console.log(await packageJson('ava@next'));
}

main().catch(console.error);
```

<!-- docks-end -->

**[back to top](#thetop)**

## See Also

Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your
existance!
- [@tunnckocore/config](https://www.npmjs.com/package/@tunnckocore/config): All the configs for all the tools, in one place | [homepage](https://github.com/tunnckoCoreLabs/config "All the configs for all the tools, in one place")
- [@tunnckocore/create-project](https://www.npmjs.com/package/@tunnckocore/create-project): Create and scaffold a new project, its GitHub repository and… [more](https://github.com/tunnckoCoreLabs/create-project) | [homepage](https://github.com/tunnckoCoreLabs/create-project "Create and scaffold a new project, its GitHub repository and contents")
- [@tunnckocore/execa](https://www.npmjs.com/package/@tunnckocore/execa): Thin layer on top of [execa][] that allows executing multiple… [more](https://github.com/tunnckoCoreLabs/execa) | [homepage](https://github.com/tunnckoCoreLabs/execa "Thin layer on top of [execa][] that allows executing multiple commands in parallel or in sequence")
- [@tunnckocore/scripts](https://www.npmjs.com/package/@tunnckocore/scripts): Universal and minimalist scripts & tasks runner. | [homepage](https://github.com/tunnckoCoreLabs/scripts "Universal and minimalist scripts & tasks runner.")
- [@tunnckocore/update](https://www.npmjs.com/package/@tunnckocore/update): Update a repository with latest templates from `charlike`. | [homepage](https://github.com/tunnckoCoreLabs/update "Update a repository with latest templates from `charlike`.")
- [asia](https://www.npmjs.com/package/asia): Blazingly fast, magical and minimalist testing framework, for Today and… [more](https://github.com/olstenlarck/asia#readme) | [homepage](https://github.com/olstenlarck/asia#readme "Blazingly fast, magical and minimalist testing framework, for Today and Tomorrow")
- [charlike](https://www.npmjs.com/package/charlike): Small & fast project scaffolder with sane defaults. Supports hundreds… [more](https://github.com/tunnckoCoreLabs/charlike) | [homepage](https://github.com/tunnckoCoreLabs/charlike "Small & fast project scaffolder with sane defaults. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options")
- [docks](https://www.npmjs.com/package/docks): Extensible system for parsing and generating documentation. It just freaking… [more](https://github.com/tunnckoCore/docks) | [homepage](https://github.com/tunnckoCore/docks "Extensible system for parsing and generating documentation. It just freaking works!")
- [gitcommit](https://www.npmjs.com/package/gitcommit): Lightweight and joyful `git commit` replacement. Conventional Commits compliant. | [homepage](https://github.com/tunnckoCore/gitcommit "Lightweight and joyful `git commit` replacement. Conventional Commits compliant.")

**[back to top](#thetop)**

## Contributing

### Follow the Guidelines

Please read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) documents for advices.
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
[@tunnckoCore](https://twitter.com/tunnckoCore) at Twitter.

### Support the project

[Become a Partner or Sponsor?][patreon-url] :dollar: Check the **Partner**, **Sponsor** or **Omega-level** tiers! :tada: You can get your company logo, link & name on this file. It's also rendered on package page in [npmjs.com][npmv-url] and [yarnpkg.com](https://yarnpkg.com/en/package/@tunnckocore/package-json) sites too! :rocket:

Not financial support? Okey! [Pull requests](https://github.com/tunnckoCoreLabs/contributing#opening-a-pull-request), stars and all kind of [contributions](https://opensource.guide/how-to-contribute/#what-it-means-to-contribute) are always
welcome. :sparkles:

### OPEN Open Source

This project is following [OPEN Open Source](http://openopensource.org) model

> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is built on collective efforts and it's not strongly guarded by its founders.
There are a few basic ground-rules for its contributors

1. Any **significant modifications** must be subject to a pull request to get feedback from other contributors.
2. [Pull requests](https://github.com/tunnckoCoreLabs/contributing#opening-a-pull-request) to get feedback are _encouraged_ for any other trivial contributions, but are not required.
3. Contributors should attempt to adhere to the prevailing code-style and development workflow.

### Wonderful Contributors

Thanks to the hard work of these wonderful people this project is alive! It follows the
[all-contributors](https://github.com/kentcdodds/all-contributors) specification.
Don't hesitate to add yourself to that list if you have made any contribution! ;) [See how,
here](https://github.com/jfmengels/all-contributors-cli#usage).

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| [<img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="120px;"/><br /><sub><b>Charlike Mike Reagent</b></sub>](https://tunnckocore.com)<br />[💻](https://github.com/tunnckoCoreLabs/package-json/commits?author=tunnckoCore "Code") [📖](https://github.com/tunnckoCoreLabs/package-json/commits?author=tunnckoCore "Documentation") [💬](#question-tunnckoCore "Answering Questions") [👀](#review-tunnckoCore "Reviewed Pull Requests") [🔍](#fundingFinding-tunnckoCore "Funding Finding") |
| :---: |

<!-- ALL-CONTRIBUTORS-LIST:END -->

Consider showing your [support](#support-the-project) to them. :sparkling_heart:

## License

Copyright (c) 2018-present, [Charlike Mike Reagent](https://tunnckocore.com) `<mameto2011@gmail.com>` & [contributors](#wonderful-contributors).
Released under the [Apache-2.0 License][license-url].

<!-- Heading badges -->

[npmv-url]: https://www.npmjs.com/package/@tunnckocore/package-json
[npmv-img]: https://badgen.net/npm/v/@tunnckocore/package-json?icon=npm

[ghrelease-url]: https://github.com/tunnckoCoreLabs/package-json/releases/latest
[ghrelease-img]: https://badgen.net/github/release/tunnckoCoreLabs/package-json?icon=github

[license-url]: https://github.com/tunnckoCoreLabs/package-json/blob/master/LICENSE
[license-img]: https://badgen.net/npm/license/@tunnckocore/package-json

<!-- Front line badges -->

[codestyle-url]: https://github.com/airbnb/javascript
[codestyle-img]: https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb

[linuxbuild-url]: https://circleci.com/gh/tunnckoCoreLabs/package-json/tree/master
[linuxbuild-img]: https://badgen.net/circleci/github/tunnckoCoreLabs/package-json/master?label=build&icon=circleci

[codecoverage-url]: https://codecov.io/gh/tunnckoCoreLabs/package-json
[codecoverage-img]: https://badgen.net/codecov/c/github/tunnckoCoreLabs/package-json?icon=codecov

[dependencies-url]: https://david-dm.org/tunnckoCoreLabs/package-json
[dependencies-img]: https://badgen.net/david/dep/tunnckoCoreLabs/package-json?label=deps

[ccommits-url]: https://conventionalcommits.org/
[ccommits-img]: https://badgen.net/badge/conventional%20commits/v1.0.0/dfb317
[new-release-url]: https://ghub.io/new-release
[new-release-img]: https://badgen.net/badge/semantically/released/05c5ff

[downloads-weekly-img]: https://badgen.net/npm/dw/@tunnckocore/package-json
[downloads-monthly-img]: https://badgen.net/npm/dm/@tunnckocore/package-json
[downloads-total-img]: https://badgen.net/npm/dt/@tunnckocore/package-json

[renovateapp-url]: https://renovatebot.com
[renovateapp-img]: https://badgen.net/badge/renovate/enabled/green
[prs-welcome-img]: https://badgen.net/badge/PRs/welcome/green
[prs-welcome-url]: http://makeapullrequest.com
[paypal-donate-url]: https://paypal.me/tunnckoCore/10
[paypal-donate-img]: https://badgen.net/badge/$/support/purple
[patreon-url]: https://www.patreon.com/bePatron?u=5579781
[patreon-img]: https://badgen.net/badge/patreon/tunnckoCore/F96854?icon=patreon
[patreon-sponsor-img]: https://badgen.net/badge/become/a%20sponsor/F96854?icon=patreon

[shareu]: https://twitter.com/intent/tweet?text=https://github.com/tunnckoCoreLabs/package-json&via=tunnckoCore
[shareb]: https://badgen.net/badge/twitter/share/1da1f2?icon=twitter
[open-issue-url]: https://github.com/tunnckoCoreLabs/package-json/issues/new

[execa]: https://github.com/sindresorhus/execa
[new-release]: https://github.com/tunnckoCore/new-release
[semantic-release]: https://github.com/semantic-release/semantic-release
23 changes: 22 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import parse from 'parse-package-name';
import axios from 'axios';

// packageName: String, endpoint: (name: String, tag: String = 'latest'): String => {}
/**
* Get package metadata from the Unpkg instead of NPM registry.
* Optionally you can pass `endpoint` function and return the build
* the registry url. See the second test in `test/index.js`.
*
* @example
* import packageJson from '@tunnckocore/package-json';
*
* async function main() {
* console.log(await packageJson('eslint'));
* console.log(await packageJson('package-json@4.0.0'));
* console.log(await packageJson('ava@next'));
* }
*
* main().catch(console.error);
*
* @name packageJson
* @param {string} packageName the package name, supports `pkg-name@1.2.2` and `pkg-name@next`
* @param {function} endpoint like `(name, tag) => url`
* @returns {object} package metadata object
* @public
*/
export default async function packageJson(packageName, endpoint) {
const { name, version } = parse(packageName);
const tag = version === '' ? 'latest' : version;
Expand Down

0 comments on commit 73b29d8

Please sign in to comment.