_From @raphinesse on July 5, 2018 8:25_
I'm talking about the logic behind setting the appropriate fields for *App ID*,
*App Name* and *App Version* in the files `package.json` and `config.xml`.
### Current situation
The most common strategy is to set the attribute in both files iff a value for
it was given to `cordovaCreate`. Exceptions are
- *App ID in `package.json`*: set attribute if value given else set to
`helloworld`
- *App Version in both files*: always set to `1.0.0`
#### Pain Points
- Strategies employed for setting the attributes differ
- Falling back to hard coded defaults is not very flexible (e.g. I usually
start my version numbering at `0.1.0`)
### Proposal
For every file `f` and every attribute `attr`, do the following
```js
if (attr in opts) {
// Save attribute value passed to cordovaCreate to f
f[attr] = opts[attr]
} else if (attr in f) {
// Attribute already present in f and no override specified
// => Leave the existing value untouched
} else if (isRequired(attr, f)) {
handleMissingRequiredAttribute(attr, f)
}
```
where `isRequired` would have to be defined adequately
and `handleMissingRequiredAttribute` could either:
1. Throw an error (my preference)
2. Save some hard coded fallback value to `f` (possibly warn that `f` is
invalid)
### Related issues
[CB-12274 - widget version number not copied from template config.xml
file](https://issues.apache.org/jira/browse/CB-12274)
---
Migrated from #89
_Copied from original issue: apache/cordova-discuss#100_
[ Full content available at: https://github.com/apache/cordova-create/issues/22
]
This message was relayed via gitbox.apache.org for [email protected]