Source code management

Source code management is a very important part of software development. It is always best to version and tag the code. Git is the most popular source code management tool, and we have been using it throughout this chapter. So, for a perfect deployment cycle, we should always create different branches. These are feature branch, develop branch, release branch, and then we have the default master branch. I have already covered best practice around this in earlier chapters, so I won't talk here about the structuring of branches and how code flow across branches is managed. However, it is important to about the folder structure to be followed for Cloud Functions. In earlier chapters, we wrote function in index.js. If functions are limited then they can easily be managed within index.js. But if we have hundreds of functions then managing them within one file becomes really tedious and painful. So, one simple way to structure the functions would be as follows:

├── /build/                # Compiled output for Node.js 6.x
├── /src/ # Application source files
│ ├── someFuncA.js # Function A
│ ├── someFuncA.test.js # Function A unit tests
│ ├── someFuncB.js # Function B
│ ├── someFuncB.test.js # Function B unit tests
├── index.js # Main export(s)
└── package.json # List of project dependencies and NPM scripts

There are many ways to structure it, but I have kept it simple. However, I would let the developer decide over the structure.