qiwi / multi-semantic-release

Proof of concept that wraps semantic-release to work with monorepos.
BSD Zero Clause License
86 stars 34 forks source link

CLI flags not taking any effect when also defined in `.releaserc.js` file #78

Closed csantos-nydig closed 2 years ago

csantos-nydig commented 2 years ago

Issue type

Expected behavior

flags passed to the CLI should override props configured in the config file when its passed down to semantic-release

Actual behavior

.releaserc.js config file is overriding the CLI glags

Steps to reproduce

I have a .releaserc.js with say this configuration:

module.exports = {
  branch: 'main',
  branches: [
    { name: 'alpha', prerelease: true },
    { name: 'beta', prerelease: true },
    'main',
    'next'
  ],
  debug: true,
  dryRun: false,
};

and I'm trying to run this command locally

NPM_TOKEN=my-token-with-write-access GITHUB_TOKEN=my-token-with-write-access multi-semantic-release --ci --debug --dry-run

While I see this at the start of my script (which is ok)

multi-semantic-release version: 3.17.1
semantic-release version: 17.4.7
flags: {
  "ignorePackages": [],
  "ci": true,
  "debug": true,
  "dryRun": true, //// HERE!
  "sequentialInit": false,
  "sequentialPrepare": false,
  "firstParent": false,
  "deps": {
    "bump": "override",
    "release": "patch"
  },
  "tagFormat": "${name}@${version}"
}

semantic-release gets dryRun: false THERE 👇 https://github.com/qiwi/multi-semantic-release/blob/888cb37426f5e0c6a93079e78e68476be046c0ea/lib/multiSemanticRelease.js#L202

Possible solution

https://github.com/qiwi/multi-semantic-release/blob/888cb37426f5e0c6a93079e78e68476be046c0ea/lib/multiSemanticRelease.js#L184

I believe the order must be:

const options = { ...pkgOptions, ...flags, ...inlinePlugin };
antongolub commented 2 years ago

@GeeWizWow,

Could you take a look?

GeeWizWow commented 2 years ago

Hey @antongolub PR is open in #80.

FYI @csantos-nydig debug can only be passed to sem-rel via CLI flags, as a result it does not do anything in your .releaserc.js file, see debug in the sem-rel docs.

qiwibot commented 2 years ago

:tada: This issue has been resolved in version 6.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

csantos-nydig commented 2 years ago

Hey @antongolub PR is open in #80.

FYI @csantos-nydig debug can only be passed to sem-rel via CLI flags, as a result it does not do anything in your .releaserc.js file, see debug in the sem-rel docs.

Thanks for the quick fix. I wonder if https://github.com/qiwi/multi-semantic-release/issues/79 is resolved by this change as well?

GeeWizWow commented 2 years ago

Thanks for the quick fix. I wonder if https://github.com/qiwi/multi-semantic-release/issues/79 is resolved by this change as well?

Given that debug can only be enabled in semrel via the CLI entrypoint, which msr bypasses, instead using the programmatic entrypoint, #79 Would need be covered by a separate PR.

It would essentially require msr to lift code directly from the semrel codebase, specifically these lines:

https://github.com/semantic-release/semantic-release/blob/587bb91c9a0a9f8eaab18c3ee4ef9f1cea9a8b48/cli.js#L50-L53

Which may or may not be desirable, I can see arguments for both, I and agree the current behaviour highlighted in #79 is misleading.