Skip to content

Instantly share code, notes, and snippets.

@hano
Last active August 29, 2015 14:06
Show Gist options
  • Save hano/28ccaea5449e9c527b53 to your computer and use it in GitHub Desktop.
Save hano/28ccaea5449e9c527b53 to your computer and use it in GitHub Desktop.
mCAP CLI
# mCAP CLI
**The command line interface**
[mway.io/cli_intro]mway.io/cli_intro
---
## Agenda
- Instruction in the mCAP CLI
- Generating an App with the CLI
- Intro to project structure
- Deploy it to a mCAP
- Publish the app to relution.io
- Hands-On
---
## Dependencies
1. node
2. npm
3. git
---
## Installation
**[README](https://github.com/mwaylabs/mcap-cli/blob/master/README.md#install)**
---
## First run
**Type** `mcap` **in your console and press enter!**
---
##Let's build an APP
- Configure Server
- Generate App
- Deploy
- Work
- Publish
---
## Add mCAP Dev-Server
```
mcap server add
$ dev
$ http://10.21.4.97:8079
$ mway
$ mway
```
---
## Add Relution-Server
```
mcap server add
$ mdmdev
$ https://mdmdev.mwaysolutions.com/
$ aaa:aaa
$ aaa
```
---
## Workarround
```
open ~/.mcaprc
```
add `"endpoint": "/mcapmudio/mcap-mudio/upload"` to *dev*
```
"dev": {
"baseurl": "http://10.21.4.97:8079",
"username": "mway",
"password": "mway",
"endpoint": "/mcapmudio/mcap-mudio/upload"
}
```
---
## Create Application
```
mcap new [YOUR_NAME]sApp de.mway.[YOUR_NAME]sApp
cd [YOUR_NAME]sApp
```
---
## The project structure
```
.
├── client
│   ├── app.rln
│   ├── changelog.txt
│   ├── css
│   ├── img
│   ├── index.html
│   ├── js
│   │   ├── app.js
│   │   ├── controllers.js
│   │   └── mcapconfig.js
│   ├── lib
│   ├── modules
│   │   └── todos
│   │   ├── bikini
│   │   │   ├── Collections
│   │   │   │   └── todos_collection.js
│   │   │   └── Models
│   │   │   └── todos_model.js
│   │   ├── controllers
│   │   ├── directives
│   │   ├── services
│   │   ├── todos.js
│   │   └── views
│   └── templates
├── mcap.json
├── models
│   └── todo.json
└── server
├── datasync.js
├── index.js
└── package.json
```
---
## Deploy Application
```
mcap deploy
# or
mcap deploy dev
```
---
## Test the Application
---
### Serve Application
```
mcap serve
# Browser 1
# login
open http://10.21.4.97:8079
# local application
open http://localhost:8080/
# Browser 2
# login
open http://10.21.4.97:8079
# remote application
open http://10.21.4.97:8079/mway/[YOUR_NAME]sApp/index.html
```
---
### Reset Application
- Delete Local Storage
- DROP TABLE Todo....
- DROP TABLE msg....
---
### Publish to Relution
Bikini needs to have a login - so lets build it.
1. Update Bikini Endpoint
2. Login on Startup
3. Publish
---
### Update Bikini Endpoint
`client/js/mcapconfig.js`
```
window.mCAPConfig.defaultStage = 'prod';
//current:stage:identifier
window.mCAPConfig.baseUrl = 'http://10.21.4.97:8079/';
window.mCAPConfig.baseUrlProd = window.mCAPConfig.baseUrl + '/mway/[YOUR_NAME]sApp/api/dataSync';
```
---
### Login on Startup
`client/index.html`
```
$ionicPlatform.ready(function() {
mCAP.application.set('baseUrl', window.mCAPConfig.baseUrl);
mCAP.authentication.login({
userName: 'mway',
password: 'mway'
}).then(function(){
alert('Login Succ');
}).fail(function(){
alert('Login Err');
});
...
});
```
---
### Publish
```
mcap publish mdmdev
```
---
## Generate a model
- Type in your console and press enter!
```
mcap generate model
```
- Answer the questions
---
## Hands-on
---
## Task
**Implement a delete button in the detail view**
---
## Any questions, ideas or suggestions?
---
## THANK YOU!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment