Browse Source

Massive init cleanup (faster loading); Improved VlocitEmacs transient

master
Levi Olson 4 years ago
parent
commit
41cea74fc2
7 changed files with 279 additions and 233 deletions
  1. +3
    -3
      lisp/01-custom-early-init.el
  2. +1
    -1
      lisp/02-custom-package-setup.el
  3. +10
    -1
      lisp/05-custom-functions.el
  4. +6
    -4
      lisp/07_5-custom-created-packages.el
  5. +63
    -127
      lisp/08-custom-packages.el
  6. +22
    -0
      lisp/custom/ol-sflogin.el
  7. +174
    -97
      lisp/custom/vlocitemacs.el

+ 3
- 3
lisp/01-custom-early-init.el View File

@ -10,7 +10,6 @@
Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
(setq file-name-handler-alist nil
message-log-max 16384
gc-cons-threshold 402653184
gc-cons-percentage 0.6
auto-window-vscroll nil)
@ -27,8 +26,9 @@ Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
(add-hook 'after-init-hook
`(lambda ()
(setq file-name-handler-alist file-name-handler-alist-old
gc-cons-threshold 20000000
gc-cons-percentage 0.1)
gc-cons-threshold 800000
gc-cons-percentage 0.1
)
(garbage-collect)) t)
(provide '01-custom-early-init)

+ 1
- 1
lisp/02-custom-package-setup.el View File

@ -18,7 +18,7 @@
(make-directory package-user-dir t)))
(setq use-package-verbose t
use-package-always-defer nil ;I'm not used to that
use-package-always-defer t ; this is default, but setting here anyway for clarity
use-package-minimum-reported-time 0.01)
;; Initialize package management

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

@ -175,7 +175,7 @@
(setq old-mlf mode-line-format)
(setq mode-line-format nil)
(org-narrow-to-subtree)
(setq cursor-type nil)
(setq cursor-type 'hbar)
(read-only-mode 1)
(text-scale-adjust 6)
(visual-line-mode 1)
@ -225,5 +225,14 @@
;; (browse-url (concat "https://" host "/login.jsp?pw=" (leo/auth-source-unfunc secret) "&un=" (leo/url-encode un)))
))
(defun leo/exec-process (cmd name &optional comint)
"Execute CMD as a process in a buffer NAME, optionally passing COMINT as non-nil to put buffer in `comint-mode'."
(let ((compilation-buffer-name-function
(lambda (mode)
(format "*%s*" name))))
(message (concat "Running " cmd))
(compile cmd comint)))
(provide '05-custom-functions)
;;; 05-custom-functions.el ends here

+ 6
- 4
lisp/07_5-custom-created-packages.el View File

@ -6,15 +6,18 @@
(use-package convert-to-table
:defer 5
:commands leo/convert-to-table
:load-path "custom/convert-to-table")
(use-package ol-dired
:defer 5
:demand t
:load-path "custom/ol-dired")
(use-package ol-sflogin
:demand t
:load-path "custom/ol-sflogin")
(use-package sfdx
:defer 5
:load-path "custom/sfdx"
:bind
("M-<tab>" . sfdx/next-component-file)
@ -25,7 +28,6 @@
:straight (:host github :repo "ryancrum/json.el" :branch "master"))
(use-package vlocitemacs
:defer 5
:load-path "custom/vlocitemacs"
:bind
("C-x C-l v" . vlo/transient-action))

+ 63
- 127
lisp/08-custom-packages.el View File

@ -34,24 +34,22 @@
;;; Code:
(use-package use-package-ensure-system-package
:ensure t)
:defer t)
(use-package ag
:ensure t)
:commands ag)
;; https://melpa.org/#/async
(use-package async
:ensure t)
:commands (async-start async-start-process))
;; https://github.com/myrjola/diminish.el
(use-package diminish
:ensure t
:demand t
)
:demand t)
;; https://elpa.gnu.org/packages/delight.html
(use-package delight
:ensure t)
:demand t)
;; https://github.com/winterTTr/ace-jump-mode
(use-package ace-jump-mode
@ -61,17 +59,15 @@
;; https://github.com/NicolasPetton/zerodark-theme
(use-package zerodark-theme
:ensure t
:demand t
:config
(load-theme 'zerodark t)
(zerodark-setup-modeline-format))
;; https://github.com/Malabarba/beacon
(use-package beacon
:diminish
:ensure t
:commands beacon-mode
:demand t
:diminish
:init
(setq beacon-size 70
beacon-color "#5B6268"
@ -82,15 +78,12 @@
;; https://github.com/iqbalansari/emacs-emojify
(use-package emojify
:ensure t
:defer 15
:defer 25
:config
(global-emojify-mode 1))
;; https://github.com/hrs/engine-mode
(use-package engine-mode
:ensure t
:defer 5
:commands (engine/get-query engine/execute-search)
:config
;; C-x / to start
@ -108,28 +101,26 @@
;; https://github.com/Fanael/rainbow-delimiters
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
;; rainbow-mode
(use-package rainbow-mode
:ensure t
:hook prog-mode)
;; M-x all-the-icons-install-fonts
(use-package all-the-icons
:ensure t
:demand t
:config
(setq inhibit-compacting-font-caches t))
;; https://github.com/emacs-dashboard/emacs-dashboard
(use-package dashboard
:ensure t
:demand t
:preface
(defvar show-week-agenda-p)
:init
(setq dashboard-items '((recents . 10)
(bookmarks . 5)
(bookmarks . 10)
(projects . 5)
(agenda . 5)))
(setq dashboard-center-content t)
@ -141,10 +132,11 @@
:config
(dashboard-setup-startup-hook))
;; counsel
(use-package amx
:commands amx-mode)
;; https://github.com/abo-abo/swiper
(use-package counsel
:ensure t
:demand t
:bind
("M-x" . counsel-M-x)
("C-c k" . counsel-rg)
@ -170,35 +162,26 @@
("C-s" . swiper)
:config
(ivy-mode 1)
)
(use-package amx
:ensure t
:config (amx-mode 1)
(amx-mode 1)
)
;; https://github.com/magnars/expand-region.el
(use-package expand-region
:ensure t
:bind
("C-@" . er/expand-region)
("C-#" . er/contract-region))
;; https://github.com/thanhvg/emacs-howdoyou
(use-package howdoyou
:ensure t
:commands (howdoyou-query howdoyou-next-link howdoyou-previous-link howdoyou-go-back-to-first-link howdoyou-reload-link)
:bind
("C-c h q" . howdoyou-query)
("C-c h n" . howdoyou-next-link)
("C-c h p" . howdoyou-previous-link)
("C-c h f" . howdoyou-go-back-to-first-link)
("C-c h r" . howdoyou-reload-link)
)
("C-c h r" . howdoyou-reload-link))
;; https://github.com/magnars/multiple-cursors.el
(use-package multiple-cursors
:ensure t
:bind
("C-}" . mc/mark-next-like-this)
("C-)" . mc/unmark-next-like-this)
@ -207,8 +190,6 @@
;; https://github.com/skeeto/elfeed
(use-package elfeed
:ensure t
:commands (elfeed elfeed-search-set-filter)
:bind
(("C-x C-l e" . elfeed)
:map elfeed-search-mode-map
@ -225,8 +206,6 @@
("http://understandinguncertainty.org/rss.xml" daily)
("http://pragmaticemacs.com/feed/" emacs)
("http://endlessparentheses.com/atom.xml" emacs)
;; ("http://www.reddit.com/r/emacs/.rss" emacs)
;; ("http://planet.emacsen.org/atom.xml" emacs)
("http://feeds.feedburner.com/XahsEmacsBlog" emacs)
("http://emacs.stackexchange.com/feeds" emacs)
("https://www.google.com/alerts/feeds/13353713273807811484/2710948715805064535" tesla)
@ -234,8 +213,7 @@
("https://www.google.com/alerts/feeds/13353713273807811484/14416938028701328804" stadia)
))
:config
(elfeed-update)
)
(elfeed-update))
;; https://github.com/rmuslimov/browse-at-remote
(use-package browse-at-remote
@ -244,24 +222,21 @@
;; https://github.com/justbur/emacs-which-key
(use-package which-key
:diminish
:ensure t
:defer 5
:config
(which-key-setup-minibuffer)
(which-key-mode))
;; https://github.com/lewang/fic-mode
(use-package fic-mode
:ensure t
:hook (prog-mode js-mode javascript-mode)
:commands fic-mode
:custom-face
(fic-face ((t :foreground "red" :weight bold)))
(fic-author-face ((t :foreground "red" :underline t))))
;; https://github.com/joaotavora/yasnippet
(use-package yasnippet
:ensure t
:commands (yas-reload-all)
:commands yas-reload-all
:hook (prog-mode . yas-minor-mode)
:init
(setq yas-snippet-dirs (list (concat user-emacs-directory "snippets")))
@ -270,9 +245,8 @@
;; https://company-mode.github.io/
(use-package company
:ensure t
:defer 5
:commands (company-mode)
:defer 25
:commands company-mode
:hook (prog-mode . company-mode)
:bind
(:map company-active-map
@ -282,83 +256,59 @@
("C-p" . company-select-previous))
:config
(setq company-idle-delay 0.1)
(setq company-minimum-prefix-length 4)
(setq company-dabbrev-downcase nil)
)
(setq company-minimum-prefix-length 3)
(setq company-dabbrev-downcase nil))
;; https://github.com/pashky/restclient.el
(use-package restclient
:ensure t
:mode ("\\.rest\\'" . restclient-mode))
;; https://github.com/iquiw/company-restclient
(use-package company-restclient
:ensure t
:after (company restclient))
;; https://github.com/magit/magit
(use-package magit
:commands magit-status
:ensure t
:bind
("C-x g" . magit-status)
("C-c g" . magit-status))
;; This is used in `rg-menu'
(use-package rg
:ensure t)
:defer t)
;; This is used in `projectile'
(use-package ripgrep
:ensure t)
:commands rg-project)
;; https://github.com/bbatsov/projectile
(use-package projectile
:delight '(:eval (concat " [" (projectile-project-name) "]"))
:ensure t
:bind (
("C-c p" . projectile-command-map)
:map projectile-command-map
("s r" . rg-project)
)
:init
;; (setq projectile-mode-line-prefix " P")
(setq projectile-completion-system 'ivy)
:config
(projectile-mode 1))
;; https://github.com/rudolfolah/angularjs-mode
(use-package angular-mode
:ensure t
:defer t
)
;; https://github.com/magnars/angular-snippets.el
(use-package angular-snippets
:ensure t
:defer t
)
;; https://github.com/magit/git-modes
(use-package gitignore-mode
:ensure t)
:mode ("\\.gitignore\\'"))
;; https://github.com/magit/git-modes
(use-package gitconfig-mode
:ensure t)
:mode ("\\.gitconfig\\'"))
;; http://web-mode.org/
(use-package web-mode
:ensure t
;; :mode (("\\.html?\\'" . web-mode)
;; ("\\.xml?\\'" . web-mode))
:hook (html-mode xml-mode)
)
:hook (html-mode xml-mode))
;; https://github.com/smihica/emmet-mode
(use-package emmet-mode
:ensure t
:hook (sgml-mode html-mode web-mode css-mode))
:hook (html-mode web-mode css-mode))
(use-package dash-at-point
:if (eq system-type 'darwin)
@ -367,24 +317,24 @@
;; https://github.com/joshwnj/json-mode
(use-package json-mode
:ensure t
:mode "\\.json\\'")
;; https://github.com/mojochao/npm-mode
;; Disabled in favor of just running npm commands in comint buffer via
;; (leo/exec-process "npm run start" "npm-start" t)
(use-package npm-mode
:ensure t
:disabled
:defer 10
:custom
(npm-mode-command-prefix "C-c r"))
;; https://github.com/antonj/scss-mode
(use-package scss-mode
:ensure t
:mode ("\\.s?css\\'" . scss-mode))
;; https://github.com/yoshiki/yaml-mode
(use-package yaml-mode
:ensure t
:mode ("\\.yml\\'" . yaml-mode))
:mode ("\\.ya?ml\\'" . yaml-mode))
;; https://github.com/kwrooijen/cargo.el
(use-package cargo
@ -393,7 +343,6 @@
;; https://github.com/flycheck/flycheck
(use-package flycheck
:diminish
:ensure t
:preface
(defvar flycheck-emacs-lisp-load-path)
:init
@ -402,7 +351,7 @@
;; https://orgmode.org/elpa.html
(use-package org
:commands (org-cycle-agenda-files org-capture)
:commands org-capture
:ensure org-plus-contrib
:mode ("\\.org\\'" . org-mode)
:bind (
@ -418,11 +367,13 @@
:preface
(defvar org-html-validation-link)
(defvar org-html-text-markup-alist)
(defvar org-capture-templates)
:init
(setq org-agenda-files '("~/Dropbox/Org/todo.org"
"~/Dropbox/Org/projects.org"
;; "~/Dropbox/Org/projects.org"
"~/Dropbox/Org/archive.org"
"~/Dropbox/Org/diary/eaglecrk.org"))
;; "~/Dropbox/Org/diary/eaglecrk.org"
))
(add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
(setq org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)")
(sequence "BUG(b)" "INPROGRESS(i)" "|" "FIXED(f)")
@ -470,6 +421,18 @@
(shell . t)
(restclient . t)
(emacs-lisp . t)))
(setq org-capture-templates
'(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
("n" "new note" entry (file+headline org-default-notes-file "Notes")
"* %?\n%i\n")
("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
"* %a\n%?\n")
("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
"* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
))
(setq org-structure-template-alist
'(("r" . "src restclient :results raw")
("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
@ -504,21 +467,21 @@
)
(use-package ob-restclient
:disabled
:ensure t
:config
(setq org-babel-default-header-args:restclient
`((:results . "output"))))
;; https://github.com/astahlman/ob-async
;; Run a begin_src block asynchronously via :async
(use-package ob-async
:disabled
:ensure t
:after org)
;; https://github.com/sabof/org-bullets
(use-package org-bullets
:ensure t
:after org
:commands org-bullets-mode
:hook (org-mode . org-bullets-mode)
:config
(setq org-bullets-bullet-list '( "" "" "" "" "" "" ""))
@ -533,29 +496,15 @@
;; https://orgmode.org/worg/org-contrib/org-protocol.html
(use-package org-protocol
:ensure org-plus-contrib
:after org
:preface
(defvar org-capture-templates)
:init
(setq org-capture-templates
'(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
("n" "new note" entry (file+headline org-default-notes-file "Notes")
"* %?\n%i\n")
("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
"* %a\n%?\n")
("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
"* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
))
)
:after org)
;; https://github.com/marsmining/ox-twbs
(use-package ox-twbs
:ensure t
:demand t
:defer 10
:after org)
(use-package ox-extra
:defer 10
:ensure org-plus-contrib
:after org
:config
@ -563,13 +512,11 @@
;; https://github.com/yjwen/org-reveal
(use-package ox-reveal
:ensure t
:defer 10
:after org)
;; https://github.com/jethrokuan/org-roam/
(use-package org-roam
:ensure t
:after org
:hook
((org-mode . org-roam-mode)
(after-init . org-roam--build-cache-async) ;; optional!
@ -591,7 +538,6 @@
;; https://github.com/jrblevin/deft
(use-package deft
:after org
:bind
("C-c n d" . deft)
:custom
@ -602,12 +548,11 @@
;; https://github.com/hniksic/emacs-htmlize
(use-package htmlize
:ensure t
:defer 5)
:defer 10
:after org)
;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
(use-package bind-key
:ensure t
:bind
("C-<tab>" . leo/tidy)
("C-;" . leo/comment-or-uncomment-region-or-line)
@ -618,22 +563,14 @@
("M-p" . leo/jump-to-prev-symbol)
("M-u" . upcase-dwim)
("M-c" . capitalize-dwim)
("M-l" . downcase-dwim)
;; ("C-x C-l s p" . sfdx/create-project)
;; ("C-x C-l s c" . sfdx/create-component)
;; ("C-x C-l s d" . sfdx/deploy-component-or-project)
)
("M-l" . downcase-dwim))
;; https://github.com/nflath/sudo-edit
(use-package sudo-edit
:ensure t
:defer t
:commands (sudo-edit))
;; https://www.emacswiki.org/emacs/ParEdit
(use-package paredit
:defer 5
:commands enable-paredit-mode
:hook (
(emacs-lisp-mode . enable-paredit-mode)
(lisp-mode . enable-paredit-mode)
@ -642,8 +579,7 @@
(eval-expression-minibuffer-setup . enable-paredit-mode)
)
:config
(unbind-key "M-q" paredit-mode-map)
)
(unbind-key "M-q" paredit-mode-map))
(provide '08-custom-packages)

+ 22
- 0
lisp/custom/ol-sflogin.el View File

@ -0,0 +1,22 @@
;;; ol-sflogin.el --- Support for links to auto-login to Salesforce
;;; Commentary:
;;; Code:
(require 'ol)
(defun org-sflogin-complete (result)
"Login to SF is complete with RESULT."
(message "Launching Org in Browser..."))
(defun org-sflogin-command (username)
"The command used to login to salesforce with USERNAME directly."
(message "Logging into Salesforce...")
(async-start-process "sfdx:login" "sfdx" 'org-sflogin-complete "force:org:open" "-u" username))
(org-link-set-parameters "sflogin"
:follow #'org-sflogin-command)
(provide 'ol-sflogin)
;;; ol-sflogin.el ends here

+ 174
- 97
lisp/custom/vlocitemacs.el View File

@ -14,19 +14,6 @@
(require 'json)
(defvar vlo/org-usernames '()
"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.txt"
"The name of the VlocitEmacs configuration file.
@ -34,20 +21,32 @@ This file exists for the purpose of locating the project folder as there is no
good way of knowing you are in the root vlocity project. It also contains the
list of environments to be used for deployments/exports.")
(defvar vlo/project-jobfile-template "projectPath: ."
"Bare-bones template to use for =job.yaml=.")
;; DONE
(defun vlo/generate-project-file ()
"Create the project file and append it to .gitignore if file exists."
(interactive)
(let* ((dir (read-directory-name "Choose Project Root: "))
(project-file (concat dir vlo/project-file-name))
(job-file (concat dir "job.yaml"))
(gitignore (concat dir ".gitignore")))
;; Create job.yaml if it doesn't exist
(when (not (file-exists-p job-file))
(with-temp-file job-file (insert vlo/project-jobfile-template)))
;; Create .vemacs.txt
(with-temp-file project-file (insert ""))
;; Insert username into .vemacs.txt
(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)))))
)
;; Add .vemacs.txt to .gitignore
(when (file-exists-p gitignore)
(append-to-file vlo/project-file-name nil gitignore))))
;; DONE
(defun vlo/prompt-org-list ()
"Get a list of authenticated orgs via SFDX cli and store the selected user in the project file."
(interactive)
@ -61,53 +60,58 @@ list of environments to be used for deployments/exports.")
(json (json-read-file temp-json-file))
(result (gethash "result" json))
(orgs (gethash "nonScratchOrgs" result))
(usernames '())
)
(setq vlo/org-usernames '())
(dolist (org orgs)
(add-to-list 'vlo/org-usernames (gethash "username" org)))
(let ((current-user (completing-read "SFDX user: " vlo/org-usernames)))
(add-to-list 'usernames (gethash "username" org)))
(let ((current-user (completing-read "SFDX user: " usernames)))
(with-temp-file project-file current-user)
current-user)))
(defun vlo/get-project-user ()
"Return the user stored in the project file."
(interactive)
(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 ()
"Return the \"key\" used by vlocity to specify what to deploy/export."
(let ((path-list (delete "" (split-string (file-name-directory (buffer-file-name)) "/"))))
(format "%s/%s"
(nth (- (length path-list) 2) path-list)
(nth (- (length path-list) 1) path-list))))
;; DONE
(defun vlo/in-vlocity-project ()
"Check if you are currently inside a vlocity project."
(if (vlo/project-path)
t
nil))
;; DONE
(defun vlo/project-path ()
"Return path to the project file, or nil.
If project file exists in the current working directory, or a
parent directory recursively, return its path. Otherwise, return
nil."
(let ((dir (locate-dominating-file default-directory vlo/project-file-name)))
(unless dir
(error (concat "Error: cannot find " vlo/project-file-name)))
dir))
(locate-dominating-file default-directory vlo/project-file-name))
(defun vlo/in-project ()
"Check if you are currently inside a vlocity project."
(if (locate-dominating-file default-directory vlo/project-file-name)
t
;; DONE
(defun vlo/get-project-user ()
"Return the user stored in the project file."
(if (vlo/in-vlocity-project)
(let ((project-dir (concat (vlo/project-path) vlo/project-file-name)))
(with-temp-buffer (insert-file-contents project-dir) (buffer-string)))
nil))
(defun leo/exec-process (cmd name &optional comint)
;; DONE
(defun vlo/get-jobfile-name ()
"The name of the job.yaml file."
"job.yaml")
;; DONE
(defun vlo/get-deployment-key ()
"Return the Name of the component dynamically from the =_DataPpack.json= file."
(let ((datapack-file (expand-file-name (concat (file-name-base) "_DataPack.json"))))
(if (file-exists-p datapack-file)
(let* ((json-object-type 'hash-table)
(json-array-type 'list)
(json-key-type 'string)
(json (json-read-file datapack-file))
(component-name (gethash "Name" json)))
(concat "VlocityUITemplate/" component-name))
nil)))
;; DONE
(defun vlo/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
(lambda (mode)
@ -116,76 +120,149 @@ nil."
(compile cmd comint)))
(defun vlo/packExport ()
"Run the packExport 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 packExport -sfdx.username %s -job %s -key %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name)
(vlo/get-deployment-key)) "vlocity:retrieve" t)
(defun vlo/packExport (username job &optional key)
"Run the packExport command with sfdx USERNAME or alias using the JOB file.
Optionally specifying KEY to export. If KEY is nil, this command will run
packExport using job.yaml provided (i.e. export all)."
(if (and (vlo/in-vlocity-project)
(file-exists-p (concat (vlo/project-path) job)))
(let ((cmd
(if key
(format "cd %s; vlocity packExport -sfdx.username %s -job %s -key %s"
(vlo/project-path)
username
job
key)
(format "cd %s; vlocity packExport -sfdx.username %s -job %s"
(vlo/project-path)
username
job)
)))
(vlo/exec-process cmd "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))))
username
job
key)))
(defun vlo/packDeploy ()
"Run the packDeploy 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 packDeploy -sfdx.username %s -job %s -key %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name)
(vlo/get-deployment-key)) "vlocity:deploy" t)
(defun vlo/packDeploy (username job &optional key)
"Run the packDeploy command with sfdx USERNAME or alias using the JOB file.
Optionally specifying KEY to export. If KEY is nil, this command will run
packDeploy using job.yaml provided (i.e. deploy all)."
(if (and (vlo/in-vlocity-project)
(file-exists-p (concat (vlo/project-path) job)))
(let ((cmd
(if key
(format "cd %s; vlocity packDeploy -sfdx.username %s -job %s -key %s"
(vlo/project-path)
username
job
key)
(format "cd %s; vlocity packDeploy -sfdx.username %s -job %s"
(vlo/project-path)
username
job)
)))
(vlo/exec-process cmd "vlocity:retrieve" 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))))
username
job
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
(defun vlo/packSearch (username job)
"Run the packGetAllAvailableExports command with USERNAME and JOB file."
(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)
(vlo/get-project-user)
(vlo/get-jobfile-name)) "vlocity:exports" t)
username
job) "vlocity:exports" t)
(message "ERROR Retrieving List:: project: %s, user: %s, job: %s"
(vlo/project-path)
(vlo/get-project-user)
(vlo/get-jobfile-name))))
username
job)))
(defun vlo/createDatapack ()
"Description."
(interactive)
(message "TODO :: Creating..."))
(defun vlo/search ()
"Description."
(interactive)
(message "TODO :: Searching..."))
;; 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!) ")
(progn
(message "Retrieving \"%s\"..." key)
(vlo/packExport (vlo/get-project-user) (vlo/get-jobfile-name) key))
(message "Cancelled Retrieve"))))
;; DONE
(defun vlo/exportAllAction ()
"Description."
(interactive)
(if (yes-or-no-p "Retrieve ALL DataPacks in Manifest? (THIS WILL OVERWRITE LOCAL CHANGES!) ")
(progn
(message "Retrieving ALL DataPacks in Manifest file...")
(vlo/packExport (vlo/get-project-user) (vlo/get-jobfile-name)))
(message "Cancelled Retrieve")))
;; DONE
(defun vlo/deployThisAction ()
"Description."
(interactive)
(let ((key (vlo/get-deployment-key)))
(if key
(progn
(vlo/packDeploy (vlo/get-project-user) (vlo/get-jobfile-name) key)
(message "Deploying \"%s\"..." key))
(message "No DataPack file found for this component!"))))
;; DONE
(defun vlo/deployAllAction ()
"Description."
(interactive)
(if (yes-or-no-p "Are you sure you wish to deploy everything? ")
(vlo/packDeploy (vlo/get-project-user) (vlo/get-jobfile-name))
(message "Cancelled")))
(defun vlo/transient-action ()
"Dynamically choose which transient to show based on if currently in a project."
(interactive)
(if (vlo/in-project)
(if (vlo/in-vlocity-project)
(vlo/transient-project-action)
(vlo/transient-init-action)))
(define-transient-command vlo/transient-init-action ()
"Vlocity Build Tool CLI Actions"
["Initialize"
("c" "Create project file" vlo/generate-project-file)])
["Vlocity Project file not created"
("i" "Initialize Vlocity Project" vlo/generate-project-file)])
(define-transient-command vlo/transient-project-action ()
"Vlocity Build Tool CLI Actions"
;; ["Environments"
;; ("a" "Add new org environment" vlo/transient-action)]
["List"
("l" "get available list" vlo/packList)]
["Actions"
("r" "retrieve" vlo/packExport)
("d" "deploy" vlo/packDeploy)])
["Create"
("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)
]
["Deploy"
("d" "deploy this datapack" vlo/deployThisAction)
("D" "deploy all local datapacks" vlo/deployAllAction)
])

Loading…
Cancel
Save