// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { ShellRunner } from '../shell-runner.js';
import { injectable } from 'tsyringe-neo';
let BrewPackageManager = class BrewPackageManager extends ShellRunner {
    async installPackages(dependencies) {
        await this.run(`brew install ${dependencies.join(' ')}`);
    }
    async uninstallPackages(dependencies) {
        await this.run(`brew uninstall ${dependencies.join(' ')}`);
    }
    async update() {
        await this.run('brew update');
    }
    async upgrade(dependencies) {
        await this.run(`brew upgrade ${dependencies.join(' ')}`);
    }
    async install() {
        await this.run('NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
        await this.run('eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"');
        process.env.PATH = `${process.env.PATH}:/home/linuxbrew/.linuxbrew/bin`;
        return this.isAvailable();
    }
    async uninstall() {
        await this.run('NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"');
    }
    async isAvailable() {
        try {
            await this.run('brew --version');
            return true;
        }
        catch {
            return false;
        }
    }
};
BrewPackageManager = __decorate([
    injectable()
], BrewPackageManager);
export { BrewPackageManager };
//# sourceMappingURL=brew-package-manager.js.map