Просмотр исходного кода

Rename to ionic-beer and prepare for production deployment

Matt Raible 7 лет назад
Родитель
Сommit
662661eeda
6 измененных файлов: 115 добавлений и 45 удалений
  1. 38
    38
      client/config.xml
  2. 1
    1
      client/ionic.config.json
  3. 1
    1
      client/package.json
  4. 2
    2
      client/src/manifest.json
  5. 6
    3
      client/src/providers/beer-service.ts
  6. 67
    0
      deploy.sh

+ 38
- 38
client/config.xml Просмотреть файл

@@ -1,40 +1,40 @@
1
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+<?xml version='1.0' encoding='utf-8'?>
2 2
 <widget id="com.ionicframework.ionicauth613285" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
-  <name>ionic-auth</name>
4
-  <description>An awesome Ionic/Cordova app.</description>
5
-  <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
6
-  <content src="index.html"/>
7
-  <access origin="*"/>
8
-  <allow-navigation href="http://ionic.local/*"/>
9
-  <allow-intent href="http://*/*"/>
10
-  <allow-intent href="https://*/*"/>
11
-  <allow-intent href="tel:*"/>
12
-  <allow-intent href="sms:*"/>
13
-  <allow-intent href="mailto:*"/>
14
-  <allow-intent href="geo:*"/>
15
-  <platform name="android">
16
-    <allow-intent href="market:*"/>
17
-  </platform>
18
-  <platform name="ios">
19
-    <allow-intent href="itms:*"/>
20
-    <allow-intent href="itms-apps:*"/>
21
-  </platform>
22
-  <preference name="webviewbounce" value="false"/>
23
-  <preference name="UIWebViewBounce" value="false"/>
24
-  <preference name="DisallowOverscroll" value="true"/>
25
-  <preference name="android-minSdkVersion" value="16"/>
26
-  <preference name="BackupWebStorage" value="none"/>
27
-  <preference name="SplashMaintainAspectRatio" value="true"/>
28
-  <preference name="FadeSplashScreenDuration" value="300"/>
29
-  <preference name="SplashShowOnlyFirstTime" value="false"/>
30
-  <preference name="KeyboardDisplayRequiresUserAction" value="false" />
31
-  <feature name="StatusBar">
32
-    <param name="ios-package" onload="true" value="CDVStatusBar"/>
33
-  </feature>
34
-  <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
35
-  <plugin name="cordova-plugin-whitelist" spec="1.3.1"/>
36
-  <plugin name="cordova-plugin-console" spec="1.0.5"/>
37
-  <plugin name="cordova-plugin-statusbar" spec="2.2.1"/>
38
-  <plugin name="cordova-plugin-device" spec="1.1.4"/>
39
-  <plugin name="cordova-plugin-splashscreen" spec="~4.0.1"/>
3
+    <name>ionic-beer</name>
4
+    <description>An awesome Ionic/Cordova app.</description>
5
+    <author email="matt.raible@stormpath.com" href="https://stormpath.com/">Matt Raible</author>
6
+    <content src="index.html" />
7
+    <access origin="*" />
8
+    <allow-navigation href="http://ionic.local/*" />
9
+    <allow-intent href="http://*/*" />
10
+    <allow-intent href="https://*/*" />
11
+    <allow-intent href="tel:*" />
12
+    <allow-intent href="sms:*" />
13
+    <allow-intent href="mailto:*" />
14
+    <allow-intent href="geo:*" />
15
+    <platform name="android">
16
+        <allow-intent href="market:*" />
17
+    </platform>
18
+    <platform name="ios">
19
+        <allow-intent href="itms:*" />
20
+        <allow-intent href="itms-apps:*" />
21
+    </platform>
22
+    <preference name="webviewbounce" value="false" />
23
+    <preference name="UIWebViewBounce" value="false" />
24
+    <preference name="DisallowOverscroll" value="true" />
25
+    <preference name="android-minSdkVersion" value="16" />
26
+    <preference name="BackupWebStorage" value="none" />
27
+    <preference name="SplashMaintainAspectRatio" value="true" />
28
+    <preference name="FadeSplashScreenDuration" value="300" />
29
+    <preference name="SplashShowOnlyFirstTime" value="false" />
30
+    <preference name="KeyboardDisplayRequiresUserAction" value="false" />
31
+    <feature name="StatusBar">
32
+        <param name="ios-package" onload="true" value="CDVStatusBar" />
33
+    </feature>
34
+    <plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
35
+    <plugin name="cordova-plugin-whitelist" spec="~1.3.1" />
36
+    <plugin name="cordova-plugin-console" spec="~1.0.5" />
37
+    <plugin name="cordova-plugin-statusbar" spec="~2.2.1" />
38
+    <plugin name="cordova-plugin-device" spec="~1.1.4" />
39
+    <plugin name="cordova-plugin-splashscreen" spec="~4.0.1" />
40 40
 </widget>

+ 1
- 1
client/ionic.config.json Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 {
2
-  "name": "ionic-auth",
2
+  "name": "ionic-beer",
3 3
   "app_id": "",
4 4
   "v2": true,
5 5
   "typescript": true

+ 1
- 1
client/package.json Просмотреть файл

@@ -48,5 +48,5 @@
48 48
       "locator": "ios"
49 49
     }
50 50
   ],
51
-  "description": "ionic-auth: An Ionic project"
51
+  "description": "ionic-beer: An Ionic project"
52 52
 }

+ 2
- 2
client/src/manifest.json Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 {
2
-  "name": "Ionic Auth",
3
-  "short_name": "Ionic Auth",
2
+  "name": "Ionic Beer",
3
+  "short_name": "Ionic Beer",
4 4
   "start_url": "index.html",
5 5
   "display": "standalone",
6 6
   "icons": [{

+ 6
- 3
client/src/providers/beer-service.ts Просмотреть файл

@@ -2,13 +2,16 @@ import { Injectable } from '@angular/core';
2 2
 import { Http, Response } from '@angular/http';
3 3
 import 'rxjs/add/operator/map';
4 4
 import { Observable } from 'rxjs';
5
+import { StormpathConfiguration } from 'angular-stormpath';
5 6
 
6 7
 @Injectable()
7 8
 export class BeerService {
8
-  public API = 'http://localhost:8080';
9
-  public BEER_API = this.API + '/beers';
9
+  public API;
10
+  public BEER_API;
10 11
 
11
-  constructor(public http: Http) {
12
+  constructor(public http: Http, public config: StormpathConfiguration) {
13
+    this.API = config.endpointPrefix;
14
+    this.BEER_API = this.API + '/beers';
12 15
   }
13 16
 
14 17
   getGoodBeers(): Observable<any> {

+ 67
- 0
deploy.sh Просмотреть файл

@@ -0,0 +1,67 @@
1
+#!/bin/bash
2
+# Warning: this script has only been tested on macOS Sierra. There's a good chance
3
+# it won't work on other operating systems. If you get it working on another OS,
4
+# please send a pull request with any changes required. Thanks!
5
+set -e
6
+
7
+### CloudFoundry CLI utilities
8
+CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
9
+CLOUD_TARGET=api.${DOMAIN}
10
+
11
+function login(){
12
+    cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
13
+    cf apps | grep OK || cf login
14
+}
15
+
16
+function app_domain(){
17
+    D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
18
+    echo $D
19
+}
20
+
21
+function deploy_service(){
22
+    N=$1
23
+    D=`app_domain $N`
24
+    JSON='{"uri":"http://'$D'"}'
25
+    cf create-user-provided-service $N -p $JSON
26
+}
27
+
28
+### Installation
29
+
30
+cd `dirname $0`
31
+r=`pwd`
32
+echo $r
33
+
34
+## Reset
35
+cf d -f ionic-server
36
+
37
+cf a
38
+
39
+# Stormpath
40
+stormpathApiKeyId=`cat ~/.stormpath/apiKey.properties | grep apiKey.id | cut -f3 -d\ `
41
+stormpathApiKeySecret=`cat ~/.stormpath/apiKey.properties | grep apiKey.secret | cut -f3 -d\ `
42
+
43
+# Deploy the server
44
+cd $r/server
45
+mvn clean package
46
+cf push -p target/*jar ionic-server --no-start  --random-route
47
+cf set-env ionic-server STORMPATH_API_KEY_ID $stormpathApiKeyId
48
+cf set-env ionic-server STORMPATH_API_KEY_SECRET $stormpathApiKeySecret
49
+cf set-env ionic-server FORCE_HTTPS true
50
+cf start ionic-server
51
+
52
+# Get the URL for the server
53
+serverUri=https://`app_domain pwa-server`
54
+
55
+# Deploy the client
56
+cd $r/client
57
+rm -rf dist
58
+# replace the server URL in the client
59
+sed -i -e "s|http://localhost:8080|$serverUri|g" $r/client/src/app/app.module.ts
60
+npm install && ionic build ios
61
+
62
+# cleanup changed files
63
+git checkout $r/client
64
+rm $r/client/src/app/app.module.ts-e
65
+
66
+# deploy client to phone
67
+ionic run ios