<commit_before>/* global describe, it */
const expect = require('expect.js');
const idyll = require('..');
const fs = require('fs');
const path = require('path');

const inputPath = path.join(__dirname, 'test-project');
const outputPath = path.join(__dirname, 'test-project', 'build');
const expectedPath = path.join(__dirname, 'expected-output');
const expectedFiles = fs.readdirSync(expectedPath);

describe('build task', function() {

    before(function(done) {
      idyll(path.join(inputPath, 'index.idl'), {
          output: outputPath,
          htmlTemplate: path.join(inputPath, '_index.html'),
          componentFolder: path.join(inputPath, 'components'),
          defaultComponents: path.join(inputPath, 'components', 'default'),
          dataFolder: path.join(inputPath, 'data'),
          compilerOptions: {
            spellcheck: false
          },
          build: true
        }, function() {
          done();
        });
    })

    it('should compile the files', function(done) {
      const outputFiles = fs.readdirSync(outputPath);
      Object.keys(expectedFiles).forEach((f) => {
        expect(Object.keys(outputFiles).indexOf(f)).to.be.above(-1);
      });
      done();
    });

    it('should strip meta from the AST output', function(done) {
      const ast = JSON.parse(fs.readFileSync(path.join('.idyll', 'ast.json')));
      expect(JSON.stringify(ast)).to.eql(JSON.stringify([["Header",[["title",["value","Welcome to Idyll"]],["subtitle",["value","Open index.idl to start writing"]],["author",["value","Your Name Here"]],["authorLink",["value","https://idyll-lang.github.io"]]],[]],["p",[],["This is an Idyll file. Write text\nas you please in here. To add interactivity,\nyou can add  different components to the text."]],["p",[],["Here is how you can use a variable:"]],["var",[["name",["value","exampleVar"]],["value",["value",5]]],[]],["div",[],[["Range",[["min",["value",0]],["max",["value",10]],["value",["variable","exampleVar"]]],[]],["DisplayVar",[["var",["variable","exampleVar"]]],[]]]],["pre",[],[["code",[],["var code = true;"]]]],["p",[],["And here is a custom component:"]],["CustomComponent",[],[]],["p",[],["You can use standard html tags if a\ncomponent with the same name\ndoesn’t exist."]]]));
      done();
    });

});
<commit_msg>Check that the correct files are created<commit_after>/* global describe, it */
const expect = require('expect.js');
const idyll = require('..');
const fs = require('fs');
const path = require('path');

const inputPath = path.join(__dirname, 'test-project');
const outputPath = path.join(__dirname, 'test-project', 'build');
const expectedPath = path.join(__dirname, 'expected-output');
const expectedFiles = fs.readdirSync(expectedPath);

describe('build task', function() {

    before(function(done) {
      idyll(path.join(inputPath, 'index.idl'), {
          output: outputPath,
          htmlTemplate: path.join(inputPath, '_index.html'),
          componentFolder: path.join(inputPath, 'components'),
          defaultComponents: path.join(inputPath, 'components', 'default'),
          dataFolder: path.join(inputPath, 'data'),
          compilerOptions: {
            spellcheck: false
          },
          build: true
        }, function() {
          done();
        });
    })

    it('should create the expected files', function(done) {
      const outputFiles = fs.readdirSync(outputPath);
      expectedFiles.forEach(expectedFile => {
        expect(outputFiles.includes(expectedFile)).to.be(true);
      });
      done();
    });

    it('should strip meta from the AST output', function(done) {
      const ast = JSON.parse(fs.readFileSync(path.join('.idyll', 'ast.json')));
      expect(JSON.stringify(ast)).to.eql(JSON.stringify([["Header",[["title",["value","Welcome to Idyll"]],["subtitle",["value","Open index.idl to start writing"]],["author",["value","Your Name Here"]],["authorLink",["value","https://idyll-lang.github.io"]]],[]],["p",[],["This is an Idyll file. Write text\nas you please in here. To add interactivity,\nyou can add  different components to the text."]],["p",[],["Here is how you can use a variable:"]],["var",[["name",["value","exampleVar"]],["value",["value",5]]],[]],["div",[],[["Range",[["min",["value",0]],["max",["value",10]],["value",["variable","exampleVar"]]],[]],["DisplayVar",[["var",["variable","exampleVar"]]],[]]]],["pre",[],[["code",[],["var code = true;"]]]],["p",[],["And here is a custom component:"]],["CustomComponent",[],[]],["p",[],["You can use standard html tags if a\ncomponent with the same name\ndoesn’t exist."]]]));
      done();
    });

});

{'fraction_non_alphanumeric': 0.22492401215805471, 'fraction_numerical': 0.0019539730785931393, 'mean_word_length': 4.407276995305164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '449843', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1374, 'n_words': 285}