<commit_before>import {join} from 'path';
import {readdirSync} from 'fs';
import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
import {ng} from '../../utils/process';
import {expectGitToBeClean} from '../../utils/git';


export default function() {
  // TODO(architect): Delete this test. It is now in devkit/build-angular.

  // Can't use the `ng` helper because somewhere the environment gets
  // stuck to the first build done
  return ng('build', '--prod')
    .then(() => expectFileToExist(join(process.cwd(), 'dist')))
    // Check for cache busting hash script src
    .then(() => expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/))
    .then(() => expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/))
    .then(() => expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/))
    .then(() => expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/))
    // Defaults to AoT
    .then(() => {
      const mainES5 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es5.[a-z0-9]+\.js/));
      expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/);

      const mainES2015 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es2015.[a-z0-9]+\.js/));
      expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/);
    })
    // Check that the process didn't change local files.
    .then(() => expectGitToBeClean());
}<commit_msg>test: fix e2e to rely on the bootstrapping call instead of the method to be present in the bundle<commit_after>import { readdirSync } from 'fs';
import { join } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { expectFileToExist, expectFileToMatch } from '../../utils/fs';
import { expectGitToBeClean } from '../../utils/git';
import { ng } from '../../utils/process';


export default async function () {
  // TODO(architect): Delete this test. It is now in devkit/build-angular.

  // Can't use the `ng` helper because somewhere the environment gets
  // stuck to the first build done
  const argv = getGlobalVariable('argv');
  const ivyProject = argv['ivy'];
  const bootstrapRegExp = ivyProject
    ? /bootstrapModule\([a-zA-Z]+\)\./
    : /bootstrapModuleFactory\([a-zA-Z]+\)\./;

  await ng('build', '--prod');
  await expectFileToExist(join(process.cwd(), 'dist'));
  // Check for cache busting hash script src
  await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/);
  await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/);
  await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/);
  await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/);

  const dirContents = readdirSync('./dist/test-project');
  const mainES5 = dirContents.find(name => /main-es5.[a-z0-9]+\.js/.test(name));
  await expectFileToMatch(`dist/test-project/${mainES5}`, bootstrapRegExp);

  const mainES2015 = dirContents.find(name => /main-es2015.[a-z0-9]+\.js/.test(name));
  await expectFileToMatch(`dist/test-project/${mainES2015}`, bootstrapRegExp);

  // Check that the process didn't change local files.
  await expectGitToBeClean();
}
{'fraction_non_alphanumeric': 0.1926829268292683, 'fraction_numerical': 0.02195121951219512, 'mean_word_length': 3.7688953488372094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '5518393', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1089, 'n_words': 235}