"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 FactorioApi_1 = require("../../src/FactorioApi");
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', 'oldInstall');
        // ensure directory, then empty it
        yield fs_extra_1.default.ensureDir(installDir);
        yield fs_extra_1.default.emptyDir(installDir);
        yield FactorioApi_1.FactorioApi.initialize({
            dataPath: installDir
        });
        // install game as normal with old version.
        yield Factory_1.Factory.installGame('1.1.90', 'headless');
        // initialize the factory now -
        yield Factory_1.Factory.initialize({
            installDir,
            updateInstall: true
        });
        // 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}`);
        }
        if (Factory_1.Factory.factoryVersion === '1.1.90') {
            throw new Error(`Factory version is not updated! Version: ${Factory_1.Factory.factoryVersion}`);
        }
        // console log the test name and result
        console.log(`TestOutdatedInstall: ${Factory_1.Factory.initStatus === 'ready' ? 'Passed' : 'Failed'}`);
    });
}
main().catch((err) => {
    console.error(err);
    console.log(`TestOutdatedInstall: Failed`);
    process.exit(1);
});
//# sourceMappingURL=TestOutdatedInstall.js.map