<commit_before># ABCWeb

[![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://github.com/volatiletech/abcweb/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/volatiletech/abcweb?status.svg)](https://godoc.org/github.com/volatiletech/abcweb)
[![Go Report Card](https://goreportcard.com/badge/volatiletech/abcweb)](http://goreportcard.com/report/volatiletech/abcweb)

ABCWeb was heavily inspired by Rails for its ease-of-use, flexibility, 
and development speed. The goal of this project is to make developing a 
web app in Go just as painless. We've tried to remain as unopinionated
as possible to make ABCWeb suited for many different application types,
and our big selling point is the packages we've chosen, which we believe
are the clear leaders in the eco-system.

Getting started is as simple as running the `abcweb new` command which will
generate you a new Go web app that comes working out of the box.

You can specify extra `abcweb new` command-line arguments to tell the generator 
what features and packages you would like enabled.

This customizability allows abcweb to suit your requirements, whether that be a 
server-side rendered web app (html templates), a client-side rendered 
web app (reactjs, angularjs) or a stand-alone web API server.

## Contents

- [ABCWeb](#abcweb)
    - [Features](#features)
    - [Packages](#packages)
    - [Getting Started](#getting-started)
    - [Usage](#usage)
    - [Configuration](#configuration)
    - [Gulp](#gulp)
    - [FAQ](#faq)

## Features

Most features can be removed on a per-app basis by specifying
flags to the `abcweb new` command.

* HTTP2 support
* Database ORM
* Database migrations
* Build system and task runner (Gulp 4)
* Automatic asset compilation on asset change
* Automatic browser refreshing with LiveReload
* Automatically rebuild Go app on code change
* Automatically run migrations against test database for testing
* SCSS and LESS support
* Asset fingerprinting, compilation, minification and gzip
* [Font-Awesome](http://fontawesome.io/) and [Twitter Bootstrap 4](https://v4-alpha.getbootstrap.com/)
* Infinite environments in configuration
* Command-line and environment variable configuration
* Flexible routing (stdlib context.Context) 
* Flexible rendering (HTML, JSON, XML, text & binary data)
* Colored and leveled logging 
* TLS1.2/SSL support
* HTTP sessions (supports cookie, disk, memory and redis sessions) 
* Flash messages 
* Rendering interface to easily add support for any templating engine
* Vendored dependencies to ensure consistent compatibility 
* Many more features!

## Packages

ABCWeb uses a collection of the very best open-source projects and packages the
Go community has to offer. These packages were chosen specifically because 
they are fast, intelligently designed, easy to use and modern. For a full list
see [PACKAGES.md](https://github.com/volatiletech/abcweb/blob/master/PACKAGES.md):

#### Database ORM

[SQLBoiler](https://github.com/vattle/sqlboiler) is one of our other core projects and was a natural 
fit for ABCWeb. It is the fastest ORM by far (on par with stdlib), it is featureful 
and has excellent relationship support, and its generation approach allows for type-safety and
editor auto-completion. We've made using SQLBoiler easy by bundling it into the `abcweb gen` command.

#### Database Migrations

[mig](https://github.com/volatiletech/mig) is our fork of [Goose](https://github.com/pressly/goose)
that patches some big issues and was tweaked to make it work better with ABCWeb. It does
everything you'd expect a migration tool to do, and has both a library and command-line component.
Mig supports MySQL and Postgres at present. It has been bundled into the `abcweb gen` 
and `abcweb migrate` commands.

#### Sessions, Cookies & Flash Messages

[ABCSessions](https://github.com/volatiletech/abcsessions) was designed to make working with 
HTTP sessions and cookies a breeze, and it also comes with a flash messages API. ABCSessions 
ships with disk, memory, redis and cookie storers, and the ability to easily add new storers using
our provided interfaces.

#### Rendering API

[Render](https://github.com/unrolled/render) is a package that provides functionality for 
easily rendering JSON, XML, text, binary data, and HTML templates. We have also written an interface
wrapper for Render ([ABCRender](https://github.com/volatiletech/abcrender)) that allows you to
easily add support for any templating engine you choose if Go's `html/template` is not enough for you.

#### Routing

[Chi](https://github.com/pressly/chi) is one of the fastest and most modern routers in the eco-system
and is starting to gain a cult following. Chi was built on the `context` package that was introduced
in Go 1.7. It's elegant API design and stdlib-only philosophy is what has Chi standing out from the rest.

#### Logging

[Zap](https://github.com/uber-go/zap) was written by Uber, and is widely regarded as the fastest and
most performant logging package, even rivaling the standard library. It is a structured, leveled &
colored logger.

#### Command Line and Configuration

ABCWeb comes with [Cobra](https://github.com/spf13/cobra) for handling command-line arguments and
[Viper](https://github.com/spf13/viper) for handling configuration loading. These packages are widely
known, widely used and widely enjoyed.

#### Vendoring

When ABCWeb generates your app it also includes a `vendor.json` file with all of its dependencies
in it. The `abcweb new` command will automatically sync your `vendor` folder on generation.
[Govendor](github.com/kardianos/govendor) was the tool of choice here. It's functional and easy to use.

#### Build System, Asset Pipeline & Task Running

ABCWeb uses [Gulp](https://github.com/gulpjs/gulp/tree/4.0) to handle asset compilation,
minification, task running and live reloading of the browser on changes to the asset files or
html templates. Read the [Gulp section of this readme](#gulp) if you'd like further information.
ABCWeb also uses [refresh](https://github.com/markbates/refresh) to rebuild your go web app on changes 
to your configuration or .go files. Refresh can be highly customized using the `watch.toml` config file.

[Read here](#why-did-you-choose-to-use-gulp) if you're wondering why we chose a NodeJS dependency. 
Also note that it's optional, but highly recommended due to the conveniences it provides.

## Getting Started

ABCWeb requires Go 1.8 or higher.

It's dead easy to generate a web app using ABCWeb.

### Step 1:
[Install NodeJS](#how-do-i-install-nodejs-npm-and-gulp).

This is required for the asset pipeline (Gulp). Using Gulp is optional (`--no-gulp`), 
but we highly recommend it because it makes the development process SO much easier.

### Step 2:
```shell
# download and install abcweb
go get -u github.com/volatiletech/abcweb

# install and upgrade all dependencies (including Gulp)
abcweb deps -u 

# generate your app (abcweb automatically uses the GOPATH to find your src folder)
abcweb new github.com/username/myapp
```

Your app has now been generated!

#### Where to from here?

```shell
# cd into your new project folder
cd $GOPATH/src/github.com/username/myapp 

# Run abcweb dev for auto-rebuild of app, assets and LiveReload.
# You can optionally set your default environment in config.toml
MYAPP_ENV=dev abcweb dev
```

Navigate your browser to your now running server at http://localhost:4000/, 
modify your `templates/main/home.html` template, and you should see your changes
automatically load. Awesome!

Note that changes to the `.go` files or `.toml` config files will automatically
rebuild your go web-server, however they will require a manual browser refresh
(automatically refreshing in the middle of server changes could put you in 
a pickle, so we decided against it).

## Usage

```
ABCWeb is a tool to help you scaffold and develop Go web applications.

Usage:
  abcweb [command]

Available Commands:
  build       Builds your abcweb binary and executes the gulp build task
  deps        Download and optionally update all abcweb dependencies
  dev         Runs your abcweb app for development
  gen         Generate your database models and migration files
  help        Help about any command
  migrate     Run migration tasks (up, down, redo, status, version)
  new         Generate a new abcweb app
  test        Runs the tests for your abcweb app

Flags:
      --version   Print the abcweb version

Use "abcweb [command] --help" for more information about a command.
```

## Configuration

This project loads configuration in the order of:

1. Command line argument default values
2. config.toml
3. Environment variables
4. Supplied command line arguments

This means that values passed into the command line will
override values passed in through the config.toml and env vars.

* App configuration is found in `config.toml`.
* Database configuration is found in `database.toml`.
* `abcweb dev` Go auto-rebuild configuration is found in `watch.toml`.
* Asset pipeline, task runner and build system configuration is found in `gulpfile.js`.<commit_msg>add dist and revendor commands to readme<commit_after># ABCWeb

[![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://github.com/volatiletech/abcweb/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/volatiletech/abcweb?status.svg)](https://godoc.org/github.com/volatiletech/abcweb)
[![Go Report Card](https://goreportcard.com/badge/volatiletech/abcweb)](http://goreportcard.com/report/volatiletech/abcweb)

ABCWeb was heavily inspired by Rails for its ease-of-use, flexibility, 
and development speed. The goal of this project is to make developing a 
web app in Go just as painless. We've tried to remain as unopinionated
as possible to make ABCWeb suited for many different application types,
and our big selling point is the packages we've chosen, which we believe
are the clear leaders in the eco-system.

Getting started is as simple as running the `abcweb new` command which will
generate you a new Go web app that comes working out of the box.

You can specify extra `abcweb new` command-line arguments to tell the generator 
what features and packages you would like enabled.

This customizability allows abcweb to suit your requirements, whether that be a 
server-side rendered web app (html templates), a client-side rendered 
web app (reactjs, angularjs) or a stand-alone web API server.

## Contents

- [ABCWeb](#abcweb)
    - [Features](#features)
    - [Packages](#packages)
    - [Getting Started](#getting-started)
    - [Usage](#usage)
    - [Configuration](#configuration)
    - [Gulp](#gulp)
    - [FAQ](#faq)

## Features

Most features can be removed on a per-app basis by specifying
flags to the `abcweb new` command.

* HTTP2 support
* Database ORM
* Database migrations
* Build system and task runner (Gulp 4)
* Automatic asset compilation on asset change
* Automatic browser refreshing with LiveReload
* Automatically rebuild Go app on code change
* Automatically run migrations against test database for testing
* SCSS and LESS support
* Asset fingerprinting, compilation, minification and gzip
* [Font-Awesome](http://fontawesome.io/) and [Twitter Bootstrap 4](https://v4-alpha.getbootstrap.com/)
* Infinite environments in configuration
* Command-line and environment variable configuration
* Flexible routing (stdlib context.Context) 
* Flexible rendering (HTML, JSON, XML, text & binary data)
* Colored and leveled logging 
* TLS1.2/SSL support
* HTTP sessions (supports cookie, disk, memory and redis sessions) 
* Flash messages 
* Rendering interface to easily add support for any templating engine
* Vendored dependencies to ensure consistent compatibility 
* Many more features!

## Packages

ABCWeb uses a collection of the very best open-source projects and packages the
Go community has to offer. These packages were chosen specifically because 
they are fast, intelligently designed, easy to use and modern. For a full list
see [PACKAGES.md](https://github.com/volatiletech/abcweb/blob/master/PACKAGES.md):

#### Database ORM

[SQLBoiler](https://github.com/vattle/sqlboiler) is one of our other core projects and was a natural 
fit for ABCWeb. It is the fastest ORM by far (on par with stdlib), it is featureful 
and has excellent relationship support, and its generation approach allows for type-safety and
editor auto-completion. We've made using SQLBoiler easy by bundling it into the `abcweb gen` command.

#### Database Migrations

[mig](https://github.com/volatiletech/mig) is our fork of [Goose](https://github.com/pressly/goose)
that patches some big issues and was tweaked to make it work better with ABCWeb. It does
everything you'd expect a migration tool to do, and has both a library and command-line component.
Mig supports MySQL and Postgres at present. It has been bundled into the `abcweb gen` 
and `abcweb migrate` commands.

#### Sessions, Cookies & Flash Messages

[ABCSessions](https://github.com/volatiletech/abcsessions) was designed to make working with 
HTTP sessions and cookies a breeze, and it also comes with a flash messages API. ABCSessions 
ships with disk, memory, redis and cookie storers, and the ability to easily add new storers using
our provided interfaces.

#### Rendering API

[Render](https://github.com/unrolled/render) is a package that provides functionality for 
easily rendering JSON, XML, text, binary data, and HTML templates. We have also written an interface
wrapper for Render ([ABCRender](https://github.com/volatiletech/abcrender)) that allows you to
easily add support for any templating engine you choose if Go's `html/template` is not enough for you.

#### Routing

[Chi](https://github.com/pressly/chi) is one of the fastest and most modern routers in the eco-system
and is starting to gain a cult following. Chi was built on the `context` package that was introduced
in Go 1.7. It's elegant API design and stdlib-only philosophy is what has Chi standing out from the rest.

#### Logging

[Zap](https://github.com/uber-go/zap) was written by Uber, and is widely regarded as the fastest and
most performant logging package, even rivaling the standard library. It is a structured, leveled &
colored logger.

#### Command Line and Configuration

ABCWeb comes with [Cobra](https://github.com/spf13/cobra) for handling command-line arguments and
[Viper](https://github.com/spf13/viper) for handling configuration loading. These packages are widely
known, widely used and widely enjoyed.

#### Vendoring

When ABCWeb generates your app it also includes a `vendor.json` file with all of its dependencies
in it. The `abcweb new` command will automatically sync your `vendor` folder on generation.
[Govendor](github.com/kardianos/govendor) was the tool of choice here. It's functional and easy to use.

#### Build System, Asset Pipeline & Task Running

ABCWeb uses [Gulp](https://github.com/gulpjs/gulp/tree/4.0) to handle asset compilation,
minification, task running and live reloading of the browser on changes to the asset files or
html templates. Read the [Gulp section of this readme](#gulp) if you'd like further information.
ABCWeb also uses [refresh](https://github.com/markbates/refresh) to rebuild your go web app on changes 
to your configuration or .go files. Refresh can be highly customized using the `watch.toml` config file.

[Read here](#why-did-you-choose-to-use-gulp) if you're wondering why we chose a NodeJS dependency. 
Also note that it's optional, but highly recommended due to the conveniences it provides.

## Getting Started

ABCWeb requires Go 1.8 or higher.

It's dead easy to generate a web app using ABCWeb.

### Step 1:
[Install NodeJS](#how-do-i-install-nodejs-npm-and-gulp).

This is required for the asset pipeline (Gulp). Using Gulp is optional (`--no-gulp`), 
but we highly recommend it because it makes the development process SO much easier.

### Step 2:
```shell
# download and install abcweb
go get -u github.com/volatiletech/abcweb

# install and upgrade all dependencies (including Gulp)
abcweb deps -u 

# generate your app (abcweb automatically uses the GOPATH to find your src folder)
abcweb new github.com/username/myapp
```

Your app has now been generated!

#### Where to from here?

```shell
# cd into your new project folder
cd $GOPATH/src/github.com/username/myapp 

# Run abcweb dev for auto-rebuild of app, assets and LiveReload.
# You can optionally set your default environment in config.toml
MYAPP_ENV=dev abcweb dev
```

Navigate your browser to your now running server at http://localhost:4000/, 
modify your `templates/main/home.html` template, and you should see your changes
automatically load. Awesome!

Note that changes to the `.go` files or `.toml` config files will automatically
rebuild your go web-server, however they will require a manual browser refresh
(automatically refreshing in the middle of server changes could put you in 
a pickle, so we decided against it).

## Usage

```
ABCWeb is a tool to help you scaffold and develop Go web applications.

Usage:
  abcweb [command]

Available Commands:
  build       Builds your abcweb binary and executes the gulp build task
  deps        Download and optionally update all abcweb dependencies
  dev         Runs your abcweb app for development
  dist        Dist creates a distribution bundle for easy deployment
  gen         Generate your database models and migration files
  help        Help about any command
  migrate     Run migration tasks (up, down, redo, status, version)
  new         Generate a new abcweb app
  revendor    Revendor updates your vendor.json file and resyncs your vendor folder
  test        Runs the tests for your abcweb app

Flags:
  -h, --help      help for abcweb
      --version   Print the abcweb version

Use "abcweb [command] --help" for more information about a command.
```

## Configuration

This project loads configuration in the order of:

1. Command line argument default values
2. config.toml
3. Environment variables
4. Supplied command line arguments

This means that values passed into the command line will
override values passed in through the config.toml and env vars.

* App configuration is found in `config.toml`.
* Database configuration is found in `database.toml`.
* `abcweb dev` Go auto-rebuild configuration is found in `watch.toml`.
* Asset pipeline, task runner and build system configuration is found in `gulpfile.js`.
{'fraction_non_alphanumeric': 0.0769105514546244, 'fraction_numerical': 0.002822405557967868, 'mean_word_length': 4.34833091436865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 38, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '582119', 'n_tokens_mistral': 5167, 'n_tokens_neox': 4943, 'n_words': 2364}