/applewood

Applewood is a skeleton framework for desktop/web/mobile deployment using Aurelia, a node Web API and a MongoDB

Primary LanguageJavaScript

Applewood

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:

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

Prerequisites


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.

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.

Getting Started


  1. Make sure you have all the prerequisites installed and working.
  2. Clone or download this repository to your development machine.
  3. Open a terminal (mac users) or command prompt (windows users) in the root of your cloned project. Enter the following commands:
  4. npm install electron -g
  5. npm install cordova -g
  6. npm install aurelia-cli -g
  7. npm install karma-cli -g
  8. npm install ios-deploy -g (Only on Macs)
  9. npm install (Be patient - it may take awhile!)

Next set configurations before running the prep command

  1. Determine the IP address of your machine (Don't use localhost)
  2. Determine the IP address of your MongoDB server
  3. Edit config/config.js and set the following:
    • authApi => baseUrl: 'http://yourIP:8050'
    • webApi => baseUrl: 'http://yourIP:8050/api/'
  4. 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 and password: crow so that you can log in.

Cordova


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.

Aurelia


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:

  1. ES2016 js and Babel transpiler
  2. Less CSS pre-processor
  3. Unit Testing using Jasmine and Karma
  4. 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

  1. au run --watch     runs the aurelai app in watch mode
  2. au 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

  1. au run --watch --server --env dev     builds the aurelia app and web api server for development
  2. au run --watch --server --env stage     builds the aurelia app and web api server for stage
  3. au 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

  1. au test --watch     runs the aurelia app tests in watch mode
  2. karma start     runs the web api server tests in watch mode

Electron


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.

  1. To run the app in electron open new terminal in root and enter electron . The dot (.) is important!
  2. To build the app open new terminal in root and enter npm run dist

Web API


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.

Configuring the Client


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