#Project Flok is divided up like rails. There is the flok kernel and driver stack and then there is user-facing applications. ###The flok command You create and build projects via the `flok` command. You must set the `$FLOK_ENV` to either `DEBUG` or `RELEASE` and `$PLATFORM` to a platform. * `flok new ` - Create a new flok project * `flok build` - Build a flok project. Generates files in `./products` * `flok server` - Trigger auto-rebuild when a file is requested in the `./app` folder and hosts the `products/$PLATFORM` folder on `http://localhost:9992/`. e.g. `http://localhost:9992/application_user.js`. Outputs `SERVER STARTED` when server is fully launched. ###Folder structure * `app/` * `controllers/` - All your controllers live here as `rb` files. * `services/` - Service `rb` files * `scripts/` - Scripts are ordinary javascript files that are merged with the main kernel. * `products/` - Autogenerated when you build * `$PLATFORM/` - A folder named after the platform you selected * `application_user.js` - The source for the flok application_user. Includes your application code statically linked * `drivers/` - Contains the driver code needed to implement the driver side interface * `config/` - The configuration files * `services.rb` - A list of service instances that are statically compiled into the kernel. See [Services](./services.md) for details. * `platforms/$PLATFORM/` - Platform dependent build options * `config.yml` - Copied from the platform's config.yml folder in the kernel `./app/drivers/$PLATFORM/config.yml`. This is used when running `flok build` ###application_user.js `application_user.js` is equivalent to the application_user build `application.js` except that it contains the users controllers statically linked (appended in *js*). ###User build process 1. The gem is build via `build:world` using the platform given in build. 2. Copy everything in the gems ./flok/products/$PLATFORM -> $PROJECT/products/$PLATFORM and ./flok/app/kern/services/*.rb -> $PROJECT/products/$PLATFORM/services/kern_services.rb 3. The controllers in `./app/controllers/**/*.rb` are run through the `user_compiler` in `./lib/flok/user_compiler.rb` and then saved to the projects `./products/$PLATFORM/glob/user_compiler.js` and the `./app/services/*.rb` are globbed into `./products/$PLATFORM/services/user_services.rb` 4. The `./products/$PLATFORM/services/*.rb` file are globbed into `./products/$PLATFORM/services/combined_services.rb` 5. The service configuration in `./config/services.rb` is read and run through `services_compiler` and files from `./products/$PLATFORM/services/combined_services.rb`. The output of this file is moved to `./products/$PLATFORM/glob/services.js` 6. `./products/$PLATFORM/application.js` is moved to `./products/$PLATFORM/glob/application.js` 7. The local project `./products/$PLATFORM/glob/application.js` and `./products/$PLATFORM/glob/user_compiler.js` and `./products/$PLATFORM/glob/services.js` and `./products/$PLATFORM/glob/scripts.js` are merged into `./products/$PLATFORM/glob/application_user.js.erb`. 8. The `erb` files is then sent to `./products/$PLATFORM/glob/application_user.js` with the below `ERB` variables allowable. ####Supported variables * `@debug` - Set to `true` when FLOK_ENV=DEBUG * `@release` - Set to `true` when FLOK_ENV=RELEASE ```js //Example JS code for debug / release mode <% if @debug %> //JS Code for debug <% else %> //JS code for not debug mode <% end %> ```