From cc4b37d5e7369bb3df7601c53dc164191fdd6b17 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sat, 22 Jan 2022 21:14:26 -0500 Subject: [PATCH] chore: document new Release in readme --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a7b0b63..d80a3fa 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,59 @@ A typical APT repository advertises a release file and packages file, both of wh ### Installation `npm install --save apt-parser`
-### Basic Usage +### Release Parsing Here's an example for getting the information out of a Release file:
```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.
+For more information on the Debian Repository Format, see https://wiki.debian.org/DebianRepository/Format.
+ +```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*
Here's an example for getting the information out of a Packages file:
```ts import axios from 'axios';