UNPKG

@wellsite/version-generator

Version:
164 lines (163 loc) 5.86 kB
/** * iOS build number generation utilities * Handles interaction with App Store Connect API to get and increment build numbers */ /** * Options for iOS build number generation */ export interface IosVersionOptions { /** * Whether iOS build number generation is enabled */ enabled?: boolean; /** * App Store Connect API Key ID */ apiKeyId?: string; /** * App Store Connect API Issuer ID */ apiIssuerId?: string; /** * App Store Connect API Private Key * Can be a string or base64-encoded string */ apiPrivateKey?: string; /** * Bundle ID of the iOS app (e.g., com.example.app) */ bundleId?: string; /** * Current app release version (CFBundleShortVersionString) * This is the version string in format major.minor.patch */ appReleaseVersion: string; /** * Git commit hash to encode in the build number */ commitHash?: string; } /** * Version information returned from App Store Connect */ export interface AppStoreVersionInfo { highestBuildNumber: number; } /** * iOS build number information */ export interface IosBuildNumberInfo { /** * The build number, incremented for each build with the same short version string */ buildNumber: number; /** * The encoded commit hash (if included) */ encodedCommitHash?: number; /** * The composed build version string in format "buildNumber.encodedCommitHash" * or just "buildNumber" if encodedCommitHash is not included */ buildVersion: string; } /** * Interface for iOS executor with all required dependencies */ export interface IosExecutor { /** * Generates a JWT token for App Store Connect API authentication * * @param keyId - The App Store Connect API Key ID * @param issuerId - The App Store Connect API Issuer ID * @param privateKey - The App Store Connect API Private Key * @returns The JWT token */ generateToken(keyId: string, issuerId: string, privateKey: string): string; /** * Queries the App Store Connect API for builds * * @param bundleId - The bundle ID of the iOS app * @param appReleaseVersion - The app release version (CFBundleShortVersionString) * @param token - The JWT token for authentication * @returns Promise resolving to the builds data */ queryApi(bundleId: string, appReleaseVersion: string, token: string): Promise<any>; } /** * Function type for getting iOS build number */ export type IosVersionProvider = (options: IosVersionOptions) => Promise<number>; /** * Gets detailed iOS build number information * * @param options - Options for getting the iOS build number * @param versionInfoProvider - Function to get version info from App Store Connect * @param jwtGenerator - JWT token generator * @param apiClient - App Store Connect API client * @param buildProcessor - Build data processor * @returns Promise resolving to the iOS build number info */ /** * Default implementation of IosExecutor */ export declare class DefaultIosExecutor implements IosExecutor { /** * Generates a JWT token for App Store Connect API authentication * * @param keyId - The App Store Connect API Key ID * @param issuerId - The App Store Connect API Issuer ID * @param privateKey - The App Store Connect API Private Key * @returns The JWT token */ generateToken(keyId: string, issuerId: string, privateKey: string): string; /** * Queries the App Store Connect API for builds * * @param bundleId - The bundle ID of the iOS app * @param appReleaseVersion - The app release version (CFBundleShortVersionString) * @param token - The JWT token for authentication * @returns Promise resolving to the builds data */ queryApi(bundleId: string, appReleaseVersion: string, token: string): Promise<any>; /** * Makes a request to the App Store Connect API * * @param url - The API URL to request * @param token - The JWT token for authentication * @returns Promise resolving to the API response data */ private makeApiRequest; } export declare function getIosBuildNumberInfo(options: IosVersionOptions, executor?: IosExecutor): Promise<IosBuildNumberInfo>; /** * Encodes a commit hash into an integer for use in iOS build numbers * * @param commitHash - The commit hash to encode * @returns The encoded commit hash as an integer */ export declare function encodeCommitHash(commitHash: string): number; /** * Gets the iOS build number with dependency injection for testing * * @param options - Options for getting the iOS build number * @param versionInfoProvider - Function to get version info from App Store Connect * @returns Promise resolving to the next iOS build number to use */ /** * Composes an iOS build version object from a build number and optional commit hash * * @param buildNumber - The build number * @param commitHash - Optional commit hash to encode in the build version * @returns The composed iOS build number info */ export declare function composeIosBuildVersion(buildNumber: number, commitHash?: string): IosBuildNumberInfo; /** * Processes the builds data to find the highest build number * * @param builds - The builds data from the App Store Connect API * @param appReleaseVersion - The app release version (CFBundleShortVersionString) * @returns The version info with the highest build number */ export declare function processBuilds(builds: any, appReleaseVersion: string): AppStoreVersionInfo | undefined; export declare function getAppStoreVersionInfo(bundleId: string, appReleaseVersion: string, apiKeyId: string, apiIssuerId: string, apiPrivateKey: string, executor?: IosExecutor): Promise<AppStoreVersionInfo | undefined>;