text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const tslib_1 = require("tslib");
  const cli_1 = require("@yarnpkg/cli");
  const core_1 = require("@yarnpkg/core");
  const fslib_1 = require("@yarnpkg/fslib");
  const clipanion_1 = require("clipanion");
  // eslint-disable-next-line arca/no-default-export
  class CacheCleanCommand extends cli_1.BaseCommand {
      constructor() {
          super(...arguments);
          this.mirror = false;
          this.all = false;
      }
      async execute() {
          const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
          const cache = await core_1.Cache.find(configuration);
          const report = await core_1.StreamReport.start({
              configuration,
              stdout: this.context.stdout,
          }, async () => {
              const cleanMirror = (this.all || this.mirror) && cache.mirrorCwd !== null;
              const cleanCache = !this.mirror;
              if (cleanMirror)
                  await fslib_1.xfs.removePromise(cache.mirrorCwd);
              if (cleanCache) {
                  await fslib_1.xfs.removePromise(cache.cwd);
              }
          });
          return report.exitCode();
      }
  }
  CacheCleanCommand.usage = clipanion_1.Command.Usage({
      description: `remove the shared cache files`,
      details: `
        This command will remove all the files from the cache.
      `,
      examples: [[
              `Remove all the local archives`,
              `$0 cache clean`,
          ], [
              `Remove all the archives stored in the ~/.yarn directory`,
              `$0 cache clean --mirror`,
          ]],
  });
  tslib_1.__decorate([
      clipanion_1.Command.Boolean(`--mirror`, { description: `Remove the global cache files instead of the local cache files` })
  ], CacheCleanCommand.prototype, "mirror", void 0);
  tslib_1.__decorate([
      clipanion_1.Command.Boolean(`--all`, { description: `Remove both the global cache files and the local cache files of the current project` })
  ], CacheCleanCommand.prototype, "all", void 0);
  tslib_1.__decorate([
      clipanion_1.Command.Path(`cache`, `clean`)
  ], CacheCleanCommand.prototype, "execute", null);
  exports.default = CacheCleanCommand;
  