package p.studio.compiler.workspaces.phases;

import p.studio.compiler.messages.BuildingIssueSink;
import p.studio.compiler.models.DependencyContext;
import p.studio.compiler.workspaces.DependencyPhase;

import java.io.IOException;

public final class SeedPhase implements DependencyPhase {
    @Override
    public BuildingIssueSink run(final DependencyContext ctx) {
        try {
            ctx.mainProjectRootPathCanon = ctx.config.cacheDir().toRealPath();
        } catch (IOException e) {
            return BuildingIssueSink.empty()
                    .report(builder -> builder
                            .error(true)
                            .message("[DEPS]: failed to canonicalize rootProjectId directory: " + ctx.config.cacheDir())
                            .exception(e));
        }

        ctx.pending.add(ctx.mainProjectRootPathCanon);

        return BuildingIssueSink.empty();
    }
}
