Skip to content

Commit

Permalink
Merge pull request FormidableLabs#22 from FormidableLabs/use-builder
Browse files Browse the repository at this point in the history
Use Builder
  • Loading branch information
exogen committed Nov 17, 2015
2 parents 381be8a + 9b95d21 commit 1a194ef
Show file tree
Hide file tree
Showing 30 changed files with 163 additions and 474 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"stage": 0,
"nonStandard": true
}
3 changes: 3 additions & 0 deletions .builderrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
archetypes:
- builder-react-component
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc-base

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc-node

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc-react

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc-react-test

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ node_modules
bower_components
.tmp
lib
npm-debug.log
npm-debug.log*
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.tmp
npm-debug.log
npm-debug.log*

# Code / build
coverage
Expand Down
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: node_js

node_js:
- 0.10
- 0.12
- "0.10"
- "0.12"
- "4.2"
- "5.0"

# Use container-based Travis infrastructure.
sudo: false
Expand All @@ -11,15 +13,23 @@ branches:
only:
- master

env:
matrix:
- NPM_3=true
- NPM_3=false

before_install:
# GUI for real browsers.
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

# Potentially update to npm 3
- 'if [ "$NPM_3" = true ]; then npm install -g npm@3; else true; fi'

script:
- npm run check-ci
- npm --version
- node_modules/.bin/builder run check-ci

# Prune deps to just production and ensure we can still build
- npm prune --production
- npm install --production
- npm run build
- node_modules/.bin/builder run build
61 changes: 38 additions & 23 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
Development
===========

We use [builder][] and `npm` to control all aspects of development and
publishing.

As a preliminary matter, please update your shell to include
`./node_modules/.bin` in `PATH` like:

```sh
export PATH="${PATH}:./node_modules/.bin"
```

So you can type `builder` instead of `./node_modules/.bin/builder` for all
commands.

## Build

Build for production use (NPM, bower, etc) and create `dist` UMD bundles
(min'ed, non-min'ed)

```
$ npm run build
$ builder run build
```

Note that `dist/` files are only updated and committed on **tagged releases**.
Expand All @@ -20,9 +33,9 @@ and launching a browser pointed to the demo page.

Run the `demo` application with watched rebuilds:

```
$ npm run dev # dev test/app server (OR)
$ npm run open-dev # dev servers _and a browser window opens!_
```sh
$ builder run dev # dev test/app server (OR)
$ builder run open-dev # dev servers _and a browser window opens!_
```

From there you can see:
Expand Down Expand Up @@ -77,21 +90,21 @@ size.

During development, you are expected to be running either:

```
$ npm run dev
```sh
$ builder run dev
```

to build the lib and test files. With these running, you can run the faster

```
$ npm run check-dev
```sh
$ builder run check-dev
```

Command. It is comprised of:

```
$ npm run lint
$ npm run test-dev
```sh
$ builder run lint
$ builder run test-dev
```

Note that the tests here are not instrumented for code coverage and are thus
Expand All @@ -102,20 +115,20 @@ more development / debugging friendly.
CI doesn't have source / test file watchers, so has to _build_ the test files
via the commands:

```
$ npm run check # PhantomJS only
$ npm run check-cov # (OR) PhantomJS w/ coverage
$ npm run check-ci # (OR) PhantomJS,Firefox + coverage - available on Travis.
```sh
$ builder run check # PhantomJS only
$ builder run check-cov # (OR) PhantomJS w/ coverage
$ builder run check-ci # (OR) PhantomJS,Firefox + coverage - available on Travis.
```

Which is currently comprised of:

```
$ npm run lint # AND ...
```sh
$ builder run lint # AND ...

$ npm run test # PhantomJS only
$ npm run test-cov # (OR) PhantomJS w/ coverage
$ npm run test-ci # (OR) PhantomJS,Firefox + coverage
$ builder run test # PhantomJS only
$ builder run test-cov # (OR) PhantomJS w/ coverage
$ builder run test-ci # (OR) PhantomJS,Firefox + coverage
```

Note that `(test|check)-(cov|ci)` run code coverage and thus the
Expand All @@ -125,7 +138,7 @@ test code may be harder to debug because it is instrumented.

The client tests rely on webpack dev server to create and serve the bundle
of the app/test code at: http://127.0.0.1:3001/assets/main.js which is done
with the task `npm run server-test` (part of `npm dev`).
with the task `builder run server-test` (part of `npm dev`).

#### Code Coverage

Expand All @@ -143,15 +156,15 @@ coverage/
**IMPORTANT - NPM**: To correctly run `preversion` your first step is to make
sure that you have a very modern `npm` binary:

```
```sh
$ npm install -g npm
```

Built files in `dist/` should **not** be committeed during development or PRs.
Instead we _only_ build and commit them for published, tagged releases. So
the basic workflow is:

```
```sh
# Make sure you have a clean, up-to-date `master`
$ git pull
$ git status # (should be no changes)
Expand Down Expand Up @@ -186,3 +199,5 @@ please review:
* [`npm publish`](https://docs.npmjs.com/cli/publish): Uploads to NPM.
* **NOTE**: We don't _build_ in `prepublish` because of the
[`npm install` runs `npm prepublish` bug](https://github.com/npm/npm/issues/3059)

[builder]: https://github.com/FormidableLabs/builder
8 changes: 5 additions & 3 deletions demo/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class App extends React.Component {
color: this.state.color,
br: this.state.br,
rotate: this.state.rotate
}}>
}}
>
{(data) => {
return (
<div style={
Expand All @@ -56,8 +57,9 @@ class App extends React.Component {
alignItems: "center",
display: "flex",
fontSize: 40,
transform: "rotate(" + data.rotate + "deg)"
}}>
transform: `rotate(${data.rotate}deg)`
}}
>
<div style={{textAlign: "center", width: "100%"}}>Test</div>
</div>
);
Expand Down
44 changes: 36 additions & 8 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,54 @@
<html>
<head>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv-printshiv.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.js"></script>
<![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Demo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style type="text/css">
* {
box-sizing: border-box;
}
.tile {
display: block;
float: left;
width: 100px;
height: 100px;
margin: 20px;
}
.tile img {
display: block;
width: 100px;
height: 100px;
}
.demo {
width: 80%;
margin: auto;
position: relative;
}
</style>
</head>
<body>
<!--[if lt IE 8]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="content">
<h1>If you can see this, something is broken (or JS is not enabled)!!.</h1>
</div>
<script type="text-javascript" src="http://localhost:3000/webpack-dev-server.js"></script>
<script type="text/javascript" src="assets/main.js"></script>
<div id="content"></div>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.7/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.7/es5-sham.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.15/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.15/es5-sham.min.js"></script>
<![endif]-->
<script src="http://localhost:3000/webpack-dev-server.js"></script>
<script src="assets/main.js"></script>
<script>
// Sanity-check the component loaded...
setTimeout(function () {
var content = document.querySelector("#content");
content.innerHTML = content.innerHTML ||
"If you can see this, something is broken (or JS is not enabled)!";
}, 500);
</script>
</body>
</html>
7 changes: 0 additions & 7 deletions demo/style.css

This file was deleted.

46 changes: 0 additions & 46 deletions demo/webpack.config.dev.js

This file was deleted.

17 changes: 0 additions & 17 deletions demo/webpack.config.hot.js

This file was deleted.

Loading

0 comments on commit 1a194ef

Please sign in to comment.