Book Image

AngularJS UI Development

By : Amit Gharat, Matthias Nehlsen
Book Image

AngularJS UI Development

By: Amit Gharat, Matthias Nehlsen

Overview of this book

<p>AngularJS and its rich set of components solve many of the problems developers face when writing reliable single page applications in ways that would not be possible using other frameworks. This book will help you expand your horizons by teaching you the skills needed to successfully design, customize, build, and deliver real-world applications in AngularJS. We will start off by setting up a fully automated environment to quickly scaffold, test, and deploy any application. Along the way, we'll cover how to design and build production-ready applications to demonstrate how innovative and powerful AngularJS is. By leveraging CSS3 animations, we'll convert them into intuitive and native-like applications in no time. You will also learn how to use Grunt for application-specific task management, Bower to manage dependencies with external libraries/plugins, Git for better versioning, and Karma and Protractor for automated testing to build applications the way experts do.</p> <p>You will learn all this by building real-world applications including a to-do application, Github dashboard, project management application, and many more.</p>
Table of Contents (17 chapters)
AngularJS UI Development
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Managing the source code with Git


You are probably using Git already. If not, you really should. You need to have it installed for working with Bower anyway, so why not use it for your own projects?. Git is a distributed Version Control System (VCS). I cannot imagine working without it, neither in a team nor when working on a project myself. We don't have the space to cover Git for team development here in either case; this topic can easily fill an entire book. However, if you are working in a team that uses Git, you will probably know how to use it already. What we can do in this introductory chapter is go through the basics for a single developer.

First, you need to install Git if you do not have it on your system yet.

Note

OS X

On a Mac, again the easiest way to do this is using Homebrew (http://brew.sh). Run the following command in the Terminal after installing Homebrew:

# brew install git

Windows

On Windows, the easiest way to install Git is to run the Windows installer from http://git-scm.com/downloads.

Linux (Ubuntu)

On Ubuntu, run the following command in the shell:

# sudo apt-get install git

Let's initialize a fresh repository in the current directory:

git init

Then, we create a hidden file named .gitignore, for now with only the following content:

node_modules

Note

This tells Git to ignore the hundreds of files and directories in the node_modules folder. These don't need to be stored in our version control system because the modules can be restored by running npm install in the root folder of the application instead, as all the dependencies are defined in the package.json file.

Next, we add all files in the current directory (and in all subdirectories):

git add 

Next, we freeze the file system in its current state:

git commit –m "initial commit"

Now, we can edit any file, try things out, and accidentally break things without having to worry because we can always come back to anything that was committed into the VCS. This adds incredible peace of mind when you are playing around with the code.

When you issue the git status command, you will notice that we are on a branch called master. A project can have multiple branches at the same time; these are really useful when working on a new feature. We should always keep master as the latest stable version; additional features (or bug fixes) should always be worked upon in a separate branch. Let's create a new feature branch called additional-feature:

git branch additional-feature

Once it is created, we need to check out the branch:

git checkout additional-feature

Now, when the new code is ready to be committed, the process is the same as before:

git add .
git commit –m "additional feature added"

We should commit early and often; this habit will make it much easier to undo previous changes when things go wrong. Now, when everything is working in the new branch (all the tests pass), we can go back into the master branch:

git checkout master

Then, we can merge the changes back into the master branch:

git merge additional-feature

Being able to freely change between branches, for example, makes it very easy to go back to the master branch from whatever you are working on and do a quick bug fix (in a specialized branch, ideally) without having to think about what you just broke with the current changes in the new feature branch. Please don't forget to commit before you switch the branch though. You can merge the bug fix in this example back into the master, go back to the feature branch you were working on, and even pull those changes that were just done in the master branch into the branch you are working on. For this, when you are inside the feature branch, merge the changes:

git merge master

If these changes were in different areas of your files, this should run without any difficulties. If they were in the same lines, you will need to manually resolve the conflicts.

Tip

Using Git is a really useful way to manage source code. However, it is in no way limited to code files (or text files, for that matter). Any file can be placed under source control. For example, this book was written with heavy usage of Git, for any file involved. This is extremely useful when you are trying to go back to the previous versions of any file.