Skip to content

Commit

Permalink
Developer tooling (vim, psqlrc, etc) (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster authored Apr 21, 2024
1 parent e7b2406 commit b0e903f
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 14 deletions.
67 changes: 54 additions & 13 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ image::https://github.com/fnf-org/TicketBooth/actions/workflows/rspec.yml/badge.
image::https://github.com/fnf-org/TicketBooth/actions/workflows/lint.yml/badge.svg[TicketBooth CI: RuboCop,link=https://github.com/fnf-org/TicketBooth/actions/workflows/lint.yml]
image:https://github.com/fnf-org/TicketBooth/actions/workflows/build.yaml/badge.svg[Docker Image Build,link="https://github.com/fnf-org/TicketBooth/actions/workflows/build.yaml"]
https://github.com/fnf-org/TicketBooth/actions/workflows/deploy.yml[image:https://github.com/fnf-org/TicketBooth/actions/workflows/deploy.yml/badge.svg[DeployToGKE]]
https://github.com/fnf-org/TicketBooth/actions/workflows/build.yml[image:https://github.com/fnf-org/TicketBooth/actions/workflows/build.yml/badge.svg[Create
and publish a Docker image]]
====

NOTE: This app is formerly known as **Helping Culture**, which in turn was originally conceived and inspired by Tracy Page. This project was originally written by https://github.com/sds[Shane de Silva]. It is currently maintained by the https://github.com/fnf-org[FnF] org, and within it specifically https://github.com/kigster[Konstantin Gredeskoul] for any application issues, and https://github.com/mike-matera[Mike Matera] for any issues related to deployment to the Google Public Cloud. Please use labels to tag any reported issues.
NOTE: Please see the https://github.com/fnf-org/TicketBooth/blob/main/README.pdf[README.pdf] for the PDF version of this README.

NOTE: Please see the xref:README.pdf[following link] for a PDF version of this README.
NOTE: Please see the xref:#acknowledgements[Acknowledgements] at the end of this page.

== Welcome to the *Ticket Booth*!

Expand All @@ -30,6 +34,19 @@ The following walks through a local setup on OS-X M1.

If you installed https://brew.sh[Homebrew] on your laptop, you should be able to boot the app.

==== Optional VIM and PostgreSQL Local Configuration

We provided a pretty comprehensive VIM configuration with auto-complete, as well as the `psql` configuration with a prompt and additional useful macros.

To install this, run

[source,bash]
bin/install-dev-tooling

After that, your `vim` sessions will have auto-complete enabled, and your `psql -U postgres` sessions will have rich prompt.

==== Running App Dependencies Installer

You can run the following setup script to attempt a complete set up of the development environment, as well as the installation of the Rubies, Gems and Database:

[source,bash]
Expand All @@ -46,7 +63,7 @@ After you stop it with `Ctrl-C`, you can restart the server using the following
[source,bash]
make dev

This actually starts Foreman via `bundle exec foreman -f Procfile.dev` — this is required to start CSS and JS just-in-time compilcation in addition to the Rails server.
This actually starts Foreman via `bundle exec foreman -f Procfile.dev` — this is required to start CSS and JS just-in-time compilcation in addition to the Rails server.

CAUTION: Running `rails s` is no longer sufficient to start the application.

Expand Down Expand Up @@ -102,6 +119,20 @@ direnv allow .

This will load the environment variables from the `.envrc` file.

==== Manual 3: NodeJS & Votal Setup

Run the following to get Volta Node Manager working:

[source,bash]
----
curl https://get.volta.sh | bash
volta install node@lts
volta install yarn
volta pin node yarn
----

Now your Node & Yarn should be installed.

==== Manual 3: Ruby Setup

[source,bash]
Expand All @@ -115,35 +146,33 @@ brew install rbenv ruby-build direnv volta
eval "$(rbenv init -)"
eval "$(direnv hook ${SHELL/*\/})"
direnv allow .
rbenv install -s $(cat .ruby-version)
rbenv local $(cat .ruby-version)
volta install node@lts
bundle install -j 12
rails db:create
rails db:migrate db:seed
rails db:prepare
rails db:test:prepare
# Run Specs at the end:
bundle exec rspec
bundle exec rspec --parallel
----

==== Manual 4: Starting the Server

To start the server post-setup, run:
To start the server post-setup, run the following (NOTE: you must start the server via Foreman, since it also starts `yarn` tasks that monitor and dynamically recompile CSS and JS assets)

[source,bash]
----
bin/rails s
# or just
rails s
bundle exec foreman -f Procfile.dev
----

You can also use the `Makefile`:

[source,bash]
----
make development boot
make dev
----

Here is an example:
Expand Down Expand Up @@ -228,4 +257,16 @@ $ bundle exec rake doc
----


== Acknowledgements

This app is formerly known as **Helping Culture**, which in turn was originally conceived and inspired by Tracy Page.

This project was originally written by https://github.com/sds[Shane de Silva].

It is currently maintained by the https://github.com/fnf-org[FnF] org, and within it specifically

* https://github.com/kigster[Konstantin Gredeskoul] for any application issues,
* https://github.com/mike-matera[Mike Matera] for any issues related to deployment to the Google Public Cloud.
* https://github.com/beingmattlevy[Matt Levy] for development, coordination and project management.

Please use labels to tag any reported issues.
45 changes: 45 additions & 0 deletions bin/install-dev-tooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2002,SC2207
# vim: ft=bash

export BASHMATIC_HOME="${BASHMATIC_HOME:-"${HOME}/.bashmatic"}"
[[ -z ${BASHMATIC_HOME} ]] && export BASHMATIC_HOME="${HOME}/.bashmatic"
[[ -d ${BASHMATIC_HOME} ]] || bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -q"
[[ -d ${BASHMATIC_HOME} ]] || {
echo "Can't find Bashmatic, even after attempting an installation."
echo "Please install Bashmatic with the following command line:"
echo 'bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install"'
exit 1
}

# shellcheck source="${BASHMATIC_HOME}/init.sh"
source "${BASHMATIC_HOME}/init" >/dev/null
output.constrain-screen-width 100

declare -g timestamp
export timestamp="$(time.now.db)"

h1 "Installing Brew Packages..."
run.set-all continue-on-error
run "brew bundle --no-upgrade --no-lock"
run.set-all abort-on-error

if [[ -d ~/.vim && -f ~/.vimrc ]]; then
h2 "Making a backup of your Current VIM Setup"
run "cp -p -v ~/.vimrc ~/.vimrc.${timestamp}"
fi

h1 "Installing custom vim configuration locally..."
run "cp -f development/config/.vimrc ${HOME}"
run "cp -f development/config/.vimrc.customizations ${HOME}"

h1 "Installing VIM Plugins... Please wait."
run.set-next show-output-on
run "vim -E +PlugInstall +qall"

h1 "Installing ~/.psqlrc"
run "mv ~/.psqlrc ~/.psqlrc.${timestamp}"
run.set-next show-output-on
run "cp -p -v development/config/.psqlrc* ${HOME}"


File renamed without changes.
132 changes: 131 additions & 1 deletion development/config/.vimrc
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
" vim: ft=vim

syntax on

set autoindent
set autoread
set background=dark
set encoding=utf8
set expandtab
set hlsearch
set ignorecase
set laststatus=2
set magic
set mat=2
set nobackup
set noerrorbells
set noswapfile
set novisualbell
set nowb
set shiftwidth=2
set smartindent
set softtabstop=2

"map <C-S-L> * exe mzgg=G`z
"map <C-S-L> * exe mzgg=G`z
"map ,l * exe mzgg=G`z

if has ("autocmd")
filetype indent on
endif

"set guicursor+=n-v-c:blinkon0

filetype plugin indent on
:filetype plugin on

map \ :NERDTreeToggle<cr>
map ,t q:Vipe bundle exec rspec <c-r>%:<c-r>=line('.')<cr><cr>
set wildignore+=*/tmp/*,*.so,*.swp,*.zip

" set *.hamlc files to haml syntax
:autocmd BufRead,BufNewFile *.itermcolors setfiletype xml
:autocmd BufRead,BufNewFile *.json setfiletype json
:autocmd BufRead,BufNewFile *.nmap setfiletype nmap
:autocmd BufRead,BufNewFile *.hamlc setfiletype haml
:autocmd BufRead,BufNewFile *.html setfiletype html
:autocmd BufRead,BufNewFile *.css setfiletype css
:autocmd BufRead,BufNewFile zone* setfiletype bind
:autocmd BufRead,BufNewFile *.zone setfiletype bind

:autocmd FileType cpp setlocal shiftwidth=4 tabstop=4
:autocmd BufNewFile,BufReadPost zone*,*.zone set filetype=bind
:autocmd BufNewFile,BufReadPost *.itermcolors set filetype=xml
:autocmd BufNewFile,BufReadPost *.ino,*.pde set filetype=cpp
:autocmd BufNewFile,BufReadPost *.sh,*.bash,*.bats set filetype=sh
:autocmd BufNewFile,BufReadPost *.yaml,*.yml set filetype=yaml
:autocmd BufNewFile,BufReadPost *.html set filetype=html
:autocmd BufNewFile,BufReadPost *.sql set filetype=sql
:autocmd BufNewFile,BufReadPost *.haml set filetype=haml
:autocmd BufNewFile,BufReadPost *.rb,*.rake,*.cap,Procfile*,Rakefile,Capfile,Gemfile,*.gemspec,*.tpl set filetype=ruby
:autocmd BufNewFile,BufReadPost *.conf set filetype=nginx

"
" 1 = horizontal, 2 = vertical, 3 = new tab, 4 = previous window
"
let g:netrw_browse_split = 4
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_altv = 1
let g:netrw_winsize = 25

" Auto-install Plugged
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')

Plug 'airblade/vim-gitgutter'
Plug 'altercation/vim-colors-solarized'
Plug 'bazelbuild/vim-bazel'
Plug 'cespare/vim-toml'
Plug 'chr4/nginx.vim'
Plug 'chrisbra/Colorizer'
Plug 'fatih/vim-go', { 'tag': '*' }
Plug 'gisphm/vim-gitignore'
Plug 'google/vim-maktaba'
Plug 'habamax/vim-asciidoctor'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/vim-plug'
Plug 'mattn/emmet-vim'
Plug 'mxw/vim-jsx'
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
Plug 'pangloss/vim-javascript'
Plug 'phanviet/vim-monokai-pro'
Plug 'psliwka/vim-smoothie'
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
Plug 'rhysd/vim-syntax-codeowners'
Plug 'rust-lang/rust.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'sbdchd/vim-shebang'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'sheerun/vim-polyglot'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-ruby/vim-ruby'
Plug 'dmmulroy/tsc.nvim', {'branch': 'main'}

call plug#end()

try
source ~/.vimrc.customizations
catch
" No such file? No problem; just ignore it.
endtry
1 change: 1 addition & 0 deletions development/config/.vimrc.customizations
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,4 @@ nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
Binary file added docs/make-boot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b0e903f

Please sign in to comment.