# cordova-config

> Parse and edit the config.xml file of a cordova project

Latest version **0.7.0** (published 2017-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install cordova-config
pnpm add cordova-config
yarn add cordova-config
bun add cordova-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.0 |
| Published | 2017-04-07 |
| First published | 2015-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Sam Verschueren |
| Maintainers | samverschueren |
| Keywords | cordova, config, xml |

## Links

- npm: https://www.npmjs.com/package/cordova-config
- Repository: https://github.com/samverschueren/cordova-config
- Homepage: https://github.com/samverschueren/cordova-config#readme
- Issues: https://github.com/samverschueren/cordova-config/issues
- npm.io page: https://npm.io/package/cordova-config

## Dependencies (3)

- [pify](https://npm.io/package/pify.md) ^2.3.0
- [elementtree](https://npm.io/package/elementtree.md) ^0.1.6
- [pinkie-promise](https://npm.io/package/pinkie-promise.md) ^1.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.7.0 (latest) — 2017-04-07
- 0.6.2 — 2015-09-13
- 0.6.1 — 2015-09-06
- 0.6.0 — 2015-09-05
- 0.5.0 — 2015-08-31
- 0.4.0 — 2015-08-07
- 0.3.0 — 2015-06-12
- 0.2.0 — 2015-05-30
- 0.1.0 — 2015-05-24
- 0.0.1 — 2015-05-20

## README

# cordova-config

[![Build Status](https://travis-ci.org/SamVerschueren/cordova-config.svg?branch=master)](https://travis-ci.org/SamVerschueren/cordova-config)
[![Coverage Status](https://coveralls.io/repos/SamVerschueren/cordova-config/badge.svg?branch=master&service=github)](https://coveralls.io/github/SamVerschueren/cordova-config?branch=master)

> Parse and edit the config.xml file of a cordova project.


## Install

```
npm install --save cordova-config
```


## Usage

```js
const Config = require('cordova-config');

// Load and parse the config.xml
const config = new Config('config.xml');
config.setName('My application');
config.setDescription('This is the description of my application');
config.setAuthor('Sam Verschueren', 'sam.verschueren@gmail.com', 'https://github.com/SamVerschueren');

// Write the config file
config.writeSync();
```

## API

### Config(file)

> Loads and parses the file.

#### file

*Required*  
Type: `string`

The path to the `config.xml` file.

### #setName(name)

> Sets the `<name>name</name>` tag in the xml file.

#### name

*Required*  
Type: `string`

The name of the application.

### #setElement(tag, [text], [attribs])

> Sets a `<tag>text</tag>` tag in the xml file.

#### tag

*Required*  
Type: `string`

The name of the element.

#### text

Type: `string`

The element text.

#### attribs

Type: `object`

The element attributes

### #setDescription(description)

> Sets the `<description>description</description>` tag in the xml file.

#### description

*Required*  
Type: `string`

The description of the application.

### #setAuthor(name [, email [, website]])

> Sets the `<author email="email" href="website">name</author>` tag in the xml file.

#### name

*Required*  
Type: `string`

The name of the author.

#### email

Type: `string`

The email address of the email.

#### website

Type: `string`

The website of the author.

### #setVersion(version)

> Sets the version attribute of the `widget` tag in the xml file.

#### version

*Required*  
Type: `string`

The version in the format `x.y.z`.

### #setAndroidVersionCode(version)

> Sets the android-versionCode attribute of the `widget` tag in the xml file.

#### version

*Required*  
Type: `number`

The Android version code.

### #setAndroidPackageName(packageName)

> Sets the Android package name of the config file.

#### packageName

*Required*  
Type: `string`

The android package name.

### #setIOSBundleVersion(version)

> Sets the ios-CFBundleVersion attribute of the `widget` tag in the xml file.

#### version

*Required*  
Type: `string`

The version in the format `x.y.z`.

### #setIOSBundleIdentifier(identifier)

> Sets the iOS CFBundleIdentifier of the config file.

#### identifier

*Required*  
Type: `string`

The iOS `CFBundleIdentifier`.

### #setPreference(name, value)

> Adds a `<preference name="name" value="value" />` tag to the xml file.

#### name

*Required*  
Type: `string`

The name of the preference tag.

#### value

*Required*  
Type: `string|boolean`

The value of the preference.

### #removeAccessOrigins()

> Removes all the `<access />` tags in the xml file.

### #removeAccessOrigin(origin)

> Removes the `<access />` tag with the origin equal to the parameter.

#### origin

*Required*  
Type: `string`

The origin of the access tag you want to remove.

### #setAccessOrigin(origin [, options])

> Adds an `<access />` tag to the xml file.

#### origin

*Required*  
Type: `string`

The origin of the access tag.

#### options

Type: `object`

A map with extra attributes that will be added to the access tag.

### #setID(id)

> Sets the ID of the config file.

#### id

*Required*  
Type: `string`

The id of the widget tag.

### #addHook(type, src)

> Adds the hook with type and src. see [Apache Cordova API Documentation](https://goo.gl/5QZlqu) for more info.

#### type

*Required*  
Type: `string`

Cordova hook type. ex) 'after_build', 'after_compile', 'after_clean'

#### src

*Required*  
Type: `string`

Src path of hook script

### #addRawXML(xml)

> Adds a raw xml element to the root of the config file.

#### xml

*Required*  
Type: `string`

A raw xml element. You can only pass in one element with one root.

### #write()

> Writes the `config.xml` file async.

Resolves a promise when the file is written.

### #writeSync()

> Writes the `config.xml` file synchronously.


## Related

- [cordova-config-cli](https://github.com/ragingwind/cordova-config-cli) - CLI for this module


## License

MIT © Sam Verschueren

---
_Source: https://npm.io/package/cordova-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
