├── .editorconfig ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.txt ├── Makefile ├── README.md ├── VERSION ├── package.json ├── packages ├── bolt-standard-flux │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ ├── karma │ │ │ ├── entry.js │ │ │ ├── karma.conf.coverage.js │ │ │ ├── karma.conf.dev.js │ │ │ └── karma.conf.js │ │ └── webpack │ │ │ ├── webpack.config.coverage.js │ │ │ ├── webpack.config.dev.js │ │ │ ├── webpack.config.hot.js │ │ │ ├── webpack.config.js │ │ │ └── webpack.config.test.js │ └── package.json ├── electrode-bolt-cli │ ├── .npmignore │ ├── CONTRIBUTING.md │ ├── README.md │ ├── bin │ │ └── bolt │ ├── package.json │ └── src │ │ └── bolt-cli.js └── electrode-bolt │ ├── CHANGELOG.md │ ├── README.md │ ├── bin │ └── bolt.js │ ├── config │ ├── eslint │ │ ├── .eslintrc-base │ │ ├── .eslintrc-bolt │ │ ├── .eslintrc-node │ │ ├── .eslintrc-react │ │ ├── .eslintrc-react-demo │ │ └── .eslintrc-react-test │ ├── istanbul │ │ └── .istanbul.yml │ ├── karma │ │ ├── entry.js │ │ ├── karma.conf.coverage.js │ │ ├── karma.conf.dev.js │ │ └── karma.conf.js │ └── webpack │ │ ├── webpack.config.coverage.js │ │ ├── webpack.config.demo.dev.js │ │ ├── webpack.config.demo.hot.js │ │ ├── webpack.config.dev.js │ │ ├── webpack.config.js │ │ └── webpack.config.test.js │ ├── package.json │ ├── src │ ├── bolt-run.js │ ├── bolt.js │ ├── init.js │ └── logger.js │ ├── tasks │ └── scaffold.js │ ├── templates │ ├── demo │ │ ├── .eslintrc │ │ ├── demo.jsx │ │ └── index.html │ ├── src │ │ ├── .eslintrc │ │ ├── components │ │ │ └── boilerplate-component.jsx │ │ └── index.js │ └── test │ │ ├── .eslintrc │ │ └── client │ │ └── spec │ │ └── components │ │ └── boilerplate-component.spec.jsx │ └── test │ └── spec │ ├── entry.js │ └── lib │ ├── bolt.spec.js │ └── logger.spec.js └── scripts ├── bootstrap.js ├── build.sh ├── publish.js ├── test.sh └── travis ├── merge-development-with-master.sh └── setup-git.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | end_of_line = lf 8 | 9 | [*.{js,json}] 10 | indent_style = space 11 | indent_size = 2 12 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "defaults/configurations/walmart/es6-node" 3 | } 4 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/npmconf/test/fixtures/package.json 3 | .*/react/.* 4 | .*/babel-core/.* 5 | 6 | [include] 7 | 8 | [libs] 9 | 10 | [options] 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/node,osx 2 | 3 | ### Node ### 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | lib 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directory 31 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 32 | node_modules 33 | 34 | 35 | ### OSX ### 36 | .DS_Store 37 | .AppleDouble 38 | .LSOverride 39 | 40 | # Icon must end with two \r 41 | Icon 42 | 43 | 44 | # Thumbnails 45 | ._* 46 | 47 | # Files that might appear in the root of a volume 48 | .DocumentRevisions-V100 49 | .fseventsd 50 | .Spotlight-V100 51 | .TemporaryItems 52 | .Trashes 53 | .VolumeIcon.icns 54 | 55 | # Directories potentially created on remote AFP share 56 | .AppleDB 57 | .AppleDesktop 58 | Network Trash Folder 59 | Temporary Items 60 | .apdisk 61 | 62 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/node,osx 2 | 3 | ### Node ### 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directory 30 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 31 | node_modules 32 | 33 | 34 | ### OSX ### 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Icon must end with two \r 40 | Icon 41 | 42 | 43 | # Thumbnails 44 | ._* 45 | 46 | # Files that might appear in the root of a volume 47 | .DocumentRevisions-V100 48 | .fseventsd 49 | .Spotlight-V100 50 | .TemporaryItems 51 | .Trashes 52 | .VolumeIcon.icns 53 | 54 | # Directories potentially created on remote AFP share 55 | .AppleDB 56 | .AppleDesktop 57 | Network Trash Folder 58 | Temporary Items 59 | .apdisk 60 | 61 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | * Use the present tense ("Add feature" not "Added feature") 4 | * Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 5 | * Limit the first line to 72 characters or less 6 | * Reference issues and pull requests liberally 7 | * Consider starting the commit message with an applicable emoji: 8 | - :art: `:art:` when improving the format/structure of the code 9 | - :bulb: `:bulb:` new idea 10 | - :construction: `:construction:` work in progress 11 | - :heavy_plus_sign: `:heavy_plus_sign:` when adding feature 12 | - :heavy_minus_sign: `:heavy_minus_sign:` when removing feature 13 | - :speaker: `:speaker:` when adding logging 14 | - :mute: `:mute:` when reducing logging 15 | - :racehorse: `:racehorse:` when improving performance 16 | - :anchor: `:anchor:` when refactoring 17 | - :wrench: `:wrench:` when working on tooling 18 | - :non-potable_water: `:non-potable_water:` when plugging memory leaks 19 | - :memo: `:memo:` when writing docs 20 | - :penguin: `:penguin:` when fixing something on Linux 21 | - :apple: `:apple:` when fixing something on Mac OS 22 | - :checkered_flag: `:checkered_flag:` when fixing something on Windows 23 | - :bug: `:bug:` when fixing a bug 24 | - :fire: `:fire:` when removing code or files 25 | - :green_heart: `:green_heart:` when fixing the CI build 26 | - :white_check_mark: `:white_check_mark:` when adding tests 27 | - :lock: `:lock:` when dealing with security 28 | - :arrow_up: `:arrow_up:` when upgrading dependencies 29 | - :arrow_down: `:arrow_down:` when downgrading dependencies 30 | - :shirt: `:shirt:` when removing linter warnings 31 | 32 | **Heavily borrowed from [Atom Contributing Guidelines](https://raw.githubusercontent.com/atom/atom/master/CONTRIBUTING.md) 33 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Walmart Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export NODE_ENV = test 2 | 3 | .PHONY: clean test test-clean test-travis publish build bootstrap 4 | 5 | build: clean 6 | ./scripts/build.sh 7 | 8 | watch: clean 9 | ./scripts/build.sh --watch 10 | 11 | lint: 12 | node node_modules/.bin/eslint packages/*/src 13 | 14 | clean: test-clean 15 | rm -rf coverage 16 | rm -rf packages/*/lib 17 | 18 | test: lint 19 | #./scripts/test.sh 20 | #make test-clean 21 | 22 | test-clean: 23 | rm -rf packages/*/test/tmp 24 | rm -rf packages/*/test-fixtures.json 25 | 26 | test-travis: bootstrap lint build test 27 | 28 | bootstrap: 29 | npm install 30 | node node_modules/.bin/babel-node scripts/bootstrap.js 31 | 32 | publish: 33 | git pull --rebase 34 | make test 35 | make build 36 | node scripts/publish.js 37 | make clean 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *** 2 | # NOTICE: 3 | 4 | ## This repository has been archived and is not supported. 5 | 6 | [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) 7 | *** 8 | NOTICE: SUPPORT FOR THIS PROJECT HAS ENDED 9 | 10 | This projected was owned and maintained by Walmart. This project has reached its end of life and Walmart no longer supports this project. 11 | 12 | We will no longer be monitoring the issues for this project or reviewing pull requests. You are free to continue using this project under the license terms or forks of this project at your own risk. This project is no longer subject to Walmart's bug bounty program or other security monitoring. 13 | 14 | 15 | ## Actions you can take 16 | 17 | We recommend you take the following action: 18 | 19 | * Review any configuration files used for build automation and make appropriate updates to remove or replace this project 20 | * Notify other members of your team and/or organization of this change 21 | * Notify your security team to help you evaluate alternative options 22 | 23 | ## Forking and transition of ownership 24 | 25 | For [security reasons](https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_stealer/), Walmart does not transfer the ownership of our primary repos on Github or other platforms to other individuals/organizations. Further, we do not transfer ownership of packages for public package management systems. 26 | 27 | If you would like to fork this package and continue development, you should choose a new name for the project and create your own packages, build automation, etc. 28 | 29 | Please review the licensing terms of this project, which continue to be in effect even after decommission. 30 | 31 | React Native Cropping Components 32 | ================================ 33 | # bolt [DEPRECATED REPO] 34 | 35 | ## Packages 36 | 37 | The `bolt` repository is home of multiple packages that belong to the bolt suite of tools. This helps keep versioning consistent and makes working on the packages themselves much easier than having them each in separate repositories. 38 | 39 | ### `bolt` suite 40 | 41 | [packages/bolt]() is the meta-task runner's core, which includes `webpack`, `eslint`, `karma`, `mocha` and `chai`. 42 | 43 | [packages/bolt-cli]() is the thin globally installed CLI runner that allows a developer to run `bolt` commands by providing access to the project's locally installed `bolt` instance. 44 | 45 | [packages/bolt-standard-flux]() is a `bolt-standard` configuration set for apps, which deviates slightly from a component library configuration set. 46 | 47 | [packages/bolt-standard-component-lib]() is a work in progress and an attempt to abstract what's unique about component libraries out into their own `bolt-standard` configuration set, rather than having them live in the `bolt` package. 48 | 49 | ## Contributing 50 | 51 | ## Development 52 | 53 | **The development environment requires `make`, so it's limited to \*nix systems** 54 | 55 | When starting development, clone down the repository: 56 | 57 | ``` 58 | $ git clone git@github.com:walmartreact/bolt.git && cd bolt 59 | ``` 60 | 61 | ### bootstrapping 62 | 63 | Once you're in the `bolt` directory, you can run: 64 | 65 | ``` 66 | $ make bootstrap 67 | ``` 68 | 69 | `bootstrap` will: 70 | 71 | - run an `npm install` at the root level of the project 72 | - iteratively `npm install` for all `packages` 73 | - iteratively create links for all `packages` using `npm link` 74 | 75 | Now you're ready to start developing `bolt` packages. 76 | 77 | ### watch 78 | 79 | Once you've bootstrapped the project and you want to start developing, the most sane way to do so is to run: 80 | 81 | ``` 82 | $ make watch 83 | ``` 84 | 85 | Running this command will watch all packages for changes and run them through `babel` so any projects that are using `bolt` will automatically be able to use the features you're developing within the `packages`. 86 | 87 | ### publishing 88 | 89 | If you have rights to publish any of these `packages`, the correct way to `publish` is to run: 90 | 91 | ``` 92 | $ make publish 93 | ``` 94 | 95 | This will: 96 | 97 | - ask you for the type of version change you're looking to make 98 | - look for any changes to your project from the previous version and update the version 99 | - publish the packages to npm 100 | 101 | One of the great advantages to publishing this way is that all versions are consistent with the version they should be published for based on what `bolt` itself is at, so it makes it a lot easier to keep versioning more consistent and easier to infer for users. 102 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.0.12 -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "babel": "^5.8.23", 5 | "babel-eslint": "^4.1.3", 6 | "eslint": "^1.6.0", 7 | "eslint-config-defaults": "^7.0.1", 8 | "eslint-plugin-filenames": "^0.1.2", 9 | "eslint-plugin-react": "^3.6.2", 10 | "flow": "^0.2.3", 11 | "mocha": "^2.3.3", 12 | "readline-sync": "^1.2.21", 13 | "semver": "^5.0.3", 14 | "shelljs": "^0.5.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Walmart Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /packages/bolt-standard-flux/README.md: -------------------------------------------------------------------------------- 1 | # standard-flux 2 | 3 | An electrode standard configuration and task for building application. 4 | 5 | Meant to be used with `bolt` [WalmartReact/bolt](https://github.com/walmartreact/electrode-bolt) 6 | 7 | ## Usage 8 | 9 | Within your project directory where `bolt` is also a dependency: 10 | 11 | ``` 12 | $ npm install bolt-standard-flux 13 | ``` 14 | 15 | Now whenever you run `bolt` it will use the scripts preferred for the standard recommended `flux` architecture. 16 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/karma/entry.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * Test setup for client-side tests. 5 | * 6 | * Intended for: 7 | * - Karma tests: `npm run test-client` 8 | * - Browser tests: `http://localhost:3000/test/client/test.html` 9 | */ 10 | /*globals window:false*/ 11 | var chai = require("chai"); 12 | var sinonChai = require("sinon-chai"); 13 | var path = require("path"); 14 | 15 | // -------------------------------------------------------------------------- 16 | // Chai / Sinon / Mocha configuration. 17 | // -------------------------------------------------------------------------- 18 | // Exports 19 | window.expect = chai.expect; 20 | 21 | // Plugins 22 | chai.use(sinonChai); 23 | 24 | // Mocha (part of static include). 25 | window.mocha.setup({ 26 | ui: "bdd", 27 | bail: false 28 | }); 29 | 30 | // -------------------------------------------------------------------------- 31 | // Bootstrap 32 | // -------------------------------------------------------------------------- 33 | // Use webpack to include all app code _except_ the entry point so we can get 34 | // code coverage in the bundle, whether tested or not. 35 | var srcReq = require.context("client", true, /^((?!app).)*\.jsx?$/); 36 | srcReq.keys().map(srcReq); 37 | 38 | // Use webpack to infer and `require` tests automatically. 39 | var testsReq = require.context("test", true, /\.spec.jsx?$/); 40 | testsReq.keys().map(testsReq); 41 | 42 | // Only start mocha in browser. 43 | if (!window.__karma__) { 44 | window.mocha.run(); 45 | } 46 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/karma/karma.conf.coverage.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var path = require("path"); 3 | 4 | /* 5 | * Karma Configuration: "coverage" version. 6 | * 7 | * This configuration is the same as basic one-shot version, just with coverage. 8 | */ 9 | var webpackCovCfg = require("../webpack/webpack.config.coverage"); 10 | 11 | module.exports = function (config) { 12 | require("./karma.conf")(config); 13 | config.set({ 14 | reporters: ["spec", "coverage"], 15 | webpack: webpackCovCfg, 16 | coverageReporter: { 17 | reporters: [ 18 | { type: "json", file: "coverage.json" }, 19 | { type: "lcov" }, 20 | { type: "text" } 21 | ], 22 | dir: path.join(process.cwd(), "coverage/client") 23 | } 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/karma/karma.conf.dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | * Karma Configuration: "dev" version. 5 | * 6 | * This configuration relies on a `webpack-dev-server` already running and 7 | * bundling `webpack.config.test.js` on port 3001. If this is not running, 8 | * then the alternate `karma.conf.js` file will _also_ run the webpack dev 9 | * server during the test run. 10 | */ 11 | module.exports = function (config) { 12 | config.set({ 13 | frameworks: ["mocha", "phantomjs-shim"], 14 | reporters: ["spec"], 15 | browsers: ["PhantomJS"], 16 | basePath: process.cwd(), // repository root. 17 | files: [ 18 | // Sinon has issues with webpack. Do global include. 19 | "./node_modules/electrode-bolt/node_modules/sinon/pkg/sinon.js", 20 | // Test bundle (must be created via `npm run dev|hot|server-test`) 21 | "http://127.0.0.1:8080/assets/bundle.js" 22 | ], 23 | port: 9999, 24 | singleRun: true, 25 | client: { 26 | mocha: { 27 | ui: "bdd" 28 | } 29 | }, 30 | plugins: [ 31 | require("karma-mocha"), 32 | require("karma-spec-reporter"), 33 | require("karma-phantomjs-shim"), 34 | require("karma-phantomjs-launcher") 35 | ] 36 | }); 37 | }; 38 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/karma/karma.conf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var path = require("path"); 4 | 5 | var webpackCfg = require("../webpack/webpack.config.test"); 6 | 7 | module.exports = function (config) { 8 | config.set({ 9 | basePath: process.cwd(), 10 | frameworks: ["mocha", "sinon-chai", "phantomjs-shim"], 11 | files: [ 12 | // Sinon has issues with webpack. Do global include. 13 | "./node_modules/electrode-bolt/node_modules/sinon/pkg/sinon.js", 14 | "./node_modules/bolt-standard-flux/config/karma/entry.js" 15 | ], 16 | preprocessors: { 17 | "./node_modules/bolt-standard-flux/config/karma/entry.js": ["webpack"] 18 | }, 19 | webpack: webpackCfg, 20 | webpackServer: { 21 | port: 3002, // Choose a non-conflicting port (3000 app, 3001 test dev) 22 | quiet: false, 23 | noInfo: true, 24 | stats: { 25 | assets: false, 26 | colors: true, 27 | version: false, 28 | hash: false, 29 | timings: false, 30 | chunks: false, 31 | chunkModules: false 32 | } 33 | }, 34 | exclude: [], 35 | port: 8080, 36 | logLevel: config.LOG_INFO, 37 | colors: true, 38 | autoWatch: false, 39 | browsers: ["PhantomJS"], 40 | reporters: ["spec", "coverage"], 41 | browserNoActivityTimeout: 60000, 42 | plugins: [ 43 | require("karma-coverage"), 44 | require("karma-mocha"), 45 | require("karma-mocha-reporter"), 46 | require("karma-phantomjs-launcher"), 47 | require("karma-firefox-launcher"), 48 | require("karma-sinon-chai"), 49 | require("karma-webpack"), 50 | require("karma-spec-reporter"), 51 | require("karma-phantomjs-shim") 52 | ], 53 | coverageReporter: { 54 | reporters: [ 55 | { type: "json", file: "coverage.json" }, 56 | { type: "lcov" }, 57 | { type: "text" } 58 | ], 59 | dir: path.join(process.cwd(), "coverage/client") 60 | }, 61 | captureTimeout: 100000, 62 | singleRun: true 63 | }); 64 | }; 65 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/webpack/webpack.config.coverage.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * Webpack frontend test (w/ coverage) configuration. 5 | */ 6 | var _ = require("lodash"); 7 | var testCfg = require("./webpack.config.test"); 8 | 9 | module.exports = _.merge({}, testCfg, { 10 | module: { 11 | preLoaders: [ 12 | // Manually instrument client code for code coverage. 13 | // https://github.com/deepsweet/isparta-loader handles ES6 + normal JS. 14 | { 15 | test: /(test|client)\/.*\.jsx?$/, 16 | exclude: /node_modules\//, 17 | loader: "isparta?{ babel: { stage: 1 } }" 18 | } 19 | ], 20 | loaders: testCfg.module.loaders 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/webpack/webpack.config.dev.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Webpack dev configuration 3 | */ 4 | var path = require("path"); 5 | var webpack = require("webpack"); 6 | var base = require("./webpack.config"); 7 | var CleanPlugin = require("clean-webpack-plugin"); 8 | var ExtractTextPlugin = require("extract-text-webpack-plugin"); 9 | var autoprefixer = require("autoprefixer-stylus"); 10 | 11 | module.exports = { 12 | cache: true, 13 | context: base.context, 14 | entry: base.entry, 15 | output: { 16 | path: path.join(process.cwd(), "dist/js"), 17 | filename: "bundle.dev.js", 18 | publicPath: "http://127.0.0.1:2992/js" 19 | }, 20 | module: base.module, 21 | stylus: base.stylus, 22 | resolve: base.resolve, 23 | resolveLoader: base.resolveLoader, 24 | devtool: "eval-source-map", 25 | plugins: [ 26 | new ExtractTextPlugin("style.css"), 27 | new webpack.NoErrorsPlugin() 28 | ] 29 | }; 30 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/webpack/webpack.config.hot.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Webpack hot configuration 3 | */ 4 | var path = require("path"); 5 | var base = require("./webpack.config.dev"); 6 | var webpack = require("webpack"); 7 | var CleanPlugin = require("clean-webpack-plugin"); 8 | var ExtractTextPlugin = require("extract-text-webpack-plugin"); 9 | var autoprefixer = require("autoprefixer-stylus"); 10 | 11 | module.exports = { 12 | cache: true, 13 | context: base.context, 14 | entry: [ 15 | "webpack-dev-server/client?http://127.0.0.1:3000", 16 | "webpack/hot/only-dev-server", 17 | base.entry 18 | ], 19 | output: base.output, 20 | module: { 21 | // Copy this because of `react-hot` injection. 22 | loaders: [ 23 | { test: /\.js(x|)?$/, include: path.join(process.cwd(), "client"), 24 | loaders: ["react-hot", "babel-loader"] }, 25 | { test: /\.styl$/, 26 | loader: ExtractTextPlugin.extract( 27 | "style-loader", "css-loader!stylus-loader") }, 28 | { test: /\.woff(2)?$/, 29 | loader: "url-loader?limit=10000&minetype=application/font-woff" }, 30 | { test: /\.(ttf|eot|svg|png)$/, 31 | loader: "file-loader" } 32 | ] 33 | }, 34 | stylus: base.stylus, 35 | resolve: base.resolve, 36 | resolveLoader: base.resolveLoader, 37 | devtool: "eval-source-map", 38 | plugins: base.plugins 39 | }; 40 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require("webpack"); 2 | var path = require("path"); 3 | var boltStandardNodeModules = path.join(__dirname, "../../", "node_modules"); 4 | var boltNodeModules = path.join(__dirname, "../../../electrode-bolt", "node_modules"); 5 | var CleanPlugin = require("clean-webpack-plugin"); 6 | var ExtractTextPlugin = require("extract-text-webpack-plugin"); 7 | var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin; 8 | var autoprefixer = require("autoprefixer-stylus"); 9 | 10 | module.exports = { 11 | cache: true, 12 | context: path.join(process.cwd(), "client"), 13 | entry: "./app.jsx", 14 | output: { 15 | path: path.join(process.cwd(), "dist/js"), 16 | filename: "bundle.[hash].js" 17 | }, 18 | module: { 19 | loaders: [ 20 | { test: /\.jsx?$/, include: path.join(process.cwd(), "client"), 21 | loaders: ["babel-loader?optional=runtime"] }, 22 | { test: /\.styl$/, 23 | loader: ExtractTextPlugin.extract( 24 | "style-loader", "css-loader!stylus-loader") }, 25 | { test: /\.woff(2)?$/, 26 | loader: "url-loader?limit=10000&minetype=application/font-woff" }, 27 | { test: /\.(ttf|eot|svg|png)$/, 28 | loader: "file-loader" } 29 | ] 30 | }, 31 | stylus: { 32 | use: [autoprefixer({ browsers: ["last 2 versions"] })] 33 | }, 34 | resolve: { 35 | root: [boltStandardNodeModules, boltNodeModules, process.cwd()], 36 | modulesDirectories: ["node_modules", "client", "node_modules/@walmart"], 37 | extensions: ["", ".js", ".jsx"] 38 | }, 39 | resolveLoader: { 40 | root: [boltNodeModules, process.cwd()] 41 | }, 42 | plugins: [ 43 | // Clean 44 | new CleanPlugin(["dist"]), 45 | new ExtractTextPlugin("style.[hash].css"), 46 | // Optimize 47 | new webpack.optimize.DedupePlugin(), 48 | new webpack.optimize.UglifyJsPlugin(), 49 | new webpack.DefinePlugin({ 50 | "process.env": { 51 | // Signal production mode for React JS libs. 52 | NODE_ENV: JSON.stringify("production") 53 | } 54 | }), 55 | new webpack.SourceMapDevToolPlugin( 56 | "../map/bundle.[hash].js.map", 57 | "\n//# sourceMappingURL=http://127.0.0.1:3001/dist/map/[url]" 58 | ), 59 | new StatsWriterPlugin({ 60 | filename: "../server/stats.json" 61 | }) 62 | ] 63 | }; 64 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/config/webpack/webpack.config.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Webpack frontend test configuration. 4 | */ 5 | var path = require("path"); 6 | var _ = require("lodash"); 7 | var prodCfg = require("./webpack.config"); 8 | 9 | console.log(__dirname); 10 | 11 | module.exports = { 12 | cache: true, 13 | context: __dirname, 14 | entry: "../karma/entry", 15 | output: { 16 | path: process.cwd(), 17 | filename: "bundle.js", 18 | publicPath: "/assets/" 19 | }, 20 | resolve: _.merge({}, prodCfg.resolve, { 21 | alias: { 22 | client: path.join(process.cwd(), "client") 23 | } 24 | }), 25 | resolveLoader: prodCfg.resolveLoader, 26 | module: { 27 | loaders: [prodCfg.module.loaders[0]] 28 | }, 29 | devtool: "#source-map" 30 | }; 31 | -------------------------------------------------------------------------------- /packages/bolt-standard-flux/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bolt-standard-flux", 3 | "version": "1.0.11", 4 | "description": "Opinionated meta config runner for react components", 5 | "scripts": { 6 | "lint-client": "eslint --ext .js,.jsx -c node_modules/electrode-bolt/config/eslint/.eslintrc-react client templates", 7 | "lint-client-test": "eslint --ext .js,.jsx -c node_modules/electrode-bolt/config/eslint/.eslintrc-react-test test/client", 8 | "lint-server": "eslint -c node_modules/electrode-bolt/config/eslint/.eslintrc-node server", 9 | "lint-server-test": "eslint -c node_modules/electrode-bolt/config/eslint/.eslintrc-node test/server test/func", 10 | "lint": "bolt lint-client && bolt lint-client-test && bolt lint-server && bolt lint-server-test", 11 | "start": "node server/index.js", 12 | "server": "nodemon --watch client --watch server --ext js,jsx server/index.js", 13 | "server-dev": "webpack-dev-server --config node_modules/bolt-standard-flux/config/webpack/webpack.config.dev.js --progress --colors --port 2992", 14 | "server-hot": "webpack-dev-server --config node_modules/bolt-standard-flux/config/webpack/webpack.config.hot.js --hot --progress --colors --port 2992 --inline", 15 | "sources": "http-server -p 3001 .", 16 | "watch": "webpack --watch", 17 | "prod": "bolt watch & bolt server & bolt sources", 18 | "dev": "bolt server-dev & WEBPACK_DEV=true bolt server", 19 | "hot": "bolt server-hot & WEBPACK_DEV=true bolt server", 20 | "build": "webpack --config node_modules/bolt-standard-flux/config/webpack/webpack.config.js", 21 | "test-frontend": "karma start node_modules/bolt-standard-flux/config/karma/karma.conf.js --colors", 22 | "test-frontend-cov": "karma start node_modules/bolt-standard-flux/config/karma/karma.conf.coverage.js --colors", 23 | "test-frontend-ci": "karma start --browsers PhantomJS,Firefox node_modules/bolt-standard-flux/config/karma/karma.conf.coverage.js --colors", 24 | "test-frontend-dev": "karma start node_modules/bolt-standard-flux/config/karma/karma.conf.dev.js --colors" 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "git@github.com:walmartreact/bolt-standard-flux.git" 29 | }, 30 | "author": "chaseadamsio", 31 | "license": "MIT", 32 | "bugs": { 33 | "url": "https://github.com/walmartreact/bolt-standard-flux/issues" 34 | }, 35 | "homepage": "https://github.com/walmartreact/bolt-standard-flux#readme", 36 | "dependencies": { 37 | "autoprefixer-stylus": "^0.7.1", 38 | "babel": "^5.8.21", 39 | "babel-core": "^5.8.22", 40 | "babel-eslint": "^4.0.10", 41 | "babel-loader": "^5.3.2", 42 | "chai": "^3.2.0", 43 | "clean-webpack-plugin": "^0.1.3", 44 | "css-loader": "^0.16.0", 45 | "eslint": "^1.2.0", 46 | "eslint-config-defaults": "^4.1.0", 47 | "eslint-plugin-filenames": "^0.1.2", 48 | "eslint-plugin-react": "^3.2.3", 49 | "extract-text-webpack-plugin": "^0.9.1", 50 | "file-loader": "^0.8.4", 51 | "isparta-loader": "^0.2.0", 52 | "karma": "^0.13.9", 53 | "karma-chrome-launcher": "^0.2.0", 54 | "karma-coverage": "^0.4.2", 55 | "karma-firefox-launcher": "^0.1.6", 56 | "karma-ie-launcher": "^0.2.0", 57 | "karma-mocha": "^0.2.0", 58 | "karma-mocha-reporter": "^1.1.1", 59 | "karma-phantomjs-launcher": "^0.2.0", 60 | "karma-phantomjs-shim": "^1.0.0", 61 | "karma-safari-launcher": "^0.1.1", 62 | "karma-sauce-launcher": "^0.2.14", 63 | "karma-sinon-chai": "^1.0.0", 64 | "karma-spec-reporter": "0.0.20", 65 | "karma-webpack": "^1.7.0", 66 | "lodash": "^3.10.1", 67 | "raw-loader": "^0.5.1", 68 | "react": "^0.14.0", 69 | "react-dom": "^0.14.0", 70 | "react-hot-loader": "^1.2.8", 71 | "react-tools": "^0.13.2", 72 | "sinon": "^1.16.1", 73 | "sinon-chai": "^2.8.0", 74 | "style-loader": "^0.12.3", 75 | "stylus-loader": "^1.2.1", 76 | "url-loader": "^0.5.6", 77 | "webpack": "^1.12.9", 78 | "webpack-dev-server": "^1.10.1", 79 | "webpack-stats-plugin": "^0.1.0" 80 | } 81 | } -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/.npmignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walmartlabs/bolt/7ef19f4bbb05f29c9d4cbfe6f86f200fe5263569/packages/electrode-bolt-cli/.npmignore -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | * Use the present tense ("Add feature" not "Added feature") 4 | * Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 5 | * Limit the first line to 72 characters or less 6 | * Reference issues and pull requests liberally 7 | * Consider starting the commit message with an applicable emoji: 8 | - :art: `:art:` when improving the format/structure of the code 9 | - :bulb: `:bulb:` new idea 10 | - :construction: `:construction:` work in progress 11 | - :heavy_plus_sign: `:heavy_plus_sign:` when adding feature 12 | - :heavy_minus_sign: `:heavy_minus_sign:` when removing feature 13 | - :speaker: `:speaker:` when adding logging 14 | - :mute: `:mute:` when reducing logging 15 | - :racehorse: `:racehorse:` when improving performance 16 | - :anchor: `:anchor:` when refactoring 17 | - :wrench: `:wrench:` when working on tooling 18 | - :non-potable_water: `:non-potable_water:` when plugging memory leaks 19 | - :memo: `:memo:` when writing docs 20 | - :penguin: `:penguin:` when fixing something on Linux 21 | - :apple: `:apple:` when fixing something on Mac OS 22 | - :checkered_flag: `:checkered_flag:` when fixing something on Windows 23 | - :bug: `:bug:` when fixing a bug 24 | - :fire: `:fire:` when removing code or files 25 | - :green_heart: `:green_heart:` when fixing the CI build 26 | - :white_check_mark: `:white_check_mark:` when adding tests 27 | - :lock: `:lock:` when dealing with security 28 | - :arrow_up: `:arrow_up:` when upgrading dependencies 29 | - :arrow_down: `:arrow_down:` when downgrading dependencies 30 | - :shirt: `:shirt:` when removing linter warnings 31 | 32 | **Heavily borrowed from [Atom Contributing Guidelines](https://raw.githubusercontent.com/atom/atom/master/CONTRIBUTING.md) 33 | -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/README.md: -------------------------------------------------------------------------------- 1 | # bolt-cli 2 | 3 | > `bolt` command line interface. 4 | 5 | Install this globally to have access to the bolt command. _This is not bolt itself,_ that can be found at [walmartreact/bolt](https://github.com/walmartreact/electrode-bolt). 6 | 7 | ``` 8 | npm install -g bolt-cli 9 | ``` 10 | 11 | ## Usage 12 | 13 | ### Local Bolt dependency 14 | 15 | Within a package that has `bolt` installed as a dependency: 16 | 17 | To list bolt tasks, you can simply run `bolt`. 18 | 19 | To run a `bolt` task, run `bolt `. If no task exists, bolt will let you know. 20 | 21 | ## Notes 22 | 23 | - This tool isn't required for using the `bolt` tool, but it allows you to run `bolt` tasks from the command line easily rather than having to have bolt itself installed globally or having all of your `npm run` tasks directly linked to every task `bolt` provides. 24 | 25 | ## Contributing 26 | 27 | ### Scripts 28 | 29 | | Command | Action | 30 | | `link:dev` | Performs a symlink to your `npm prefix -g` for ease of development | 31 | | `dev` | Watches `src` for changes, transpiles to `bin/bolt` with `babel` | 32 | | `build` | Makes `bin` directory if it doesn't exist, transpiles `src` to `bin/bolt` with `babel` | 33 | 34 | ### Publishing 35 | 36 | `src/bolt-cli.js` is built to `bin/bolt` on `npm run prepublish` 37 | -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/bin/bolt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | require("../lib/bolt-cli"); 4 | -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electrode-bolt-cli", 3 | "version": "1.0.7", 4 | "description": "A CLI for electrode-bolt", 5 | "repository": "walmartreact/electrode-bolt", 6 | "bin": { 7 | "bolt": "bin/bolt" 8 | }, 9 | "scripts": { 10 | "dev": "babel src/bolt-cli.js --watch --out-file lib/bolt-cli.js", 11 | "build": "if [ ! -e lib ]; then mkdir lib; fi && babel src --out-file lib/bolt-cli.js", 12 | "prepublish": "npm run build", 13 | "test": "node bin/bolt test" 14 | }, 15 | "author": "", 16 | "license": "ISC", 17 | "dependencies": { 18 | "findup-sync": "^0.3.0", 19 | "jsonfile": "^2.2.3", 20 | "mkdirp": "^0.5.1", 21 | "resolve": "^1.1.6", 22 | "step": "0.0.6" 23 | }, 24 | "devDependencies": { 25 | "babel": "^5.8.23" 26 | } 27 | } -------------------------------------------------------------------------------- /packages/electrode-bolt-cli/src/bolt-cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import findup from "findup-sync"; 4 | import resolve from "resolve"; 5 | 6 | const baseDir = process.cwd(); 7 | let boltPath; 8 | 9 | try { 10 | boltPath = resolve.sync("electrode-bolt", { basedir: baseDir, moduleDirectory: "node_modules" }); 11 | } catch (e) { 12 | boltPath = findup("lib/bolt-cli"); 13 | 14 | if (!boltPath) { 15 | /* eslint-disable no-console */ 16 | console.log(`Unable to find local bolt. Be sure to initialze a new npm project and run: 17 | npm install electrode-bolt --save-dev`); 18 | /* eslint-enable no-console */ 19 | /* eslint-disable no-process-exit */ 20 | process.exit(99); 21 | /* eslint-enable no-process-exit */ 22 | } 23 | } 24 | 25 | require(boltPath); 26 | -------------------------------------------------------------------------------- /packages/electrode-bolt/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## 0.1.6 6 | 7 | - [`d5aab5f`](https://github.com/walmartreact/electrode-bolt/commit/d5aab5fe37a17d5b187f5bf9386a169f67d5b709) Upgrade `eslint-config-defaults` to `7.0.0` 8 | - [`3cd90ba`](https://github.com/walmartreact/electrode-bolt/commit/3cd90baa8850f2f42d52a42c8f6d1e316867090d) Chore change port for `demo` and `dev` server to `4000` 9 | - [`6395d93`](https://github.com/walmartreact/electrode-bolt/commit/6395d93279faf4a55c4fefc52710554051594c56) Remove all `open` tasks since they weren't working in the first place 10 | -------------------------------------------------------------------------------- /packages/electrode-bolt/README.md: -------------------------------------------------------------------------------- 1 | # bolt 2 | 3 | > An opinionated meta config runner for react components, doing the heavy lifting so you don't have to. 4 | 5 | Bolt makes creating new react component libraries easy. 6 | 7 | It provides tasks for different phases of a component library development cycle, such as: 8 | 9 | - `dev` and `hot` - the ability to 10 | - `lint` - Run `eslint` on `demo`, `src`, `test` 11 | - `test` - Run tests in `test/client/` 12 | - `build` - Generate an npm package 13 | 14 | ## Install 15 | 16 | To get the most out of `bolt`, install the command line tool: 17 | ``` 18 | $ npm install bolt-cli -g 19 | ``` 20 | 21 | This will allow you to directly run `bolt` from the command line, instead of having to put it behind `scripts` in your `package.json`. 22 | 23 | within a react component library, run: 24 | 25 | ```sh 26 | $ npm install bolt --save 27 | ``` 28 | 29 | 1. in your `package.json`, replace existing scripts with `bolt ` where the task is the name of the task being replaced. For instance: `"cov-frontend": "istanbul check-coverage 'coverage/client/*/coverage.json'"` would be replaced with `"cov-frontend": "bolt cov-frontend"`. 30 | 1. Enjoy seamless integration with pre-existing configs for your opininated `react` component! 31 | 32 | **If you're using `bolt-cli` (`npm install bolt-cli -g`), run `bolt` within your package to see the scripts that are available to you.** 33 | 34 | ## Usage 35 | 36 | Running `npm run ` will run the appropriate bolt task that's in your `package.json`. 37 | 38 | ## Unique Configuration 39 | 40 | So you don't want to use a `bolt` command out of the box? No problem! 41 | 42 | You can override a command in _your_ `package.json` and run `bolt ` and `bolt` will opt for your script over the script it provides. 43 | 44 | For example, say you run: 45 | 46 | ``` 47 | $ bolt clean-dist 48 | ``` 49 | 50 | `bolt` will run `rimraf` on your `dist` directory. If you wanted it to do something else such as echo "I love electricity!", you can put the following script in your `scripts` object: 51 | 52 | ``` 53 | "scripts": { 54 | "clean-dist": "echo 'I love electricity!'" 55 | ... 56 | } 57 | ``` 58 | 59 | Now when you run `bolt clean-dist`, rather than it running `rimraf dist`, it will echo "I love electricity!". 60 | 61 | ## Why? 62 | 63 | Going through and modifying `*.config*` files in _every_ react component library you have (which correlates 1:1 to a git repository) is a huge pain in the butt, it's a lot of copy/pasta and no one should 1) have to do that and 2) have to endure the possible degradation over time of human copy/pasta. 64 | 65 | This package tries to solve the problem of creating a "meta-monolith" that stands behind our components so people can just build cool stuff and not worry about all the config that goes into keeping a component up to date. 66 | 67 | Maybe one day it won't be opinionated. But this day? Not this day. 68 | 69 | ## Opinionated Directory Structure 70 | 71 | ``` 72 | |-- my_project 73 | | |-- package.json 74 | | |-- demo 75 | | | |-- index.html 76 | | | |-- demo.jsx 77 | | |-- dist 78 | | |-- src 79 | | | |-- components 80 | | | | |-- component.jsx 81 | | | |-- index.js 82 | | |-- docs 83 | | |-- test 84 | | |-- client 85 | | |-- component 86 | | |-- component.spec.jsx 87 | ``` 88 | 89 | ## Contributing 90 | 91 | See [CONTRIBUTING.md](/CONTRIBUTING.md) for how to contribute. 92 | -------------------------------------------------------------------------------- /packages/electrode-bolt/bin/bolt.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | var Bolt = require("../lib/bolt"); 5 | var bolt = new Bolt(process); 6 | bolt.run(); 7 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-base: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "eslint-config-defaults/configurations/eslint.js" 4 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-bolt: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "eslint-config-defaults/configurations/walmart/es5-node" 4 | rules: 5 | "no-console": 0 6 | "no-process-exit": 0 7 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-node: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "eslint-config-defaults/configurations/walmart/es5-node" 4 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-react: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "eslint-config-defaults/configurations/walmart/es6-react" 4 | globals: 5 | window: false 6 | ReactElement: false 7 | rules: 8 | "react/jsx-boolean-value": 0 9 | "react/jsx-closing-bracket-location": 0 10 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-react-demo: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "./.eslintrc-react" 4 | globals: 5 | document: false 6 | rules: 7 | "complexity": 0 8 | "max-len": 0 9 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/eslint/.eslintrc-react-test: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "eslint-config-defaults/configurations/walmart/es6-test" 4 | - "./.eslintrc-react" 5 | globals: 6 | document: false 7 | expect: false 8 | it: false 9 | sinon: false 10 | Element: false 11 | rules: 12 | "no-unused-expressions": 0 # for `chai.expect` 13 | "max-len": [2, 100, 2, {ignorePattern: "^\\s*(?:it|describe)\\(.*"}] 14 | "max-statements": 0 15 | "max-nested-callbacks": 0 16 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/istanbul/.istanbul.yml: -------------------------------------------------------------------------------- 1 | check: 2 | global: 3 | statements: 5 4 | functions: 5 5 | branches: 5 6 | lines: 5 7 | each: 8 | statements: 5 9 | functions: 5 10 | branches: 5 11 | lines: 5 12 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/karma/entry.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | require("babel-core/polyfill"); 4 | 5 | /** 6 | * Test setup for client-side tests. 7 | * 8 | * Intended for: 9 | * - Karma tests: `npm run test-client` 10 | * - Browser tests: `http://localhost:4000/test/client/test.html` 11 | */ 12 | /*globals window:false*/ 13 | var chai = require("chai"); 14 | var sinonChai = require("sinon-chai"); 15 | 16 | // -------------------------------------------------------------------------- 17 | // Chai / Sinon / Mocha configuration. 18 | // -------------------------------------------------------------------------- 19 | // Exports 20 | window.expect = chai.expect; 21 | 22 | // Plugins 23 | chai.use(sinonChai); 24 | 25 | // Mocha (part of static include). 26 | window.mocha.setup({ 27 | ui: "bdd", 28 | bail: false 29 | }); 30 | 31 | // -------------------------------------------------------------------------- 32 | // Bootstrap 33 | // -------------------------------------------------------------------------- 34 | // Use webpack to include all app code _except_ the entry point so we can get 35 | // code coverage in the bundle, whether tested or not. 36 | var srcReq = require.context("src", true, /\.jsx?$/); 37 | srcReq.keys().map(srcReq); 38 | 39 | // Use webpack to infer and `require` tests automatically. 40 | var testsReq = require.context("test", true, /\.spec.jsx?$/); 41 | testsReq.keys().map(testsReq); 42 | 43 | // Only start mocha in browser. 44 | if (!window.__karma__) { 45 | window.mocha.run(); 46 | } 47 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/karma/karma.conf.coverage.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | * Karma Configuration: "coverage" version. 5 | * 6 | * This configuration is the same as basic one-shot version, just with coverage. 7 | */ 8 | var webpackCovCfg = require("../webpack/webpack.config.coverage"); 9 | 10 | module.exports = function (config) { 11 | require("./karma.conf")(config); 12 | config.set({ 13 | reporters: ["spec", "coverage"], 14 | webpack: webpackCovCfg, 15 | coverageReporter: { 16 | reporters: [ 17 | { type: "json", file: "coverage.json" }, 18 | { type: "lcov" }, 19 | { type: "text" } 20 | ], 21 | dir: "coverage/client" 22 | } 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/karma/karma.conf.dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | * Karma Configuration: "dev" version. 5 | * 6 | * This configuration relies on a `webpack-dev-server` already running and 7 | * bundling `webpack.config.test.js` on port 3001. If this is not running, 8 | * then the alternate `karma.conf.js` file will _also_ run the webpack dev 9 | * server during the test run. 10 | */ 11 | module.exports = function (config) { 12 | config.set({ 13 | frameworks: ["mocha", "phantomjs-shim"], 14 | reporters: ["spec"], 15 | browsers: ["PhantomJS"], 16 | basePath: process.cwd(), // repository root. 17 | files: [ 18 | // Sinon has issues with webpack. Do global include. 19 | "./node_modules/electrode-bolt/node_modules/sinon/pkg/sinon.js", 20 | // Test bundle (must be created via `npm run dev|hot|server-test`) 21 | "http://127.0.0.1:8080/assets/bundle.js" 22 | ], 23 | port: 9999, 24 | singleRun: true, 25 | client: { 26 | mocha: { 27 | ui: "bdd" 28 | } 29 | }, 30 | plugins: [ 31 | require("karma-mocha"), 32 | require("karma-spec-reporter"), 33 | require("karma-phantomjs-shim"), 34 | require("karma-phantomjs-launcher") 35 | ] 36 | }); 37 | }; 38 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/karma/karma.conf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var path = require("path"); 4 | 5 | var webpackCfg = require("../webpack/webpack.config.test"); 6 | 7 | module.exports = function (config) { 8 | config.set({ 9 | basePath: process.cwd(), 10 | frameworks: ["mocha", "sinon-chai", "phantomjs-shim", "intl-shim"], 11 | files: [ 12 | // Sinon has issues with webpack. Do global include. 13 | "./node_modules/electrode-bolt/node_modules/sinon/pkg/sinon.js", 14 | "./node_modules/electrode-bolt/config/karma/entry.js" 15 | ], 16 | preprocessors: { 17 | "./node_modules/electrode-bolt/config/karma/entry.js": ["webpack"] 18 | }, 19 | webpack: webpackCfg, 20 | webpackServer: { 21 | port: 3002, // Choose a non-conflicting port (3000 app, 3001 test dev) 22 | quiet: false, 23 | noInfo: true, 24 | stats: { 25 | assets: false, 26 | colors: true, 27 | version: false, 28 | hash: false, 29 | timings: false, 30 | chunks: false, 31 | chunkModules: false 32 | } 33 | }, 34 | exclude: [], 35 | port: 8080, 36 | logLevel: config.LOG_INFO, 37 | colors: true, 38 | autoWatch: false, 39 | browsers: ["PhantomJS"], 40 | reporters: ["spec", "coverage"], 41 | browserNoActivityTimeout: 60000, 42 | plugins: [ 43 | require("karma-coverage"), 44 | require("karma-mocha"), 45 | require("karma-mocha-reporter"), 46 | require("karma-phantomjs-launcher"), 47 | require("karma-firefox-launcher"), 48 | require("karma-sinon-chai"), 49 | require("karma-webpack"), 50 | require("karma-spec-reporter"), 51 | require("karma-phantomjs-shim"), 52 | require("karma-intl-shim") 53 | ], 54 | coverageReporter: { 55 | reporters: [ 56 | { type: "json", file: "coverage.json" }, 57 | { type: "lcov" }, 58 | { type: "text" } 59 | ], 60 | dir: path.join(process.cwd(), "coverage/client") 61 | }, 62 | captureTimeout: 100000, 63 | singleRun: true 64 | }); 65 | }; 66 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.coverage.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * Webpack frontend test (w/ coverage) configuration. 5 | */ 6 | var _ = require("lodash"); 7 | var testCfg = require("./webpack.config.test"); 8 | 9 | module.exports = _.merge({}, testCfg, { 10 | module: { 11 | preLoaders: [ 12 | // Manually instrument client code for code coverage. 13 | // https://github.com/deepsweet/isparta-loader handles ES6 + normal JS. 14 | { 15 | test: /src\/.*\.jsx?$/, 16 | exclude: /(test|node_modules)\//, 17 | loader: "isparta?{ babel: { stage: 1 } }" 18 | } 19 | ] 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.demo.dev.js: -------------------------------------------------------------------------------- 1 | /*globals __dirname:false */ 2 | "use strict"; 3 | 4 | var webpack = require("webpack"); 5 | var path = require("path"); 6 | var base = require("./webpack.config"); 7 | 8 | var _ = require("lodash"); 9 | 10 | module.exports = { 11 | 12 | devServer: { 13 | port: (process.env.WEBPACK_DEVSERVER_PORT || "4000"), 14 | contentBase: path.join(process.cwd(), "demo"), 15 | noInfo: false 16 | }, 17 | 18 | output: { 19 | path: process.cwd(), 20 | filename: "bundle.js", 21 | publicPath: "/assets/" 22 | }, 23 | 24 | cache: true, 25 | devtool: "source-map", 26 | entry: { 27 | app: ["./demo/demo.jsx"] 28 | }, 29 | stats: { 30 | colors: true, 31 | reasons: true 32 | }, 33 | resolve: _.merge({}, base.resolve, { 34 | alias: { 35 | // Allow root import of `src/FOO` from ROOT/src. 36 | src: path.join(process.cwd(), "src") 37 | } 38 | }), 39 | resolveLoader: base.resolveLoader, 40 | module: base.module, 41 | plugins: [ 42 | new webpack.NoErrorsPlugin() 43 | ] 44 | }; 45 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.demo.hot.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var webpack = require("webpack"); 4 | var _ = require("lodash"); 5 | var base = require("./webpack.config.demo.dev"); 6 | 7 | // Update our own module version. 8 | var mod = _.cloneDeep(base.module); 9 | // First loader needs react hot. 10 | mod.loaders[0].loaders = ["react-hot"].concat(mod.loaders[0].loaders); 11 | base.devServer.hot = true; 12 | 13 | module.exports = _.merge({}, _.omit(base, "entry", "module"), { 14 | entry: { 15 | app: [ 16 | "webpack-dev-server/client?http://0.0.0.0:" + 17 | (process.env.WEBPACK_DEVSERVER_PORT || "4000"), // WebpackDevServer host and port 18 | "webpack/hot/only-dev-server", 19 | "./demo/demo.jsx" 20 | ] 21 | }, 22 | 23 | module: mod, 24 | plugins: [ 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoErrorsPlugin() 27 | ].concat(base.plugins) 28 | }); 29 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var webpack = require("webpack"); 4 | var config = require("./webpack.config"); 5 | 6 | config.plugins = [ 7 | new webpack.SourceMapDevToolPlugin("bundle.map") 8 | ]; 9 | 10 | // Export mutated base. 11 | module.exports = config; 12 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var webpack = require("webpack"); 4 | var path = require("path"); 5 | var boltNodeModules = path.join(__dirname, "../../", "node_modules"); 6 | 7 | module.exports = { 8 | cache: true, 9 | debug: false, 10 | devtool: "source-map", 11 | entry: path.join(process.cwd(), "index.js"), 12 | output: { 13 | path: path.join(process.cwd(), "dist"), 14 | filename: "bundle.js" 15 | }, 16 | module: { 17 | loaders: [{ 18 | test: /\.jsx?$/, 19 | exclude: [/node_modules/], 20 | loaders: ["babel-loader?stage=1"] 21 | }, { 22 | test: /\.json$/, 23 | loaders: ["json-loader"] 24 | }, { 25 | test: /\.css$/, 26 | loader: "style-loader!css-loader" 27 | }, { 28 | test: /\.styl$/, 29 | loader: "style-loader!css-loader!stylus-loader" 30 | }, { 31 | test: /\.(png|jpg|svg|gif)$/, 32 | loader: "url-loader?limit=8192" 33 | }] 34 | }, 35 | plugins: [ 36 | new webpack.optimize.DedupePlugin(), 37 | new webpack.optimize.UglifyJsPlugin({ 38 | compress: { 39 | warnings: false 40 | } 41 | }), 42 | new webpack.DefinePlugin({ 43 | // Signal production, so that webpack removes non-production code that 44 | // is in condtionals like: `if (process.env.NODE_ENV === "production")` 45 | "process.env.NODE_ENV": JSON.stringify("production") 46 | }), 47 | new webpack.SourceMapDevToolPlugin("[file].map") 48 | ], 49 | resolve: { 50 | root: [boltNodeModules, process.cwd()], 51 | modulesDirectories: ["node_modules"], 52 | extensions: ["", ".js", ".jsx"] 53 | }, 54 | resolveLoader: { 55 | root: [boltNodeModules, process.cwd()] 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /packages/electrode-bolt/config/webpack/webpack.config.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Webpack frontend test configuration. 4 | */ 5 | var path = require("path"); 6 | var _ = require("lodash"); 7 | var prodCfg = require("./webpack.config"); 8 | 9 | module.exports = { 10 | cache: true, 11 | context: path.join(process.cwd(), "test/client"), 12 | entry: "../../node_modules/electrode-bolt/config/karma/entry", 13 | output: { 14 | path: process.cwd(), 15 | filename: "bundle.js", 16 | publicPath: "/assets/" 17 | }, 18 | resolve: _.merge({}, prodCfg.resolve, { 19 | alias: { 20 | // Allow root import of `src/FOO` from ROOT/src. 21 | src: path.join(process.cwd(), "src") 22 | } 23 | }), 24 | resolveLoader: prodCfg.resolveLoader, 25 | module: prodCfg.module, 26 | devtool: "#source-map" 27 | }; 28 | -------------------------------------------------------------------------------- /packages/electrode-bolt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electrode-bolt", 3 | "version": "1.0.12", 4 | "description": "Opinionated meta config runner for react components", 5 | "scripts": { 6 | "dev": "bolt server-dev & bolt server-test", 7 | "hot": "bolt server-hot & bolt server-test", 8 | "lint-react-demo": "eslint --ext .js,.jsx -c ./node_modules/electrode-bolt/config/eslint/.eslintrc-react-demo demo/*.jsx --color", 9 | "lint-react-src": "eslint --ext .js,.jsx -c ./node_modules/electrode-bolt/config/eslint/.eslintrc-react src --color", 10 | "lint-react-test": "eslint --ext .js,.jsx -c ./node_modules/electrode-bolt/config/eslint/.eslintrc-react-test test/client --color", 11 | "lint": "bolt lint-react-demo && bolt lint-react-src && bolt lint-react-test", 12 | "clean-dist": "rimraf dist", 13 | "build-dist-min": "webpack --config node_modules/electrode-bolt/config/webpack/webpack.config.js --colors", 14 | "build-dist-dev": "webpack --config node_modules/electrode-bolt/config/webpack/webpack.config.dev.js --colors", 15 | "build-dist": "bolt clean-dist && bolt build-dist-min && bolt build-dist-dev", 16 | "clean-lib": "rimraf lib", 17 | "build-lib": "bolt clean-lib && babel --stage 1 src -d lib", 18 | "clean": "bolt clean-lib && bolt clean-dist", 19 | "build": "bolt build-lib && bolt build-dist", 20 | "server-dev": "webpack-dev-server --port 4000 --config node_modules/electrode-bolt/config/webpack/webpack.config.demo.dev.js --colors", 21 | "server-hot": "webpack-dev-server --port 4000 --config node_modules/electrode-bolt/config/webpack/webpack.config.demo.hot.js --colors", 22 | "server-test": "webpack-dev-server --port 3001 --config node_modules/electrode-bolt/config/webpack/webpack.config.test.js --colors", 23 | "cov-frontend": "istanbul check-coverage 'coverage/client/*/coverage.json' --config=node_modules/electrode-bolt/config/istanbul/.istanbul.yml", 24 | "test-frontend": "karma start node_modules/electrode-bolt/config/karma/karma.conf.js --colors", 25 | "test-frontend-cov": "karma start node_modules/electrode-bolt/config/karma/karma.conf.coverage.js --colors", 26 | "test-frontend-ci": "karma start --browsers PhantomJS,Firefox node_modules/electrode-bolt/config/karma/karma.conf.coverage.js --colors", 27 | "test-frontend-dev": "karma start node_modules/electrode-bolt/config/karma/karma.conf.dev.js --colors", 28 | "test": "npm run bolt:check-ci", 29 | "test-ci": "bolt test-frontend-ci", 30 | "test-cov": "bolt test-frontend-cov", 31 | "test-dev": "bolt test-frontend-dev", 32 | "check": "bolt lint && bolt check-cov && bolt cov-frontend", 33 | "check-ci": "bolt lint && bolt test-ci", 34 | "check-cov": "bolt lint && bolt test-cov", 35 | "check-dev": "bolt lint && bolt test-dev", 36 | "init": "node ./node_modules/electrode-bolt/lib/init.js", 37 | "bolt:test": "NODE_ENV=test mocha --require ./test/spec/entry.js --reporter spec --bail --check-leaks test --recursive --color --config=node_modules/electrode-bolt/config/istanbul/.istanbul.yml", 38 | "bolt:ci": "istanbul cover _mocha --report lcovonly -- -R spec --require ./test/spec/entry.js test --recursive --color --config=node_modules/electrode-bolt/config/istanbul/.istanbul.yml", 39 | "bolt:check-ci": "NODE_ENV=test npm run bolt:lint && npm run bolt:ci", 40 | "bolt:cov": "NODE_ENV=test istanbul cover _mocha -- -R spec --require ./test/spec/entry.js test --recursive --color --config=node_modules/electrode-bolt/config/istanbul/.istanbul.yml", 41 | "bolt:check-cov": "NODE_ENV=test npm run bolt:lint && npm run bolt:cov", 42 | "bolt:tap": "NODE_ENV=test istanbul cover _mocha -- -R tap --require ./test/spec/entry.js test --recursive --color --config=node_modules/electrode-bolt/config/istanbul/.istanbul.yml", 43 | "bolt:lint": "NODE_ENV=test eslint --ext .js -c ./config/eslint/.eslintrc-bolt bin config --color" 44 | }, 45 | "bin": { 46 | "bolt": "./bin/bolt.js" 47 | }, 48 | "main": "bin/bolt.js", 49 | "repository": "walmartreact/electrode-bolt", 50 | "author": { 51 | "name": "chaseadamsio" 52 | }, 53 | "license": "MIT", 54 | "bugs": { 55 | "url": "https://github.com/walmartreact/bolt/issues" 56 | }, 57 | "homepage": "https://github.com/walmartreact/bolt#readme", 58 | "dependencies": { 59 | "babel": "^5.8.21", 60 | "babel-core": "^5.8.22", 61 | "babel-eslint": "^4.0.10", 62 | "babel-loader": "^5.3.2", 63 | "chai": "^3.2.0", 64 | "chalk": "^1.1.1", 65 | "css-loader": "^0.16.0", 66 | "eslint": "~1.7.0", 67 | "eslint-config-defaults": "~7.0.0", 68 | "eslint-plugin-filenames": "~0.1.2", 69 | "eslint-plugin-react": "~3.6.3", 70 | "file-loader": "^0.8.4", 71 | "fs-extra": "^0.24.0", 72 | "isparta-loader": "^1.0.0", 73 | "istanbul": "^0.3.18", 74 | "json-loader": "^0.5.3", 75 | "jsonfile": "^2.2.2", 76 | "karma": "^0.13.9", 77 | "karma-chrome-launcher": "^0.2.0", 78 | "karma-coverage": "^0.4.2", 79 | "karma-firefox-launcher": "^0.1.6", 80 | "karma-ie-launcher": "^0.2.0", 81 | "karma-intl-shim": "^1.0.0", 82 | "karma-mocha": "^0.2.0", 83 | "karma-mocha-reporter": "^1.1.1", 84 | "karma-phantomjs-launcher": "^0.2.0", 85 | "karma-phantomjs-shim": "^1.0.0", 86 | "karma-safari-launcher": "^0.1.1", 87 | "karma-sauce-launcher": "^0.2.14", 88 | "karma-sinon-chai": "^1.0.0", 89 | "karma-spec-reporter": "0.0.20", 90 | "karma-webpack": "^1.7.0", 91 | "lodash": "^3.10.1", 92 | "mkdirp": "^0.5.1", 93 | "mocha": "^2.3.3", 94 | "phantomjs": "^1.9.18", 95 | "raw-loader": "^0.5.1", 96 | "react": "^0.14.0", 97 | "react-addons-test-utils": "^0.14.0", 98 | "react-dom": "^0.14.0", 99 | "react-hot-loader": "^1.2.8", 100 | "react-tools": "^0.13.2", 101 | "rimraf": "^2.4.0", 102 | "sinon": "^1.15.4", 103 | "sinon-chai": "^2.8.0", 104 | "style-loader": "^0.12.3", 105 | "stylus-loader": "^1.2.1", 106 | "url-loader": "^0.5.6", 107 | "webpack": "^1.11.0", 108 | "webpack-dev-server": "^1.10.1" 109 | }, 110 | "devDependencies": { 111 | "html-webpack-plugin": "^1.6.1", 112 | "proxyquire": "^1.7.2" 113 | }, 114 | "readme": "# bolt\n\n> An opinionated meta config runner for react components, doing the heavy lifting so you don't have to.\n\nProvides CLI access to things such as:\n\n- `webpack`\n- `eslint`\n- `karma`\n\nthrough `bolt`.\n\n## Install\n\nwithin an electrode package, run:\n\n```sh\n$ npm install electrode-bolt --save\n```\n\n1. in your `package.json`, replace existing scripts with `bolt ` where the task is the name of the task being replaced. For instance: `\"cov-frontend\": \"istanbul check-coverage 'coverage/client/*/coverage.json'\"` would be replaced with `\"cov-frontend\": \"bolt cov-frontend\"`.\n1. Enjoy seamless integration with pre-existing configs for your opininated `electrode` component!\n\n**Run `bolt` within your package to see the scripts that are available to you.**\n\n## Usage\n\nOnce you've followed the steps above, you should be able to not worry about using it. `bolt` does the work for you.\n\n## Unique Configuration\n\nSo you don't want to the `bolt` command out of the box? No problem!\n\nYou can override a command in _your_ `package.json` and run `bolt ` and `bolt` will opt for your script over the script it provides.\n\nFor example, say you run:\n\n```\n$ bolt clean-dist\n```\n\n`bolt` will run `rimraf` on your `dist` directory. If you wanted it to do something else such as echo \"I love electricity!\", you can put the following script in your `scripts` object:\n\n```\n\"scripts\": {\n \"clean-dist\": \"echo 'I love electricity!'\"\n ...\n}\n```\n\nNow when you run `bolt clean-dist`, rather than it running `rimraf dist`, it will echo \"I love electricity!\".\n\n## Why?\n\nGoing through and modifying `*.config*` files in _every_ react component library you have (which correlates 1:1 to a git repository) is a huge pain in the butt, it's a lot of copy/pasta and no one should 1) have to do that and 2) have to endure the possible degradation over time of human copy/pasta.\n\nThis package tries to solve the problem of creating a \"meta-monolith\" that stands behind our components so people can just build cool stuff and not worry about all the config that goes into keeping a component up to date.\n\nMaybe one day it won't be opinionated. But this day? Not this day.\n\n## Opinionated Directory Structure\n\n```\n|-- my_project\n| |-- package.json\n| |-- demo\n| | |-- index.html\n| | |-- demo.jsx\n| |-- dist\n| |-- src\n| | |-- components\n| | | |-- component.jsx\n| | |-- index.js\n| |-- docs\n| |-- test\n| |-- client\n| |-- component\n| |-- component.spec.jsx\n```\n", 115 | "readmeFilename": "README.md", 116 | "gitHead": "95155dd088c9547a901708b6854b3efec6275629", 117 | "_id": "electrode-bolt@0.4.14", 118 | "_shasum": "d5c23a5eaa0140690d40d89cee6a311e603b2514", 119 | "_from": "electrode-bolt@>=0.4.13 <0.5.0" 120 | } -------------------------------------------------------------------------------- /packages/electrode-bolt/src/bolt-run.js: -------------------------------------------------------------------------------- 1 | const Bolt = require("./bolt"); 2 | 3 | const bolt = new Bolt(process); 4 | bolt.run(); 5 | -------------------------------------------------------------------------------- /packages/electrode-bolt/src/bolt.js: -------------------------------------------------------------------------------- 1 | import logger from "./logger"; 2 | import chalk from "chalk"; 3 | import path from "path"; 4 | import childProcess from "child_process"; 5 | import _ from "lodash"; 6 | 7 | const exec = childProcess.exec; 8 | 9 | const Bolt = module.exports = function (proc) { 10 | this.proc = proc; 11 | 12 | this.gatherEnvironment(); 13 | 14 | this.run = function () { 15 | if (!this.cmd || this.cmd === "help") { 16 | this.help(); 17 | } else { 18 | this.checkForBoltStandard(); 19 | process.env.PATH = this.setupPath(); 20 | this.executeScript(); 21 | } 22 | }; 23 | }; 24 | 25 | Bolt.prototype.gatherEnvironment = function () { 26 | this.CWD = process.cwd(); 27 | this.boltDir = __dirname; 28 | this.binPath = "node_modules/.bin"; 29 | 30 | this.cwdPkg = require(path.join(this.CWD, "package.json")); 31 | 32 | this.scripts = { 33 | package: this.cwdPkg.scripts, 34 | bolt: require(path.join(this.boltDir, "../package.json")).scripts 35 | }; 36 | 37 | this.cmd = this.proc.argv[2] || null; 38 | this.args = null; 39 | }; 40 | 41 | Bolt.prototype.pathDelimiter = function () { 42 | return this.proc.platform.indexOf("win") === 0 ? ";" : ":"; 43 | }; 44 | 45 | Bolt.prototype.setupPath = function () { 46 | const pathDelimiter = this.pathDelimiter(); 47 | 48 | const cwdNodeModules = path.join(this.CWD, this.binPath); 49 | const boltNodeModules = path.join(this.boltDir, "../" + this.binPath); 50 | const modulePaths = [cwdNodeModules, boltNodeModules]; 51 | 52 | if (this.boltStandard) { 53 | modulePaths.push(path.join(this.CWD, "node_modules", this.boltStandard, this.binPath)); 54 | } 55 | 56 | const newPath = (process.env.PATH || "") 57 | .split(pathDelimiter) 58 | .filter(function (x) { 59 | return x; 60 | }) 61 | .concat(modulePaths) 62 | .join(pathDelimiter); 63 | 64 | return newPath; 65 | }; 66 | 67 | Bolt.prototype.gatherScripts = function () { 68 | const allScripts = _.merge({}, 69 | this.scripts.boltStandard, this.scripts.bolt, this.scripts.package); 70 | 71 | return allScripts; 72 | }; 73 | 74 | Bolt.prototype.help = function () { 75 | const allScripts = this.gatherScripts(); 76 | 77 | logger(`\n Usage: ${chalk.green("bolt ")}\n`); 78 | logger("available via `bolt`:\n"); 79 | for (const boltScriptName in allScripts) { 80 | logger(" " + chalk.green(boltScriptName) + "\n " + allScripts[boltScriptName]); 81 | } 82 | }; 83 | 84 | Bolt.prototype.checkForBoltStandard = function () { 85 | const dependencies = _.merge({}, this.cwdPkg.dependencies, this.cwdPkg.devDependencies); 86 | 87 | for (const dep in dependencies) { 88 | if (dep.match(/bolt-standard-.*/)) { 89 | this.boltStandard = dep; 90 | break; 91 | } 92 | } 93 | 94 | if (this.boltStandard) { 95 | this.scripts.boltStandard = this.getBoltStandardPkg().scripts; 96 | } 97 | }; 98 | 99 | Bolt.prototype.getBoltStandardPkg = function () { 100 | const boltStandardPath = path.join(this.CWD, "node_modules", this.boltStandard); 101 | return require(path.join(boltStandardPath, "package.json")); 102 | }; 103 | 104 | Bolt.prototype.tryScripts = function () { 105 | const tryScripts = ["package", "boltStandard", "bolt"]; 106 | for (let idx = 0; idx < tryScripts.length; idx++) { 107 | if (!this.scripts[tryScripts[idx]]) { continue; } 108 | 109 | const script = this.scripts[tryScripts[idx]][this.cmd]; 110 | if (script) { 111 | this.source = tryScripts[idx]; 112 | return script; 113 | } 114 | } 115 | }; 116 | 117 | Bolt.prototype.preexecuteScript = function () { 118 | const runnerName = "bolt"; 119 | 120 | this.args = this.tryScripts(); 121 | this.userArgs = this.proc.argv.length > 3 ? this.proc.argv.splice(3) : []; 122 | 123 | if (!this.source) { 124 | throw new Error("No command found for: " + this.cmd); 125 | } 126 | 127 | /* istanbul ignore else */ 128 | if (this.source === "package") { 129 | const cwdParts = this.args.split(/\s+/); 130 | const isBoltUtil = cwdParts.length === 2 && cwdParts[0] === runnerName; 131 | const isBoltCmd = cwdParts[1] === this.cmd; 132 | this.isProxy = isBoltUtil && isBoltCmd; 133 | 134 | if (!this.isProxy) { 135 | this.args = this.args; 136 | } 137 | } 138 | }; 139 | 140 | Bolt.prototype.executeScript = function () { 141 | this.preexecuteScript(); 142 | 143 | logger("Executing script", 144 | "`" + this.cmd + "` (" + this.args + ")", 145 | "from", this.source); 146 | 147 | /* istanbul ignore next */ 148 | const proc = exec(this.args + " " + this.userArgs.join(" "), { 149 | env: this.proc.env 150 | }, (err) => { 151 | /* eslint-disable no-process-exit */ 152 | if (err) { process.exit(err.code); } 153 | /* eslint-enable no-process-exit */ 154 | }); 155 | 156 | proc.stdout.pipe(process.stdout, { end: false }); 157 | proc.stderr.pipe(process.stderr, { end: false }); 158 | }; 159 | -------------------------------------------------------------------------------- /packages/electrode-bolt/src/init.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import path from "path"; 3 | import fs from "fs-extra"; 4 | import jsonfile from "jsonfile"; 5 | jsonfile.spaces = 2; 6 | import _ from "lodash"; 7 | 8 | const tasks = { 9 | prepublish: "bolt build-lib", 10 | demo: "bolt server-dev", 11 | build: "bolt build-lib", 12 | hot: "bolt server-hot", 13 | "test:dev": "bolt test-frontend", 14 | test: "bolt check-cov && bolt cov-frontend" 15 | }; 16 | 17 | const devDeps = { 18 | "babel-eslint": "^4.1.3", 19 | eslint: "^1.5.1", 20 | "eslint-config-defaults": "^6.0.0", 21 | "eslint-plugin-filenames": "^0.1.2", 22 | "eslint-plugin-react": "^3.4.2" 23 | }; 24 | 25 | const cpFiles = function () { 26 | fs.copy("node_modules/electrode-bolt/templates", path.join(process.cwd(), "."), function (err) { 27 | if (err) { return console.error(err); } 28 | 29 | console.log("bolt component lib initialized successfully!"); 30 | 31 | ["src/components/boilerplate-component.jsx", 32 | "test/client/spec/components/boilerplate-component.spec.jsx" 33 | ].forEach(function (filename) { 34 | fs.readFile(path.join(process.cwd(), filename), function (_err, file) { 35 | if (_err) { 36 | throw _err; 37 | } 38 | 39 | const contents = _.template(file.toString())({ name: "BoilerplateComponent" }); 40 | 41 | /* eslint-disable max-nested-callbacks */ 42 | fs.writeFile(path.join(process.cwd(), filename), contents, function (__err) { 43 | if (__err) { 44 | throw __err; 45 | } 46 | console.log("Generated", filename); 47 | }); 48 | }); 49 | }); 50 | }); 51 | }; 52 | 53 | const updatePackageJSON = function () { 54 | // read project's package.json 55 | const pkg = require(path.join(process.cwd(), "package.json")); 56 | 57 | // check if task exists for script tag 58 | for (const task in tasks) { 59 | let isBak = false; 60 | // if so, mv it to task:bak 61 | // add task to scripts 62 | if (pkg.scripts[task]) { 63 | pkg.scripts[task + ":bak"] = pkg.scripts[task]; 64 | isBak = true; 65 | } 66 | pkg.scripts[task] = isBak ? 67 | "echo \"original version of " + task + " is now " + task + ":bak" + 68 | " if you believe this is in error, please remove this task and change " + 69 | task + ":bak back to " + task + "\" && " + tasks[task] : tasks[task]; 70 | } 71 | 72 | for (const dep in devDeps) { 73 | pkg.devDependencies = pkg.devDependencies || {}; 74 | if (!pkg.devDependencies[dep]) { 75 | pkg.devDependencies[dep] = devDeps[dep]; 76 | } 77 | } 78 | 79 | console.log("package.json has been updated with new tasks and dependencies."); 80 | console.log("It is recommended that you run `npm install` to pick up new dependencies."); 81 | jsonfile.writeFile(path.join(process.cwd(), "package.json"), pkg, 82 | function (err) { 83 | if (err) { 84 | throw err; 85 | } 86 | } 87 | ); 88 | }; 89 | 90 | cpFiles(); 91 | 92 | updatePackageJSON(); 93 | -------------------------------------------------------------------------------- /packages/electrode-bolt/src/logger.js: -------------------------------------------------------------------------------- 1 | /* istanbul ignore next */ 2 | module.exports = function () { 3 | if (process.env.NODE_ENV === "test" && !process.env.TEST_LOGGER) { return; } 4 | 5 | const args = Array.prototype.slice.call(arguments); 6 | /* eslint-disable no-console */ 7 | console.log(...args); 8 | /* eslint-disable no-console */ 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /packages/electrode-bolt/tasks/scaffold.js: -------------------------------------------------------------------------------- 1 | var fs = require("fs"); 2 | var path = require("path"); 3 | var _ = require("lodash"); 4 | 5 | var createComponent = function (args) { 6 | fs.readFile(path.join(__dirname, "../templates/src/components/boilerplate-component.jsx"), function (err, file) { 7 | var file = _.template(file.toString())(args); 8 | 9 | fs.writeFile(path.join(process.cwd(), "src/components", args.name + ".jsx"), file, function (err, file) { 10 | if (err) { 11 | throw err; 12 | } 13 | console.log("Generated", args.name + ".jsx", "in", "src/components"); 14 | }); 15 | }); 16 | }; 17 | 18 | var createTest = function (args) { 19 | fs.readFile(path.join(__dirname, "../templates/test/client/spec/components/boilerplate-component.spec.jsx"), function (err, file) { 20 | if (err) { 21 | throw err; 22 | } 23 | var file = _.template(file.toString())(args); 24 | 25 | fs.writeFile(path.join(process.cwd(), "test/client/spec/components", args.name + ".spec.jsx"), file, function (err, file) { 26 | if (err) { 27 | throw err; 28 | } 29 | console.log("Generated", args.name + ".spec.jsx", "in", "test/client/spec/components"); 30 | }); 31 | }); 32 | }; 33 | 34 | var addComponentToIndex = function (args) { 35 | fs.readFile(path.join(process.cwd(), "src/index.js"), function(err, file) { 36 | if (err) { 37 | throw err; 38 | } 39 | 40 | var re = /module\.exports \= \{([\s\S]*?)\s\}/; 41 | 42 | var file = re.exec(file.toString()); 43 | 44 | var newFile = "module.exports = {" + 45 | (file[1] ? file[1] + "," : "") + "\n " + 46 | _.capitalize(args.name) + ": require(\"./components/" + args.name + ".jsx\")" 47 | + "\n};\n"; 48 | 49 | fs.writeFile(path.join(process.cwd(), "src/index.js"), newFile, function (err, file) { 50 | if (err) { 51 | throw err; 52 | } 53 | console.log("Added", args.name + ".jsx", "to src/index.js exports"); 54 | }) 55 | }); 56 | }; 57 | 58 | var fileExists = function (args) { 59 | return fs.existsSync(path.join(process.cwd(), "src/components", args.name + ".jsx")); 60 | }; 61 | 62 | module.exports = function (args) { 63 | if (fileExists(args)) { 64 | return console.log("Component already exists in src/. Please give the component a different name."); 65 | } 66 | 67 | createComponent(args); 68 | createTest(args); 69 | addComponentToIndex(args); 70 | }; 71 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/demo/.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "defaults/configurations/walmart/es6-react" 4 | globals: 5 | document: false 6 | rules: 7 | "complexity": 0 8 | "max-len": 0 9 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/demo/demo.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {BoilerplateComponent} from "../src/index"; 3 | 4 | class App extends React.Component { 5 | render() { 6 | return ( 7 |
8 | 9 |
10 | ); 11 | } 12 | } 13 | 14 | const content = document.getElementById("content"); 15 | 16 | React.render(, content); 17 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | Demo 10 | 11 | 12 | 34 | 35 | 36 | 39 |
40 |

If you can see this, something is broken (or JS is not enabled)!!.

41 |
42 | 43 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/src/.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "defaults/configurations/walmart/es6-react" 4 | globals: 5 | window: false 6 | rules: 7 | "react/jsx-boolean-value": 0 8 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/src/components/boilerplate-component.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export default class <%= name %> extends React.Component { 4 | render() { 5 | return ( 6 |
7 |

Edit me!

8 |
9 | ); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/src/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | BoilerplateComponent: require("./components/boilerplate-component") 3 | }; 4 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/test/.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - "defaults/configurations/walmart/es6-test" 4 | globals: 5 | document: false 6 | expect: false 7 | it: false 8 | sinon: false 9 | Element: false 10 | rules: 11 | "no-unused-expressions": 0 # for `chai.expect` 12 | "max-len": [2, 100, 2, {ignorePattern: "^\\s*(?:it|describe)\\(.*"}] 13 | "max-statements": 0 14 | "max-nested-callbacks": 0 15 | -------------------------------------------------------------------------------- /packages/electrode-bolt/templates/test/client/spec/components/boilerplate-component.spec.jsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Client tests 3 | */ 4 | import React from "react/addons"; 5 | 6 | describe("<%= _.capitalize(name) %>", () => { 7 | let <%= _.capitalize(name) %>; 8 | let component; 9 | let container; 10 | 11 | beforeEach(() => { 12 | <%= _.capitalize(name) %> = require("src/components/<%= _.kebabCase(name) %>"); 13 | container = document.createElement("div"); 14 | }); 15 | 16 | afterEach(() => { 17 | React.unmountComponentAtNode(container); 18 | }); 19 | 20 | it("has expected content with deep render", () => { 21 | component = React.render( 22 | <<%= _.capitalize(name) %> />, 23 | container 24 | ); 25 | 26 | expect(component).to.not.be.false; 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/electrode-bolt/test/spec/entry.js: -------------------------------------------------------------------------------- 1 | global.chai = require('chai'); 2 | global.sinonChai = require("sinon-chai"); 3 | 4 | global.expect = chai.expect; 5 | global.sinon = require('sinon'); 6 | chai.use(sinonChai); 7 | -------------------------------------------------------------------------------- /packages/electrode-bolt/test/spec/lib/bolt.spec.js: -------------------------------------------------------------------------------- 1 | var Bolt = require("../../../lib/bolt"); 2 | 3 | describe("Bolt", function () { 4 | var bolt; 5 | var sandbox; 6 | var spy; 7 | var stub; 8 | var proc; 9 | 10 | beforeEach(function () { 11 | sandbox = sinon.sandbox.create(); 12 | 13 | proc = { 14 | platform: process.platform, 15 | argv: ["node", "bolt"], 16 | env: process.env, 17 | exit: process.exit, 18 | on: process.on, 19 | stdout: process.stdout, 20 | stdin: process.stdin 21 | }; 22 | }); 23 | 24 | afterEach(function() { 25 | sandbox.restore(); 26 | 27 | /* restore proc */ 28 | proc = { 29 | argv: ["node", "bolt"] 30 | }; 31 | }); 32 | 33 | it("should run `help()` if there are no arguments", function () { 34 | spy = sandbox.spy(Bolt.prototype, "help"); 35 | 36 | bolt = new Bolt(proc); 37 | bolt.run(); 38 | 39 | expect(spy).to.have.been.called; 40 | Bolt.prototype.help.restore(); 41 | }); 42 | 43 | describe("#pathDelimiter", function () { 44 | var platformRestore = process.platform; 45 | 46 | afterEach(function () { 47 | proc.platform = platformRestore; 48 | }); 49 | 50 | it("should return : if 'win' is not found in platform", function () { 51 | bolt = new Bolt(proc); 52 | bolt.run(); 53 | 54 | expect(bolt.pathDelimiter()).to.eql(":"); 55 | }); 56 | 57 | it("should return ; if 'win' is found in platform", function () { 58 | proc.platform = "win"; 59 | bolt = new Bolt(proc); 60 | bolt.run(); 61 | 62 | expect(bolt.pathDelimiter()).to.eql(";"); 63 | }); 64 | }); 65 | 66 | describe("#checkForBoltStandard", function () { 67 | beforeEach(function() { 68 | proc.argv.push("test"); 69 | 70 | bolt = new Bolt(proc); 71 | }); 72 | 73 | it("should run `checkForBoltStandard() if there are additional arguments", function () { 74 | spy = sandbox.spy(Bolt.prototype, "checkForBoltStandard"); 75 | 76 | bolt.run(); 77 | 78 | expect(spy).to.have.been.called; 79 | Bolt.prototype.checkForBoltStandard.restore(); 80 | }); 81 | 82 | 83 | it("should not set `this.boltStandard` if no `bolt-standard-*` found in project dependencies", function () { 84 | bolt.cwdPkg.devDependencies = { 85 | "foo": "0.0.1", 86 | "bar": "0.0.1" 87 | }; 88 | 89 | bolt.run(); 90 | 91 | expect(bolt.boltStandard).to.be.undefined; 92 | }); 93 | 94 | it("should set `this.boltStandard` of first `bolt-standard-*` found in project dependencies", function () { 95 | stub = sandbox.stub(Bolt.prototype, "getBoltStandardPkg").returns({}); 96 | bolt.cwdPkg.devDependencies = { 97 | "bolt-standard-flux": "0.0.1", 98 | "bolt-standard-foo": "0.0.1", 99 | "foo": "0.0.1" 100 | }; 101 | 102 | bolt.run(); 103 | 104 | expect(bolt.boltStandard).to.eql("bolt-standard-flux"); 105 | expect(bolt.boltStandard).to.not.eql("bolt-standard-foo"); 106 | Bolt.prototype.getBoltStandardPkg.restore(); 107 | }); 108 | }); 109 | 110 | describe("#preexecuteScript", function () { 111 | beforeEach(function() { 112 | proc.argv.push("noScriptFound"); 113 | 114 | bolt = new Bolt(proc); 115 | }); 116 | 117 | it("should throw if no script is found", function () { 118 | expect((function () { bolt.preexecuteScript() })).to.throw(Error); 119 | }); 120 | 121 | it("should throw if cwd pkg scripts is undefined or null is found", function () { 122 | bolt.cwdPkg.scripts = null; 123 | expect((function () { bolt.preexecuteScript() })).to.throw(Error); 124 | 125 | bolt.cwdPkg.scripts = undefined; 126 | expect((function () { bolt.preexecuteScript() })).to.throw(Error); 127 | }); 128 | }); 129 | }); 130 | -------------------------------------------------------------------------------- /packages/electrode-bolt/test/spec/lib/logger.spec.js: -------------------------------------------------------------------------------- 1 | var logger = require("../../../lib/logger"); 2 | 3 | describe("logger", function () { 4 | var NODE_ENVRestore = process.env.NODE_ENV; 5 | var sandbox; 6 | var spy; 7 | var stub; 8 | 9 | beforeEach(function () { 10 | sandbox = sinon.sandbox.create(); 11 | }); 12 | 13 | afterEach(function () { 14 | sandbox.restore(); 15 | }); 16 | 17 | it("should call console log if NODE_ENV is not 'test'", function () { 18 | process.env.TEST_LOGGER = true; 19 | stub = sandbox.stub(global.console, "log"); 20 | 21 | logger("hello", "world"); 22 | expect(stub).to.have.been.called; 23 | global.console.log.restore(); 24 | delete process.env.TEST_LOGGER; 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | /* global exec, ls, console, mkdir, cd, ln */ 2 | /* eslint-disable no-console, no-multi-str, global-require */ 3 | require("shelljs/global"); 4 | 5 | const path = require("path"); 6 | const fs = require("fs"); 7 | 8 | exec("npm list --global --depth 1 electrode-bolt-cli >/dev/null 2>&1 \ 9 | && npm uninstall -g electrode-bolt-cli || true"); 10 | 11 | const packages = []; 12 | ls("packages/*").forEach((loc) => { 13 | const name = path.basename(loc); 14 | 15 | if (name[0] === ".") { return; } 16 | 17 | const pkgLoc = path.join(__dirname, "/../packages/", name, "/package.json"); 18 | 19 | if (!fs.existsSync(pkgLoc)) { return; } 20 | 21 | const pkg = require(pkgLoc); 22 | 23 | packages.push({ 24 | folder: name, 25 | pkg, 26 | name: pkg.name 27 | }); 28 | }); 29 | 30 | // create links 31 | packages.forEach((root) => { 32 | console.log(root.name); 33 | 34 | const nodeModulesLoc = `packages/${root.folder}/node_modules`; 35 | mkdir("-p", nodeModulesLoc); 36 | 37 | packages.forEach((sub) => { 38 | if (!root.pkg.dependencies || !root.pkg.dependencies[sub.name]) { return; } 39 | 40 | if (!fs.existsSync(path.join(nodeModulesLoc, "/", sub.name))) { 41 | console.log(`Linking packages/${sub.folder} to ${nodeModulesLoc}/${sub.name}`); 42 | ln("-s", `packages/${sub.folder}${nodeModulesLoc}/${sub.name}`); 43 | } 44 | }); 45 | 46 | cd(path.join("packages/", root.folder)); 47 | exec("npm install"); 48 | exec("npm link"); 49 | cd("../.."); 50 | }); 51 | 52 | exec("git submodule update --init"); 53 | exec("make build"); 54 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | for f in packages/*; do 5 | if [ -d "$f/src" ]; then 6 | echo "Running babel on $f" 7 | node ./node_modules/babel/bin/babel "$f/src" --out-dir "$f/lib" --copy-files $1 & 8 | fi 9 | done 10 | 11 | # if [ $1="--watch" ]; then 12 | # # Relink CLI watcher 13 | # echo "Watching CLI for relink" 14 | # chsum1="" 15 | # cd packages/electrode-bolt-cli 16 | 17 | # sleep 2 18 | # while [[ true ]] 19 | # do 20 | # if [ -d 'lib' ]; then 21 | # chsum2=`find lib -type f -exec md5 {} \;` 22 | # if [[ $chsum1 != $chsum2 ]] ; then 23 | # npm link 24 | # chsum1=$chsum2 25 | # fi 26 | # fi 27 | # sleep 2 28 | # done 29 | # fi 30 | 31 | wait 32 | -------------------------------------------------------------------------------- /scripts/publish.js: -------------------------------------------------------------------------------- 1 | require("shelljs/global"); 2 | 3 | var readline = require("readline-sync"); 4 | var semver = require("semver"); 5 | var child = require("child_process"); 6 | var fs = require("fs"); 7 | 8 | var PACKAGE_LOC = __dirname + "/../packages"; 9 | var VERSION_LOC = __dirname + "/../VERSION"; 10 | 11 | var CURRENT_VERSION = fs.readFileSync(VERSION_LOC, "utf8").trim(); 12 | console.log("Current version:", CURRENT_VERSION); 13 | 14 | var FORCE_VERSION = process.env.FORCE_VERSION; 15 | FORCE_VERSION = FORCE_VERSION ? FORCE_VERSION.split(",") : []; 16 | 17 | // 18 | 19 | function getVersion() { 20 | var input = readline.question("New version (Leave blank for new patch): "); 21 | 22 | var ver = semver.valid(input); 23 | if (!ver) { 24 | ver = semver.inc(CURRENT_VERSION, input || "patch"); 25 | } 26 | 27 | if (ver) { 28 | return ver; 29 | } else { 30 | console.log("Version provided is not valid semver."); 31 | return getVersion(); 32 | } 33 | } 34 | 35 | var NEW_VERSION = getVersion(); 36 | fs.writeFileSync(VERSION_LOC, NEW_VERSION, "utf8"); 37 | 38 | // 39 | 40 | function exec(cmd, log) { 41 | console.log("$", cmd); 42 | 43 | var out = child.execSync(cmd, { 44 | encoding: "utf8" 45 | }).trim(); 46 | 47 | if (log) { 48 | if (out) console.log(out); 49 | } else { 50 | return out; 51 | } 52 | } 53 | 54 | function getPackageLocation(name) { 55 | return PACKAGE_LOC + "/" + name; 56 | } 57 | 58 | // 59 | 60 | function publish() { 61 | var packageNames = fs.readdirSync(PACKAGE_LOC).filter(function (name) { 62 | return name[0] !== "."; 63 | }); 64 | 65 | var lastTagCommit = exec("git rev-list --tags --max-count=1"); 66 | var lastTag = exec("git describe " + lastTagCommit); 67 | 68 | var changedPackages = []; 69 | var changedFiles = [VERSION_LOC]; 70 | 71 | packageNames.forEach(function (name) { 72 | // check if package has changed since last release 73 | var diff = exec("git diff " + lastTag + " -- " + getPackageLocation(name)); 74 | if (diff || FORCE_VERSION.indexOf("*") >= 0 || FORCE_VERSION.indexOf(name) >= 0) { 75 | console.log("Changes detected to package", name); 76 | changedPackages.push(name); 77 | } 78 | }); 79 | 80 | if (!changedPackages.length && !FORCE_VERSION.length) { 81 | throw new Error("No packages changed."); 82 | } 83 | 84 | // 85 | 86 | changedPackages.forEach(function (name) { 87 | var loc = getPackageLocation(name); 88 | var pkgLoc = loc + "/package.json"; 89 | var pkg = require(pkgLoc); 90 | 91 | // set new version 92 | pkg.version = NEW_VERSION; 93 | 94 | // updated dependencies 95 | for (var depName in pkg.dependencies) { 96 | if (changedPackages.indexOf(depName) >= 1) { 97 | pkg.dependencies[depName] = "^" + NEW_VERSION; 98 | } 99 | } 100 | 101 | // write new package 102 | fs.writeFileSync(pkgLoc, JSON.stringify(pkg, null, " ")); 103 | 104 | // push to be git committed 105 | changedFiles.push(pkgLoc); 106 | }); 107 | 108 | changedFiles.forEach(function (loc) { 109 | exec("git add " + loc, true); 110 | }); 111 | 112 | var NEW_TAG_NAME = "v" + NEW_VERSION; 113 | exec("git commit -m " + NEW_TAG_NAME, true); 114 | exec("git tag " + NEW_TAG_NAME, true); 115 | 116 | changedPackages.forEach(function (name) { 117 | // prepublish script 118 | var prePub = getPackageLocation(name) + "/scripts/prepublish.js"; 119 | if (fs.existsSync(prePub)) require(prePub); 120 | }); 121 | 122 | changedPackages.forEach(function (name) { 123 | var loc = getPackageLocation(name); 124 | exec("cd " + loc + " && npm publish", true); 125 | 126 | // postpublish script 127 | var postPub = loc + "/scripts/postpublish.js"; 128 | if (fs.existsSync(postPub)) require(postPub); 129 | }); 130 | } 131 | 132 | var originalCommit = exec(""); 133 | 134 | try { 135 | publish(); 136 | } catch (err) { 137 | // todo: unpublish npm packages already created 138 | console.log(err.stack); 139 | console.log("Rolling back to commit", originalCommit, "..."); 140 | exec("git checkout --hard " + originalCommit, true); 141 | return; 142 | } 143 | 144 | exec("git push origin HEAD", true); 145 | exec("git push origin --tags", true); 146 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -z "$TEST_GREP" ]; then 5 | TEST_GREP="" 6 | fi 7 | 8 | node node_modules/mocha/bin/_mocha `scripts/_get-test-directories.sh` --opts mocha.opts --grep "$TEST_GREP" 9 | -------------------------------------------------------------------------------- /scripts/travis/merge-development-with-master.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | echo "Branch: $TRAVIS_BRANCH" 5 | echo "Commit: $TRAVIS_COMMIT" 6 | 7 | if [ "$TRAVIS_BRANCH" != "development" ]; then 8 | exit 0; 9 | fi 10 | 11 | git fetch origin master:master 12 | git checkout master 13 | git merge "$TRAVIS_COMMIT" 14 | git push "https://${GH_TOKEN}@github.com/walmartreact/electrode-bolt" 15 | -------------------------------------------------------------------------------- /scripts/travis/setup-git.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | git config user.name "caiobotci" 5 | git config user.email "caiobotci@gmail.com" 6 | --------------------------------------------------------------------------------