├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── logo ├── icon.png ├── icon.svg ├── logotype_horizontal.png ├── logotype_horizontal.svg ├── logotype_vertical.png ├── logotype_vertical.svg └── onecolor.png ├── shard.yml ├── spec ├── sentry-run_spec.cr └── spec_helper.cr └── src ├── sentry-run.cr └── sentry-run ├── sentry-config.cr └── version.cr /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/ 2 | /lib/ 3 | /bin/ 4 | /.shards/ 5 | /shard.lock 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: crystal 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Faustino Aguilar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

sentry-run

2 | 3 | [![Build Status](https://travis-ci.org/faustinoaq/sentry-run.svg?branch=master)](https://travis-ci.org/faustinoaq/sentry-run) 4 | 5 | A shard using [Sentry](https://github.com/samueleaton/sentry) for reload code changes with `Sentry.run`. 6 | 7 | ## Installation 8 | 9 | Add this to your application's `shard.yml`: 10 | 11 | ```yaml 12 | development_dependencies: 13 | sentry-run: 14 | github: faustinoaq/sentry-run 15 | ``` 16 | 17 | Then run `shards update`. 18 | 19 | ## Usage 20 | 21 | 1. Create a new process with `process = Sentry.config(...)` 22 | 2. Execute `Sentry.run(process) do ... end` 23 | 24 | ```crystal 25 | require "kemal" 26 | require "sentry-run" 27 | 28 | get "/" do 29 | "Hello world" 30 | end 31 | 32 | process = Sentry.config( 33 | process_name: "App", 34 | build_command: "crystal", 35 | run_command: "./bin/app", 36 | build_args: ["build", "src/app.cr", "-o", "bin/app"], 37 | run_args: ["-p", "9000"]) 38 | 39 | Sentry.run(process) do 40 | Kemal.run 41 | end 42 | ``` 43 | 44 | You can use `Sentry.run` for recompile and reload your code without external `sentry.cr`. 45 | 46 | Default values: 47 | 48 | ``` 49 | process_name : String 50 | build_command : String 51 | run_command : String 52 | build_args = [] of String 53 | run_args = [] of String 54 | files = ["src/**/*.cr", "src/**/*.ecr"] 55 | should_build = true 56 | ``` 57 | 58 | ## How does it work? 59 | 60 | Basically this shard checks a `sentry.lock` file. 61 | 62 | When you run your code `Sentry.run` create a `sentry.lock` and then yield a block. After a code change Sentry recompiles your file and rerun a new app instance with `run_command` in `Sentry.config`. 63 | 64 | ## Contributing 65 | 66 | 1. Fork it ( https://github.com/faustinoaq/sentry-run/fork ) 67 | 2. Create your feature branch (git checkout -b my-new-feature) 68 | 3. Commit your changes (git commit -am 'Add some feature') 69 | 4. Push to the branch (git push origin my-new-feature) 70 | 5. Create a new Pull Request 71 | 72 | ## Disclaimer 73 | 74 | `Sentry.run` is intended for use in a development environment. 75 | 76 | ## Contributors 77 | 78 | - [faustinoaq](https://github.com/faustinoaq) Faustino Aguilar - creator, maintainer 79 | -------------------------------------------------------------------------------- /logo/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faustinoaq/sentry-run/6daa03a870746857d3c41929ebccc62fd3a13642/logo/icon.png -------------------------------------------------------------------------------- /logo/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 11 | 26 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /logo/logotype_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faustinoaq/sentry-run/6daa03a870746857d3c41929ebccc62fd3a13642/logo/logotype_horizontal.png -------------------------------------------------------------------------------- /logo/logotype_horizontal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 17 | 22 | 27 | 31 | 36 | 40 | 45 | 50 | 51 | 52 | 53 | 55 | 57 | 72 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /logo/logotype_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faustinoaq/sentry-run/6daa03a870746857d3c41929ebccc62fd3a13642/logo/logotype_vertical.png -------------------------------------------------------------------------------- /logo/logotype_vertical.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 20 | 27 | 32 | 36 | 40 | 45 | 49 | 54 | 58 | 59 | 61 | 63 | 78 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /logo/onecolor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faustinoaq/sentry-run/6daa03a870746857d3c41929ebccc62fd3a13642/logo/onecolor.png -------------------------------------------------------------------------------- /shard.yml: -------------------------------------------------------------------------------- 1 | name: sentry-run 2 | version: 0.3.0 3 | 4 | authors: 5 | - Faustino Aguilar 6 | 7 | dependencies: 8 | sentry: 9 | github: samueleaton/sentry 10 | version: ~> 0.3.0 11 | 12 | license: MIT 13 | -------------------------------------------------------------------------------- /spec/sentry-run_spec.cr: -------------------------------------------------------------------------------- 1 | require "./spec_helper" 2 | 3 | describe Sentry do 4 | it "create sentry.lock" do 5 | File.write(Sentry::LOCK, "") 6 | exists? = File.exists? Sentry::LOCK 7 | exists?.should eq(true) 8 | end 9 | 10 | it "delete sentry.lock" do 11 | File.delete Sentry::LOCK 12 | exists? = File.exists? Sentry::LOCK 13 | exists?.should eq(false) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/spec_helper.cr: -------------------------------------------------------------------------------- 1 | require "spec" 2 | require "../src/sentry-run" 3 | -------------------------------------------------------------------------------- /src/sentry-run.cr: -------------------------------------------------------------------------------- 1 | require "./sentry-run/*" 2 | 3 | module Sentry 4 | 5 | LOCK = "sentry.lock" 6 | 7 | # Check if `sentry.lock` exists then yield a block 8 | # If it doesn't exist then create a lock and execute a Sentry process. 9 | # When a Sentry process is finished the `sentry.lock` file is deleted 10 | # because Signal::INT has a trap for Ctrl+C and `at_exit` is executed. 11 | def self.run(process : Sentry::ProcessRunner) 12 | Signal::INT.trap { exit } 13 | if File.exists?(LOCK) 14 | yield 15 | else 16 | File.write(LOCK, "") 17 | at_exit { File.delete(LOCK) } 18 | process.run 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /src/sentry-run/sentry-config.cr: -------------------------------------------------------------------------------- 1 | require "sentry" 2 | 3 | # Sentry config wrapper to create a new Sentry process 4 | module Sentry 5 | def self.config(process_name : String, 6 | build_command : String, 7 | run_command : String, 8 | build_args = [] of String, 9 | run_args = [] of String, 10 | files = ["src/**/*.cr", "src/**/*.ecr"], 11 | should_build = true) 12 | Sentry::ProcessRunner.new( 13 | process_name, 14 | build_command, 15 | run_command, 16 | build_args, 17 | run_args, 18 | files, 19 | should_build) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /src/sentry-run/version.cr: -------------------------------------------------------------------------------- 1 | module Sentry::Run 2 | VERSION = "0.3.0" 3 | end 4 | --------------------------------------------------------------------------------