Skip to content

Commit

Permalink
move shadow-cljs CLI to :node-library
Browse files Browse the repository at this point in the history
the reason it used :npm-module has been gone for years.

probably going to regret this in some way in case people use
global installs but there is a warning for this now so should
be fine.
  • Loading branch information
thheller committed Jun 6, 2020
1 parent abff5b6 commit 5b354c5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion npm-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

console.log("process-pid", process.pid);

var lib = require("./packages/shadow-cljs/cli/dist/shadow.cljs.npm.cli.js");
var lib = require("./packages/shadow-cljs/cli/dist.js");
lib.main(process.argv.slice(2));

3 changes: 1 addition & 2 deletions packages/shadow-cljs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cli/lib.js
cli/dist/
cli/dist.js
node_modules
4 changes: 2 additions & 2 deletions packages/shadow-cljs/cli/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var root = process.cwd();
// replicate default node resolve which looks in parent directories as well
// so you can run it from $PROJECT/src/foo and have it pick up $PROJECT/node_modules
for (;;) {
var test = path.resolve(root, "node_modules", "shadow-cljs", "cli", "dist", "shadow.cljs.npm.cli.js")
var test = path.resolve(root, "node_modules", "shadow-cljs", "cli", "dist.js")

if (fs.existsSync(test)) {
localLib = test;
Expand All @@ -39,7 +39,7 @@ if (localLib != null) {
// console.log("shadow-cljs - using global version")

// this throws if not found right?
lib = require("./dist/shadow.cljs.npm.cli.js");
lib = require("./dist.js");
}

if (lib == null) {
Expand Down
6 changes: 3 additions & 3 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

:builds
{:cli
{:target :npm-module
:entries [shadow.cljs.npm.cli]
:output-dir "packages/shadow-cljs/cli/dist"
{:target :node-library
:exports {:main shadow.cljs.npm.cli/main}
:output-to "packages/shadow-cljs/cli/dist.js"

:devtools
{:enabled false}}
Expand Down
15 changes: 6 additions & 9 deletions src/main/shadow/cljs/npm/cli.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(js/process.stderr.write (str (->> args (map str) (str/join " ")) "\n")))

(def jar-version
(-> (js/require "../../package.json")
(-> (js/require "../package.json")
(gobj/get "jar-version")))

(defn file-older-than [a b]
Expand Down Expand Up @@ -114,11 +114,8 @@
(js/process.exit 1)
))))

(def default-config-str
(util/slurp (path/resolve js/__dirname ".." "default-config.edn")))

(def default-config
(reader/read-string default-config-str))
(defn default-config-str []
(util/slurp (path/resolve js/__dirname "default-config.edn")))

(defn ensure-config []
(loop [root (path/resolve)]
Expand All @@ -143,7 +140,7 @@

(when (rl-sync/keyInYN "Create?")
;; FIXME: ask for default source path, don't just use one
(fs/writeFileSync config default-config-str)
(fs/writeFileSync config (default-config-str))
(log "shadow-cljs - created default configuration")
config
)))
Expand Down Expand Up @@ -521,7 +518,7 @@
(defn print-cli-info [project-root config-path {:keys [cache-root source-paths] :as config} opts]
(println "=== Version")
(println "jar: " jar-version)
(println "cli: " (-> (js/require "../../package.json")
(println "cli: " (-> (js/require "../package.json")
(gobj/get "version")))
(println "deps: " (-> (js/require "shadow-cljs-jar/package.json")
(gobj/get "version")))
Expand Down Expand Up @@ -789,7 +786,7 @@
(catch :default e
(println "WARNING: package.json not found. See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install"))))

(defn ^:export main [args]
(defn main [args]

(try
(let [{:keys [action options] :as opts}
Expand Down

0 comments on commit 5b354c5

Please sign in to comment.