Open pdehaan opened 8 years ago
From what I understand jpm init is only supposed to run against an empty directory. I guess it doesn't complain about it, but that's what it's intended use is. It will essentially write a new package.json based on your choices in the jpm init wizzard (plus some good default values, like the jetpack keyword).
A very easy solution would be just to check if there is a package.json and if there is just don't execute the command?
Or else tweak the lib/init-input.js file to read the current directory's package.json (if it exists) and use those values as the defaults, and then fall back to the current hard-coded values.
I kinda hate jpm init. I would much rather have something like ember new.
Ah, interesting! I've never tried Ember, but I'll check out their ember new
scaffolding.
We were actually discussing initialization templates over in https://github.com/mozilla/shield-study-cli/issues/14 and I was curious why you prefer the ember new
behavior over the current jpm init
or something else. /cc @gregglind
Found in:
After running
jpm init
on a non-empty folder (it only had a package.json and locally installed jpm in node_modules), I noticed that jpm seems to have its own set of default values and doesn't respect previous values in package.json that it's attempting to overwrite, leading to data loss. This could be kind of dangerous, if I was publishing this module to npm, since you'd potentially be publishing as an unexpected version number, or the incorrect package name.Steps to reproduce:
$ npm init -y
which uses default values.name
, add adescription
and somekeywords
, etc).jpm init
.Actual results:
Before running
jpm init
, my beautiful hypothetical package.json looked like:After running
jpm init
, my package.json looks like:TL;DR
name
was changed. (pre: "jpm-init-tester", post: "jpm-init-test")description
was changed. (pre: "stuff and things", post: "A basic add-on")version
was changed. (pre: "1.0.0", post: "0.0.1")keywords
were changed. (pre: ["foo", "bar"], post: ["jetpack"])license
was changed. (pre: "WTFPL", post: "MIT")author
was deleted.scripts
were deleted.dependencies
anddevDependencies
were deleted.