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
Increment version by semver keyword with --cd-version flag #607
Changes from 3 commits
f05e704
b0abdb4
f1f031f
916f329
b8f2ef3
4906409
6f73862
cef1634
1aec9b8
fb6d2cb
762a33b
bac6568
88cf53b
9f678d2
0919778
41f5d9d
addbf8d
254e679
29def98
bdd03e5
fb1dd8f
dcff07d
57c6a3e
9c655af
b56b14c
a76dbcf
7278490
88cc4bc
24cbcde
a545ef3
664f1b6
8ff033b
109356c
33f555d
f564d43
403a326
0a8d213
1ed379f
dda2c02
6b33324
f385531
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,6 +204,85 @@ describe("PublishCommand", () => { | |
} | ||
})); | ||
}); | ||
|
||
it("should use semver increments when passed to repoVersion flag", (done) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion, but feel it would be worth refactoring these tests to smaller assertion blocks / calls rather than the larger fixture > result chunks. CLI tools with lots of arg permutations is hard to test all paths There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds interesting, but not sure I understand clearly. Can you give an example of how you'd like to see it organized? |
||
const publishCommand = new PublishCommand([], { | ||
independent: true, | ||
repoVersion: "patch" | ||
}); | ||
|
||
publishCommand.runValidations(); | ||
publishCommand.runPreparations(); | ||
|
||
assertStubbedCalls([ | ||
[ChildProcessUtilities, "execSync", {}, [ | ||
{ args: ["git tag"] } | ||
]], | ||
[PromptUtilities, "confirm", { valueCallback: true }, [ | ||
{ args: ["Are you sure you want to publish the above changes?"], returns: true } | ||
]], | ||
[ChildProcessUtilities, "execSync", {}, [ | ||
{ args: ["git add " + escapeArgs(path.join(testDir, "packages/package-1/package.json"))] }, | ||
{ args: ["git add " + escapeArgs(path.join(testDir, "packages/package-2/package.json"))] }, | ||
{ args: ["git add " + escapeArgs(path.join(testDir, "packages/package-3/package.json"))] }, | ||
{ args: ["git add " + escapeArgs(path.join(testDir, "packages/package-4/package.json"))] }, | ||
{ args: ["git commit -m \"$(echo \"Publish" + EOL + EOL + " - package-1@1.0.1" + EOL + " - package-2@2.0.1" + EOL + " - package-3@3.0.1" + EOL + " - package-4@4.0.1\")\""] }, | ||
{ args: ["git tag package-1@1.0.1"] }, | ||
{ args: ["git tag package-2@2.0.1"] }, | ||
{ args: ["git tag package-3@3.0.1"] }, | ||
{ args: ["git tag package-4@4.0.1"] } | ||
]], | ||
[ChildProcessUtilities, "exec", { nodeCallback: true }, [ | ||
{ args: ["cd " + escapeArgs(path.join(testDir, "packages/package-1")) + " && npm publish --tag lerna-temp"] }, | ||
{ args: ["cd " + escapeArgs(path.join(testDir, "packages/package-3")) + " && npm publish --tag lerna-temp"] }, | ||
{ args: ["cd " + escapeArgs(path.join(testDir, "packages/package-4")) + " && npm publish --tag lerna-temp"] }, | ||
{ args: ["cd " + escapeArgs(path.join(testDir, "packages/package-2")) + " && npm publish --tag lerna-temp"] } | ||
], true], | ||
[ChildProcessUtilities, "execSync", {}, [ | ||
{ args: ["npm dist-tag ls package-1"], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-1 lerna-temp"] }, | ||
{ args: ["npm dist-tag add package-1@1.0.1 latest"] }, | ||
|
||
{ args: ["npm dist-tag ls package-3"], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-3 lerna-temp"] }, | ||
{ args: ["npm dist-tag add package-3@3.0.1 latest"] }, | ||
|
||
{ args: ["npm dist-tag ls package-4"], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-4 lerna-temp"] }, | ||
{ args: ["npm dist-tag add package-4@4.0.1 latest"] }, | ||
|
||
{ args: ["npm dist-tag ls package-2"], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-2 lerna-temp"] }, | ||
{ args: ["npm dist-tag add package-2@2.0.1 latest"] }, | ||
|
||
{ args: ["git symbolic-ref --short HEAD"], returns: "master" }, | ||
{ args: ["git push origin master"] }, | ||
{ args: ["git push origin package-1@1.0.1 package-2@2.0.1 package-3@3.0.1 package-4@4.0.1"] } | ||
]], | ||
]); | ||
|
||
publishCommand.runCommand(exitWithCode(0, (err) => { | ||
if (err) return done(err); | ||
|
||
try { | ||
assert.ok(!pathExists.sync(path.join(testDir, "lerna-debug.log"))); | ||
assert.equal(normalizeNewline(fs.readFileSync(path.join(testDir, "lerna.json"), "utf-8")), "{\n \"lerna\": \"__TEST_VERSION__\",\n \"version\": \"independent\"\n}\n"); | ||
|
||
assert.equal(require(path.join(testDir, "packages/package-1/package.json")).version, "1.0.1"); | ||
assert.equal(require(path.join(testDir, "packages/package-2/package.json")).version, "2.0.1"); | ||
assert.equal(require(path.join(testDir, "packages/package-3/package.json")).version, "3.0.1"); | ||
assert.equal(require(path.join(testDir, "packages/package-4/package.json")).version, "4.0.1"); | ||
|
||
assert.equal(require(path.join(testDir, "packages/package-2/package.json")).dependencies["package-1"], "^1.0.1"); | ||
assert.equal(require(path.join(testDir, "packages/package-3/package.json")).devDependencies["package-2"], "^2.0.1"); | ||
assert.equal(require(path.join(testDir, "packages/package-4/package.json")).dependencies["package-1"], "^0.0.0"); | ||
|
||
done(); | ||
} catch (err) { | ||
done(err); | ||
} | ||
})); | ||
}); | ||
}); | ||
|
||
/** ========================================================================= | ||
|
@@ -746,7 +825,7 @@ describe("PublishCommand", () => { | |
{ args: ["npm dist-tag ls package-4", {env: {"npm_config_registry":"https://my-private-registry"}}], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-4 lerna-temp", {env: {"npm_config_registry":"https://my-private-registry"}}] }, | ||
{ args: ["npm dist-tag add package-4@1.0.1 latest", {env: {"npm_config_registry":"https://my-private-registry"}}] }, | ||
|
||
{ args: ["npm dist-tag ls package-2", {env: {"npm_config_registry":"https://my-private-registry"}}], returns: "lerna-temp: 1.0.1\nstable: 1.0.0" }, | ||
{ args: ["npm dist-tag rm package-2 lerna-temp", {env: {"npm_config_registry":"https://my-private-registry"}}] }, | ||
{ args: ["npm dist-tag add package-2@1.0.1 latest", {env: {"npm_config_registry":"https://my-private-registry"}}] }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... actually I wonder if
--repo-version
is the right option for this. That's really meant specifically for non-independent versioning. And actually looking at this again it will only work correctly for independently versioned repos. It won't update theversion
in lerna.json unless the return value fromgetVersionsForUpdates
includes aversion
(singular) value.It might actually be better to add a new option that works for both independent and non-independent repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same thoughts :) This was the easiest point of interception to get this working locally without introducing much new functionality. Stoked maintainers are willing to help guide this one, we really need it. Any suggestions on flag name? I feel it should be fairly straight forward within the same method to intercept and alter the test. I'll get back to you with more suggestions on that first thing next week. As I stated in the comment, definitely tough to get all paths (especially the inverse coverage) when you have many options