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

fix(publish): Support --tag-version-prefix in --canary mode #2435

Merged
merged 2 commits into from May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions commands/publish/__tests__/publish-canary.test.js
Expand Up @@ -32,7 +32,7 @@ const lernaPublish = require("@lerna-test/command-runner")(require("../command")
// stabilize commit SHA
expect.addSnapshotSerializer(require("@lerna-test/serialize-git-sha"));

async function initTaggedFixture(fixtureName) {
async function initTaggedFixture(fixtureName, tagVersionPrefix = "v") {
const cwd = await initFixture(fixtureName);

if (fixtureName.indexOf("independent") > -1) {
Expand All @@ -44,7 +44,7 @@ async function initTaggedFixture(fixtureName) {
gitTag(cwd, "package-5@5.0.0"),
]);
} else {
await gitTag(cwd, "v1.0.0");
await gitTag(cwd, `${tagVersionPrefix}1.0.0`);
}

return cwd;
Expand Down Expand Up @@ -111,6 +111,21 @@ Object {
`);
});

test("publish --canary --tag-version-prefix='abc'", async () => {
const cwd = await initTaggedFixture("normal", "abc");

await setupChanges(cwd, ["packages/package-1/all-your-base.js", "belong to us"]);
await lernaPublish(cwd)("--canary", "--tag-version-prefix", "abc");

expect(writePkg.updatedVersions()).toMatchInlineSnapshot(`
Object {
"package-1": 1.0.1-alpha.0+SHA,
"package-2": 1.0.1-alpha.0+SHA,
"package-3": 1.0.1-alpha.0+SHA,
}
`);
});

test("publish --canary <semver>", async () => {
const cwd = await initTaggedFixture("normal");

Expand Down
2 changes: 1 addition & 1 deletion commands/publish/index.js
Expand Up @@ -358,7 +358,7 @@ class PublishCommand extends Command {

const makeVersion = fallback => ({ lastVersion = fallback, refCount, sha }) => {
// the next version is bumped without concern for preid or current index
const nextVersion = semver.inc(lastVersion, release.replace("pre", ""));
const nextVersion = semver.inc(lastVersion.replace(this.tagPrefix, ""), release.replace("pre", ""));

// semver.inc() starts a new prerelease at .0, git describe starts at .1
// and build metadata is always ignored when comparing dependency ranges
Expand Down