Webstorm, Husky and Commitizen

Our team is using Commitizen to enforce format of git commit messages (this is later used to auto-generate changelogs and bump version). And we’re using Husky to make sure everyone joining the team has commitizen running as a git hook.

Now, I am using Webstorm and I create my commit directly from my IDE.  The commitizen git hook prepare-commit-msg clashes with Webstorm because it is meant to be used in a CLI environment.

The solution I am using is

  • Use Git Commit Template plugin for Webstorm to format git messages
  • After a fresh `​npm install` (husky recreates its git hook), I have to
    • Manually edit `.git/hooks/prepare-commit-msg`
    • To comment the line that runs husky by simply adding a # at the beginning of the line
      `. “$(dirname “$0”)/husky.sh”`

Of course, Webstorm is configured to “Run git hooks”. So it will keep running the others hooks we have (lint, tests, …). But it will skip the prepare-commit-msg hook.

VS Code alias auto-completion

All credits go to jgoux ; this post is a post-it to his explanation on Github: https://github.com/tleunen/babel-plugin-module-resolver/issues/92#issuecomment-285755384


1. Teach VS Code’s Intellisense where to look at

So you can jump to the definition and have autocompletion. sparkles

To do that, create a jsconfig.json file at the root of your project :

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "~/*": [
        "src/*"
      ]
    }
  },
  "exclude": [
    "node_modules"
  ]
}

2. Teach VS Code to autocomplete your paths

Install the extension Path Intellisense

This extension allows the autocompletion of the custom paths.

Configure the extension in your project’s settings under .vscode/settings.json :

{
  "path-intellisense.mappings": {
    "~": "${workspaceRoot}/src"
  }
}

3. Teach Babel how to resolve your custom paths

The last step is to install and configure babel-plugin-module-resolver so the code compile!

Here is my .babelrc :

{
  "plugins": [
    [
      "module-resolver",
      {
        "alias": {
          "~": "./src"
        }
      }
    ]
  ]
}

AWS CloudFront S3, Basic HTTP authentication – password protection

This is a post it to this article explaining how to use a Lambda function to protect a CloudFront-S3 distribution using Basic HTTP Authentication.

Some additional notes:

  • The Lambda Function must be in the region us-east-1 (US East N. Virginia)
  • You must create a new version of the Lambda function
  • The ARN of the Lambda function you provide to CloudFront must inlude the lambda version
  • The Lambda function’s role must have the following Trust Policy

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com", "edgelambda.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }