Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerna import fails when package root is repo root #1872

Closed
wavebeem opened this issue Jan 15, 2019 · 3 comments · Fixed by #1875
Closed

lerna import fails when package root is repo root #1872

wavebeem opened this issue Jan 15, 2019 · 3 comments · Fixed by #1875

Comments

@wavebeem
Copy link
Contributor

wavebeem commented Jan 15, 2019

When we run lerna import ../mycompany-legacy --flatten it fails to import because lerna cannot automatically detect our lerna package root.

Note that we are keeping our lerna packages at the top level of the git repo and requiring all of them to be prefixed with mycompany-. There is no "packages/" directory or similar.

Expected Behavior

Expected that lerna would import mycompany-legacy into the lerna project root directory.

Current Behavior

% yarn lerna import ../mycompany-legacy --flatten
yarn run v1.13.0
$ /Users/brianmock/w/mycompany-editor-frontend/node_modules/.bin/lerna import ../mycompany-legacy --flatten
lerna notice cli v3.8.1
lerna ERR! EDESTDIR --dest does not match with the package directories:
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Possible Solution

The method getPackageDirectories here: https://github.com/lerna/lerna/blob/master/commands/import/index.js#L116-L118

Could be upgraded to return ["."] or similar in the case where no base directory can be found.

Steps to Reproduce (for bugs)

  1. Use a lerna config with the line "packages": ["mycompany-*"]
  2. Try lerna import ../some-other-repo
  3. It fails because it can't find the package root directory
lerna.json

{
  "packages": [
    "mycompany-*"
  ],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "version": "3.24.0-rc.0",
  "command": {
    "publish": {
      "allowBranch": [
        "master",
        "release/*",
        "topic/deploy-junk"
      ]
    }
  }
}

Context

I'm trying to import another repo into our lerna monorepo. I am going to need to work around the issue by importing the package into a temporary directory and then using git mv afterward.

Your Environment

Executable Version
lerna --version 3.8.1
npm --version 6.5.0
yarn --version 1.13.0
node --version 11.6.0
OS Version
macOS Mojave 10.14.2
@wavebeem
Copy link
Contributor Author

I'd be happy to submit a PR for this but I wanted to open this up to feedback first 😄

@evocateur
Copy link
Member

The test coverage is indeed a little sparse around edge cases like this. Make that "completely absent," if I'm being honest. 😅 I don't think anyone anticipated your structure, so a PR is perfectly welcome. :)

@wavebeem
Copy link
Contributor Author

I'm taking a look into a PR for this today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants