Browse Source

Massive completions around VlocitEmacs retrieval and search

master
Levi Olson 4 years ago
parent
commit
b9c1d57f6e
1 changed files with 78 additions and 18 deletions
  1. +78
    -18
      lisp/custom/vlocitemacs.el

+ 78
- 18
lisp/custom/vlocitemacs.el View File

@ -119,7 +119,7 @@ nil."
(message (concat "Running " cmd))
(compile cmd comint)))
;; DONE
(defun vlo/packExport (username job &optional key)
"Run the packExport command with sfdx USERNAME or alias using the JOB file.
@ -146,6 +146,7 @@ packExport using job.yaml provided (i.e. export all)."
job
key)))
;; DONE
(defun vlo/packDeploy (username job &optional key)
"Run the packDeploy command with sfdx USERNAME or alias using the JOB file.
@ -173,35 +174,45 @@ packDeploy using job.yaml provided (i.e. deploy all)."
key)))
(defun vlo/packSearch (username job)
"Run the packGetAllAvailableExports command with USERNAME and JOB file."
(defun vlo/prompt-tabulated-list (&optional result)
"A wrapper function to `vlocitemacs' from async call which passes a RESULT."
(vlocitemacs))
;; FIXME :: This isn't triggering `vlocitemacs' as it should after building the list.
(defun vlo/get-available-exports (username job)
"Run the packGetAllAvailableExports command with USERNAME and JOB file.
Returns a list into VlocityBuildLog.yaml. Upon completing the async process
`vlocitemacs' is run."
(if (and (vlo/in-vlocity-project)
(file-exists-p (concat (vlo/project-path) job)))
(vlo/exec-process
(format "cd %s; vlocity packGetAllAvailableExports -sfdx.username %s -job %s -type VlocityUITemplate"
(vlo/project-path)
username
job) "vlocity:exports" t)
(message "ERROR Retrieving List:: project: %s, user: %s, job: %s"
(vlo/project-path)
username
job)))
;; this following 'if' is essentially a cache
(if (not (string= (shell-command-to-string (format "cat %sVlocityBuildLog.yaml | grep 'manifest'" (vlo/project-path))) ""))
(vlocitemacs)
(progn
(message "Generating list...")
(async-start-process "vlocity:getlist" "sh" (lambda (res) (vlocitemacs)) "-c" (format "cd %s; vlocity packGetAllAvailableExports -sfdx.username %s -job %s -type VlocityUITemplate; exit" (vlo/project-path) username job))))
(message "Cannot get available exports!")))
(defun vlo/createDatapack ()
"Description."
(interactive)
(message "TODO :: Creating..."))
;; DONE
(defun vlo/search ()
"Description."
(interactive)
(message "TODO :: Searching..."))
(vlo/get-available-exports (vlo/get-project-user) (vlo/get-jobfile-name)))
;; DONE
(defun vlo/exportThisAction ()
"Destructively retrieve this component."
(interactive)
(let ((key (vlo/get-deployment-key)))
(if (yes-or-no-p "Retrieve \"%s\"? (THIS WILL OVERWRITE LOCAL CHANGES!) ")
(if (yes-or-no-p (format "Retrieve \"%s\"? (THIS WILL OVERWRITE LOCAL CHANGES!) " key))
(progn
(message "Retrieving \"%s\"..." key)
(vlo/packExport (vlo/get-project-user) (vlo/get-jobfile-name) key))
@ -238,6 +249,55 @@ packDeploy using job.yaml provided (i.e. deploy all)."
;; TODO : could check if file is installed locally and then either prompt to overwrite or goto item
(defun vlo/get-item-at-point (&optional arg)
"Get the DataPack under cursor ARG."
(interactive "P")
(let ((item (aref (tabulated-list-get-entry) 0)))
(message "Item Selected: %s and arg %s" item arg)
(vlo/packExport (vlo/get-project-user) (vlo/get-jobfile-name) (concat "VlocityUITemplate/" item))))
;; DONE
(defvar vlocitemacs-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") 'vlo/get-item-at-point)
map)
"Keymap for `vlocitemacs-mode'.")
;; DONE
(define-derived-mode vlocitemacs-mode tabulated-list-mode "VlocitEmacs"
"A custom mode for interacting with the Vlocity Build Tool CLI."
(let (
(columns [("Choose DataPack" 100)])
(rows (mapcar (lambda(x) `(nil [,x]))
(split-string (shell-command-to-string (format "cat %sVlocityBuildLog.yaml | grep ' - ' | sed 's/ - VlocityUITemplate\\///'" (vlo/project-path)))))))
(buffer-disable-undo)
(kill-all-local-variables)
(setq truncate-lines t)
(setq mode-name "VlocitEmacs")
(setq major-mode 'vlocitemacs-mode)
(setq tabulated-list-format columns)
(setq tabulated-list-entries rows)
(use-local-map vlocitemacs-mode-map)
(tabulated-list-init-header)
(tabulated-list-print)
(run-mode-hooks 'vlocitemacs-mode-hook)))
;; DONE
(defun vlocitemacs ()
"Invoke the VlocitEmacs buffer."
(interactive)
(switch-to-buffer "*vlocitemacs*")
(vlocitemacs-mode))
;; DONE
(defun vlo/transient-action ()
"Dynamically choose which transient to show based on if currently in a project."
(interactive)
@ -256,12 +316,12 @@ packDeploy using job.yaml provided (i.e. deploy all)."
("c" "Create a new datapack (dynamically)" vlo/createDatapack)]
["Retrieve"
("s" "Search for new datapack" vlo/search)
("r" "refresh this datapack (destructive)" vlo/exportThisAction)
("R" "refresh all local datapacks (destructive)" vlo/exportAllAction)
("r" "Refresh this datapack (destructive)" vlo/exportThisAction)
("R" "Refresh all local datapacks (destructive)" vlo/exportAllAction)
]
["Deploy"
("d" "deploy this datapack" vlo/deployThisAction)
("D" "deploy all local datapacks" vlo/deployAllAction)
("d" "Deploy this datapack" vlo/deployThisAction)
("D" "Deploy all local datapacks" vlo/deployAllAction)
])

Loading…
Cancel
Save