Description
Related
- Fails with missing GitHub token when --dry-run and --no-ci #261 (comment)
- conventional-changelog-conventionalcommits v8.0.0 breaks semantic release release-notes-generator#633 (comment)
Sure, if we already have a token set up and securely saved somewhere, we can always npx cross-env GITHUB_TOKEN=gh_pat*** npx semantic-release --dry-run
, but sometimes we just can't be bothered to go through the steps of decrypting and copying the token value from secure storage. Or perhaps we don't care about token validation, but still want to dry run all other 'verify conditions'.
potential solutions (requires changes in @semantic-release/semantic-release)
--no-github
? Skip the entire github plugin.
--no-token
? Its implementation in semantic-release's CLI may affect plugins such as @semantic-release/npm.
--no-token=@semantic-release/github,@semantic-release/gitlab,@semantic-release/npm
? Pass comma-separated plugin names to indicate which plugins' token verification should be skipped?
It may be feasible to introduce a startsWith('!')
pattern to remove specific plugins from the options.plugins
before the plugins are passed to and loaded by @semantic-release/semantic-release/lib/plugins/index.js#default.
https://github.com/semantic-release/semantic-release/blob/5f05152fe642f29dda437ce78e1ce3bcb89f1dea/lib/get-config.js#L63-L92
+ // if any PluginSpec is a string and starts with '!', remove all instances of the negated plugins from the array.
+ /** @type { string[] } */
+ const negatedPlugins = options.plugins.filter(v => v[0] === '!');
+
+ options.plugins = options.plugins.filter(
+ // keep plugins whose IDs do not startWith '!'
+ plugin => !(negatedPlugins.includes(plugin))
+ ).filter(
+ // keep plugins that are *not* negated by negatedPlugins
+ plugin => {
+ /** @type { string | [string, Record<keyof any, unknown>] } */
+ const p = plugin;
+ if (typeof p === 'string')
+ return !(negatedPlugins.includes('!' + p));
+ else
+ return !(negatedPlugins.includes('!' + p[0]));
+ }
+ )
+
if (options.ci === false) {
options.noCi = true;
}
debug("options values: %O", options);
return { options, plugins: await plugins({ ...context, options }, pluginsPath) };