"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const node_path_1 = (0, tslib_1.__importDefault)(require("node:path"));
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
const exec_sh_1 = (0, tslib_1.__importDefault)(require("exec-sh"));
const hook = async function (opts) {
    const dataDirectory = node_path_1.default.join(opts.config.dataDir, 'data');
    await fs_extra_1.default.ensureDir(opts.config.dataDir);
    await new Promise((resolve, _reject) => {
        (0, exec_sh_1.default)('git clone https://github.com/SteerProtocol/backtesting-toolkit.git . && npm i', { cwd: opts.config.dataDir, stdio: null }, function (err) {
            if (err) {
                // console.log('🚨 Error: Could not bootstrap necessary setup. Please make sure nodejs and git are installed.')
                resolve(null);
            }
            resolve(null);
        });
    });
    await fs_extra_1.default.ensureDir(dataDirectory);
    await new Promise((resolve, _reject) => {
        (0, exec_sh_1.default)('npx hardhat clean', { cwd: opts.config.dataDir, stdio: null }, function (err) {
            if (err) {
                // console.log('🚨 Error: Could not bootstrap necessary setup. Please make sure nodejs and git are installed.', err)
                resolve(null);
            }
            resolve(null);
        });
    });
    await fs_extra_1.default.ensureDir(node_path_1.default.join(opts.config.dataDir, 'results'));
};
exports.default = hook;
