-
Notifications
You must be signed in to change notification settings - Fork 12
install phpactor with phpactor-update function #60
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
;; Created: 8 Apr 2018 | ||
;; Version: 0.1.0 | ||
;; Keywords: tools, php | ||
;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (f "0.17")) | ||
;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (f "0.17") (composer "0.1")) | ||
;; URL: https://github.com/emacs-php/phpactor.el | ||
;; License: GPL-3.0-or-later | ||
|
||
|
@@ -48,6 +48,7 @@ | |
(require 'json) | ||
(require 'php-project) | ||
(require 'ring) | ||
(require 'composer) | ||
|
||
;; Variables | ||
;;;###autoload | ||
|
@@ -86,10 +87,23 @@ | |
"Return Phpactor command or path to executable." | ||
(or (when phpactor-executable | ||
(php-project--eval-bootstrap-scripts phpactor-executable)) | ||
(executable-find phpactor-command-name) | ||
(let ((vendor-executable (f-join (phpactor-get-working-dir) "vendor/bin/phpactor"))) | ||
(let ((vendor-executable (f-join (phpactor-package-directory) "vendor/bin/phpactor"))) | ||
(when (file-exists-p vendor-executable) | ||
vendor-executable)))) | ||
vendor-executable)) | ||
(error "Phpactor not found. Please run phpactor-update"))) | ||
|
||
(defun phpactor-update () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about naming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I tend to like the semantic that comes with the term But I agree that for the first time you use it, it feels a bit wrong. Would that justify having both name, one aliasing towards the other ? |
||
"Install or update phpactor inside phpactor.el's folder." | ||
(interactive) | ||
(let ((package-folder (phpactor-package-directory)) | ||
(composer-executable (car (composer--find-executable)))) | ||
(unless composer-executable (error ("composer not found."))) | ||
(setq default-directory package-folder) | ||
(call-process composer-executable nil (get-buffer-create phpactor-action--buffer-name) nil "install" "--no-dev"))) | ||
|
||
(defun phpactor-package-directory () | ||
"Return the folder where phpactor.el is installed." | ||
(file-name-directory(locate-library "phpactor.el"))) | ||
|
||
(defun phpactor-get-working-dir () | ||
"Return working directory of Phpactor." | ||
|
@@ -464,7 +478,9 @@ function." | |
(cl-defun phpactor-action-dispatch (&key action parameters version) | ||
"Execite action by `NAME' and `PARAMETERS'." | ||
(when (and version (not (equal phpactor--supported-rpc-version version))) | ||
(error "Phpactor uses rpc protocol %s whereas this package requires %s" version phpactor--supported-rpc-version)) | ||
(if (phpactor-executable) | ||
(error "Phpactor uses rpc protocol %s but this package requires %s" version phpactor--supported-rpc-version) | ||
(error "Phpactor should be upgraded. Please run phpactor-update"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines can be modified as follows, but what do you think? @@ -469,10 +469,11 @@ function."
;; Dispatcher:
(cl-defun phpactor-action-dispatch (&key action parameters version)
"Execite action by `NAME' and `PARAMETERS'."
- (when (and version (not (equal phpactor--supported-rpc-version version)))
- (if (phpactor-executable)
+ (unless (or (null version)
+ (version<= phpactor--supported-rpc-version version))
+ (if (phpactor-find-executable)
(error "Phpactor uses rpc protocol %s but this package requires %s" version phpactor--supported-rpc-version)
- (error "Phpactor should be upgraded. Please run phpactor-update")))
+ (error "Phpactor should be upgraded. Please run phpactor-update")))
(phpactor--add-history 'phpactor-action-dispatch (list :action action :parameters parameters :version version))
(let ((func (cdr-safe (assq (intern action) phpactor-action-table))))
(if func There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, I'm not yet used to
Not sure I see what you mean here. if versions are equal, no issue but if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I see. |
||
(phpactor--add-history 'phpactor-action-dispatch (list :action action :parameters parameters :version version)) | ||
(let ((func (cdr-safe (assq (intern action) phpactor-action-table)))) | ||
(if func | ||
|
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.
I was a bit puzzled by this way of installing phactor (inside a php project), but even so, I'd rather recommend everyone to either install it from phpactor.el or define it manually (hopefully after having considered the risks it brings).
how does that sound ?