GithubHelp home page GithubHelp logo

eginez / calvin Goto Github PK

View Code? Open in Web Editor NEW
185.0 7.0 9.0 120 KB

A minimalistic build tool for clojurescript projects that does not require the jvm

Shell 1.24% Clojure 98.76%
repl clojurescript planck lumo lein build-tool bootstrap

calvin's Introduction

calvin npm package

A minimalistic build tool for clojurescript in clojurescript that does not require the jvm.

Why?

In conjunction with boostrapped clojurescript calvin aims to enable a clojurescript jvm-less development environment

Current status

  1. Repls: calvin boostraps planck or lumo repls with the proper "classpath" as described in a lein project file
  2. Dependencies: calvin resolves and prints dependencies specified in lein project files
  3. Building: Calvin can now build your cljs project using the lumo build api and your lein-cljsbuild configuration. For more information look at the lumo build api

Installation

  1. Install lumo or planck

  2. Download and install via npm

Getting started

Once calvin is installed you can do this in your terminal

calvin -h

This will print out the help for calvin

Repls

To start one of the boostrapped repls you can

start a lumo repl

calvin repl

start a planck repl

calvin -p planck repl

Any remaining arguments are passed on to lumo/planck, so you can do things like

calvin repl my_script.cljs
calvin repl --dumb-terminal
calvin repl -c src -m my-project.main
calvin repl --socket-repl 3333

Dependencies

To discover the dependecies of a project

calvin deps

Calvin assumes there is a lein project file in the current directory. It will read such file and resolve transitive dependencies

Building

Build will read the cljsbuild :compiler options of yout project.clj file. Please note that some compiler options are not supported by the lumo.build.api

calvin build dev

Using node modules

Assuming npm is installed, here is an example of using an artifact from npm:

  1. Installation
npm install shelljs --save
  1. Invoking
(require '[cljs.nodejs :as node])
(def s (node/require "shelljs"))
(.echo s "foo")
  1. Latest node_modules inference in ClojureScript

ClojureScript versions 1.9.854 and after can treat node modules as namespaces.

Example cljsbuild configuration in the project.clj:

:cljsbuild {:builds
            {:dev {:source-paths ["src"]
                   :compiler {:output-to "out/main.js"
                              :main some-ns.main
                              :target :nodejs
                              ;; :npm-deps causes to treat node
                              ;; modules as proper name spaces
                              :npm-deps {:shelljs "0.7.8"}}}}}

Now the specified node module can be required like a ClojureScript namespace.

(require 'shelljs)
(shelljs/echo "foo")

Hacking

Calvin uses Figwheel for interactive development:

 lein figwheel
 node out/dev/figwheel-server.js

calvin's People

Contributors

abhi18av avatar alepeino avatar arichiardi avatar asukiaaa avatar eginez avatar iku000888 avatar plexus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

calvin's Issues

Read :source-paths from project.clj

Hello! Great project, with great potential, let's make a better lein ๐Ÿ‘

A problem I would like to report. I started calvin repl and everything works, except the fact that I cannot execute (require 'a-namespace.core), where the namespace file resides in:

src
โ””โ”€โ”€ a-namespace
    โ””โ”€โ”€ core.cljs

I am going to check your code as well ;)

implement the new command from lein

This one seems pretty straight forward, the templates are in clojars, and they are specified as mustache templates
There are few templating engines in nodejs and even in cljs already so no need to write those.
Download the template, and render it

Some project.clj files not readable/error not friendly?

Exact steps:

  1. Paste the below project.clj in a fresh directory
  2. run calvin repl containing the project.clj
  3. Get an error

project.clj

(defproject iku000888/schema "1.1.7-SNAPSHOT"
  :description "Clojure(Script) library for declarative data description and validation"
  :url "http://github.com/plumatic/schema"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                  [org.clojure/clojurescript "1.9.908"]
                                  ;;[org.clojure/clojurescript "0.0-2760"]
                                  ;;[org.clojure/tools.nrepl "0.2.5"]
                                  [org.clojure/test.check "0.9.0"]
                                  [potemkin "0.4.1"]
                                  [com.cemerick/piggieback "0.2.2"]]
                   :plugins [;;[cljsee "0.1.0"]
                             [codox "0.8.8"]
                             [lein-cljsbuild "1.1.7"]
                             [com.cemerick/clojurescript.test "0.3.1"]]
                   :cljsee {:builds [{:source-paths ["src/cljx"]
                                      :output-path "target/generated/src/clj"
                                      :rules :clj}
                                     {:source-paths ["src/cljx"]
                                      :output-path "target/generated/src/cljs"
                                      :rules :cljs}
                                     {:source-paths ["test/cljx"]
                                      :output-path "target/generated/test/clj"
                                      :rules :clj}
                                     {:source-paths ["test/cljx"]
                                      :output-path "target/generated/test/cljs"
                                      :rules :cljs}]}}
             :1.8 {:dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/clojurescript "0.0-3308"]]}
             :1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha5"] [org.clojure/clojurescript "0.0-3308"]]}}

  :aliases {"all" ["with-profile" "dev:dev,1.8:dev,1.9"]
            ;;"deploy" ["do" "clean," "cljsee" "once," "deploy" "clojars"]
            "test" ["do" "clean,"
                    ;;"cljsee" "once,"
                    "test," "with-profile" "dev" "cljsbuild" "test"]}

  :jar-exclusions [#"\.cljx|\.swp|\.swo|\.DS_Store"]

  :lein-release {:deploy-via :shell
                 :shell ["lein" "deploy"]}

  :auto-clean false

  ;;:source-paths ["target/generated/src/clj" "src/clj"]
  :source-paths ["src/clj" "src/cljx"]

  ;;:resource-paths ["target/generated/src/cljs"]

  ;;:test-paths ["target/generated/test/clj" "test/clj"]
  :test-paths ["test/cljx" "test/clj"]

  :cljsbuild {:test-commands {"unit" ["phantomjs" :runner
                                      "this.literal_js_was_evaluated=true"
                                      "target/unit-test.js"]
                              "unit-no-assert" ["phantomjs" :runner
                                                "this.literal_js_was_evaluated=true"
                                                "target/unit-test-no-assert.js"]}
              :builds
              {:dev {:source-paths ["src/clj" "src/cljx"]
                     :compiler {:output-to "target/main.js"
                                :optimizations :whitespace
                                :pretty-print true}}
               :test {:source-paths ["src/clj" "test/clj"
                                     "src/cljx" "test/cljx"
                                     ;;"target/generated/src/cljs"
                                     ;;"target/generated/test/cljs"
                                     ]
                      :compiler {:output-to "target/unit-test.js"
                                 :optimizations :whitespace
                                 :pretty-print true}}
               :test-no-assert
               {:source-paths ["src/clj" "test/clj"
                               "src/cljx" "test/cljx"
                               ;;"target/generated/src/cljs"
                               ;;"target/generated/test/cljs"
                               ]
                :assert false
                :compiler {:output-to "target/unit-test-no-assert.js"
                           :optimizations :whitespace
                           :pretty-print true}}}}

  :codox {:src-uri-mapping {#"target/generated/src/clj" #(str "src/cljx/" % "x")}
          :src-dir-uri "http://github.com/plumatic/schema/blob/master/"
          :src-linenum-anchor-prefix "L"}

  :signing {:gpg-key "66E0BF75"})

Error Message

/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34968
  var c = cljs.reader.read_token.call(null, a, cljs.reader.read_char.call(null, a)), d = cljs.reader.re_matches_STAR_.call(null, cljs.reader.symbol_pattern, c), c = d[0], e = d[1], d = d[2];
                                                                                                                                                                      ^

TypeError: Cannot read property '0' of null
    at cljs.reader.read_keyword (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34968:167)
    at cljs.reader.read_delimited_list (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34856:33)
    at cljs.reader.read_map (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34888:43)
    at cljs.reader.read_delimited_list (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34856:33)
    at cljs.reader.read_list (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:34875:48)
    at cljs.reader.read (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:35021:37)
    at cljs.reader.read_string (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:35034:27)
    at eginez.calvin.core.find_lein_project_configuration (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:38429:37)
    at Function.eginez.calvin.core._main.cljs$core$IFn$_invoke$arity$variadic (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:38884:62)
    at Function.eginez.calvin.core._main.cljs$lang$applyTo (/usr/local/lib/node_modules/calvin-cljs/prod/index.js:38906:35)

`calvin deps` prints * chars forever on fail

This works

(defproject example "1.0.0"
  :dependencies [[andare "0.5.0"]
                 [macchiato/fs "0.0.6"]]
  )

this doesn't

(defproject example "1.0.0"
  :dependencies [[andare "0.5.0"]
                 [macchiato/fs "0.0.6"]
                 [IDontExists "6.6.6"]]
  )

and will print **** forever into the stdout.

ps. how do I differentiate npm devDependencies and npm dependencies in the project.clj file, how does one go around at all using npm dependencies without needing extra package.json file alongside project.clj?

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.