import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  getProjectDependencies,
  saveWixLock
} from "./chunk-I5KDLQBC.js";
import {
  createPackageManager,
  getRepoType
} from "./chunk-RF4NA2OH.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site/src/services/dependencies.ts
init_esm_shims();
async function createDependenciesService(projectFolder, veloClient) {
  const repoType = await getRepoType(projectFolder);
  const packageManager = await createPackageManager(repoType);
  const updateWixLock = async () => {
    const dependencies = await getProjectDependencies(projectFolder);
    const wixLockContent = await veloClient.generateWixLockFile(dependencies);
    await saveWixLock(projectFolder, wixLockContent);
  };
  return {
    install: async (packageName) => {
      if (packageName) {
        await packageManager.runInstallPackage(projectFolder, packageName);
      } else {
        await packageManager.runInstall(projectFolder);
      }
      await updateWixLock();
    },
    uninstall: async (packageName) => {
      await packageManager.runUninstallPackage(projectFolder, packageName);
      await updateWixLock();
    }
  };
}

export {
  createDependenciesService
};
//# sourceMappingURL=chunk-QLZSW3TK.js.map