_From @raphinesse on July 5, 2018 8:23_

### Current situation

#### Arguments

```js
/**
 * Usage:
 * @dir - directory where the project will be created. Required.
 * @optionalId - app id. Required (but be "undefined")
 * @optionalName - app name. Required (but can be "undefined").
 * @cfg - extra config to be saved in .cordova/config.json Required (but can be 
"{}").
 * @extEvents - An EventEmitter instance that will be used for logging 
purposes. Required (but can be "undefined").
 **/
// Returns a promise.
function (dir, optionalId, optionalName, cfg, extEvents) {...}
```

#### Properties of `cfg` used in `cordovaCreate`¹

```js
{
    lib: {
        www: {
            // The path/url/npm-name to the template that should be used
            url: String,

            // Symlink instead of copy files from template to dir
            link: Boolean,

            // Template is only fetched when true.
            // Template files are only copied when true.
            // If false, only some "mandatory" files are copied over from
            // `cordova-app-hello-world`
            template: Boolean,

            // Deprecated alias for url (w/out deprecation warning)
            uri: String
        }
    }
}
```

¹: neither the `cfg` object nor parts larger than single leaf properties are
passed outside the scope of this module, so a local view on this is all we need.

#### Pain Points
- *Required but optional*™ arguments
- Deeply nested structure of configuration
- Confusing naming and unclear semantics of configuration

### Proposal

#### Arguments

```js
/**
 * Creates a new cordova project in dest.
 *
 * @param {string} dest - directory where the project will be created.
 * @param {Object} [opts={}] - options to be used for creating a new cordova 
project.
 * @returns {Promise} Promise that resolves when project creation has finished
 */
function (dest, opts) {...}
```

#### Structure of `opts`

```js
{
    // Attributes to be set in package.json & config.xml
    id: String,
    name: String,
    version: String,

    // The path/url/npm-name to the template that should be used
    template: String,

    // Symlink instead of copy files from template to dest
    link: Boolean,

    // An EventEmitter instance that will be used for logging purposes
    // If not dropped as proposed in §4
    extEvents: EventEmitter
}
```

---

Migrated from #89

_Copied from original issue: apache/cordova-discuss#99_

[ Full content available at: https://github.com/apache/cordova-create/issues/21 
]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to