@@ -134,7 +134,7 @@ var paths = {
134134 firebase : "src/lib/firebase/**/*" ,
135135 js : "src/js/*.js" ,
136136 serviceWorker : "src/firebase-messaging-sw.js" ,
137- staticData : ' src/data/qmStaticData.js' ,
137+ data : " src/data" ,
138138 } ,
139139 www : {
140140 devCredentials : "www/dev-credentials.json" ,
@@ -143,7 +143,7 @@ var paths = {
143143 firebase : "www/lib/firebase/" ,
144144 js : "www/js/" ,
145145 scripts : "www/scripts" ,
146- staticData : 'src /data/qmStaticData.js' ,
146+ data : "www /data" ,
147147 } ,
148148 chcpLogin : '.chcplogin' ,
149149} ;
@@ -1100,6 +1100,8 @@ function postAppStatus() {
11001100 return makeApiRequest ( options ) ;
11011101}
11021102function makeApiRequest ( options , successHandler ) {
1103+ options . headers . XDEBUG_SESSION_START = "PHPSTORM" ;
1104+ options . qs . XDEBUG_SESSION_START = "PHPSTORM" ;
11031105 var rp = require ( 'request-promise' ) ;
11041106 qmLog . info ( 'Making request to ' + options . uri + ' with clientId: ' + QUANTIMODO_CLIENT_ID ) ;
11051107 qmLog . debug ( options . uri , options , 280 ) ;
@@ -1128,9 +1130,13 @@ function postNotifyCollaborators(appType) {
11281130function getRequestOptions ( path ) {
11291131 var options = {
11301132 uri : qmGulp . getAppHostName ( ) + path ,
1131- qs : { clientId : QUANTIMODO_CLIENT_ID , includeClientSecret : true , allStaticAppData : true } ,
1133+ qs : {
1134+ clientId : QUANTIMODO_CLIENT_ID ,
1135+ includeClientSecret : false ,
1136+ allStaticAppData : true ,
1137+ } ,
11321138 headers : { 'User-Agent' : 'Request-Promise' , 'Content-Type' : 'application/json' } ,
1133- json : true // Automatically parses the JSON string in the response
1139+ json : true , // Automatically parses the JSON string in the response
11341140 } ;
11351141 if ( process . env . QUANTIMODO_ACCESS_TOKEN ) {
11361142 options . qs . access_token = process . env . QUANTIMODO_ACCESS_TOKEN ;
@@ -1278,7 +1284,7 @@ function generateConfigXmlFromTemplate(callback) {
12781284 if ( parsedXmlFile . widget . chcp ) { parsedXmlFile . widget . chcp [ 0 ] [ 'config-file' ] = [ { '$' : { "url" : qmGulp . chcp . getChcpJsonUrl ( ) } } ] ; }
12791285 writeToXmlFile ( './config.xml' , parsedXmlFile , callback ) ;
12801286 qmGulp . staticData . configXml = parsedXmlFile ;
1281- writeStaticDataFile ( ) ;
1287+ writeAppSettingsFile ( ) ;
12821288 }
12831289 } ) ;
12841290}
@@ -1401,7 +1407,15 @@ var chromeScripts = [
14011407 'lib/quantimodo/quantimodo-web.js' ,
14021408 'js/qmLogger.js' ,
14031409 'js/qmHelpers.js' ,
1404- 'data/qmStaticData.js' , // Must come after qmHelpers because we assign to qm.staticData
1410+ 'data/appSettings.js' , // Must come after qmHelpers because we assign to qm.staticData
1411+ 'data/qmStates.js' ,
1412+ 'data/stateNames.js' ,
1413+ 'data/buildInfo.js' ,
1414+ 'data/units.js' ,
1415+ 'data/variableCategories.js' ,
1416+ 'data/commonVariables.js' ,
1417+ 'data/docs.js' ,
1418+ 'data/dialogAgent.js' ,
14051419 'lib/underscore/underscore-min.js' ,
14061420] ;
14071421//if(qmGit.accessToken){chromeScripts.push('qm-amazon/qmUrlUpdater.js');}
@@ -1773,26 +1787,46 @@ gulp.task('downloadSwaggerJson', [], function () {
17731787 // .pipe(gulp.dest("src/data/"));
17741788 return getConstantsFromApiAndWriteToJson ( 'docs' , url ) ;
17751789} ) ;
1776- function writeStaticDataFile ( ) {
1790+ function writeBuildInfoFile ( ) {
1791+ var as = qmGulp . buildInfoHelper . getCurrentBuildInfo ( ) ;
1792+ var string =
1793+ 'if(typeof qm === "undefined"){if(typeof window === "undefined") {global.qm = {}; }else{window.qm = {};}}\n' +
1794+ 'if(typeof qm.staticData === "undefined"){qm.staticData = {};}\n' +
1795+ 'qm.staticData.buildInfo =' + qmLog . prettyJSONStringify ( as ) ;
1796+ try {
1797+ writeToFile ( paths . www . data + "/buildInfo.js" , string ) ;
1798+ } catch ( e ) {
1799+ qmLog . error ( e . message + ". Maybe www/data doesn't exist but it might be resolved when we copy from src" ) ;
1800+ }
1801+ try {
1802+ writeToFile ( 'build/chrome_extension/data/buildInfo.js' , string ) ;
1803+ } catch ( e ) {
1804+ qmLog . error ( e . message + ". Maybe build/chrome_extension/data doesn't exist but it might be resolved when we copy from src" ) ;
1805+ }
1806+ return writeToFile ( paths . src . data + "/buildInfo.js" , string ) ;
1807+ }
1808+ function writeAppSettingsFile ( ) {
17771809 qmGulp . staticData . buildInfo = qmGulp . buildInfoHelper . getCurrentBuildInfo ( ) ;
1778- var string = 'var staticData = ' + qmLog . prettyJSONStringify ( qmGulp . staticData ) +
1779- '; if(typeof window !== "undefined"){window.qm.staticData = staticData;} ' +
1780- ' else if(typeof qm !== "undefined"){qm.staticData = staticData;} else {module.exports = staticData;} ' +
1781- 'if(typeof qm !== "undefined"){qm.stateNames = staticData.stateNames;}' ;
1810+ var as = qmGulp . getAppSettings ( ) ;
1811+ var string =
1812+ 'if(typeof qm === "undefined"){if(typeof window === "undefined") {global.qm = {}; }else{window.qm = {};}}\n' +
1813+ 'if(typeof qm.staticData === "undefined"){qm.staticData = {};}\n' +
1814+ 'qm.staticData.appSettings =' + qmLog . prettyJSONStringify ( as ) ;
17821815 try {
1783- writeToFile ( paths . www . staticData , string ) ;
1816+ writeToFile ( paths . www . data + "/appSettings.js" , string ) ;
17841817 } catch ( e ) {
17851818 qmLog . error ( e . message + ". Maybe www/data doesn't exist but it might be resolved when we copy from src" ) ;
17861819 }
17871820 try {
1788- writeToFile ( 'build/chrome_extension/data/qmStaticData .js' , string ) ;
1821+ writeToFile ( 'build/chrome_extension/data/appSettings .js' , string ) ;
17891822 } catch ( e ) {
17901823 qmLog . error ( e . message + ". Maybe build/chrome_extension/data doesn't exist but it might be resolved when we copy from src" ) ;
17911824 }
1792- return writeToFile ( paths . src . staticData , string ) ;
1825+ return writeToFile ( paths . src . data + "/appSettings.js" , string ) ;
17931826}
17941827gulp . task ( 'staticDataFile' , [ 'getAppConfigs' ] , function ( ) {
1795- return writeStaticDataFile ( ) ;
1828+ writeBuildInfoFile ( ) ;
1829+ return writeAppSettingsFile ( ) ;
17961830} ) ;
17971831function getConstantsFromApiAndWriteToJson ( type , urlPath ) {
17981832 var jeditor = require ( 'gulp-json-editor' ) ;
0 commit comments