"use strict";
/*
* This test is meant to test a brand new startup with NO DATA in folders at all to start with
* - Delete files in the installDir first
* */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Factory_1 = require("../../src/Factory");
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const Source_1 = require("../../src/Source");
const Trial_1 = require("../../src/Trial");
const FactoryDatabase_1 = require("../../src/FactoryDatabase");
require('dotenv').config();
function main() {
    return __awaiter(this, void 0, void 0, function* () {
        // setup directory for the 'noInstall' test
        const installDir = path_1.default.join(process.cwd(), 'tests', 'installA');
        // ensure directory, then empty it
        yield fs_extra_1.default.ensureDir(installDir);
        yield fs_extra_1.default.emptyDir(installDir);
        // initialize the factory
        yield Factory_1.Factory.initialize({
            installDir,
            hideConsole: true
        });
        yield FactoryDatabase_1.FactoryDatabase.initialize();
        // Create a source from a blueprint string (45spm base test)
        const bpFile = path_1.default.join(process.cwd(), 'factory/examples/45spm_base.bp');
        const bpString = yield fs_extra_1.default.readFile(bpFile, 'utf8');
        let mySource = new Source_1.Source({
            name: '45spm_base',
            variant: 'blueprint',
            text: bpString,
            tags: ['test', 'debug'],
            desc: `Loaded from ${bpFile}`
        });
        // make sure factory is initialized and ready to go
        if (Factory_1.Factory.initStatus !== 'ready') {
            throw new Error(`Factory is not ready! Status: ${Factory_1.Factory.initStatus}`);
        }
        let trial = new Trial_1.Trial({
            source: mySource,
            recordItems: true,
            recordPollution: true,
            recordSystem: true,
            tickInterval: 60,
            length: 72000,
            initialBots: 200,
            name: '45spm_base_t1',
        });
        yield FactoryDatabase_1.FactoryDatabase.saveTrial(trial);
        let results = yield Factory_1.Factory.analyzeTrial(trial);
        console.log(results);
        // console log the test name and result
        console.log(`TestEmptyStartup: ${Factory_1.Factory.initStatus === 'ready' ? 'Passed' : 'Failed'}`);
    });
}
main().catch((err) => {
    console.error(err);
    console.log(`TestEmptyStartup: Failed`);
    process.exit(1);
});
//# sourceMappingURL=TestSourceBlueprintImportA.js.map