"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unifyWhiteSpaces = exports.filesEqual = exports.prepareOutDir = exports.getApprovalsBaseDir = exports.getTestClientInput = exports.getInvalidTestBaseDir = exports.getTestBaseDir = void 0;
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2022 Plexus Interop Deutsche Bank AG
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var fs_extra_1 = require("fs-extra");
var path = require("path");
var files_1 = require("../../src/common/files");
function getTestBaseDir() {
    return path.resolve((0, files_1.getBaseDir)(), '../../../samples/greeting/registry');
}
exports.getTestBaseDir = getTestBaseDir;
function getInvalidTestBaseDir() {
    return path.resolve((0, files_1.getBaseDir)(), '../../../dsl/gen/test/src/main/resources');
}
exports.getInvalidTestBaseDir = getInvalidTestBaseDir;
function getTestClientInput() {
    return 'greeting_client.interop';
}
exports.getTestClientInput = getTestClientInput;
function getApprovalsBaseDir() {
    return path.join((0, files_1.getBaseDir)(), 'tests/approved');
}
exports.getApprovalsBaseDir = getApprovalsBaseDir;
function prepareOutDir(testName) {
    var outDir = path.join((0, files_1.getBaseDir)(), 'dist/gen', testName);
    (0, fs_extra_1.mkdirsSync)(outDir);
    return outDir;
}
exports.prepareOutDir = prepareOutDir;
function filesEqual(first, second) {
    return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
        var firstContent, secondContent;
        return (0, tslib_1.__generator)(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, (0, files_1.readTextFile)(first)];
                case 1:
                    firstContent = _a.sent();
                    return [4 /*yield*/, (0, files_1.readTextFile)(second)];
                case 2:
                    secondContent = _a.sent();
                    return [2 /*return*/, unifyWhiteSpaces(firstContent) === unifyWhiteSpaces(secondContent)];
            }
        });
    });
}
exports.filesEqual = filesEqual;
function unifyWhiteSpaces(s) {
    return s.replace(/\s+/g, ' ');
}
exports.unifyWhiteSpaces = unifyWhiteSpaces;
//# sourceMappingURL=setup.js.map