Coder Social home page Coder Social logo

cordova-config's Introduction

cordova-config

Build Status Coverage Status

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

Install

npm install --save cordova-config

Usage

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', '[email protected]', '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 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

License

MIT © Sam Verschueren

cordova-config's People

Contributors

gburnett avatar ragingwind avatar samverschueren avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.