import { __name } from './chunk-6AXVLTU5.js';
import { LogLevelLabel } from '@storm-software/config-tools/types';
import { removeDirectory } from '@stryke/fs/helpers';
import { joinPaths } from '@stryke/path/join-paths';

async function cleanArtifacts(log, context, hooks) {
  log(LogLevelLabel.TRACE, `Cleaning the Storm Stack project artifacts.`);
  await removeDirectory(joinPaths(context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.artifactsDir));
  await hooks.callHook("clean:artifacts", context).catch((error) => {
    log(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
    });
  });
}
__name(cleanArtifacts, "cleanArtifacts");
async function cleanDocs(log, context, hooks) {
  log(LogLevelLabel.TRACE, `Cleaning the Storm Stack project generated documentation.`);
  await removeDirectory(joinPaths(context.workspaceConfig.workspaceRoot, context.options.outputPath));
  await hooks.callHook("clean:docs", context).catch((error) => {
    log(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
    });
  });
}
__name(cleanDocs, "cleanDocs");
async function cleanOutput(log, context, hooks) {
  log(LogLevelLabel.TRACE, `Cleaning the Storm Stack project output.`);
  await removeDirectory(joinPaths(context.workspaceConfig.workspaceRoot, context.options.outputPath));
  await hooks.callHook("clean:output", context).catch((error) => {
    log(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
    });
  });
}
__name(cleanOutput, "cleanOutput");

// src/clean/index.ts
async function clean(log, context, hooks) {
  await hooks.callHook("clean:begin", context).catch((error) => {
    log(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(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
    });
  });
}
__name(clean, "clean");

export { clean };
//# sourceMappingURL=chunk-2SY6WRSH.js.map
//# sourceMappingURL=chunk-2SY6WRSH.js.map