Skip to content

Commit

Permalink
sync: geovation photos
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianovide committed Jan 4, 2019
1 parent a7296e9 commit 65ece13
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
1 change: 1 addition & 0 deletions cordova-app/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<icon src="res/icon/ios/[email protected]" width="87" />
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
</platform>
<hook src="scripts/changeVersion.js" type="before_prepare" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
Expand Down
6 changes: 6 additions & 0 deletions cordova-app/package-lock.json

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

5 changes: 3 additions & 2 deletions cordova-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"cordova-plugin-whitelist": "^1.3.3"
},
"devDependencies": {
"http-server": "^0.11.1"
"http-server": "^0.11.1",
"xmldom": "^0.1.27"
}
}
}
37 changes: 37 additions & 0 deletions cordova-app/scripts/changeVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = function(ctx) {
var configXmlHelper = require('./configXmlHelper');

var configXml = configXmlHelper.readConfigXML();
var widget = configXml.getElementsByTagName("widget")[0];

var version = widget.getAttribute("version");
var androidVersionCode = widget.getAttribute("android-versionCode");
var iosCFBundleVersion = widget.getAttribute("ios-CFBundleVersion");

var versionSplit = version.split(".");
versionSplit[2] = parseInt(process.env.TRAVIS_BUILD_NUMBER || "0");

var newAndroidVersionCode = versionSplit[0] * 10000000 + versionSplit[1] * 10000 + versionSplit[2];
var newVersion = versionSplit.join(".");
var newIosCFBundleVersion = newVersion;

console.log("Version:", version);
console.log("android-versionCode:", androidVersionCode);
console.log("ios-CFBundleVersion:", iosCFBundleVersion);

widget.setAttribute("version", newVersion);
widget.setAttribute("ios-CFBundleVersion", newIosCFBundleVersion);
widget.setAttribute("android-versionCode", newAndroidVersionCode);

console.log("New Version:", widget.getAttribute("version"));
console.log("New android-versionCode:", widget.getAttribute("android-versionCode"));
console.log("New ios-CFBundleVersion:", widget.getAttribute("ios-CFBundleVersion"));

configXmlHelper.writeConfigXML(configXml);
};

if (!require.main.loaded) {
module.exports({
cmdLine: process.argv.join(" ")
});
}
19 changes: 19 additions & 0 deletions cordova-app/scripts/configXmlHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var filePath = "config.xml";
var xmldom = require('xmldom');
var fs = require('fs');

module.exports = {
readConfigXML: function() {
var DOMParser = xmldom.DOMParser;
var xmlString = fs.readFileSync(filePath, "utf-8");

return new DOMParser().parseFromString(xmlString);
},

writeConfigXML: function (configXml) {
var XMLSerializer = xmldom.XMLSerializer;
var xmlString = new XMLSerializer().serializeToString(configXml);

fs.writeFileSync(filePath, xmlString, 'utf8');
}
};

0 comments on commit 65ece13

Please sign in to comment.