diff --git a/README.md b/README.md index 93279e555d..200adfc04b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ [Bootstrap 3][bootstrap] components built with [React][react] -[![Build Status][build-badge]][build] +[![Travis Build Status][build-badge]][build] +[![AppVeyor Build Status][appveyor-badge]][appveyor] [![NPM version][npm-badge]][npm] [![Bower version][bower-badge]][bower] [![HuBoard][huboard-badge]][huboard] @@ -74,3 +75,6 @@ Yes please! See the [contributing guidelines][contributing] for details. [huboard-badge]: https://img.shields.io/badge/Hu-Board-7965cc.svg [huboard]: https://huboard.com/react-bootstrap/react-bootstrap + +[appveyor-badge]: https://ci.appveyor.com/api/projects/status/ylitpyo6n5yq1s6i/branch/master?svg=true +[appveyor]: https://ci.appveyor.com/project/mtscout6/react-bootstrap/branch/master diff --git a/appveyor.yml.tmp b/appveyor.yml.tmp new file mode 100644 index 0000000000..d9d1c9d62e --- /dev/null +++ b/appveyor.yml.tmp @@ -0,0 +1,28 @@ +version: '{build}' + +# Test against this version of Node.js +environment: + matrix: + # node.js + - nodejs_version: "0.10" + - nodejs_version: "0.12" + # io.js + - nodejs_version: "1.0" + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node.js or io.js + - ps: Install-Product node $env:nodejs_version + # install modules + - npm -g install npm@latest + - set PATH=%APPDATA%\npm;%PATH% + - npm --version + - npm install + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - node --version + - npm --version + # run tests + - npm test diff --git a/docs/build.js b/docs/build.js index 9a94cbbc2e..942995a5d8 100644 --- a/docs/build.js +++ b/docs/build.js @@ -4,6 +4,7 @@ import Router from 'react-router'; import routes from './src/Routes'; import Root from './src/Root'; import fsp from 'fs-promise'; +import { copy } from '../tools/fs-utils'; import { exec, spawn } from 'child-process-promise'; const repoRoot = path.resolve(__dirname, '../'); @@ -16,7 +17,7 @@ const readmeDest = path.join(docsBuilt, 'README.md'); export default function BuildDocs() { console.log('Building: '.cyan + 'docs'.green); - return exec(`rm -rf ${docsBuilt}`) + return exec(`rimraf ${docsBuilt}`) .then(() => fsp.mkdir(docsBuilt)) .then(() => { let writes = Root @@ -31,8 +32,8 @@ export default function BuildDocs() { return Promise.all(writes.concat([ exec(`webpack --config webpack.docs.js -p --bail`), - exec(`cp ${license} ${docsBuilt}`), - exec(`cp ${readmeSrc} ${readmeDest}`) + copy(license, docsBuilt), + copy(readmeSrc, readmeDest) ])); }) .then(() => console.log('Built: '.cyan + 'docs'.green)); diff --git a/package.json b/package.json index ac28d00b95..fb768fe1bb 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "homepage": "http://react-bootstrap.github.io/", "scripts": { - "build": "./run-babel tools/build.js", + "build": "node run-babel tools/build.js", "test-watch": "karma start", "test": "karma start --single-run && npm run lint && npm run build", "lint": "eslint src test docs ie8 tools webpack karma.conf.js webpack.config.js webpack.docs.js", - "docs-build": "./run-babel tools/build.js --docs-only", - "docs": "./run-babel docs/server.js", - "docs-prod": "webpack --config webpack.docs.js -p --progress && NODE_ENV=production ./run-babel docs/server.js", - "ie8": "./run-babel ie8/server.js" + "docs-build": "node run-babel tools/build.js --docs-only", + "docs": "node run-babel docs/server.js", + "docs-prod": "webpack --config webpack.docs.js -p --progress && NODE_ENV=production node run-babel docs/server.js", + "ie8": "node run-babel ie8/server.js" }, "main": "lib/index.js", "directories": { @@ -51,6 +51,7 @@ "express": "^4.12.3", "extract-text-webpack-plugin": "^0.3.8", "file-loader": "^0.8.1", + "fs-extra": "^0.18.0", "fs-promise": "^0.3.1", "json-loader": "^0.5.1", "karma": "~0.12.32", @@ -71,6 +72,7 @@ "react": "^0.13.1", "react-router": "^0.13.1", "rf-changelog": "^0.4.0", + "rimraf": "^2.3.2", "semver": "^4.3.1", "sinon": "^1.10.3", "style-loader": "^0.9.0", @@ -82,4 +84,4 @@ "dependencies": { "classnames": "^1.1.4" } -} \ No newline at end of file +} diff --git a/tools/amd/build.js b/tools/amd/build.js index 527dd6b157..7d06d527d2 100644 --- a/tools/amd/build.js +++ b/tools/amd/build.js @@ -1,6 +1,7 @@ import _ from 'lodash'; import path from 'path'; import fsp from 'fs-promise'; +import { copy } from '../fs-utils'; import { exec, spawn } from 'child-process-promise'; const repoRoot = path.resolve(__dirname, '../../'); @@ -28,13 +29,13 @@ function bowerConfig() { export default function BuildBower() { console.log('Building: '.cyan + 'bower module'.green); - return exec(`rm -rf ${amd}`) + return exec(`rimraf ${amd}`) .then(() => fsp.mkdir(amd)) .then(() => Promise.all([ bowerConfig(), exec(`babel --modules amd --optional es7.objectRestSpread ${src} --out-dir ${path.join(amd, 'lib')}`), - exec(`cp ${readme} ${amd}`), - exec(`cp ${license} ${amd}`) + copy(readme, amd), + copy(license, amd) ])) .then(() => console.log('Built: '.cyan + 'bower module'.green)); } diff --git a/tools/build.js b/tools/build.js index 416835c5f5..0873cfac2c 100644 --- a/tools/build.js +++ b/tools/build.js @@ -1,14 +1,20 @@ /* eslint no-process-exit: 0 */ import from 'colors'; +import path from 'path'; import bower from './amd/build'; import lib from './lib/build'; import docs from '../docs/build'; import dist from './dist/build'; +import { copy } from './fs-utils'; import { exec, spawn } from 'child-process-promise'; import yargs from 'yargs'; +const repoRoot = path.resolve(__dirname, '../'); +const distFolder = path.join(repoRoot, 'dist'); +const amdFolder = path.join(repoRoot, 'amd'); + const argv = yargs .option('docs-only', { demand: false, @@ -26,12 +32,15 @@ export default function Build(noExitOnFailure) { dist(), docs() ]) - .then(() => exec(`cp -R dist/ amd`)); + .then(() => copy(distFolder, amdFolder)); if (!noExitOnFailure) { result = result .catch(err => { console.error(err.toString().red); + if (err.stack) { + console.error(err.stack.red); + } process.exit(1); }); } diff --git a/tools/fs-utils.js b/tools/fs-utils.js new file mode 100644 index 0000000000..13652b449a --- /dev/null +++ b/tools/fs-utils.js @@ -0,0 +1,39 @@ +import path from 'path'; +import fsp from 'fs-promise'; +import fse from 'fs-extra'; + +function copy(src, dest, options) { + options = options || {}; + + return Promise.all([ + fsp.stat(src), + fsp.exists(dest) + .then(exists => { + if (!exists) { + return false; + } + + return fsp.stat(dest); + }) + ]) + .then(([srcStat, destStat]) => { + if (srcStat.isFile() && destStat && destStat.isDirectory()) { + let filename = path.basename(src); + dest = path.join(dest, filename); + } + + return new Promise((resolve, reject) => { + fse.copy(src, dest, options, err => { + if (err) { + reject(err); + } + + resolve(); + }); + }); + }); +} + +export default { + copy +} diff --git a/tools/release-scripts/repo-release.js b/tools/release-scripts/repo-release.js index 0f17fcd620..e798fe8bf9 100644 --- a/tools/release-scripts/repo-release.js +++ b/tools/release-scripts/repo-release.js @@ -2,27 +2,32 @@ import from 'colors'; import path from 'path'; import fsp from 'fs-promise'; import { exec, spawn } from 'child-process-promise'; +import { copy } from '../fs-utils'; + +const repoRoot = path.resolve(__dirname, '../../'); + +const license = path.join(repoRoot, 'LICENSE'); export default (repo, srcFolder, tmpFolder, version) => { console.log('Releasing: '.cyan + repo.green); - return exec(`rm -rf ${tmpFolder}`) + return exec(`rimraf ${tmpFolder}`) .then(() => exec(`git clone ${repo} ${tmpFolder}`)) .then(() => fsp.readdir(tmpFolder)) .then(files => { return Promise.all( files .filter(file => file !== '.git') - .map(file => exec(`rm -rf ${path.join(tmpFolder, file)}`)) + .map(file => exec(`rimraf ${path.join(tmpFolder, file)}`)) ); }) - .then(() => exec(`cp -R ${srcFolder} ${tmpFolder}`)) - .then(() => exec(`cp LICENSE ${tmpFolder}`)) + .then(() => copy(srcFolder, tmpFolder)) + .then(() => copy(license, tmpFolder)) .then(() => exec(`cd ${tmpFolder} && git add -A .`)) .then(() => exec(`cd ${tmpFolder} && git commmit -m "Release v${version}"`)) .then(() => exec(`cd ${tmpFolder} && git tag -a --message=v${version} v${version}`)) .then(() => exec(`cd ${tmpFolder} && git push`)) .then(() => exec(`cd ${tmpFolder} && git push --tags`)) - .then(() => exec(`rm -rf ${tmpFolder}`)) + .then(() => exec(`rimraf ${tmpFolder}`)) .then(() => console.log('Released: '.cyan + repo.green)); }