{"action":"created","issue":{"url":"https://api.github.com/repos/lerna/lerna/issues/401","repository_url":"https://api.github.com/repos/lerna/lerna","labels_url":"https://api.github.com/repos/lerna/lerna/issues/401/labels{/name}","comments_url":"https://api.github.com/repos/lerna/lerna/issues/401/comments","events_url":"https://api.github.com/repos/lerna/lerna/issues/401/events","html_url":"https://github.com/lerna/lerna/issues/401","id":188062029,"number":401,"title":"Upgrading from 1.x to 2.x: lerna added to both dependencies & devDependencies","user":{"login":"timoxley","id":43438,"avatar_url":"https://avatars.githubusercontent.com/u/43438?v=3","gravatar_id":"","url":"https://api.github.com/users/timoxley","html_url":"https://github.com/timoxley","followers_url":"https://api.github.com/users/timoxley/followers","following_url":"https://api.github.com/users/timoxley/following{/other_user}","gists_url":"https://api.github.com/users/timoxley/gists{/gist_id}","starred_url":"https://api.github.com/users/timoxley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoxley/subscriptions","organizations_url":"https://api.github.com/users/timoxley/orgs","repos_url":"https://api.github.com/users/timoxley/repos","events_url":"https://api.github.com/users/timoxley/events{/privacy}","received_events_url":"https://api.github.com/users/timoxley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-08T18:03:02Z","updated_at":"2016-11-16T19:14:03Z","closed_at":null,"body":"### Problem\r\n\r\nWhen updating an existing lerna project from 1.x to 2.x, users will end up with lerna 2.x in their `devDependencies` and lerna 1.x in `dependencies`.\r\n\r\n### Suggestion\r\n\r\n`lerna init` should remove any version of `lerna` in `dependencies` before adding itself to `devDependencies`, ideally only when updating from 1.x to 2.x.\r\n\r\n### Details\r\n\r\nThe `lerna bootstrap` command from lerna 1.1.3 adds `lerna` to `devDependencies`.\r\nThe `lerna init` command from lerna 2.0.0-beta.30 adds `lerna` to `dependencies`.\r\n\r\n#### Repro Script\r\n\r\n```sh\r\nyarn global add lerna@1.1.3 # current release version\r\nmkdir $TMPDIR/lerna-test && cd $TMPDIR/lerna-test\r\nlerna bootstrap # will create package.json with lerna in dependencies\r\nyarn global add lerna@2.0.0-beta.30 # current prerelease version\r\nlerna init # will add lerna to package.json devDependencies\r\ncat package.json\r\n```\r\n\r\n```json\r\n{\r\n  \"private\": true,\r\n  \"dependencies\": {\r\n    \"lerna\": \"^1.1.3\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"lerna\": \"2.0.0-beta.30\"\r\n  }\r\n}\r\n```\r\n\r\nThis was mainly surprising because `lerna init` appears to know what it's doing when performing the \"upgrade\":\r\n\r\n```\r\n`lerna.json` does not exist, have you run `lerna init`?\r\n> lerna init\r\nLerna v2.0.0-beta.30\r\nUpdating package.json.\r\nCreating lerna.json.\r\nRemoving old VERSION file.\r\nSuccessfully created Lerna files\r\n```\r\n\r\n----\r\n\r\nIIUC this problem will be somewhat resolved if https://github.com/lerna/lerna/pull/370 lands for 2.x, as I believe the existing version of `lerna` in `dependencies` will be updated rather than a new one added to `devDependencies`. The problem is that when 2.x is released most existing users will end up with `lerna` in their `dependencies` rather than `devDependencies`, where it probably belongs.\r\n\r\nI'd suggest that @joscha's usecase should be considered an edgecase, \"advanced\" usage. I think any \"damage\" for such users would be mitigated if the init script informs the user \"moving lerna to devDependencies\" like it does with \"Removing old VERSION file.\". Most users end up with lerna in the right location, a small subset of users has to move the dependency back to `dependencies`.\r\n\r\nAlso possible to be \"smart\" and only invoke this forced move from `dependencies` to `devDependencies` if it's detected the user is upgrading from lerna 1.x to 2.x e.g. user has a VERSION file or current version of `lerna` in `dependencies` is 1.x.\r\n"},"comment":{"url":"https://api.github.com/repos/lerna/lerna/issues/comments/261042481","html_url":"https://github.com/lerna/lerna/issues/401#issuecomment-261042481","issue_url":"https://api.github.com/repos/lerna/lerna/issues/401","id":261042481,"user":{"login":"thejameskyle","id":952783,"avatar_url":"https://avatars.githubusercontent.com/u/952783?v=3","gravatar_id":"","url":"https://api.github.com/users/thejameskyle","html_url":"https://github.com/thejameskyle","followers_url":"https://api.github.com/users/thejameskyle/followers","following_url":"https://api.github.com/users/thejameskyle/following{/other_user}","gists_url":"https://api.github.com/users/thejameskyle/gists{/gist_id}","starred_url":"https://api.github.com/users/thejameskyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejameskyle/subscriptions","organizations_url":"https://api.github.com/users/thejameskyle/orgs","repos_url":"https://api.github.com/users/thejameskyle/repos","events_url":"https://api.github.com/users/thejameskyle/events{/privacy}","received_events_url":"https://api.github.com/users/thejameskyle/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T19:14:03Z","updated_at":"2016-11-16T19:14:03Z","body":"It might be better to just use whatever field it is already installed into. So if Lerna was installed in `dependencies` we'll just continue to use `dependencies`"}}
{"actor":{"display_login":"thejameskyle"}}