{"id":20614394,"url":"https://github.com/cnstr/apt-parser-ts","last_synced_at":"2025-04-15T07:32:28.882Z","repository":{"id":38047503,"uuid":"448378454","full_name":"cnstr/apt-parser-ts","owner":"cnstr","description":"Parse APT's key-value files and retrieve all the values as a Map","archived":false,"fork":false,"pushed_at":"2023-02-12T21:26:47.000Z","size":2092,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T23:17:49.478Z","etag":null,"topics":["apt","esm","hacktoberfest","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/apt-parser","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnstr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-15T20:01:42.000Z","updated_at":"2024-05-03T09:43:06.000Z","dependencies_parsed_at":"2024-11-16T14:16:48.376Z","dependency_job_id":null,"html_url":"https://github.com/cnstr/apt-parser-ts","commit_stats":{"total_commits":81,"total_committers":1,"mean_commits":81.0,"dds":0.0,"last_synced_commit":"8f844da208bab2c9480b33a1b215f02d8a1b9e24"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnstr","download_url":"https://codeload.github.com/cnstr/apt-parser-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249026902,"owners_count":21200525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apt","esm","hacktoberfest","typescript"],"created_at":"2024-11-16T11:12:37.707Z","updated_at":"2025-04-15T07:32:28.842Z","avatar_url":"https://github.com/cnstr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APT Parser\n\nThis library is capable of parsing files used within the [APT Package Manager](https://en.wikipedia.org/wiki/APT_(software)).\u003cbr\u003e\nA typical APT repository advertises a release file and packages file, utilizing a key-value organization system.\nThis library is able to parse the data and return it as type-safe objects for usage in JavaScript and TypeScript projects.\u003cbr\u003e\n\n### Installation\n\n`npm install --save apt-parser`\u003cbr\u003e\n\n### Release Parsing\n\nHere's an example for getting the information out of a Release file:\u003cbr\u003e\n\n```ts\nimport axios from 'axios';\nimport { Release } from 'apt-parser';\n\nconst { data } = await axios.get('http://archive.ubuntu.com/ubuntu/dists/jammy/Release');\nconst release = new Release(data);\n\nconsole.log(release.origin); // =\u003e Ubuntu\nconsole.log(release.version); // =\u003e 22.04\nconsole.log(release.get('InvalidKey')); // =\u003e null\n```\n\nA full Release object has the following properties attached on it, all of which map to documented APT fields.\u003cbr\u003e\nFor more information on the Debian Repository Format, see \u003chttps://wiki.debian.org/DebianRepository/Format.\u003cbr\u003e\u003e\n\n```ts\ninterface IRelease {\n architectures: string[]               // =\u003e Architectures\n noSupportForArchitectureAll?: boolean // =\u003e No-Support-For-Architecture-All\n description?: string                  // =\u003e Description\n origin?: string                       // =\u003e Origin\n label?: string                        // =\u003e Label\n suite: string                         // =\u003e Suite\n codename: string                      // =\u003e Codename\n version?: string                      // =\u003e Version\n date?: Date                           // =\u003e Date\n validUntil?: Date                     // =\u003e Valid-Until\n components: string[]                  // =\u003e Components\n md5?: ReleaseHash[]                   // =\u003e MD5Sum\n sha1?: ReleaseHash[]                  // =\u003e SHA1\n sha256?: ReleaseHash[]                // =\u003e SHA256\n sha512?: ReleaseHash[]                // =\u003e SHA512\n notAutomatic?: boolean                // =\u003e NotAutomatic\n butAutomaticUpgrades?: boolean        // =\u003e ButAutomaticUpgrades\n acquireByHash?: boolean               // =\u003e Acquire-By-Hash\n signedBy?: string[]                   // =\u003e Signed-By\n packagesRequireAuthorization: boolean // =\u003e Packages-Require-Authorization\n\n get(key: string): string | undefined  // =\u003e Retrieve a raw field value not assigned a strict type\n get fieldCount(): number              // =\u003e Get total number of fields in the Release contents\n}\n\ntype ReleaseHash = {\n filename: string\n hash: string\n size: number\n}\n```\n\n### Binary Control Parsing\n\nHere's an example for getting the information out of a binary control file:\u003cbr\u003e\n\n```ts\nimport { Release } from 'apt-parser';\n\nconst data =\n`\nPackage: com.amywhile.signalreborn\nArchitecture: iphoneos-arm\nDescription: Visualise your nearby cell towers\nDepends: firmware (\u003e= 12.2) | org.swift.libswift\nMaintainer: Amy While \u003csupport@anamy.gay\u003e\nSection: Applications\nVersion: 2.2.1-2\nInstalled-Size: 1536\nCustom-Key: cool-value\n`;\n\nconst control = new BinaryControl(data);\n\nconsole.log(control.version); // =\u003e 2.2.1-2\nconsole.log(control.package); // =\u003e com.amywhile.signalreborn\nconsole.log(control.get('Custom-Key')); // =\u003e cool-value\nconsole.log(control.get('Invalid-Key')); // =\u003e null\n```\n\nA full BinaryControl object has the following properties attached on it, all of which map to documented APT fields.\u003cbr\u003e\nFor more information on the Debian Control Format, see \u003chttps://www.debian.org/doc/debian-policy/ch-controlfields.html.\u003cbr\u003e\u003e\n\n```ts\ninterface IBinaryControl {\n package: string                       // =\u003e Package\n source?: string                       // =\u003e Source\n version: string                       // =\u003e Version\n section?: string                      // =\u003e Section\n priority?: PriorityLevel              // =\u003e Priority\n architecture: string                  // =\u003e Architecture\n essential?: boolean                   // =\u003e Essential\n\n depends?: string[]                    // =\u003e Depends\n preDepends?: string[]                 // =\u003e Pre-Depends\n recommends?: string[]                 // =\u003e Recommends\n suggests?: string[]                   // =\u003e Suggests\n replaces?: string[]                   // =\u003e Replaces\n enhances?: string[]                   // =\u003e Enhances\n breaks?: string[]                     // =\u003e Breaks\n conflicts?: string[]                  // =\u003e Conflicts\n\n installedSize?: number               // =\u003e Installed-Size\n maintainer: string                    // =\u003e Maintainer\n description: string                   // =\u003e Description\n homepage?: string                     // =\u003e Homepage\n builtUsing?: string                   // =\u003e Built-Using\n packageType?: PackageType             // =\u003e Package-Type\n\n get(key: string): string | undefined  // =\u003e Retrieve a raw field value not assigned a strict type\n get fieldCount(): number              // =\u003e Get total number of fields in the control contents\n}\n```\n\n### Packages Parsing\n\nHere's an example for getting the information out of a Packages file:\u003cbr\u003e\n\n```ts\nimport axios from 'axios';\nimport { Packages } from 'apt-parser';\n\nconst { data } = await axios.get('https://repo.chariz.com/Packages');\nconst packages = new Packages(data);\n\nfor (const pkg of packages) {\n console.log(pkg.package); // Package Identifier\n console.log(pkg.get('InvalidKey')); // =\u003e null\n}\n```\n\nA full Packages object has the following properties attached on it, all of which map to documented APT fields.\u003cbr\u003e\nFor more information on the Debian Repository Format, see \u003chttps://wiki.debian.org/DebianRepository/Format.\u003cbr\u003e\u003e\n\n```ts\ninterface IPackage extends IBinaryControl {\n filename: string                      // =\u003e Filename\n size: number                          // =\u003e Size\n md5?: string                          // =\u003e MD5sum\n sha1?: string                         // =\u003e SHA1\n sha256?: string                       // =\u003e SHA256\n sha512?: string                       // =\u003e SHA512\n descriptionMd5?: string               // =\u003e Description-md5\n\n get(key: string): string | undefined  // =\u003e Retrieve a raw field value not assigned a strict type\n get fieldCount(): number              // =\u003e Get total number of fields in the package contents\n}\n\ninterface IPackages extends Array\u003cIPackage\u003e {\n constructor(rawData: string) // Pass in the raw contents of the file\n}\n```\n\n### Skipping Validation\n\nThe parser validates required fields based on the parameters defined by the Debian Team on their documentation pages.\nDisabling this validation is possible, but it is not recommended if you are parsing valid repositories.\n\nDisabling this validation will stop the APT parser from throwing any `MissingRequiredKeyError`s.\nIt is disabled through an option when constructing your parser.\n\n```ts\nimport axios from 'axios';\nimport { Packages } from 'apt-parser';\n\nconst { data } = await axios.get('https://repo.chariz.com/Packages');\nconst packages = new Packages(data, {\n skipValidation: true\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnstr%2Fapt-parser-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnstr%2Fapt-parser-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnstr%2Fapt-parser-ts/lists"}