Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition feature flag infrastructure to modules #11375

Merged
merged 1 commit into from
Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@
//
// DISABLE_ES3=true DISABLE_JSCS=true DISABLE_JSHINT=true DISABLE_MIN=true DISABLE_DEREQUIRE=true ember serve --environment=production

var fs = require('fs');

var EmberBuild = require('emberjs-build');
var packages = require('./lib/packages');

var applyFeatureFlags = require('babel-plugin-feature-flags');

var vendoredPackage = require('emberjs-build/lib/vendored-package');
var htmlbarsPackage = require('emberjs-build/lib/htmlbars-package');
var vendoredES6Package = require('emberjs-build/lib/es6-vendored-package');

var featuresJson = fs.readFileSync('./features.json', { encoding: 'utf8' });

function babelConfigFor(environment) {
var isDevelopment = (environment === 'development');

var features = JSON.parse(featuresJson).features;
features["mandatory-setter"] = isDevelopment;

return {
plugins: [
applyFeatureFlags({
import: { module: 'ember-metal/features' },
features: features
})
]
};
}

var emberBuild = new EmberBuild({
babel: {
development: babelConfigFor('development'),
production: babelConfigFor('production')
},
htmlbars: require('htmlbars'),
packages: packages,
vendoredPackages: {
Expand Down
1 change: 0 additions & 1 deletion features.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"features": {
"features-stripped-test": null,
"ember-routing-named-substates": true,
"mandatory-setter": "development-only",
"ember-htmlbars-component-generation": null,
"ember-htmlbars-component-helper": true,
"ember-htmlbars-inline-if-helper": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'ember-views': {trees: null, requirements: ['ember-runtime', 'ember-metal-views']},
'ember-extension-support': {trees: null, requirements: ['ember-application']},
'ember-testing': {trees: null, requirements: ['ember-application', 'ember-routing'], testing: true},
'ember-template-compiler': {trees: null, vendorRequirements: ['htmlbars-runtime'], templateCompilerVendor: ['simple-html-tokenizer', 'morph-range', 'htmlbars-runtime', 'htmlbars-util', 'htmlbars-compiler', 'htmlbars-syntax', 'htmlbars-test-helpers']},
'ember-template-compiler': {trees: null, requirements: ['ember-metal'], vendorRequirements: ['htmlbars-runtime'], templateCompilerVendor: ['simple-html-tokenizer', 'morph-range', 'htmlbars-runtime', 'htmlbars-util', 'htmlbars-compiler', 'htmlbars-syntax', 'htmlbars-test-helpers', 'backburner']},
'ember-htmlbars': {trees: null, vendorRequirements: ['htmlbars-util', 'htmlbars-runtime'], requirements: ['ember-metal-views'], testingVendorRequirements: [ 'htmlbars-test-helpers'], hasTemplates: true},
'ember-routing': {trees: null, vendorRequirements: ['router', 'route-recognizer'],
requirements: ['ember-runtime', 'ember-views']},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
},
"devDependencies": {
"aws-sdk": "~2.1.5",
"babel-plugin-feature-flags": "~0.2.0",
"bower": "~1.3.2",
"chalk": "^0.5.1",
"ember-cli": "^0.2.7",
"ember-cli-dependency-checker": "^1.0.1",
"ember-cli-sauce": "^1.3.0",
"ember-cli-yuidoc": "^0.7.0",
"ember-publisher": "0.0.7",
"emberjs-build": "0.1.5",
"emberjs-build": "0.2.0",
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/container/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Ember from 'ember-metal/core'; // Ember.assert
import isEnabled from "ember-metal/features";
import dictionary from 'ember-metal/dictionary';
import Container from './container';

var VALID_FULL_NAME_REGEXP = /^[^:]+.+:[^:]+$/;

var instanceInitializersFeatureEnabled;
if (Ember.FEATURES.isEnabled('ember-application-instance-initializers')) {
if (isEnabled('ember-application-instance-initializers')) {
instanceInitializersFeatureEnabled = true;
}

Expand Down
11 changes: 6 additions & 5 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import DAG from 'dag-map';
import Registry from 'container/registry';

import Ember from "ember-metal"; // Ember.FEATURES, Ember.deprecate, Ember.assert, Ember.libraries, LOG_VERSION, Namespace, BOOTED
import Ember from "ember-metal"; // Ember.deprecate, Ember.assert, Ember.libraries, LOG_VERSION, Namespace, BOOTED
import isEnabled from "ember-metal/features";
import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import { runLoadHooks } from "ember-runtime/system/lazy_load";
Expand Down Expand Up @@ -293,7 +294,7 @@ var Application = Namespace.extend(DeferredMixin, {
// decremented by the Application's own `initialize` method.
this._readinessDeferrals = 1;

if (Ember.FEATURES.isEnabled('ember-application-visit')) {
if (isEnabled('ember-application-visit')) {
if (this.autoboot) {
// Create subclass of Ember.Router for this Application instance.
// This is to ensure that someone reopening `App.Router` does not
Expand Down Expand Up @@ -686,7 +687,7 @@ var Application = Namespace.extend(DeferredMixin, {
this._runInitializer('initializers', function(name, initializer) {
Ember.assert("No application initializer named '" + name + "'", !!initializer);

if (Ember.FEATURES.isEnabled("ember-application-initializer-context")) {
if (isEnabled("ember-application-initializer-context")) {
initializer.initialize(registry, App);
} else {
var ref = initializer.initialize;
Expand Down Expand Up @@ -799,7 +800,7 @@ var Application = Namespace.extend(DeferredMixin, {
}
});

if (Ember.FEATURES.isEnabled('ember-application-instance-initializers')) {
if (isEnabled('ember-application-instance-initializers')) {
Application.reopen({
instanceInitializer(options) {
this.constructor.instanceInitializer(options);
Expand All @@ -811,7 +812,7 @@ if (Ember.FEATURES.isEnabled('ember-application-instance-initializers')) {
});
}

if (Ember.FEATURES.isEnabled('ember-application-visit')) {
if (isEnabled('ember-application-visit')) {
Application.reopen({
/**
Creates a new instance of the application and instructs it to route to the
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-application/tests/system/initializers_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import { indexOf } from "ember-metal/array";
Expand Down Expand Up @@ -333,7 +334,7 @@ QUnit.test("initializers are per-app", function() {
});
});

if (Ember.FEATURES.isEnabled("ember-application-initializer-context")) {
if (isEnabled("ember-application-initializer-context")) {
QUnit.test("initializers should be executed in their own context", function() {
expect(1);
var MyApplication = Application.extend();
Expand All @@ -355,7 +356,7 @@ if (Ember.FEATURES.isEnabled("ember-application-initializer-context")) {
});
}

if (Ember.FEATURES.isEnabled("ember-application-instance-initializers")) {
if (isEnabled("ember-application-instance-initializers")) {
QUnit.test("initializers should throw a deprecation warning when performing a lookup on the registry", function() {
expect(1);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import ApplicationInstance from "ember-application/system/application-instance";
Expand All @@ -6,11 +7,11 @@ import jQuery from "ember-views/system/jquery";

var app, initializeContextFeatureEnabled;

if (Ember.FEATURES.isEnabled("ember-application-initializer-context")) {
if (isEnabled("ember-application-initializer-context")) {
initializeContextFeatureEnabled = true;
}

if (Ember.FEATURES.isEnabled('ember-application-instance-initializers')) {
if (isEnabled('ember-application-instance-initializers')) {
QUnit.module("Ember.Application instance initializers", {
setup() {
},
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-application/tests/system/visit_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import ApplicationInstance from "ember-application/system/application-instance";
Expand All @@ -18,7 +19,7 @@ function createApplication() {
return App;
}

if (Ember.FEATURES.isEnabled('ember-application-visit')) {
if (isEnabled('ember-application-visit')) {
QUnit.module("Ember.Application - visit()");

// This tests whether the application is "autobooted" by registering an
Expand Down
7 changes: 4 additions & 3 deletions packages/ember-debug/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*global __fail__*/

import Ember from "ember-metal/core";
import isEnabled, { FEATURES } from "ember-metal/features";
import EmberError from "ember-metal/error";
import Logger from "ember-metal/logger";

Expand Down Expand Up @@ -230,14 +231,14 @@ export function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped)

if (!Ember.testing) {
// Complain if they're using FEATURE flags in builds other than canary
Ember.FEATURES['features-stripped-test'] = true;
FEATURES['features-stripped-test'] = true;
var featuresWereStripped = true;

if (Ember.FEATURES.isEnabled('features-stripped-test')) {
if (isEnabled('features-stripped-test')) {
featuresWereStripped = false;
}

delete Ember.FEATURES['features-stripped-test'];
delete FEATURES['features-stripped-test'];
_warnIfUsingStrippedFeatureFlags(Ember.ENV.FEATURES, featuresWereStripped);

// Inform the developer about the Ember Inspector if not installed.
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/lib/env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import environment from "ember-metal/environment";

import { hooks } from "htmlbars-runtime";
Expand Down Expand Up @@ -100,7 +101,7 @@ registerKeyword('mut', mut);
registerKeyword('@mut', privateMut);
registerKeyword('each', each);
registerKeyword('readonly', readonly);
if (Ember.FEATURES.isEnabled('ember-htmlbars-get-helper')) {
if (isEnabled('ember-htmlbars-get-helper')) {
registerKeyword('get', getKeyword);
}

Expand Down
4 changes: 3 additions & 1 deletion packages/ember-htmlbars/lib/helpers/-get.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import isEnabled from "ember-metal/features";

/*
This private helper is used in conjuntion with the get keyword
@private
*/

if (Ember.FEATURES.isEnabled('ember-htmlbars-get-helper')) {
if (isEnabled('ember-htmlbars-get-helper')) {

var getHelper = function getHelper([value]) {
return value;
Expand Down
4 changes: 3 additions & 1 deletion packages/ember-htmlbars/lib/helpers/each-in.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if (Ember.FEATURES.isEnabled('ember-htmlbars-each-in')) {
import isEnabled from "ember-metal/features";

if (isEnabled('ember-htmlbars-each-in')) {
var shouldDisplay = function(object) {
if (object === undefined || object === null) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/lib/keywords/get.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import isEnabled from "ember-metal/features";
import Stream from "ember-metal/streams/stream";
import { labelFor } from "ember-metal/streams/utils";
import { read, isStream } from "ember-metal/streams/utils";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";

if (Ember.FEATURES.isEnabled('ember-htmlbars-get-helper')) {
if (isEnabled('ember-htmlbars-get-helper')) {

var getKeyword = function getKeyword(morph, env, scope, params, hash, template, inverse, visitor) {
var objParam = params[0];
Expand Down
7 changes: 4 additions & 3 deletions packages/ember-htmlbars/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from "ember-metal/core";
import isEnabled from "ember-metal/features";

import {
precompile,
Expand Down Expand Up @@ -47,7 +48,7 @@ registerHelper('with', withHelper);
registerHelper('loc', locHelper);
registerHelper('log', logHelper);
registerHelper('each', eachHelper);
if (Ember.FEATURES.isEnabled('ember-htmlbars-each-in')) {
if (isEnabled('ember-htmlbars-each-in')) {
registerHelper('each-in', eachInHelper);
}
registerHelper('-bind-attr-class', bindAttrClassHelper);
Expand All @@ -56,7 +57,7 @@ registerHelper('concat', concatHelper);
registerHelper('-join-classes', joinClassesHelper);
registerHelper('-legacy-each-with-controller', legacyEachWithControllerHelper);
registerHelper('-legacy-each-with-keyword', legacyEachWithKeywordHelper);
if (Ember.FEATURES.isEnabled('ember-htmlbars-get-helper')) {
if (isEnabled('ember-htmlbars-get-helper')) {
registerHelper('-get', getHelper);
}
registerHelper('-html-safe', htmlSafeHelper);
Expand All @@ -72,7 +73,7 @@ Ember.HTMLBars = {
DOMHelper
};

if (Ember.FEATURES.isEnabled('ember-htmlbars-helper')) {
if (isEnabled('ember-htmlbars-helper')) {
Helper.helper = makeHelper;
Ember.Helper = Helper;
}
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/tests/attr_nodes/boolean_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import compile from "ember-template-compiler/system/compile";
Expand All @@ -10,7 +11,7 @@ function appendView(view) {
}

// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: boolean attribute", {
teardown() {
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/class_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import compile from "ember-template-compiler/system/compile";
Expand All @@ -10,12 +11,12 @@ function appendView(view) {
}

var isInlineIfEnabled = false;
if (Ember.FEATURES.isEnabled('ember-htmlbars-inline-if-helper')) {
if (isEnabled('ember-htmlbars-inline-if-helper')) {
isInlineIfEnabled = true;
}

// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: class attribute", {
teardown() {
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/tests/attr_nodes/data_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import EmberObject from "ember-runtime/system/object";
Expand All @@ -9,7 +10,7 @@ import { runAppend, runDestroy } from "ember-runtime/tests/utils";

var view, originalSetAttribute, setAttributeCalls, renderer;

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: data attribute", {
teardown() {
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/tests/attr_nodes/href_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import compile from "ember-template-compiler/system/compile";
Expand All @@ -10,7 +11,7 @@ function appendView(view) {
}

// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: href attribute", {
teardown() {
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/tests/attr_nodes/property_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import compile from "ember-template-compiler/system/compile";
Expand All @@ -16,7 +17,7 @@ function canSetFalsyMaxLength() {
}

// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: property", {
teardown() {
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/tests/attr_nodes/sanitized_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* jshint scripturl:true */

import isEnabled from "ember-metal/features";
import EmberView from "ember-views/views/view";
import compile from "ember-template-compiler/system/compile";
import { SafeString } from "ember-htmlbars/utils/string";
Expand All @@ -16,7 +17,7 @@ QUnit.module("ember-htmlbars: sanitized attribute", {

// jscs:disable validateIndentation
// jscs:disable disallowTrailingWhitespace
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
if (isEnabled('ember-htmlbars-attribute-syntax')) {

var badTags = [
{ tag: 'a', attr: 'href',
Expand Down
Loading