Skip to content

Commit

Permalink
chore: document new Release in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tale committed Jan 23, 2022
1 parent 4e48eec commit cc4b37d
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,59 @@ A typical APT repository advertises a release file and packages file, both of wh
### Installation
`npm install --save apt-parser`<br>

### Basic Usage
### Release Parsing
Here's an example for getting the information out of a Release file:<br>
```ts
import axios from 'axios';
import { parseRelease } from 'apt-parser';
import { Release } from 'apt-parser';

const { data } = await axios.get('http://archive.ubuntu.com/ubuntu/dists/jammy/Release');
const releaseMap = parseRelease(data);
const release = new Release(data);

console.log(releaseMap.get('Origin')); // => Ubuntu
console.log(releaseMap.get('Version')); // => 22.04
console.log(release.origin); // => Ubuntu
console.log(release.version); // => 22.04
console.log(releaseMap.get('InvalidKey')); // => null
```

A full Release object has the following properties attached on it, all of which map to documented APT fields.<br>
For more information on the Debian Repository Format, see https://wiki.debian.org/DebianRepository/Format.<br>

```ts
interface Release {
architectures: string[] // => Architectures
noSupportForArchitectureAll?: boolean // => No-Support-For-Architecture-All
description?: string // => Description
origin?: string // => Origin
label?: string // => Label
suite: string // => Suite
codename: string // => Codename
version?: string // => Version
date?: Date // => Date
validUntil?: Date // => Valid-Until
components: string[] // => Components
md5?: ReleaseHash[] // => MD5Sum
sha1?: ReleaseHash[] // => SHA1
sha256?: ReleaseHash[] // => SHA256
sha512?: ReleaseHash[] // => SHA512
notAutomatic?: boolean // => NotAutomatic
butAutomaticUpgrades?: boolean // => ButAutomaticUpgrades
acquireByHash?: boolean // => Acquire-By-Hash
signedBy?: string[] // => Signed-By
packagesRequireAuthorization: boolean // => Packages-Require-Authorization

get(key: string): string | undefined // => Retrieve a raw field value not assigned a strict type
get fieldCount(): number // => Get total number of fields in the Release contents
}

type ReleaseHash = {
filename: string
hash: string
size: number
}
```
### Packages Parsing
*Package parsing will have strictly defined types soon*<br>
Here's an example for getting the information out of a Packages file:<br>
```ts
import axios from 'axios';
Expand Down

0 comments on commit cc4b37d

Please sign in to comment.