-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
79 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,45 @@ | ||
# packageurl-js | ||
|
||
### Installing: | ||
### Installing | ||
|
||
To install `packageurl-js` in your project, simply run: | ||
``` | ||
```bash | ||
npm install packageurl-js | ||
``` | ||
|
||
This command will download the `packageurl-js` npm package for use in your application. | ||
|
||
### Local Development: | ||
### Local Development | ||
|
||
Clone the `packageurl-js` repo and `cd` into the directory. | ||
|
||
Then run: | ||
``` | ||
```bash | ||
npm install | ||
``` | ||
|
||
### Testing | ||
|
||
To run the test suite: | ||
``` | ||
```bash | ||
npm test | ||
``` | ||
|
||
### Usage Examples | ||
|
||
#### Import ES6 Module | ||
#### Importing | ||
|
||
``` | ||
As an ES6 module | ||
```js | ||
import { PackageURL } from 'packageurl-js' | ||
``` | ||
|
||
#### Import CommonJs Module | ||
|
||
``` | ||
As a CommonJS module | ||
```js | ||
const { PackageURL } = require('packageurl-js') | ||
``` | ||
|
||
#### Parsing a string | ||
#### Parsing | ||
|
||
```js | ||
const purlStr = 'pkg:maven/org.springframework.integration/[email protected]' | ||
|
@@ -48,12 +51,12 @@ will both log | |
|
||
``` | ||
PackageURL { | ||
type: 'maven', | ||
name: 'spring-integration-jms', | ||
namespace: 'org.springframework.integration', | ||
version: '5.5.5', | ||
qualifiers: undefined, | ||
subpath: undefined | ||
type: 'maven', | ||
name: 'spring-integration-jms', | ||
namespace: 'org.springframework.integration', | ||
version: '5.5.5', | ||
qualifiers: undefined, | ||
subpath: undefined | ||
} | ||
``` | ||
|
||
|
@@ -69,7 +72,7 @@ const pkg = new PackageURL( | |
console.log(pkg.toString()) | ||
``` | ||
|
||
will log | ||
=> | ||
|
||
``` | ||
pkg:maven/org.springframework.integration/[email protected] | ||
|
@@ -85,8 +88,65 @@ try { | |
} | ||
``` | ||
|
||
will log | ||
=> | ||
|
||
``` | ||
Invalid purl: missing required "pkg" scheme component | ||
``` | ||
|
||
#### Helper Objects | ||
|
||
Helpers for encoding, normalizing, and validating purl components and types can | ||
be imported directly from the module or found on the PackageURL class as static | ||
properties. | ||
```js | ||
import { | ||
PackageURL, | ||
PurlComponent, | ||
PurlType | ||
} from 'packageurl-js' | ||
|
||
PurlComponent === PackageURL.Component // => true | ||
PurlType === PackageURL.Type // => true | ||
``` | ||
|
||
#### PurlComponent | ||
|
||
Contains the following properties each with their own `encode`, `normalize`, | ||
and `validate` methods, e.g. `PurlComponent.name.validate(nameStr)`: | ||
- type | ||
- namespace | ||
- name | ||
- version | ||
- qualifiers | ||
- qualifierKey | ||
- qualifierValue | ||
- subpath | ||
|
||
#### PurlType | ||
|
||
Contains the following properties each with their own `normalize`, and `validate` | ||
methods, e.g. `PurlType.npm.validate(purlObj)`: | ||
- alpm | ||
- apk | ||
- bitbucket | ||
- bitnami | ||
- composer | ||
- conan | ||
- cran | ||
- deb | ||
- github | ||
- gitlab | ||
- golang | ||
- hex | ||
- huggingface | ||
- luarocks | ||
- maven | ||
- mlflow | ||
- npm | ||
- oci | ||
- pub | ||
- pypi | ||
- qpkg | ||
- rpm | ||
- swift |