Refactor package managent batch commands
+ Replace message! with print! + doom//packages-* commands now only return t if package list changed
This commit is contained in:
parent
0d9db6f149
commit
61ca98fd3f
1 changed files with 98 additions and 103 deletions
|
@ -26,15 +26,15 @@
|
|||
(condition-case ex2
|
||||
(progn ,@body)
|
||||
('file-error
|
||||
(message! (bold (red " FILE ERROR: %s" (error-message-string ex2))))
|
||||
(message! " Trying again...")
|
||||
(print! (bold (red " FILE ERROR: %s" (error-message-string ex2))))
|
||||
(print! " Trying again...")
|
||||
(quiet! (doom-refresh-packages-maybe t))
|
||||
,@body))
|
||||
('user-error
|
||||
(message! (bold (red " ERROR: %s" ex))))
|
||||
(print! (bold (red " ERROR: %s" ex))))
|
||||
('error
|
||||
(doom--refresh-pkg-cache)
|
||||
(message! (bold (red " FATAL ERROR: %s" ex))))))
|
||||
(print! (bold (red " FATAL ERROR: %s" ex))))))
|
||||
|
||||
(defun doom--refresh-pkg-cache ()
|
||||
"Clear the cache for `doom-refresh-packages-maybe'."
|
||||
|
@ -336,12 +336,11 @@ package.el as appropriate."
|
|||
(defun doom//packages-install ()
|
||||
"Interactive command for installing missing packages."
|
||||
(interactive)
|
||||
(if (not noninteractive)
|
||||
(doom-packages--async-run 'doom//packages-install)
|
||||
(message! "Looking for packages to install...")
|
||||
(doom-initialize-packages)
|
||||
(print! "Looking for packages to install...")
|
||||
(let ((packages (reverse (doom-get-missing-packages))))
|
||||
(cond ((not packages)
|
||||
(message! (green "No packages to install!"))
|
||||
(print! (green "No packages to install!"))
|
||||
nil)
|
||||
|
||||
((not (or (getenv "YES")
|
||||
|
@ -364,44 +363,42 @@ package.el as appropriate."
|
|||
"ELPA"))))
|
||||
(sort (cl-copy-list packages) #'doom--sort-alpha)
|
||||
"\n")))))
|
||||
(message! (yellow "Aborted!"))
|
||||
nil)
|
||||
(error "Aborted!"))
|
||||
|
||||
(t
|
||||
((let (success)
|
||||
(doom-refresh-packages-maybe doom-debug-mode)
|
||||
(dolist (pkg packages)
|
||||
(message! "Installing %s" (car pkg))
|
||||
(print! "Installing %s" (car pkg))
|
||||
(doom--condition-case!
|
||||
(message! "%s%s"
|
||||
(print! "%s%s"
|
||||
(if (and (package-installed-p (car pkg))
|
||||
(not (doom-package-different-backend-p (car pkg)))
|
||||
(not (doom-package-different-recipe-p (car pkg))))
|
||||
(dark (white "⚠ ALREADY INSTALLED"))
|
||||
(condition-case e
|
||||
(if (doom-install-package (car pkg) (cdr pkg))
|
||||
(green "✓ DONE")
|
||||
(prog1 (green "✓ DONE")
|
||||
(setq success t))
|
||||
(red "✕ FAILED"))
|
||||
(error
|
||||
(red "✕ ERROR (%s)" e))))
|
||||
(if (plist-member (cdr pkg) :pin)
|
||||
(format " [pinned: %s]" (plist-get (cdr pkg) :pin))
|
||||
""))))
|
||||
|
||||
(message! (bold (green "Finished!")))
|
||||
(print! (bold (green "Finished!")))
|
||||
(doom//reload-load-path)
|
||||
t)))))
|
||||
success)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom//packages-update ()
|
||||
"Interactive command for updating packages."
|
||||
(interactive)
|
||||
(if (not noninteractive)
|
||||
(doom-packages--async-run 'doom//packages-update)
|
||||
(message! "Looking for outdated packages...")
|
||||
(doom-initialize-packages)
|
||||
(print! "Looking for outdated packages...")
|
||||
(doom-refresh-packages-maybe doom-debug-mode)
|
||||
(let ((packages (sort (doom-get-outdated-packages) #'doom--sort-alpha)))
|
||||
(cond ((not packages)
|
||||
(message! (green "Everything is up-to-date"))
|
||||
(print! (green "Everything is up-to-date"))
|
||||
nil)
|
||||
|
||||
((not (or (getenv "YES")
|
||||
|
@ -420,32 +417,30 @@ package.el as appropriate."
|
|||
(package-version-join (cl-caddr pkg))))
|
||||
packages
|
||||
"\n"))))))
|
||||
(message! (yellow "Aborted!"))
|
||||
nil)
|
||||
(error "Aborted!"))
|
||||
|
||||
(t
|
||||
((let (success)
|
||||
(dolist (pkg packages)
|
||||
(message! "Updating %s" (car pkg))
|
||||
(print! "Updating %s" (car pkg))
|
||||
(doom--condition-case!
|
||||
(message!
|
||||
(print!
|
||||
(let ((result (doom-update-package (car pkg) t)))
|
||||
(when result (setq success t))
|
||||
(color (if result 'green 'red)
|
||||
(if result "✓ DONE" "✕ FAILED"))))))
|
||||
|
||||
(message! (bold (green "Finished!")))
|
||||
(print! (bold (green "Finished!")))
|
||||
(doom//reload-load-path)
|
||||
t)))))
|
||||
success)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom//packages-autoremove ()
|
||||
"Interactive command for auto-removing orphaned packages."
|
||||
(interactive)
|
||||
(if (not noninteractive)
|
||||
(doom-packages--async-run 'doom//packages-autoremove)
|
||||
(message! "Looking for orphaned packages...")
|
||||
(doom-initialize-packages)
|
||||
(print! "Looking for orphaned packages...")
|
||||
(let ((packages (doom-get-orphaned-packages)))
|
||||
(cond ((not packages)
|
||||
(message! (green "No unused packages to remove"))
|
||||
(print! (green "No unused packages to remove"))
|
||||
nil)
|
||||
|
||||
((not
|
||||
|
@ -466,22 +461,22 @@ package.el as appropriate."
|
|||
(upcase (symbol-name backend))))))
|
||||
(sort (cl-copy-list packages) #'string-lessp)
|
||||
"\n")))))
|
||||
(message! (yellow "Aborted!"))
|
||||
nil)
|
||||
(error "Aborted!"))
|
||||
|
||||
(t
|
||||
((let (success)
|
||||
(dolist (pkg packages)
|
||||
(doom--condition-case!
|
||||
(message!
|
||||
(print!
|
||||
(let ((result (doom-delete-package pkg t)))
|
||||
(when result (setq success t))
|
||||
(color (if result 'green 'red)
|
||||
"%s %s"
|
||||
(if result "✓ Removed" "✕ Failed to remove")
|
||||
pkg)))))
|
||||
|
||||
(message! (bold (green "Finished!")))
|
||||
(print! (bold (green "Finished!")))
|
||||
(doom//reload-load-path)
|
||||
t)))))
|
||||
success)))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue