I build pretty much all my bikes, which focuses the mind a lot on the relative value of parts – and, indeed, a complete factory build.
I generally look lovingly at new bikes, get close to buying one, then confirm to myself that the change isn’t the much given the cost. It’s often a lot cheaper to shift parts around (and harder work).
The opposite argument is of the “what the hell, treat yourself” variety. A new bike will ride with a cohesiveness that’s difficult to achieve from the DIY route, at least until a few weeks of fettling have been done IME.
If the moving parts are worn, I’d upgrade those first and – later – the frame. Otherwise, I’d do it the other way around.