<commit_before>/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import {initializeApp} from 'firebase/app';
import {Arguments, Argv} from 'yargs';

import {
  configureAuthorizedGitClientWithTemporaryToken,
  getCurrentUser,
  restoreNgTokenFromDiskIfValid,
} from '../auth/shared/ng-dev-token.js';
import {assertValidGithubConfig, getConfig} from './config.js';
import {configureGitClientWithTokenOrFromEnvironment} from './git/github-yargs.js';
import {Log} from './logging.js';

/** Configuration for the firebase application used for ng-dev token management. */
const firebaseConfig = {
  apiKey: '<KEY>',
  authDomain: 'internal-200822.firebaseapp.com',
  projectId: 'internal-200822',
  storageBucket: 'internal-200822.appspot.com',
  messagingSenderId: '823469418460',
  appId: '1:823469418460:web:009b51c93132b218761119',
};

/** Whether or not the middleware has already been run. */
let ngDevServiceMiddlewareHasRun = false;

/**
 * Sets up middleware to ensure that configuration and setup is completed for commands which
 *  require the ng-dev service
 */
export async function useNgDevService<T>(argv: Argv<T>): Promise<Argv<T>>;
export async function useNgDevService<T>(argv: Argv<T>, isAuthCommand: true): Promise<Argv<T>>;
export async function useNgDevService<T>(
  argv: Argv<T>,
  isAuthCommand: boolean = false,
): Promise<Argv<T>> {
  const {github} = await getConfig([assertValidGithubConfig]);

  if (github.useNgDevAuthService !== true) {
    return argv;
  }

  return (
    argv<commit_msg>fix(ng-dev): always include the github token option on merge. (#771)<commit_after>/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import {initializeApp} from 'firebase/app';
import {Arguments, Argv} from 'yargs';

import {
  configureAuthorizedGitClientWithTemporaryToken,
  getCurrentUser,
  restoreNgTokenFromDiskIfValid,
} from '../auth/shared/ng-dev-token.js';
import {assertValidGithubConfig, getConfig} from './config.js';
import {
  addGithubTokenOption,
  configureGitClientWithTokenOrFromEnvironment,
} from './git/github-yargs.js';
import {Log} from './logging.js';

/** Configuration for the firebase application used for ng-dev token management. */
const firebaseConfig = {
  apiKey: '<KEY>',
  authDomain: 'internal-200822.firebaseapp.com',
  projectId: 'internal-200822',
  storageBucket: 'internal-200822.appspot.com',
  messagingSenderId: '823469418460',
  appId: '1:823469418460:web:009b51c93132b218761119',
};

/** Whether or not the middleware has already been run. */
let ngDevServiceMiddlewareHasRun = false;

/**
 * Sets up middleware to ensure that configuration and setup is completed for commands which
 *  require the ng-dev service
 */
export async function useNgDevService<T>(argv: Argv<T>): Promise<Argv<T>>;
export async function useNgDevService<T>(argv: Argv<T>, isAuthCommand: true): Promise<Argv<T>>;
export async function useNgDevService<T>(
  argv: Argv<T>,
  isAuthCommand: boolean = false,
): Promise<Argv<T>> {
  const {github} = await getConfig([assertValidGithubConfig]);

  if (github.useNgDevAuthService !== true) {
    return addGithubTokenOption(argv);
  }

  return (
    argv
{'fraction_non_alphanumeric': 0.12071967498549042, 'fraction_numerical': 0.03685432385374347, 'mean_word_length': 5.079365079365079, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, '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': '6413824', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1068, 'n_words': 301}