{"version":3,"file":"deprecated-command.mjs","names":[],"sources":["../../src/lib/cli/legacy-commands.ts","../../src/bin/deprecated-command.ts"],"sourcesContent":["import {\n  generateHelpTextForAllCommands,\n  type Application,\n  type CommandContext,\n} from '@stricli/core';\n\nimport { app } from '../../app.js';\nimport { logger } from '../../logger.js';\n\n// Maps legacy (<7.0.0) command names to their modern command structure\nexport const LEGACY_COMMAND_TO_MODERN_COMMAND_MAP: Record<string, string[]> = {\n  'tr-build-xdi-sync-endpoint': ['consent', 'build-xdi-sync-endpoint'],\n  'tr-consent-manager-service-json-to-yml': ['inventory', 'consent-manager-service-json-to-yml'],\n  'tr-consent-managers-to-business-entities': [\n    'inventory',\n    'consent-managers-to-business-entities',\n  ],\n  'tr-cron-mark-identifiers-completed': ['request', 'cron', 'mark-identifiers-completed'],\n  'tr-cron-pull-identifiers': ['request', 'cron', 'pull-identifiers'],\n  'tr-derive-data-silos-from-data-flows': ['inventory', 'derive-data-silos-from-data-flows'],\n  'tr-derive-data-silos-from-data-flows-cross-instance': [\n    'inventory',\n    'derive-data-silos-from-data-flows-cross-instance',\n  ],\n  'tr-discover-silos': ['inventory', 'discover-silos'],\n  'tr-generate-api-keys': ['admin', 'generate-api-keys'],\n  'tr-manual-enrichment-pull-identifiers': ['request', 'preflight', 'pull-identifiers'],\n  'tr-manual-enrichment-push-identifiers': ['request', 'preflight', 'push-identifiers'],\n  'tr-mark-request-data-silos-completed': [\n    'request',\n    'system',\n    'mark-request-data-silos-completed',\n  ],\n  'tr-pull': ['inventory', 'pull'],\n  'tr-pull-consent-metrics': ['consent', 'pull-consent-metrics'],\n  'tr-pull-consent-preferences': ['consent', 'pull-consent-preferences'],\n  'tr-pull-datapoints': ['inventory', 'pull-datapoints'],\n  'tr-pull-pull-unstructured-discovery-files': ['inventory', 'pull-unstructured-discovery-files'],\n  'tr-push': ['inventory', 'push'],\n  'tr-request-approve': ['request', 'approve'],\n  'tr-request-cancel': ['request', 'cancel'],\n  'tr-request-download-files': ['request', 'download-files'],\n  'tr-request-enricher-restart': ['request', 'enricher-restart'],\n  'tr-request-export': ['request', 'export'],\n  'tr-request-mark-silent': ['request', 'mark-silent'],\n  'tr-request-notify-additional-time': ['request', 'notify-additional-time'],\n  'tr-request-reject-unverified-identifiers': ['request', 'reject-unverified-identifiers'],\n  'tr-request-restart': ['request', 'restart'],\n  'tr-request-upload': ['request', 'upload'],\n  'tr-retry-request-data-silos': ['request', 'system', 'retry-request-data-silos'],\n  'tr-scan-packages': ['inventory', 'scan-packages'],\n  'tr-skip-preflight-jobs': ['request', 'skip-preflight-jobs'],\n  'tr-skip-request-data-silos': ['request', 'system', 'skip-request-data-silos'],\n  'tr-sync-ot': ['migration', 'sync-ot'],\n  'tr-update-consent-manager': ['consent', 'update-consent-manager'],\n  'tr-upload-consent-preferences': ['consent', 'upload-consent-preferences'],\n  'tr-upload-cookies-from-csv': ['consent', 'upload-cookies-from-csv'],\n  'tr-upload-data-flows-from-csv': ['consent', 'upload-data-flows-from-csv'],\n  'tr-upload-preferences': ['consent', 'upload-preferences'],\n};\n\n// All commands have been migrated to the modern command structure\n\n/**\n * Gets the help text for a command\n *\n * @param command - The command to get help text for\n * @returns The help text for the command\n */\nexport function getHelpTextForCommand(command: string[]): string | undefined {\n  const helpTextForAllCommands = generateHelpTextForAllCommands(app as Application<CommandContext>);\n\n  return helpTextForAllCommands.find(\n    (x) => x[0] === `${app.config.name} ${command.join(' ')}`,\n  )?.[1];\n}\n\n/**\n * Logs a modern command recommendation for a legacy command\n *\n * @param legacyCommand - The legacy command to log a modern command recommendation for\n * @example\n * logModernCommandRecommendation('tr-cron-mark-identifiers-completed');\n */\nexport function logModernCommandRecommendation(\n  legacyCommand: keyof typeof LEGACY_COMMAND_TO_MODERN_COMMAND_MAP,\n): void {\n  logger.log('[DEPRECATION NOTICE]');\n\n  const modernCommand = LEGACY_COMMAND_TO_MODERN_COMMAND_MAP[legacyCommand];\n  if (!modernCommand) {\n    const modernCommandString = Object.entries(LEGACY_COMMAND_TO_MODERN_COMMAND_MAP)\n      .map(\n        ([legacyCommand, modernCommand]) =>\n          `\\`${legacyCommand}\\` -> \\`${app.config.name} ${modernCommand.join(' ')}\\``,\n      )\n      .join('\\n');\n    logger.log(\n      'This command is deprecated as of v7.0.0.' +\n        ` Here is a list of new commands, mapped to their legacy command names:\n${modernCommandString}`,\n    );\n    return;\n  }\n\n  logger.log(\n    `\\`${legacyCommand}\\` is deprecated as of v7.0.0.\\nUse \\`${\n      app.config.name\n    } ${modernCommand.join(' ')}\\` instead.\\n`,\n  );\n\n  const helpText = getHelpTextForCommand(modernCommand);\n  if (!helpText) {\n    throw new Error(`Failed to get help text for command: \\`${modernCommand.join(' ')}\\``);\n  }\n\n  logger.log(helpText);\n}\n","#!/usr/bin/env node\nimport { logModernCommandRecommendation } from '../lib/cli/legacy-commands.js';\n\n/**\n * Runs when a deprecated command is called.\n */\nfunction main(): void {\n  const command = process.argv.at(-1);\n  const legacyCommand = command?.split('/').pop()?.trim();\n  if (legacyCommand) {\n    logModernCommandRecommendation(legacyCommand);\n  } else {\n    throw new Error('Deprecated command');\n  }\n\n  process.exit(1);\n}\n\nmain();\n"],"mappings":";6IAUA,MAAa,EAAiE,CAC5E,6BAA8B,CAAC,UAAW,0BAA0B,CACpE,yCAA0C,CAAC,YAAa,sCAAsC,CAC9F,2CAA4C,CAC1C,YACA,wCACD,CACD,qCAAsC,CAAC,UAAW,OAAQ,6BAA6B,CACvF,2BAA4B,CAAC,UAAW,OAAQ,mBAAmB,CACnE,uCAAwC,CAAC,YAAa,oCAAoC,CAC1F,sDAAuD,CACrD,YACA,mDACD,CACD,oBAAqB,CAAC,YAAa,iBAAiB,CACpD,uBAAwB,CAAC,QAAS,oBAAoB,CACtD,wCAAyC,CAAC,UAAW,YAAa,mBAAmB,CACrF,wCAAyC,CAAC,UAAW,YAAa,mBAAmB,CACrF,uCAAwC,CACtC,UACA,SACA,oCACD,CACD,UAAW,CAAC,YAAa,OAAO,CAChC,0BAA2B,CAAC,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