"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readRemoteConfig = exports.writeRemoteConfig = void 0;
const fs = require("fs");
const path = require("path");
const REMOTE_JSON_FILE = '.remote.json';
function writeRemoteConfig(branch, eventSchemaSha, testSpecs, outDir) {
    const testSpecShas = testSpecs
        .filter((f) => f.sha != null)
        .reduce((obj, f) => {
        obj[f.path] = f.sha ?? '';
        return obj;
    }, {});
    const remoteConfig = {
        branch,
        shas: {
            eventSchemaSha,
            testSpecShas
        }
    };
    fs.writeFileSync(path.join(outDir, REMOTE_JSON_FILE), JSON.stringify(remoteConfig, null, 2));
}
exports.writeRemoteConfig = writeRemoteConfig;
function readRemoteConfig(input) {
    try {
        const config = JSON.parse(fs.readFileSync(path.join(input, REMOTE_JSON_FILE), 'utf-8'));
        return config;
    }
    catch (e) { }
}
exports.readRemoteConfig = readRemoteConfig;
