UNPKG

@capgo/cli

Version:
66 lines (65 loc) 3.56 kB
export declare function readTextIfExists(path: string): string | null; /** Parse android/gradle.properties into a key→value map (ignores comments/blank lines). */ export declare function gradleProperties(projectDir: string): Record<string, string>; /** Count `include ':…'` modules in android/capacitor.settings.gradle (proxy for plugin module count). */ export declare function settingsGradleModuleCount(projectDir: string): number; export declare function appBuildGradle(projectDir: string): string | null; export declare function gradleApplicationId(projectDir: string): string | null; export interface EffectiveApplicationId { /** The resolved package name, or null when the base id is unknown. */ packageName: string | null; /** * True when a productFlavors block exists (or a flavor was requested) but the * effective applicationId for that flavor cannot be resolved unambiguously * from static parsing. Callers should NOT emit a blocking error in this case. */ ambiguous: boolean; } /** * Resolve the package name the build will actually upload, accounting for the * active product flavor's `applicationId` override / `applicationIdSuffix` on * top of defaultConfig. A store-access probe must target this final package, * not the unflavored defaultConfig id, or it 404s on a valid flavored upload. * * Returns `ambiguous: true` (and a best-effort packageName) when a flavored * build cannot be statically resolved, so the caller can downgrade rather than * emit a blocking error. */ export declare function resolveEffectiveApplicationId(projectDir: string, flavor?: string): EffectiveApplicationId; declare const SDK_DIMENSIONS: { readonly minSdk: "minSdkVersion"; readonly targetSdk: "targetSdkVersion"; readonly compileSdk: "compileSdkVersion"; }; export type SdkDimension = keyof typeof SDK_DIMENSIONS; /** * Remove block and line (`//`) comments from a Gradle source. Required because * gradleApplicationId / resolveSdk must not match commented declarations. * Conservative: line stripping cuts from `//` to end-of-line, so a `//` inside * a string literal trims that line's tail - acceptable for the presence/value * scans these helpers perform. */ export declare function stripGradleComments(source: string): string; /** * Parse android/variables.gradle `ext { name = <int> }` into a key->number map. * The canonical Capacitor template puts SDK literals here and app/build.gradle * only references rootProject.ext.*. Non-integer values are skipped. */ export declare function variablesGradle(projectDir: string): Record<string, number>; /** * Resolve an SDK dimension: literal in comment-stripped app/build.gradle first, * then android/variables.gradle, then the manifest <uses-sdk>. Returns null * (skip the dimension) when unresolved so SDK checks agree on one source of * truth. * * The gradle literal scan excises the `productFlavors` block first. A flavor * routinely pins a per-flavor SDK literal (e.g. a legacy/wear flavor with a * lower minSdk) that the active build does not necessarily apply; reading the * first literal anywhere in the file would let that flavor value drive a false * blocking SDK error (minSdkCapacitor / targetSdkPlay). Excising productFlavors * keeps the android-level `compileSdkVersion` and the defaultConfig * `minSdkVersion`/`targetSdkVersion` (the values the build actually applies) * while ignoring per-flavor overrides. */ export declare function resolveSdk(projectDir: string, dim: SdkDimension): number | null; export {};