Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

The “Cog” File

$
0
0

A few weeks ago, I ran into a situation where I had to pull in another a developer to help me finish up some work before an upcoming milestone. I directed her to our repository and she had the project up and running in a few minutes. I was excited by how quickly and easily she was able to get the project started, thanks to our internal documentation. I’ve lived through three hour npm install` debugging sessions before where versions aren’t documented or dependency conflicts arise. This validated the importance of documenting every project setup. Saving time here allowed me to focus on my current work instead of wasting both of our time trying to spin up the project locally on her machine.

Happy Cog alumDan Delauro, who wrote articles such as “ Deploying Static Websites to AWS S3 Behind an Nginx Proxy ” and “Gone zshin”, implemented what we affectionately call the “Cog” file. This file is a bash script that masks away all the heavy lifting in each project. Each cog file is custom to each project.

The Cog Commands
The “Cog” File

In terminal, Running cog` will print a list of available commands we have available for this django app.

These commands can vary from project to project.


The “Cog” File

Whether the project is built with Django, Laravel, CraftCMS, Patternlab, or any other framework/cms, running cog setup` will initially configure the entire project. This will install all the required packages, setup the local db, configuring your .env file, etc.


The “Cog” File

As of now, to automate our task we use either gulp or grunt . Sometime in the future we could be using who knows what. We can mask the default preprocessor by running cog dev`.


The “Cog” File

The cog go` command might be my favorite because with it we can start a docker container, run the built in php web server, or just about type of web server.

Invest the time

Not limited to the examples listed above, the cog file is a very powerful script. Instead of having lines of code to copy and paste to do all of these tasks, we compile it into one cohesive script. The time we invest into our documentation and cog files certainly benefits us as a team and saves us countless hours in the future. Do you have a different approach? How do you automate your workflow? Is your README file well-documented? I’d love to hear from you.


Viewing all articles
Browse latest Browse all 9596

Trending Articles