I usually do npm init right before I publish, so I've already got a ton of files in node_modules/ with the new flatter behavior in v3. When it comes time to npm init, npm thinks all of those flattened dependencies belong in my package.json as top-level dependencies.
Yup, it should totally do the right thing here.
To do this it needs to use read-package-tree like everything else in npm@3 and then look for packages with a _requiredBy containing #USER, which indicates they were installed by direct user action and not due to a subdep or an existing package.json. It might be reasonable to also include any module that doesn't have a _requiredBy field– that'd be modules installed via npm@2, and any module with a _requiredBy containing /, which would be from a previous package.json.
I heard it always does the "right thing".
based both on universal standards & models for ethical and absolute correctness.
I mean, they exist don't they!! RTFM or RTFSC it's all in there. init'ing after the fact, i like that, that's so manga, now they're busy re-wiring who put what where!! 😱
Aaand, this lives off in init-package-json, which complicates matters because it's building its tree in an entirely npm independent manner. I think this is going to require some (much needed) refactoring to extract those parts of the new installer into independent modules.
So yeah, this landed in 2.14.0 and 3.3.0!