UNPKG

@wellsite/version-generator

Version:
155 lines (154 loc) 5.43 kB
/** * Android version code generation utilities * Handles interaction with Google Play Developer API to get and increment version codes */ /** * Default increment to add to version code when major version changes */ export declare const DEFAULT_MAJOR_VERSION_INCREMENT = 10; /** * Raw track data returned from the Play Store API */ export interface PlayStoreTrackData { /** * Track name */ track?: string; /** * Releases in the track */ releases?: any[]; } /** * Interface for Android executor to handle Play Store API interactions * This allows for easier mocking in tests */ export interface AndroidExecutor { /** * Query a specific track from the Play Store API * * @param packageName - The package name of the Android app * @param credentials - The parsed service account credentials * @param track - The track to query * @returns Promise resolving to the track data */ queryTrack(packageName: string, credentials: any, track: string): Promise<PlayStoreTrackData | undefined>; /** * Query all tracks from the Play Store API * * @param packageName - The package name of the Android app * @param credentials - The parsed service account credentials * @returns Promise resolving to an array of track data */ queryAllTracks(packageName: string, credentials: any): Promise<PlayStoreTrackData[]>; } /** * Options for Android version code generation */ export interface AndroidVersionOptions { /** * Whether Android version code generation is enabled */ enabled?: boolean; /** * Package name of the Android app */ packageName?: string; /** * Service account key JSON for Google Play API authentication * Can be either a JSON string or a base64-encoded JSON string */ serviceAccountKey?: string; /** * Track to check for version codes (if not specified, checks all tracks) */ track?: string; /** * Increment to add to version code when major version changes * @default 10 */ majorVersionIncrement?: number; /** * Current major version from app version */ currentMajorVersion: number; } /** * Version information returned from Google Play */ export interface PlayStoreVersionInfo { /** * The highest version code found */ highestVersionCode: number; /** * The major version associated with the highest version code */ majorVersion: number; } /** * Default implementation of AndroidExecutor */ export declare class DefaultAndroidExecutor implements AndroidExecutor { /** * Create an authenticated Google Play API client * * @param credentials - The parsed service account credentials * @returns The authenticated API client */ private createApiClient; /** * Query a specific track from the Play Store API * * @param packageName - The package name of the Android app * @param credentials - The parsed service account credentials * @param track - The track to query * @returns Promise resolving to the track data */ queryTrack(packageName: string, credentials: any, track: string): Promise<PlayStoreTrackData | undefined>; /** * Query all tracks from the Play Store API * * @param packageName - The package name of the Android app * @param credentials - The parsed service account credentials * @returns Promise resolving to an array of track data */ queryAllTracks(packageName: string, credentials: any): Promise<PlayStoreTrackData[]>; } /** * Gets the Android version code from Google Play API * * @param options - Options for getting the Android version code * @param executor - The Android executor to use (optional) * @returns Promise resolving to the next Android version code to use */ export declare function getAndroidVersionCode(options: AndroidVersionOptions, executor?: AndroidExecutor): Promise<number>; /** * Helper function to process releases and find the highest version code * * @param releases - Array of releases to process * @param currentHighestVersionCode - Current highest version code found * @param currentMajorVersion - Current major version found * @returns Object containing the highest version code and associated major version */ export declare function processReleases(releases: any[], currentHighestVersionCode?: number, currentMajorVersion?: number): { highestVersionCode: number; majorVersion: number; }; /** * Gets the version info from the Play Store * * @param packageName - The package name of the Android app * @param serviceAccountKey - The service account key for authentication * @param track - The track to get the version info from (optional) * @param executor - The Android executor to use (optional) * @returns Promise resolving to the version info */ export declare function getPlayStoreVersionInfo(packageName: string, serviceAccountKey: string, track?: string, executor?: AndroidExecutor): Promise<PlayStoreVersionInfo | undefined>; /** * Process track data to find the highest version code and associated major version * * @param trackData - Array of track data to process * @returns The version info with highest version code and major version */ export declare function processTrackData(trackData: PlayStoreTrackData[]): PlayStoreVersionInfo | undefined;