#!/usr/bin/env node

// This file is the entry point for when this package is run as a CLI. Though
// this file is not executable, the above "shebang" line is necessary as an
// indicator to npm that this file is a Node.js script, not a shell script e.g.

import { runCliAndExit } from '@alwaysai/alwayscli';
import { checkForUpdatesAndPrompt } from './components/general/check-for-updates';
import { enhancer } from './enhancer';
import { postTrackingDataToHubspot } from './infrastructure/post-tracking-data-to-hubspot';
import { root } from './root';

if (module === require.main) {
  const currentDate = new Intl.DateTimeFormat('en-US', {
    timeZone: 'America/Los_Angeles'
  }).format(new Date());
  void postTrackingDataToHubspot('most_recent_cli_date', currentDate).then(
    function () {
      // do nothing
    }
  );

  void runCliAndExit(root, { enhancer, postRun: checkForUpdatesAndPrompt });
}
