@j-ulrich/release-it-regex-bumper 2.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Jochen Ulrich
3
+ Copyright (c) 2020-2022 Jochen Ulrich
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  > Regular expression based version read/write plugin for release-it
4
4
 
5
5
  ![CI](https://github.com/j-ulrich/release-it-regex-bumper/workflows/CI/badge.svg)
6
- [![Test Coverage](https://app.codacy.com/project/badge/Coverage/bf3c6e8740a9472b9acd7dac231adf4e)](https://www.codacy.com/manual/j-ulrich/release-it-regex-bumper?utm_source=github.com&utm_medium=referral&utm_content=j-ulrich/release-it-regex-bumper&utm_campaign=Badge_Coverage)
7
- [![Code Quality](https://app.codacy.com/project/badge/Grade/bf3c6e8740a9472b9acd7dac231adf4e)](https://www.codacy.com/manual/j-ulrich/release-it-regex-bumper?utm_source=github.com&utm_medium=referral&utm_content=j-ulrich/release-it-regex-bumper&utm_campaign=Badge_Grade)
6
+ [![Test Coverage](https://app.codacy.com/project/badge/Coverage/bf3c6e8740a9472b9acd7dac231adf4e)](https://www.codacy.com/gh/j-ulrich/release-it-regex-bumper/dashboard?utm_source=github.com&utm_medium=referral&utm_content=j-ulrich/release-it-regex-bumper&utm_campaign=Badge_Coverage)
7
+ [![Code Quality](https://app.codacy.com/project/badge/Grade/bf3c6e8740a9472b9acd7dac231adf4e)](https://www.codacy.com/gh/j-ulrich/release-it-regex-bumper/dashboard?utm_source=github.com&utm_medium=referral&utm_content=j-ulrich/release-it-regex-bumper&utm_campaign=Badge_Grade)
8
8
 
9
9
  This [release-it](https://github.com/release-it/release-it) plugin reads and/or writes versions
10
10
  using regular expressions.
@@ -34,13 +34,13 @@ For example:
34
34
  {
35
35
  "plugins": {
36
36
  "@j-ulrich/release-it-regex-bumper": {
37
- "in": "path/to/versionfile.txt",
37
+ "in": "path/to/version_file.txt",
38
38
  "out": [
39
- "path/to/versionfile.txt",
39
+ "path/to/version_file.txt",
40
40
  {
41
41
  "file": "README.md",
42
42
  "search": "Version \\d+\\.\\d+\\.\\d+",
43
- "replace": "Version {{version}}"
43
+ "replace": "Version {{versionWithoutPrerelease}}"
44
44
  }
45
45
  ]
46
46
  }
@@ -48,7 +48,7 @@ For example:
48
48
  }
49
49
  ```
50
50
 
51
- For a more complex example, see [here](https://gitlab.com/julrich/MockNetworkAccessManager/-/blob/b31fd6d956ab0f61c1017432265e9e1c99a17bee/.release-it.json).
51
+ For a more complex example, see [here](https://gitlab.com/julrich/MockNetworkAccessManager/-/blob/main/.release-it.json).
52
52
 
53
53
 
54
54
  ## Regular Expressions ##
@@ -64,7 +64,8 @@ example, the pattern `\d+` needs to be written as `"\\d+"` inside JSON.
64
64
 
65
65
  ## Configuration Options ##
66
66
 
67
- > **Note:** Options without a default value are required.
67
+ > ℹ️ **Note:**
68
+ > Options without a default value are required.
68
69
 
69
70
  ### `in` ###
70
71
 
@@ -111,12 +112,26 @@ If `in.search` is an object, it takes the following properties:
111
112
 
112
113
  **Type:** `string`
113
114
 
114
- The regular expression pattern to find the version inside `in.file`.
115
+ The regular expression pattern template to find the version inside `in.file`.
115
116
 
116
117
  Capturing groups can be used to extract the version from a part of the whole match. See the
117
118
  documentation of the configuration option `in.search.versionCaptureGroup` for a description of the
118
119
  handling of capturing groups.
119
120
 
121
+ The `in.search.pattern` also supports a set of placeholders (since version 3.0.0):
122
+
123
+ - `{{semver}}` is matching any version string complying to the semantic versioning specification (meaning at least
124
+ "major.minor.patch").
125
+ - `{{now:<format>}}` is matching the current timestamp in a format specified by the `<format>` parameter.
126
+ The supported format syntax can be found in the [date-fns format](https://date-fns.org/v2.8.0/docs/format)
127
+ documentation.
128
+ Example: `{{now:yyyy-MM-dd}}`
129
+ - `{{{}}` is matching a literal `{`. This can be used to match a literal placeholder.
130
+ For example: `{{{}}{foo}}` is matching `{{foo}}`
131
+
132
+ > ℹ️ **Note:**
133
+ > All the placeholders are contained in a non-capturing group (`(?:...)`) so they behave like "atomic" constructs.
134
+
120
135
  ### `in.search.flags` ###
121
136
 
122
137
  **Type:** `string`
@@ -124,6 +139,8 @@ handling of capturing groups.
124
139
 
125
140
  The flags for the regular expression `in.search.pattern`.
126
141
 
142
+ If this option is `null` or not defined, the [global `search.flags`](#searchflags) are used.
143
+
127
144
  ### `in.search.versionCaptureGroup` ###
128
145
 
129
146
  **Type:** `integer|string`
@@ -192,7 +209,7 @@ If both, this option and `out.files` are given, both are processed.
192
209
  **Since:** 1.1.0
193
210
 
194
211
  A path or an array of paths to files where the new version is written to. This option behaves the
195
- same as the `out.file` option but allows specifing multiple files or patterns. Accordingly, the
212
+ same as the `out.file` option but allows specifying multiple files or patterns. Accordingly, the
196
213
  entries are also parsed with [fast-glob](https://github.com/mrmlnc/fast-glob):
197
214
 
198
215
  ```json
@@ -225,7 +242,7 @@ If this option is `null` or not defined, the [global `encoding`](#encoding) opti
225
242
 
226
243
  Defines the regular expression to find the text which is replaced with the new version inside
227
244
  `out.file`.
228
- If this option is `null` or not defined, the [global `search`](#search) option is used.
245
+ If this option is `null` or not defined, the [global `search`](#search) is used.
229
246
 
230
247
  If `out.search` is a string, it is interpreted as the regular expression pattern.
231
248
 
@@ -235,12 +252,45 @@ If `out.search` is an object, it takes the following properties:
235
252
 
236
253
  **Type:** `string`
237
254
 
238
- The regular expression pattern to find the text to be replaced with the new version inside
255
+ The regular expression pattern template to find the text to be replaced with the new version inside
239
256
  `out.file`.
240
257
 
241
258
  In contrast to `in.search.pattern`, capturing groups are not treated special in this pattern. So
242
259
  `out.replace` always replaces the *whole* match.
243
260
 
261
+ If this option is `null` or not defined, the [global `search`](#search) resp.
262
+ [global `search.pattern`](#searchpattern) is used.
263
+
264
+ The `out.search.pattern` also supports a set of placeholders (since version 3.0.0):
265
+
266
+ - `{{version}}` is matching the current version (before the increment).
267
+ - `{{major}}` is matching the major part of the current version.
268
+ - `{{minor}}` is matching the minor part of the current version.
269
+ - `{{patch}}` is matching the patch part of the current version.
270
+ - `{{prerelease}}` is matching the prerelease part of the current version. If the version does
271
+ not have a prerelease part, it is omitted (matching empty string).
272
+ - `{{prefixedPrerelease}}` is matching a dash ('-') followed by the prerelease part of the current version. If the
273
+ version does not have a prerelease part, it is omitted (matching empty string).
274
+ - `{{build}}` is matching the build part of the current version. If the version does not have a
275
+ build part, it is omitted (matching empty string).
276
+ - `{{prefixedBuild}}` is matching a plus ('+') followed by the build part of the current version. If the version
277
+ does not have a build part, it is omitted (matching empty string).
278
+ - `{{versionWithoutBuild}}` is matching the current version without the build part.
279
+ - `{{versionWithoutPrerelease}}` is matching the current version without the prerelease and build parts.
280
+ - `{{tag}}` is matching the current VCS tag (before the bump).
281
+ - `{{newVersion}}` is matching the new version (after the increment).
282
+ - `{{semver}}` is matching any version string complying to the semantic versioning specification (meaning at least
283
+ "major.minor.patch").
284
+ - `{{now:<format>}}` is matching the current timestamp in a format specified by the `<format>` parameter.
285
+ The supported format syntax can be found in the [date-fns format](https://date-fns.org/v2.8.0/docs/format)
286
+ documentation.
287
+ Example: `{{now:yyyy-MM-dd}}`
288
+ - `{{{}}` is matching a literal `{`. This can be used to match a literal placeholder.
289
+ For example: `{{{}}{foo}}` is matching `{{foo}}`
290
+
291
+ > ℹ️ **Note:**
292
+ > All the placeholders are contained in a non-capturing group (`(?:...)`) so they behave like "atomic" constructs.
293
+
244
294
  ### `out.search.flags` ###
245
295
 
246
296
  **Type:** `string`
@@ -248,6 +298,8 @@ In contrast to `in.search.pattern`, capturing groups are not treated special in
248
298
 
249
299
  The flags for the regular expression `out.search.pattern`.
250
300
 
301
+ If this option is `null` or not defined, the [global `search.flags`](#searchflags) are used.
302
+
251
303
  ### `out.replace` ###
252
304
 
253
305
  **Type:** `string`
@@ -263,31 +315,39 @@ XRegExp](http://xregexp.com/syntax/#replacementText).
263
315
 
264
316
  The template string also supports a set of placeholders:
265
317
 
266
- - `{{version}}` is replaced with the new version.
267
- - `{{major}}` is replaced with the major part of the new version.
318
+ - `{{version}}` is replaced by the new version.
319
+ - `{{major}}` is replaced by the major part of the new version.
268
320
  Since: 1.2.0
269
- - `{{minor}}` is replaced with the minor part of the new version.
321
+ - `{{minor}}` is replaced by the minor part of the new version.
270
322
  Since: 1.2.0
271
- - `{{patch}}` is replaced with the patch part of the new version.
323
+ - `{{patch}}` is replaced by the patch part of the new version.
272
324
  Since: 1.2.0
273
- - `{{prerelease}}` is replaced with the prerelease part of the new version.
325
+ - `{{prerelease}}` is replaced by the prerelease part of the new version or an empty string if the version does not
326
+ have a prerelease part.
274
327
  Since: 1.2.0
275
- - `{{build}}` is replaced with the build part of the new version.
328
+ - `{{prefixedPrerelease}}` is replaced by a dash ('-') followed by the prerelease part of the new version or and empty
329
+ string if the version does not have a prerelease part.
330
+ Since: 3.0.0
331
+ - `{{build}}` is replaced by the build part of the new version or an empty string if the version does not have a
332
+ build part.
276
333
  Since: 1.2.0
277
- - `{{versionWithoutBuild}}` is replaced with the new version without the build part.
334
+ - `{{prefixedBuild}}` is replaced by a plus ('+') followed by the build part of the new version or an empty string
335
+ if the version does not have a build part.
336
+ Since: 3.0.0
337
+ - `{{versionWithoutBuild}}` is replaced by the new version without the build part.
278
338
  Since: 1.2.0
279
- - `{{versionWithoutPrerelease}}` is replaced with the new version without the prelease and build
339
+ - `{{versionWithoutPrerelease}}` is replaced by the new version without the prerelease and build
280
340
  parts.
281
341
  Since: 1.2.0
282
- - `{{latestVersion}}` is replaced with the current version, that is the version before the increase.
283
- - `{{latestTag}}` is replaced with the current VCS tag.
284
- - `{{now}}` is replaced with the current timestamp in ISO 8601 format.
285
- - `{{now:<format>}}` is replaced with the current timestamp in a format specified by the `<format>`
342
+ - `{{latestVersion}}` is replaced by the current version, that is the version before the increase.
343
+ - `{{latestTag}}` is replaced by the current VCS tag.
344
+ - `{{now}}` is replaced by the current timestamp in ISO 8601 format.
345
+ - `{{now:<format>}}` is replaced by the current timestamp in a format specified by the `<format>`
286
346
  parameter. The supported format syntax can be found in the [date-fns
287
347
  format](https://date-fns.org/v2.8.0/docs/format) documentation.
288
348
  Example: `{{now:yyyy-MM-dd}}`
289
- - `{{{}}` is replaced with a literal `{`. This can be used to write a literal placeholder.
290
- For example: `{{{}}{foo}}` is replaced with `{{foo}}`
349
+ - `{{{}}` is replaced by a literal `{`. This can be used to write a literal placeholder.
350
+ For example: `{{{}}{foo}}` is replaced by `{{foo}}`
291
351
  Since: 1.2.0
292
352
 
293
353
  The placeholders are replaced before the template string is used in the search and replace and thus
@@ -309,17 +369,26 @@ If `search` is an object, it takes the following properties:
309
369
  ### `search.pattern` ###
310
370
 
311
371
  **Type:** `string`
312
- **Default:** A pattern matching versions according to the semantic version specification.
372
+ **Default:** `"{{semver}}"`
373
+
374
+ The default regular expression pattern template which is used when `in.search.pattern` or
375
+ `out.search.pattern` is `null` or not defined. See [`in.search.pattern`](#insearchpattern) and
376
+ [`out.search.pattern`](#outsearchpattern) for more information.
313
377
 
314
- The default regular expression pattern which is used when `in.search.pattern` or
315
- `out.search.pattern` is `null` or not defined.
378
+ > ⚠️ **Warning:**
379
+ > Note that the global `search.pattern` is used for both `in.search.pattern` and `out.search.pattern` unless
380
+ > overridden explicitly. But `in.search.pattern` does not support all the placeholders of `out.search.pattern` and
381
+ > using unsupported placeholders raises an error.
382
+
383
+ If this option is not defined or set to `null`, the default value is used.
316
384
 
317
385
  ### `search.flags` ###
318
386
 
319
387
  **Type:** `string`
320
388
  **Default:** `null`
321
389
 
322
- The flags for the regular expression `search.pattern`.
390
+ The default flags for the search pattern which are used when `in.search.flags` or
391
+ `out.search.flags` are `null` or not defined.
323
392
 
324
393
  ### `search.versionCaptureGroup` ###
325
394
 
@@ -352,9 +421,18 @@ encodings are the ones supported by Node's `fs` module.
352
421
 
353
422
  If this option is not defined or set to `null`, the default value is used.
354
423
 
424
+ ## Tips ##
425
+
426
+ ### Disable Output via Command-Line Parameter ###
427
+ To completely disable changing any files by the plugin, you can use the command-line parameter `--no-plugins.@j-ulrich/release-it-regex-bumper.out`.
428
+ For example:
429
+ ```
430
+ npx release-it --no-plugins.@j-ulrich/release-it-regex-bumper.out
431
+ ```
432
+
355
433
 
356
434
  # License #
357
435
 
358
- Copyright (c) 2020-2021 Jochen Ulrich
436
+ Copyright (c) 2020-2022 Jochen Ulrich
359
437
 
360
438
  Licensed under [MIT license](LICENSE).