mirror of
https://github.com/janet-lang/janet
synced 2025-11-17 15:57:12 +00:00
Revert support for bundles without an info file
This commit is contained in:
@@ -4222,7 +4222,9 @@
|
|||||||
(put new-env *syspath* fixed-syspath)
|
(put new-env *syspath* fixed-syspath)
|
||||||
(with-env new-env
|
(with-env new-env
|
||||||
(put new-env :bundle-dir (bundle-dir bundle-name)) # get the syspath right
|
(put new-env :bundle-dir (bundle-dir bundle-name)) # get the syspath right
|
||||||
(require (string "@syspath/bundle/" bundle-name)))))
|
(try
|
||||||
|
(require (string "@syspath/bundle/" bundle-name))
|
||||||
|
([_] (error "bundle must contain bundle.janet or bundle/init.janet"))))))
|
||||||
|
|
||||||
(defn- do-hook
|
(defn- do-hook
|
||||||
[module bundle-name hook & args]
|
[module bundle-name hook & args]
|
||||||
@@ -4338,30 +4340,33 @@
|
|||||||
# Detect bundle name
|
# Detect bundle name
|
||||||
(def infofile-src1 (string path s "bundle" s "info.jdn"))
|
(def infofile-src1 (string path s "bundle" s "info.jdn"))
|
||||||
(def infofile-src2 (string path s "info.jdn"))
|
(def infofile-src2 (string path s "info.jdn"))
|
||||||
(def infofile-src (if (fexists infofile-src1) infofile-src1 infofile-src2))
|
(def infofile-src (cond
|
||||||
(assert (fexists infofile-src) "bundle must contain info.jdn or bundle/info.jdn")
|
(fexists infofile-src1) infofile-src1
|
||||||
|
(fexists infofile-src2) infofile-src2))
|
||||||
(def info (-?> infofile-src slurp parse))
|
(def info (-?> infofile-src slurp parse))
|
||||||
(def bundle-name (get config :name (get info :name)))
|
(def bundle-name (get config :name (get info :name)))
|
||||||
(assertf bundle-name "unable to infer bundle name for %v, use :name argument" path)
|
(assertf bundle-name
|
||||||
|
"unable to infer bundle name for %v, use :name argument or add :name to info file" path)
|
||||||
(assertf (not (string/check-set "\\/" bundle-name))
|
(assertf (not (string/check-set "\\/" bundle-name))
|
||||||
"bundle name %v cannot contain path separators" bundle-name)
|
"bundle name %v cannot contain path separators" bundle-name)
|
||||||
(assert (next bundle-name) "cannot use empty bundle-name")
|
(assert (next bundle-name) "cannot use empty bundle-name")
|
||||||
(assertf (not (fexists (get-manifest-filename bundle-name)))
|
(assertf (not (fexists (get-manifest-filename bundle-name)))
|
||||||
"bundle %v is already installed" bundle-name)
|
"bundle %v is already installed" bundle-name)
|
||||||
# Check initfile
|
# Check bscript
|
||||||
(def initfile-src1 (string path s "bundle" s "init.janet"))
|
(def bscript-src1 (string path s "bundle" s "init.janet"))
|
||||||
(def initfile-src2 (string path s "bundle.janet"))
|
(def bscript-src2 (string path s "bundle.janet"))
|
||||||
(def initfile-src (if (fexists initfile-src1) initfile-src1 initfile-src2))
|
(def bscript-src (cond
|
||||||
(assert (fexists initfile-src) "bundle must contain bundle.janet or bundle/init.janet")
|
(fexists bscript-src1) bscript-src1
|
||||||
|
(fexists bscript-src2) bscript-src2))
|
||||||
# Setup installed paths
|
# Setup installed paths
|
||||||
(prime-bundle-paths)
|
(prime-bundle-paths)
|
||||||
(os/mkdir (bundle-dir bundle-name))
|
(os/mkdir (bundle-dir bundle-name))
|
||||||
# Copy aliased infofile
|
# Copy aliased infofile
|
||||||
(when (fexists infofile-src2)
|
(when (fexists infofile-src2)
|
||||||
(copyfile infofile-src2 (bundle-file bundle-name "info.jdn")))
|
(copyfile infofile-src2 (bundle-file bundle-name "info.jdn")))
|
||||||
# Copy aliased initfile
|
# Copy aliased bscript
|
||||||
(when (fexists initfile-src2)
|
(when (fexists bscript-src2)
|
||||||
(copyfile initfile-src2 (bundle-file bundle-name "init.janet")))
|
(copyfile bscript-src2 (bundle-file bundle-name "init.janet")))
|
||||||
# Copy some files into the new location unconditionally
|
# Copy some files into the new location unconditionally
|
||||||
(def implicit-sources (string path s "bundle"))
|
(def implicit-sources (string path s "bundle"))
|
||||||
(when (= :directory (os/stat implicit-sources :mode))
|
(when (= :directory (os/stat implicit-sources :mode))
|
||||||
@@ -4370,13 +4375,14 @@
|
|||||||
(merge-into man config)
|
(merge-into man config)
|
||||||
(sync-manifest man)
|
(sync-manifest man)
|
||||||
(edefer (do (print "installation error, uninstalling") (bundle/uninstall bundle-name))
|
(edefer (do (print "installation error, uninstalling") (bundle/uninstall bundle-name))
|
||||||
(def deps (seq [d :in (get info :dependencies @[])]
|
(when info
|
||||||
(string (if (dictionary? d) (get d :name) d))))
|
(def deps (seq [d :in (get info :dependencies @[])]
|
||||||
(def missing (filter (complement bundle/installed?) deps))
|
(string (if (dictionary? d) (get d :name) d))))
|
||||||
(when (next missing)
|
(def missing (filter (complement bundle/installed?) deps))
|
||||||
(error (string "missing dependencies " (string/join missing ", "))))
|
(when (next missing)
|
||||||
(put man :dependencies deps)
|
(error (string "missing dependencies " (string/join missing ", "))))
|
||||||
(put man :info info)
|
(put man :dependencies deps)
|
||||||
|
(put man :info info))
|
||||||
(def module (get-bundle-module bundle-name))
|
(def module (get-bundle-module bundle-name))
|
||||||
(def clean (get config :clean))
|
(def clean (get config :clean))
|
||||||
(def check (get config :check))
|
(def check (get config :check))
|
||||||
|
|||||||
@@ -117,15 +117,15 @@
|
|||||||
(assert (= 0 (length (bundle/list))) "bundles are listed correctly 7")
|
(assert (= 0 (length (bundle/list))) "bundles are listed correctly 7")
|
||||||
(assert (= 0 (length (bundle/topolist))) "bundles are listed correctly 8")
|
(assert (= 0 (length (bundle/topolist))) "bundles are listed correctly 8")
|
||||||
|
|
||||||
# Try installing a bundle that is missing initfile
|
# Try installing a bundle that is missing bundle script
|
||||||
(assert-error-value "bad test"
|
(assert-error-value "bundle missing bundle script"
|
||||||
"bundle must contain bundle.janet or bundle/init.janet"
|
"bundle must contain bundle.janet or bundle/init.janet"
|
||||||
(bundle/install "./examples/sample-bad-bundle1"))
|
(bundle/install "./examples/sample-bad-bundle1"))
|
||||||
(assert (= 0 (length (bundle/list))) "check failure 0")
|
(assert (= 0 (length (bundle/list))) "check failure 0")
|
||||||
(assert (= 0 (length (bundle/topolist))) "check failure 1")
|
(assert (= 0 (length (bundle/topolist))) "check failure 1")
|
||||||
|
|
||||||
# Try installing a bundle that fails check
|
# Try installing a bundle that fails check
|
||||||
(assert-error-value "bad test"
|
(assert-error-value "bundle check hook fails"
|
||||||
"Check failed!"
|
"Check failed!"
|
||||||
(bundle/install "./examples/sample-bad-bundle2" :check true))
|
(bundle/install "./examples/sample-bad-bundle2" :check true))
|
||||||
(assert (= 0 (length (bundle/list))) "check failure 0")
|
(assert (= 0 (length (bundle/list))) "check failure 0")
|
||||||
|
|||||||
Reference in New Issue
Block a user