"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAbiPaths = exports.parseExports = exports.listFiles = void 0;
const fs = require('fs-extra');
const path = require('path');
const listFiles = async (folderName) => {
    const folderPath = path.resolve('src', folderName);
    if (!(await fs.pathExists(folderPath)))
        throw new Error(`path not found: ${folderPath}`);
    let files;
    try {
        files = await fs.readdir(folderPath);
    }
    catch (err) {
        console.log(err);
    }
    return files;
};
exports.listFiles = listFiles;
const parseExports = async (folderName) => {
    const files = await (0, exports.listFiles)(folderName);
    const exportsList = files
        .filter((f) => f.includes('.json'))
        .map((f) => `./${folderName}/${f}`);
    // make sure all paths exists
    await Promise.all(exportsList.map((f) => fs.pathExists(path.resolve(f))));
    return exportsList;
};
exports.parseExports = parseExports;
const getAbiPaths = async () => {
    const folders = [
        'abis/PublicLock',
        'abis/Unlock',
        'abis/UnlockDiscountToken',
        'abis/Governor',
        'abis/utils',
    ];
    const paths = await Promise.all(folders.map((f) => (0, exports.parseExports)(f)));
    return paths;
};
exports.getAbiPaths = getAbiPaths;
