Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kros-sk/kros.variablesubstitution
https://github.com/kros-sk/kros.variablesubstitution
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/kros-sk/kros.variablesubstitution
- Owner: Kros-sk
- License: mit
- Created: 2021-05-31T07:23:01.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T14:30:10.000Z (almost 3 years ago)
- Last Synced: 2024-08-31T10:37:15.297Z (4 months ago)
- Language: C#
- Size: 53.7 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# varsub
`varsub` is tool for variable substitutions in JSON files. It was created as a replacement for the [FileTransform](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/file-transform?view=azure-devops) task for DevOps, because it could not process multiple ZIP files at once.
## Installation
`varsub` is implemented as a .NET Global Tool, so its installation is quite simple:
```properties
dotnet tool install -g Kros.VariableSubstitution
```To update it to the latest version, if it was installed previously, use:
```properties
dotnet tool update -g Kros.VariableSubstitution
```## How to use it
```properties
varsub -w d:\Projects\artifacts -j **/appsettings.json
```
### Parameters**--workingDirectory, -w**: Working directory.
**--zipFilesOrDirectories, -f**: Glob pattern to search a list of files or directories.
**--jsonTargetFiles, -j**: Glob pattern to search the target Json files.
**--tempDirectory, -t**: Path to temp directory.
**--variables, -v**: Variables. (var1=value1 var2=value2)
This tool processes all ZIP files that match the `--zipFilesOrDirectories` pattern in working directory. Multiple glob patterns are allowed (`-f *pattern.zip -f **/anotherPattern.zip ...`). Processes all files that match the `--jsonTargetFiles` pattern. By default, it takes variables from environment variables. It tries to find the corresponding property in the JSON object for these variables. If a match is found, it will replace it.
The `--variables` parameter can be used mainly for testing purposes, with which it is possible to define variables and their values (`--variables var1=value1 --variables var2=value2 ...`).
> ⚠ It is not possible to add a new property to a JSON object or a new record to a JSON field using this tool. It only allows the replacement of existing properties.