'stageDir' in this context is ambiguous, it would be better to get it as a function param or return the manifest and write the file in the caller function.