All files identity.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20            2x     2x     7x       6x      
// Made with ❤️ by [Vibey](https://the-vibey-project.github.io/vibey/), Developed by [Adam Matthew Steinberger](https://vibewithadam.matthewsteinberger.com/) ([@adammatthewsteinberger](https://github.com/adammatthewsteinberger/)).
/** Stable and nightly, side by side; stable by default. Declared by `interfaces/identity-interface.ts`. */
import IDENTITIES from './identities.json';
import type { AppIdentitiesInterface, AppIdentity, Channel } from './interfaces/identity-interface';
 
export class AppIdentities implements AppIdentitiesInterface {
  readonly defaultChannel: Channel = 'stable';
 
  /** One JSON file, so `app.config.ts` (which cannot import TypeScript) reads the same identities. */
  private static readonly IDENTITIES = IDENTITIES as Readonly<Record<Channel, AppIdentity>>;
 
  channel(variant: string | undefined): Channel {
    return variant?.trim().toLowerCase() === 'nightly' ? 'nightly' : this.defaultChannel;
  }
 
  identity(channel: Channel): AppIdentity {
    return AppIdentities.IDENTITIES[channel];
  }
}