diff --git a/npmextra.json b/npmextra.json index 72e7bba..1974ce1 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,12 +9,22 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartnpm", - "description": "interface with npm to retrieve package information", + "description": "A library to interface with npm for retrieving package information and manipulation.", "npmPackagename": "@push.rocks/smartnpm", - "license": "MIT" + "license": "MIT", + "keywords": [ + "npm", + "package", + "information", + "registry", + "search", + "metadata", + "version", + "dependencies" + ] } }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 356f340..b734846 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartnpm", "version": "2.0.4", "private": false, - "description": "interface with npm to retrieve package information", + "description": "A library to interface with npm for retrieving package information and manipulation.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -46,5 +46,15 @@ ], "browserslist": [ "last 1 chrome versions" + ], + "keywords": [ + "npm", + "package", + "information", + "registry", + "search", + "metadata", + "version", + "dependencies" ] -} +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 9a623a0..542669a 100644 --- a/readme.md +++ b/readme.md @@ -1,37 +1,109 @@ # @push.rocks/smartnpm interface with npm to retrieve package information -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartnpm) -* [gitlab.com (source)](https://gitlab.com/push.rocks/smartnpm) -* [github.com (source mirror)](https://github.com/push.rocks/smartnpm) -* [docs (typedoc)](https://push.rocks.gitlab.io/smartnpm/) - -## Status for master - -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartnpm/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartnpm/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartnpm)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartnpm)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartnpm)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartnpm)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartnpm)](https://lossless.cloud) +## Install +To install `@push.rocks/smartnpm`, open your terminal and run the following command: +```sh +npm install @push.rocks/smartnpm --save +``` +This will add `@push.rocks/smartnpm` as a dependency to your project and you're ready to start using it. ## Usage +To use `@push.rocks/smartnpm` in your project, you first need to import it in your TypeScript files. `@push.rocks/smartnpm` provides a powerful interface to interact with npm to retrieve package information, handle package downloads, and more. Below are examples showcasing how to leverage some of its features in real-world scenarios. -Use TypeScript for best in class instellisense. +### Initialize the NpmRegistry +Before you can retrieve any package information or perform actions such as downloading packages, you need to create an instance of `NpmRegistry`. This acts as your starting point. -## Contribution +```typescript +import { NpmRegistry } from '@push.rocks/smartnpm'; -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +const npmRegistry = new NpmRegistry(); +``` -For further information read the linked docs at the top of this readme. +Optionally, you can provide a custom npm registry URL if you're not using the default npm registry: -## Legal -> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +const customRegistry = new NpmRegistry({ + npmRegistryUrl: 'https://custom.registry.url' +}); +``` + +### Retrieve Package Information +`@push.rocks/smartnpm` allows you to easily get detailed information about a package, including its versions, dist tags, and metadata. Here's how you can get information about a specific package: + +```typescript +async function getPackageInfo() { + const packageName = 'your-package-name'; + const packageInfo = await npmRegistry.getPackageInfo(packageName); + console.log(packageInfo); +} + +getPackageInfo(); +``` + +### Search for Packages +You can search for packages using a variety of filters such as keywords, author, maintainer, etc. Here's an example of searching for packages with specific criteria: + +```typescript +async function searchPackages() { + const searchResults = await npmRegistry.searchOnNpm({ + keywords: ['webpack-plugin'], + author: 'webpack' + }); + console.log(searchResults); +} + +searchPackages(); +``` + +### Downloading Packages +`@push.rocks/smartnpm` provides an easy way to download npm packages and extract them to a specific directory. This could be useful for creating tools that need to programmatically handle packages. + +```typescript +async function downloadPackage() { + const packageName = 'some-package'; + const targetDirectory = './path/to/targetDir'; + + await npmRegistry.savePackageToDisk(packageName, targetDirectory); + console.log(`${packageName} has been downloaded to ${targetDirectory}`); +} + +downloadPackage(); +``` + +### Working with Package Versions and Dist Tags +You can easily retrieve detailed information about specific package versions or distribution tags. This is particularly useful for automation scripts that need to work with specific versions of a package. + +```typescript +async function getPackageVersionDetails() { + const packageName = 'some-package'; + const version = '1.0.0'; // You can also use dist tags like 'latest' + + const packageInfo = await npmRegistry.getPackageInfo(packageName); + const versionInfo = packageInfo.allVersions.find(v => v.version === version); + console.log(versionInfo); +} + +getPackageVersionDetails(); +``` + +These examples only scratch the surface of what you can achieve with `@push.rocks/smartnpm`. By integrating this library, you have a powerful tool at your disposal for interacting with npm in a programmatic way, enabling a wide range of possibilities for automation, CI/CD, and tooling around npm packages. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.