Building Your App
Each FW App comes with a particular file: gulpfile.js
, that when used along with the Gulp build system, provides several command line things that will assist you in building your application.
First, you must make sure your node modules have been installed correctly. Make sure NodeJS is installed on your system, then run npm install
from your application's root folder. Once that has completed, you need to run gulp init
. That sets up all of the ember-cli dependencies, and enables your ember-cli application to run successfully. Once both of those commands have run successfully, you are ready to use all of the gulp commands in the application.
Brief note on config.json
This first time you run gulp init
, or any of the gulp commands, two files will be generated: config.json
and fw.json
. fw.json
is autogenerated and should not be edited, but the config.json
is designed to house a couple of variables that are used during development of your ember application. These variables are encoded in JSON notation for convenience.
outputDirectory
This is the directory you want your ember-cli build script to output to. It needs to point to the location inside of your web server's document root. (Must be the exact folder that you want your app to be built to)
For example, if your document root is /var/www/site/
and you want your application's url to be http://my-testing-website.com/apps/my-app/
, you would set the outputDirectory
to /var/www/site/apps/my-app/
.
url
This needs to be set to your application's url relative to the domain name. To take from the previous example, if you want your app's url to be http://my-testing-website.com/apps/my-app/
, you would set url
to /apps/my-app/
. Note: This must have a trailing slash on both ends, so if you want your app to be exactly the domain name, you would set url
to /
Basic Tasks
gulp init
Even though you should have already run this command, it warrants mentioning what exactly this command does and when you should re-run it. gulp init
ensures that all of your client (ember-cli) dependencies are installed correctly. You should re-run this command any time your update the dependencies your app has.
gulp help
This lists all of the available gulp commands with a short description as to their usage.
gulp clean
This will remove all installed dependencies (gulp and client-side) and all built ember-cli files. You will need to re-run npm install
and gulp init
after this. This command is useful if and when you run into a dependency conflict error (doesn't happen often, and when it does it's normally on updating).
Building Tasks
These commands need to be run whenever you are working on the client side of your application.
gulp dev
This builds your ember-cli application in the development
environment, which essentially means that your application javascript files will be compiled, but not made as small as possible. See ember-cli's docs on environments for more information.
gulp prod
This builds your ember-cli application in the production
environment. This should be used for a live version of your application, because it shrinks down all of the built files to their smallest possible size, which reduces page load times. See ember-cli's docs on environments for more information.
gulp watch
This builds your ember-cli application in the development
environment (similar to gulp dev
), however it will watch for file changes in your ember-cli application. Whenever that happens, your app will be automatically re-built. This is extremely helpful whenever you are doing lots of work on your client application and want all of your changes to take effect immediately.
Database Tasks
If you are using the migration-core
addon (which comes pre-installed when you use the fw-kit
or gc-kit
blueprint), the application's build script can do some basic migration tasks. See the Phinx Documentation and the migration-core documentation (TBD) for more information.
gulp phinx:migrate
This command runs all of the database migration scripts up to the latest version
gulp phinx:rollback
This command rolls back your database one migration version.
gulp phinx:create
This command creates a new database migration automatically. See migration-core's documentation for more information.
Testing Commands
The build scripts contain several helpful commands for testing, as well as an overarching command that runs all of the test commands at once. Note: if you installed FW Api via the installer, you will need to go to your api's directory and run composer install
to ensure all the dependencies are installed for testing
-
gulp validate
- This runs all the testing commands at once. Useful for something like an automated build environment. -
gulp lint
- This runs all of the code 'linting' commands, which basically check code style and usage to make sure your code is uniform and doesn't have any usage errors. (Doesn't check for bugs though ;) -
gulp test-unit
- This runs all of your php unit tests using PHPUnit. -
gulp test-ember
- This runs all of your ember-cli tests. See the testing section of the ember-cli docs for more information