Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: minAndroidVersion option #17

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ APKMirrorDownloader.download({ org: "google-inc", repo: "youtube" });

- arch: Optional. The architecture of the application. For example, arm64-v8a, armeabi-v7a, etc.
- dpi: Optional. The screen density of the application. For example, 240dpi, 320dpi, 480dpi, etc.
- minAndroidVersion: Optional. The minimum Android version that the application is compatible with.
- outDir: Optional. The output directory where the application files will be stored.

🟣 **AppOptions Interface**
Expand All @@ -57,6 +58,7 @@ APKMirrorDownloader.download({ org: "google-inc", repo: "youtube" });
- arch: Optional, DEFAULT: "universal". The architecture of the application. For example, arm64-v8a, armeabi-v7a, etc.
- dpi: Optional, DEFAULT: "nodpi". The screen density of the application. For example, 240dpi, 320dpi, 480dpi, etc.
- type: Optional, DEFAULT: "apk". The type of the application. Supported types are "apk" and "bundle".
- minAndroidVersion: Optional. The minimum Android version that the application is compatible with.
- outFile: Optional. The name of the output file where the application will be saved.
- outDir: Optional. The output directory where the application files will be stored.

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ APKMirrorDownloader.download({ org: "google-inc", repo: "youtube" });
🟠 **APKMDOptions Interface**
- arch: Optional. The architecture of the application. For example, arm64-v8a, armeabi-v7a, etc.
- dpi: Optional. The screen density of the application. For example, 240dpi, 320dpi, 480dpi, etc.
- minAndroidVersion: Optional. The minimum Android version that the application is compatible with.
- outDir: Optional. The output directory where the application files will be stored.

🟣 **AppOptions Interface**
- version: Optional. The version of the application.
- arch: Optional, DEFAULT: "universal". The architecture of the application. For example, arm64-v8a, armeabi-v7a, etc.
- dpi: Optional, DEFAULT: "nodpi". The screen density of the application. For example, 240dpi, 320dpi, 480dpi, etc.
- type: Optional, DEFAULT: "apk". The type of the application. Supported types are "apk" and "bundle".
- minAndroidVersion: Optional. The minimum Android version that the application is compatible with.
- outFile: Optional. The name of the output file where the application will be saved.
- outDir: Optional. The output directory where the application files will be stored.

Expand Down
6 changes: 6 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ yargs(process.argv.slice(2))
alias: "t",
choices: ["apk", "bundle"],
})
.option("minandroidversion", {
type: "string",
describe: "Minimum Android version",
alias: "m",
})
.option("outfile", {
type: "string",
describe: "Output file",
Expand All @@ -112,6 +117,7 @@ yargs(process.argv.slice(2))
arch: argv.arch,
dpi: argv.dpi,
type: argv.type as AppOptions["type"],
minAndroidVersion: argv.minandroidversion,
outFile: argv.outfile,
outDir: argv.outdir,
};
Expand Down
9 changes: 9 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
export type APKMDOptions = {
arch?: AppOptions["arch"];
dpi?: AppOptions["dpi"];
minAndroidVersion?: AppOptions["minAndroidVersion"];
outDir?: AppOptions["outDir"];
};

Expand Down Expand Up @@ -101,6 +102,14 @@ export class APKMirrorDownloader {
variants = variants.filter(v => v.dpi === o.dpi);
}

// filter by minAndroidVersion
if (o.minAndroidVersion) {
variants = variants.filter(
v =>
parseFloat(v.minAndroidVersion) <= parseFloat(o.minAndroidVersion!),
);
}

// filter by type
variants = variants.filter(v => v.type === o.type);

Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type AppOptions = {
arch?: string;
dpi?: string;
type?: AppType;
minAndroidVersion?: string;
outFile?: string;
outDir?: string;
};