LookAtMySuitBot/js/node_modules/package.json/README.md

91 lines
11 KiB
Markdown
Raw Normal View History

2023-12-24 20:08:39 -05:00
# pkg.json
[![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![AMA](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/pkg.json.svg)](https://www.npmjs.com/package/pkg.json) [![Downloads](https://img.shields.io/npm/dt/pkg.json.svg)](https://www.npmjs.com/package/pkg.json) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
> Get the package.json content either from npm or from a git repository.
## :cloud: Installation
```sh
$ npm i --save pkg.json
```
## :clipboard: Example
```js
const packageJson = require("pkg.json");
packageJson("git-stats", function (err, data) {
console.log(err || data);
// { _id: 'git-stats',
// _rev: '34-f8a1ea58b78974bb0c530dd9e366cf24',
// name: 'git-stats',
// description: 'Local git statistics including GitHub-like contributions calendars.',
// 'dist-tags': { latest: '2.9.2' },
// versions: {...},
// readme: '[![git-stats](http://i.imgur.com/Q7TQYHx.png)](#)\n\n# `$ git-stats` [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/git-stats.svg)](https://www.npmjs.com/package/git-stats) [![Downloads](https://img.shields.io/npm/dt/git-stats.svg)](https://www.npmjs.com/package/git-stats) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)\n\n> Local git statistics including GitHub-like contributions calendars.\n\nI\'d be curious to see your calendar with all your commits. Ping me on Twitter ([**@IonicaBizau**](https://twitter.com/IonicaBizau)). :smile: Until then, here\'s my calendar:\n\n![](http://i.imgur.com/PpM0i3v.png)\n\n## Contents\n\n - [Installation](#installation)\n - [Usage](#usage)\n \n - [Importing and deleting commits](#importing-and-deleting-commits)\n - [Importing all the commits from GitHub and BitBucket](#importing-all-the-commits-from-github-and-bitbucket)\n - [What about the GitHub Contributions calendar?](#what-about-the-github-contributions-calendar)\n \n - [Documentation](#documentation)\n - [How to contribute](#how-to-contribute)\n\n## Installation\n\nYou can install the package globally and use it as command line tool:\n\n```sh\n# Install the package globally\nnpm i -g git-stats\n# Initialize git hooks\n# This is for tracking the new commits\ncurl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/master/scripts/init-git-post-commit | bash\n```\n\nThen, run `git-stats --help` and see what the CLI tool can do.\n\n```sh\n$ git-stats --help\nUsage: git-stats [options]\n\nOptions:\n -s, --since <date> Optional start date. \n -u, --until <date> Optional end date. \n -n, --no-ansi Forces the tool not to use ANSI styles. \n -l, --light Enables the light theme. \n -a, --authors Shows a pie chart with the author related \n contributions in the current repository. \n -g, --global-activity Shows global activity calendar in the current \n repository. \n -d, --data <path> Sets a custom data store file. \n -f, --first-day <day> Sets the first day of the week. \n --record <data> Records a new commit. Don\'t use this unless you \n are a mad scientist. If you are a developer, just\n use this option as part of the module. \n -r, --raw Outputs a dump of the raw JSON data. \n -h, --help Displays this help. \n -v, --version Displays version information. \n\nExamples:\n git-stats # Default behavior (stats in the last year)\n git-stats -l # Light mode\n git-stats -s \'1 January 2012\' # All the commits from 1 January 2012 to now\n git-stats -s \'1 January 2012\' -u \'31 December 2012\' # All the commits from 2012\n\nYour commit history is kept in ~/.git-stats by default. You can create ~/.git-stats-config.json to specify different defaults.\n\nDocumentation can be found at https://github.com/IonicaBizau/git-stats\n```\n\n## Usage\n### Importing and deleting commits\n\nI know it\'s not nice to start your git commit calendar from scratch. That\'s why I created [`git-stats-importer`](https://github.com/IonicaBizau/git-stats-importer)a tool which imports or deletes the commits from selected repositories.\n\nCheck it out here: https://github.com/IonicaBizau/git-stats-importer\n\nThe usage is simple:\n\n```sh\n# Install the importer tool\n$ npm install -g git-stats-importer\n\n# Go to the repository you want to import\n$ cd path/to/my-repository\n\n# Import the commits\n$ git-stats-importer\n\n# ...or delete them if that\'s a dummy repository\
// maintainers: [ { name: 'ionicabizau', email: 'bizauionica@yahoo.com' } ],
// time: {...},
// ...
// users: { bret: true, despairblue: true, program247365: true },
// _attachments: {} }
});
packageJson("IonicaBizau/git-stats", function (err, data) {
console.log(err || data);
// { name: 'git-stats',
// version: '2.9.2',
// description: 'Local git statistics including GitHub-like contributions calendars.',
// main: 'lib/index.js',
// bin: { 'git-stats': './bin/git-stats' },
// ...
// _id: 'git-stats@2.9.2' }
});
packageJson("git@github.com:IonicaBizau/git-stats.git", function (err, data) {
console.log(err || data);
// { name: 'git-stats',
// version: '2.9.2',
// description: 'Local git statistics including GitHub-like contributions calendars.',
// ...
// _id: 'git-stats@2.9.2' }
});
packageJson("git@github.com:IonicaBizau/git-stats.git", "2.7.0", function (err, data) {
console.log(err || data.version);
// "2.7.0"
});
```
## :memo: Documentation
### `packageJson(input, version, callback)`
Fetches the `package.json` file contents from `npm` or a git repository.
#### Params
- **String** `input`: The package `npm` name or git url. The git urls are friendly, being parsed by [`git-source`](https://github.com/IonicaBizau/git-source).
- **String** `version`: The `npm` package version or a git sha/tag/branch/etc.
- **Function** `callback`: The callback function.
## :yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].
## :scroll: License
[MIT][license] © [Ionică Bizău][website]
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png
[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(http%3A%2F%2Fionicabizau.net)&year=2016#license-mit
[website]: http://ionicabizau.net
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md