repo_description: A Swiss Army knife for service workers.
repo_topics: nextjs nuxt nuxtjs offline-first progressive-web-app pwa service-worker service-workers serwist serwistjs svelte sveltejs sveltekit sw sw-precache sw-toolbox vite vitejs webpack
code: import fg from "fast-glob";
  import { run } from "npm-check-updates";
  
  /**
   * Update and then log updated dependencies.
   *
   * @param {import("npm-check-updates").RunOptions} runOptions
   */
  const updateAndLog = async (runOptions) => {
    const upgraded = await run(runOptions);
    console.log(`Upgraded dependencies for ${runOptions.packageFile ?? "./package.json"}:`, upgraded);
  };
  
  const packageJsonList = await fg("**/package.json", {
    ignore: ["examples/**", "**/node_modules/**"],
  });
  const examplesPackageJsonList = await fg("examples/*/package.json", {
    ignore: ["**/node_modules/**"],
  });
  const excludePackages = ["pretty-bytes"];
  
  /**
   * @type {Promise<any>[]}
   */
  const updatePromise = [];
  
  for (const packageFile of packageJsonList) {
    updatePromise.push(
      updateAndLog({
        packageFile,
        upgrade: true,
        filter(packageName) {
          return !excludePackages.includes(packageName);
        },
        target(dep) {
          if (dep === "glob") {
            return "@legacy-v10";
          }
          if (dep === "rimraf") {
            return "@v5-legacy";
          }
          if (/^react(-dom)?$/.test(dep)) {
            return "@latest";
          }
          if (dep === "tailwindcss" || dep === "@tailwindcss/vite") {
            return "@next";
          }
          return "latest";
        },
      }),
    );
  }
  
  for (const packageFile of examplesPackageJsonList) {
    updatePromise.push(
      updateAndLog({
        packageFile,
        upgrade: true,
        filter(packageName) {
          return !excludePackages.includes(packageName);
        },
      }),
    );
  }
  
  await Promise.all(updatePromise);
  