├── .devcontainer └── devcontainer.json ├── .docker ├── mongo │ └── db.js ├── start.sh └── zsh │ ├── history │ └── .zsh_history │ └── powerlevel10k │ └── .p10k.zsh ├── .dockerignore ├── .env ├── .env.prod ├── .env.test ├── .eslintrc.js ├── .github └── workflows │ └── ci_cd.yml ├── .gitignore ├── .prettierrc ├── .swcrc ├── Dockerfile.dev ├── Dockerfile.prod ├── README.md ├── api.http ├── docker-compose.prod.yaml ├── docker-compose.yaml ├── nest-cli.json ├── package-lock.json ├── package.json ├── src ├── app.controller.spec.ts ├── app.controller.ts ├── app.module.ts ├── app.service.ts ├── main.ts └── tweets │ ├── dto │ ├── create-tweet.dto.ts │ └── update-tweet.dto.ts │ ├── entities │ ├── tweet.entity.spec.ts │ └── tweet.entity.ts │ ├── tweets.controller.spec.txt │ ├── tweets.controller.ts │ ├── tweets.module.ts │ ├── tweets.service.spec.ts │ └── tweets.service.ts ├── test ├── app.e2e-spec.ts └── tweets.e2e-spec.ts ├── tsconfig.build.json └── tsconfig.json /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/docker-existing-docker-compose 3 | // If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. 4 | { 5 | "name": "Nestjs Tweets", 6 | 7 | // Update the 'dockerComposeFile' list if you have more compose files or use different names. 8 | // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. 9 | "dockerComposeFile": [ 10 | "../docker-compose.yaml" 11 | ], 12 | 13 | // The 'service' property is the name of the service for the container that VS Code should 14 | // use. Update this value and .devcontainer/docker-compose.yml to the real service name. 15 | "service": "app", 16 | 17 | // The optional 'workspaceFolder' property is the path VS Code should open by default when 18 | // connected. This is typically a file mount in .devcontainer/docker-compose.yml 19 | "workspaceFolder": "/home/node/app", 20 | "extensions": [ 21 | "dbaeumer.vscode-eslint", 22 | "esbenp.prettier-vscode", 23 | "ms-vscode.vscode-typescript-tslint-plugin", 24 | "msjsdiag.debugger-for-chrome", 25 | "msjsdiag.vscode-react-native", 26 | "octref.vetur", 27 | "PKief.material-icon-theme", 28 | "ritwickdey.LiveServer", 29 | "vuetifyjs.vuetify-vscode" 30 | ] 31 | 32 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 33 | // "forwardPorts": [], 34 | 35 | // Uncomment the next line if you want start specific services in your Docker Compose config. 36 | // "runServices": [], 37 | 38 | // Uncomment the next line if you want to keep your containers running after VS Code shuts down. 39 | // "shutdownAction": "none", 40 | 41 | // Uncomment the next line to run commands after the container is created - for example installing curl. 42 | // "postCreateCommand": "apt-get update && apt-get install -y curl", 43 | 44 | // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. 45 | // "remoteUser": "vscode" 46 | } 47 | -------------------------------------------------------------------------------- /.docker/mongo/db.js: -------------------------------------------------------------------------------- 1 | // criar banco de dados 2 | // criar usuarios 3 | // registros -------------------------------------------------------------------------------- /.docker/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | npm install 4 | 5 | tail -f /dev/null 6 | #npm run start:dev -------------------------------------------------------------------------------- /.docker/zsh/history/.zsh_history: -------------------------------------------------------------------------------- 1 | : 1665622865:0;code ~/.zshrc 2 | : 1665622888:0;cat /tmp/node-code-zsh/.p10k.zsh 3 | : 1665622903:0;cp /tmp/node-code-zsh/.p10k.zsh ~/.p10k.zsh 4 | : 1665622911:0;cat ~/.p10k.zsh 5 | : 1665622949:0;node -v 6 | : 1665622962:0;docker run etc etc etc etc 7 | -------------------------------------------------------------------------------- /.docker/zsh/powerlevel10k/.p10k.zsh: -------------------------------------------------------------------------------- 1 | # Generated by Powerlevel10k configuration wizard on 2022-10-13 at 01:00 UTC. 2 | # Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 30611. 3 | # Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 2 lines, 4 | # disconnected, no frame, sparse, few icons, concise, instant_prompt=quiet. 5 | # Type `p10k configure` to generate another config. 6 | # 7 | # Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate 8 | # your own config based on it. 9 | # 10 | # Tip: Looking for a nice color? Here's a one-liner to print colormap. 11 | # 12 | # for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done 13 | 14 | # Temporarily change options. 15 | 'builtin' 'local' '-a' 'p10k_config_opts' 16 | [[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') 17 | [[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') 18 | [[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') 19 | 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' 20 | 21 | () { 22 | emulate -L zsh -o extended_glob 23 | 24 | # Unset all configuration options. This allows you to apply configuration changes without 25 | # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. 26 | unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' 27 | 28 | # Zsh >= 5.1 is required. 29 | [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return 30 | 31 | # The list of segments shown on the left. Fill it with the most important segments. 32 | typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( 33 | # =========================[ Line #1 ]========================= 34 | # os_icon # os identifier 35 | dir # current directory 36 | vcs # git status 37 | # =========================[ Line #2 ]========================= 38 | newline # \n 39 | prompt_char # prompt symbol 40 | ) 41 | 42 | # The list of segments shown on the right. Fill it with less important segments. 43 | # Right prompt on the last prompt line (where you are typing your commands) gets 44 | # automatically hidden when the input line reaches it. Right prompt above the 45 | # last prompt line gets hidden if it would overlap with left prompt. 46 | typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( 47 | # =========================[ Line #1 ]========================= 48 | status # exit code of the last command 49 | command_execution_time # duration of the last command 50 | background_jobs # presence of background jobs 51 | direnv # direnv status (https://direnv.net/) 52 | asdf # asdf version manager (https://github.com/asdf-vm/asdf) 53 | virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) 54 | anaconda # conda environment (https://conda.io/) 55 | pyenv # python environment (https://github.com/pyenv/pyenv) 56 | goenv # go environment (https://github.com/syndbg/goenv) 57 | nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) 58 | nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) 59 | nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) 60 | # node_version # node.js version 61 | # go_version # go version (https://golang.org) 62 | # rust_version # rustc version (https://www.rust-lang.org) 63 | # dotnet_version # .NET version (https://dotnet.microsoft.com) 64 | # php_version # php version (https://www.php.net/) 65 | # laravel_version # laravel php framework version (https://laravel.com/) 66 | # java_version # java version (https://www.java.com/) 67 | # package # name@version from package.json (https://docs.npmjs.com/files/package.json) 68 | rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) 69 | rvm # ruby version from rvm (https://rvm.io) 70 | fvm # flutter version management (https://github.com/leoafarias/fvm) 71 | luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) 72 | jenv # java version from jenv (https://github.com/jenv/jenv) 73 | plenv # perl version from plenv (https://github.com/tokuhirom/plenv) 74 | perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) 75 | phpenv # php version from phpenv (https://github.com/phpenv/phpenv) 76 | scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) 77 | haskell_stack # haskell version from stack (https://haskellstack.org/) 78 | kubecontext # current kubernetes context (https://kubernetes.io/) 79 | terraform # terraform workspace (https://www.terraform.io) 80 | # terraform_version # terraform version (https://www.terraform.io) 81 | aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) 82 | aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) 83 | azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) 84 | gcloud # google cloud cli account and project (https://cloud.google.com/) 85 | google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) 86 | toolbox # toolbox name (https://github.com/containers/toolbox) 87 | context # user@hostname 88 | nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) 89 | ranger # ranger shell (https://github.com/ranger/ranger) 90 | nnn # nnn shell (https://github.com/jarun/nnn) 91 | xplr # xplr shell (https://github.com/sayanarijit/xplr) 92 | vim_shell # vim shell indicator (:sh) 93 | midnight_commander # midnight commander shell (https://midnight-commander.org/) 94 | nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) 95 | # vpn_ip # virtual private network indicator 96 | # load # CPU load 97 | # disk_usage # disk usage 98 | # ram # free RAM 99 | # swap # used swap 100 | todo # todo items (https://github.com/todotxt/todo.txt-cli) 101 | timewarrior # timewarrior tracking status (https://timewarrior.net/) 102 | taskwarrior # taskwarrior task count (https://taskwarrior.org/) 103 | # cpu_arch # CPU architecture 104 | # time # current time 105 | # =========================[ Line #2 ]========================= 106 | newline 107 | # ip # ip address and bandwidth usage for a specified network interface 108 | # public_ip # public IP address 109 | # proxy # system-wide http/https/ftp proxy 110 | # battery # internal battery 111 | # wifi # wifi speed 112 | # example # example user-defined segment (see prompt_example function below) 113 | ) 114 | 115 | # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. 116 | typeset -g POWERLEVEL9K_MODE=nerdfont-complete 117 | # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid 118 | # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. 119 | typeset -g POWERLEVEL9K_ICON_PADDING=none 120 | 121 | # Basic style options that define the overall look of your prompt. You probably don't want to 122 | # change them. 123 | typeset -g POWERLEVEL9K_BACKGROUND= # transparent background 124 | typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace 125 | typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space 126 | typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol 127 | 128 | # When set to true, icons appear before content on both sides of the prompt. When set 129 | # to false, icons go after content. If empty or not set, icons go before content in the left 130 | # prompt and after content in the right prompt. 131 | # 132 | # You can also override it for a specific segment: 133 | # 134 | # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false 135 | # 136 | # Or for a specific segment in specific state: 137 | # 138 | # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false 139 | typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true 140 | 141 | # Add an empty line before each prompt. 142 | typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true 143 | 144 | # Connect left prompt lines with these symbols. 145 | typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= 146 | typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= 147 | typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= 148 | # Connect right prompt lines with these symbols. 149 | typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= 150 | typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= 151 | typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= 152 | 153 | # The left end of left prompt. 154 | typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= 155 | # The right end of right prompt. 156 | typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= 157 | 158 | # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll 159 | # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and 160 | # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. 161 | typeset -g POWERLEVEL9K_SHOW_RULER=false 162 | typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' 163 | typeset -g POWERLEVEL9K_RULER_FOREGROUND=242 164 | 165 | # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' 166 | # to make it easier to see the alignment between left and right prompt and to separate prompt 167 | # from command output. It serves the same purpose as ruler (see above) without increasing 168 | # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false 169 | # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact 170 | # prompt. 171 | typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' 172 | if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then 173 | # The color of the filler. 174 | typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 175 | # Add a space between the end of left prompt and the filler. 176 | typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' 177 | # Add a space between the filler and the start of right prompt. 178 | typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' 179 | # Start filler from the edge of the screen if there are no left segments on the first line. 180 | typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' 181 | # End filler on the edge of the screen if there are no right segments on the first line. 182 | typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' 183 | fi 184 | 185 | #################################[ os_icon: os identifier ]################################## 186 | # OS identifier color. 187 | typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= 188 | # Custom icon. 189 | # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' 190 | 191 | ################################[ prompt_char: prompt symbol ]################################ 192 | # Green prompt symbol if the last command succeeded. 193 | typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 194 | # Red prompt symbol if the last command failed. 195 | typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 196 | # Default prompt symbol. 197 | typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' 198 | # Prompt symbol in command vi mode. 199 | typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' 200 | # Prompt symbol in visual vi mode. 201 | typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' 202 | # Prompt symbol in overwrite vi mode. 203 | typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' 204 | typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true 205 | # No line terminator if prompt_char is the last segment. 206 | typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' 207 | # No line introducer if prompt_char is the first segment. 208 | typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= 209 | 210 | ##################################[ dir: current directory ]################################## 211 | # Default current directory color. 212 | typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 213 | # If directory is too long, shorten some of its segments to the shortest possible unique 214 | # prefix. The shortened directory can be tab-completed to the original. 215 | typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique 216 | # Replace removed segment suffixes with this symbol. 217 | typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= 218 | # Color of the shortened directory segments. 219 | typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 220 | # Color of the anchor directory segments. Anchor segments are never shortened. The first 221 | # segment is always an anchor. 222 | typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 223 | # Display anchor directory segments in bold. 224 | typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true 225 | # Don't shorten directories that contain any of these files. They are anchors. 226 | local anchor_files=( 227 | .bzr 228 | .citc 229 | .git 230 | .hg 231 | .node-version 232 | .python-version 233 | .go-version 234 | .ruby-version 235 | .lua-version 236 | .java-version 237 | .perl-version 238 | .php-version 239 | .tool-version 240 | .shorten_folder_marker 241 | .svn 242 | .terraform 243 | CVS 244 | Cargo.toml 245 | composer.json 246 | go.mod 247 | package.json 248 | stack.yaml 249 | ) 250 | typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" 251 | # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains 252 | # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is 253 | # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) 254 | # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers 255 | # and other directories don't. 256 | # 257 | # Optionally, "first" and "last" can be followed by ":" where is an integer. 258 | # This moves the truncation point to the right (positive offset) or to the left (negative offset) 259 | # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" 260 | # respectively. 261 | typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false 262 | # Don't shorten this many last directory segments. They are anchors. 263 | typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 264 | # Shorten directory if it's longer than this even if there is space for it. The value can 265 | # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, 266 | # directory will be shortened only when prompt doesn't fit or when other parameters demand it 267 | # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). 268 | # If set to `0`, directory will always be shortened to its minimum length. 269 | typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 270 | # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this 271 | # many columns for typing commands. 272 | typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 273 | # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least 274 | # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. 275 | typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 276 | # If set to true, embed a hyperlink into the directory. Useful for quickly 277 | # opening a directory in the file manager simply by clicking the link. 278 | # Can also be handy when the directory is shortened, as it allows you to see 279 | # the full directory that was used in previous commands. 280 | typeset -g POWERLEVEL9K_DIR_HYPERLINK=false 281 | 282 | # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON 283 | # and POWERLEVEL9K_DIR_CLASSES below. 284 | typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 285 | 286 | # The default icon shown next to non-writable and non-existent directories when 287 | # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. 288 | # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' 289 | 290 | # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different 291 | # directories. It must be an array with 3 * N elements. Each triplet consists of: 292 | # 293 | # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with 294 | # extended_glob option enabled. 295 | # 2. Directory class for the purpose of styling. 296 | # 3. An empty string. 297 | # 298 | # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. 299 | # 300 | # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories 301 | # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. 302 | # 303 | # For example, given these settings: 304 | # 305 | # typeset -g POWERLEVEL9K_DIR_CLASSES=( 306 | # '~/work(|/*)' WORK '' 307 | # '~(|/*)' HOME '' 308 | # '*' DEFAULT '') 309 | # 310 | # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one 311 | # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or 312 | # WORK_NON_EXISTENT. 313 | # 314 | # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an 315 | # option to define custom colors and icons for different directory classes. 316 | # 317 | # # Styling for WORK. 318 | # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' 319 | # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 320 | # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 321 | # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 322 | # 323 | # # Styling for WORK_NOT_WRITABLE. 324 | # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' 325 | # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 326 | # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 327 | # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 328 | # 329 | # # Styling for WORK_NON_EXISTENT. 330 | # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' 331 | # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 332 | # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 333 | # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 334 | # 335 | # If a styling parameter isn't explicitly defined for some class, it falls back to the classless 336 | # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls 337 | # back to POWERLEVEL9K_DIR_FOREGROUND. 338 | # 339 | typeset -g POWERLEVEL9K_DIR_CLASSES=() 340 | 341 | # Custom prefix. 342 | # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' 343 | 344 | #####################################[ vcs: git status ]###################################### 345 | # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. 346 | typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= 347 | 348 | # Untracked files icon. It's really a question mark, your font isn't broken. 349 | # Change the value of this parameter to show a different icon. 350 | typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' 351 | 352 | # Formatter for Git status. 353 | # 354 | # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. 355 | # 356 | # You can edit the function to customize how Git status looks. 357 | # 358 | # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: 359 | # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. 360 | function my_git_formatter() { 361 | emulate -L zsh 362 | 363 | if [[ -n $P9K_CONTENT ]]; then 364 | # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from 365 | # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. 366 | typeset -g my_git_format=$P9K_CONTENT 367 | return 368 | fi 369 | 370 | if (( $1 )); then 371 | # Styling for up-to-date Git status. 372 | local meta='%f' # default foreground 373 | local clean='%76F' # green foreground 374 | local modified='%178F' # yellow foreground 375 | local untracked='%39F' # blue foreground 376 | local conflicted='%196F' # red foreground 377 | else 378 | # Styling for incomplete and stale Git status. 379 | local meta='%244F' # grey foreground 380 | local clean='%244F' # grey foreground 381 | local modified='%244F' # grey foreground 382 | local untracked='%244F' # grey foreground 383 | local conflicted='%244F' # grey foreground 384 | fi 385 | 386 | local res 387 | 388 | if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then 389 | local branch=${(V)VCS_STATUS_LOCAL_BRANCH} 390 | # If local branch name is at most 32 characters long, show it in full. 391 | # Otherwise show the first 12 … the last 12. 392 | # Tip: To always show local branch name in full without truncation, delete the next line. 393 | (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line 394 | res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" 395 | fi 396 | 397 | if [[ -n $VCS_STATUS_TAG 398 | # Show tag only if not on a branch. 399 | # Tip: To always show tag, delete the next line. 400 | && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line 401 | ]]; then 402 | local tag=${(V)VCS_STATUS_TAG} 403 | # If tag name is at most 32 characters long, show it in full. 404 | # Otherwise show the first 12 … the last 12. 405 | # Tip: To always show tag name in full without truncation, delete the next line. 406 | (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line 407 | res+="${meta}#${clean}${tag//\%/%%}" 408 | fi 409 | 410 | # Display the current Git commit if there is no branch and no tag. 411 | # Tip: To always display the current Git commit, delete the next line. 412 | [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line 413 | res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" 414 | 415 | # Show tracking branch name if it differs from local branch. 416 | if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then 417 | res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" 418 | fi 419 | 420 | # Display "wip" if the latest commit's summary contains "wip" or "WIP". 421 | if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then 422 | res+=" ${modified}wip" 423 | fi 424 | 425 | # ⇣42 if behind the remote. 426 | (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" 427 | # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. 428 | (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " 429 | (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" 430 | # ⇠42 if behind the push remote. 431 | (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" 432 | (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " 433 | # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. 434 | (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" 435 | # *42 if have stashes. 436 | (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" 437 | # 'merge' if the repo is in an unusual state. 438 | [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" 439 | # ~42 if have merge conflicts. 440 | (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" 441 | # +42 if have staged changes. 442 | (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" 443 | # !42 if have unstaged changes. 444 | (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" 445 | # ?42 if have untracked files. It's really a question mark, your font isn't broken. 446 | # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. 447 | # Remove the next line if you don't want to see untracked files at all. 448 | (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" 449 | # "─" if the number of unstaged files is unknown. This can happen due to 450 | # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower 451 | # than the number of files in the Git index, or due to bash.showDirtyState being set to false 452 | # in the repository config. The number of staged and untracked files may also be unknown 453 | # in this case. 454 | (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" 455 | 456 | typeset -g my_git_format=$res 457 | } 458 | functions -M my_git_formatter 2>/dev/null 459 | 460 | # Don't count the number of unstaged, untracked and conflicted files in Git repositories with 461 | # more than this many files in the index. Negative value means infinity. 462 | # 463 | # If you are working in Git repositories with tens of millions of files and seeing performance 464 | # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output 465 | # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's 466 | # config: `git config bash.showDirtyState false`. 467 | typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 468 | 469 | # Don't show Git status in prompt for repositories whose workdir matches this pattern. 470 | # For example, if set to '~', the Git repository at $HOME/.git will be ignored. 471 | # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. 472 | typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' 473 | 474 | # Disable the default Git status formatting. 475 | typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true 476 | # Install our own Git status formatter. 477 | typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' 478 | typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' 479 | # Enable counters for staged, unstaged, etc. 480 | typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 481 | 482 | # Icon color. 483 | typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 484 | typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 485 | # Custom icon. 486 | typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION= 487 | # Custom prefix. 488 | # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' 489 | 490 | # Show status of repositories of these types. You can add svn and/or hg if you are 491 | # using them. If you do, your prompt may become slow even when your current directory 492 | # isn't in an svn or hg repository. 493 | typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) 494 | 495 | # These settings are used for repositories other than Git or when gitstatusd fails and 496 | # Powerlevel10k has to fall back to using vcs_info. 497 | typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 498 | typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 499 | typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 500 | 501 | ##########################[ status: exit code of the last command ]########################### 502 | # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and 503 | # style them independently from the regular OK and ERROR state. 504 | typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true 505 | 506 | # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as 507 | # it will signify success by turning green. 508 | typeset -g POWERLEVEL9K_STATUS_OK=false 509 | typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 510 | typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' 511 | 512 | # Status when some part of a pipe command fails but the overall exit status is zero. It may look 513 | # like this: 1|0. 514 | typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true 515 | typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 516 | typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' 517 | 518 | # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as 519 | # it will signify error by turning red. 520 | typeset -g POWERLEVEL9K_STATUS_ERROR=false 521 | typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 522 | typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' 523 | 524 | # Status when the last command was terminated by a signal. 525 | typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true 526 | typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 527 | # Use terse signal names: "INT" instead of "SIGINT(2)". 528 | typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false 529 | typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' 530 | 531 | # Status when some part of a pipe command fails and the overall exit status is also non-zero. 532 | # It may look like this: 1|0. 533 | typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true 534 | typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 535 | typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' 536 | 537 | ###################[ command_execution_time: duration of the last command ]################### 538 | # Show duration of the last command if takes at least this many seconds. 539 | typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 540 | # Show this many fractional digits. Zero means round to seconds. 541 | typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 542 | # Execution time color. 543 | typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 544 | # Duration format: 1d 2h 3m 4s. 545 | typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' 546 | # Custom icon. 547 | typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION= 548 | # Custom prefix. 549 | # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' 550 | 551 | #######################[ background_jobs: presence of background jobs ]####################### 552 | # Don't show the number of background jobs. 553 | typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false 554 | # Background jobs color. 555 | typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 556 | # Custom icon. 557 | # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' 558 | 559 | #######################[ direnv: direnv status (https://direnv.net/) ]######################## 560 | # Direnv color. 561 | typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 562 | # Custom icon. 563 | # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 564 | 565 | ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### 566 | # Default asdf color. Only used to display tools for which there is no color override (see below). 567 | # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. 568 | typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 569 | 570 | # There are four parameters that can be used to hide asdf tools. Each parameter describes 571 | # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at 572 | # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to 573 | # hide a tool, it gets shown. 574 | # 575 | # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and 576 | # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: 577 | # 578 | # asdf local python 3.8.1 579 | # asdf global python 3.8.1 580 | # 581 | # After running both commands the current python version is 3.8.1 and its source is "local" as 582 | # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, 583 | # it'll hide python version in this case because 3.8.1 is the same as the global version. 584 | # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't 585 | # contain "local". 586 | 587 | # Hide tool versions that don't come from one of these sources. 588 | # 589 | # Available sources: 590 | # 591 | # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" 592 | # - local `asdf current` says "set by /some/not/home/directory/file" 593 | # - global `asdf current` says "set by /home/username/file" 594 | # 595 | # Note: If this parameter is set to (shell local global), it won't hide tools. 596 | # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. 597 | typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) 598 | 599 | # If set to false, hide tool versions that are the same as global. 600 | # 601 | # Note: The name of this parameter doesn't reflect its meaning at all. 602 | # Note: If this parameter is set to true, it won't hide tools. 603 | # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. 604 | typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false 605 | 606 | # If set to false, hide tool versions that are equal to "system". 607 | # 608 | # Note: If this parameter is set to true, it won't hide tools. 609 | # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. 610 | typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true 611 | 612 | # If set to non-empty value, hide tools unless there is a file matching the specified file pattern 613 | # in the current directory, or its parent directory, or its grandparent directory, and so on. 614 | # 615 | # Note: If this parameter is set to empty value, it won't hide tools. 616 | # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. 617 | # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. 618 | # 619 | # Example: Hide nodejs version when there is no package.json and no *.js files in the current 620 | # directory, in `..`, in `../..` and so on. 621 | # 622 | # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' 623 | typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= 624 | 625 | # Ruby version from asdf. 626 | typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 627 | # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' 628 | # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' 629 | 630 | # Python version from asdf. 631 | typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 632 | # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' 633 | # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' 634 | 635 | # Go version from asdf. 636 | typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 637 | # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' 638 | # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' 639 | 640 | # Node.js version from asdf. 641 | typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 642 | # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' 643 | # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' 644 | 645 | # Rust version from asdf. 646 | typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 647 | # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' 648 | # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' 649 | 650 | # .NET Core version from asdf. 651 | typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 652 | # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' 653 | # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' 654 | 655 | # Flutter version from asdf. 656 | typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 657 | # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' 658 | # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' 659 | 660 | # Lua version from asdf. 661 | typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 662 | # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' 663 | # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' 664 | 665 | # Java version from asdf. 666 | typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 667 | # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' 668 | # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' 669 | 670 | # Perl version from asdf. 671 | typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 672 | # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' 673 | # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' 674 | 675 | # Erlang version from asdf. 676 | typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 677 | # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' 678 | # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' 679 | 680 | # Elixir version from asdf. 681 | typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 682 | # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' 683 | # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' 684 | 685 | # Postgres version from asdf. 686 | typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 687 | # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' 688 | # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' 689 | 690 | # PHP version from asdf. 691 | typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 692 | # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' 693 | # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' 694 | 695 | # Haskell version from asdf. 696 | typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 697 | # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' 698 | # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' 699 | 700 | # Julia version from asdf. 701 | typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 702 | # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' 703 | # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' 704 | 705 | ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### 706 | # NordVPN connection indicator color. 707 | typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 708 | # Hide NordVPN connection indicator when not connected. 709 | typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= 710 | typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= 711 | # Custom icon. 712 | # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' 713 | 714 | #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## 715 | # Ranger shell color. 716 | typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 717 | # Custom icon. 718 | # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' 719 | 720 | ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### 721 | # Nnn shell color. 722 | typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 723 | # Custom icon. 724 | # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' 725 | 726 | ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## 727 | # xplr shell color. 728 | typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 729 | # Custom icon. 730 | # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' 731 | 732 | ###########################[ vim_shell: vim shell indicator (:sh) ]########################### 733 | # Vim shell indicator color. 734 | typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 735 | # Custom icon. 736 | # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' 737 | 738 | ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### 739 | # Midnight Commander shell color. 740 | typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 741 | # Custom icon. 742 | # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' 743 | 744 | #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## 745 | # Nix shell color. 746 | typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 747 | 748 | # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. 749 | # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= 750 | 751 | # Custom icon. 752 | # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' 753 | 754 | ##################################[ disk_usage: disk usage ]################################## 755 | # Colors for different levels of disk usage. 756 | typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 757 | typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 758 | typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 759 | # Thresholds for different levels of disk usage (percentage points). 760 | typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 761 | typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 762 | # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. 763 | typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false 764 | # Custom icon. 765 | # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' 766 | 767 | ######################################[ ram: free RAM ]####################################### 768 | # RAM color. 769 | typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 770 | # Custom icon. 771 | # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' 772 | 773 | #####################################[ swap: used swap ]###################################### 774 | # Swap color. 775 | typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 776 | # Custom icon. 777 | # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' 778 | 779 | ######################################[ load: CPU load ]###################################### 780 | # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. 781 | typeset -g POWERLEVEL9K_LOAD_WHICH=5 782 | # Load color when load is under 50%. 783 | typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 784 | # Load color when load is between 50% and 70%. 785 | typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 786 | # Load color when load is over 70%. 787 | typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 788 | # Custom icon. 789 | # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' 790 | 791 | ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ 792 | # Todo color. 793 | typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 794 | # Hide todo when the total number of tasks is zero. 795 | typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true 796 | # Hide todo when the number of tasks after filtering is zero. 797 | typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false 798 | 799 | # Todo format. The following parameters are available within the expansion. 800 | # 801 | # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. 802 | # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. 803 | # 804 | # These variables correspond to the last line of the output of `todo.sh -p ls`: 805 | # 806 | # TODO: 24 of 42 tasks shown 807 | # 808 | # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. 809 | # 810 | # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' 811 | 812 | # Custom icon. 813 | # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' 814 | 815 | ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ 816 | # Timewarrior color. 817 | typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 818 | # If the tracked task is longer than 24 characters, truncate and append "…". 819 | # Tip: To always display tasks without truncation, delete the following parameter. 820 | # Tip: To hide task names and display just the icon when time tracking is enabled, set the 821 | # value of the following parameter to "". 822 | typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' 823 | 824 | # Custom icon. 825 | # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' 826 | 827 | ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## 828 | # Taskwarrior color. 829 | typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 830 | 831 | # Taskwarrior segment format. The following parameters are available within the expansion. 832 | # 833 | # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. 834 | # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. 835 | # 836 | # Zero values are represented as empty parameters. 837 | # 838 | # The default format: 839 | # 840 | # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' 841 | # 842 | # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' 843 | 844 | # Custom icon. 845 | # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' 846 | 847 | ################################[ cpu_arch: CPU architecture ]################################ 848 | # CPU architecture color. 849 | typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 850 | 851 | # Hide the segment when on a specific CPU architecture. 852 | # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= 853 | # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= 854 | 855 | # Custom icon. 856 | # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' 857 | 858 | ##################################[ context: user@hostname ]################################## 859 | # Context color when running with privileges. 860 | typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 861 | # Context color in SSH without privileges. 862 | typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 863 | # Default context color (no privileges, no SSH). 864 | typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 865 | 866 | # Context format when running with privileges: bold user@hostname. 867 | typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' 868 | # Context format when in SSH without privileges: user@hostname. 869 | typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' 870 | # Default context format (no privileges, no SSH): user@hostname. 871 | typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' 872 | 873 | # Don't show context unless running with privileges or in SSH. 874 | # Tip: Remove the next line to always show context. 875 | typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= 876 | 877 | # Custom icon. 878 | # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' 879 | # Custom prefix. 880 | # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' 881 | 882 | ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### 883 | # Python virtual environment color. 884 | typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 885 | # Don't show Python version next to the virtual environment name. 886 | typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false 887 | # If set to "false", won't show virtualenv if pyenv is already shown. 888 | # If set to "if-different", won't show virtualenv if it's the same as pyenv. 889 | typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false 890 | # Separate environment name from Python version only with a space. 891 | typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= 892 | # Custom icon. 893 | # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 894 | 895 | #####################[ anaconda: conda environment (https://conda.io/) ]###################### 896 | # Anaconda environment color. 897 | typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 898 | 899 | # Anaconda segment format. The following parameters are available within the expansion. 900 | # 901 | # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. 902 | # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. 903 | # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). 904 | # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). 905 | # 906 | # CONDA_PROMPT_MODIFIER can be configured with the following command: 907 | # 908 | # conda config --set env_prompt '({default_env}) ' 909 | # 910 | # The last argument is a Python format string that can use the following variables: 911 | # 912 | # - prefix The same as CONDA_PREFIX. 913 | # - default_env The same as CONDA_DEFAULT_ENV. 914 | # - name The last segment of CONDA_PREFIX. 915 | # - stacked_env Comma-separated list of names in the environment stack. The first element is 916 | # always the same as default_env. 917 | # 918 | # Note: '({default_env}) ' is the default value of env_prompt. 919 | # 920 | # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER 921 | # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former 922 | # is empty. 923 | typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' 924 | 925 | # Custom icon. 926 | # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' 927 | 928 | ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ 929 | # Pyenv color. 930 | typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 931 | # Hide python version if it doesn't come from one of these sources. 932 | typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) 933 | # If set to false, hide python version if it's the same as global: 934 | # $(pyenv version-name) == $(pyenv global). 935 | typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false 936 | # If set to false, hide python version if it's equal to "system". 937 | typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true 938 | 939 | # Pyenv segment format. The following parameters are available within the expansion. 940 | # 941 | # - P9K_CONTENT Current pyenv environment (pyenv version-name). 942 | # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). 943 | # 944 | # The default format has the following logic: 945 | # 946 | # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or 947 | # starts with "$P9K_PYENV_PYTHON_VERSION/". 948 | # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". 949 | typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' 950 | 951 | # Custom icon. 952 | # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 953 | 954 | ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ 955 | # Goenv color. 956 | typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 957 | # Hide go version if it doesn't come from one of these sources. 958 | typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) 959 | # If set to false, hide go version if it's the same as global: 960 | # $(goenv version-name) == $(goenv global). 961 | typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false 962 | # If set to false, hide go version if it's equal to "system". 963 | typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true 964 | # Custom icon. 965 | # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 966 | 967 | ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## 968 | # Nodenv color. 969 | typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 970 | # Hide node version if it doesn't come from one of these sources. 971 | typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) 972 | # If set to false, hide node version if it's the same as global: 973 | # $(nodenv version-name) == $(nodenv global). 974 | typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false 975 | # If set to false, hide node version if it's equal to "system". 976 | typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true 977 | # Custom icon. 978 | # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 979 | 980 | ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### 981 | # Nvm color. 982 | typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 983 | # Custom icon. 984 | # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' 985 | 986 | ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ 987 | # Nodeenv color. 988 | typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 989 | # Don't show Node version next to the environment name. 990 | typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false 991 | # Separate environment name from Node version only with a space. 992 | typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= 993 | # Custom icon. 994 | # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 995 | 996 | ##############################[ node_version: node.js version ]############################### 997 | # Node version color. 998 | typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 999 | # Show node version only when in a directory tree containing package.json. 1000 | typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true 1001 | # Custom icon. 1002 | # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1003 | 1004 | #######################[ go_version: go version (https://golang.org) ]######################## 1005 | # Go version color. 1006 | typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 1007 | # Show go version only when in a go project subdirectory. 1008 | typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true 1009 | # Custom icon. 1010 | # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1011 | 1012 | #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## 1013 | # Rust version color. 1014 | typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 1015 | # Show rust version only when in a rust project subdirectory. 1016 | typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true 1017 | # Custom icon. 1018 | # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1019 | 1020 | ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ 1021 | # .NET version color. 1022 | typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 1023 | # Show .NET version only when in a .NET project subdirectory. 1024 | typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true 1025 | # Custom icon. 1026 | # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1027 | 1028 | #####################[ php_version: php version (https://www.php.net/) ]###################### 1029 | # PHP version color. 1030 | typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 1031 | # Show PHP version only when in a PHP project subdirectory. 1032 | typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true 1033 | # Custom icon. 1034 | # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1035 | 1036 | ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### 1037 | # Laravel version color. 1038 | typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 1039 | # Custom icon. 1040 | # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1041 | 1042 | ####################[ java_version: java version (https://www.java.com/) ]#################### 1043 | # Java version color. 1044 | typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 1045 | # Show java version only when in a java project subdirectory. 1046 | typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true 1047 | # Show brief version. 1048 | typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false 1049 | # Custom icon. 1050 | # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1051 | 1052 | ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### 1053 | # Package color. 1054 | typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 1055 | # Package format. The following parameters are available within the expansion. 1056 | # 1057 | # - P9K_PACKAGE_NAME The value of `name` field in package.json. 1058 | # - P9K_PACKAGE_VERSION The value of `version` field in package.json. 1059 | # 1060 | # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' 1061 | # Custom icon. 1062 | # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' 1063 | 1064 | #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## 1065 | # Rbenv color. 1066 | typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 1067 | # Hide ruby version if it doesn't come from one of these sources. 1068 | typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) 1069 | # If set to false, hide ruby version if it's the same as global: 1070 | # $(rbenv version-name) == $(rbenv global). 1071 | typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false 1072 | # If set to false, hide ruby version if it's equal to "system". 1073 | typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true 1074 | # Custom icon. 1075 | # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1076 | 1077 | #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## 1078 | # Rvm color. 1079 | typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 1080 | # Don't show @gemset at the end. 1081 | typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false 1082 | # Don't show ruby- at the front. 1083 | typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false 1084 | # Custom icon. 1085 | # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' 1086 | 1087 | ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ 1088 | # Fvm color. 1089 | typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 1090 | # Custom icon. 1091 | # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' 1092 | 1093 | ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### 1094 | # Lua color. 1095 | typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 1096 | # Hide lua version if it doesn't come from one of these sources. 1097 | typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) 1098 | # If set to false, hide lua version if it's the same as global: 1099 | # $(luaenv version-name) == $(luaenv global). 1100 | typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false 1101 | # If set to false, hide lua version if it's equal to "system". 1102 | typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true 1103 | # Custom icon. 1104 | # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1105 | 1106 | ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ 1107 | # Java color. 1108 | typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 1109 | # Hide java version if it doesn't come from one of these sources. 1110 | typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) 1111 | # If set to false, hide java version if it's the same as global: 1112 | # $(jenv version-name) == $(jenv global). 1113 | typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false 1114 | # If set to false, hide java version if it's equal to "system". 1115 | typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true 1116 | # Custom icon. 1117 | # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1118 | 1119 | ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ 1120 | # Perl color. 1121 | typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 1122 | # Hide perl version if it doesn't come from one of these sources. 1123 | typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) 1124 | # If set to false, hide perl version if it's the same as global: 1125 | # $(plenv version-name) == $(plenv global). 1126 | typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false 1127 | # If set to false, hide perl version if it's equal to "system". 1128 | typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true 1129 | # Custom icon. 1130 | # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1131 | 1132 | ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ 1133 | # Perlbrew color. 1134 | typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 1135 | # Show perlbrew version only when in a perl project subdirectory. 1136 | typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true 1137 | # Don't show "perl-" at the front. 1138 | typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false 1139 | # Custom icon. 1140 | # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' 1141 | 1142 | ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ 1143 | # PHP color. 1144 | typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 1145 | # Hide php version if it doesn't come from one of these sources. 1146 | typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) 1147 | # If set to false, hide php version if it's the same as global: 1148 | # $(phpenv version-name) == $(phpenv global). 1149 | typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false 1150 | # If set to false, hide php version if it's equal to "system". 1151 | typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true 1152 | # Custom icon. 1153 | # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1154 | 1155 | #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### 1156 | # Scala color. 1157 | typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 1158 | # Hide scala version if it doesn't come from one of these sources. 1159 | typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) 1160 | # If set to false, hide scala version if it's the same as global: 1161 | # $(scalaenv version-name) == $(scalaenv global). 1162 | typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false 1163 | # If set to false, hide scala version if it's equal to "system". 1164 | typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true 1165 | # Custom icon. 1166 | # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1167 | 1168 | ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### 1169 | # Haskell color. 1170 | typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 1171 | # Hide haskell version if it doesn't come from one of these sources. 1172 | # 1173 | # shell: version is set by STACK_YAML 1174 | # local: version is set by stack.yaml up the directory tree 1175 | # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) 1176 | typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) 1177 | # If set to false, hide haskell version if it's the same as in the implicit global project. 1178 | typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true 1179 | # Custom icon. 1180 | # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' 1181 | 1182 | #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# 1183 | # Show kubecontext only when the command you are typing invokes one of these tools. 1184 | # Tip: Remove the next line to always show kubecontext. 1185 | typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' 1186 | 1187 | # Kubernetes context classes for the purpose of using different colors, icons and expansions with 1188 | # different contexts. 1189 | # 1190 | # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element 1191 | # in each pair defines a pattern against which the current kubernetes context gets matched. 1192 | # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) 1193 | # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, 1194 | # you'll see this value in your prompt. The second element of each pair in 1195 | # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The 1196 | # first match wins. 1197 | # 1198 | # For example, given these settings: 1199 | # 1200 | # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( 1201 | # '*prod*' PROD 1202 | # '*test*' TEST 1203 | # '*' DEFAULT) 1204 | # 1205 | # If your current kubernetes context is "deathray-testing/default", its class is TEST 1206 | # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. 1207 | # 1208 | # You can define different colors, icons and content expansions for different classes: 1209 | # 1210 | # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 1211 | # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' 1212 | # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' 1213 | typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( 1214 | # '*prod*' PROD # These values are examples that are unlikely 1215 | # '*test*' TEST # to match your needs. Customize them as needed. 1216 | '*' DEFAULT) 1217 | typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 1218 | # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' 1219 | 1220 | # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext 1221 | # segment. Parameter expansions are very flexible and fast, too. See reference: 1222 | # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. 1223 | # 1224 | # Within the expansion the following parameters are always available: 1225 | # 1226 | # - P9K_CONTENT The content that would've been displayed if there was no content 1227 | # expansion defined. 1228 | # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the 1229 | # output of `kubectl config get-contexts`. 1230 | # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the 1231 | # output of `kubectl config get-contexts`. 1232 | # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE 1233 | # in the output of `kubectl config get-contexts`. If there is no 1234 | # namespace, the parameter is set to "default". 1235 | # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the 1236 | # output of `kubectl config get-contexts`. 1237 | # 1238 | # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), 1239 | # the following extra parameters are available: 1240 | # 1241 | # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". 1242 | # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. 1243 | # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. 1244 | # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. 1245 | # 1246 | # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, 1247 | # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": 1248 | # 1249 | # - P9K_KUBECONTEXT_CLOUD_NAME=gke 1250 | # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account 1251 | # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a 1252 | # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 1253 | # 1254 | # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": 1255 | # 1256 | # - P9K_KUBECONTEXT_CLOUD_NAME=eks 1257 | # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 1258 | # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 1259 | # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 1260 | typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= 1261 | # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. 1262 | POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' 1263 | # Append the current context's namespace if it's not "default". 1264 | POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' 1265 | 1266 | # Custom prefix. 1267 | # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' 1268 | 1269 | ################[ terraform: terraform workspace (https://www.terraform.io) ]################# 1270 | # Don't show terraform workspace if it's literally "default". 1271 | typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false 1272 | # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element 1273 | # in each pair defines a pattern against which the current terraform workspace gets matched. 1274 | # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) 1275 | # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, 1276 | # you'll see this value in your prompt. The second element of each pair in 1277 | # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The 1278 | # first match wins. 1279 | # 1280 | # For example, given these settings: 1281 | # 1282 | # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( 1283 | # '*prod*' PROD 1284 | # '*test*' TEST 1285 | # '*' OTHER) 1286 | # 1287 | # If your current terraform workspace is "project_test", its class is TEST because "project_test" 1288 | # doesn't match the pattern '*prod*' but does match '*test*'. 1289 | # 1290 | # You can define different colors, icons and content expansions for different classes: 1291 | # 1292 | # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 1293 | # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' 1294 | # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' 1295 | typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( 1296 | # '*prod*' PROD # These values are examples that are unlikely 1297 | # '*test*' TEST # to match your needs. Customize them as needed. 1298 | '*' OTHER) 1299 | typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 1300 | # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' 1301 | 1302 | #############[ terraform_version: terraform version (https://www.terraform.io) ]############## 1303 | # Terraform version color. 1304 | typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 1305 | # Custom icon. 1306 | # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' 1307 | 1308 | #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# 1309 | # Show aws only when the command you are typing invokes one of these tools. 1310 | # Tip: Remove the next line to always show aws. 1311 | typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' 1312 | 1313 | # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element 1314 | # in each pair defines a pattern against which the current AWS profile gets matched. 1315 | # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) 1316 | # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, 1317 | # you'll see this value in your prompt. The second element of each pair in 1318 | # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The 1319 | # first match wins. 1320 | # 1321 | # For example, given these settings: 1322 | # 1323 | # typeset -g POWERLEVEL9K_AWS_CLASSES=( 1324 | # '*prod*' PROD 1325 | # '*test*' TEST 1326 | # '*' DEFAULT) 1327 | # 1328 | # If your current AWS profile is "company_test", its class is TEST 1329 | # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. 1330 | # 1331 | # You can define different colors, icons and content expansions for different classes: 1332 | # 1333 | # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 1334 | # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' 1335 | # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' 1336 | typeset -g POWERLEVEL9K_AWS_CLASSES=( 1337 | # '*prod*' PROD # These values are examples that are unlikely 1338 | # '*test*' TEST # to match your needs. Customize them as needed. 1339 | '*' DEFAULT) 1340 | typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 1341 | # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' 1342 | 1343 | # AWS segment format. The following parameters are available within the expansion. 1344 | # 1345 | # - P9K_AWS_PROFILE The name of the current AWS profile. 1346 | # - P9K_AWS_REGION The region associated with the current AWS profile. 1347 | typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' 1348 | 1349 | #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# 1350 | # AWS Elastic Beanstalk environment color. 1351 | typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 1352 | # Custom icon. 1353 | # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' 1354 | 1355 | ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## 1356 | # Show azure only when the command you are typing invokes one of these tools. 1357 | # Tip: Remove the next line to always show azure. 1358 | typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' 1359 | # Azure account name color. 1360 | typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 1361 | # Custom icon. 1362 | # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' 1363 | 1364 | ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### 1365 | # Show gcloud only when the command you are typing invokes one of these tools. 1366 | # Tip: Remove the next line to always show gcloud. 1367 | typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' 1368 | # Google cloud color. 1369 | typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 1370 | 1371 | # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or 1372 | # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative 1373 | # enough. You can use the following parameters in the expansions. Each of them corresponds to the 1374 | # output of `gcloud` tool. 1375 | # 1376 | # Parameter | Source 1377 | # -------------------------|-------------------------------------------------------------------- 1378 | # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' 1379 | # P9K_GCLOUD_ACCOUNT | gcloud config get-value account 1380 | # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project 1381 | # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' 1382 | # 1383 | # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. 1384 | # 1385 | # Obtaining project name requires sending a request to Google servers. This can take a long time 1386 | # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud 1387 | # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets 1388 | # set and gcloud prompt segment transitions to state COMPLETE. 1389 | # 1390 | # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL 1391 | # and COMPLETE. You can also hide gcloud in state PARTIAL by setting 1392 | # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and 1393 | # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. 1394 | typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' 1395 | typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' 1396 | 1397 | # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name 1398 | # this often. Negative value disables periodic polling. In this mode project name is retrieved 1399 | # only when the current configuration, account or project id changes. 1400 | typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 1401 | 1402 | # Custom icon. 1403 | # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' 1404 | 1405 | #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# 1406 | # Show google_app_cred only when the command you are typing invokes one of these tools. 1407 | # Tip: Remove the next line to always show google_app_cred. 1408 | typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' 1409 | 1410 | # Google application credentials classes for the purpose of using different colors, icons and 1411 | # expansions with different credentials. 1412 | # 1413 | # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first 1414 | # element in each pair defines a pattern against which the current kubernetes context gets 1415 | # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion 1416 | # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION 1417 | # parameters, you'll see this value in your prompt. The second element of each pair in 1418 | # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. 1419 | # The first match wins. 1420 | # 1421 | # For example, given these settings: 1422 | # 1423 | # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( 1424 | # '*:*prod*:*' PROD 1425 | # '*:*test*:*' TEST 1426 | # '*' DEFAULT) 1427 | # 1428 | # If your current Google application credentials is "service_account deathray-testing x@y.com", 1429 | # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. 1430 | # 1431 | # You can define different colors, icons and content expansions for different classes: 1432 | # 1433 | # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 1434 | # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' 1435 | # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' 1436 | typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( 1437 | # '*:*prod*:*' PROD # These values are examples that are unlikely 1438 | # '*:*test*:*' TEST # to match your needs. Customize them as needed. 1439 | '*' DEFAULT) 1440 | typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 1441 | # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' 1442 | 1443 | # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by 1444 | # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: 1445 | # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. 1446 | # 1447 | # You can use the following parameters in the expansion. Each of them corresponds to one of the 1448 | # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. 1449 | # 1450 | # Parameter | JSON key file field 1451 | # ---------------------------------+--------------- 1452 | # P9K_GOOGLE_APP_CRED_TYPE | type 1453 | # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id 1454 | # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email 1455 | # 1456 | # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. 1457 | typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' 1458 | 1459 | ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### 1460 | # Toolbox color. 1461 | typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 1462 | # Don't display the name of the toolbox if it matches fedora-toolbox-*. 1463 | typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' 1464 | # Custom icon. 1465 | # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' 1466 | # Custom prefix. 1467 | # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' 1468 | 1469 | ###############################[ public_ip: public IP address ]############################### 1470 | # Public IP color. 1471 | typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 1472 | # Custom icon. 1473 | # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' 1474 | 1475 | ########################[ vpn_ip: virtual private network indicator ]######################### 1476 | # VPN IP color. 1477 | typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 1478 | # When on VPN, show just an icon without the IP address. 1479 | # Tip: To display the private IP address when on VPN, remove the next line. 1480 | typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= 1481 | # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN 1482 | # to see the name of the interface. 1483 | typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' 1484 | # If set to true, show one segment per matching network interface. If set to false, show only 1485 | # one segment corresponding to the first matching network interface. 1486 | # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. 1487 | typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false 1488 | # Custom icon. 1489 | # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' 1490 | 1491 | ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### 1492 | # IP color. 1493 | typeset -g POWERLEVEL9K_IP_FOREGROUND=38 1494 | # The following parameters are accessible within the expansion: 1495 | # 1496 | # Parameter | Meaning 1497 | # ----------------------+------------------------------------------- 1498 | # P9K_IP_IP | IP address 1499 | # P9K_IP_INTERFACE | network interface 1500 | # P9K_IP_RX_BYTES | total number of bytes received 1501 | # P9K_IP_TX_BYTES | total number of bytes sent 1502 | # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt 1503 | # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt 1504 | # P9K_IP_RX_RATE | receive rate (since last prompt) 1505 | # P9K_IP_TX_RATE | send rate (since last prompt) 1506 | typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' 1507 | # Show information for the first network interface whose name matches this regular expression. 1508 | # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. 1509 | typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' 1510 | # Custom icon. 1511 | # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' 1512 | 1513 | #########################[ proxy: system-wide http/https/ftp proxy ]########################## 1514 | # Proxy color. 1515 | typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 1516 | # Custom icon. 1517 | # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' 1518 | 1519 | ################################[ battery: internal battery ]################################# 1520 | # Show battery in red when it's below this level and not connected to power supply. 1521 | typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 1522 | typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 1523 | # Show battery in green when it's charging or fully charged. 1524 | typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 1525 | # Show battery in yellow when it's discharging. 1526 | typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 1527 | # Battery pictograms going from low to high level of charge. 1528 | typeset -g POWERLEVEL9K_BATTERY_STAGES='\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578' 1529 | # Don't show the remaining time to charge/discharge. 1530 | typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false 1531 | 1532 | #####################################[ wifi: wifi speed ]##################################### 1533 | # WiFi color. 1534 | typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 1535 | # Custom icon. 1536 | # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' 1537 | 1538 | # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). 1539 | # 1540 | # # Wifi colors and icons for different signal strength levels (low to high). 1541 | # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values 1542 | # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values 1543 | # 1544 | # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' 1545 | # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' 1546 | # 1547 | # The following parameters are accessible within the expansions: 1548 | # 1549 | # Parameter | Meaning 1550 | # ----------------------+--------------- 1551 | # P9K_WIFI_SSID | service set identifier, a.k.a. network name 1552 | # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown 1553 | # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second 1554 | # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 1555 | # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 1556 | # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) 1557 | 1558 | ####################################[ time: current time ]#################################### 1559 | # Current time color. 1560 | typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 1561 | # Format for the current time: 09:51:02. See `man 3 strftime`. 1562 | typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' 1563 | # If set to true, time will update when you hit enter. This way prompts for the past 1564 | # commands will contain the start times of their commands as opposed to the default 1565 | # behavior where they contain the end times of their preceding commands. 1566 | typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false 1567 | # Custom icon. 1568 | typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION= 1569 | # Custom prefix. 1570 | # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' 1571 | 1572 | # Example of a user-defined prompt segment. Function prompt_example will be called on every 1573 | # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or 1574 | # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. 1575 | # 1576 | # Type `p10k help segment` for documentation and a more sophisticated example. 1577 | function prompt_example() { 1578 | p10k segment -f 208 -i '⭐' -t 'hello, %n' 1579 | } 1580 | 1581 | # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job 1582 | # is to generate the prompt segment for display in instant prompt. See 1583 | # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. 1584 | # 1585 | # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function 1586 | # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k 1587 | # will replay these calls without actually calling instant_prompt_*. It is imperative that 1588 | # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this 1589 | # rule is not observed, the content of instant prompt will be incorrect. 1590 | # 1591 | # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If 1592 | # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. 1593 | function instant_prompt_example() { 1594 | # Since prompt_example always makes the same `p10k segment` calls, we can call it from 1595 | # instant_prompt_example. This will give us the same `example` prompt segment in the instant 1596 | # and regular prompts. 1597 | prompt_example 1598 | } 1599 | 1600 | # User-defined prompt segments can be customized the same way as built-in segments. 1601 | # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 1602 | # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' 1603 | 1604 | # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt 1605 | # when accepting a command line. Supported values: 1606 | # 1607 | # - off: Don't change prompt when accepting a command line. 1608 | # - always: Trim down prompt when accepting a command line. 1609 | # - same-dir: Trim down prompt when accepting a command line unless this is the first command 1610 | # typed after changing current working directory. 1611 | typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off 1612 | 1613 | # Instant prompt mode. 1614 | # 1615 | # - off: Disable instant prompt. Choose this if you've tried instant prompt and found 1616 | # it incompatible with your zsh configuration files. 1617 | # - quiet: Enable instant prompt and don't print warnings when detecting console output 1618 | # during zsh initialization. Choose this if you've read and understood 1619 | # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. 1620 | # - verbose: Enable instant prompt and print a warning when detecting console output during 1621 | # zsh initialization. Choose this if you've never tried instant prompt, haven't 1622 | # seen the warning, or if you are unsure what this all means. 1623 | typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet 1624 | 1625 | # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. 1626 | # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload 1627 | # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you 1628 | # really need it. 1629 | typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true 1630 | 1631 | # If p10k is already loaded, reload configuration. 1632 | # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. 1633 | (( ! $+functions[p10k] )) || p10k reload 1634 | } 1635 | 1636 | # Tell `p10k configure` which file it should overwrite. 1637 | typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} 1638 | 1639 | (( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} 1640 | 'builtin' 'unset' 'p10k_config_opts' 1641 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .history/ 2 | .docker/dbdata/ 3 | .docker/zsh 4 | .devcontainer/ 5 | .git/ 6 | .github/ 7 | dist/ 8 | node_modules/ 9 | docker-compose.yaml 10 | Dockerfile.dev 11 | Dockerfile.prod -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | MONGO_DSN=mongodb://root:root@db:27017/tweets?authSource=admin -------------------------------------------------------------------------------- /.env.prod: -------------------------------------------------------------------------------- 1 | MONGO_DSN=mongodb://root:root@db_prod:27017/tweets?authSource=admin -------------------------------------------------------------------------------- /.env.test: -------------------------------------------------------------------------------- 1 | #MONGO_DSN=mongodb://root:root@db_test:27017/tweets_test?authSource=admin 2 | MONGO_DSN=mongodb://root:root@db_prod:27017/tweets_test?authSource=admin -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir : __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ['.eslintrc.js'], 19 | rules: { 20 | '@typescript-eslint/interface-name-prefix': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/explicit-module-boundary-types': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /.github/workflows/ci_cd.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | 3 | # This workflow uses actions that are not certified by GitHub. 4 | # They are provided by a third-party and are governed by 5 | # separate terms of service, privacy policy, and support 6 | # documentation. 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | # Publish semver tags as releases. 12 | tags: [ 'v*.*.*' ] 13 | pull_request: 14 | branches: [ "main" ] 15 | 16 | env: 17 | # Use docker.io for Docker Hub if empty 18 | #REGISTRY: ghcr.io 19 | REGISTRY: gcr.io 20 | IMAGE_NAME: nestjs-api-365414/nest 21 | SERVICE: nest 22 | REGION: us-central1 23 | #IMAGE_NAME: ${{ github.repository }} 24 | # github.repository as / 25 | 26 | 27 | jobs: 28 | ci: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | tags: ${{ steps.meta.outputs.tags }} 32 | permissions: 33 | contents: read 34 | packages: write 35 | # This is used to complete the identity challenge 36 | # with sigstore/fulcio when running outside of PRs. 37 | id-token: write 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Install the cosign tool except on PR 44 | # https://github.com/sigstore/cosign-installer 45 | - name: Install cosign 46 | if: github.event_name != 'pull_request' 47 | uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0 48 | with: 49 | cosign-release: 'v1.11.0' 50 | 51 | 52 | # Workaround: https://github.com/docker/build-push-action/issues/461 53 | - name: Setup Docker buildx 54 | uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf 55 | 56 | # Login against a Docker registry except on PR 57 | # https://github.com/docker/login-action 58 | - name: Log into registry ${{ env.REGISTRY }} 59 | if: github.event_name != 'pull_request' 60 | uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 61 | with: 62 | registry: ${{ env.REGISTRY }} 63 | username: _json_key 64 | #username: ${{ github.actor }} 65 | password: ${{ secrets.GCP_SA_KEY }} 66 | #password: ${{ secrets.GITHUB_TOKEN }} 67 | 68 | # Extract metadata (tags, labels) for Docker 69 | # https://github.com/docker/metadata-action 70 | - name: Extract Docker metadata 71 | id: meta 72 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 73 | with: 74 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 75 | 76 | - name: Build for testing 77 | id: build-for-testing 78 | uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a 79 | with: 80 | context: . 81 | file: ./Dockerfile.prod 82 | push: false 83 | target: testing 84 | tags: ${{ steps.meta.outputs.tags }} 85 | cache-from: type=gha 86 | cache-to: type=gha,mode=max 87 | 88 | - name: Up containers 89 | run: docker compose -f docker-compose.prod.yaml up -d 90 | 91 | - name: Waiting environment to be ready 92 | run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for | sh -s -- http://localhost:3000 -- echo success 93 | 94 | - name: Running tests 95 | run: docker compose -f docker-compose.prod.yaml exec -T app_prod sh -c "npm run test" 96 | 97 | # Build and push Docker image with Buildx (don't push on PR) 98 | # https://github.com/docker/build-push-action 99 | - name: Build and push Docker image 100 | id: build-and-push 101 | uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a 102 | if: ${{ github.event_name != 'pull_request' }} 103 | with: 104 | context: . 105 | file: ./Dockerfile.prod 106 | target: production 107 | push: true 108 | tags: ${{ steps.meta.outputs.tags }} 109 | labels: ${{ steps.meta.outputs.labels }} 110 | cache-from: type=gha 111 | cache-to: type=gha,mode=max 112 | 113 | 114 | # Sign the resulting Docker image digest except on PRs. 115 | # This will only write to the public Rekor transparency log when the Docker 116 | # repository is public to avoid leaking data. If you would like to publish 117 | # transparency data even for private images, pass --force to cosign below. 118 | # https://github.com/sigstore/cosign 119 | - name: Sign the published Docker image 120 | if: ${{ github.event_name != 'pull_request' }} 121 | env: 122 | COSIGN_EXPERIMENTAL: "true" 123 | # This step uses the identity token to provision an ephemeral certificate 124 | # against the sigstore community Fulcio instance. 125 | run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} 126 | 127 | cd: 128 | needs: ci 129 | if: ${{ github.event_name != 'pull_request' }} 130 | runs-on: ubuntu-latest 131 | 132 | steps: 133 | 134 | - name: Checkout repository 135 | uses: actions/checkout@v3 136 | 137 | - id: 'auth' 138 | uses: 'google-github-actions/auth@v0' 139 | with: 140 | credentials_json: '${{ secrets.GCP_SA_KEY }}' 141 | 142 | - name: 'Deploy to Cloud Run' 143 | uses: 'google-github-actions/deploy-cloudrun@v0' 144 | with: 145 | service: ${{ env.SERVICE }} 146 | image: ${{ needs.ci.outputs.tags }} 147 | region: ${{ env.REGION }} 148 | env_vars: MONGO_DSN=${{ secrets.MONGO_DSN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | pnpm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # OS 15 | .DS_Store 16 | 17 | # Tests 18 | /coverage 19 | /.nyc_output 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | 30 | # IDE - VSCode 31 | .vscode/* 32 | !.vscode/settings.json 33 | !.vscode/tasks.json 34 | !.vscode/launch.json 35 | !.vscode/extensions.json 36 | 37 | .history/ 38 | 39 | .docker/dbdata -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /.swcrc: -------------------------------------------------------------------------------- 1 | { 2 | "jsc": { 3 | "parser": { 4 | "syntax": "typescript", 5 | "tsx": false, 6 | "decorators": true 7 | }, 8 | "target": "es2017", 9 | "keepClassNames": true, 10 | "transform": { 11 | "legacyDecorator": true, 12 | "decoratorMetadata": true 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM node:16.16.0-slim 2 | 3 | RUN apt update && apt install -y \ 4 | git gpg gnupg gpg-agent socat \ 5 | ca-certificates \ 6 | zsh \ 7 | curl \ 8 | wget \ 9 | fonts-powerline \ 10 | procps 11 | 12 | RUN npm install -g @nestjs/cli@9.1.4 13 | 14 | USER node 15 | 16 | RUN mkdir -p /home/node/app 17 | 18 | WORKDIR /home/node/app 19 | 20 | RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.2/zsh-in-docker.sh)" -- \ 21 | -t https://github.com/romkatv/powerlevel10k \ 22 | -p git \ 23 | -p git-flow \ 24 | -p https://github.com/zdharma-continuum/fast-syntax-highlighting \ 25 | -p https://github.com/zsh-users/zsh-autosuggestions \ 26 | -p https://github.com/zsh-users/zsh-completions \ 27 | -a 'export TERM=xterm-256color' 28 | 29 | RUN echo '[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh' >> ~/.zshrc && \ 30 | echo 'HISTFILE=/home/node/zsh/.zsh_history' >> ~/.zshrc 31 | 32 | CMD [ ".docker/start.sh" ] 33 | 34 | #CMD [ "tail", "-f", "/dev/null" ] -------------------------------------------------------------------------------- /Dockerfile.prod: -------------------------------------------------------------------------------- 1 | FROM node:16.16.0-slim as testing 2 | 3 | USER node 4 | 5 | RUN mkdir -p /home/node/app 6 | 7 | WORKDIR /home/node/app 8 | 9 | COPY --chown=node:node package.json package-lock.json ./ 10 | RUN npm ci 11 | 12 | COPY --chown=node:node . . 13 | 14 | RUN npm run build 15 | 16 | ENV NODE_ENV=prod 17 | CMD [ "npm", "run", "start:prod" ] 18 | 19 | FROM node:16.16.0-slim as production 20 | 21 | USER node 22 | 23 | RUN mkdir -p /home/node/app 24 | 25 | WORKDIR /home/node/app 26 | 27 | COPY --from=testing --chown=node:node /home/node/app/package*.json ./ 28 | RUN npm ci --omit=dev 29 | 30 | COPY --from=testing --chown=node:node /home/node/app . 31 | 32 | EXPOSE 3000 33 | 34 | ENV NODE_ENV=prod 35 | CMD [ "npm", "run", "start:prod" ] 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Imersão Full Stack && Full Cycle](https://events-fullcycle.s3.amazonaws.com/events-fullcycle/static/site/img/grupo_4417.png) 2 | 3 | Participe gratuitamente: https://imersao.fullcycle.com.br/ 4 | 5 | ## Sobre o repositório 6 | Esse repositório contém o código-fonte ministrado nas aulas: 7 | 8 | * Desenvolvimento de APIs com Nest.js: Do zero aos testes automatizados: [https://www.youtube.com/watch?v=yggaGQnsnxo](https://www.youtube.com/watch?v=yggaGQnsnxo) 9 | * Docker avançado no VSCode: [https://www.youtube.com/watch?v=oAcrXHRAqoY](https://www.youtube.com/watch?v=oAcrXHRAqoY) 10 | * CI/CD: Fazendo deploy de uma aplicação Nest.js no mundo real: [https://www.youtube.com/watch?v=89GWF72F0sw](https://www.youtube.com/watch?v=89GWF72F0sw) 11 | 12 | Durante estas 3 aulas, mostramos como: 13 | 14 | * Desenvolver API Rest e testes automatizados (pirâmide de testes) com Nest.js 15 | * Como montar um ambiente de desenvolvimento com Docker no VSCode satisfazendo necessidades como: backup dos banco de dados de dados em volumes, tmpfs para testes, terminal ZSH dentro do container e Remote Container 16 | * Como montar uma esteira de CI/CD (Integração Contínua e Deploy Contínuo) usando Github Action, Github Packages, Artifact Registry e Cloud Run 17 | 18 | ## Rodar a aplicação 19 | 20 | ```bash 21 | docker compose up # para levantar a versão de desenvolvimento 22 | ``` 23 | 24 | ```bash 25 | docker compose -f docker-compose.prod.yaml up # para levantar a versão de produção 26 | ``` 27 | 28 | Entre no container do Nest.js para levantar o servidor WEB: 29 | 30 | ```bash 31 | # versão de desenvolvimento 32 | docker compose exec app bash 33 | npm run start:dev 34 | 35 | # versão de produção 36 | docker compose -f docker-compose.prod.yaml exec app bash 37 | npm run start:dev 38 | ``` 39 | 40 | 41 | 42 | Use o arquivo `api.http` para testar a publicação usando a extensão Rest Client do VSCode ou outra ferramenta para brincar com o HTTP. -------------------------------------------------------------------------------- /api.http: -------------------------------------------------------------------------------- 1 | GET http://localhost:3000/tweets 2 | 3 | ### 4 | GET http://localhost:3000/tweets/634586dbcef12dae83f3bde3 5 | 6 | 7 | 8 | ### 9 | POST http://localhost:3000/tweets 10 | Content-Type: application/json 11 | 12 | { 13 | "content": "Hello World!", 14 | "screen_name": "Luiz Carlos" 15 | } -------------------------------------------------------------------------------- /docker-compose.prod.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | app_prod: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile.prod 8 | target: ${STAGE:-testing} 9 | ports: 10 | - 3000:3000 11 | volumes: 12 | - .:/home/node/app 13 | - /home/node/app/dist 14 | - /home/node/app/node_modules 15 | depends_on: 16 | - db_prod 17 | 18 | db_prod: 19 | image: mongo:6.0.2 20 | #- ./.docker/mongo:/docker-entrypoint-initdb.d 21 | environment: 22 | - MONGO_INITDB_ROOT_USERNAME=root 23 | - MONGO_INITDB_ROOT_PASSWORD=root 24 | #- MONGO_INITDB_DATABASE=app 25 | # entrypoint.init.db 26 | 27 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | app: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile.dev 8 | ports: 9 | - 3000:3000 10 | volumes: 11 | - .:/home/node/app 12 | - ./.docker/zsh/powerlevel10k/.p10k.zsh:/home/node/.p10k.zsh:delegated 13 | - ./.docker/zsh/history:/home/node/zsh:delegated 14 | depends_on: 15 | - db 16 | 17 | db: 18 | image: mongo:6.0.2 19 | profiles: 20 | - dev 21 | ports: 22 | - 27017:27017 23 | volumes: 24 | - ./.docker/dbdata:/data/db 25 | #- ./.docker/mongo:/docker-entrypoint-initdb.d 26 | environment: 27 | - MONGO_INITDB_ROOT_USERNAME=root 28 | - MONGO_INITDB_ROOT_PASSWORD=root 29 | #- MONGO_INITDB_DATABASE=app 30 | # entrypoint.init.db 31 | 32 | db_test: 33 | image: mongo:6.0.2 34 | environment: 35 | - MONGO_INITDB_ROOT_USERNAME=root 36 | - MONGO_INITDB_ROOT_PASSWORD=root 37 | tmpfs: 38 | - /data/db 39 | 40 | mongo-express: 41 | image: mongo-express 42 | profiles: 43 | - dev 44 | restart: always 45 | ports: 46 | - 8081:8081 47 | environment: 48 | - ME_CONFIG_MONGODB_SERVER=db 49 | - ME_CONFIG_MONGODB_AUTH_USERNAME=root 50 | - ME_CONFIG_MONGODB_AUTH_PASSWORD=root 51 | - ME_CONFIG_MONGODB_ADMINUSERNAME=root 52 | - ME_CONFIG_MONGODB_ADMINPASSWORD=root 53 | depends_on: 54 | - db 55 | 56 | #npm run test ----> mongo -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nestjs-api-tests", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "", 6 | "private": true, 7 | "license": "UNLICENSED", 8 | "scripts": { 9 | "prebuild": "rimraf dist", 10 | "build": "nest build", 11 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 12 | "start": "nest start", 13 | "start:dev": "nest start --watch", 14 | "start:debug": "nest start --debug --watch", 15 | "start:prod": "node dist/main", 16 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 17 | "test": "jest", 18 | "test:watch": "jest --watch", 19 | "test:cov": "jest --coverage", 20 | "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", 21 | "test:e2e": "jest --config ./test/jest-e2e.json" 22 | }, 23 | "dependencies": { 24 | "@nestjs/common": "^9.0.0", 25 | "@nestjs/config": "^2.2.0", 26 | "@nestjs/core": "^9.0.0", 27 | "@nestjs/mapped-types": "*", 28 | "@nestjs/mongoose": "^9.2.0", 29 | "@nestjs/platform-express": "^9.0.0", 30 | "mongoose": "^6.6.5", 31 | "reflect-metadata": "^0.1.13", 32 | "rimraf": "^3.0.2", 33 | "rxjs": "^7.2.0" 34 | }, 35 | "devDependencies": { 36 | "@nestjs/cli": "^9.0.0", 37 | "@nestjs/schematics": "^9.0.0", 38 | "@nestjs/testing": "^9.0.0", 39 | "@swc/core": "^1.3.6", 40 | "@swc/jest": "^0.2.23", 41 | "@types/express": "^4.17.13", 42 | "@types/jest": "28.1.8", 43 | "@types/node": "^16.0.0", 44 | "@types/supertest": "^2.0.11", 45 | "@typescript-eslint/eslint-plugin": "^5.0.0", 46 | "@typescript-eslint/parser": "^5.0.0", 47 | "eslint": "^8.0.1", 48 | "eslint-config-prettier": "^8.3.0", 49 | "eslint-plugin-prettier": "^4.0.0", 50 | "jest": "28.1.3", 51 | "prettier": "^2.3.2", 52 | "source-map-support": "^0.5.20", 53 | "supertest": "^6.1.3", 54 | "ts-jest": "28.0.8", 55 | "ts-loader": "^9.2.3", 56 | "ts-node": "^10.0.0", 57 | "tsconfig-paths": "4.1.0", 58 | "typescript": "^4.7.4" 59 | }, 60 | "jest": { 61 | "moduleFileExtensions": [ 62 | "js", 63 | "json", 64 | "ts" 65 | ], 66 | "rootDir": ".", 67 | "testRegex": ".*\\..*spec\\.ts$", 68 | "transform": { 69 | "^.+\\.(t|j)s$": "@swc/jest" 70 | }, 71 | "collectCoverageFrom": [ 72 | "**/*.(t|j)s" 73 | ], 74 | "coverageDirectory": "../coverage", 75 | "testEnvironment": "node" 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppController', () => { 6 | let appController: AppController; 7 | 8 | beforeEach(async () => { 9 | const app: TestingModule = await Test.createTestingModule({ 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }).compile(); 13 | 14 | appController = app.get(AppController); 15 | }); 16 | 17 | describe('root', () => { 18 | it('should return "Hello World!"', () => { 19 | expect(appController.getHello()).toBe('Hello World!'); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ConfigModule } from '@nestjs/config'; 3 | import { MongooseModule } from '@nestjs/mongoose'; 4 | import { join } from 'path'; 5 | import { AppController } from './app.controller'; 6 | import { AppService } from './app.service'; 7 | import { TweetsModule } from './tweets/tweets.module'; 8 | 9 | // banco de dados é criado se não existe 10 | @Module({ 11 | imports: [ 12 | ConfigModule.forRoot({ 13 | envFilePath: [ 14 | join(__dirname, '..', `.env.${process.env.NODE_ENV}`), 15 | join(__dirname, '..', '.env'), 16 | ], 17 | }), 18 | MongooseModule.forRoot(process.env.MONGO_DSN), 19 | TweetsModule, 20 | ], 21 | controllers: [AppController], 22 | providers: [AppService], 23 | }) 24 | export class AppModule {} 25 | 26 | // /tweets - CRUD 27 | 28 | //Root - AppModule 29 | 30 | //tweetsmodule 31 | -------------------------------------------------------------------------------- /src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | 10 | //repositórios - Github Packages - nova versão 11 | 12 | //repositórios do Google Artifact Registry -------------------------------------------------------------------------------- /src/tweets/dto/create-tweet.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateTweetDto {} 2 | -------------------------------------------------------------------------------- /src/tweets/dto/update-tweet.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateTweetDto } from './create-tweet.dto'; 3 | 4 | export class UpdateTweetDto extends PartialType(CreateTweetDto) {} 5 | -------------------------------------------------------------------------------- /src/tweets/entities/tweet.entity.spec.ts: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | import { Tweet, TweetSchema } from './tweet.entity'; 3 | 4 | describe('Tweet Tests', () => { 5 | //Teste de unidade 6 | describe('Tweet Class', () => { 7 | it('should create a tweet', () => { 8 | const tweet = new Tweet({ 9 | content: 'Hello World', 10 | screen_name: 'Luiz Carlos', 11 | }); 12 | 13 | expect(tweet.content).toBe('Hello World'); 14 | expect(tweet.screen_name).toBe('Luiz Carlos'); 15 | }); 16 | }); 17 | 18 | //teste de integração - menos rapido e mais custoso que unitario 19 | describe('Using MongoDB', () => { 20 | let conn: mongoose.Mongoose; 21 | 22 | beforeEach(async () => { 23 | conn = await mongoose.connect( 24 | `mongodb://root:root@db_prod:27017/tweets_entity_test?authSource=admin`, 25 | ); 26 | }); 27 | 28 | afterEach(async () => { 29 | await conn.disconnect(); 30 | }); 31 | 32 | it('create a tweet document', async () => { 33 | const TweetModel = conn.model('Tweet', TweetSchema); 34 | const tweet = new TweetModel({ 35 | content: 'Hello World', 36 | screen_name: 'Luiz Carlos', 37 | }); 38 | await tweet.save(); 39 | 40 | const tweetCreated = await TweetModel.findById(tweet._id); 41 | 42 | expect(tweetCreated.content).toBe('Hello World'); 43 | expect(tweetCreated.screen_name).toBe('Luiz Carlos'); 44 | }); 45 | }); 46 | }); -------------------------------------------------------------------------------- /src/tweets/entities/tweet.entity.ts: -------------------------------------------------------------------------------- 1 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; 2 | import { Document } from 'mongoose'; 3 | 4 | export type TweetDocument = Tweet & Document; 5 | 6 | export type TweetProps = { 7 | content: string; 8 | screen_name: string; 9 | }; 10 | 11 | @Schema() 12 | export class Tweet { 13 | constructor(props: TweetProps) { 14 | Object.assign(this, props); 15 | } 16 | 17 | @Prop({ required: true }) 18 | content: string; 19 | 20 | @Prop({ required: true }) 21 | screen_name: string; 22 | } 23 | 24 | export const TweetSchema = SchemaFactory.createForClass(Tweet); 25 | -------------------------------------------------------------------------------- /src/tweets/tweets.controller.spec.txt: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { TweetsController } from './tweets.controller'; 3 | import { TweetsService } from './tweets.service'; 4 | 5 | describe('TweetsController', () => { 6 | let controller: TweetsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [TweetsController], 11 | providers: [TweetsService], 12 | }).compile(); 13 | 14 | controller = module.get(TweetsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/tweets/tweets.controller.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Controller, 3 | Get, 4 | Post, 5 | Body, 6 | Patch, 7 | Param, 8 | Delete, 9 | } from '@nestjs/common'; 10 | import { TweetsService } from './tweets.service'; 11 | import { CreateTweetDto } from './dto/create-tweet.dto'; 12 | import { UpdateTweetDto } from './dto/update-tweet.dto'; 13 | 14 | @Controller('tweets') 15 | export class TweetsController { 16 | constructor(private readonly tweetsService: TweetsService) {} 17 | 18 | @Post() 19 | create(@Body() createTweetDto: CreateTweetDto) { 20 | return this.tweetsService.create(createTweetDto); 21 | } 22 | 23 | @Get() 24 | findAll() { 25 | return this.tweetsService.findAll(); 26 | } 27 | 28 | @Get(':id') 29 | findOne(@Param('id') id: string) { 30 | return this.tweetsService.findOne(id); 31 | } 32 | 33 | @Patch(':id') 34 | update(@Param('id') id: string, @Body() updateTweetDto: UpdateTweetDto) { 35 | return this.tweetsService.update(id, updateTweetDto); 36 | } 37 | 38 | @Delete(':id') 39 | remove(@Param('id') id: string) { 40 | return this.tweetsService.remove(id); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/tweets/tweets.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TweetsService } from './tweets.service'; 3 | import { TweetsController } from './tweets.controller'; 4 | import { Tweet, TweetSchema } from './entities/tweet.entity'; 5 | import { MongooseModule } from '@nestjs/mongoose'; 6 | 7 | @Module({ 8 | imports: [ 9 | MongooseModule.forFeature([{ name: Tweet.name, schema: TweetSchema }]), 10 | ], 11 | controllers: [TweetsController], 12 | providers: [TweetsService], 13 | }) 14 | export class TweetsModule {} 15 | -------------------------------------------------------------------------------- /src/tweets/tweets.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { MongooseModule } from '@nestjs/mongoose'; 2 | import { Test, TestingModule } from '@nestjs/testing'; 3 | import { Tweet, TweetSchema } from './entities/tweet.entity'; 4 | import { TweetsService } from './tweets.service'; 5 | 6 | describe('TweetsService', () => { 7 | let service: TweetsService; 8 | let module: TestingModule; 9 | 10 | beforeEach(async () => { 11 | const uri = `mongodb://root:root@db_prod:27017/tweets_service_test?authSource=admin`; 12 | module = await Test.createTestingModule({ 13 | imports: [ 14 | MongooseModule.forRoot(uri), 15 | MongooseModule.forFeature([{ name: Tweet.name, schema: TweetSchema }]), 16 | ], 17 | providers: [TweetsService], 18 | }).compile(); 19 | service = module.get(TweetsService); 20 | }); 21 | 22 | afterEach(async () => { 23 | await module.close(); 24 | }); 25 | 26 | it('should be defined', () => { 27 | expect(service).toBeDefined(); 28 | }); 29 | 30 | it('should create a tweet', async () => { 31 | const tweet = await service.create({ 32 | content: 'Hello World', 33 | screen_name: 'Luiz Carlos', 34 | }); 35 | 36 | expect(tweet.content).toBe('Hello World'); 37 | expect(tweet.screen_name).toBe('Luiz Carlos'); 38 | 39 | const tweetCreated = await service['tweetModel'].findById(tweet._id); 40 | expect(tweetCreated.content).toBe('Hello World'); 41 | expect(tweetCreated.screen_name).toBe('Luiz Carlos'); 42 | }); 43 | 44 | it('should find all tweets', async () => { 45 | // criar um tweet 46 | // const tweets = await service.findAll(); 47 | }); 48 | 49 | it('should find one tweet', async () => { 50 | // criar um tweet 51 | // const tweet = await service.findOne(); 52 | 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /src/tweets/tweets.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectModel } from '@nestjs/mongoose'; 3 | import { Model } from 'mongoose'; 4 | import { CreateTweetDto } from './dto/create-tweet.dto'; 5 | import { UpdateTweetDto } from './dto/update-tweet.dto'; 6 | import { Tweet, TweetDocument } from './entities/tweet.entity'; 7 | 8 | @Injectable() 9 | export class TweetsService { 10 | constructor( 11 | @InjectModel(Tweet.name) 12 | private tweetModel: Model, 13 | ) {} 14 | 15 | async create(createTweetDto: CreateTweetDto) { 16 | const tweetDoc = new this.tweetModel(createTweetDto); 17 | await tweetDoc.save(); 18 | return tweetDoc; 19 | } 20 | 21 | findAll() { 22 | return this.tweetModel.find().exec(); 23 | } 24 | 25 | findOne(id: string) { 26 | return this.tweetModel.findById(id).exec(); 27 | } 28 | 29 | update(id: string, updateTweetDto: UpdateTweetDto) { 30 | return `This action updates a #${id} tweet`; 31 | } 32 | 33 | remove(id: string) { 34 | return `This action removes a #${id} tweet`; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { INestApplication } from '@nestjs/common'; 3 | import request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeEach(async () => { 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | afterEach(async () => { 19 | if (app) { 20 | await app.close(); 21 | } 22 | }); 23 | 24 | it('/ (GET)', () => { 25 | return request(app.getHttpServer()) 26 | .get('/') 27 | .expect(200) 28 | .expect('Hello World!'); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /test/tweets.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { INestApplication } from '@nestjs/common'; 2 | import { Test } from '@nestjs/testing'; 3 | import { AppModule } from '../src/app.module'; 4 | import request from 'supertest'; 5 | 6 | describe('TweetController (e2e)', () => { 7 | let app: INestApplication; 8 | beforeEach(async () => { 9 | const module = await Test.createTestingModule({ 10 | imports: [AppModule], 11 | }).compile(); 12 | 13 | app = module.createNestApplication(); 14 | await app.init(); 15 | }); 16 | 17 | afterEach(async () => { 18 | if (app) { 19 | await app.close(); 20 | } 21 | }); 22 | 23 | // mais demorado e caro 24 | it('POST /tweets', async () => { 25 | const res = await request(app.getHttpServer()) 26 | .post('/tweets') 27 | .send({ 28 | content: 'Hello World', 29 | screen_name: 'Luiz Carlos', 30 | }) 31 | .expect(201); 32 | 33 | expect(res.body._id).toBeDefined(); 34 | expect(res.body).toMatchObject({ 35 | content: 'Hello World', 36 | screen_name: 'Luiz Carlos', 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | --------------------------------------------------------------------------------