Conversation
|
I really really like this. Thanks for doing this. Can you use the name "external" instead of "foreign"? |
src/commands/ImportCommand.js
Outdated
|
|
||
| this.commits.forEach(sha => { | ||
| progressBar.tick(sha); | ||
| const patch = this.foreignExecSync(`git format-patch -1 ${sha} --stdout`) |
There was a problem hiding this comment.
Can you add a comment explaining what is happening here?
Yes, that's a better name. Done. |
README.md
Outdated
| $ lerna import <path-to-external-repository> | ||
| ``` | ||
|
|
||
| Import the package at `<path-to-external-repository>`, with commit history. |
There was a problem hiding this comment.
If we want to be more verbose here, you can mention that the package x is imported into packages/x and maybe an example. You can even use lerna-changelog as the example?
There was a problem hiding this comment.
Added some more detail here. I worry that using lerna-changelog as an example might be confusing, since it has "lerna" in the name, so I continued to use placeholders.
I also lower-cased the section heading to match the changes from @kaicataldo over the weekend (which I've picked up via rebase).
There was a problem hiding this comment.
Yeah you're right - maybe babel would of been a better example but all good
README.md
Outdated
| into `packages/<package-name>`. Original commit authors, dates and messages | ||
| are preserved. Commits are applied to the current branch. | ||
|
|
||
| This is useful for gathering pre-exising standalone packages into a Lerna |
src/commands/ImportCommand.js
Outdated
| if (!packageName) { | ||
| throw new Error(`No package name specified in "${packageJson}"`); | ||
| } | ||
| this.targetDir = "packages/"+packageName; |
There was a problem hiding this comment.
can do packages/${packageName} here
There was a problem hiding this comment.
There was a problem hiding this comment.
Yeah the style has been to usually have whitespace between operators (we should add space-infix-ops)
There was a problem hiding this comment.
we should add
space-infix-ops
|
👍 |
|
Can you add a test that |
|
|
|
Looks like the latest build may have had a spurious failure in one environment. I'm not able to retry. |
Weird, I thought |
|
There's a merge conflict b/c of the last PR |
|
Rebased. |
|
Oh fucking hell, merged another one of your PRs and it needs another rebase. 🃏 |
|
blah I hope it's not because of the readme |
|
Rebased again.
Nope, lerna.js and index.js this time. 😛 |
|
Would be nice to use lerna here and do a canary release - can try a publish manually |
| throw new Error(`Input path "${inputPath}" is not a directory`); | ||
| } | ||
| const packageJson = path.join(externalRepoPath, "package.json"); | ||
| const packageName = require(packageJson).name; |
There was a problem hiding this comment.
Do we want to make a specific error message here or no? (if the package path doesn't have a package.json)
Errored while running ImportCommand.initialize
Error: Cannot find module '/module/package.json'
|
Testing it out locally - do we want have an option to add a prefix or no? Like in babel everything is called maybe like Not a blocker and can be a further improvement |
|
Another simple error we can add in is if you have already imported that repo in before (either by name or git log, package.json, etc) |
7a0afd2 to
7f0ebd9
Compare
|
Rebased, added some tests, did these two things and got it running in node 0.10. |
src/commands/ImportCommand.js
Outdated
|
|
||
| this.targetDir = "packages/" + externalRepoBase; | ||
|
|
||
| let targetDirExists; |
There was a problem hiding this comment.
this block could be
try {
fs.statSync(this.targetDir);
} catch (e) {
return callback(new Error(`Target directory already exists "${this.targetDir}"`));
}right?
There was a problem hiding this comment.
Yeah, I spent some time trying to come up with a simpler check here. What you posted above is nicer looking, but it is actually the inverse of what we want: It returns an error when the target directory does not exist.
There was a problem hiding this comment.
Oh right my bad, read the code again now.
How about
try {
if (fs.statSync(this.targetDir)) {
return callback(new Error(`Target directory already exists "${this.targetDir}"`));
}
} catch (e) { /* Pass */ }This is a nit anyway :)
There was a problem hiding this comment.
I like it! Always glad to be rid of a variable. 👹
|
There's a docs fix to add, but other than that I'm good with landing this and we can improve as it's tested/used? |
|
Need to rebase again and back out the changes to support node 0.10. |
Imports a package with git history from a foreign repository.
This is necessary for compatibility with lerna#188.
Also add tests for error messages
|
Rebased and updated docs. |
That last commit in lerna#173 updated _one_ reference to package name, but missed another.
That last commit in #173 updated _one_ reference to package name, but missed another.
* feature/pkg-main: Bootstrap: copy `main` property from package.json 2.0.0-beta.23 fix execSync use Add `onlyExplicitUpdates` flag so that only packages that have changed have version bumps rather than all packages that depend on the updated packages (lerna#241) Re-introduce node 0.10 support (lerna#248) 2.0.0-beta.22 Consistent naming in README `import` section (lerna#243) [skip ci] Lerna import (lerna#173) Revert "Use sync-exec for node 0.10" (lerna#242) Revert "Fix bootstrap install to use quotes around versions (lerna#235)" 2.0.0-beta.21 Fix bootstrap install to use quotes around versions (lerna#235) typo [skip ci] # Conflicts: # src/commands/BootstrapCommand.js
|
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |

The problem: I have a package in a stand-alone repository that I want to pull into a lerna repo.
The solution:
lerna import.Imports a package from a foreign repository with commit history.