Skip to content
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

Read -pkg.el file prior to package-file while exists #21

Merged
merged 6 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## 0.7.x (Unreleased)
> Released N/A

* Avoid loading package info unless it's needed (#13)
* Avoid loading package info unless it's needed (#13, #14, and #19)
* Read `-pkg.el` file prior to package-file while exists (#21)

## 0.6.17
> Released Mar 5, 2022
Expand Down
40 changes: 28 additions & 12 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ the `eask-start' execution.")
;; Just in case, but this should never happens!
"latest"))

(defun eask-pkg-el ()
"Return package description file if exists."
(let ((pkg-el (package--description-file default-directory)))
(when (file-readable-p pkg-el) pkg-el)))

;;
;;; Flag

Expand Down Expand Up @@ -657,14 +662,24 @@ Eask file in the workspace."
(if eask-package-file
(eask-error "Multiple definition of `package-file'")
(setq eask-package-file (expand-file-name file))
(if (file-exists-p eask-package-file)
(progn
(with-temp-buffer
(insert-file-contents eask-package-file)
(setq eask-package-desc (ignore-errors (package-buffer-info))))
(unless eask-package-desc
(eask-warn "Failed to construct package-descriptor, lint the package-file `%s'" file)))
(eask-warn "Package-file seems to be missing `%s'" file))))
(let* ((package-file-exists (file-exists-p eask-package-file))
(def-point (if (eask-pkg-el) "-pkg.el file" "package-file"))
(target-file (cond ((eask-pkg-el) (expand-file-name (eask-pkg-el)))
(package-file-exists eask-package-file))))
(unless package-file-exists
(eask-warn "Package-file seems to be missing `%s'" file))
(when target-file
(with-temp-buffer
(insert-file-contents target-file)
(setq eask-package-desc (ignore-errors
(if (eask-pkg-el)
(package--read-pkg-desc 'dir)
(package-buffer-info)))))
(eask-msg (concat
(if eask-package-desc "✓ " "✗ ")
"Try constructing the package-descriptor (%s)... "
(if eask-package-desc "succeed! " "failed!"))
jcs090218 marked this conversation as resolved.
Show resolved Hide resolved
(file-name-nondirectory target-file))))))

(defun eask-files (&rest patterns)
"Set files patterns."
Expand Down Expand Up @@ -1010,13 +1025,14 @@ Standard is, 0 (error), 1 (warning), 2 (info), 3 (log), 4 or above (debug)."
"Return errors if required metadata is missing."
(unless eask-package (eask-error "Missing metadata package; make sure you have create Eask-file with $ eask init!")))

(defun eask--check-strings (fmt f p)
(defun eask--check-strings (fmt f p &rest args)
"Test strings (F and P); then print FMT if not equal."
(unless (string= f p) (eask-warn fmt f p)))
(unless (string= f p) (apply #'eask-warn (append (list fmt f p) args))))

(defun eask--checker-metadata ()
"Report warnings if metadata doesn't match."
(when (and eask-package eask-package-desc)
(when-let* (((and eask-package eask-package-desc))
(def-point (if (eask-pkg-el) "-pkg.el file" "package-file")))
(eask--check-strings
"Unmatch package name '%s'; it should be '%s'"
(eask-package-name) (package-desc-name eask-package-desc))
Expand All @@ -1037,7 +1053,7 @@ Standard is, 0 (error), 1 (warning), 2 (info), 3 (log), 4 or above (debug)."
(eask-warn "Unmatch dependency '%s'; add (depends-on \"%s\") to Eask-file or consider removing it" req req)))
(dolist (dep dependencies)
(unless (member dep requirements)
(eask-warn "Unmatch dependency '%s'; add (%s \"VERSION\") to package-file or consider removing it" dep dep))))))
(eask-warn "Unmatch dependency '%s'; add (%s \"VERSION\") to %s or consider removing it" dep dep def-point))))))
jcs090218 marked this conversation as resolved.
Show resolved Hide resolved

(add-hook 'eask-file-loaded-hook #'eask--checker-existence)
(add-hook 'eask-file-loaded-hook #'eask--checker-metadata)
Expand Down
3 changes: 2 additions & 1 deletion lisp/core/info.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
(ansi-cyan (length eask-depends-on-dev)))
(eask-msg (eask-package-description))
(when eask-package-desc
(eask-msg (ansi-cyan (eask--package-desc-url)))
(when-let ((url (eask--package-desc-url)))
(eask-msg (ansi-cyan url)))
(when-let ((keywords (package-desc--keywords eask-package-desc)))
(eask-msg "")
(eask-msg "keywords: %s" (mapconcat #'identity keywords ", "))))
Expand Down