"use strict";
const path = require("path");
class GenerateMessages {
    constructor($fs, $messageContractGenerator, $options) {
        this.$fs = $fs;
        this.$messageContractGenerator = $messageContractGenerator;
        this.$options = $options;
        this.allowedParameters = [];
    }
    execute(args) {
        return (() => {
            let result = this.$messageContractGenerator.generate().wait(), innerMessagesDirectory = path.join(__dirname, "../messages"), outerMessagesDirectory = path.join(__dirname, "../.."), interfaceFilePath, implementationFilePath;
            if (this.$options.default) {
                interfaceFilePath = path.join(innerMessagesDirectory, GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME);
                implementationFilePath = path.join(innerMessagesDirectory, GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME);
            }
            else {
                interfaceFilePath = path.join(outerMessagesDirectory, GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME);
                implementationFilePath = path.join(outerMessagesDirectory, GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME);
            }
            this.$fs.writeFile(interfaceFilePath, result.interfaceFile).wait();
            this.$fs.writeFile(implementationFilePath, result.implementationFile).wait();
        }).future()();
    }
}
GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME = "messages.interface.d.ts";
GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME = "messages.ts";
exports.GenerateMessages = GenerateMessages;
$injector.registerCommand("dev-generate-messages", GenerateMessages);
