diff --git a/lisp/04-custom-init.el b/lisp/04-custom-init.el index d2b29dd..1315f61 100644 --- a/lisp/04-custom-init.el +++ b/lisp/04-custom-init.el @@ -5,15 +5,16 @@ ;;; Code: (defvar backup-dir (expand-file-name "~/.emacs.d/backup/") "Set the default location of file backups.") -(defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/") "Set the default location of autosaves.") +;; (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/") "Set the default location of autosaves.") (cond ((member "PragmataPro Liga" (font-family-list)) (set-face-attribute 'default nil :font "PragmataPro Liga-16"))) -(setq initial-scratch-message nil - backup-directory-alist (list (cons ".*" backup-dir)) - auto-save-list-file-prefix autosave-dir - auto-save-file-name-transforms `((".*" ,autosave-dir t))) +(setq-default initial-scratch-message nil + backup-directory-alist (list (cons ".*" backup-dir)) + ;; auto-save-list-file-prefix autosave-dir + ;; auto-save-file-name-transforms `((".*" ,autosave-dir t)) + ) ;; Turn off the menus, scrollbars, and toolbars (menu-bar-mode 0) @@ -76,7 +77,7 @@ (defvar browse-url-generic-program) (defvar engine/browser-function) ;; (setq ; browse-url-generic-program "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" - ;; browse-url-browser-function 'browse-url-generic) +;; browse-url-browser-function 'browse-url-generic) (setq browse-url-browser-function 'browse-url-generic engine/browser-function 'browse-url-generic diff --git a/lisp/05-custom-functions.el b/lisp/05-custom-functions.el index 30f8454..efdadf3 100644 --- a/lisp/05-custom-functions.el +++ b/lisp/05-custom-functions.el @@ -209,7 +209,7 @@ (defun leo/auth-source-unfunc (secret) "Unfurl the SECRET." (if (functionp secret) - (funcall secret) + (funcall secret) secret)) (defun leo/url-encode (str) @@ -223,5 +223,5 @@ (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))))) - (provide '05-custom-functions) +(provide '05-custom-functions) ;;; 05-custom-functions.el ends here diff --git a/lisp/07_5-custom-created-packages.el b/lisp/07_5-custom-created-packages.el index 4aff431..164cdd7 100644 --- a/lisp/07_5-custom-created-packages.el +++ b/lisp/07_5-custom-created-packages.el @@ -4,9 +4,29 @@ ;;; Code: -(require 'sfdx) -(require 'convert-to-table) -(require 'ol-dired) + +(use-package convert-to-table + :defer 5 + :load-path "custom/convert-to-table") + +(use-package ol-dired + :defer 5 + :load-path "custom/ol-dired") + +(use-package sfdx + :defer 5 + :load-path "custom/sfdx" + :bind + ("M-" . sfdx/next-component-file) + ("C-x C-l s" . sfdx/transient-action)) + +(use-package vlocitemacs + :defer 5 + :load-path "custom/vlocitemacs" + :bind + ("C-x C-l v" . vlo/transient-action)) + + (provide '07_5-custom-created-packages) ;;; 07_5-custom-created-packages.el ends here diff --git a/lisp/08-custom-packages.el b/lisp/08-custom-packages.el index 484f237..299a6f6 100644 --- a/lisp/08-custom-packages.el +++ b/lisp/08-custom-packages.el @@ -369,6 +369,12 @@ :ensure t :mode "\\.json\\'") +;; https://github.com/mojochao/npm-mode +(use-package npm-mode + :ensure t + :custom + (npm-mode-command-prefix "C-c r")) + ;; https://github.com/antonj/scss-mode (use-package scss-mode :ensure t @@ -612,8 +618,6 @@ ("M-u" . upcase-dwim) ("M-c" . capitalize-dwim) ("M-l" . downcase-dwim) - ("M-" . sfdx/next-component-file) - ("C-x C-l s" . sfdx/transient-action) ;; ("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) diff --git a/lisp/custom/sfdx.el b/lisp/custom/sfdx.el index 5eab5b8..c35d3b1 100644 --- a/lisp/custom/sfdx.el +++ b/lisp/custom/sfdx.el @@ -22,12 +22,16 @@ (when (string= current-ext "html") (if (file-exists-p (concat current-file-name ".css")) (find-file (concat current-file-name ".css")) - (if (and sfdx-create-css (yes-or-no-p "Do you want to create a CSS file?")) - (find-file (concat current-file-name ".css")) - (setq-local sfdx-create-css nil) - (find-file (concat current-file-name ".js"))))) + (if (file-exists-p (concat current-file-name ".scss")) + (find-file (concat current-file-name ".scss")) + (if (and sfdx-create-css (yes-or-no-p "Do you want to create a CSS file?")) + (find-file (concat current-file-name ".css")) + (setq-local sfdx-create-css nil) + (find-file (concat current-file-name ".js")))))) (when (string= current-ext "css") (find-file (concat current-file-name ".js"))) + (when (string= current-ext "scss") + (find-file (concat current-file-name ".js"))) )) (defun sfdx--goto-project (project-path) @@ -76,16 +80,16 @@ (insert (format "Starting deployment of %s...\n" comp-name)) (start-process process buffer "sh" "-c" (concat "cd " cd-dir "; sfdx force:source:deploy --sourcepath ./force-app/main/default/lwc/" comp-name " --loglevel fatal")) ) - (progn - (delete-other-windows) - (split-window-below 40) - (other-window 1) - (switch-to-buffer buffer) - (erase-buffer) - (local-set-key (kbd "q") 'delete-window) - (insert "Starting deployment of project...\n") - (start-process process buffer "sh" "-c" (concat "cd " cd-dir "; sfdx force:source:deploy --sourcepath ./force-app/main/default/ --loglevel fatal")) - ) + (progn + (delete-other-windows) + (split-window-below 40) + (other-window 1) + (switch-to-buffer buffer) + (erase-buffer) + (local-set-key (kbd "q") 'delete-window) + (insert "Starting deployment of project...\n") + (start-process process buffer "sh" "-c" (concat "cd " cd-dir "; sfdx force:source:deploy --sourcepath ./force-app/main/default/ --loglevel fatal")) + ) ) ) ) diff --git a/lisp/custom/vlocitemacs.el b/lisp/custom/vlocitemacs.el new file mode 100644 index 0000000..18858f4 --- /dev/null +++ b/lisp/custom/vlocitemacs.el @@ -0,0 +1,127 @@ +;;; vlocitemacs.el --- Vlocity Build Tool :: Emacs integration + +;;; Commentary: +;; +;; Essentially the following commands are abstracted into elisp and made dynamic: +;; +;; vlocity packDeploy -propertyfile build.properties -job job.yaml -key VlocityUITemplate/Test-test +;; vlocity packExport -propertyfile build.properties -job job.yaml -key VlocityUITemplate/Test-test +;; +;; +;;; Code: + +(require 'transient) + +(use-package json + :ensure t + :straight (:host github :repo "ryancrum/json.el" :branch "master")) + + +(defun vlo/generate-sfdx-login-list () + "This function is used to give a list of choices (Orgs) to the user when deploying/exporting." + ;; 1. make temp file to put the output of `sfdx force:org:list --json` in + ;; 2. read that into the following + ;; + ;; let* means the variables can ref each other + (let* ((json-object-type 'hash-table) + (json-array-type 'list) + (json-key-type 'string) + (json (json-read-file "tempfile-location.json"))) + ;; this is how we access the first item of the "result" json member + (car (gethash "result" json)) + ) + ) + +(defvar vlo/orgs '(("build.properties" . "job.yaml")) + "List of cons-es that relate a properties file to a job file.") + +(defvar vlo/project-file-name ".vemacs" + "The name of the VlocitEmacs file.") + +(defvar vlo/store-user nil "Store SFDX user for current session.") + +(defun vlo/get-user () + "Prompt for sfdx username or use stored." + (if vlo/store-user + vlo/store-user + (read-string + + ;; (defun vlo/get-propertyfile-name () + ;; "The name of the build.properties file." + ;; (car (nth 0 vlo/orgs))) + + ;; (defun vlo/get-jobfile-name () + ;; "The name of the job.yaml file." + ;; (cdr (nth 0 vlo/orgs))) + + (defun vlo/get-deployment-key () + "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)) "/")))) + (format "%s/%s" + (nth (- (length path-list) 2) path-list) + (nth (- (length path-list) 1) path-list)))) + + (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)) + + (defun vlo/ensure-init-file () + "Asserts that you're currently inside a vlocity project." + (vlo/project-path)) + + (defun leo/exec-process (cmd &optional comint) + "Execute a process running CMD and optionally pass COMINT as t to put buffer in `comint-mode'." + (let ((compilation-buffer-name-function + (lambda (mode) + (format "*exec-process*")))) + (message (concat "Running " cmd)) + (compile cmd comint))) + + + + + (defun vlo/packExport () + "Run the packExport command." + (interactive) + (if (and (file-exists-p (vlo/get-propertyfile-name)) + (file-exists-p (vlo/get-jobfile-name))) + (leo/exec-process + (format "cd %s; vlocity packExport -sfdx.username %s -job %s -key %s" + (vlo/ensure-init-file) + (vlo/get-user) + (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))))) + + (defun vlo/packDeploy () + "Run the packDeploy command." + (interactive) + (if (and (file-exists-p (vlo/get-propertyfile-name)) + (file-exists-p (vlo/get-jobfile-name))) + (leo/exec-process + (format "cd %s; vlocity packDeploy -sfdx.username %s -job %s -key %s" + (vlo/ensure-init-file) + (vlo/get-user) + (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))))) + + (define-transient-command vlo/transient-action () + "Vlocity Build Tool CLI Actions" + ["Actions" + ("e" "export" vlo/packExport) + ("d" "deploy" vlo/packDeploy)]) + + + + + + (provide 'vlocitemacs) +;;; vlocitemacs.el ends here