<commit_before>const argv = require('minimist')(process.argv.slice(2));
const {createCtrlcHandler} = require('../common/ctrlcHandler');
const {cyan, green} = require('kleur/colors');
const {doServe} = require('./serve');
const {log} = require('../common/logging');
const {parseExtensionFlags} = require('./extension-helpers');
const {printConfigHelp} = require('./helpers');
const {runPreBuildSteps} = require('./build');
const {runPreDistSteps} = require('./dist');

/**
 * Prints a useful help message prior to the default amp task
 */
function printDefaultTaskHelp() {
  log(green('Running the default ') + cyan('amp ') + green('task.'));
  log(
    green(
      '⤷ JS and extensions will be lazily built when requested from the server.'
    )
  );
}

/**
 * The default task run when `amp` is executed
 *
 * @return {!Promise}
 */
async function defaultTask() {
  createCtrlcHandler('amp');
  process.env.NODE_ENV = 'development';
  printConfigHelp('amp');
  printDefaultTaskHelp();
  parseExtensionFlags(/* preBuild */ true);
  if (argv.minified) {
    await runPreDistSteps(/* watch */ true);
  } else {
    await runPreBuildSteps(/* watch */ true);
  }
  await doServe(/* lazyBuild */ true);<commit_msg>build-system: lazy preDist and preBuild configuration (#36480)<commit_after>const argv = require('minimist')(process.argv.slice(2));
const {createCtrlcHandler} = require('../common/ctrlcHandler');
const {cyan, green} = require('kleur/colors');
const {doServe} = require('./serve');
const {log} = require('../common/logging');
const {parseExtensionFlags} = require('./extension-helpers');
const {printConfigHelp} = require('./helpers');
const {runPreBuildSteps} = require('./build');
const {runPreDistSteps} = require('./dist');

/**
 * Prints a useful help message prior to the default amp task
 */
function printDefaultTaskHelp() {
  log(green('Running the default ') + cyan('amp ') + green('task.'));
  log(
    green(
      '⤷ JS and extensions will be lazily built when requested from the server.'
    )
  );
}

/**
 * The default task run when `amp` is executed
 *
 * @return {!Promise}
 */
async function defaultTask() {
  createCtrlcHandler('amp');
  process.env.NODE_ENV = 'development';
  printConfigHelp('amp');
  printDefaultTaskHelp();
  parseExtensionFlags(/* preBuild */ true);

  const options = {fortesting: true, minify: argv.minified, watch: true};
  if (argv.minified) {
    await runPreDistSteps(options);
  } else {
    await runPreBuildSteps(options);
  }

  await doServe(/* lazyBuild */ true);
{'fraction_non_alphanumeric': 0.1673921646220815, 'fraction_numerical': 0.002770083102493075, 'mean_word_length': 4.495652173913044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '503467', 'n_tokens_mistral': 777, 'n_tokens_neox': 774, 'n_words': 203}