Validate Fire TV package names#583
Conversation
Greptile SummaryThis PR introduces an
Confidence Score: 4/5Safe to merge; the validation logic is correct and the tests cover the stated rejection cases. The regex and No files require special attention; both changed files are straightforward. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B[buildPlan]
B --> C{requirePackageName}
C -- invalid --> D[throw Error 'packageName must be a valid Android ID']
C -- valid trimmed name --> E[artifactPath]
E --> F{requirePackageName again}
F -- valid --> G[return apkPath or join outDir/firetv/name.apk]
G --> H[assemble plan object]
H --> I{dryRun?}
I -- yes --> J[return dry-run meta with plan.packageName]
I -- no --> K[writeFile plan JSON / submit to Amazon]
Reviews (1): Last reviewed commit: "Validate Fire TV package names" | Re-trigger Greptile |
| function artifactPath(ctx: { outDir: string }, config: Config): string { | ||
| return config.apkPath ?? join(ctx.outDir, 'firetv', `${config.packageName}.apk`); | ||
| const packageName = requirePackageName(config); | ||
| return config.apkPath ?? join(ctx.outDir, 'firetv', `${packageName}.apk`); | ||
| } | ||
|
|
||
| function targeting(config: Config): NonNullable<Config['deviceTargeting']> { | ||
| return config.deviceTargeting ?? 'firetv-only'; | ||
| } | ||
|
|
||
| function buildPlan(ctx: { outDir: string; version: string; channel: string }, config: Config) { | ||
| const packageName = requirePackageName(config); | ||
| const artifact = artifactPath(ctx, config); |
There was a problem hiding this comment.
requirePackageName is called twice for every buildPlan invocation: once on line 33, and again inside artifactPath on line 34. The validated name from the first call is already available, so passing it through to artifactPath would eliminate the redundant validation and make the data-flow explicit.
| function artifactPath(ctx: { outDir: string }, config: Config): string { | |
| return config.apkPath ?? join(ctx.outDir, 'firetv', `${config.packageName}.apk`); | |
| const packageName = requirePackageName(config); | |
| return config.apkPath ?? join(ctx.outDir, 'firetv', `${packageName}.apk`); | |
| } | |
| function targeting(config: Config): NonNullable<Config['deviceTargeting']> { | |
| return config.deviceTargeting ?? 'firetv-only'; | |
| } | |
| function buildPlan(ctx: { outDir: string; version: string; channel: string }, config: Config) { | |
| const packageName = requirePackageName(config); | |
| const artifact = artifactPath(ctx, config); | |
| function artifactPath(ctx: { outDir: string }, packageName: string, config: Pick<Config, 'apkPath'>): string { | |
| return config.apkPath ?? join(ctx.outDir, 'firetv', `${packageName}.apk`); | |
| } | |
| function targeting(config: Config): NonNullable<Config['deviceTargeting']> { | |
| return config.deviceTargeting ?? 'firetv-only'; | |
| } | |
| function buildPlan(ctx: { outDir: string; version: string; channel: string }, config: Config) { | |
| const packageName = requirePackageName(config); | |
| const artifact = artifactPath(ctx, packageName, config); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Fixes #582.
Changes:
Validation: