<commit_before>//@flow
import fs from 'fs';
import zlib from 'zlib';

import _ from 'lodash';
import DecompressZip from 'decompress-zip';
import fse from 'fs-extra';
import rimraf from 'rimraf';

import {ScenarioReport, ScenarioPart} from './reports';
import {REPORTS_DESTINATION} from './scenarios';
import type {ReportModel} from './jgivenReport/ReportModel';
import type {ScenarioModel} from './jgivenReport/ScenarioModel';
import type {StepModel} from './jgivenReport/StepModel';

export const JGIVEN_APP_VERSION = '0.12.1';

export async function generateJGivenReport(): Promise<void> {
    try {
        await installJGivenReportApp();
        generateJGivenReportDataFiles();

        console.log(`jsGiven report available in ./jGiven-report`);
    } catch (error) {
        console.log(error);
        process.exit(-1);
    }
}

export async function cleanReports(): Promise<void> {
    try {
        await removeDir(`./${REPORTS_DESTINATION}`);
    } catch (error) {
        console.log(error);
        process.exit(-1);
    }
}

export async function installJGivenReportApp(reportPrefix: string = '.'): Promise<void> {
    const reportDir = `${reportPrefix}/jGiven-report`;

    await removeDir(reportDir);
    fs.mkdirSync(reportDir);
    fs.mkdirSync(`${reportDir}/data`);

    let jarFile = './jgiven-html5-report.jar';<commit_msg>fix(js-given/report): do not generate report if there are no jsgiven reports<commit_after>//@flow
import fs from 'fs';
import zlib from 'zlib';

import _ from 'lodash';
import DecompressZip from 'decompress-zip';
import fse from 'fs-extra';
import rimraf from 'rimraf';

import {ScenarioReport, ScenarioPart} from './reports';
import {REPORTS_DESTINATION} from './scenarios';
import type {ReportModel} from './jgivenReport/ReportModel';
import type {ScenarioModel} from './jgivenReport/ScenarioModel';
import type {StepModel} from './jgivenReport/StepModel';

export const JGIVEN_APP_VERSION = '0.12.1';

export async function generateJGivenReport(): Promise<void> {
    try {
        if (!fileExists(REPORTS_DESTINATION)) {
            console.log('No jsGiven reports found, skipping jgiven report generation');
            return;
        }

        await installJGivenReportApp();
        generateJGivenReportDataFiles();

        console.log(`jsGiven report available in ./jGiven-report`);
    } catch (error) {
        console.log(error);
        process.exit(-1);
    }
}

export async function cleanReports(): Promise<void> {
    try {
        await removeDir(`./${REPORTS_DESTINATION}`);
    } catch (error) {
        console.log(error);
        process.exit(-1);
    }
}

export async function installJGivenReportApp(reportPrefix: string = '.'): Promise<void> {
    const reportDir = `${reportPrefix}/jGiven-report`;

    await removeDir(reportDir);
    fs.mkdirSync(reportDir);
    fs.mkdirSync(`${reportDir}/data`);

    let jarFile = './jgiven-html5-report.jar';
{'fraction_non_alphanumeric': 0.1343385880740233, 'fraction_numerical': 0.004797806716929404, 'mean_word_length': 3.7233009708737863, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2215540', 'n_tokens_mistral': 923, 'n_tokens_neox': 891, 'n_words': 216}