<commit_before>import lodash from 'lodash';
import semver from 'semver';

import sdkVersion from './sdkVersion';
import { PolyfillMap } from './plugins/polyfill';

export interface BuildTargetDescriptor {
  displayName: string;
  platform: string[];
  resourceFilterTag: string;
  polyfills?: PolyfillMap;
  maxDeviceBundleSize?: number; // in bytes
  minSDKVersion?: string;
}

const baseBuildTargets: { [platform: string]: BuildTargetDescriptor } = {
  higgs: {
    displayName: 'Fitbit Ionic',
    platform: ['30.1.2+'],
    resourceFilterTag: '348x250',
  },
  meson: {
    displayName: 'Fitbit Versa',
    platform: ['32.4.18+'],
    resourceFilterTag: '300x300',
  },
  gemini: {
    displayName: 'Fitbit Versa Lite',
    platform: ['33.1.30+'],
    resourceFilterTag: '300x300',
    minSDKVersion: '3.1.0',
    maxDeviceBundleSize: 3145728,
    polyfills: {
      barometer: 'export var Barometer = undefined; export default Barometer;',
      gyroscope: 'export var Gyroscope = undefined; export default Gyroscope;',
      orientation:
        'export var OrientationSensor = undefined; export default OrientationSensor;',
      'user-activity': `
        export { today, goals, default } from 'user-activity';
        import { today } from 'user-activity';
        Object.defineProperty(today.local, 'elevationGain', {});
      `,
    },
  },
};

let extraBuildTargets: typeof baseBuildTargets | undefined;
try {
  extraBuildTargets = require('@fitbit/sdk-build-targets').default;
} catch {}

export function generateBuildTargets() {
  return lodash.pickBy(
    {
      ...baseBuildTargets,
      ...extraBuildTargets,
    },
    ({ minSDKVersion }) =>
      minSDKVersion === undefined ||
      semver.gte(sdkVersion().format(), minSDKVersion),
  );
}

const buildTargets = generateBuildTargets();<commit_msg>Add Versa 2 build target (#144)<commit_after>import lodash from 'lodash';
import semver from 'semver';

import sdkVersion from './sdkVersion';
import { PolyfillMap } from './plugins/polyfill';

export interface BuildTargetDescriptor {
  displayName: string;
  platform: string[];
  resourceFilterTag: string;
  polyfills?: PolyfillMap;
  maxDeviceBundleSize?: number; // in bytes
  minSDKVersion?: string;
}

const baseBuildTargets: { [platform: string]: BuildTargetDescriptor } = {
  higgs: {
    displayName: 'Fitbit Ionic',
    platform: ['30.1.2+'],
    resourceFilterTag: '348x250',
  },
  meson: {
    displayName: 'Fitbit Versa',
    platform: ['32.4.18+'],
    resourceFilterTag: '300x300',
  },
  gemini: {
    displayName: 'Fitbit Versa Lite',
    platform: ['33.1.30+'],
    resourceFilterTag: '300x300',
    minSDKVersion: '3.1.0',
    maxDeviceBundleSize: 3145728,
    polyfills: {
      barometer: 'export var Barometer = undefined; export default Barometer;',
      gyroscope: 'export var Gyroscope = undefined; export default Gyroscope;',
      orientation:
        'export var OrientationSensor = undefined; export default OrientationSensor;',
      'user-activity': `
        export { today, goals, default } from 'user-activity';
        import { today } from 'user-activity';
        Object.defineProperty(today.local, 'elevationGain', {});
      `,
    },
  },
  mira: {
    displayName: 'Fitbit Versa 2',
    platform: ['68.9.12+'],
    minSDKVersion: '4.0.0',
    resourceFilterTag: '300x300',
  },
};

let extraBuildTargets: typeof baseBuildTargets | undefined;
try {
  extraBuildTargets = require('@fitbit/sdk-build-targets').default;
} catch {}

export function generateBuildTargets() {
  return lodash.pickBy(
    {
      ...baseBuildTargets,
      ...extraBuildTargets,
    },
    ({ minSDKVersion }) =>
      minSDKVersion === undefined ||
      semver.gte(sdkVersion().format(), minSDKVersion),
  );
}

const buildTargets = generateBuildTargets();
{'fraction_non_alphanumeric': 0.13645943097997892, 'fraction_numerical': 0.02713382507903056, 'mean_word_length': 3.6024242424242425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876302', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1174, 'n_words': 273}