"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShrinkwrapFileFactory = void 0;
const NpmShrinkwrapFile_1 = require("./npm/NpmShrinkwrapFile");
const PnpmShrinkwrapFile_1 = require("./pnpm/PnpmShrinkwrapFile");
const YarnShrinkwrapFile_1 = require("./yarn/YarnShrinkwrapFile");
class ShrinkwrapFileFactory {
    static getShrinkwrapFile(options) {
        const { packageManager, shrinkwrapFilePath, subspaceHasNoProjects } = options;
        switch (packageManager) {
            case 'npm':
                return NpmShrinkwrapFile_1.NpmShrinkwrapFile.loadFromFile(shrinkwrapFilePath);
            case 'pnpm':
                return PnpmShrinkwrapFile_1.PnpmShrinkwrapFile.loadFromFile(shrinkwrapFilePath, { subspaceHasNoProjects });
            case 'yarn':
                return YarnShrinkwrapFile_1.YarnShrinkwrapFile.loadFromFile(shrinkwrapFilePath);
            default:
                throw new Error(`Invalid package manager: ${packageManager}`);
        }
    }
    static parseShrinkwrapFile(options) {
        const { packageManager, shrinkwrapContent, subspaceHasNoProjects } = options;
        switch (packageManager) {
            case 'npm':
                return NpmShrinkwrapFile_1.NpmShrinkwrapFile.loadFromString(shrinkwrapContent);
            case 'pnpm':
                return PnpmShrinkwrapFile_1.PnpmShrinkwrapFile.loadFromString(shrinkwrapContent, { subspaceHasNoProjects });
            case 'yarn':
                return YarnShrinkwrapFile_1.YarnShrinkwrapFile.loadFromString(shrinkwrapContent);
            default:
                throw new Error(`Invalid package manager: ${packageManager}`);
        }
    }
}
exports.ShrinkwrapFileFactory = ShrinkwrapFileFactory;
//# sourceMappingURL=ShrinkwrapFileFactory.js.map