(shouldCopyResources = true)
| 246 | } |
| 247 | |
| 248 | writeConfigXmlAndCopyResources(shouldCopyResources = true) { |
| 249 | const { XmlBuilder } = loadIsopackage('xmlbuilder'); |
| 250 | |
| 251 | let config = XmlBuilder.create('widget'); |
| 252 | |
| 253 | // Set the root attributes |
| 254 | _.each({ |
| 255 | id: this.metadata.id, |
| 256 | version: this.metadata.version, |
| 257 | 'android-versionCode': this.metadata.buildNumber, |
| 258 | 'ios-CFBundleVersion': this.metadata.buildNumber, |
| 259 | xmlns: 'http://www.w3.org/ns/widgets', |
| 260 | 'xmlns:cdv': 'http://cordova.apache.org/ns/1.0' |
| 261 | }, (value, key) => { |
| 262 | if (value) { |
| 263 | config.att(key, value); |
| 264 | } |
| 265 | }); |
| 266 | |
| 267 | // Set the metadata |
| 268 | config.element('name').txt(this.metadata.name); |
| 269 | config.element('description').txt(this.metadata.description); |
| 270 | config.element('author', { |
| 271 | href: this.metadata.website, |
| 272 | email: this.metadata.email |
| 273 | }).txt(this.metadata.author); |
| 274 | |
| 275 | // Set the additional global configuration preferences |
| 276 | _.each(this.additionalConfiguration.global, (value, key) => { |
| 277 | config.element('preference', { |
| 278 | name: key, |
| 279 | value: value.toString() |
| 280 | }); |
| 281 | }); |
| 282 | |
| 283 | // Set custom tags into widget element |
| 284 | _.each(this.custom, elementSet => { |
| 285 | const tag = config.raw(elementSet); |
| 286 | }); |
| 287 | |
| 288 | config.element('content', { src: this.metadata.contentUrl }); |
| 289 | |
| 290 | // Copy all the access rules |
| 291 | _.each(this.accessRules, (options, pattern) => { |
| 292 | const type = options.type; |
| 293 | options = _.omit(options, 'type'); |
| 294 | |
| 295 | if (type === 'intent') { |
| 296 | config.element('allow-intent', { href: pattern }); |
| 297 | } else if (type === 'navigation') { |
| 298 | config.element('allow-navigation', _.extend({ href: pattern }, options)); |
| 299 | } else { |
| 300 | config.element('access', _.extend({ origin: pattern }, options)); |
| 301 | } |
| 302 | }); |
| 303 | |
| 304 | const platformElement = { |
| 305 | ios: config.element('platform', {name: 'ios'}), |
no test coverage detected