Browse Source

Fixed company-mode lowercase crap; Simplified VlocitEmacs for now

master
Levi Olson 4 years ago
parent
commit
6c4b13bbd6
3 changed files with 83 additions and 66 deletions
  1. +3
    -1
      lisp/05-custom-functions.el
  2. +1
    -0
      lisp/08-custom-packages.el
  3. +79
    -65
      lisp/custom/vlocitemacs.el

+ 3
- 1
lisp/05-custom-functions.el View File

@ -221,7 +221,9 @@
(interactive) (interactive)
(let ((secret (plist-get (nth 0 (auth-source-search :max 1 :user un)) :secret)) (let ((secret (plist-get (nth 0 (auth-source-search :max 1 :user un)) :secret))
(host (plist-get (nth 0 (auth-source-search :max 1 :user un)) :host))) (host (plist-get (nth 0 (auth-source-search :max 1 :user un)) :host)))
(browse-url (concat "https://" host "/login.jsp?pw=" (leo/auth-source-unfunc secret) "&un=" (leo/url-encode un)))))
(shell-command (format "sfdx force:org:open -u %s" un))
;; (browse-url (concat "https://" host "/login.jsp?pw=" (leo/auth-source-unfunc secret) "&un=" (leo/url-encode un)))
))
(provide '05-custom-functions) (provide '05-custom-functions)
;;; 05-custom-functions.el ends here ;;; 05-custom-functions.el ends here

+ 1
- 0
lisp/08-custom-packages.el View File

@ -283,6 +283,7 @@
:config :config
(setq company-idle-delay 0.1) (setq company-idle-delay 0.1)
(setq company-minimum-prefix-length 4) (setq company-minimum-prefix-length 4)
(setq company-dabbrev-downcase nil)
) )
;; https://github.com/pashky/restclient.el ;; https://github.com/pashky/restclient.el

+ 79
- 65
lisp/custom/vlocitemacs.el View File

@ -17,17 +17,17 @@
(defvar vlo/org-usernames '() (defvar vlo/org-usernames '()
"Auto-generated list of usernames from SFDX that are both authenticated and connected.") "Auto-generated list of usernames from SFDX that are both authenticated and connected.")
(defvar vlo/default-environment-template "{
\"environments\": [
{
\"env\": \"default\",
\"username\": \"\",
\"job\": \"job.yaml\"
}
]
}" "Default template for creating the initial .vemacs file.")
(defvar vlo/project-file-name ".vemacs.json"
;; (defvar vlo/default-environment-template "{
;; \"environments\": [
;; {
;; \"env\": \"default\",
;; \"username\": \"\",
;; \"job\": \"job.yaml\"
;; }
;; ]
;; }" "Default template for creating the initial .vemacs file.")
(defvar vlo/project-file-name ".vemacs.txt"
"The name of the VlocitEmacs configuration file. "The name of the VlocitEmacs configuration file.
This file exists for the purpose of locating the project folder as there is no This file exists for the purpose of locating the project folder as there is no
@ -41,15 +41,18 @@ list of environments to be used for deployments/exports.")
(let* ((dir (read-directory-name "Choose Project Root: ")) (let* ((dir (read-directory-name "Choose Project Root: "))
(project-file (concat dir vlo/project-file-name)) (project-file (concat dir vlo/project-file-name))
(gitignore (concat dir ".gitignore"))) (gitignore (concat dir ".gitignore")))
(with-temp-file project-file (insert vlo/default-environment-template))
(when (file-exists-p gitignore)
(append-to-file vlo/project-file-name nil gitignore))))
(with-temp-file project-file (insert ""))
(let ((current-user (vlo/prompt-org-list)))
(with-temp-file project-file (insert current-user))
(when (file-exists-p gitignore)
(append-to-file vlo/project-file-name nil gitignore)))))
(defun vlo/get-org-list ()
"Get a list of authenticated orgs via SFDX cli and populate the `vlo/org-usernames' variable."
(defun vlo/prompt-org-list ()
"Get a list of authenticated orgs via SFDX cli and store the selected user in the project file."
(interactive) (interactive)
(let* ((temp-json-file
(let* ((project-file (concat (vlo/project-path) vlo/project-file-name))
(temp-json-file
(make-temp-file "sfdx-org-list" nil ".json" (make-temp-file "sfdx-org-list" nil ".json"
(shell-command-to-string "sfdx force:org:list --json"))) (shell-command-to-string "sfdx force:org:list --json")))
(json-object-type 'hash-table) (json-object-type 'hash-table)
@ -59,36 +62,30 @@ list of environments to be used for deployments/exports.")
(result (gethash "result" json)) (result (gethash "result" json))
(orgs (gethash "nonScratchOrgs" result)) (orgs (gethash "nonScratchOrgs" result))
) )
;; (message "%s" orgs)
(setq vlo/org-usernames '()) (setq vlo/org-usernames '())
(dolist (org orgs) (dolist (org orgs)
(add-to-list 'vlo/org-usernames (gethash "username" org))) (add-to-list 'vlo/org-usernames (gethash "username" org)))
)
)
(let ((current-user (completing-read "SFDX user: " vlo/org-usernames)))
(with-temp-file project-file current-user)
current-user)))
;; (defun vlo/get-environment-list (&optional key)
;; "Get the list of org environment vars from within vlo/project-file-name JSON file with optional KEY to get a list of keys."
;; (let* ())
;; )
(defun vlo/getuser ()
"Prompt for sfdx username or use stored."
(defun vlo/get-project-user ()
"Return the user stored in the project file."
(interactive) (interactive)
(let ((username (completing-read "SFDX User: " vlo/org-usernames nil t nil nil)))
(if (yes-or-no-p (format "Set \"%s\" as default for this project?" username))
;;insert username into project file
(progn
(with-temp-file (concat (vlo/project-path) vlo/project-file-name) (insert username))
(message "Default set to: %s" username)
)
(message "No default set"))))
(if (vlo/in-project)
(let* ((project-dir (concat (vlo/project-path) vlo/project-file-name)))
(with-temp-buffer (insert-file-contents project-dir)
(buffer-string)))
(prog1
nil
(message "Must be in vlocity project for that command"))))
(defun vlo/get-jobfile-name ()
"The name of the job.yaml file."
"job.yaml")
(defun vlo/get-deployment-key () (defun vlo/get-deployment-key ()
"Return the \"key\" used by vlocity to specify what to deploy/export." "Return the \"key\" used by vlocity to specify what to deploy/export."
(vlo/ensure-init-file)
(let ((path-list (delete "" (split-string (file-name-directory (buffer-file-name)) "/")))) (let ((path-list (delete "" (split-string (file-name-directory (buffer-file-name)) "/"))))
(format "%s/%s" (format "%s/%s"
(nth (- (length path-list) 2) path-list) (nth (- (length path-list) 2) path-list)
@ -105,50 +102,68 @@ nil."
dir)) dir))
(defun vlo/in-project () (defun vlo/in-project ()
"Asserts that you're currently inside a vlocity project."
(let ((dir (locate-dominating-file default-directory vlo/project-file-name)))
(if dir
t
nil)))
"Check if you are currently inside a vlocity project."
(if (locate-dominating-file default-directory vlo/project-file-name)
t
nil))
(defun leo/exec-process (cmd &optional comint)
"Execute a process running CMD and optionally pass COMINT as t to put buffer in `comint-mode'."
(defun leo/exec-process (cmd name &optional comint)
"Execute a process running CMD and use NAME to generate a unique buffer name and optionally pass COMINT as t to put buffer in `comint-mode'."
(let ((compilation-buffer-name-function (let ((compilation-buffer-name-function
(lambda (mode) (lambda (mode)
(format "*exec-process*"))))
(format "*%s*" name))))
(message (concat "Running " cmd)) (message (concat "Running " cmd))
(compile cmd comint))) (compile cmd comint)))
(defun vlo/packExport () (defun vlo/packExport ()
"Run the packExport command." "Run the packExport command."
(interactive) (interactive)
(if (and (vlo/in-project) (if (and (vlo/in-project)
(file-exists-p (vlo/get-propertyfile-name))
(file-exists-p (vlo/get-jobfile-name)))
(file-exists-p (concat (vlo/project-path) (vlo/get-jobfile-name))))
(leo/exec-process (leo/exec-process
(format "cd %s; vlocity packExport -sfdx.username %s -job %s -key %s" (format "cd %s; vlocity packExport -sfdx.username %s -job %s -key %s"
(vlo/project-path) (vlo/project-path)
(vlo/get-user)
(vlo/get-project-user)
(vlo/get-jobfile-name) (vlo/get-jobfile-name)
(vlo/get-deployment-key)))
(error (format "Error: cannot find either %s or %s" (vlo/get-propertyfile-name) (vlo/get-jobfile-name)))))
(vlo/get-deployment-key)) "vlocity:retrieve" t)
(message "ERROR Exporting:: project: %s, user: %s, job: %s, key: %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name)
(vlo/get-deployment-key))))
(defun vlo/packDeploy () (defun vlo/packDeploy ()
"Run the packDeploy command." "Run the packDeploy command."
(interactive) (interactive)
(if (and (vlo/in-project) (if (and (vlo/in-project)
(file-exists-p (vlo/get-propertyfile-name))
(file-exists-p (vlo/get-jobfile-name)))
(file-exists-p (concat (vlo/project-path) (vlo/get-jobfile-name))))
(leo/exec-process (leo/exec-process
(format "cd %s; vlocity packDeploy -sfdx.username %s -job %s -key %s" (format "cd %s; vlocity packDeploy -sfdx.username %s -job %s -key %s"
(vlo/project-path) (vlo/project-path)
(vlo/get-user)
(vlo/get-project-user)
(vlo/get-jobfile-name) (vlo/get-jobfile-name)
(vlo/get-deployment-key)))
(error (format "Error: cannot find either %s or %s" (vlo/get-propertyfile-name) (vlo/get-jobfile-name)))))
(vlo/get-deployment-key)) "vlocity:deploy" t)
(message "ERROR Deploying:: project: %s, user: %s, job: %s, key: %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name)
(vlo/get-deployment-key))))
(defun vlo/packList ()
"Run the packGetAllAvailableExports command."
(interactive)
(if (and (vlo/in-project)
(file-exists-p (concat (vlo/project-path) (vlo/get-jobfile-name))))
(leo/exec-process
(format "cd %s; vlocity packGetAllAvailableExports -sfdx.username %s -job %s -type VlocityUITemplate"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name)) "vlocity:exports" t)
(message "ERROR Retrieving List:: project: %s, user: %s, job: %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name))))
(defun vlo/transient-action () (defun vlo/transient-action ()
"Dynamically choose which transient to show based on if currently in a project." "Dynamically choose which transient to show based on if currently in a project."
@ -160,20 +175,19 @@ nil."
(define-transient-command vlo/transient-init-action () (define-transient-command vlo/transient-init-action ()
"Vlocity Build Tool CLI Actions" "Vlocity Build Tool CLI Actions"
["Initialize" ["Initialize"
("i" "Create .vemacs in project root" vlo/generate-project-file)]
)
("c" "Create project file" vlo/generate-project-file)])
(define-transient-command vlo/transient-project-action () (define-transient-command vlo/transient-project-action ()
"Vlocity Build Tool CLI Actions" "Vlocity Build Tool CLI Actions"
["Environments"
("a" "Add new org environment" vlo/transient-action)]
;; ["Environments"
;; ("a" "Add new org environment" vlo/transient-action)]
["List"
("l" "get available list" vlo/packList)]
["Actions" ["Actions"
("e" "export" vlo/packExport)
("r" "retrieve" vlo/packExport)
("d" "deploy" vlo/packDeploy)]) ("d" "deploy" vlo/packDeploy)])
(provide 'vlocitemacs) (provide 'vlocitemacs)
;;; vlocitemacs.el ends here ;;; vlocitemacs.el ends here

Loading…
Cancel
Save