'use strict';

var chunkAF3E2D32_cjs = require('./chunk-AF3E2D32.cjs');
var types = require('@storm-software/config-tools/types');
var helpers = require('@stryke/fs/helpers');
var joinPaths = require('@stryke/path/join-paths');

async function cleanArtifacts(log, context, hooks) {
  log(types.LogLevelLabel.TRACE, `Cleaning the Storm Stack project artifacts.`);
  await helpers.removeDirectory(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.artifactsDir));
  await hooks.callHook("clean:artifacts", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while cleaning the Storm Stack project artifacts: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while cleaning the Storm Stack project artifacts", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(cleanArtifacts, "cleanArtifacts");
async function cleanDocs(log, context, hooks) {
  log(types.LogLevelLabel.TRACE, `Cleaning the Storm Stack project generated documentation.`);
  await helpers.removeDirectory(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.options.outputPath));
  await hooks.callHook("clean:docs", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while cleaning the Storm Stack project generated documentation: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while cleaning the Storm Stack project generated documentation", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(cleanDocs, "cleanDocs");
async function cleanOutput(log, context, hooks) {
  log(types.LogLevelLabel.TRACE, `Cleaning the Storm Stack project output.`);
  await helpers.removeDirectory(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.options.outputPath));
  await hooks.callHook("clean:output", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while cleaning the Storm Stack project output: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while cleaning the Storm Stack project output", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(cleanOutput, "cleanOutput");

// src/clean/index.ts
async function clean(log, context, hooks) {
  await hooks.callHook("clean:begin", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while starting the clean process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while starting the clean process for the Storm Stack project", {
      cause: error
    });
  });
  await cleanArtifacts(log, context, hooks);
  await cleanOutput(log, context, hooks);
  await cleanDocs(log, context, hooks);
  await hooks.callHook("clean:complete", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while finishing the clean process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while finishing the clean process for the Storm Stack project", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(clean, "clean");

exports.clean = clean;
//# sourceMappingURL=chunk-ARMA5W26.cjs.map
//# sourceMappingURL=chunk-ARMA5W26.cjs.map