An open API service indexing awesome lists of open source software.

https://github.com/alchemmist/devsyringe

A CLI tool for injecting dynamic values into code or config files based on declarative rules.
https://github.com/alchemmist/devsyringe

automation cli devops golang tui

Last synced: 15 days ago
JSON representation

A CLI tool for injecting dynamic values into code or config files based on declarative rules.

Awesome Lists containing this project

README

          


Favicon Preview Devsyringe

[![Github](https://img.shields.io/badge/alchemmist%2Fdevsyringe-blue?logo=github&label=github&color=blue)](https://github.com/alchemmist/devsyringe)
![Last commit](https://img.shields.io/github/last-commit/alchemmist/devsyringe?style=flat) ![Stars](https://img.shields.io/github/stars/alchemmist/devsyringe?style=flat)
![Forks](https://img.shields.io/github/forks/alchemmist/devsyringe?style=flat)
![License](https://img.shields.io/github/license/alchemmist/devsyringe?style=flat)
![Contributors](https://img.shields.io/github/contributors/alchemmist/devsyringe?style=flat)
![Go](https://img.shields.io/badge/1.24-default?label=Go)
[![Build](https://github.com/alchemmist/devsyringe/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/alchemmist/devsyringe/actions/workflows/build.yaml)

CLI for inject dynamic values into code/config files from external commands using a declarative YAML config. More about this tool in article: «[Devsyringe: Stop Copy-Pasting Dynamic Values](https://alchemmist.xyz/articles/the-devsyringe/)»

## Why?

In many projects, you have parameters like web domains, API tokens, titles, passwords, or UUIDs.
When working in a programming environment, we often use `.env` files and helper libraries:

```python
load_dotenv(find_dotenv())
host = get_env("HOST")
```

This works well when you have a compiler, package manager, or libraries.
But sometimes you need to work with simple HTML files, static configs, or scripts --- where such tools are not available.

Devsyringe solves this problem: it can fetch values from any source and inject them into any target files, making your parameters dynamic without templates.

## Demo


Demo GIF

In this demo we use this compose file:

```yaml
serums:
https_host:
source: ssh -R 80:localhost:3000 serveo.net
mask: https?://[^\s]*?\.serveo\.net\b
targets:
.env:
path: ./.env
clues: ["HOST"]
```

Devsryinge run command, cut vlue from ouput with mask and replace value in target `.env` file under the mask to new. Very simple!

## Installation

1. Install with **Go**:

```sh
go install github.com/alchemmist/devsyringe/cmd/dsy@latest
```

2. Arch from **`AUR`**:
```sh
paru -S devsyringe
# or: yay -S devsyringe
```

3. Mac with `brew`:
```sh
brew tap alchemmist/homebrew-tap
brew install devsyringe
```

Usage

- Commands for preocess cofnig and controll processes, which need to be got injectable values. See table bottom.

-

Use dsy [command] --help for more information about a command.

- Use `dsy` without commands or flags for run TUI with table of processes.
- In TUI you can see table of processes, which devsyringe run. In table you can see status of process (`stoped` or `active`), command for running, `PID` and title.
- Here you can controll processes with hotkeys. Press `?` for see help. You can stop process, delete process, see full ouput of process and so on.
Available commands for process config and controll processes:



Command
Description




completion
Generate the autocompletion script for the specified shell


delete
If not stopped, stop. Then delete process with [title] from list and delete all logs.


help
Help about any command


inject
Start an injection based on some config


list
Show dynamic list of running processes


logs
Show logs from process with [title]


stop
Stop process with [title], but save logs and keep in list


## Configuration

Devsyringe uses a **YAML file** (usually named `devsyringe.yaml`) to describe what commands to run,
how to extract values from their output, and where to inject them.

### Top-level structure

```yaml
serums:
:
source:
mask:
max-timeout:
targets:
:
path:
clues: [, , ...]
```

`serums` — the root section. Each child key under serums defines a serum (a dynamic value you want to manage).

`` — unique name of the serum (e.g. localtunnel, https_host, ping-test).

| Option | Type | Description | Example |
| ------------- | --------- | --------------------------------------------------------------------------------------------------- | ------------------------------- |
| `source` | string | Command to run. Its output will be scanned to extract values. | `lt --port 80` |
| `mask` | regex | Regular expression to capture the desired part of the output. If omitted, the whole output is used. | `https://[a-z0-9\-]+\.loca\.lt` |
| `max-timeout` | int (sec) | Maximum time to wait for `source` output before failing. | `5` |
| `targets` | map | Where to inject the extracted value(s). Each target has its own settings. | see below |

**Targets:**
Each serum may inject values into one or multiple files.

```yaml
targets:
:
path:
clues: [, , ...]
```

`` — arbitrary name for readability (e.g. env, js, config).

`path` — relative or absolute path to the file to update.

`clues` — list of words/markers that help Devsyringe find the right place in the file to replace.

### Examples

**Exampel 1** -- Localtunnel URL injection:

```yaml
serums:
localtunnel:
source: lt --port 80
mask: https://[a-z0-9\-]+\.loca\.lt
targets:
.env:
path: test/.env
clues: ["HOST"]
js:
path: test/static.js
clues: ["const", "url"]
```

**Example 2** -- SSH serveo tunnel with timeout:

```yaml
serums:
https_host:
source: ssh -R 80:localhost:3000 serveo.net
mask: https?://[^\s]*?\.serveo\.net\b
max-timeout: 5
targets:
.env:
path: ./.env
clues: ["HOST"]
js:
path: ./static/scanner.js
clues: ["const", "url"]
```

## Contribution

If you run into any issues or have any suggestions, open a Pull Request that includes the updates and I'll review/comment/merge it as soon as I can. If you don't have enough time or don't know how to fix the issue, submit an Issue and provide as much detail as you can.

For any questions, mail at: anton.ingrish@gmail.com