npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-build-config-editor

v0.5.1

Published

Utility for ember blueprints to use to modify ember-cli-build.js

Downloads

46,048

Readme

Build Status Dependency Status devDependency Status Greenkeeper badge Ember Observer

Ember CLI Build Config Editor

Utility for ember blueprints to use to modify ember-cli-build.js

Installation for Use

For installation in a non-Ember project:

npm install ember-cli-build-config-editor --save-dev

For installation in an Ember project:

ember install ember-cli-build-config-editor

Usage

Note: This package only handles flat configurations at this point.

Querying configuration

var BuildConfigEditor = require('ember-cli-build-config-editor.js');
var fs = require('fs');

// Specify 'utf-8' to force it to be a string instead of a buffer
var source = fs.readFileSync('./ember-cli-build.js', 'utf-8');

var build = new BuildConfigEditor(source);

var config = build.retrieve('some-addon');

// Do something with the config

Adding or editing configuration

Use this from your Ember blueprint to add or update configuration options in your ember-cli-build.js.

var BuildConfigEditor = require('ember-cli-build-config-editor.js');
var fs = require('fs');

// Specify 'utf-8' to force it to be a string instead of a buffer
var source = fs.readFileSync('./ember-cli-build.js', 'utf-8');

var build = new BuildConfigEditor(source);

build.edit('some-addon', {
    booleanProperty: false,
    numericProperty: 17,
    stringProperty: 'wow'
});

fs.writeFileSync('./ember-cli-build.js', build.code());

What It Does

The above example modifies ember-cli-build.js in the following ways

  • Finds the 'some-addon' key in the options object of your EmberApp construction, creating one if it doesn't exist
  • For each of the entries in the passed object, it adds property or updates it if it already exists with the specified value.

Keys that are not specified are preserved untouched. Added object keys are single-quoted for safety.

Troubleshooting

TypeError: this.source.charCodeAt is not a function

You have passed a buffer instead of a string to the constructor. Add the encoding argument when you read the file, e.g., var source = fs.readFileSync('./ember-cli-build.js', 'utf-8').

Development

Installation for Development

  • Fork and clone the repo
  • cd into the project directory
  • npm install

Running tests

npm test

Understanding JavaScript ASTs

The AST for the basic configuration can be found in this SVG for reference. It was generated from Rappid's JavaScript AST Visualizer.

The approach used here is based on that for ember-router-generator.

The DSL for AST types used by esprima provided great insight once I got my head around it.

Contributing

Please fork the project and submit pull requests and issues using GitHub.