GithubHelp home page GithubHelp logo

analogjupiter / reloaded-vibes Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 26 KB

๐Ÿ”„ Smart auto-reloading service and server for web development

License: Boost Software License 1.0

D 86.17% JavaScript 13.83%
d reloading browser websockets web-development-tools filesystemwatcher

reloaded-vibes's Introduction

Reloaded Vibes D Code Club - Discord server

Reloaded Vibes is a smart auto-reloading service and server for (web) development.

It watches a directory for changes and notifies web browsers (or other client applications) through its WebSocket server. This way those clients can respond to the change and e.g. reload the page so that they'll display the recent changes made by the user.

Are you're tired of hitting the refresh button again and again while developing?

Then Reloaded Vibes is the app you're looking for: It watches your project for changes and automatically triggers a refresh in your web browser. Moreover, it's possible to execute command lines before. This allows to schedule the runs of preprocessors (like Sass or Less) and source compilers or any other apps and scripts.

Plain and simple

This is Reloaded Vibes main design goal. It's achieved by not using complicated config or recipe files. Instead everything is configured by command line arguments.

What's more?

It features a built-in webserver for serving static files. Utilizing it's script-injection feature it can automatically insert the script loader into your HTML pages, so you don't have to take care of it manually.

Usage

Command line

./rlv --watch=<DIRECTORY TO WATCH> --action=<COMMANDLINE>
Option Example values Explanation
--watch=<DIR> source, ../ Directories to watch changes.
--action=<CMD> "npm run build",
./myScript.sh
Command lines to execute before triggering a refresh.

Visit http://<SOCKET NOTIFICATION SERVICE>/test to try it out on the test page.

Multiple directories or actions

./rlv --watch=<DIR_1> --watch=<DIR_2> --action=<CMD_1> --action=<CMD_2>

Just specify the respective arguments multiple times.

Custom socket for the notification service

./rlv --watch=<DIRECTORY TO WATCH> --socket=<SOCKET>
Option Example values Explanation
--socket=<SOCKET> 127.0.0.1:3001,
[::1]:3001
Socket to bind the notification service to.

Built-in webserver

./rlv --watch=<DIRECTORY TO WATCH> --webserver=<SOCKET> --htdocs=<DOCUMENT ROOT>
Option Example values Explanation
--webserver=<SOCKET> 127.0.0.1:3002,
[::1]:3002
Socket to bind the built-in webserver to.
--htdocs=<DIR> public/,
/var/www/mysite
Document root path for the built-in webserver.
--noinject Disables injection of the script loader.
Automatic script-injection

Injects a script loader (<script></script>) into HTML files that allows the automatical setup of Reloaded Vibes. Those will need a .html file extension, plus a </body> closing tag.

This feature is enabled by default for the built-in webserver. Pass --noinject to disable it.

No service ("offline") mode

Use Reloaded Vibes to execute commands on changes - with networking disabled.

./rlv --watch=<DIRECTORY TO WATCH> --action=<COMMANDLINE> --noservice
Option Example values Explanation
--noservice Disables to notification service. Reloaded Vibes will still watch for changes and execute the specified actions.

Website

Copy the following code into your webpage's HTML <body> and adjust the URL specified in the src attribute.

<script src="http://<NOTIFICATION SERVICE>/reloaded-vibes.js"></script>

You can also open the notification service's index page in your browser and copy the pre-configured <script> tag from there.

Alternative: see the automatic script-injection of the built-in webserver.

Setup

Prerequisites

  1. Install your favorite D compiler
  2. Check whether DUB came bundled with it. If not, install DUB.

Build

git clone https://github.com/voidblaster/reloaded-vibes.git
cd reloaded-vibes
dub build --build=release

You can find the built executable inside the bin/ directory

Acknowledgements

  • rejectedsoftware
    • vibe.d
      • vibe.d is a high-performance asynchronous I/O, concurrency and web application toolkit written in D.
      • License: MIT
      • Copyright (c) 2012-2019, rejectedsoftware e.K.
  • Jan Jurzitza (@WebFreak001)
    • FSWatch
      • A cross-platform folder & file watching library using win32, inotify or std.file
      • License: BSL-1.0
      • Copyright ยฉ 2016, webfreak
  • Viktor (@dayllenger)

Packaging

Please note that while the source code of Reloaded Vibes itself is available under the Boost Software License 1.0, its dependency vibe.d is licensed under the terms of the MIT public license that also affects the final binary. Ask your laywer for an explanation or details.

reloaded-vibes's People

Contributors

0xeab avatar lempiji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

aberba lempiji

reloaded-vibes's Issues

Startup output is a mess

  • Actions get executed during startup. Thereby their output is printed on the terminal ahead of anything else. Should be the other way round.
  • Also there's no separator in between of the action's log and the startup-info.
    [./src/asdf/xyz.js] 1.64 KiB {main} [built]
        [./src/app.js] 182ms -> factory:2ms building:67ms = 251ms
    Reloaded Vibes
    
    Watching:                src
    

Do not reload when actions fail

RV shouldn't trigger a reload when any of the specified actions fail.

Otherwise the reload might refresh away a working version to some non-working one in some cases.

Error with new compiler

Dependency packages are outdated, so building them will result in deprecated warnings and errors.

Compiler : 2.098.0
OS: Windows10

Cmd: dub build reloaded-vibes

Errors:

C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\internal\memory_legacy.d(154,3): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\internal\memory_legacy.d(166,3): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\internal\memory_legacy.d(832,3): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\internal\memory_legacy.d(866,3): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\utils\array.d(653,2): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
C:\...\vibe-d-0.8.6\vibe-d\utils\vibe\internal\memory_legacy.d(9,8): Error: module `std.exception` import `enforceEx` not found, did you mean template `std.exception.enforce(E : Throwable = Exception) if (is(typeof(new E("", string.init, size_t.init)) : Throwable) || is(typeof(new E(string.init, size_t.init)) : Throwable))`?

Relative parent paths crash FSWatch

./reloaded-vibes --watch=../ --webserver=127.0.0.1:3002 --htdocs=test

core.exception.AssertError@../../.dub/packages/fswatch-0.4.0/fswatch/source/fswatch.d(307): inotify_add_watch returned invalid watch descriptor. Error code 28
----------------
??:? _d_assert_msg
../../.dub/packages/fswatch-0.4.0/fswatch/source/fswatch.d:308 void fswatch.FileWatch.addWatch(immutable(char)[])
../../.dub/packages/fswatch-0.4.0/fswatch/source/fswatch.d:331 fswatch.FileChangeEvent[] fswatch.FileWatch.getEvents()
../../.dub/packages/fswatch-0.4.0/fswatch/source/fswatch.d:288 ref fswatch.FileWatch fswatch.FileWatch.__ctor(immutable(char)[], bool, bool)
source/reloadedvibes/watcher.d:26 reloadedvibes.watcher.Watcher reloadedvibes.watcher.Watcher.__ctor(immutable(char)[][])
source/reloadedvibes/app.d:101 _Dmain

CLI usage example looks weird when app name is shorter/longer than 20 characters

Reproduce

Version: v0.1.2
Command: rv or rv --help

2 chars

  Example:
    rv --socket=127.0.0.1:3001
                         --watch=./src            --watch=./sass
                         --action="npm run build" --action="./refreshDB.sh"

20 chars

  Example:
    ./bin/reloaded-vibes --socket=127.0.0.1:3001
                         --watch=./src            --watch=./sass
                         --action="npm run build" --action="./refreshDB.sh"

Socket with no port leads to range violation

./bin/reloaded-vibes --watch=test --webserver=127.0.0.1 --htdocs=test
core.exception.RangeError@source/reloadedvibes/utils.d(75): Range violation
----------------
??:? _d_arrayboundsp [0x1936f672]
source/reloadedvibes/utils.d:75 pure @safe bool reloadedvibes.utils.tryParseSocket(immutable(char)[], out reloadedvibes.utils.Socket) [0x1918f55e]
source/reloadedvibes/app.d:143 _Dmain [0x191707fe]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.