From caff9a0cc1c423d0020213c5b9d45a90a6b4f6ae Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Sun, 19 Jul 2015 07:48:44 -0600 Subject: [PATCH] [removed] Factory support See #825 --- docs/src/GettingStartedPage.js | 12 ------------ package.json | 5 ++--- src/templates/factory.index.js.template | 11 ----------- src/templates/factory.js.template | 6 ------ test/FactoriesSpec.js | 21 --------------------- tools/build-cli.js | 10 +--------- tools/generateFactories.js | 23 ----------------------- tools/lib/build.js | 6 +----- tools/release-scripts/test.js | 2 +- 9 files changed, 5 insertions(+), 91 deletions(-) delete mode 100644 src/templates/factory.index.js.template delete mode 100644 src/templates/factory.js.template delete mode 100644 test/FactoriesSpec.js delete mode 100644 tools/generateFactories.js diff --git a/docs/src/GettingStartedPage.js b/docs/src/GettingStartedPage.js index 883dff20e9..a8d4fe981a 100644 --- a/docs/src/GettingStartedPage.js +++ b/docs/src/GettingStartedPage.js @@ -87,18 +87,6 @@ define(['react-bootstrap'], function(ReactBootstrap) { var Alert = ReactBootstra /> -

Without JSX

-

If you do not use JSX and just call components as functions, you must explicitly create a factory before calling it. React-bootstrap provides factories for you in lib/factories:

-
- -

Browser support

diff --git a/package.json b/package.json index c70f241ebb..18dc23cd65 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,8 @@ "homepage": "http://react-bootstrap.github.io/", "scripts": { "build": "babel-node tools/build-cli.js", - "lib-build": "babel-node tools/build-cli.js --lib-only", - "test-watch": "npm run lib-build && karma start", - "test-coverage": "npm run lib-build && COVERAGE=true karma start --single-run", + "test-watch": "karma start", + "test-coverage": "COVERAGE=true karma start --single-run", "test": "npm run lint && npm run build && npm run tests-set", "tests-set": "karma start --single-run && _mocha --compilers js:babel-core/register test/server/*Spec.js", "lint": "eslint ./", diff --git a/src/templates/factory.index.js.template b/src/templates/factory.index.js.template deleted file mode 100644 index baaeb1ef02..0000000000 --- a/src/templates/factory.index.js.template +++ /dev/null @@ -1,11 +0,0 @@ -<% _.forEach(components, function (component) { %> -import <%= component %> from './<%= component %>'; -<% }); %> - -console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); - -export default { -<% _.forEach(components, function (component) { %> - <%= component %>, -<% }); %> -} diff --git a/src/templates/factory.js.template b/src/templates/factory.js.template deleted file mode 100644 index 051dbd144e..0000000000 --- a/src/templates/factory.js.template +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import <%= name %> from '../<%= name %>'; - -console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); - -export default React.createFactory(<%= name %>); diff --git a/test/FactoriesSpec.js b/test/FactoriesSpec.js deleted file mode 100644 index 040d636430..0000000000 --- a/test/FactoriesSpec.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import components from '../tools/public-components'; - -let props = { - ButtonInput: {value: 'button'}, - Glyphicon: {glyph: 'star'}, - Modal: {onHide() {}}, - ModalTrigger: {modal: React.DOM.div(null)}, - OverlayTrigger: {overlay: React.DOM.div(null)} -}; - -function createTest(component) { - let factory = require(`../lib/factories/${component}`); - describe('factories', function () { - it(`Should have a ${component} factory`, function () { - assert.ok(React.isValidElement(factory(props[component]))); - }); - }); -} - -components.map(component => createTest(component)); diff --git a/tools/build-cli.js b/tools/build-cli.js index d3b69fed77..a447d72df9 100644 --- a/tools/build-cli.js +++ b/tools/build-cli.js @@ -3,7 +3,6 @@ import 'colors'; import build from './build'; import docs from '../docs/build'; -import lib from './lib/build'; import { setExecOptions } from './exec'; import yargs from 'yargs'; @@ -14,11 +13,6 @@ const argv = yargs demand: false, default: false }) - .option('lib-only', { - demand: false, - default: false, - describe: 'Used for factories testing' - }) .option('verbose', { demand: false, default: false, @@ -35,9 +29,7 @@ setExecOptions(argv); let buildProcess; -if (argv.libOnly) { - buildProcess = lib(argv); -} else if (argv.docsOnly) { +if (argv.docsOnly) { buildProcess = docs(argv); } else { buildProcess = build(argv); diff --git a/tools/generateFactories.js b/tools/generateFactories.js deleted file mode 100644 index 84477051af..0000000000 --- a/tools/generateFactories.js +++ /dev/null @@ -1,23 +0,0 @@ -import _ from 'lodash'; -import path from 'path'; -import fs from 'fs'; -import { srcRoot } from './constants'; -import components from './public-components'; -import { buildContent } from './buildBabel'; - -export default function generateFactories(destination, babelOptions={}) { - - function generateCompiledFile(file, content) { - const outpath = path.join(destination, 'factories', `${file}.js`); - buildContent(content, __dirname, outpath, babelOptions); - } - - const indexTemplate = fs.readFileSync(path.join(srcRoot, 'templates', 'factory.index.js.template')); - const factoryTemplate = fs.readFileSync(path.join(srcRoot, 'templates', 'factory.js.template')); - - generateCompiledFile( 'index', _.template(indexTemplate)({components}) ); - - return Promise.all( - components.map( name => generateCompiledFile( name, _.template(factoryTemplate)({name}) )) - ); -} diff --git a/tools/lib/build.js b/tools/lib/build.js index 01a47e4cbb..2869824453 100644 --- a/tools/lib/build.js +++ b/tools/lib/build.js @@ -2,7 +2,6 @@ import 'colors'; import { exec } from '../exec'; import fsp from 'fs-promise'; import { srcRoot, libRoot } from '../constants'; -import generateFactories from '../generateFactories'; import { buildFolder } from '../buildBabel'; export default function BuildCommonJs() { @@ -10,9 +9,6 @@ export default function BuildCommonJs() { return exec(`rimraf ${libRoot}`) .then(() => fsp.mkdirs(libRoot)) - .then(() => Promise.all([ - generateFactories(libRoot), - buildFolder(srcRoot, libRoot) - ])) + .then(() => buildFolder(srcRoot, libRoot)) .then(() => console.log('Built: '.cyan + 'npm module'.green)); } diff --git a/tools/release-scripts/test.js b/tools/release-scripts/test.js index dc1e311756..75175fbaa4 100644 --- a/tools/release-scripts/test.js +++ b/tools/release-scripts/test.js @@ -4,7 +4,7 @@ import { exec } from '../exec'; function test() { console.log('Running: '.cyan + 'tests'.green); - return exec('npm run lib-build && npm run tests-set') + return exec('npm run tests-set') .then(() => console.log('Completed: '.cyan + 'tests'.green)); }