ember-cli-config-builder
Extensible library to edit Ember’s config files with familiar API.
Why? Checkout this blog post.
Installation
$ npm install --save ember-cli-config-builder
Or
$ yarn add ember-cli-config-builder
Basic Usage
// Import libraryconst ConfigBuilder = ; // Create builder instance. Notice: it is async operation which returns// Promise because async fs.readFile method is used to read file contentslet config = await ConfigBuilder; // Read variables with #get(path) method. Notice: it is always returns string// with raw value. Example: "'string value'", 'true', '{ object: true }' etcconfig; // "'/'" // Read nested values with dot-separated pathconfig; // 'false' // Read multiple values at onceconfig; // { modulePrefix: "'dummy'", locationType: "'auto'" } // Change existing properties with #set(path, value) method. It returns true// if set was successful or false otherwiseconfig; // true // Create a new popertyconfig; // true // Change nested propertiesconfig; // true // Change or create multiple properties at onceconfig; // { 'myNewProp.child': true, 'rootURL.child': false } // Or remove properties entirely with #remove(path) method. It returns true// if key was found and removed and false otherwiseconfig; // true // You can remove only child keys.config; // true // Multiple remove is available as wellconfig; // { myNewProp: true, modulePrefix: true } // After editing is done there are a few options to save result.// The most straightforward is save to the same file.// Notice: this method is async as well because of usage non-blocking// fs.writeFile methodawait config; // will write changes to disk and return string with file content // Or you can write changes to another fileawait config; // See Advanced Usage section for more use cases
Built-in adapters
- environment.js
- ember-cli-build.js
Alternatives
- ember-cli-build-config-editor – uses the same approach with recast AST trees but is have many limits what you can edit and uses it owns non-Ember intuitive API. Also it moves reading and writing files to user responsibilities.
- recast – very powerful but yet very low-level tool to parse, edit and print JavaScript files. This addon wraps it to make editing much more easier.
Advanced Usage
TODO: write this :)
Contributing
Installation
git clone git@github.com:kolybasov/ember-cli-config-builder.git
cd ember-cli-config-builder
yarn install
Running tests
yarn test
– Runs jest tests
License
This project is licensed under the MIT License.