Skip to content

Commit

Permalink
[fixed] Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
mtscout6 committed Apr 4, 2015
1 parent 2a578d4 commit 20472b9
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 19 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
28 changes: 28 additions & 0 deletions appveyor.yml.tmp
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions docs/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '../');
Expand All @@ -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
Expand All @@ -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));
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -82,4 +84,4 @@
"dependencies": {
"classnames": "^1.1.4"
}
}
}
7 changes: 4 additions & 3 deletions tools/amd/build.js
Original file line number Diff line number Diff line change
@@ -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, '../../');
Expand Down Expand Up @@ -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));
}
11 changes: 10 additions & 1 deletion tools/build.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
});
}
Expand Down
39 changes: 39 additions & 0 deletions tools/fs-utils.js
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 10 additions & 5 deletions tools/release-scripts/repo-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

0 comments on commit 20472b9

Please sign in to comment.