/**
 * Injects values into the placeholders in Cordova config.xml file
 */
'use strict';

const filter = require('gulp-filter');
const lazypipe = require('lazypipe');
const replace = require('gulp-replace');
const size = require('gulp-size');

const DEFAULT_SOURCE = 'index.html';

/**
 * Replaces placeholder in the Cordova's config.xml
 * 
 * @param {Object} options Configuration for the replacement
 * @param {string} options.appId ID under which the app is registered in the app store, e.g. com.company.app
 * @param {string[]} options.versionNumber Version number of the release
 * @param {string} options.source Path of the application, e.g. index.html (or http://localhost:post for iOS)
 */
module.exports = function injectConfig({ appId, versionNumber, source = DEFAULT_SOURCE} = options) {
	// Split version into major/minor/patch, and calculate a version code for android versioning
	const versionTokens = versionNumber.split('.');
	const androidVersionCode = versionTokens[0]*100000 + versionTokens[1]*1000 + versionTokens[2]*10

	const configFilter = filter('config.xml', {restore: true});

	return lazypipe()
		.pipe(() => configFilter)
		.pipe(() => replace('%%GULP.CORDOVA_ID%%', appId))
		.pipe(() => replace('%%GULP.CORDOVA_VERSION%%', versionNumber))
		.pipe(() => replace('%%GULP.CORDOVA_VERSION_ANDROID_VERSION_CODE%%', androidVersionCode))
		.pipe(() => replace('%%GULP.CORDOVA_SOURCE%%', source))
		.pipe(() => replace('%%GULP.CORDOVA_USER_AGENT%%', `${appId}/${versionNumber}`))
		.pipe(() => replace('%%GULP.CORDOVA_ALLOWED_NAV_SOURCE%%', source !== DEFAULT_SOURCE ? source : 'file://'))
		.pipe(() => size({title: 'inject-cordova-config'}))
		.pipe(() => configFilter.restore);
}

@@ -526,10 +526,8 @@
 ring
-%5B%5D
 %7D op
@@ -962,16 +962,23 @@
 nCode = 
+Number(
 versionT
@@ -985,16 +985,17 @@
 okens%5B0%5D
+)
 *100000 
@@ -992,24 +992,31 @@
 %5D)*100000 + 
+Number(
 versionToken
@@ -1023,16 +1023,17 @@
 s%5B1%5D
+)
 *1000 + 
 vers
@@ -1028,16 +1028,23 @@
 *1000 + 
+Number(
 versionT
@@ -1051,19 +1051,21 @@
 okens%5B2%5D
+)
 *10
+;
 %0A%0A%09const
@@ -1357,16 +1357,23 @@
 ODE%25%25', 
+String(
 androidV
@@ -1384,16 +1384,17 @@
 onCode))
+)
 %0A%09%09.pipe

Fix type-related errors