Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Neise committed Jan 5, 2016
0 parents commit 6846109
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pom.xml
*jar
/lib/
/classes/
/out/
/release/
/target/
.lein-deps-sum
.lein-repl-history
.lein-plugins/
node_modules
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# hello-npm

FIXME: Write a one-line description of your library/project.

## Overview

FIXME: Write a paragraph about the library/project and highlight its goals.

## Setup

Most of the following scripts require [rlwrap](http://utopia.knoware.nl/~hlub/uck/rlwrap/) (on OS X installable via brew).

Build your project once in dev mode with the following script and then open `index.html` in your browser.

./scripts/build

To auto build your project in dev mode:

./script/watch

To start an auto-building Node REPL:

./scripts/repl

To get source map support in the Node REPL:

lein npm install

To start a browser REPL:

1. Uncomment the following lines in src/hello_npm/core.cljs:
```clojure
;; (defonce conn
;; (repl/connect "http://localhost:9000/repl"))
```
2. Run `./scripts/brepl`
3. Browse to `http://localhost:9000` (you should see `Hello world!` in the web console)
4. (back to step 3) you should now see the REPL prompt: `cljs.user=>`
5. You may now evaluate ClojureScript statements in the browser context.

For more info using the browser as a REPL environment, see
[this](https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments#browser-as-evaluation-environment).

Clean project specific out:

lein clean
Build a single release artifact with the following script and then open `index_release.html` in your browser.

./scripts/release

## License

Copyright © 2015 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>hello-npm</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script src="out/hello_npm.js" type="text/javascript"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions index_release.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>hello-npm</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script src="release/hello_npm.js" type="text/javascript"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "hello-npm",
"version": "0.0.1",
"description": "An example module to illustrate the usage of ClojureScript and npm",
"author": "Maria Geller ",
"main": "lib/hello_npm.js",
"dependencies": {
},
"devDependencies": {
},
"private": true,
"license": "MIT",
"keywords": []
}
13 changes: 13 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(defproject hello-npm "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170" :classifier "aot"
:exclusion [org.clojure/data.json]]
[org.clojure/data.json "0.2.6" :classifier "aot"]]
:jvm-opts ^:replace ["-Xmx1g" "-server"]
:plugins [[lein-npm "0.6.1"]]
:npm {:dependencies [[source-map-support "0.3.2"]]}
:source-paths ["src" "target/classes"]
:clean-targets ["out" "release"]
:target-path "target")
2 changes: 2 additions & 0 deletions scripts/brepl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rlwrap lein trampoline run -m clojure.main scripts/brepl.clj
2 changes: 2 additions & 0 deletions scripts/brepl.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
lein trampoline run -m clojure.main scripts\brepl.clj
13 changes: 13 additions & 0 deletions scripts/brepl.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(require
'[cljs.build.api :as b]
'[cljs.repl :as repl]
'[cljs.repl.browser :as browser])

(b/build "src"
{:main 'hello-npm.core
:output-to "out/hello_npm.js"
:output-dir "out"
:verbose true})

(repl/repl (browser/repl-env)
:output-dir "out")
2 changes: 2 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rlwrap lein trampoline run -m clojure.main scripts/build.clj
2 changes: 2 additions & 0 deletions scripts/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
lein trampoline run -m clojure.main scripts\build.clj
14 changes: 14 additions & 0 deletions scripts/build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(require '[cljs.build.api :as b])

(println "Building ...")

(let [start (System/nanoTime)]
(b/build "src"
{:main 'hello-npm.core
:output-to "out/hello_npm.js"
:output-dir "out"
:verbose true
:target :nodejs})
(println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))


2 changes: 2 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rlwrap lein trampoline run -m clojure.main scripts/release.clj
2 changes: 2 additions & 0 deletions scripts/release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
lein trampoline run -m clojure.main scripts\release.clj
11 changes: 11 additions & 0 deletions scripts/release.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(require '[cljs.build.api :as b])

(println "Building ...")

(let [start (System/nanoTime)]
(b/build "src"
{:output-to "release/hello_npm.js"
:output-dir "release"
:optimizations :advanced
:verbose true})
(println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))
2 changes: 2 additions & 0 deletions scripts/repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rlwrap lein trampoline run -m clojure.main scripts/repl.clj
2 changes: 2 additions & 0 deletions scripts/repl.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
lein trampoline run -m clojure.main scripts\repl.clj
5 changes: 5 additions & 0 deletions scripts/repl.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require
'[cljs.repl :as repl]
'[cljs.repl.node :as node])

(repl/repl (node/repl-env))
2 changes: 2 additions & 0 deletions scripts/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rlwrap lein trampoline run -m clojure.main scripts/watch.clj
2 changes: 2 additions & 0 deletions scripts/watch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
lein trampoline run -m clojure.main scripts\watch.clj
6 changes: 6 additions & 0 deletions scripts/watch.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(require '[cljs.build.api :as b])

(b/watch "src"
{:main 'hello-npm.core
:output-to "out/hello_npm.js"
:output-dir "out"})
13 changes: 13 additions & 0 deletions src/hello_npm/core.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns hello-npm.core
(:require [clojure.browser.repl :as repl]
[cljs.nodejs :as nodejs]))

;; (defonce conn
;; (repl/connect "http://localhost:9000/repl"))

(nodejs/enable-util-print!)

(defn -main [& args]
(println "Hello world!"))

(set! *main-cli-fn* -main)

0 comments on commit 6846109

Please sign in to comment.