diff options
| author | Franck Cuny <franck.cuny@gmail.com> | 2016-08-13 09:04:37 -0700 |
|---|---|---|
| committer | Franck Cuny <franck.cuny@gmail.com> | 2016-08-13 09:04:37 -0700 |
| commit | 44b0a689cdd2ae2f3f34451910eb1f09fd4d65dd (patch) | |
| tree | 5a3588c8928bbd56f426b091b68f17cc533795d1 /posts/2014-02-15-cursive-nrepl-cljs-oh-my.md | |
| parent | Move assets around (diff) | |
| download | lumberjaph-44b0a689cdd2ae2f3f34451910eb1f09fd4d65dd.tar.gz | |
some more clean up.
Diffstat (limited to '')
| -rw-r--r-- | posts/2014-02-15-cursive-nrepl-cljs-oh-my.md | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/posts/2014-02-15-cursive-nrepl-cljs-oh-my.md b/posts/2014-02-15-cursive-nrepl-cljs-oh-my.md index 996d653..4de858d 100644 --- a/posts/2014-02-15-cursive-nrepl-cljs-oh-my.md +++ b/posts/2014-02-15-cursive-nrepl-cljs-oh-my.md @@ -15,15 +15,13 @@ The Intellij IDEA requirement is new. I've never used an IDE before and I've dec I'm pleased to say that after a few hours I had a completely working environment meeting all my requirements. I'm pretty sure this notes will become outdated quickly, so I'll try update this post as I discover more things. -The VM ------- +## The VM I like Vagrant and there's no reason to not use it for this kind of projects. I've created a [repository](https://github.com/franckcuny/devbox) on GitHub with my setup for that. It's a simple VM with VirtualBox and Vagrant. I'm using Ansible to do the provisioning part. After cloning the repository, you can run `vagrant up` and a virtual machine, running Ubuntu 13.10, will be started and provisionned (a bunch of tools like tmux are installed, but what really interest us here is the openjdk). Once it's up, a I run `vagrant ssh` then I start a `tmux` session. -Create a project ----------------- +## Create a project I create a project using the [cljs-start](https://github.com/magomimmo/cljs-start) template for leiningen. To be honest, all the hard work is done by this template, I'm just putting the pieces together to have the setup I want build around it. With this template, you get: @@ -34,8 +32,7 @@ This plugin relies on [Austin](https://github.com/cemerick/austin). All I needed to do was to run `lein new cljs-start project` (where project is the name of my project). -The REPL --------- +## The REPL Once you've started to work with a REPL it's hard to go back to a language that don't have one. When working with Clojure, you get used very quickly to it, especially since nREPL is so nice, and allows you to work on a remote box. @@ -47,14 +44,13 @@ The only tricky thing when setting up the VM is to be sure to forward a few port I run the REPL in headless mode on the VM (in my `tmux` session), from my project's directory: ``` bash - # specify a port that I will be forwarded from my host to the guest - AUSTIN_DEFAULT_SERVER_PORT=4343 lein repl :headless :host 0.0.0.0 :port 4242 +# specify a port that I will be forwarded from my host to the guest +AUSTIN_DEFAULT_SERVER_PORT=4343 lein repl :headless :host 0.0.0.0 :port 4242 ``` The `AUSTIN_DEFAULT_SERVER_PORT` variable is the port that will be used by your REPL to talk to the browser. That's why you need to forward this port in Vagrant. The other options (**host** and **port**) are here to tell the repl to listen on all the interfaces (so I can connect from the host) on the given port. -Editor ------- +## Editor > I'm focusing on Intellij IDEA here, but it works the same with Emacs/[CIDER](https://github.com/clojure-emacs/cider). @@ -62,27 +58,30 @@ To install the Cursive plugin, you need to go to [this page](http://cursivecloju I can now open a project in Intellij and start coding. I've configured my project to use a remote REPL. -[/imgs/remote-nrepl.webp](file:///imgs/remote-nrepl.webp) Now I can connect to the remote REPL and do a quick test to see if it works: + Now I can connect to the remote REPL and do a quick test to see if it works: -[/imgs/test-remote-nrepl.webp](file:///imgs/test-remote-nrepl.webp) Great! It's time to start the web server to serve our static files and see if I can connect the browser-repl to it too. Running the following code in the REPL should do the trick: + -``` example - (run) ;; will start a server with jetty on port 3000, that I can reach from port 4000 - (browser-repl) ;; that’s the *really* cool part +Great! It's time to start the web server to serve our static files and see if I can connect the browser-repl to it too. Running the following code in the REPL should do the trick: + +``` clojure +(run) ;; will start a server with jetty on port 3000, that I can reach from port 4000 +(browser-repl) ;; that’s the *really* cool part ``` If I want to test something, all I have to do is to load the file into the REPL and then call a function. For example: -``` example - (.log js/console "Hi from Intellij IDEA!") +``` clojure +(.log js/console "Hi from Intellij IDEA!") ``` and see the output in my browser's console! -[/imgs/nrepl-it-works.webp](file:///imgs/nrepl-it-works.webp) When working on the project, I can run evaluate the file or a form and send it to the browser. Again, this would be the same with Emacs, instead of having CIDER to use a local nREPL session, you'll just connect to a remote one. + + +When working on the project, I can run evaluate the file or a form and send it to the browser. Again, this would be the same with Emacs, instead of having CIDER to use a local nREPL session, you'll just connect to a remote one. -Conclusion ----------- +## Conclusion I realize that it's not the easiest setup. I'm maintaining the build system we have at work for our sites; we use javascript and nodejs, and I'm really upset by the complexity of our process. If I had to put with all of that to build a site I would be pretty mad. Still, I think this setup can be simplified a lot. But using a VM also makes it easier to give a working environment to a new developer, and it's easy to throw it away, after all, I'm using it mostly to run the REPL and to have it working in an environment similar to what it would be in production. |
