2025-01-21 14:37:05 -08:00
( defun snowball-reformat-chanced-file ( )
" Run the current buffer through Pint. "
( interactive )
( let ( ( format-file-name ( concat " fmt- " ( file-name-nondirectory ( buffer-file-name ) ) ) ) )
( unwind-protect
( progn
( write-region ( point-min ) ( point-max ) format-file-name )
( shell-command
( format " %s %s "
( expand-file-name " ../chanced-scripts/format " ( project-root ( project-current ) ) )
( file-relative-name format-file-name ( project-root ( project-current ) ) ) )
nil nil )
( let ( ( temp-buffer ( find-file-noselect format-file-name ) ) )
( unwind-protect
( replace-buffer-contents temp-buffer )
( kill-buffer temp-buffer ) ) ) )
( delete-file format-file-name ) ) ) )
( defun tomwpunt:enable-directory-local-modes ( )
" Enable hooks and modes that are bound to specific directory. "
( cond
( ( string-suffix-p " src/social-api/ " ( or ( and-let* ( ( project ( project-current ) ) )
( project-root project ) )
" " ) )
( local-set-key ( kbd " C-c c " ) #' artisan-transient )
( when ( equal major-mode 'php-mode )
( add-hook 'before-save-hook 'snowball-reformat-chanced-file nil t ) ) ) ) )
( add-hook 'find-file-hook 'tomwpunt:enable-directory-local-modes )
( transient-define-prefix artisan-transient ( )
" A transient to run artisan commands. "
[ " Punt "
[ " Composer "
( " pci " " Install " artisan-punt-composer-install ) ]
[ " Artisan "
( " pac " " Run Command " artisan-punt-run-command )
( " pam " " Migrate " artisan-punt-migrate )
( " pat " " Test " artisan-punt-test ) ] ]
[ " Chanced "
[ " Composer "
( " cci " " Install " artisan-chanced-composer-install ) ]
[ " Artisan "
( " cac " " Run Command " artisan-chanced-run-command )
( " cam " " Migrate " artisan-chanced-migrate )
( " cat " " Test " artisan-chanced-test ) ] ] )
( defun artisan-punt-composer-install ( )
( interactive )
( let ( ( default-directory ( expand-file-name " punt " ( project-root ( project-current ) ) ) ) )
( async-shell-command " docker exec -it punt-backend composer install " ) ) )
( defun artisan-chanced-composer-install ( )
( interactive )
( let ( ( default-directory ( expand-file-name " chanced " ( project-root ( project-current ) ) ) ) )
( async-shell-command " docker exec -it chanced-backend composer install " ) ) )
( defun artisan-punt-run-command ( command )
( interactive
( list
( read-string " Command: " ) ) )
( let ( ( default-directory ( expand-file-name " punt " ( project-root ( project-current ) ) ) ) )
( async-shell-command ( format " docker exec -it punt-backend php artisan %s " command ) ) ) )
( defun artisan-chanced-run-command ( command )
( interactive
( list
( read-string " Command: " ) ) )
( let ( ( default-directory ( expand-file-name " chanced " ( project-root ( project-current ) ) ) ) )
( async-shell-command ( format " docker exec -it chanced-backend php artisan %s " command ) ) ) )
( defun artisan-punt-migrate ( )
( interactive )
( let ( ( default-directory ( expand-file-name " punt " ( project-root ( project-current ) ) ) ) )
( async-shell-command " docker exec -it punt-backend php artisan migrate " ) ) )
( defun artisan-chanced-migrate ( )
( interactive )
( let ( ( default-directory ( expand-file-name " chanced " ( project-root ( project-current ) ) ) ) )
( async-shell-command " docker exec -it chanced-backend php artisan migrate " ) ) )
( defun artisan-punt-test ( pick )
( interactive " P " )
( artisan--test-internal pick " punt " " chanced " ) )
( defun artisan-chanced-test ( pick )
( interactive " P " )
( artisan--test-internal pick " chanced " " punt " ) )
( defvar artisan--test-last-command nil
" The last testing commnand that was run in the test buffer.
This variable should always be buffer local and only set in test
buffers. " )
( make-variable-buffer-local 'artisan--test-last-command )
( defun artisan--test-internal ( pick name ignore )
( let* ( ( default-directory ( expand-file-name name ( project-root ( project-current ) ) ) )
( buffer-name ( format " *%s Tests* " ( capitalize name ) ) )
( buffer ( get-buffer-create buffer-name ) )
( files ( cons ' ( " all " . " " )
( mapcar ( lambda ( dir ) ( cons ( file-name-nondirectory dir ) dir ) )
( directory-files-recursively " ../ " ( rx " Test.php " ) nil ( lambda ( subdir ) ( not ( or ( string-suffix-p " vendor " subdir ) ( string-suffix-p ignore subdir ) ) ) ) ) ) ) )
( command ( with-current-buffer buffer
( or ( and ( not pick ) artisan--test-last-command )
( format " ../../chanced-scripts/test %s %s "
name ( map-elt files ( completing-read " File: " files nil t ) ) ) ) ) )
( compilation-scroll-output t ) )
( cl-letf ( ( ( symbol-function 'compilation-buffer-name )
( lambda ( &rest args ) buffer-name ) ) )
( compile command ) )
( with-current-buffer buffer
( setq artisan--test-last-command command )
( local-set-key ( kbd " g " )
( lambda ( )
( interactive )
( artisan--test-internal nil name ignore ) ) )
2025-01-24 12:14:56 -08:00
( local-set-key ( kbd " q " ) #' bury-buffer )
( local-set-key ( kbd " s " ) ( lambda ( ) ( interactive ) ( interrupt-process ) ) ) ) ) )
2025-02-05 13:45:46 -08:00
( require 'dashboard )
( dashboard-setup-startup-hook )
( run-with-idle-timer 300 t ( lambda ( ) ( switch-to-buffer dashboard-buffer-name ) ) )
( run-at-time " 02:00 " 86400 #' dashboard-open )
2025-02-07 08:59:20 -08:00
( setq dashboard-navigator-buttons ` ( ( ( , ( propertize " " 'display ` ( image :type svg :file , ( expand-file-name " search.svg " oni-gui-icons-dir ) :ascent center :margin ( 5 . 0 ) ) ) " PRs " " Open pull requests "
( lambda ( &rest _ )
( browse-url " https://github.com/pulls?q=is%3Aopen+is%3Apr+org%3Ajuked-social+draft%3Afalse+review%3Anone+-author%3Aapp%2Fdependabot " ) )
default " [ " " ] " ) )
( ( , ( propertize " " 'display ` ( image :type svg :file , ( expand-file-name " search.svg " oni-gui-icons-dir ) :ascent center :margin ( 5 . 0 ) ) ) " back-end " " Unmerged into back-end "
( lambda ( &rest _ )
( browse-url " https://github.com/juked-social/social-api/compare/main...staging " ) )
default " [ " " ] " )
( , ( propertize " " 'display ` ( image :type svg :file , ( expand-file-name " search.svg " oni-gui-icons-dir ) :ascent center :margin ( 5 . 0 ) ) ) " chanced " " Unmerged into chanced front-end "
( lambda ( &rest _ )
( browse-url " https://github.com/juked-social/chanced-frontend/compare/main...staging " ) )
default " [ " " ] " )
( , ( propertize " " 'display ` ( image :type svg :file , ( expand-file-name " search.svg " oni-gui-icons-dir ) :ascent center :margin ( 5 . 0 ) ) ) " punt " " Unmerged into punt front-end "
( lambda ( &rest _ )
( browse-url " https://github.com/juked-social/punt-frontend/compare/main...staging " ) )
default " [ " " ] " ) ) ) )
( setq dashboard-set-navigator t )
2025-02-05 13:45:46 -08:00
( add-hook 'server-after-make-frame-hook #' dashboard-open )