Add support for "increment" format to increment an integer version number with support for "increment:semver" to increment the build or patch of a SemVer version number.
Usage:
```json
"versions": [
{
"format": "increment",
"key": "version",
"outfile": "assets.json"
}
]
```
```jsonc
{
"version": 16 // → 17
}
```
```json
"versions": [
{
"format": "increment:semver",
"key": "version",
"outfile": "assets.json"
}
]
```
```jsonc
{
"version": "1.0.0" // → 1.0.1
}
```
```jsonc
{
"version": "1.0.0+1" // → 1.0.0+2
}
```
Separated generic functions from build helpers.
Changed:
- Moved 'utils/*.js' to 'helpers/*.js'
- From 'utils/config.js':
- Moved function `merge` to 'utils/index.js'.
- Moved function `isObjectLike` to 'utils/index.js'.
- From 'utils/template.js':
- Moved function `flatten` to 'utils/index.js'.
- Moved function `escapeRegExp` to 'utils/index.js'.
- From 'tasks/styles.js':
- Moved function `createPostCSSProcessor` to 'helpers/postcss.js' as `createProcessor`.
- Replaced function `Object.assign` with `merge` for task options parsing in all tasks.
Added support for replacing a string in a file using a regular expression.
The routine uses Node's Readline and Stream modules.
The `outfile` will be renamed with a `~` suffix, then stream each line, writing to a new `outfile`.
On success, the backup file (with `~`) is deleted.
On error, any new file is deleted, then the backup file is renamed without a `~` suffix.
Usage:
```json
"versions": [
{
"format": "timestamp",
"key": "regexp:(?<=\bdefine\('ASSETS_VERSION', )[^\)]+(?=\);)",
"outfile": "src/bootstrap.php"
}
]
```
```php
<?php
define( 'ASSETS_VERSION', 1665071717350 );
```
Added:
- Support for writing multiple times to the same file.
- Support for random hexadecimal value instead of timestamp.
Usage:
```json
"versions": [
{
"format": "timestamp",
"key": "now",
"outfile": "./assets.json"
},
{
"format": "hex:8",
"key": "hex",
"outfile": "./assets.json"
}
]
```
```json
{
"now": 1665071717350,
"hex": "6ef54181c4ba"
}
```
A task to allow one to define zero or more JSON files and keys to create or update with the current timestamp.
By default, the boilerplate will maintain a './assets.json' file which should be imported by the Web framework and applied to compiled assets.