diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..fdf7ed5 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +lib/** diff --git a/.travis.yml b/.travis.yml index dd3e9cc..3daa38a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,15 @@ sudo: false language: node_js node_js: - - "iojs" + - "4.0" - "0.10" - "0.12" + +branches: + only: + - master + +script: +- npm run test +- npm run lint +- npm run build diff --git a/karma.conf.js b/karma.conf.js index 74657d7..72c7d48 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,7 +1,7 @@ /* eslint no-var: 0 */ require("babel/register"); -var webpackConfig = require("./webpack/test.config.js"); +var webpackConfig = require("./webpack.config.test.js"); var isCI = process.env.CONTINUOUS_INTEGRATION === "true"; module.exports = function (config) { diff --git a/package.json b/package.json index 6dd9817..9504ab3 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "lib": "lib/" }, "scripts": { - "build": "node run-babel tools/build.js", - "lint": "eslint src test tools webpack karma.conf.js", - "test": "karma start --single-run && npm run build", + "build": "rm -rf lib && babel src --out-dir lib", + "lint": "eslint ./", + "test": "karma start --single-run", "test-watch": "karma start", "patch": "release patch --run", "minor": "release minor --run", @@ -36,39 +36,36 @@ "react": ">=0.14" }, "devDependencies": { - "babel": "~5.8.21", + "babel": "~5.8.21", "babel-core": "~5.8.22", - "babel-eslint": "~4.0.8", + "babel-eslint": "~4.1.3", "babel-loader": "~5.3.2", - "chai": "~3.2.0", + "chai": "~3.3.0", "child-process-promise": "~1.1.0", "colors": "~1.1.0", "es5-shim": "~4.1.3", - "eslint": "~1.1.0", - "eslint-config-defaults": "~4.0.1", - "eslint-plugin-react": "~3.2.3", - "fs-promise": "~0.3.1", + "eslint": "~1.6.0", + "eslint-config-defaults": "~7.0.1", + "eslint-plugin-react": "~3.5.1", "karma": "~0.13.9", "karma-chai": "~0.1.0", "karma-chrome-launcher": "~0.2.0", "karma-cli": "~0.1.0", "karma-mocha": "~0.2.0", "karma-mocha-reporter": "~1.1.1", - "karma-phantomjs-launcher": "~0.2.1", + "karma-phantomjs-launcher": "^0.2.1", "karma-sourcemap-loader": "~0.3.5", "karma-webpack": "~1.7.0", - "lodash": "~3.10.1", - "mocha": "~2.2.5", + "mocha": "~2.3.3", "mt-changelog": "^0.6.2", "phantomjs": "^1.9.18", "react": "~0.14.0", "react-dom": "~0.14.0", - "webpack": "~1.11.0", - "yargs": "~3.19.0" "release-script": "^0.5.3", + "webpack": "~1.12.2" }, "dependencies": { "babel-runtime": "^5.8.0", - "react-async-script": "~0.4.0" + "react-async-script": "~0.5.0" } } diff --git a/run-babel b/run-babel deleted file mode 100644 index 982ea36..0000000 --- a/run-babel +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node -/* eslint no-var: 0 */ -var path = require("path"); -require("babel/register"); -var mod = require(path.join(__dirname, process.argv[2])); - -if (typeof mod === "function") { - mod(); -} diff --git a/tools/build.js b/tools/build.js deleted file mode 100644 index 2a25441..0000000 --- a/tools/build.js +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint no-process-exit: 0, no-console: 0 */ -import "colors"; -import lib from "./lib/build"; - -export default function Build(noExitOnFailure) { - let result = Promise.all([ - lib(), - ]); - - if (!noExitOnFailure) { - result = result - .catch(err => { - console.error(err.toString().red); - if (err.stack) { - console.error(err.stack.red); - } - process.exit(1); - }); - } - - return result; -} diff --git a/tools/lib/build.js b/tools/lib/build.js deleted file mode 100644 index 8f7aed1..0000000 --- a/tools/lib/build.js +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint no-console: 0 */ -import "colors"; -import path from "path"; -import { exec } from "child-process-promise"; - -const repoRoot = path.resolve(__dirname, "../../"); -const lib = path.join(repoRoot, "lib"); -const src = path.join(repoRoot, "src"); - -export default function BuildCommonJs() { - console.log("Building: ".cyan + "npm module".green); - - return exec(`rm -rf ${lib}`) - .then(() => exec(`./node_modules/.bin/babel --optional es7.objectRestSpread,runtime ${src} --out-dir ${lib}`)) - .then(() => console.log("Built: ".cyan + "npm module".green)); -} diff --git a/webpack.config.test.js b/webpack.config.test.js new file mode 100644 index 0000000..d0e3f89 --- /dev/null +++ b/webpack.config.test.js @@ -0,0 +1,20 @@ +import { DefinePlugin } from "webpack"; +export default { + output: { + pathinfo: true, + }, + devtool: "inline-source-map", + + module: { + loaders: [ + { test: /\.js/, loader: "babel", exclude: /node_modules/ }, + ], + }, + plugins: [ + new DefinePlugin({ + "process.env": { + NODE_ENV: JSON.stringify("production"), + }, + }), + ], +}; diff --git a/webpack/strategies/index.js b/webpack/strategies/index.js deleted file mode 100644 index 0f3c8dd..0000000 --- a/webpack/strategies/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import test from "./test"; - -export default [ - test, -]; diff --git a/webpack/strategies/test.js b/webpack/strategies/test.js deleted file mode 100644 index 69dbf77..0000000 --- a/webpack/strategies/test.js +++ /dev/null @@ -1,17 +0,0 @@ -import _ from "lodash"; - -export default (config, options) => { - if (options.test) { - config = _.extend({}, config, { - devtool: "inline-source-map", - entry: undefined, - output: { - pathinfo: true, - }, - externals: undefined, - }); - - return config; - } - return config; -}; diff --git a/webpack/test.config.js b/webpack/test.config.js deleted file mode 100644 index 891a506..0000000 --- a/webpack/test.config.js +++ /dev/null @@ -1,3 +0,0 @@ -import config from "./webpack.config"; - -export default config({ test: true }); diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js deleted file mode 100644 index c1d3218..0000000 --- a/webpack/webpack.config.js +++ /dev/null @@ -1,63 +0,0 @@ -import _ from "lodash"; -import webpack from "webpack"; -import strategies from "./strategies"; -import yargs from "yargs"; - -const argv = yargs - .alias("p", "optimize-minimize") - .alias("d", "debug") - .argv; - -const defaultOptions = { - development: argv.debug, - docs: false, - test: false, - optimize: argv.optimizeMinimize, -}; - -export default (options) => { - options = _.merge({}, defaultOptions, options); - const environment = options.development || options.test ? "development" : "production"; - - const config = { - entry: { - ReCAPTCHA: "./src/recaptcha.jsx", - }, - - output: { - path: "./dist", - filename: "[name].js", - library: "ReCAPTCHA", - libraryTarget: "umd", - }, - - externals: [ - { - react: { - root: "React", - commonjs2: "react", - commonjs: "react", - amd: "react", - }, - }, - ], - - module: { - loaders: [ - { test: /\.js/, loader: "babel", exclude: /node_modules/ }, - ], - }, - - plugins: [ - new webpack.DefinePlugin({ - "process.env": { - NODE_ENV: JSON.stringify(environment), - }, - }), - ], - }; - - return strategies.reduce((conf, strategy) => { - return strategy(conf, options); - }, config); -};