Skip to content

Commit 2aa0ff1

Browse files
authored
Merge pull request #1243 from openstax/webpack-build
Scripts and tweaks for webpack serving and building
2 parents f70e2bc + 1c4b8a7 commit 2aa0ff1

File tree

190 files changed

+526
-900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+526
-900
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/coverage
88
/coverage-selenium.json
99
/docs*
10-
10+
archive.tar.gz
11+
/*/dist
1112
*.cjsx.js
12-
1313
/phantomjsdriver.log

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# `sudo:false` for faster builds.
22
sudo: false
33
language: node_js
4-
node_js:
5-
- "0.12.10"
4+
env:
5+
- OX_PROJECT=tutor
6+
- OX_PROJECT=coach
7+
- OX_PROJECT=exercises
8+
- OX_PROJECT=shared
9+
before_install:
10+
- "npm install -g npm@^3"
611
script:
712
- npm run ci
813
after_failure:

Gulpfile.coffee

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![dependency status][dependency-image]][dependency-url]
55
[![dev dependency status][dev-dependency-image]][dev-dependency-url]
66

7-
The JavaScript client for openstax Tutor.
7+
The Front-end code for Openstax Tutor related projects
88

99
## Install
1010

@@ -14,16 +14,16 @@ The JavaScript client for openstax Tutor.
1414
- If you don’t have `git` installed you can install homebrew and then `brew install git`
1515
1. `cd tutor-js` move into the checked out directory
1616
1. `npm install`
17-
1. `npm start`
17+
1. `npm run serve <project>` *(where <project is one of tutor|coach|exercises)*
1818
1. Point your browser to <http://localhost:8000> to use the mock data in `/api`
1919

2020

2121
## Development
2222

23-
- `npm start` starts up a local development webserver which rebuilds files when changed
24-
- `npm test` runs unit tests
23+
- `npm run serve <project>` starts up a local development webserver which rebuilds files when changed
24+
- `npm test` runs unit tests for all projects
2525
- `npm run coverage` generates a code coverage report
26-
- `gulp prod` builds minified files for production
26+
- `npm run build <project> archive` builds minified files for production
2727

2828
Use `PORT=8000 npm start` to change the default webserver port.
2929

bin/build

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
bin/checkinputs "$@"
6+
7+
export OX_PROJECT=$1
8+
echo Building: $OX_PROJECT
9+
export NODE_ENV=production
10+
11+
[ -d $OX_PROJECT/dist ] && rm -r $OX_PROJECT/dist
12+
13+
webpack --progress --config webpack.config.js
14+
15+
if [ $2 == "archive" ]; then
16+
cd $OX_PROJECT
17+
# credit/blame to: http://stackoverflow.com/questions/8201729/rename-files-to-md5-sum-extension-bash
18+
for F in dist/*.min.*; do
19+
mv $F `md5sum $F | perl -MFile::Basename -ne '($m, $f) = split(/\s+/,$_); $f=basename($f); $f =~ m/(.*?)\.(.*)/; print "dist/$1-$m.$2"'`
20+
done
21+
tar -czf ../archive.tar.gz dist/*
22+
fi

bin/checkinputs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
if [ $# -eq 0 ]; then
4+
echo "No project to build was given. usage:"
5+
echo "$0 <tutor|exercises|coach>"
6+
exit 1
7+
fi

bin/serve

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
bin/checkinputs "$@"
6+
7+
export OX_PROJECT=$1
8+
echo Serving: $OX_PROJECT
9+
10+
webpack-dev-server --progress --config webpack.config.js

bin/tdd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
on_termination() {
6+
echo killing webpack $WEBPACK_PID
7+
kill -TERM $WEBPACK_PID 2>/dev/null
8+
}
9+
10+
bin/checkinputs "$@"
11+
12+
trap on_termination SIGTERM SIGINT
13+
14+
export OX_PROJECT=$1
15+
echo TDD: $OX_PROJECT
16+
17+
18+
webpack-dev-server --config webpack.config.js &
19+
WEBPACK_PID=$!
20+
echo webpack started pid: $WEBPACK_PID
21+
22+
23+
karma start test/karma.config.js --auto-watch --no-single-run

bin/test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
bin/checkinputs "$@"
6+
7+
export OX_PROJECT=$1
8+
echo Test: $OX_PROJECT
9+
10+
karma start test/karma.config.js --single-run

bin/test-ci

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
# travis should be setting the OX_PROJECT variable
6+
# export OX_PROJECT='tutor'
7+
8+
karma start test/karma.config.js --single-run

0 commit comments

Comments
 (0)