Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/crystal-china/sentry

Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes
https://github.com/crystal-china/sentry

Last synced: 4 days ago
JSON representation

Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes

Awesome Lists containing this project

README

        




cubbie!



# Breaking Changes

1. --build-command=COMMAND need specify the build command without args, e.g. crystal
In the configuration file, the corresponding `build` has been changed to `build_command`
2. --build-args=ARGS need specify build string but without the command part, e.g. `build src/sentry_cli.cr -o bin/sentry`
In the configuration file, the corresponding `build` has been changed to `build_args`
3. The `-b` is still keep for backwards compatibility, but without the long-command form,
using `--src=src/foo.cr` is always recommended when there is no `shard.yml`.
4. When build crystal program, if a valid shard.yml was found, will create run command binary in the `./bin`
folder instead of in the project root(`./`) respect the rule of `shards build`.

# New feature

1. Many bugs get fixed.
2. sentry will play a audio file when build success/fail, individually. (Linux only)
3. now, configuration file support settings all options, except `--src`, latter tend to use in command line only,
instead of setting `--build-command` and `--build-args` or `-b` when there is no `shard.yml` exists.

# Sentry 🤖

Build/Runs your crystal application, watches files, and rebuilds/reruns app on file changes

## Installation

Download released binary from [release page](https://github.com/crystal-china/sentry/releases), run it!

### Options

You don't need to set any options if you're using the `shards` to manage build.

```bash
╰──➤ $ sentry
🤖 Your SentryBot is vigilant. beep-boop...
🤖 watching file: ./src/daka/version.cr
🤖 watching file: ./src/daka.cr
🤖 watching file: ./src/records.ecr
🤖 compiling daka...
🤖 starting daka...
[development] Kemal is ready to lead at http://0.0.0.0:3000
```

If you are don't use shards, specify the entry path for the main crystal file use --src should enough.

```bash
sentry --src=src/sentry.cr
```

For the detailed usage, please check following command-line help or check [.sentry.example.yml](./.sentry.example.yml)

```bash
Usage: ./sentry [options]
-n NAME, --name=NAME Sets the display name of the app process (default: sentry)
--src=PATH Sets the entry path for the main crystal file inferred from shard.yml (default: src/sentry_cli.cr)
--build-command=COMMAND Overrides the default build command (default: crystal)
--build-args=ARGS Specifies arguments for the build command (default: build src/sentry_cli.cr -o ./bin/sentry)
-b FULL_COMMAND Set both `BUILD COMMAND' and `BUILD ARGS', for backwards compatibility (default: crystal build src/sentry_cli.cr -o ./bin/sentry)
--no-build Skips the build step
-r COMMAND, --run=COMMAND Overrides the default run command inferred from shard.yml (default: ./bin/sentry)
--run-args=ARGS Specifies arguments for the run command, (default: '')
-w FILE, --watch=FILE Appends to list of watched files, (will overrides default: ["./src/**/*.cr", "./src/**/*.ecr"])
-c FILE, --config=FILE Specifies a file to load for automatic configuration (default: .sentry.yml)
--install Run `shards install' once before running Sentry build and run commands
--no-color Removes colorization from output
--not-play-audio Skips the attempt to play audio file with `aplay' from `alsa-utils' package when building on Linux succeeds or fails
-i, --info Shows the configuration informations
-V, --version Shows version
-h, --help Show this help
```

#### Override Default Files to Watch

```bash
./sentry -w "./src/**/*.cr" -w "./lib/**/*.cr"
```

By specifying files to watch, the default will be omitted. So if you want to watch all of the file in your `src` directory, you will need to specify that like in the above example.

#### Show Info Before Running

This shows the values for the build command, run command, and watched files.

```bash
🤖 Sentry configuration:
display name: sentry
shard name: sentry
src_path: src/sentry_cli.cr
build_command: crystal
build_args: build src/sentry_cli.cr -o ./bin/sentry
run_command: ./bin/sentry
run_args:
watched files: ["./src/**/*.cr", "./src/**/*.ecr"]
colorize: true
run shards install: false
should play audio: true
should build: true
should print info: true
🤖 Your SentryBot is vigilant. beep-boop...
🤖 watching file: ./src/sentry/process_runner.cr
🤖 watching file: ./src/sentry/config.cr
🤖 watching file: ./src/sentry/sound_file_storage.cr
🤖 watching file: ./src/sentry.cr
🤖 watching file: ./src/sentry_cli.cr
🤖 compiling sentry...
🤖 starting sentry...
```

#### Setting Build or Run Arguments

If you prefer granularity, you can specify arguments to the build or run commands using the `--build-args` or `--run-args` flags followed by a string of arguments.

```bash
./sentry -r "crystal" --run-args "spec --debug"
```

#### Running `shards install` Before Starting

This is especially usefull when initiating Sentry from a `Dockerfile` or `package.json` file. It guarantees all the shards are installed before running.

```bash
./sentry --install
```

#### Reading Configurations from a File

Sentry will automatically read configurations from `.sentry.yml` if it exists. This can be changed with `-c FILE` or `--config=FILE`.

See definition in [.sentry.example.yml](./.sentry.example.yml) for valid file properties.

#### Removing Colorization

Sentry output is colorized by default. To remove colorization, pass the `--no-color` argument.

Example

```bash
./sentry --no-color
```

## Sentry Crystal API

See [CRYSTAL_API.md](./CRYSTAL_API.md)

## Why?

(1) It is tiring to have to stop and restart an app on every change.

(2) Docker!

Stop and restarting your app is especially expensive (and annoying) when running the app in a docker container, where one would need to totally rebuild the docker image for every change.

Now, for development, simply run sentry in your docker container, and it will rebuild the app from the docker container on any changes, without rebuilding the docker image/container.

## Contributing

1. Fork it ( https://github.com/samueleaton/sentry/fork )
2. Create your feature branch (git checkout -b feat-my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin feat-my-new-feature)
5. Create a new Pull Request

## Contributors

- [samueleaton](https://github.com/samueleaton) Sam Eaton - creator, maintainer
- [billy](http://github.com/zw963) Billy.Zheng - maintainer

## Disclaimer

Sentry is intended for use in a development environment, where failure is safe and expected 😉.