"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TspHostImpl = void 0;
const codegen_1 = require("@azure-tools/codegen");
const fs_1 = require("fs");
const path_1 = require("path");
class TspHostImpl {
    constructor(configurations) {
        this.configurations = configurations;
    }
    protectFiles(path) {
        // ToDo by xiaogang, skip this for now
        return Promise.resolve();
    }
    readFile(filename) {
        // ToDo by xiaogang, skip this for now
        return Promise.resolve('');
    }
    getValue(key) {
        return this.configurations[key];
    }
    listInputs(artifactType) {
        // Shall not be called, so throw an exception
        throw new Error('Method listInputs not implemented');
    }
    writeFile({ filename, content, sourceMap, artifactType }) {
        const directoryPath = (0, path_1.dirname)(filename);
        if (!(0, fs_1.existsSync)(directoryPath)) {
            (0, fs_1.mkdirSync)(directoryPath, { recursive: true });
        }
        if (artifactType === 'binary-file') {
            (0, fs_1.writeFileSync)(filename, Buffer.from(content, 'base64'));
        }
        else {
            if (artifactType === 'source-file-csharp' && filename.endsWith('.cs')) {
                const header = (0, codegen_1.comment)('Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License. See License.txt in the project root for license information.\nChanges may cause incorrect behavior and will be lost if the code is regenerated.', '//');
                content = header + '\n' + content;
            }
            (0, fs_1.writeFileSync)(filename, content);
        }
    }
    UpdateConfigurationFile(filename, content) {
        // Shall not be called 
        throw new Error('Method UpdateConfigurationFile not implemented');
    }
    GetConfigurationFile(filename) {
        throw new Error('Method GetConfigurationFile not implemented');
    }
    // WriteFile(filename: string, content: string): void {
    //   throw new Error('Method not implemented');
    // }
    // GetValue(key: string): any {
    //   throw new Error('Method not implemented');
    // }
    message(message) {
        // ToDo by xiaogang, skip this for now
        return;
    }
}
exports.TspHostImpl = TspHostImpl;
//# sourceMappingURL=tsp-host.js.map