generator-angular2-firebase-bootstrap

1.2.0 • Public • Published

generator-angular2-firebase-bootstrap NPM version Build Status Dependency Status

A Yeoman generator for creating projects based on Angular, Firebase and Twitter Bootstrap.

angular-220px bootstrap-social-logo-220px firebase_16-logo-220px

This will be the last version of the project generator-angular2-firebase-bootstrap before it gets renamed to generator-ngx-firebase-bootstrap with support of Angular 4 and beyond.

Features

  • An Angular 2 app generated with angular-cli
  • Twitter Bootstrap with ng2-bootstrap
  • AngularFire2 and Firebase
  • An initial implementation of an authentication service (See auth-service)
  • One component to display user information
  • One component to login using username/password, Google or Twitter
  • One component to allow a user to register himself with username/password.
  • One component for password reset (when using username/password).

It is up to you to use these component in your own pages. When the project is scaffolded they all included on the home page for demo purposes.

Installation

Requirement Node 6+ && NPM 3+

This generator is targeted to be used with Node >= 6.9.0 and NPM >= 3.0.0. You can check your version number with the command

$ node --version && npm --version

Requirement Angular CLI

To build and run this project, you will need Angular CLI. This version is compatible with @angular/cli rc2. If you have any previous instantiation of the Angular CLI, you should remove them.

$ npm uninstall -g angular-cli # remove any previous angular-cli 
$ npm i -g @angular/cli
$ ng --version # make sur you have the correct version of angular/cli 
    _                      _                 ____ _     ___
   /   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0
node: 6.10.1
os: darwin x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/compiler-cli: 2.4.10
@angular/cli: 1.0.0

Steps to install

First, install Yeoman and generator-angular2-firebase-bootstrap using npm (we assume you have pre-installed node.js).

$ npm install -g yo
$ npm install -g generator-angular2-firebase-bootstrap
# If you want this generator to init a git repository for you 
$ npm install -g generator-git-init

Then generate your new project:

$ yo angular2-firebase-bootstrap

Features

  • An Angular 2 generated with angular-cli.
  • Bootstrap with ng2-bootstrap
  • AngularFire2 for Firebase
  • An initial implementation of an authentication service (See auth-service)
  • One ready to use component to display user information (from Firebase)
  • One ready to use component to login using username/password, Google or Twitter.

Getting Started

You should have your Firebase project created in Firebase. For this, go to the Firebase Console and create a new project, in the newly created project go to 'Add Firebase to your web app'. This option will give you all the credential information you will need when generating your project. For authentication to work, you should enable the Authentication methods you want to use. The seeded project contains a auth-service provider that can handle several types of authentication.

Steps to scaffold a new project

  1. Create a project folder and enter it: mkdir myproject && cd $_
  2. Generate project: yo angular2-firebase-bootstrap

The generator will ask you a few information on your Firebase project:

  • Your Api Key
  • Your Auth Domain
  • Your Database URL
  • Your Storage Bucket
  • Your Messaging SenderId

You should have those handy when you run the generator. Otherwise, you can go and fill in those values in the firebaseConfig.ts file in the generated project.

The generator will also optionally run git init on your project and do an initial commit for you.

Firebase Authentication example

The generated project will contain example code to authenticate to your project in Firebase. For this to actually work, you will have to enable authentication in your firebase project. The project supports Email/Password, Google Sign-In and Twitter. You could probably use Facebook and Github but we never tested that.

Go to Firebase Authentication Documentation to find out how to enable authentication for your project in Firebase. Please note that to use Email/Password authentication, so you will have to register users yourself via the Firebase Console.

The generated project will contain 3 ready to be used components for login, register and display user information. They are initially present in the home page of the application but can be moved elsewhere at your convenience.

Screenshot

Run the application

To run the project using Angular CLI, do the following

$ ng serve

Please refer to Angular CLI documentation below.

Deploy to Firebase Hosting

To deploy your application to Firebase Hosting you should follow the instructions as explained at Deploy Your Site in the Firebase Documentation.

In a nutshell:

$ firebase init
 
> Choose Hosting
> Accept default database.rules.json
> Choose 'dist' as your public directory
> Enter 'no' for rewrite all urls to index.html

Then build your application for production with AOT.

$ ng build --prod --aot

Then deploy to Firebase.

$ firebase deploy

Angular 2 CLI Specifics

This project was generated with angular-cli version 1.0.0-beta.21. It currently runs fine with angular-cli version 1.0.0-beta.28.3. It also supports AOT.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive/pipe/service/class.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the -prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor. Before running the tests make sure you are serving the app via ng serve.

Deploying to Github Pages

Run ng github-pages:deploy to deploy to Github Pages.

Further help

To get more help on the angular-cli use ng --help or go check out the Angular-CLI README.

License

Apache-2.0 © Bernard Niset

Package Sidebar

Install

npm i generator-angular2-firebase-bootstrap

Weekly Downloads

3

Version

1.2.0

License

Apache-2.0

Last publish

Collaborators

  • bn3t