From c1c72afdacbbab17dba6dee73fd0f2a57932ddae Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Mon, 11 Jul 2016 21:50:30 -0700 Subject: [PATCH 1/4] first attempt at new build structure --- .gitignore | 3 ++- .npmignore | 9 +++++++++ config/projectPaths.js | 3 ++- gulpfile.babel.js | 42 +++++++++++++++++++++++++++--------------- index.js | 1 - package.json | 2 +- src/index.js | 1 - 7 files changed, 41 insertions(+), 20 deletions(-) delete mode 100644 index.js diff --git a/.gitignore b/.gitignore index 67cc385..ee510bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules coverage/ -build \ No newline at end of file +index.js +react.js diff --git a/.npmignore b/.npmignore index e69de29..90e249c 100644 --- a/.npmignore +++ b/.npmignore @@ -0,0 +1,9 @@ +.gitignore +.travis.yml +gulpfile.babel.js +package.json +config/ +coverage/ +node_modules/ +src/ +tests/ \ No newline at end of file diff --git a/config/projectPaths.js b/config/projectPaths.js index 65268b4..7d9acf9 100644 --- a/config/projectPaths.js +++ b/config/projectPaths.js @@ -25,9 +25,10 @@ module.exports = { rootDir: rute, sourceDir: sourceDir, testsDir: testsDir, - buildDir: buildDir, + buildDir: rute, // entry points entry: path.join(sourceDir, 'index.js'), + reactEntry: path.join(sourceDir, 'react.js'), // globs testsGlob: path.join(testsDir, 'test_*.js'), // configuration files diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 025f7f5..ffba550 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -12,12 +12,7 @@ import projectPaths from './config/projectPaths' /** * Build entry point. */ -gulp.task('build', ['clean'], () => { - return gulp.src(projectPaths.entry) - .pipe(named()) - .pipe(webpack(require(projectPaths.webpackConfig))) - .pipe(gulp.dest(projectPaths.buildDir)) -}) +gulp.task('build', ['clean', 'build:core', 'build:react']) /** @@ -35,24 +30,32 @@ gulp.task('watch', ['clean'], () => { .pipe(gulp.dest(projectPaths.buildDir)) }) - -/** - * Build entry point for production. - */ -gulp.task('build-production', ['clean'], () => { +gulp.task('production', () => { // set the environment variable env({ vars: { NODE_ENV: 'production', }, }) +}) + + +gulp.task('build:core', () => { // build the client - return gulp.src(projectPaths.entry) - .pipe(named()) - .pipe(webpack(require(projectPaths.webpackConfig))) - .pipe(gulp.dest(projectPaths.buildDir)) + return buildFile(projectPaths.entry, 'index') +}) + + +gulp.task('build:react', () => { + return buildFile(projectPaths.reactEntry, 'react') }) +// Production aliases + +gulp.task('build:prod', ['production', 'build:core', 'build:react'], () => { +}) + + /** * Remove all ouptut files from previous builds. @@ -87,4 +90,13 @@ gulp.task('tdd', () => { }) +// Utilities + +const buildFile = (source, name) => ( + gulp.src(source) + .pipe(named(() => name)) + .pipe(webpack(require(projectPaths.webpackConfig))) + .pipe(gulp.dest(projectPaths.buildDir)) +) + // end of file diff --git a/index.js b/index.js deleted file mode 100644 index 278a548..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -export default from './src' diff --git a/package.json b/package.json index 0df428d..af284f8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "redux-responsive", "version": "2.2.0", "description": "Utilities for easily creating responsive designs in a redux architecture.", - "main": "build/index.js", + "main": "index.js", "repository": { "type": "git", "url": "https://github.com/aaivazis/redux-responsive.git" diff --git a/src/index.js b/src/index.js index 056b341..81d470f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,6 @@ import _createResponsiveStateReducer from './util/createResponsiveStateReducer' import _createResponsiveStoreEnhancer from './util/createResponsiveStoreEnhancer' export {CALCULATE_RESPONSIVE_STATE} from './actions/types' export {calculateResponsiveState} from './actions/creators' -export StyleSheet from './components/stylesheet' export const createResponsiveStateReducer = _createResponsiveStateReducer From fe5eb79162f9bec782e83d15e3c01f76989fd2b9 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Mon, 11 Jul 2016 22:07:27 -0700 Subject: [PATCH 2/4] cleaned up gulpfile ; bumped version number --- gulpfile.babel.js | 55 ++++++++++------------------------------------- package.json | 6 +++--- 2 files changed, 14 insertions(+), 47 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index ffba550..d9e0873 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -10,25 +10,15 @@ import projectPaths from './config/projectPaths' /** - * Build entry point. + * Build entry points. */ -gulp.task('build', ['clean', 'build:core', 'build:react']) +gulp.task('build', ['build:core', 'build:react']) +gulp.task('build:prod', ['production', 'build']) /** - * Watch entry point. + * Sets the current chain of tasks to 'production mode'. */ -gulp.task('watch', ['clean'], () => { - const config = { - ...require(projectPaths.webpackConfig), - watch: true, - } - - return gulp.src(projectPaths.entry) - .pipe(named()) - .pipe(webpack(config)) - .pipe(gulp.dest(projectPaths.buildDir)) -}) gulp.task('production', () => { // set the environment variable @@ -40,29 +30,16 @@ gulp.task('production', () => { }) -gulp.task('build:core', () => { - // build the client - return buildFile(projectPaths.entry, 'index') -}) - - -gulp.task('build:react', () => { - return buildFile(projectPaths.reactEntry, 'react') -}) - -// Production aliases - -gulp.task('build:prod', ['production', 'build:core', 'build:react'], () => { -}) - +/** + * Build the core library. + */ +gulp.task('build:core', () => buildFile(projectPaths.entry, 'index')) /** - * Remove all ouptut files from previous builds. + * Build the react run modules. */ -gulp.task('clean', () => { - del.sync(projectPaths.buildDir) -}) +gulp.task('build:react', () => buildFile(projectPaths.reactEntry, 'react')) /** @@ -78,17 +55,6 @@ gulp.task('test', (cb) => { }) -/** - * Watch source and tests for changes, run tests on change. - */ -gulp.task('tdd', () => { - const server = new karma.Server({ - configFile: projectPaths.karmaConfig, - }) - - server.start() -}) - // Utilities @@ -99,4 +65,5 @@ const buildFile = (source, name) => ( .pipe(gulp.dest(projectPaths.buildDir)) ) + // end of file diff --git a/package.json b/package.json index af284f8..086a0ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redux-responsive", - "version": "2.2.0", + "version": "3.0.0", "description": "Utilities for easily creating responsive designs in a redux architecture.", "main": "index.js", "repository": { @@ -12,8 +12,8 @@ "Monte Mishkin" ], "scripts": { - "test": "node_modules/gulp/bin/gulp.js test", - "prepublish": "node_modules/gulp/bin/gulp.js build-production" + "test": "gulp test", + "prepublish": "gulp build:prod" }, "license": "MIT", "devDependencies": { From 7a956dc532bc147d6b722009278fd2f934fe4171 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Thu, 14 Jul 2016 23:22:48 -0700 Subject: [PATCH 3/4] fixed issue with react sub-package and gitignore --- .gitignore | 2 +- src/react.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/react.js diff --git a/.gitignore b/.gitignore index ee510bd..e80020b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules coverage/ index.js -react.js +/react.js diff --git a/src/react.js b/src/react.js new file mode 100644 index 0000000..53fd9eb --- /dev/null +++ b/src/react.js @@ -0,0 +1 @@ +export StyleSheet from './components/stylesheet' From 5b643614010e873c665c322dbab296009cfdd6c4 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Sat, 16 Jul 2016 09:58:03 -0700 Subject: [PATCH 4/4] tests pass --- gulpfile.babel.js | 15 +++------------ package.json | 3 ++- src/components/stylesheet.js | 4 ++-- tests/test_stylesheet.js | 9 ++++++--- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index d9e0873..b854c82 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -15,6 +15,9 @@ import projectPaths from './config/projectPaths' gulp.task('build', ['build:core', 'build:react']) gulp.task('build:prod', ['production', 'build']) +gulp.task('build:core', () => buildFile(projectPaths.entry, 'index')) +gulp.task('build:react', () => buildFile(projectPaths.reactEntry, 'react')) + /** * Sets the current chain of tasks to 'production mode'. @@ -30,18 +33,6 @@ gulp.task('production', () => { }) -/** - * Build the core library. - */ -gulp.task('build:core', () => buildFile(projectPaths.entry, 'index')) - - -/** - * Build the react run modules. - */ -gulp.task('build:react', () => buildFile(projectPaths.reactEntry, 'react')) - - /** * Run the test suite once. */ diff --git a/package.json b/package.json index 086a0ef..bc8f770 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "eslint-plugin-react": "^3.5.1", "gulp": "^3.9.0", "gulp-env": "^0.2.0", - "karma": "^0.13.22", + "karma": "^1.1.1", "karma-chrome-launcher": "^0.2.1", "karma-coverage": "^0.5.5", "karma-firefox-launcher": "^0.1.6", @@ -49,6 +49,7 @@ "webpack-stream": "^2.1.1" }, "dependencies": { + "karma": "^1.1.1", "lodash": "^4.2.1", "mediaquery": "0.0.3", "redux": "^3.5.2" diff --git a/src/components/stylesheet.js b/src/components/stylesheet.js index 9c3273a..4468a41 100644 --- a/src/components/stylesheet.js +++ b/src/components/stylesheet.js @@ -1,5 +1,5 @@ // external imports -import {connect} from 'react-redux' +// import {connect} from 'react-redux' import mapValues from 'lodash/mapValues' import sortBy from 'lodash/sortBy' @@ -126,7 +126,7 @@ const defaultOptions = { // export a higher order component export default (stylesheet, opts) => (component) => ( - connect( + require('react-redux').connect( // eslint-disable-line no-undef mapStateToPropsFactory(stylesheet, {...defaultOptions, ...opts}) )(component) ) diff --git a/tests/test_stylesheet.js b/tests/test_stylesheet.js index e7a0348..aa26e10 100644 --- a/tests/test_stylesheet.js +++ b/tests/test_stylesheet.js @@ -1,3 +1,6 @@ + +import 'babel-polyfill' + // local imports import { parsePattern, @@ -5,9 +8,9 @@ import { sortKeys, transformStyle, } from '../src/components/stylesheet' - -// fix the testing environment -import 'babel-polyfill' +// import {parsePattern} from 'components/stylesheet' +// // fix the testing environment +// import foo from 'components/stylesheet' describe('ReactStyleSheet', function () { it("can parse the relevant data from style patterns", function() {