Applewood is a tasty flavor of The Smoke House Project https://github.com/smokehouseproject
Applewood is a skeleton framework for desktop/web/mobile deployment using Aurelia, a node Web API and a MongoDB. Each Smoke House Project is a good starting point for any project that can be run in a browser, compiled to a mobile app or built with electron into a desktop app.
Is a collection of the following libraries:
- Electron http://electron.atom.io/ builder for desktop apps
- Cordova https://cordova.apache.org/ builder for mobile apps
- Aurelia http://aurelia.io/ modern javascript framework
- Mongoose http://mongoosejs.com/ data base connector
Contains the following features:
- User Authentication
- User roles and permissions
- Web API Authentication
- Touch handling for mobile
- Scroll handling for mobile
- Localization
- Collection of Less mixins
- Data models that can auto persist state on mobile pause and resume
The following items must be installed on your dev machine with the exception of the MongoDB server. You just need a sever to be available for development.
- MongoDB database server https://www.mongodb.com/download-center#community
- Node.js version 4.x or above https://nodejs.org/en/ (Mac users see note below before installing node)
- Git Client https://desktop.github.com/ or https://git-scm.com/
- Android Studio https://developer.android.com/studio/index.html or JDK 1.8 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html on Macs and Windows machines
- Xcode (on Macs only)
For Mac users you may want to use Node Version manager https://github.com/creationix/nvm/blob/master/README.markdown This package is the recommended way to install and manage Node on Macs.
You will need a good code editor. I recommend Visual Studio Code https://code.visualstudio.com/download but you may use any code editor you feel comfortable with. The Aurelia project in this framework has been optimized for Visual Studio Code. You may have to do some re-work for other editors.
- Make sure you have all the prerequisites installed and working.
- Clone or download this repository to your development machine.
- Open a terminal (mac users) or command prompt (windows users) in the root of your cloned project. Enter the following commands:
npm install electron -g
npm install cordova -g
npm install aurelia-cli -g
npm install karma-cli -g
npm install ios-deploy -g
(Only on Macs)npm install
(Be patient - it may take awhile!)
Next set configurations before running the prep command
- Determine the IP address of your machine (Don't use localhost)
- Determine the IP address of your MongoDB server
- Edit
config/config.js
and set the following:authApi => baseUrl: 'http://yourIP:8050'
webApi => baseUrl: 'http://yourIP:8050/api/'
- Edit
server/config/config.dev.js
and set the following:config.host = 'yourIP
config.mongo.connectionstring = 'mongodb://yourMongoServerIP/Applewood'
Enter npm run prep
in the terminal open at the root of the project.
It is important to run the prep command. This installs the cordova platforms and plugins as well as performing a build and initializing the server web api. This only needs to done once.
The prep commands also seeds the data base with an administrator user with
username: sam
andpassword: crow
so that you can log in.
The cordova platform is pre configured as follows:
- Platforms
- IOS
- Android
- Plugins
- Device
- Splachscreen
- Whitelist
The Cordova wrapper consumes the following directories and files:
|-- /hooks Cordova build hooks
|-- /platforms Platform files
|-- /plugins Plugin files
|-- /res Resource files
|-- /www Core project source (don't edit this)
|-- config.xml Cordova config file
|-- cordova.js Polyfill to stub cordova in a browser
|-- cordova_plugins.js Polyfill to stub cordova in a browser
The www folder gets updated by a custom aurelai build script. Do not edit this folder.
Mobile resource images are in the res folder. Please see README for detailed instructions.
Run
cordova build
if you change anything in any of the above files. It is not necessary to run a cordova build when editing the aurelia project because the custom build scripts push the www folder to the platforms.
This project uses a pre-configured aurelia project using the aurelia cli http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli with the following options selected:
- ES2016 js and Babel transpiler
- Less CSS pre-processor
- Unit Testing using Jasmine and Karma
- Visual Studio Code as the editior
Aurelia (the core project) consumes the following directories and files:
|-- /.vscode Visual Studio Code settings
|-- /aurelia_project Aurelia project files
|-- /automation Scripts to prep the project
|-- /client Aurelia source files
|-- /images Image files
|-- /config Project configuration
|-- /fonts Font files
|-- /images Image files
|-- /less Less files
|-- /locales Language files
|-- /scripts Aurelia generated bundles
|-- /styles CSS files
|-- /test Test Scripts
|-- .babelrc Bable config
|-- .editorconfig Visual Studio editor config
|-- .eslintrc.json Linter config
|-- .gitignore Git config
|-- cordova.js Polyfill to stub cordova in a browser
|-- cordova_plugins.js Polyfill to stub cordova in a browser
|-- favicon.ico Browser icon
|-- index.html Main file for Aurelia
|-- jsconfig.json Visual Studio config
|-- karma.cong.js Karma config
|-- main.js Launcher used by Electron
To run the app in dev mode open a new terminal and enter
au run --watch
runs the aurelai app in watch modeau run --watch --server
runs the aurelai app and web api server in watch mode
The build can be changed for different environments by adding a command line switch
au run --watch --server --env dev
builds the aurelia app and web api server for developmentau run --watch --server --env stage
builds the aurelia app and web api server for stageau run --watch --server --env prod
builds the aurelia app and web api server for production
To run the test suite open a new terminal window and enter
au test --watch
runs the aurelia app tests in watch modekarma start
runs the web api server tests in watch mode
Electron uses the electron-builder https://github.com/electron-userland/electron-builder to build Windows, Unix and Mac installable packages. Configurations settings are located in package.json.
Electron consumes the following directories and files:
|-- /app Core project source (don't edit this)
|-- /build Build resource files
|-- /dist Distribution files from build
|-- main.js Loader file for Electron
The app folder gets updated by a custom aurelai build script. Do not edit this folder.
The build folder contains image resources required by electron. Please see README for detailed instructions.
- To run the app in electron open new terminal in root and enter
electron .
The dot (.) is important! - To build the app open new terminal in root and enter
npm run dist
The web API is located in the server directory. It is a stand alone project and is launched by a customized aurelia run script.
Please see README for more information.
All configurations are located in the /config directory
The baseUrl settings should match the server host settings. Please note the
/api/
addition to the url for the webApi setting Localhost works for developing using a desktop browser but compiled mobile apps will not be able to find the server unless they have a valid IP address
Please see README for configuring the server