5.0.0 • Published 3 years ago

get-pkg-repo v5.0.0

Weekly downloads
1,558,640
License
MIT
Repository
github
Last release
3 years ago

get-pkg-repo

Get repository SCM platform, domain, user, and project information from package.json file contents.

Extracts information from the repository field contained in the content of a package.json file using @hutson/parse-repository-url and hosted-git-info.

Table of Contents

Features

  • Return browse function that returns URL usable in a browser. (Similar to hosted-git-info)
  • Return domain property containing the fully qualified domain name and port.
  • Return project property.
  • Return type property indicating the SCM host, such as github or gitlab.
  • Return user property.

*Note: Returns null for any property where the information could not be extracted from the repository URL.

Installation

To install the get-pkg-repo tool please run the following command:

yarn [global] add [--dev] get-pkg-repo

Usage

There are two ways to use get-pkg-repo, either as a CLI tool, or programmatically.

Programmatically

Package data must be passed as an object to get-pkg-repo function. If the contents of the package.json are a string, please pass it through JSON.parse first.

const getPkgRepo = require(`get-pkg-repo`);

/* Assume the `package.json` file contains the following:
{
  "repository": {
    "url": `https://github.com/conventional-changelog/get-pkg-repo`
  }
}
*/
fs.readFile(`package.json`, (err, packageData) => {
  if (err) {
    ...
  }

  // {domain: `github.com`, project: `get-pkg-repo`, type: `github`, user: `conventional-changelog`}
  const repository = getPkgRepo(JSON.parse(packageData));

  repository.browse(); // https://github.com/conventional-changelog/get-pkg-repo
});

CLI Tool

After you've installed get-pkg-repo, you can call the tool based on whether you installed it globally or locally:

Globally

get-pkg-repo package.json

Locally

$(yarn bin)/get-pkg-repo package.json
$ get-pkg-repo package.json

{
  domain: `github.com`,
  project: `get-pkg-repo`,
  type: `github`,
  user: `conventional-changelog`
}

The contents of the package.json can also be piped to get-pkg-repo:

$ cat package.json | get-pkg-repo

{
  domain: `github.com`,
  project: `get-pkg-repo`,
  type: `github`,
  user: `conventional-changelog`
}

Debugging

To assist users of get-pkg-repo with debugging the behavior of this module we use the debug utility package to print information about the publish process to the console. To enable debug message printing, the environment variable DEBUG, which is the variable used by the debug package, must be set to a value configured by the package containing the debug messages to be printed.

To print debug messages on a unix system set the environment variable DEBUG with the name of this package prior to executing get-pkg-repo:

DEBUG=get-pkg-repo get-pkg-repo

On the Windows command line you may do:

set DEBUG=get-pkg-repo
get-pkg-repo

Node Support Policy

We only support Long-Term Support versions of Node.

We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.

It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.

As each Node LTS version reaches its end-of-life we will remove that version from the node engines property of our package's package.json file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.

We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called current.

JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our node engines property. If you encounter issues installing this package, please report the issue to your package manager.

Contributing

Please read our contributing guide on how you can help improve this project.

@yattho/gatsby-theme-rigituseasy-select-rnreact-native-bluetooth2killi8n-react-native-fast-imageairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112@ntt_app/react-native-custom-notificationreact-native-covid-sdk@jttechnic/interpreterreact-native-printer-brothersreact-native-shekhar-bridge-testcogoportutils@oiti/documentoscopy-react-nativequoc-test@infinitebrahmanuniverse/nolb-get-pluminos-ui-core@everything-registry/sub-chunk-1752jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgreact-native-jawwy_samplegriffin-ui-librarytamia-changelogtailwind-vector-effecttest-library-123test-haptik-libwinx-form-winxwifi_configuration_packagern-tm-notifyrn-currency-formatterrn-counter-demorn-session-multiplier-demorn_unique_device_idrnttlocksame-authorschematics-readmereactnativelyrn-check-btnrn-circular-chartroc-plugin-reporn-adyen-dropinteanessstatic-docreact-native-wtfreact-native-version-appreact-native-withframework-checksemantic-release-githubsemantic-release-github-notifiersemantic-release-github-releasersemantic-release-gitlabsemantic-release-gitlab-notifiersemantic-release-gitlab-releasertest-zeo-collectvision-camera-plugin-scan-facesvision-camera-base64-resizedvcloudcam-playkit-js-hlsvantiq-reactvue-dev-clonejawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwytest_lib_module_aarquickcapture_react_nativesushi-sdk-ftmrn-agora-ios-mzzzxxxyyy321123miracle-webpack-tree-shakingjesh-calculationjamuskalimjrennsoh88-react-native-scroll-indicatormpd-parser-1iiif-manifest-editorkhaled-salem-custom-componentsjordy-frijters-test-liblazy-bee-uil2forlernagh-monoproject-climanual-git-changelogluojia-cli-devreact-native-rom-componentsopen-repo-cliori-bot-react-nativeplaykit-js-hls-sondqnpm_one_12_34_1_npm_one_1_2_3npm_one_2_2npm_qwertypnm-yph-react-native-custom-componentspayutestingraact-native-arunramya151react-native-bluetooth-device-detectreact-native-build-vesion-getter
5.0.0

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.0

6 years ago

2.0.0

7 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.1.0

9 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago