Skip to content

Commit

Permalink
BW-654 #comment resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendraashutec committed Sep 11, 2019
1 parent ef67dfd commit 0e125d5
Show file tree
Hide file tree
Showing 32 changed files with 333 additions and 245 deletions.
46 changes: 20 additions & 26 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const buildApps = `ng build trivia --configuration=productVariant-env &&
ng run trivia:server`;
const compileFunctions = `npx rimraf functions/server && npx tsc --project functions`;
const buildSSRServer = `npx webpack --config webpack.server.config.js`;
const deployFunctionsCommand = `${compileFunctions} &&
const deployFunctionsCommand = ` ${buildApps} &&
${compileFunctions} &&
${buildSSRServer} &&
setConfig
npx rimraf functions/index.js &&
Expand Down Expand Up @@ -195,7 +196,9 @@ const commandList = {
"preCommand": async (argv) => { await updateAppVersion(argv, false); await updatePackageJson(argv); }
},
"release-mobile": {
"command": `tns buildCmd platformName --bundle
"command": `npx rimraf platforms/platformName &&
tns platform add platformName &&
tns build platformName --bundle
environment
--env.aot --env.uglify
forDevice
Expand Down Expand Up @@ -248,12 +251,6 @@ const commandList = {
"type": 'string',
"alias": ['VN', 'vn']
},
"token": {
"demand": true,
"description": 'token from schedular token ',
"type": 'string',
"alias": ['T', 't']
},
"androidRelease": {
"demand": false,
"hidden": true
Expand All @@ -273,11 +270,6 @@ const commandList = {
"description": 'key store alias password',
"type": 'string'
},
"buildCmd": {
"demand": false,
"type": 'string',
"hidden": true
},
"forDevice": {
"demand": false,
"hidden": true
Expand All @@ -292,7 +284,6 @@ const commandList = {
const keyStoreAliasPassword = args.argv.keyStoreAliasPassword;
args.options(
{
'buildCmd': { 'default': 'build' },
'forDevice': { 'default': '' }
}
);
Expand All @@ -303,7 +294,7 @@ const commandList = {
--key-store-alias-password ${keyStoreAliasPassword}
--copy-to ${productVariant}.apk`;
} else {
args.options({ 'buildCmd': { 'default': 'prepare' }, 'forDevice': { 'default': '--for-device' } });
args.options({ 'forDevice': { 'default': '--for-device' } });
args.argv.androidRelease = '';
}
},
Expand Down Expand Up @@ -397,17 +388,20 @@ async function updateAppVersion(argv, isRelease) {
fs.writeFileSync(filepath, buffer, options);

const config = getConfig(argv.productVariant);
if (isRelease) {
await axios({
method: 'post',
url: `${config.functionsUrl[environment]}/general/updateAppVersion`,
headers: { 'token': argv.token, 'Content-Type': 'application/json' },
data: {
'versionCode': argv.versionCode,
'platform': platform
}
});
}

// we need to make a seperate command to update version in firebase after uploading to appstore/playstore

// if (isRelease) {
// await axios({
// method: 'post',
// url: `${config.functionsUrl[environment]}/general/updateAppVersion`,
// headers: { 'token': argv.token, 'Content-Type': 'application/json' },
// data: {
// 'versionCode': argv.versionCode,
// 'platform': platform
// }
// });
// }


} catch (error) {
Expand Down
3 changes: 1 addition & 2 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ Commands :
description: release android app for staging/production environment
e.g. : node cli release-mobile --pv trivia --pk io.bitwiser.trivia.dev --plt android --e dev
--keyStorePassword <keyStorePassword> --keyStoreAlias <keyStoreAlias> --keyStoreAliasPassword <keyStoreAliasPassword>
--t <token> --v 28 --vn 1.1
--v 28 --vn 1.1
arguments : pv = productVarient e.g. trivia
pk = project package name defined in firebase e.g. io.bitwiser.trivia.dev
plt = Mobile platform e.g. android
e = project environment
keyStorePassword = keyStorePassword for android(optional)
keyStoreAlias = key store store alias for android(optional)
keyStoreAliasPassword = key store alias password for android(optional)
token = token from schedular token
v = versionCode for android/ios build
vn = versionName for android build CFBundleShortVersionString for ios

Expand Down
4 changes: 2 additions & 2 deletions deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ How to deploy Android app on Google play store?

Dev Env : node cli release-mobile --pv trivia --pk io.bitwiser.trivia.dev --plt android --e staging
--keyStorePassword <keyStorePassword> --keyStoreAlias <keyStoreAlias> --keyStoreAliasPassword <keyStoreAliasPassword> --v <versionCode>
--t <token> --vn <versionName>
--vn <versionName>
Prod Env : node cli release-mobile --pv trivia --pk io.bitwiser.trivia --plt android --e production
--keyStorePassword <keyStorePassword> --keyStoreAlias <keyStoreAlias> --keyStoreAliasPassword <keyStoreAliasPassword> --v <versionCode>
--t <token> --vn <versionName>
--vn <versionName>

4) Deploy App on Google play store:

Expand Down
7 changes: 0 additions & 7 deletions functions/controllers/friend.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FriendConstants, interceptorConstants, ResponseMessagesConstants, User } from '../../projects/shared-library/src/lib/shared/model';
import { MakeFriends } from '../utils/make-friends';
import { Utils } from '../utils/utils';
import { AccountService } from '../services/account.service';
import { AppSettings } from '../services/app-settings.service';

export class FriendController {

Expand All @@ -15,14 +13,9 @@ export class FriendController {
const token = req.body.token;
const userId = req.body.userId;
const email = req.body.email;

try {
const makeFriends: MakeFriends = new MakeFriends(token, userId, email);
const appSetting = await AppSettings.Instance.getAppSettings();
const invitee = await makeFriends.validateToken();
if (appSetting.invite_bits_enabled) {
await AccountService.updateBits(userId, appSetting.invite_bits);
}
Utils.sendResponse(res, interceptorConstants.SUCCESS, { created_uid: invitee });
} catch (error) {
Utils.sendError(res, error);
Expand Down
6 changes: 5 additions & 1 deletion functions/db/firebase.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';


class FirebaseClient {

public admin: any;

constructor() {
this.admin = admin.initializeApp(functions.config().firebase);
// There is bug with firebase-function in production not in function emulator
// behavior keep changing version over version
// https://github.com/firebase/firebase-functions/issues/311
this.admin = admin.initializeApp(functions.config().firebase);
}
}

Expand Down
8 changes: 6 additions & 2 deletions functions/utils/make-friends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from '../../projects/shared-library/src/lib/shared/model';
import { PushNotification } from './push-notifications';
import { Utils } from './utils';

import { AppSettings } from '../services/app-settings.service';
import { AccountService } from '../services/account.service';

export class MakeFriends {

Expand All @@ -23,12 +24,15 @@ export class MakeFriends {
async validateToken(): Promise<string> {
try {
const invitationObj: Invitation = await FriendService.getInvitationByToken(this.token);

const appSetting = await AppSettings.Instance.getAppSettings();
if (invitationObj.email === this.email) {
invitationObj.status = friendInvitationConstants.APPROVED;
await this.updateFriendsList(invitationObj.created_uid, this.userId);
await this.updateFriendsList(this.userId, invitationObj.created_uid);
await FriendService.updateInvitation({ ...invitationObj });
if (appSetting.invite_bits_enabled) {
await AccountService.updateBits(invitationObj.created_uid, appSetting.invite_bits);
}
return this.userId;
}
} catch (error) {
Expand Down
10 changes: 7 additions & 3 deletions hooks/after-prepare/firebase-copy-google-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ module.exports = function($logger, $projectData, hookArgs) {

return new Promise(function(resolve, reject) {

/* Decide whether to prepare for dev or prod environment */
var isReleaseBuild = (hookArgs.appFilesUpdaterOptions || hookArgs.prepareData).release;
/* do not add this line we do not use --release to decide release environment */
// var isReleaseBuild = (hookArgs.appFilesUpdaterOptions || hookArgs.prepareData).release;
/* Decide whether to prepare for dev or prod environment */
var validProdEnvs = ['prod','production'];
var isProdEnv = false; // building with --env.prod or --env.production flag
var env = (hookArgs.platformSpecificData || hookArgs.prepareData).env;
Expand All @@ -17,7 +18,10 @@ return new Promise(function(resolve, reject) {
});
}

var buildType = isReleaseBuild || isProdEnv ? 'production' : 'development';
/* do not change this line
we use --env.prod to decide release environment
we do not use --release to decide release environment */
var buildType = isProdEnv ? 'production' : 'development';
const platformFromHookArgs = hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform));
const platform = (platformFromHookArgs || '').toLowerCase();

Expand Down
91 changes: 91 additions & 0 deletions hooks/before-checkForChanges/firebase-copy-google-services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

var path = require("path");
var fs = require("fs");

module.exports = function($logger, hookArgs) {
return new Promise(function(resolve, reject) {

/* do not add this line we do not use --release to decide release environment */
// var isReleaseBuild = !!((hookArgs.checkForChangesOpts && hookArgs.checkForChangesOpts.projectChangesOptions) || hookArgs.prepareData).release;
/* Decide whether to prepare for dev or prod environment */
var validProdEnvs = ['prod','production'];
var isProdEnv = false; // building with --env.prod or --env.production flag

var env = ((hookArgs.checkForChangesOpts && hookArgs.checkForChangesOpts.projectData && hookArgs.checkForChangesOpts.projectData.$options && hookArgs.checkForChangesOpts.projectData.$options.argv) || hookArgs.prepareData).env;
if (env) {
Object.keys(env).forEach((key) => {
if (validProdEnvs.indexOf(key)>-1) { isProdEnv=true; }
});
}


// do not change this line
// we use --env.prod to decide release environment
// we do not use --release to decide release environment
var buildType = isProdEnv ? 'production' : 'development';

/*
Detect if we have nativescript-plugin-firebase temp file created during after-prepare hook, so we know
for which environment {development|prod} the project was prepared. If needed, we delete the NS .nsprepareinfo
file so we force a new prepare
*/
var platform = (hookArgs.checkForChangesOpts || hookArgs.prepareData).platform.toLowerCase();
var projectData = (hookArgs.checkForChangesOpts && hookArgs.checkForChangesOpts.projectData) || hookArgs.projectData;
var platformsDir = projectData.platformsDir;
var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath;
var forcePrepare = true; // whether to force NS to run prepare, defaults to true
var npfInfoPath = path.join(platformsDir, platform, ".pluginfirebaseinfo");
var nsPrepareInfoPath = path.join(platformsDir, platform, ".nsprepareinfo");
var copyPlistOpts = { platform, appResourcesDirectoryPath, buildType, $logger }

if (fs.existsSync(npfInfoPath)) {
var npfInfo = undefined;
try { npfInfo = JSON.parse(fs.readFileSync(npfInfoPath, 'utf8')); }
catch (e) { $logger.info('nativescript-plugin-firebase: error reading '+npfInfoPath); }

if (npfInfo && npfInfo.hasOwnProperty('buildType') && npfInfo.buildType===buildType) {
$logger.info('nativescript-plugin-firebase: building for same environment, not forcing prepare.');
forcePrepare=false;
}
} else { $logger.info('nativescript-plugin-firebase: '+npfInfoPath+' not found, forcing prepare!'); }

if (forcePrepare) {
$logger.info('nativescript-plugin-firebase: running release build or change in environment detected, forcing prepare!');

if (fs.existsSync(npfInfoPath)) { fs.unlinkSync(npfInfoPath); }
if (fs.existsSync(nsPrepareInfoPath)) { fs.unlinkSync(nsPrepareInfoPath); }

if (copyPlist(copyPlistOpts)) { resolve(); } else { reject(); }
} else { resolve(); }
});
};

/*
Handle preparing of Google Services files for iOS
*/
var copyPlist = function(copyPlistOpts) {
if (copyPlistOpts.platform === 'android') { return true; }
else if (copyPlistOpts.platform === 'ios') {
var sourceGooglePlistProd = path.join(copyPlistOpts.appResourcesDirectoryPath, "iOS", "GoogleService-Info.plist.prod");
var sourceGooglePlistDev = path.join(copyPlistOpts.appResourcesDirectoryPath, "iOS", "GoogleService-Info.plist.dev");
var destinationGooglePlist = path.join(copyPlistOpts.appResourcesDirectoryPath, "iOS", "GoogleService-Info.plist");

// if we have both dev/prod versions, we copy (or overwrite) GoogleService-Info.plist in destination dir
if (fs.existsSync(sourceGooglePlistProd) && fs.existsSync(sourceGooglePlistDev)) {
if (copyPlistOpts.buildType==='production') { // use prod version
copyPlistOpts.$logger.info("nativescript-plugin-firebase: copy " + sourceGooglePlistProd + " to " + destinationGooglePlist + ".");
fs.writeFileSync(destinationGooglePlist, fs.readFileSync(sourceGooglePlistProd));
return true;
} else { // use dev version
copyPlistOpts.$logger.info("nativescript-plugin-firebase: copy " + sourceGooglePlistDev + " to " + destinationGooglePlist + ".");
fs.writeFileSync(destinationGooglePlist, fs.readFileSync(sourceGooglePlistDev));
return true;
}
} else if (!fs.existsSync(destinationGooglePlist)) { // single GoogleService-Info.plist modus but missing
copyPlistOpts.$logger.warn("nativescript-plugin-firebase: " + destinationGooglePlist + " does not exist. Please follow the installation instructions from the documentation");
return false;
} else {
return true; // single GoogleService-Info.plist modus
}
} else { return true; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const CONFIG: IConfig = {
messagingSenderId: '704157888306'
},
'functionsUrl': `https://bitwiser-edu.firebaseapp.com/${appConstants.API_VERSION}`,
'editorUrl': 'https://bitwiser-edu.firebaseapp.com/trivia-editor',
'editorUrl': 'https://bitwiser-edu.firebaseapp.com/editor',
'termsAndConditionsUrl': 'https://bitwiser-edu.firebaseapp.com/terms-and-conditions',
'privacyUrl': 'https://bitwiser-edu.firebaseapp.com/privacy-policy',
'ua_id': 'UA-122807814-1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const CONFIG: IConfig = {
messagingSenderId: '701588063269'
},
'functionsUrl': `https://rwa-trivia-dev-e57fc.firebaseapp.com/${appConstants.API_VERSION}`,
'editorUrl': 'https://rwa-trivia-dev-e57fc.firebaseapp.com/trivia-editor',
'editorUrl': 'https://rwa-trivia-dev-e57fc.firebaseapp.com/editor',
'termsAndConditionsUrl': 'https://bitwiser.io/terms-and-conditions',
'privacyUrl': 'https://bitwiser.io/privacy-policy',
'ua_id': 'UA-122807814-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const CONFIG: IConfig = {
messagingSenderId: '479350787602'
},
'functionsUrl': `https://bitwiser.io`,
'editorUrl': 'https://bitwiser.io/trivia-editor',
'editorUrl': 'https://bitwiser.io/editor',
'termsAndConditionsUrl': 'https://bitwiser.io/terms-and-conditions',
'privacyUrl': 'https://bitwiser.io/privacy-policy',
'ua_id': 'UA-122807814-1'
Expand Down
7 changes: 7 additions & 0 deletions projects/shared-library/src/lib/shared/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ import { RenderAnswerComponent } from './render-answer/render-answer.component';
import { CropImageDialogComponent } from './crop-image-dialog/crop-image-dialog.component';
import { UserReactionComponent } from './user-reaction/user-reaction.component';
import { UserCardComponent } from './user-card/user-card.component';
<<<<<<< HEAD
import { SignupExtraInfoComponent } from './signup-extra-info/signup-extra-info.component';
import { CheckDisplayNameComponent } from './check-display-name/check-display-name.component';
import { FriendInviteComponent } from './friend-invite/friend-invite.component';
import { GameInviteComponent } from './game-invite/game-invite.component';
=======
import { FriendInviteComponent } from './friend-invite/friend-invite.component';
import { GameInviteComponent } from './game-invite/game-invite.component';
import { SignupExtraInfoComponent } from './signup-extra-info/signup-extra-info.component';
import { CheckDisplayNameComponent } from './check-display-name/check-display-name.component';
>>>>>>> 6ead799eabdf50645b3df387d830f0d09e4a9f10
import { InviteMailFriendsComponent } from './invite-mail-friends/invite-mail-friends.component';
export {
QuestionsSearchComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<span *ngIf="showSuccessMsg" class="success row col-sm-12" [innerHtml]="showSuccessMsg"></span>
</form>
</div>
<div class="mail-option-div">
<div *ngIf="applicationSettings?.invite_bits_enabled && applicationSettings?.invite_bits > 0" class="addBits">
Earn + {{applicationSettings?.invite_bits}} bits
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ input[type="text"]{
{
font-size: 16px;
}



.addBits {
margin: 15px;
font-size: 18px;
font-family: "hindmedium";
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
<label row="0" col="1" (tap)="onSubscribe()" class="send-invite-button Hind-Bold" text="Send Invite"
stlRippleEffect></label>
</GridLayout>
<Label margin="0 10 0 10"
*ngIf="applicationSettings?.invite_bits_enabled && applicationSettings?.invite_bits > 0"
text="Earn + {{applicationSettings?.invite_bits}} bits" textWrap="true"></Label>
<StackLayout marginTop="10" marginBottom="20">
<Label class="error-msg" text="Email is required!" textWrap="true"
*ngIf="invitationForm.controls.email.invalid && emailCheck"></Label>
<StackLayout *ngIf="showErrorMsg">
<Label class="error-msg" [text]="errorMsg" textWrap="true"></Label>
<Label class="error-msg" [text]="invalidEmailList" textWrap="true"></Label>
</StackLayout>
<Label class="success-msg" [text]="showSuccessMsg" textWrap="true" *ngIf="showSuccessMsg"></Label>
</StackLayout>
</StackLayout>
</PreviousNextView>
Expand Down
Loading

0 comments on commit 0e125d5

Please sign in to comment.