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

feat: context available in replacement function #167

Conversation

ei-ds
Copy link

@ei-ds ei-ds commented Apr 28, 2022

Make context available in replacement function by binding the function's execution environment to the semantic-release context.

Make `context` available in replacement function by binding the function's execution environment to the `semantic-release` context.
@google-cla
Copy link

google-cla bot commented Apr 28, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@KiwiKilian
Copy link

@ei-ds I would be interested in this feature, are you willing to sign the cla?

jpoehnelt pushed a commit that referenced this pull request Dec 20, 2022
* docs: generate documentation for current HEAD

The documentation was not completely up-to-date with the state of the
code. The URLs now all point back to the main repository.

* test: fix "file contents contain" assertion

This previously only set up a matcher and did not actually assert
anything.

This can be verified by changing to `expect.not.stringContaining` and
seeing whether any tests start to fail.

* feat: support full `from` functionality of `replace-in-file`

To better support configuration through JSON, the default behavior of
`from` for string inputs was previously changed relative to that of the
`replace-in-file` package.

For more advanced use cases, i.e. where a JavaScript configuration file
is used, the full functionality of the `replace-in-file` package is made
available.

* fix: improve typing for multi-argument callback functions for `to`

The `to` callback function can be as simple as a two-argument function
receiving the matched string and the filename it was matched in. However
if `from` is a regular expression, the function arguments may
additionally contain captures, the offset for the matched substring, the
whole string being inspected, etc. This type definition ensures those
functions are accepted, but require providing additional type
information.

* feat: pass the `semantic-release` `Context` to `from` callback functions

Information from the `semantic-release` `Context` may be useful when
determining the which content should be replaced. The `Context` is made
available as the last argument to the callback function.

Alternative implementation of #167.

* feat: pass the `semantic-release` `Context` to `to` callback functions

Information from the `semantic-release` `Context` may be useful when
determining the replacement text. The `Context` is made available as the
last argument to the callback function.

Alternative implementation of #167.

* feat: accept multiple `from` matchers

The underlying `replace-in-file` package accepts multiple matchers to be
passed as an array. This functionality is made available for multiple
basic string and more advanced replacements.

* feat: accept multiple `to` replacements

The underlying `replace-in-file` package accepts multiple replacements
to be passed as an array. This functionality is made available for
multiple basic string replacements and callback functions. When using
multiple replacements the number of replacements needs to be the same as
the number of matchers. Otherwise only a subset of the replacements is
used, e.g. it's not possible to use a single string matcher and provide
multiple replacements.
github-actions bot pushed a commit that referenced this pull request Dec 20, 2022
# [1.2.0](v1.1.0...v1.2.0) (2022-12-20)

### Features

* support more replace-in-file functionality ([#172](#172)) ([429ed59](429ed59)), closes [#167](#167) [#167](#167)
@jpoehnelt
Copy link
Owner

closing in favor of solution in #172

@jpoehnelt jpoehnelt closed this Dec 20, 2022
AsifNawaz-cnic referenced this pull request in centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin Mar 27, 2024
# 1.0.0 (2024-03-27)

### Bug Fixes

* build before release ([36a4632](36a4632))
* build before release ([bef4c0a](bef4c0a))
* **deps:** move lodash to dependencies ([#19](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/19)) ([81c8098](81c8098))
* enables multiline regex mode ([#140](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/140)) ([e14d13f](e14d13f))
* improve error message ([#3](#3)) ([b7871c6](b7871c6))
* **index.ts and index.test.ts:** refactored the plugin to support latest version of semantic release ([618cf92](618cf92))
* rename package ([d105286](d105286))
* switch to esm ([#222](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/222)) ([d785268](d785268))
* trigger release ([5a2606b](5a2606b))
* trigger release ([d1112bd](d1112bd))
* trigger release ([a4bd09f](a4bd09f))
* update package.json ([90c2976](90c2976))

### Features

* add support for passing in `replace-in-file` functions ([#156](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/156)) ([4bfa3c7](4bfa3c7))
* support more replace-in-file functionality ([#172](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/172)) ([429ed59](429ed59)), closes [#167](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/167) [#167](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-replace-plugin/issues/167)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants