<commit_before>const fs = require("fs");

// TODO make this a command line param
const baseDir = "./";

function fmt(n) {
  let result = n.toString();
  // Stay clear of the left-pad chaos!
  while (result.length < 6) {
    result = "0" + result;
  }
  return result;
}

function generateComponents(n) {
  for (let i = 1; i <= n; i++) {
    const me = fmt(i);
    const left = fmt(2 * i);
    const right = fmt(2 * i + 1);

    let ts = `// Code generated by angular2-stress-test

import { Component } from '@angular/core';\n`;

    ts += `
@Component({
    selector: 'my-comp-${me}',
    template: '<div>component ${me}<div style="padding-left: 5px">`;

    if (left <= n) {
      ts += `<my-comp-${left}></my-comp-${left}>`;
    }
    if (right <= n) {
      ts += `<my-comp-${right}></my-comp-${right}>`;
    }

    ts += `</div></div>'
})
export class GeneratedComponent${me} { }
`;

    const componentFileName = `${baseDir}component${me}.ts`;
    fs.writeFileSync(componentFileName, ts);
  }
}

function generateAppComponent() {
  const ts = `// Code generated by angular2-stress-test

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: '<h1>Angular 2 App with many components</h1><my-comp-${fmt(1)}></my-comp-${fmt(1)}>'
})
export class AppComponent { }
`;

  fs.writeFileSync(baseDir + "app.component.ts", ts);
}

function generateAppModule(n) {
  let ts = `// Code generated by angular2-stress-test

import { NgModule }       from '@angular/core';
import { BrowserModule  } from '@angular/platform-browser';
import { AppComponent }   from './app.component';

`;
  for (let i = 1; i <= n; i++) {
    const me = fmt(i);
    ts += `import { GeneratedComponent${me} } from "./component${me}";\n`;
  }
  ts += `<commit_msg>app-root selector to match CLI default, `` strings<commit_after>const fs = require("fs");

// TODO make this a command line param
const baseDir = "./";

function fmt(n) {
  let result = n.toString();
  // Stay clear of the left-pad chaos!
  while (result.length < 6) {
    result = "0" + result;
  }
  return result;
}

function generateComponents(n) {
  for (let i = 1; i <= n; i++) {
    const me = fmt(i);
    const left = fmt(2 * i);
    const right = fmt(2 * i + 1);

    let ts = `// Code generated by angular2-stress-test

import { Component } from '@angular/core';\n`;

    ts += `
@Component({
    selector: 'my-comp-${me}',
    template: \`<div>
      <span>component ${me}</span>
      <div style="padding-left: 5px">`;

    if (left <= n) {
      ts += `
        <my-comp-${left}></my-comp-${left}>`;
    }
    if (right <= n) {
      ts += `
        <my-comp-${right}></my-comp-${right}>`;
    }

    ts += `
      </div></div>
    \`
})
export class GeneratedComponent${me} { }
`;

    const componentFileName = `${baseDir}component${me}.ts`;
    fs.writeFileSync(componentFileName, ts);
  }
}

function generateAppComponent() {
  const ts = `// Code generated by angular2-stress-test

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: '<h1>Angular 2 App with many components</h1><my-comp-${fmt(1)}></my-comp-${fmt(1)}>'
})
export class AppComponent { }
`;

  fs.writeFileSync(baseDir + "app.component.ts", ts);
}

function generateAppModule(n) {
  let ts = `// Code generated by angular2-stress-test

import { NgModule }       from '@angular/core';
import { BrowserModule  } from '@angular/platform-browser';
import { AppComponent }   from './app.component';

`;
  for (let i = 1; i <= n; i++) {
    const me = fmt(i);
    ts += `import { GeneratedComponent${me} } from "./component${me}";\n`;
  }
  ts += `
{'fraction_non_alphanumeric': 0.1925824175824176, 'fraction_numerical': 0.008791208791208791, 'mean_word_length': 2.983588621444201, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 29, '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': '444501', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1252, 'n_words': 318}