-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc improvements to lumo build #7
Conversation
20c31da
to
83e34ae
Compare
I don't know how to change it against |
:let [k (keyword (str/replace k #"^-{1,2}" "")) | ||
k (cli-option-map k k)]] | ||
[k (parse-option k v)]))) | ||
(for [[k v] (partition 2 argv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I will fix this change, it slipped in.
index.js
Outdated
@@ -52,8 +52,13 @@ function basepath(config, service, opts) { | |||
|
|||
function cljsLambdaBuild(serverless, opts) { | |||
const fns = slsToCljsLambda(serverless.service.functions, opts); | |||
const compiler = _.get(serverless.service, 'custom.cljs-compiler'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyphenated keys are going to look out of place in a serverless.yml. Please use lumo: true
.
index.js
Outdated
if (process.env.SLS_DEBUG) { | ||
serverless.cli.log(`Compiler is set to: ${compiler}`); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gratuitous, it will fail immediately if the compiler is incompatible with the project, so we don't need a log message.
(doseq [d (zip-opts :dirs)] | ||
(.directory archiver d)) | ||
(.file archiver (zip-opts :index) #js {:name "index.js"}) | ||
(doseq [d (:dirs zip-opts)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the log messages, it makes the code noisy and is not particularly helpful here.
(.file archiver (zip-opts :index) #js {:name "index.js"}) | ||
(doseq [d (:dirs zip-opts)] | ||
(js/console.log "adding directory %s" (.stringify js/JSON (clj->js d))) | ||
(if (string? d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this conditional and always assume a directory is a string. If we need this in the future for some reason, we can add it.
|
||
(defn write-index [content outpath] | ||
(js/console.log "writing %s..." outpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these log messages.
|
||
(defn ^:export -main [& args] | ||
(let [opts (cli-options *command-line-args*) | ||
conf (read-conf!)] | ||
(build! opts (merge-with merge default-config (read-conf!))))) | ||
file-config (read-conf!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove these log calls.
(js/console.log "config is %s" (.stringify js/JSON (clj->js config) nil 2)) | ||
(.then (build! opts config) | ||
#(js/console.log "zip created: %s" %1) | ||
#(js/console.error "Error:" (.-message %1))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please set the process exit code to 1
if we catch an error here.
(.on output-stream "close" #(resolve-fn output-path)) | ||
(.on archiver "warning" #(if (= (.-code %1) "ENOENT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a function with named parameters.
Why remove? It is so so useful when you have problems, you can ask a user to execute to send the output of the "Executing:" command..don't you think?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
@arichiardi That hasn't been my experience - it's not helpful enough to justify the clutter. The serverless plugin logs the parameters it's passing to the script - everything else that's being logged could just as well be obtained by asking for the config file, or asking for a directory listing. |
Ok, I can do that but I feel you really close for future kinds of compilers. And then you need to push a major version for the change? What is the advantage of a boolean?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I can use camel case
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
If you prefer that, use camel case. |
I think it makes more sense. Will change it.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Ok will remove the commit.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
748cb7d
to
a590a65
Compare
Ok addressed all the change requests and added some doc to the README |
Thanks - why is 1.7.0+ required, just so I know? |
Because there is was a breaking change from lumo.core/command-line-args to cljs.core. We could actually support both namespaces in our code but 1.7.0 will be broken unless we use an unmangled get on global. |
@arichiardi Why are we using |
The reason is node sends all the args, even the ones passed to lumo itself and we don't want those. Sure I can tweak that. |
Yeah, let's work around it. |
This patch allows to specify the cljs compiler of the build. At the moment only lumo is the alternative to the default JVM compiler (which requires lein), but in the future others can be added (a vanilla cljs script, shadow-cljs, boot-cljs...).
a590a65
to
b01bac0
Compare
@arichiardi Regarding the fix, is command-line-args empty, or unbound in older versions of lumo? |
Premise: the above works for the three versions regardless, so In |
Btw I have just noticed there that I don't need |
Presumably you can use the unmangled syntax to refer to the lumo.core var - |
@moea not that would not work in |
b01bac0
to
35e7093
Compare
If |
Good point! Maybe it is not |
I mean if you just add |
No I don't think it can work because the However the global JS object is filled up at runtime so we can query it. |
If the namespace is required, you will get a compiler warning about an undefined var, and nil at runtime. Please make the change. |
Will do, probably more verbose and uglier than what is now, but hey, you're the boss 😄 |
35e7093
to
2e817c3
Compare
Awesome, it seems like it is nice and working now 😉 |
* Add lumo script for deploying self-host lambdas (#6) * Simplify option parsing, misc. fixes * Working end-to-end example * Misc improvements to lumo build (#7) * Handle archive warning * Use apply for sequable :files entries in zip! * Make keyword lookup idiomatic * Handle custom.cljsCompiler option in serverless.yml This patch allows to specify the cljs compiler of the build. At the moment only lumo is the alternative to the default JVM compiler (which requires lein), but in the future others can be added (a vanilla cljs script, shadow-cljs, boot-cljs...). * Add Lumo compiler section to README * Work-around lumo's command-line-args bug and support all versions * Use `simple` template for `advanced` compilation * 0.2.0
This patch adds various improvements to the lumo build, notably:
custom.cljsCompiler
option in serverless.yml