Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 7 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Integration Tests

## Heroku Test App
https://dashboard.heroku.com/apps/medimodo

### Logs
https://dashboard.heroku.com/apps/medimodo/resources
124 changes: 20 additions & 104 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
/* eslint-disable no-process-env,semi,space-infix-ops,block-spacing,object-shorthand,no-unused-vars,one-var */

/* eslint-disable no-process-env,object-shorthand,semi,block-spacing,comma-dangle,one-var,space-infix-ops,no-unused-vars,no-multi-spaces,no-useless-concat,no-empty */
const {missingRequiredParameter} = require("./ts/qm.log");
const {readJsonFile} = require("./ts/qm.file-helper");
const {loadEnv} = require("./ts/env-helper");
const {envs} = require("./ts/env-helper");
const {paths} = require("./ts/env-helper");
const {qmPlatform} = require("./ts/env-helper");
const {getenvOrException} = require("./ts/env-helper");
var qmLog = require("./ts/qm.log");
var pump = require('pump');
const {getQMClientIdOrException} = require("./ts/env-helper")

try {
var dotenv = require('dotenv')
dotenv.config({path: './secrets/.env'});

} catch (e) {
console.error(e);
qmLog.info(e.message);
}
var QUANTIMODO_CLIENT_ID = process.env.QUANTIMODO_CLIENT_ID || process.env.CLIENT_ID;
var QUANTIMODO_CLIENT_ID = getQMClientIdOrException()
var devCredentials;
var androidArm7DebugApkName = 'android-armv7-debug';
var androidX86DebugApkName = 'android-x86-debug';
Expand All @@ -19,66 +32,6 @@ function isTruthy(value) {return (value && value !== "false");}
var buildPath = 'build';
var circleCIPathToRepo = '~/quantimodo-android-chrome-ios-web-app';
var chromeExtensionBuildPath = buildPath + '/chrome_extension';
var qmPlatform = {
buildingFor: {
getPlatformBuildingFor: function(){
if(qmPlatform.buildingFor.android()){return 'android';}
if(qmPlatform.buildingFor.ios()){return 'ios';}
if(qmPlatform.buildingFor.chrome()){return 'chrome';}
if(qmPlatform.buildingFor.web()){return 'web';}
qmLog.error("What platform are we building for?");
return null;
},
setChrome: function(){
qmPlatform.buildingFor.platform = qmPlatform.chrome;
},
platform: null,
web: function () {
return !qmPlatform.buildingFor.android() && !qmPlatform.buildingFor.ios() && !qmPlatform.buildingFor.chrome();
},
android: function () {
if (qmPlatform.buildingFor.platform === 'android'){ return true; }
if (process.env.BUDDYBUILD_SECURE_FILES) { return true; }
if (process.env.TRAVIS_OS_NAME === "osx") { return false; }
return process.env.BUILD_ANDROID;
},
ios: function () {
if (qmPlatform.buildingFor.platform === qmPlatform.ios){ return true; }
if (process.env.BUDDYBUILD_SCHEME) {return true;}
if (process.env.TRAVIS_OS_NAME === "osx") { return true; }
return process.env.BUILD_IOS;
},
chrome: function () {
if (qmPlatform.buildingFor.platform === qmPlatform.chrome){ return true; }
return process.env.BUILD_CHROME;
},
mobile: function () {
return qmPlatform.buildingFor.android() || qmPlatform.buildingFor.ios();
}
},
setBuildingFor: function(platform){
qmPlatform.buildingFor.platform = platform;
},
isOSX: function(){
return process.platform === 'darwin';
},
isLinux: function(){
return process.platform === 'linux';
},
isWindows: function(){
return !qmPlatform.isOSX() && !qmPlatform.isLinux();
},
getPlatform: function(){
if(qmPlatform.buildingFor){return qmPlatform.buildingFor;}
if(qmPlatform.isOSX()){return qmPlatform.ios;}
if(qmPlatform.isWindows()){return qmPlatform.android;}
return qmPlatform.web;
},
ios: 'ios',
android: 'android',
web: 'web',
chrome: 'chrome'
};
// Setup platforms to build that are supported on current hardware
// See https://taco.visualstudio.com/en-us/docs/tutorial-gulp-readme/
//var winPlatforms = ["android", "windows"], //Android is having problems so I'm only building windows for now
Expand Down Expand Up @@ -117,36 +70,6 @@ var appIds = {
'quantimodo': true,
'medimodo': true
};
var paths = {
apk: {//android\app\build\outputs\apk\release\app-release.apk
combinedRelease: "platforms/android/app/build/outputs/apk/release/app-release.apk",
combinedDebug: "platforms/android/app/build/outputs/apk/release/app-debug.apk",
arm7Release: "platforms/android/app/build/outputs/apk/release/app-arm7-release.apk",
x86Release: "platforms/android/app/build/outputs/apk/release/app-x86-release.apk",
outputFolder: "platforms/android/app/build/outputs/apk",
builtApk: null,
},
sass: ['./src/scss/**/*.scss'],
src:{
devCredentials: "src/dev-credentials.json",
defaultPrivateConfig: "src/default.private_config.json",
icons: "src/img/icons",
firebase: "src/lib/firebase/**/*",
js: "src/js/*.js",
serviceWorker: "src/firebase-messaging-sw.js",
staticData: 'src/data/qmStaticData.js',
},
www: {
devCredentials: "www/dev-credentials.json",
defaultPrivateConfig: "www/default.private_config.json",
icons: "www/img/icons",
firebase: "www/lib/firebase/",
js: "www/js/",
scripts: "www/scripts",
staticData: 'src/data/qmStaticData.js',
},
chcpLogin: '.chcplogin',
};
var argv = require('yargs').argv;
var defaultRequestOptions = {strictSSL: false};
var fs = require('fs');
Expand Down Expand Up @@ -565,7 +488,7 @@ var qmGulp = {
return qmGulp.buildInfoHelper.currentBuildInfo;
},
getPreviousBuildInfo: function () {
var previousBuildInfo = readFile(paths.src.buildInfo);
var previousBuildInfo = readJsonFile(paths.src.buildInfo);
if(!previousBuildInfo){
qmLog.info("No previous BuildInfo file at "+paths.src.buildInfo);
qmGulp.buildInfoHelper.previousBuildInfo = false;
Expand Down Expand Up @@ -754,7 +677,7 @@ var qmGulp = {
}
};
qmGulp.buildInfoHelper.setVersionNumbers();
var Quantimodo = require('quantimodo');
var Quantimodo = require('./plain-javascript-client/index.js');
/** @namespace Quantimodo.ApiClient */
var defaultClient = Quantimodo.ApiClient.instance;
var quantimodo_oauth2 = defaultClient.authentications.quantimodo_oauth2;
Expand Down Expand Up @@ -803,21 +726,14 @@ function getPathToChromeExtensionZip() {return buildPath + '/' + getChromeExtens
function getPathToUnzippedChromeExtension() {return buildPath + '/' + QUANTIMODO_CLIENT_ID + '-chrome-extension';}
function readDevCredentials(){
try{
devCredentials = JSON.parse(fs.readFileSync(paths.src.devCredentials));
devCredentials = readJsonFile(paths.src.devCredentials);
qmLog.info("Using dev credentials from " + paths.src.devCredentials + ". This file is ignored in .gitignore and should never be committed to any repository.");
} catch (error){
qmLog.debug('No existing dev credentials found');
devCredentials = {};
}
}
function readFile(path){
try {
return JSON.parse(fs.readFileSync(path));
} catch (e) {
qmLog.error("Could not read "+path);
return false;
}
}

function outputFileContents(path){
qmLog.info(path+": "+fs.readFileSync(path));
}
Expand Down
50 changes: 50 additions & 0 deletions ts/cypress-runner.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added ts/cypress-runner.js.map
Empty file.
Empty file added ts/env-helper.js
Empty file.
1 change: 1 addition & 0 deletions ts/env-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export let paths = {
chcpLogin: ".chcplogin",
sass: ["./src/scss/**/*.scss"],
src: {
buildInfo: "src/data/build-info.json",
defaultPrivateConfig: "src/default.private_config.json",
devCredentials: "src/dev-credentials.json",
firebase: "src/lib/firebase/**/*",
Expand Down
Empty file added ts/qm.file-helper.js
Empty file.
11 changes: 11 additions & 0 deletions ts/qm.file-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Q from "q"
import rimraf from "rimraf"
import {envs, getenvOrException} from "./env-helper"
import * as qmLog from "./qm.log"
import {missingRequiredParameter} from "./qm.log"
const defaultS3Bucket = "qmimages"
// tslint:disable-next-line:no-var-requires
const appRoot = require("app-root-path")
Expand Down Expand Up @@ -237,3 +238,13 @@ export function listFilesRecursively(dir: string) {
})
return deferred.promise
}

export function readJsonFile(jsonPath: string ) {
try {
const content = fs.readFileSync(jsonPath).toString()
return JSON.parse(content)
} catch (e) {
qmLog.error("Could not read "+jsonPath)
return false
}
}
Empty file added ts/qm.log.js
Empty file.
Empty file added ts/qm.log.js.map
Empty file.