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.
Please visit my blog https://darylcober.blogspot.com/ for a complete review of how I put together this repository.
Latest ver 0.3.0 has been updated to use node 10.x.x, uses latest release of Aurelia CLI 1.0.0-beta.11 and uses latest release of Cordova Browser 6.0.0 (see known issues)
This project now includes Apple notarize for building a distributable for Macs. Please see my blog at https://darylcober.blogspot.com/2020/02/notarize-ios-apps.html for more information. You MUST update the appId in root/package.json "build" node to reflect your apple developer account. You MUST update the configuration information in notarize/notarize.js to reflect your apple developer id and your app specific password. You must update the widget id in root/config.xml to reflect your apple developer account. Failing to do so will result in the build failing.
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
- Note that this project provides a docker-compose file. With a docker engine installed, you can run
docker-compose upto launch a MongoDB server exposed on it's default port, 27017. - 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 and 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 all users you may want to use Node Version manager (recommended)
- https://github.com/coreybutler/nvm-windows Windows machines
- https://github.com/creationix/nvm 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 cordova -gnpm install aurelia-cli -gnpm install karma-cli -gnpm install(Be patient - it may take awhile!)
Next, if you're not running MongoDB locally, set its host configuration before running the prep command
- Determine the IP address of your MongoDB server
- Edit
server/config/config.dev.jsand set the following: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 be run once after a new git download.
The prep commands also seeds the data base with an administrator user with
username: samandpassword: crowso that you can log in.
The cordova platform is pre configured as follows:
- Platforms
- Browser
- 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
The www folder gets updated by a custom aurelia build script. Do not edit this folder.
Mobile resource images are in the res folder. Please see README for detailed instructions.
Run
cordova buildif 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.
Node tries to execute the cordova.js shim file in the project root when trying to execute any cordova cli commands. A simple fix is to run cordova cli commands from a sub directory such as www instead of the project root.
This project uses a pre-configured aurelia project using the aurelia cli https://aurelia.io/docs/cli with the following options selected:
- Built-in bundler with RequireJS
- ESNext
- Babel
- Less CSS pre-processor
- Unit Testing using Karma and Jasmine
- 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
|-- /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
|-- favicon.ico Browser icon
|-- index.html Main file for Aurelia
|-- jsconfig.json Visual Studio config
|-- karma.cong.js Karma config
To run the app in dev mode open a new terminal and enter
au run --watchruns the aurelia app in watch modeau run --watch --serverruns the aurelia app and web api server in watch mode
To build the app open a new terminal and enter
au buildbuilds the aurelia app
The run or build can be changed for different environments by adding a command line switch
au run --watch --server --env devbuilds the aurelia app and web api server for developmentau run --watch --server --env stagebuilds the aurelia app and web api server for stageau run --watch --server --env prodbuilds the aurelia app and web api server for production
To run the test suite open a new terminal window and enter
au test --watchruns the aurelia app tests in watch modekarma startruns 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 files here)
|-- /app/main.js Main project file for electron (editable)
|-- /app/package.json Configuration file for electron (editable)
|-- /build Build resource files
|-- /dist Distribution files from build
The app folder gets updated by a custom aurelai build script. Do not edit files this folder except for the main.js file and the package.json file that are not copied during the update and may be edited as needed for the Electron app.
The build folder contains image resources required by electron. Please see README for detailed instructions.
- To run the electron app open new terminal in root and enter
npm start - To build the electron installable package 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 client/config directory
The baseUrl settings should match the server host settings. Please note the
/api/addition to the url for the webApi setting
Please see README for configuring the server