Skip to content

Commit

Permalink
Merge pull request #266 from crossroads/master
Browse files Browse the repository at this point in the history
#December2018Release1
  • Loading branch information
namrataukirde authored Dec 6, 2018
2 parents ff71818 + 90a832f commit 37cd51d
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 64 deletions.
59 changes: 37 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ aliases:
- image: circleci/node:carbon
working_directory: ~/code
- &restore-repo-cache
key: admin-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
key: v1-admin-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
- &restore-yarn-cache
keys:
- admin-goodcity-yarn-packages-{{ checksum "yarn.lock" }}
- v1-admin-goodcity-yarn-packages-{{ checksum "yarn.lock" }}
- &save-yarn-cache
key: admin-goodcity-yarn-packages-{{ checksum "yarn.lock" }}
key: v1-admin-goodcity-yarn-packages-{{ checksum "yarn.lock" }}
paths:
- node_modules
- ~/.cache/yarn
- &yarn
|
yarn install --non-interactive --cache-folder ~/.cache/yarn --frozen-lockfile
- &restore-bower-cache
key: admin-goodcity-bower-components-{{ checksum "bower.json" }}
key: v1-admin-goodcity-bower-components-{{ checksum "bower.json" }}
- &save-bower-cache
key: admin-goodcity-bower-components-{{ checksum "bower.json" }}
key: v1-admin-goodcity-bower-components-{{ checksum "bower.json" }}
paths:
- bower_components
- &restore-bundler-cache
key: admin-goodcity-bundle-{{ checksum "Gemfile.lock" }}
key: v1-admin-goodcity-bundle-{{ checksum "Gemfile.lock" }}
- &save-bundler-cache
key: admin-goodcity-bundle-{{ checksum "Gemfile.lock" }}
key: v1-admin-goodcity-bundle-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle

Expand All @@ -38,7 +38,7 @@ jobs:
steps:
- checkout
- save_cache:
key: admin-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
key: v1-admin-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/code

Expand All @@ -55,6 +55,8 @@ jobs:

tests:
<<: *defaults
docker:
- image: circleci/node:8-browsers
environment:
JOBS: 1
steps:
Expand Down Expand Up @@ -120,17 +122,30 @@ jobs:
- restore-cache: *restore-bundler-cache
- run: bundle check --path=vendor/bundle || bundle install --deployment --jobs=4 --retry=3
- save-cache: *save-bundler-cache
- run:
name: Setup Environment variables
command: |
echo 'export ASSET_HOST_URL=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo "https://admin.goodcity.hk/assets"; else echo "https://admin-staging.goodcity.hk/assets"; fi)' >> $BASH_ENV
echo 'export APP_VERSION=$(jq -r ".version" package.json)' >> $BASH_ENV
- attach_workspace:
at: ~/code
- run: mv dist-www/ dist
- run:
name: Get source map url with grep
command: echo 'export SOURCE_MAP_WITH_VARIABLE_NAME=$(grep sourceMappingURL dist/assets/goodcity-*.js)' >> $BASH_ENV
- run: echo $SOURCE_MAP_WITH_VARIABLE_NAME
- run:
name: Remove unnecessary characters form source map
command: echo 'export SOURCE_MAP=$(eval echo $SOURCE_MAP_WITH_VARIABLE_NAME | cut -c22-100)' >> $BASH_ENV
- run: echo $SOURCE_MAP
- run:
name: Setup Environment
command: echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
- run: bundle exec cap $ENVIRONMENT deploy:upload
- run:
name: Upload Source Map to Rollbar
command: |
curl https://api.rollbar.com/api/1/sourcemap/download -F access_token="${ROLLBAR_ACCESS_TOKEN}" -F version="${APP_VERSION}" -F minified_url=https://admin-staging.goodcity.hk/assets/goodcity.js
curl https://api.rollbar.com/api/1/sourcemap/download -F access_token="${ROLLBAR_KEY}" -F version="${APP_VERSION}" -F minified_url=$ASSET_HOST_URL/$SOURCE_MAP
ember_cordova_build:
Expand Down Expand Up @@ -237,10 +252,10 @@ jobs:
name: Setup Environment variables
command: |
echo 'export PATH=$PATH:`yarn bin`' >> $BASH_ENV
echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
echo 'export PROVISIONING_PROFILE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo $PROD_PROVISIONING_PROFILE; else echo $STAGING_PROVISIONING_PROFILE; fi)' >> $BASH_ENV
echo 'export CERTIFICATE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo $PROD_CERT; else echo $STAGING_CERT; fi)' >> $BASH_ENV
echo 'export STAGING=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo false; else echo true; fi)' >> $BASH_ENV
echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
echo 'export PROVISIONING_PROFILE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo 'GoodCity_Admin.mobileprovision'; else echo 'GoodCity_Admin_Staging.mobileprovision'; fi)' >> $BASH_ENV
echo 'export CERTIFICATE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo 'Goodcity_2019.p12'; else echo 'GoodCity_2018_Development.p12'; fi)' >> $BASH_ENV
- run:
command: |
npm rebuild node-sass
Expand Down Expand Up @@ -270,13 +285,13 @@ jobs:
working_directory: ~/code
- run: pod setup
- run:
name: install cordova-update-config globally
name: Install cordova-update-config globally
command: npm i -g cordova-update-config
- run:
name: install cordova globally
name: Install cordova globally
command: npm i -g [email protected]
- run:
name: create keychain and import certificates
name: Create keychain and import p12 certificate
command: bundle exec fastlane ios prepare_certificates cert:$CERTIFICATE
working_directory: ~/code
- run:
Expand All @@ -286,7 +301,7 @@ jobs:
- store_artifacts:
path: cordova/platforms/ios/build/device
- run:
name: release ios build
name: Release ios build
command: bundle exec fastlane ios ${ENVIRONMENT}
working_directory: ~/code

Expand Down Expand Up @@ -334,9 +349,9 @@ workflows:
filters:
branches:
only: /^(master|live)$/
# - ios_build_and_deploy:
# requires:
# - ember_cordova_build
# filters:
# branches:
# only: /^(master|live)$/
- ios_build_and_deploy:
requires:
- tests
filters:
branches:
only: live
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ gem "fastlane"
gem "cocoapods"
gem "credentials_manager"
gem "nokogiri" # for CircleCI v2 deployment to extract version number
gem "plist"

3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ DEPENDENCIES
credentials_manager
fastlane
nokogiri
plist
rake

BUNDLED WITH
1.16.0
1.16.1
66 changes: 42 additions & 24 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require "json"
require "fileutils"
require "rake/clean"
require 'plist'

ROOT_PATH = File.dirname(__FILE__)
CORDOVA_PATH = "#{ROOT_PATH}/cordova"
Expand All @@ -46,17 +47,6 @@ TESTFAIRY_PLUGIN_NAME = "com.testfairy.cordova-plugin"
SPLUNKMINT_PLUGIN_URL = "https://github.com/crossroads/cordova-plugin-splunkmint.git"
KEYSTORE_FILE = "#{CORDOVA_PATH}/goodcity.keystore"
BUILD_JSON_FILE = "#{CORDOVA_PATH}/build.json"
IOS_SIGNING_STYLE = false
IOS_DEBUGMODE_BUILDCONF = {
code_signing: "\'iPhone Developer\'",
package_type: 'development',
icloud_container_environment: 'Development'
}.freeze
IOS_RELEASEMODE_BUILDCONF = {
code_signing: "\'iPhone Distribution\'",
package_type: 'app-store',
icloud_container_environment: 'Production'
}.freeze

# Default task
task default: %w(app:build)
Expand Down Expand Up @@ -109,6 +99,12 @@ namespace :cordova do
desc "Cordova build {platform}"
task build: :prepare do
Dir.chdir(CORDOVA_PATH) do
#Temporary fix for phonegap-plugin-push
if platform == 'android'
sh %{ cordova plugin add [email protected] }
else
sh %{ cordova plugin add [email protected] --variable SENDER_ID="XXXXXXX" }
end
build = (environment == "staging" && platform == 'android') ? "debug" : "release"
extra_params = (platform === "android") ? '' : ios_build_config
system({"ENVIRONMENT" => environment}, "cordova compile #{platform} --#{build} --device #{extra_params}")
Expand Down Expand Up @@ -244,23 +240,45 @@ def app_version
end
end

def ios_build_config
signing_style = IOS_SIGNING_STYLE
team_id = ENV['IOS_DEVELOPMENT_TEAM_ID']
def mobile_provisioning_file
prefix = ['~', 'Library', 'MobileDevice', 'Provisioning\ Profiles']
file = if production_env?
"GoodCity_Admin.mobileprovision"
else
"GoodCity_Admin_Staging.mobileprovision"
end
File.join(prefix, file)
end

if(environment === 'production')
provisioning_profile = ENV['PROVISIONING_PROFILE_ADMIN_PROD']
code_signing = IOS_RELEASEMODE_BUILDCONF[:code_signing]
package_type = IOS_RELEASEMODE_BUILDCONF[:package_type]
icloud_container_environment = IOS_RELEASEMODE_BUILDCONF[:icloud_container_environment]
def mobile_provisioning_plist
@mobile_provisioning_plist ||= begin
profile = `openssl smime -inform der -verify -noverify -in #{mobile_provisioning_file}`
Plist.parse_xml(profile)
end
end

def ios_build_config
opts = {}
opts["developmentTeam"] = mobile_provisioning_plist["TeamIdentifier"].first
opts["automaticProvisionin"] = false
opts["provisioningProfile"] = mobile_provisioning_plist["UUID"]
if production_env?
opts["codeSignIdentity"] = "\'iPhone Distribution\'"
opts["packageType"] = "app-store"
opts["icloud_container_environment"] = "Production"
else
provisioning_profile = ENV['PROVISIONING_PROFILE_ADMIN_STAGING']
code_signing = IOS_DEBUGMODE_BUILDCONF[:code_signing]
package_type = IOS_DEBUGMODE_BUILDCONF[:package_type]
icloud_container_environment = IOS_DEBUGMODE_BUILDCONF[:icloud_container_environment]
opts["codeSignIdentity"] = "\'iPhone Developer\'"
opts["packageType"] = 'development'
opts["icloud_container_environment"] = "Development"
end
opts.map do |key, value|
"--#{key}=#{value}"
end.join(" ")
#" --codeSignIdentity=#{code_signing} --developmentTeam=#{team_id} --packageType=#{package_type} --provisioningProfile=\'#{provisioning_profile}\' --automaticProvisionin=#{signing_style} --icloud_container_environment=#{icloud_container_environment}"
end

" --codeSignIdentity=#{code_signing} --developmentTeam=#{team_id} --packageType=#{package_type} --provisioningProfile=\'#{provisioning_profile}\' --automaticProvisionin=#{signing_style} --icloud_container_environment=#{icloud_container_environment}"
def production_env?
environment == 'production'
end

def testfairy_upload_script
Expand Down
49 changes: 40 additions & 9 deletions app/components/inventory-number-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,58 @@ import AjaxPromise from '../utils/ajax-promise';
const { getOwner } = Ember;

export default Ember.Component.extend({

i18n: Ember.inject.service(),
attributeBindings: ["name", "inputId", "value", "invalid", "disabled", "packageId"],
isCordovaApp: config.cordova.enabled,
messageBox: Ember.inject.service(),
showMenu: false,
bardcodeReadonly: true,

checkPermissionAndScan() {
let _this = this;
let permissions = cordova.plugins.permissions;
let permissionError = () => {
let error_message = this.get("i18n").t("camera_scan.permission_error");
_this.get("messageBox").alert(error_message);
};
let permissionSuccess = (status) => {
//after requesting check for permission then, permit to scan
if( status.hasPermission ) {
_this.scan();
} else {
permissionError();
}
};
permissions.hasPermission(permissions.CAMERA, function( status ){
//check permission here
if ( status.hasPermission ) {
_this.scan();
}
else {
//request permission here
permissions.requestPermission(permissions.CAMERA, permissionSuccess, permissionError);
}
});
},

scan() {
let options = {"formats": "CODE_128"};
let onError = error => this.get("messageBox").alert("Scanning failed: " + error);
let onSuccess = res => {
if (!res.cancelled) {
this.set("value", res.text);
}
};
cordova.plugins.barcodeScanner.scan(onSuccess, onError, options);
},

actions: {
toggleMenu() {
this.toggleProperty("showMenu");
},

scanBarcode() {
var onSuccess = res => {
if (!res.cancelled) {
this.set("value", res.text);
}
};
var onError = error => this.get("messageBox").alert("Scanning failed: " + error);
var options = {"formats": "CODE_128"};
cordova.plugins.barcodeScanner.scan(onSuccess, onError, options);
this.checkPermissionAndScan();
},

printBarcode() {
Expand Down
5 changes: 4 additions & 1 deletion app/locales/en/translations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ I18nTranslationsEn =
"users":
"search": "Search User"

"camera_scan":
"permission_error": "Camera permission is not turned on."

"holiday":
"name": "Holiday Name"
"date": "Date"
Expand Down Expand Up @@ -164,7 +167,7 @@ I18nTranslationsEn =
"message_donor": "Message Donor"
"finish_review_request": "Please finish reviewing items first!"
"accepted_items": "Accepted Items"
"gogovan_requirement": "Gogovan Reqirement"
"gogovan_requirement": "Gogovan Requirement"
"crossroads_requirement": "Crossroads Requirement"
"complete_review": "Complete Review"
"ggv_hire": "Gogovan Hire Requirement"
Expand Down
3 changes: 3 additions & 0 deletions app/locales/zh-tw/translations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ I18nTranslationsZhTw =
"users":
"search": "搜尋使用者"

"camera_scan":
"permission_error": "Camera permission is not turned on."

"holiday":
"name": "假期名稱"
"date": "日期"
Expand Down
3 changes: 2 additions & 1 deletion cordova/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<engine name="android" spec="~6.3.0" />
<engine name="windows" spec="~4.3.1" />
<plugin name="cordova-plugin-statusbar" spec="~2.1.1" />
<plugin name="phonegap-plugin-push" spec="~2.1.2"/>
<plugin name="cordova-plugin-device" spec="^1.1.1" />
<plugin name="cordova-plugin-android-permissions" spec="https://github.com/NeoLSN/cordova-plugin-android-permissions" />
<plugin name="cordova-plugin-whitelist" spec="~1.2.1" />
<plugin name="cordova-plugin-inappbrowser" spec="~1.2.0" />
<plugin name="cordova-plugin-network-information" spec="^1.2.0" />
Expand All @@ -95,3 +95,4 @@
<plugin name="cordova-plugin-ios-no-export-compliance" spec="https://github.com/mikaoelitiana/cordova-plugin-ios-no-export-compliance.git" />
<plugin name="com.phonegap.plugins.twilioclient" spec="https://github.com/crossroads/twilio_client_phonegap.git" />
</widget>

4 changes: 2 additions & 2 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module.exports = function(defaults) {
},
minifyJS: {
options: {
exclude: ["**/goodcity.js"]
exclude: ["**/*.js"]
}
},
fingerprint: {
extensions: ['css', 'png', 'jpg', 'gif', 'map'],
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'],
enabled: webRelease
},
gzip: {
Expand Down
4 changes: 2 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ platform :ios do
desc "Generate staging build (just upload to TestFairy)"
lane :staging do
raise_if_no_env_var(["FL_TESTFAIRY_API_KEY"])
testfairy
testfairy(auto_update: 'on')
end

desc "Upload to TestFlight"
Expand Down Expand Up @@ -72,7 +72,7 @@ platform :android do
desc "Generate staging build (just upload to TestFairy)"
lane :staging do
raise_if_no_env_var(["FL_TESTFAIRY_API_KEY", "TESTFAIRY_IPA_PATH"])
testfairy
testfairy(auto_update: 'on')
end

desc "Upload to GooglePlay beta track"
Expand Down
Loading

0 comments on commit 37cd51d

Please sign in to comment.