From 61d2b5dfe57f38dfef1dd7462e10fee149f72ce8 Mon Sep 17 00:00:00 2001 From: Matt Fairbrass Date: Tue, 29 Aug 2017 14:21:52 +1000 Subject: [PATCH 1/4] Converted Actions and Stores over to ES6. Added support for running electron-renderer tests via Karma. Updated package.json with new dependencies and new test command for Karma. Added new webpack config for Karma. --- template/config/webpack.dev.config.js | 4 +- template/config/webpack.karma.config.js | 110 ++++++++++++++++++ template/config/webpack.prod.config.js | 4 +- template/config/webpack.test.config.js | 4 +- template/config/webpack.watch.config.js | 4 +- template/karma.conf.js | 28 +++++ template/package.json | 10 ++ template/src/actions/Actions.js | 11 ++ template/src/actions/index.js | 12 +- template/src/stores/Store.js | 92 +++++++++++++++ .../stores/{index.spec.js => Store.spec.js} | 0 template/src/stores/index.js | 93 +-------------- template/test/renderer/Store.spec.js | 24 ++++ 13 files changed, 293 insertions(+), 103 deletions(-) create mode 100644 template/config/webpack.karma.config.js create mode 100644 template/karma.conf.js create mode 100644 template/src/actions/Actions.js create mode 100644 template/src/stores/Store.js rename template/src/stores/{index.spec.js => Store.spec.js} (100%) create mode 100644 template/test/renderer/Store.spec.js diff --git a/template/config/webpack.dev.config.js b/template/config/webpack.dev.config.js index 6c4d21e..d5cbe3b 100644 --- a/template/config/webpack.dev.config.js +++ b/template/config/webpack.dev.config.js @@ -46,9 +46,11 @@ module.exports = { fonts: path.join(project.path.src, 'assets/fonts'), images: path.join(project.path.src, 'assets/images'), less: path.join(project.path.src, 'assets/less'), + models: path.join(project.path.src, 'models'), plugin: path.join(project.path.src, 'index.js'), stores: path.join(project.path.src, 'stores'), - storybook: project.path.storybook + storybook: project.path.storybook, + utils: path.join(project.path.src, 'utils') } }, module: { diff --git a/template/config/webpack.karma.config.js b/template/config/webpack.karma.config.js new file mode 100644 index 0000000..d8aaa33 --- /dev/null +++ b/template/config/webpack.karma.config.js @@ -0,0 +1,110 @@ +const webpack = require('webpack'); +const path = require('path'); +const project = require('./project'); + +const GLOBALS = { + 'process.env': { + 'NODE_ENV': JSON.stringify('test') + }, + __DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'true')) +}; + +module.exports = { + target: 'electron-renderer', // webpack should compile node compatible code for tests + stats: 'errors-only', + externals: { + 'jsdom': 'window', + 'react/addons': 'react', + 'react/lib/ExecutionEnvironment': 'react', + 'react/lib/ReactContext': 'react', + 'react-addons-test-utils': 'react-dom', + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.jsx', '.json', 'less'], + alias: { + actions: path.join(project.path.src, 'actions'), + components: path.join(project.path.src, 'components'), + constants: path.join(project.path.src, 'constants'), + fonts: path.join(project.path.src, 'assets/fonts'), + images: path.join(project.path.src, 'assets/images'), + less: path.join(project.path.src, 'assets/less'), + models: path.join(project.path.src, 'models'), + plugin: path.join(project.path.src, 'index.js'), + stores: path.join(project.path.src, 'stores'), + storybook: project.path.storybook, + utils: path.join(project.path.src, 'utils') + } + }, + module: { + rules: [ + { + test: /\.css$/, + use: [ + { loader: 'style-loader'}, + { loader: 'css-loader' } + ] + }, + { + test: /\.less$/, + exclude: /node_modules/, + use: [ + { loader: 'style-loader' }, + { + loader: 'css-loader', + options: { + modules: true, + importLoaders: 1, + localIdentName: 'QueryHistory_[name]-[local]__[hash:base64:5]' + } + }, + { + loader: 'postcss-loader', + options: { + plugins: function () { + return [ + project.plugin.autoprefixer + ]; + } + } + }, + { + loader: 'less-loader', + options: { + noIeCompat: true + } + } + ] + }, + { + test: /node_modules\/JSONStream\/index\.js$/, + use: [{ loader: 'shebang-loader' }] + }, + { + test: /\.(js|jsx)$/, + use: [{ loader: 'babel-loader' }], + exclude: /(node_modules)/ + }, + { + test: /\.(png|jpg|jpeg|gif|svg)$/, + use: [{ + loader: 'ignore-loader', + query: { + limit: 8192, + name: 'assets/images/[name]__[hash:base64:5].[ext]' + } + }] + }, + { + test: /\.(woff|woff2|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/, + use: [{ + loader: 'ignore-loader', + query: { + limit: 8192, + name: 'assets/fonts/[name]__[hash:base64:5].[ext]' + } + }], + } + ] + } +}; diff --git a/template/config/webpack.prod.config.js b/template/config/webpack.prod.config.js index f050dfb..461676a 100644 --- a/template/config/webpack.prod.config.js +++ b/template/config/webpack.prod.config.js @@ -41,9 +41,11 @@ module.exports = { fonts: path.join(project.path.src, 'assets/fonts'), images: path.join(project.path.src, 'assets/images'), less: path.join(project.path.src, 'assets/less'), + models: path.join(project.path.src, 'models'), plugin: path.join(project.path.src, 'index.js'), stores: path.join(project.path.src, 'stores'), - storybook: project.path.storybook + storybook: project.path.storybook, + utils: path.join(project.path.src, 'utils') } }, module: { diff --git a/template/config/webpack.test.config.js b/template/config/webpack.test.config.js index 7173162..ef8efd7 100644 --- a/template/config/webpack.test.config.js +++ b/template/config/webpack.test.config.js @@ -29,9 +29,11 @@ module.exports = { fonts: path.join(project.path.src, 'assets/fonts'), images: path.join(project.path.src, 'assets/images'), less: path.join(project.path.src, 'assets/less'), + models: path.join(project.path.src, 'models'), plugin: path.join(project.path.src, 'index.js'), stores: path.join(project.path.src, 'stores'), - storybook: project.path.storybook + storybook: project.path.storybook, + utils: path.join(project.path.src, 'utils') } }, module: { diff --git a/template/config/webpack.watch.config.js b/template/config/webpack.watch.config.js index a4ffbf3..5efb9cc 100644 --- a/template/config/webpack.watch.config.js +++ b/template/config/webpack.watch.config.js @@ -35,9 +35,11 @@ module.exports = { fonts: path.join(project.path.src, 'assets/fonts'), images: path.join(project.path.src, 'assets/images'), less: path.join(project.path.src, 'assets/less'), + models: path.join(project.path.src, 'models'), plugin: path.join(project.path.src, 'index.js'), stores: path.join(project.path.src, 'stores'), - storybook: project.path.storybook + storybook: project.path.storybook, + utils: path.join(project.path.src, 'utils') } }, module: { diff --git a/template/karma.conf.js b/template/karma.conf.js new file mode 100644 index 0000000..ed74f22 --- /dev/null +++ b/template/karma.conf.js @@ -0,0 +1,28 @@ +const webpackConfig = require('./config/webpack.karma.config'); + +module.exports = function(config) { + config.set({ + basePath: '', + singleRun: true, + files: [ + 'test/**/*.spec.js' + ], + reporters: ['mocha'], + preprocessors: { + 'test/**/*.spec.js': ['webpack', 'sourcemap'] + }, + browsers: ['Electron'], + frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'], + webpack: webpackConfig, + webpackMiddleware: { + noInfo: true, + stats: 'errors-only' + }, + // DEV: `useIframe: false` is for launching a new window instead of using an iframe + // In Electron, iframes don't get `nodeIntegration` priveleges yet windows do + client: { + useIframe: false + }, + logLevel: config.LOG_ERROR + }); +}; \ No newline at end of file diff --git a/template/package.json b/template/package.json index 28dadfe..fb093bb 100644 --- a/template/package.json +++ b/template/package.json @@ -13,6 +13,7 @@ "start:prod": "npm run compile && electron --noDevServer ./electron", "test": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\"", "test:watch": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\" --watch", + "test:karma": "cross-env NODE_ENV=test karma start", "cover": "nyc npm run test", "ci": "npm run check && npm test", "fmt": "mongodb-js-fmt ./*.js ./test/*.js", @@ -63,6 +64,15 @@ "istanbul-instrumenter-loader": "^3.0.0", "jsdom": "^11.1.0", "jsdom-global": "^3.0.2", + "karma": "^1.7.0", + "karma-chai": "^0.1.0", + "karma-chai-sinon": "^0.1.5", + "karma-electron": "^5.2.1", + "karma-mocha": "^1.3.0", + "karma-mocha-reporter": "^2.2.4", + "karma-sinon": "^1.0.5", + "karma-sourcemap-loader": "^0.3.7", + "karma-webpack": "^2.0.4", "less": "^2.7.2", "less-loader": "^4.0.5", "mocha": "^3.4.2", diff --git a/template/src/actions/Actions.js b/template/src/actions/Actions.js new file mode 100644 index 0000000..3686320 --- /dev/null +++ b/template/src/actions/Actions.js @@ -0,0 +1,11 @@ +import Reflux from 'reflux'; + +const {{pascalcase name}}Actions = Reflux.createActions([ + /** + * define your actions as strings below, for example: + */ + 'toggleStatus' +]); + +export default {{pascalcase name}}Actions; +export { {{pascalcase name}}Actions }; \ No newline at end of file diff --git a/template/src/actions/index.js b/template/src/actions/index.js index 5cbf711..25a2fa9 100644 --- a/template/src/actions/index.js +++ b/template/src/actions/index.js @@ -1,10 +1,4 @@ -const Reflux = require('reflux'); +import {{pascalcase name}}Actions from './Actions'; -const {{pascalcase name}}Actions = Reflux.createActions([ - /** - * define your actions as strings below, for example: - */ - 'toggleStatus' -]); - -module.exports = {{pascalcase name}}Actions; +export default {{pascalcase name}}Actions; +export { {{pascalcase name}}Actions }; diff --git a/template/src/stores/Store.js b/template/src/stores/Store.js new file mode 100644 index 0000000..9697c37 --- /dev/null +++ b/template/src/stores/Store.js @@ -0,0 +1,92 @@ +import Reflux from 'reflux'; +import StateMixin from 'reflux-state-mixin'; +import {{pascalcase name}}Actions from 'actions'; + +const debug = require('debug')('mongodb-compass:stores:{{slugcase name}}'); + +/** + * {{capitalcase name}} store. + */ +const {{pascalcase name}}Store = Reflux.createStore({ + /** + * adds a state to the store, similar to React.Component's state + * @see https://github.com/yonatanmn/Super-Simple-Flux#reflux-state-mixin + * + * If you call `this.setState({...})` this will cause the store to trigger + * and push down its state as props to connected components. + */ + mixins: [StateMixin.store], + + /** + * listen to all actions defined in ../actions/index.jsx + */ + listenables: {{pascalcase name}}Actions, + + /** + * Initialize everything that is not part of the store's state. + */ + init() { + }, + + /** + * This method is called when all plugins are activated. You can register + * listeners to other plugins' stores here, e.g. + * + * appRegistry.getStore('OtherPlugin.Store').listen(this.otherStoreChanged.bind(this)); + * + * If this plugin does not depend on other stores, you can delete the method. + * + * @param {Object} appRegistry app registry containing all stores and components + */ + onActivated() { + }, + + /** + * This method is called when the data service is finished connecting. You + * receive either an error or the connected data service object, and if the + * connection was successful you can now make calls to the database, e.g. + * + * dataService.command('admin', {connectionStatus: 1}, this.handleStatus.bind(this)); + * + * If this plugin does not need to talk to the database, you can delete this + * method. + * + * @param {Object} error the error object if connection was unsuccessful + * @param {Object} dataService the dataService object if connection was successful + * + */ + onConnected() { + }, + + /** + * Initialize the {{capitalcase name}} store state. The returned object must + * contain all keys that you might want to modify with this.setState(). + * + * @return {Object} initial store state. + */ + getInitialState() { + return { + status: 'enabled' + }; + }, + + /** + * handlers for each action defined in ../actions/index.jsx, for example: + */ + toggleStatus() { + this.setState({ + status: this.state.status === 'enabled' ? 'disabled' : 'enabled' + }); + }, + + /** + * log changes to the store as debug messages. + * @param {Object} prevState previous state. + */ + storeDidUpdate(prevState) { + debug('{{pascalcase name}} store changed from', prevState, 'to', this.state); + } +}); + +export default {{pascalcase name}}Store; +export { {{pascalcase name}}Store }; diff --git a/template/src/stores/index.spec.js b/template/src/stores/Store.spec.js similarity index 100% rename from template/src/stores/index.spec.js rename to template/src/stores/Store.spec.js diff --git a/template/src/stores/index.js b/template/src/stores/index.js index ef1d0b6..4acd54b 100644 --- a/template/src/stores/index.js +++ b/template/src/stores/index.js @@ -1,91 +1,4 @@ -const Reflux = require('reflux'); -const {{pascalcase name}}Actions = require('../actions'); -const StateMixin = require('reflux-state-mixin'); +import {{pascalcase name}}Store from './Store'; -const debug = require('debug')('mongodb-compass:stores:{{slugcase name}}'); - -/** - * {{capitalcase name}} store. - */ -const {{pascalcase name}}Store = Reflux.createStore({ - /** - * adds a state to the store, similar to React.Component's state - * @see https://github.com/yonatanmn/Super-Simple-Flux#reflux-state-mixin - * - * If you call `this.setState({...})` this will cause the store to trigger - * and push down its state as props to connected components. - */ - mixins: [StateMixin.store], - - /** - * listen to all actions defined in ../actions/index.jsx - */ - listenables: {{pascalcase name}}Actions, - - /** - * Initialize everything that is not part of the store's state. - */ - init() { - }, - - /** - * This method is called when all plugins are activated. You can register - * listeners to other plugins' stores here, e.g. - * - * appRegistry.getStore('OtherPlugin.Store').listen(this.otherStoreChanged.bind(this)); - * - * If this plugin does not depend on other stores, you can delete the method. - * - * @param {Object} appRegistry app registry containing all stores and components - */ - onActivated() { - }, - - /** - * This method is called when the data service is finished connecting. You - * receive either an error or the connected data service object, and if the - * connection was successful you can now make calls to the database, e.g. - * - * dataService.command('admin', {connectionStatus: 1}, this.handleStatus.bind(this)); - * - * If this plugin does not need to talk to the database, you can delete this - * method. - * - * @param {Object} error the error object if connection was unsuccessful - * @param {Object} dataService the dataService object if connection was successful - * - */ - onConnected() { - }, - - /** - * Initialize the {{capitalcase name}} store state. The returned object must - * contain all keys that you might want to modify with this.setState(). - * - * @return {Object} initial store state. - */ - getInitialState() { - return { - status: 'enabled' - }; - }, - - /** - * handlers for each action defined in ../actions/index.jsx, for example: - */ - toggleStatus() { - this.setState({ - status: this.state.status === 'enabled' ? 'disabled' : 'enabled' - }); - }, - - /** - * log changes to the store as debug messages. - * @param {Object} prevState previous state. - */ - storeDidUpdate(prevState) { - debug('{{pascalcase name}} store changed from', prevState, 'to', this.state); - } -}); - -module.exports = {{pascalcase name}}Store; +export default {{pascalcase name}}Store; +export { {{pascalcase name}}Store }; \ No newline at end of file diff --git a/template/test/renderer/Store.spec.js b/template/test/renderer/Store.spec.js new file mode 100644 index 0000000..dafdb84 --- /dev/null +++ b/template/test/renderer/Store.spec.js @@ -0,0 +1,24 @@ +import Store from 'stores'; + +describe('{{pascalcase name}}Store [Store]', () => { + beforeEach(function() { + Store.setState( Store.getInitialState() ); + }); + + it('should have an initial state of {status: \'enabled\'}', function() { + expect(Store.state.status).to.be.equal('enabled'); + }); + + describe('toggleStatus()', function() { + it('should switch the state to {status: \'disabled\'}', function() { + Store.toggleStatus(); + expect(Store.state.status).to.be.equal('disabled'); + }); + + it('should switch the state back to {status: \'enabled\'} when used a second time', function() { + Store.toggleStatus(); + Store.toggleStatus(); + expect(Store.state.status).to.be.equal('enabled'); + }); + }); +}); From a62c7b706b0758b88982c4527e410637c91941f0 Mon Sep 17 00:00:00 2001 From: Matt Fairbrass Date: Wed, 30 Aug 2017 14:33:57 +1000 Subject: [PATCH 2/4] Fixed linting issues. Added .editorconfig to autoconfigure IDE's with correct coding style settings that support editorconfigs. --- template/.editorconfig | 16 +++++++++++ template/karma.conf.js | 50 ++++++++++++++++----------------- template/src/actions/Actions.js | 2 +- template/src/stores/index.js | 2 +- 4 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 template/.editorconfig diff --git a/template/.editorconfig b/template/.editorconfig new file mode 100644 index 0000000..b9b7147 --- /dev/null +++ b/template/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig helps developers define and maintain +# consistent coding styles between different editors and IDEs. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/template/karma.conf.js b/template/karma.conf.js index ed74f22..43619a7 100644 --- a/template/karma.conf.js +++ b/template/karma.conf.js @@ -1,28 +1,28 @@ const webpackConfig = require('./config/webpack.karma.config'); module.exports = function(config) { - config.set({ - basePath: '', - singleRun: true, - files: [ - 'test/**/*.spec.js' - ], - reporters: ['mocha'], - preprocessors: { - 'test/**/*.spec.js': ['webpack', 'sourcemap'] - }, - browsers: ['Electron'], - frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'], - webpack: webpackConfig, - webpackMiddleware: { - noInfo: true, - stats: 'errors-only' - }, - // DEV: `useIframe: false` is for launching a new window instead of using an iframe - // In Electron, iframes don't get `nodeIntegration` priveleges yet windows do - client: { - useIframe: false - }, - logLevel: config.LOG_ERROR - }); -}; \ No newline at end of file + config.set({ + basePath: '', + singleRun: true, + files: [ + 'test/**/*.spec.js' + ], + reporters: ['mocha'], + preprocessors: { + 'test/**/*.spec.js': ['webpack', 'sourcemap'] + }, + browsers: ['Electron'], + frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'], + webpack: webpackConfig, + webpackMiddleware: { + noInfo: true, + stats: 'errors-only' + }, + // DEV: `useIframe: false` is for launching a new window instead of using an iframe + // In Electron, iframes don't get `nodeIntegration` priveleges yet windows do + client: { + useIframe: false + }, + logLevel: config.LOG_ERROR + }); +}; diff --git a/template/src/actions/Actions.js b/template/src/actions/Actions.js index 3686320..eb41bd2 100644 --- a/template/src/actions/Actions.js +++ b/template/src/actions/Actions.js @@ -8,4 +8,4 @@ const {{pascalcase name}}Actions = Reflux.createActions([ ]); export default {{pascalcase name}}Actions; -export { {{pascalcase name}}Actions }; \ No newline at end of file +export { {{pascalcase name}}Actions }; diff --git a/template/src/stores/index.js b/template/src/stores/index.js index 4acd54b..d9c738d 100644 --- a/template/src/stores/index.js +++ b/template/src/stores/index.js @@ -1,4 +1,4 @@ import {{pascalcase name}}Store from './Store'; export default {{pascalcase name}}Store; -export { {{pascalcase name}}Store }; \ No newline at end of file +export { {{pascalcase name}}Store }; From 88af57b5ac6ed591572fec6746dedbcb95c18315 Mon Sep 17 00:00:00 2001 From: Matt Fairbrass Date: Wed, 30 Aug 2017 15:50:12 +1000 Subject: [PATCH 3/4] Renamed the casing of file names to slug case following internal discussion on naming convention. --- template/karma.conf.js | 2 +- template/src/actions/{Actions.js => actions.js} | 0 template/src/actions/index.js | 2 +- template/src/components/toggleButton/index.js | 2 +- .../toggleButton/{ToggleButton.jsx => toggle-button.jsx} | 2 +- .../{ToggleButton.less => toggle-button.less} | 0 .../{ToggleButton.spec.js => toggle-button.spec.js} | 2 +- .../{ToggleButton.stories.js => toggle-button.stories.js} | 0 template/src/index.js | 2 +- template/src/{Plugin.js => plugin.js} | 0 template/src/{Plugin.spec.js => plugin.spec.js} | 2 +- template/src/stores/index.js | 2 +- template/src/stores/{Store.js => store.js} | 0 template/src/stores/{Store.spec.js => store.spec.js} | 0 template/test/renderer/{Store.spec.js => store.spec.js} | 8 ++++++++ 15 files changed, 16 insertions(+), 8 deletions(-) rename template/src/actions/{Actions.js => actions.js} (100%) rename template/src/components/toggleButton/{ToggleButton.jsx => toggle-button.jsx} (95%) rename template/src/components/toggleButton/{ToggleButton.less => toggle-button.less} (100%) rename template/src/components/toggleButton/{ToggleButton.spec.js => toggle-button.spec.js} (95%) rename template/src/components/toggleButton/{ToggleButton.stories.js => toggle-button.stories.js} (100%) rename template/src/{Plugin.js => plugin.js} (100%) rename template/src/{Plugin.spec.js => plugin.spec.js} (91%) rename template/src/stores/{Store.js => store.js} (100%) rename template/src/stores/{Store.spec.js => store.spec.js} (100%) rename template/test/renderer/{Store.spec.js => store.spec.js} (74%) diff --git a/template/karma.conf.js b/template/karma.conf.js index 43619a7..f2d6dd9 100644 --- a/template/karma.conf.js +++ b/template/karma.conf.js @@ -19,7 +19,7 @@ module.exports = function(config) { stats: 'errors-only' }, // DEV: `useIframe: false` is for launching a new window instead of using an iframe - // In Electron, iframes don't get `nodeIntegration` priveleges yet windows do + // In Electron, iframes don't get `nodeIntegration` priveleges yet windows do. client: { useIframe: false }, diff --git a/template/src/actions/Actions.js b/template/src/actions/actions.js similarity index 100% rename from template/src/actions/Actions.js rename to template/src/actions/actions.js diff --git a/template/src/actions/index.js b/template/src/actions/index.js index 25a2fa9..ec23f6a 100644 --- a/template/src/actions/index.js +++ b/template/src/actions/index.js @@ -1,4 +1,4 @@ -import {{pascalcase name}}Actions from './Actions'; +import {{pascalcase name}}Actions from './actions'; export default {{pascalcase name}}Actions; export { {{pascalcase name}}Actions }; diff --git a/template/src/components/toggleButton/index.js b/template/src/components/toggleButton/index.js index 4485dc2..e4b7918 100644 --- a/template/src/components/toggleButton/index.js +++ b/template/src/components/toggleButton/index.js @@ -1,4 +1,4 @@ -import ToggleButton from './ToggleButton'; +import ToggleButton from './toggle-button'; export default ToggleButton; export { ToggleButton }; diff --git a/template/src/components/toggleButton/ToggleButton.jsx b/template/src/components/toggleButton/toggle-button.jsx similarity index 95% rename from template/src/components/toggleButton/ToggleButton.jsx rename to template/src/components/toggleButton/toggle-button.jsx index 9bc1cbf..bbeb292 100644 --- a/template/src/components/toggleButton/ToggleButton.jsx +++ b/template/src/components/toggleButton/toggle-button.jsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import styles from './ToggleButton.less'; +import styles from './toggle-button.less'; class ToggleButton extends Component { static displayName = 'ToggleButton'; diff --git a/template/src/components/toggleButton/ToggleButton.less b/template/src/components/toggleButton/toggle-button.less similarity index 100% rename from template/src/components/toggleButton/ToggleButton.less rename to template/src/components/toggleButton/toggle-button.less diff --git a/template/src/components/toggleButton/ToggleButton.spec.js b/template/src/components/toggleButton/toggle-button.spec.js similarity index 95% rename from template/src/components/toggleButton/ToggleButton.spec.js rename to template/src/components/toggleButton/toggle-button.spec.js index 4d9cf2c..c4c71cd 100644 --- a/template/src/components/toggleButton/ToggleButton.spec.js +++ b/template/src/components/toggleButton/toggle-button.spec.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import ToggleButton from 'components/toggleButton'; -import styles from './ToggleButton.less'; +import styles from './toggle-button.less'; describe('ToggleButton [Component]', () => { let component; diff --git a/template/src/components/toggleButton/ToggleButton.stories.js b/template/src/components/toggleButton/toggle-button.stories.js similarity index 100% rename from template/src/components/toggleButton/ToggleButton.stories.js rename to template/src/components/toggleButton/toggle-button.stories.js diff --git a/template/src/index.js b/template/src/index.js index 50dc1a8..f4bbc9c 100644 --- a/template/src/index.js +++ b/template/src/index.js @@ -1,4 +1,4 @@ -import {{pascalcase name}}Plugin from './Plugin'; +import {{pascalcase name}}Plugin from './plugin'; import {{pascalcase name}}Actions from 'actions'; import {{pascalcase name}}Store from 'stores'; diff --git a/template/src/Plugin.js b/template/src/plugin.js similarity index 100% rename from template/src/Plugin.js rename to template/src/plugin.js diff --git a/template/src/Plugin.spec.js b/template/src/plugin.spec.js similarity index 91% rename from template/src/Plugin.spec.js rename to template/src/plugin.spec.js index bc3f0a2..47b04ea 100644 --- a/template/src/Plugin.spec.js +++ b/template/src/plugin.spec.js @@ -1,7 +1,7 @@ import React from 'react'; import { mount } from 'enzyme'; import { StoreConnector } from 'hadron-react-components'; -import {{pascalcase name}}Plugin from './Plugin'; +import {{pascalcase name}}Plugin from './plugin'; describe('{{pascalcase name}} [Plugin]', () => { let component; diff --git a/template/src/stores/index.js b/template/src/stores/index.js index d9c738d..323a59f 100644 --- a/template/src/stores/index.js +++ b/template/src/stores/index.js @@ -1,4 +1,4 @@ -import {{pascalcase name}}Store from './Store'; +import {{pascalcase name}}Store from './store'; export default {{pascalcase name}}Store; export { {{pascalcase name}}Store }; diff --git a/template/src/stores/Store.js b/template/src/stores/store.js similarity index 100% rename from template/src/stores/Store.js rename to template/src/stores/store.js diff --git a/template/src/stores/Store.spec.js b/template/src/stores/store.spec.js similarity index 100% rename from template/src/stores/Store.spec.js rename to template/src/stores/store.spec.js diff --git a/template/test/renderer/Store.spec.js b/template/test/renderer/store.spec.js similarity index 74% rename from template/test/renderer/Store.spec.js rename to template/test/renderer/store.spec.js index dafdb84..b45fe10 100644 --- a/template/test/renderer/Store.spec.js +++ b/template/test/renderer/store.spec.js @@ -1,3 +1,11 @@ +/* + * Place tests that must run in a renderer context inside Electron here. + * + * Note: The tests below are just a copy of the store unit tests as an example. + * More complex plugins will require actual renderer/integration tests to be + * executed here. + */ + import Store from 'stores'; describe('{{pascalcase name}}Store [Store]', () => { From dcce7d07997c7340e8a70faa9c633e8da4547b99 Mon Sep 17 00:00:00 2001 From: Matt Fairbrass Date: Wed, 30 Aug 2017 16:12:06 +1000 Subject: [PATCH 4/4] Changed directory casing as per clarification of naming conventions discussed with the team. --- .../src/components/{toggleButton => toggle-button}/index.js | 0 .../{toggleButton => toggle-button}/toggle-button.jsx | 0 .../{toggleButton => toggle-button}/toggle-button.less | 0 .../{toggleButton => toggle-button}/toggle-button.spec.js | 2 +- .../{toggleButton => toggle-button}/toggle-button.stories.js | 2 +- template/src/components/{{name}}/{{name}}.jsx | 2 +- template/src/components/{{name}}/{{name}}.spec.js | 2 +- 7 files changed, 4 insertions(+), 4 deletions(-) rename template/src/components/{toggleButton => toggle-button}/index.js (100%) rename template/src/components/{toggleButton => toggle-button}/toggle-button.jsx (100%) rename template/src/components/{toggleButton => toggle-button}/toggle-button.less (100%) rename template/src/components/{toggleButton => toggle-button}/toggle-button.spec.js (94%) rename template/src/components/{toggleButton => toggle-button}/toggle-button.stories.js (96%) diff --git a/template/src/components/toggleButton/index.js b/template/src/components/toggle-button/index.js similarity index 100% rename from template/src/components/toggleButton/index.js rename to template/src/components/toggle-button/index.js diff --git a/template/src/components/toggleButton/toggle-button.jsx b/template/src/components/toggle-button/toggle-button.jsx similarity index 100% rename from template/src/components/toggleButton/toggle-button.jsx rename to template/src/components/toggle-button/toggle-button.jsx diff --git a/template/src/components/toggleButton/toggle-button.less b/template/src/components/toggle-button/toggle-button.less similarity index 100% rename from template/src/components/toggleButton/toggle-button.less rename to template/src/components/toggle-button/toggle-button.less diff --git a/template/src/components/toggleButton/toggle-button.spec.js b/template/src/components/toggle-button/toggle-button.spec.js similarity index 94% rename from template/src/components/toggleButton/toggle-button.spec.js rename to template/src/components/toggle-button/toggle-button.spec.js index c4c71cd..902883e 100644 --- a/template/src/components/toggleButton/toggle-button.spec.js +++ b/template/src/components/toggle-button/toggle-button.spec.js @@ -1,7 +1,7 @@ import React from 'react'; import { mount } from 'enzyme'; -import ToggleButton from 'components/toggleButton'; +import ToggleButton from 'components/toggle-button'; import styles from './toggle-button.less'; describe('ToggleButton [Component]', () => { diff --git a/template/src/components/toggleButton/toggle-button.stories.js b/template/src/components/toggle-button/toggle-button.stories.js similarity index 96% rename from template/src/components/toggleButton/toggle-button.stories.js rename to template/src/components/toggle-button/toggle-button.stories.js index d66a4e0..bc1c162 100644 --- a/template/src/components/toggleButton/toggle-button.stories.js +++ b/template/src/components/toggle-button/toggle-button.stories.js @@ -5,7 +5,7 @@ import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import ComponentPreview from 'storybook/decorators/componentPreview'; import { withChaptersOptions } from 'constants/storybook'; -import { ToggleButton } from 'components/toggleButton'; +import { ToggleButton } from 'components/toggle-button'; storiesOf('ToggleButton', module) .addWithChapters('Example Title', { diff --git a/template/src/components/{{name}}/{{name}}.jsx b/template/src/components/{{name}}/{{name}}.jsx index 31ed027..23b499a 100644 --- a/template/src/components/{{name}}/{{name}}.jsx +++ b/template/src/components/{{name}}/{{name}}.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import ToggleButton from 'components/toggleButton'; +import ToggleButton from 'components/toggle-button'; import styles from './{{name}}.less'; diff --git a/template/src/components/{{name}}/{{name}}.spec.js b/template/src/components/{{name}}/{{name}}.spec.js index 6df9d56..7a5c2fe 100644 --- a/template/src/components/{{name}}/{{name}}.spec.js +++ b/template/src/components/{{name}}/{{name}}.spec.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import {{pascalcase name}} from 'components/{{name}}'; -import ToggleButton from 'components/toggleButton'; +import ToggleButton from 'components/toggle-button'; import styles from './{{name}}.less'; describe('{{pascalcase name}} [Component]', () => {