Skip to content

Commit

Permalink
refactor: simplify --tag-format flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Cid53 authored and antongolub committed Sep 10, 2021
1 parent 259864c commit 67d28b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CLI flag options:
--ignore-packages Packages list to be ignored on bumping process (append to the ones that already exist at package.json workspaces)
--deps.bump Define deps version updating rule. Allowed: override, satisfy, inherit.
--deps.release Define release type for dependent package if any of its deps changes. Supported values: patch, minor, major, inherit.
--tag-version-format Format to use for the version number applied to tag names. Default: "@${version}" generates "[email protected]"
--tag-format Format to use for creating tag names. Should include "name" and "version" vars. Default: "${name}@${version}" generates "[email protected]"
--help Help info.

Examples
Expand Down
6 changes: 3 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const cli = meow(
--deps.bump Define deps version updating rule. Allowed: override, satisfy, inherit.
--deps.release Define release type for dependent package if any of its deps changes. Supported values: patch, minor, major, inherit.
--ignore-packages Packages' list to be ignored on bumping process
--tag-version-format Format to use for the version number applied to tag names. Default: "@\${version}" generates "[email protected]"
--tag-format Format to use for creating tag names. Should include "name" and "version" vars. Default: "\${name}@\${version}" generates "[email protected]"
--help Help info.
Examples
Expand Down Expand Up @@ -50,9 +50,9 @@ const cli = meow(
ignorePackages: {
type: "string",
},
tagVersionFormat: {
tagFormat: {
type: "string",
default: "@${version}",
default: "${name}@${version}",
},
dryRun: {
type: "boolean",
Expand Down
10 changes: 8 additions & 2 deletions lib/multiSemanticRelease.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { dirname } = require("path");
const semanticRelease = require("semantic-release");
const { uniq } = require("lodash");
const { uniq, template } = require("lodash");
const { check, ValueError } = require("./blork");
const getLogger = require("./getLogger");
const getSynchronizer = require("./getSynchronizer");
Expand Down Expand Up @@ -189,7 +189,13 @@ async function releasePackage(pkg, createInlinePlugin, multiContext, flags) {
// Add the package name into tagFormat.
// Thought about doing a single release for the tag (merging several packages), but it's impossible to prevent Github releasing while allowing NPM to continue.
// It'd also be difficult to merge all the assets into one release without full editing/overriding the plugins.
options.tagFormat = name + (flags.tagVersionFormat || "@${version}");
const tagFormatCtx = {
name,
version: "${version}",
};

const tagFormatDefault = "${name}@${version}";
options.tagFormat = template(flags.tagFormat || tagFormatDefault)(tagFormatCtx);

// This options are needed for plugins that do not rely on `pluginOptions` and extract them independently.
options._pkgOptions = pkgOptions;
Expand Down
2 changes: 1 addition & 1 deletion test/lib/multiSemanticRelease.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ describe("multiSemanticRelease()", () => {
[`packages/a/package.json`],
{},
{ cwd, stdout, stderr },
{ tagVersionFormat: "/${version}", deps: {} }
{ tagFormat: "${name}/${version}", deps: {} }
);

// Get stdout and stderr output.
Expand Down

0 comments on commit 67d28b4

Please sign in to comment.