Skip to content

Commit

Permalink
Merge pull request #397 from ever-co/develop
Browse files Browse the repository at this point in the history
Fixing builds for Ionic projects
  • Loading branch information
evereq authored Mar 29, 2019
2 parents daccf22 + 49f9f19 commit aee2b1c
Show file tree
Hide file tree
Showing 50 changed files with 288 additions and 148 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ jobs:
- run:
name: Run Build
command: cd carrier/mobile-ionic && yarn build
- run:
name: Run Ionic Build (Production)
command: cd carrier/mobile-ionic && yarn ionic:build:prod
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-carrier-mobile-ionic-{{ checksum "yarn.lock" }}
Expand Down Expand Up @@ -167,6 +170,9 @@ jobs:
- run:
name: Run Build
command: cd shop/mobile-ionic && yarn build
- run:
name: Run Ionic Build (Production)
command: cd shop/mobile-ionic && yarn ionic:build:prod
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-shop-mobile-ionic-{{ checksum "yarn.lock" }}
Expand Down Expand Up @@ -247,6 +253,9 @@ jobs:
- run:
name: Run Build
command: cd merchant/tablet-ionic && yarn build
- run:
name: Run Ionic Build (Production)
command: cd merchant/tablet-ionic && yarn ionic:build:prod
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-merchant-tablet-ionic-{{ checksum "yarn.lock" }}
Expand Down
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ yarn bootstrap

This will install required packages in all Platform projects using Lerna

Note: if above command fails for any reason, you can try to install required packages manually by running `yarn` inside every sub-folder with 'package.json' file

### Lerna (manual installation)

We are using [Lerna](https://github.com/lerna/lerna) for mono-repo management.
You need to run the following command from working folder where you cloned Ever git repo, which will install Lerna together with other packages:

```
yarn install
yarn
```

You may instead install Lerna globally:
Expand Down Expand Up @@ -144,31 +146,50 @@ It is also possible to use [AWS DocumentDB](https://aws.amazon.com/documentdb) o

_Note: we currently integrating [Mongo Memory Server](https://github.com/nodkz/mongodb-memory-server) which will allow to test Platform without need to install MongoDB locally._

### Platform Configuration (optional)
### Platform Configuration

#### Default

We created templates & initial configuration files (with reasonable defaults) for each project in the Platform, to save your time and keep things simple.

We created templates & initial configuration files (with reasonable defaults) for each project in the Platform, to save your time and keep things simple:
In the Angular based projects, the "standard" environment configuration files `environment.ts` and `environment.prod.ts` will be auto-generated from .env file (if it's exists) or from default settings on the first app run.

- For _Backend (API)_ configuration, the `./backend/api/.env.template` file should be copied into `./backend/api/.env` and relevant changes should (optionally) be done.
So, the following files will be auto-generated:

**IMPORTANT**: you should have `./backend/api/.env` file in place to be able to run the Platform on developer machine if you want to use different settings to our defaults.
- in Admin UI: `./admin/website-angular/src/environments/environment.ts` and `./admin/website-angular/src/environments/environment.prod.ts`.
- in Mobile Shop: `./shop/mobile-ionic/src/environments/environment.ts` and `./shop/mobile-ionic/src/environments/environment.prod.ts`
- in Web Shop: `./shop/website-angular/src/environments/environment.ts` and `./shop/website-angular/src/environments/environment.prod.ts`
- in Carrier App: `./carrier/mobile-ionic/src/environments/environment.ts` and `./carrier/mobile-ionic/src/environments/environment.prod.ts`
- in Merchant App: `./merchant/tablet-ionic/src/environments/environment.ts` and `./merchant/tablet-ionic/src/environments/environment.prod.ts`

- For _Admin_ Angular App configuration, the `./admin/website-angular/.env.template` file should be copied into `./admin/website-angular/.env` and relevant changes should (optionally) be done.
Note: you should never edit auto-generated files above and instead you should edit relevant .env files for custom configurations, see more details below.

Note: the "Standard" Angular environment configuration files `./admin/website-angular/src/environments/environment.ts` and `./admin/website-angular/src/environments/environment.prod.ts` will be auto-generated from .env file (if it's exists) or from default settings on the first app run
#### Custom / Manual

- For _Merchant_ Ionic App configuration, see `./merchant/tablet-ionic/src/environments/environment.ts` and `./merchant/tablet-ionic/src/environments/environment.prod.ts` files. If you need to run Merchant App using PM2 (as Web app, not Tablet App), needs copy `./merchant/tablet-ionic/.env.template` to `./merchant/tablet-ionic/.env` and make relevant changes (if required)
- For _Backend (API)_ configuration, the `./backend/api/.env.template` file should be copied into `./backend/api/.env` and relevant changes should be done in the `.env` file.
It means you should have `./backend/api/.env` file in place to be able to run the Platform on developer machine if you want to use different settings to our defaults.

- For _Shopping Mobile_ App (Ionic) configuration, see `./shop/mobile-ionic/src/environments/environment.ts` and `./shop/mobile-ionic/src/environments/environment.prod.ts` files
- For _Admin_ Angular App configuration, the `./admin/website-angular/.env.template` file should be copied into `./admin/website-angular/.env` and relevant changes should be done in the `.env` file.

- For _Shopping Website_ configuration, see `./shop/website-angular/src/environments/environment.ts` and `./shop/website-angular/src/environments/environment.prod.ts` files
- For _Merchant_ Ionic App configuration, the `./merchant/tablet-ionic/.env.template` file should be copied into `./merchant/tablet-ionic/.env` and relevant changes should be done in the `.env` file.
If you need to run Merchant App using PM2 (as Web app, not Tablet App), needs copy `./merchant/tablet-ionic/.env.template` to `./merchant/tablet-ionic/.env` and make relevant changes (if required)

- For _Carrier Mobile_ App (Ionic) configuration, see `./carrier/mobile-ionic/src/environments/environment.ts` and `./carrier/mobile-ionic/src/environments/environment.prod.ts` files
- For _Shopping Mobile_ App (Ionic) configuration, the `./shop/mobile-ionic/.env.template` file should be copied into `./shop/mobile-ionic/.env` and relevant changes should be done in the `.env` file.

- For _Shopping Website_ configuration, the `./shop/website-angular/.env.template` file should be copied into `./shop/website-angular/.env` and relevant changes should be done in the `.env` file.

- For _Carrier Mobile_ App (Ionic) configuration, the `./carrier/mobile-ionic/.env.template` file should be copied into `./carrier/mobile-ionic/.env` and relevant changes should be done in the `.env` file.

Notes:

- for initial development run no changes required in the `.env` or `environment.ts` files in the projects, unless some manual changes were done to the Backend (API) configuration. However, to enable some of the Platform features, you may need to change relevant configurations at corresponding files.
- For initial development no changes required in the `.env` files in the projects, unless some manual changes were done to the Backend (API) configuration. However, to enable some of the Platform features, you may need to change relevant configurations in corresponding `.env` files.

- As a general rule, files `.env` are configurations you should never make public (and of course never commit to Git repo), unless you removed all private/secure parameters from them.
In addition, for Angular based projects, you should never put any secure settings (e.g. Secret Keys, API Keys, etc) in `environment.ts` and `environment.prod.ts` files because all of them will be loaded into the browser and made public.
Because we are using auto-generated `environment.ts` and `environment.prod.ts` files, it means you should never put any secure settings into `.env` files in our Angular projects.
The only safe place to put your secure settings is `.env` file on the backend API/Server project!

- files `.env`, `environment.ts`, `environment.prod.ts` are configurations you should never make public, unless you removed all private/secure parameters from them.
- We are using dotenv (.env) in Angular based projects for consistency with configuration between all our Platform projects only.

### Run Platform Projects

Expand Down
13 changes: 13 additions & 0 deletions admin/website-angular/scripts/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ try {
} catch {}

const envFileDest: string = isProd ? 'environment.prod.ts' : 'environment.ts';
const envFileDestOther: string = !isProd
? 'environment.prod.ts'
: 'environment.ts';

writeFile(`./src/environments/${envFileDest}`, envFileContent, function(err) {
if (err) {
Expand All @@ -80,3 +83,13 @@ writeFile(`./src/environments/${envFileDest}`, envFileContent, function(err) {
console.log(`Generated Angular environment file: ${envFileDest}`);
}
});

writeFile(`./src/environments/${envFileDestOther}`, '', function(err) {
if (err) {
console.log(err);
} else {
console.log(
`Generated Second Empty Angular environment file: ${envFileDestOther}`
);
}
});
1 change: 1 addition & 0 deletions admin/website-angular/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"allowSyntheticDefaultImports": true,
Expand Down
4 changes: 2 additions & 2 deletions carrier/mobile-ionic/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.2" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<plugin name="cordova-plugin-email-composer" spec="^0.8.15" />
<engine name="browser" spec="5.0.3" />
<engine name="android" spec="7.1.1" />
<plugin name="mx.ferreyra.callnumber" spec="^0.0.2" />
<plugin name="cordova-plugin-camera" spec="4.0.3" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
Expand All @@ -100,4 +98,6 @@
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-vibration" spec="3.1.0" />
<engine name="browser" spec="^6.0.0" />
<engine name="android" spec="7.1.4" />
</widget>
3 changes: 1 addition & 2 deletions carrier/mobile-ionic/ionic.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"pro_id": "16ee2ab7",
"type": "angular",
"id": "16ee2ab7"
}
2 changes: 1 addition & 1 deletion carrier/mobile-ionic/ionic.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"type": "angular",
"app_id": "16ee2ab7"
}
53 changes: 28 additions & 25 deletions carrier/mobile-ionic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,37 +97,36 @@
"apollo-link-ws": "^1.0.17",
"call-number": "~1.0.1",
"connect": "^3.6.6",
"cordova-android": "^7.1.4",
"cordova-android": "7.1.4",
"cordova-android-support-gradle-release": "^2.0.1",
"cordova-browser": "^6.0.0",
"cordova-open-native-settings": "^1.5.2",
"cordova-plugin-appavailability": "^0.4.2",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-dialogs": "^2.0.1",
"cordova-plugin-geolocation": "4.0.1",
"cordova-plugin-globalization": "1.11.0",
"cordova-plugin-google-analytics": "1.8.6",
"cordova-plugin-email-composer": "^0.9.2",
"cordova-plugin-geolocation": "^4.0.1",
"cordova-plugin-globalization": "^1.11.0",
"cordova-plugin-google-analytics": "^1.8.6",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-intercom": "^6.2.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.0.0",
"cordova-plugin-mixpanel": "4.5.2",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-ionic-webview": "^4.0.1",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-mixpanel": "^4.5.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-screen-orientation": "^3.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-uniquedeviceid": "^1.3.2",
"cordova-plugin-vibration": "3.1.0",
"cordova-plugin-vibration": "^3.1.0",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-open-native-settings": "^1.5.2",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "4.0.3",
"cordova-plugin-email-composer": "^0.9.2",
"cordova-plugin-local-notification": "0.9.0-beta.2",
"cordova-plugin-network-information": "2.0.1",
"cordova-plugin-screen-orientation": "^3.0.1",
"phonegap-plugin-barcodescanner": "^8.0.1",
"core-js": "^3.0.0",
"cryptiles": "^4.1.3",
"font-awesome": "^4.7.0",
"es6-promise-plugin": "^4.2.2",
"font-awesome": "^4.7.0",
"graphql": "^14.1.1",
"graphql-tag": "^2.10.1",
"hooks-fixed": "^2.0.2",
Expand All @@ -137,8 +136,9 @@
"mongoose": "^5.4.19",
"mpath": "^0.5.1",
"mquery": "^3.2.0",
"mx.ferreyra.callnumber": "^0.0.2",
"mx.ferreyra.callnumber": "0.0.2",
"node-sass": "^4.11.0",
"phonegap-plugin-barcodescanner": "^8.0.1",
"qrcode": "^1.3.3",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.4.0",
Expand All @@ -147,12 +147,11 @@
"save": "^2.3.3",
"socket.io-client": "^2.2.0",
"stripe": "^6.28.0",
"swiper": "^4.5.0",
"sw-toolbox": "^3.6.0",
"swiper": "^4.5.0",
"tslib": "^1.9.3",
"uuid": "^3.3.2",
"waves": "^0.1.1",
"webpack-merge": "^4.2.1",
"zone.js": "^0.9.0"
},
"devDependencies": {
Expand Down Expand Up @@ -209,7 +208,8 @@
"tslint": "^5.14.0",
"yargs": "^13.2.2",
"typescript": "~3.2.4",
"webpack-bundle-analyzer": "^3.1.0"
"webpack-bundle-analyzer": "^3.1.0",
"webpack-merge": "^4.2.1"
},
"config": {
"ionic_webpack": "./config/webpack.config.js"
Expand All @@ -227,7 +227,9 @@
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-google-analytics": {},
"cordova-plugin-google-analytics": {
"GMS_VERSION": "11.0.1"
},
"cordova-plugin-network-information": {},
"cordova-plugin-mixpanel": {
"PLAY_SERVICES_VERSION": "+"
Expand All @@ -246,7 +248,8 @@
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-vibration": {},
"cordova-plugin-local-notification": {}
"cordova-plugin-local-notification": {},
"call-number": {}
}
},
"engines": {
Expand Down
13 changes: 13 additions & 0 deletions carrier/mobile-ionic/scripts/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export const environment: Environment = {
`;

const envFileDest: string = isProd ? 'environment.prod.ts' : 'environment.ts';
const envFileDestOther: string = !isProd
? 'environment.prod.ts'
: 'environment.ts';

// we always want first to remove old generated files (one of them is not needed for current build)
try {
Expand All @@ -85,3 +88,13 @@ writeFile(`./src/environments/${envFileDest}`, envFileContent, function(err) {
console.log(`Generated Angular environment file: ${envFileDest}`);
}
});

writeFile(`./src/environments/${envFileDestOther}`, '', function(err) {
if (err) {
console.log(err);
} else {
console.log(
`Generated Second Empty Angular environment file: ${envFileDestOther}`
);
}
});
2 changes: 1 addition & 1 deletion carrier/mobile-ionic/src/pages/information/about/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { environment } from 'environment';
styleUrls: ['about.scss']
})
export class AboutPage {
protected aboutHtml: string;
aboutHtml: string;

protected appVersion: string;

Expand Down
4 changes: 2 additions & 2 deletions carrier/mobile-ionic/src/pages/language/language.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component } from '@angular/core';

import { TranslateService } from '@ngx-translate/core';
import { DeviceRouter } from '@modules/client.common.angular2/routers/device-router.service';

Expand All @@ -22,11 +21,12 @@ export class LanguagePage {
return localStorage.getItem('_deviceId');
}

languageChange(val) {
languageChange() {
localStorage.setItem('_language', this.language);

// Example: "en-US".substr(0, 2) = "en"
const langAbbreviation = this.language.substr(0, 2);

this._langTranslator.use(langAbbreviation);

if (this.deviceId) {
Expand Down
4 changes: 4 additions & 0 deletions carrier/mobile-ionic/src/pages/main/delivery/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class DeliveryPage implements AfterViewInit {
carrierUserDistance: string;
disabledButtons: boolean = true;

get fullAddress() {
return this.selectedOrder.user.fullAddress;
}

constructor(
private orderRouter: OrderRouter,
private mixpanel: Mixpanel,
Expand Down
1 change: 1 addition & 0 deletions carrier/mobile-ionic/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"allowSyntheticDefaultImports": true,
Expand Down
Loading

0 comments on commit aee2b1c

Please sign in to comment.