Generator for Angular / Firebase / Bootstrap projects
A Yeoman generator for creating projects based on Angular, Firebase and Twitter Bootstrap. This generator provides basic integration
with those tools and offers a framework for authentication right out of the box.
Now the router setup allows navigation between the pages and the components. You will just need to customize the Home page
and add more pages to your own needs.
If you like and/or use this generator, please star this project on Github.
This generator is targeted to be used with Node >= 10.0.0 and NPM >= 6.0.0. You can check your version number with the command
$ node --version && npm --version
v10.13.0
6.5.0
To build and run this project, you will need Angular CLI. This version is compatible with @angular/cli 7.2.1. 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
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 7.2.1
Node: 10.13.0
OS: darwin x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.12.1 (cli-only)
@angular-devkit/core 7.2.1 (cli-only)
@angular-devkit/schematics 7.2.1 (cli-only)
@schematics/angular 7.2.1 (cli-only)
@schematics/update 0.12.1 (cli-only)
rxjs 6.3.3
First, install Yeoman and generator-ngx-firebase-bootstrap using npm (we assume you have pre-installed node.js).
$ npm install -g yo
$ npm install -g generator-ngx-firebase-bootstrap
# If you want this generator to init a git repository for you
# not supported for the moment: $ npm install -g generator-git-init
Then generate your new project:
$ yo ngx-firebase-bootstrap
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 (See Authenticate Using Google Sign-In with JavaScript). The seeded project contains a auth-service
provider that can handle several types of authentication.
mkdir myproject && cd $_
yo ngx-firebase-bootstrap
The generator will ask you a few information on your Firebase project:
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.
Not supported for the moment: The generator will also optionally run git init
on your project and do an initial commit for you.
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 the following pages to help you start with your application featuring a basic router
setup.
There is a Bootstrap base navigation bar provided as an example.
The Home (when not already logged in) has a link to the Login Page which allows to Login via Twitter, Google or Email/Password. The Login page also has the Reset Password component.
Also accessible from the Home page, the Register page shows the register component to allow … guess what.
When not logged in the Home Pages shows links to the Login and Register pages, otherwise, it shows user information as shown below.
The Dashboard page is an example of a proteted page in your application. The page is protected by the LoggedInGuard that
checks the user is logged in before allowing access.
This page is available when not logged in and shows all available components in one convenient page.
To run the project using Angular CLI, do the following:
$ ng serve 130 ↵
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-05-20T11:14:31.504Z
Hash: 4c66c7c1edfed1ce558d
Time: 14024ms
chunk {main} main.js, main.js.map (main) 83.8 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 134 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.43 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
Please refer to Angular CLI documentation below.
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 'yes' for rewrite all urls to index.html
> Enter 'no' for Overwriting dist/index.html
Then build your application for production with AOT.
$ ng build --prod --aot
Then deploy to Firebase.
$ firebase deploy
This project was generated with Angular Cli. The project is still compatible
with the CLI so you can use it to run your Development server, add more components, etc.
Apache-2.0 © Bernard Niset