// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { NpmShrinkwrapFile } from './npm/NpmShrinkwrapFile';
import { PnpmShrinkwrapFile } from './pnpm/PnpmShrinkwrapFile';
import { YarnShrinkwrapFile } from './yarn/YarnShrinkwrapFile';
export class ShrinkwrapFileFactory {
    static getShrinkwrapFile(options) {
        const { packageManager, shrinkwrapFilePath, subspaceHasNoProjects } = options;
        switch (packageManager) {
            case 'npm':
                return NpmShrinkwrapFile.loadFromFile(shrinkwrapFilePath);
            case 'pnpm':
                return PnpmShrinkwrapFile.loadFromFile(shrinkwrapFilePath, { subspaceHasNoProjects });
            case 'yarn':
                return 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.loadFromString(shrinkwrapContent);
            case 'pnpm':
                return PnpmShrinkwrapFile.loadFromString(shrinkwrapContent, { subspaceHasNoProjects });
            case 'yarn':
                return YarnShrinkwrapFile.loadFromString(shrinkwrapContent);
            default:
                throw new Error(`Invalid package manager: ${packageManager}`);
        }
    }
}
//# sourceMappingURL=ShrinkwrapFileFactory.js.map