File

libs/nx/src/generators/journey-src/lib/extract-debug-flags/extract-debug-flags.ts

Index

Properties

Properties

debugAcl
Type boolean
debugBb
Type boolean
debugPfe
Type boolean
import { logger } from '@nx/devkit';
import chalk from 'chalk';

export interface DebugFlags {
  debugPfe: boolean;
  debugAcl: boolean;
  debugBb: boolean;
}

export interface InputDebugFlagsWithDeprecated extends Partial<DebugFlags> {
  /**
   * Whether to show debug output and include debug inspectors (ACL Inspector, PFE Debugger,
   * BB Debugger).
   */
  debugHelpers?: boolean;
}

export function extractDebugFlags(inputFlags: InputDebugFlagsWithDeprecated): DebugFlags {
  const resultFlags: DebugFlags = {
    debugPfe: (inputFlags.debugPfe || inputFlags.debugHelpers) ?? false,
    debugAcl: (inputFlags.debugAcl || inputFlags.debugHelpers) ?? false,
    debugBb: (inputFlags.debugBb || inputFlags.debugHelpers) ?? false
  };

  const isAnyDebugPropertyDefinedManually = Object.values(inputFlags).some(
    (value) => value === true
  );
  if (isAnyDebugPropertyDefinedManually) {
    logger.info(`🐞 Debug mode enabled (This is not recommended for production!):
    ${chalk.yellow('debugPfe: ')}${resultFlags.debugPfe ? chalk.green('ON') : chalk.red('OFF')}
    ${chalk.yellow('debugAcl: ')}${resultFlags.debugAcl ? chalk.green('ON') : chalk.red('OFF')}
    ${chalk.yellow('debugBb: ')}${resultFlags.debugBb ? chalk.green('ON') : chalk.red('OFF')}`);
  }

  return resultFlags;
}

results matching ""

    No results matching ""