Skip to content

Scripts and tweaks for webpack serving and building #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
90445f5
webpack building
nathanstitt Aug 2, 2016
c81842c
a known-good standalone config for Tutor
nathanstitt Aug 2, 2016
2eea492
update webpack building config
nathanstitt Aug 3, 2016
e618a13
build and serve scripts
nathanstitt Aug 3, 2016
f92b297
fix paths for production build
nathanstitt Aug 3, 2016
a4f42c8
remove unused/uneeded gulpfile
nathanstitt Aug 3, 2016
56c00f7
fix script
nathanstitt Aug 3, 2016
15ff98e
Load shared components from "shared" directory
nathanstitt Aug 3, 2016
3dc7143
remove spec that tests non-existant component
nathanstitt Aug 3, 2016
3e82a25
Basic test setup
nathanstitt Aug 3, 2016
f92ed53
add `bin-archive` command for backwards compat
nathanstitt Aug 3, 2016
52b22f5
rename scripts folder to bin
nathanstitt Aug 3, 2016
e15236d
Update README to describe updated serve/build
nathanstitt Aug 3, 2016
405aed6
move coffeelint config into top level dir
nathanstitt Aug 3, 2016
c964539
add shared path resolves to base webpack config from tutor-specific
pandafulmanda Aug 3, 2016
1d9dcc1
serve preview for all projects with serve script
pandafulmanda Aug 3, 2016
543185b
pull out repeated input checking
pandafulmanda Aug 3, 2016
b058e29
make sure course data is loaded
nathanstitt Aug 3, 2016
bbdfd1b
body can be both element or string
nathanstitt Aug 3, 2016
bdeff02
Add needed task counts for late message
nathanstitt Aug 3, 2016
1cf650f
remove malfunctioning spec (it's tested in store)
nathanstitt Aug 3, 2016
31fc887
add name to course
nathanstitt Aug 3, 2016
ea048c1
update message to match actual text
nathanstitt Aug 3, 2016
6a22978
disable spec that has indeterminate behaviour
nathanstitt Aug 3, 2016
7f95586
setup scripts for each testing purpose
nathanstitt Aug 3, 2016
5e50950
rename ci runner script to match package.json
nathanstitt Aug 3, 2016
bebe3fb
course may be null in specs
nathanstitt Aug 3, 2016
2c5d5de
re-enable spec
nathanstitt Aug 3, 2016
ce008f4
Make tdd actually start webserver
nathanstitt Aug 3, 2016
c251199
webpack config for karma should also have project based paths so that…
pandafulmanda Aug 4, 2016
a105545
hardcode ci for tutor for now
pandafulmanda Aug 4, 2016
8d0e4d7
Update karma related packages
nathanstitt Aug 4, 2016
b29750f
remove single-run from config and set it using cli
nathanstitt Aug 4, 2016
c7b39b4
include tutor test files directly
nathanstitt Aug 4, 2016
750bf7c
update phantomjs
nathanstitt Aug 4, 2016
c094d09
revert phantom/karma versio changes
nathanstitt Aug 4, 2016
d7d7a22
test command works for other projects
pandafulmanda Aug 4, 2016
4202522
build projects in their own dist folders
nathanstitt Aug 4, 2016
bafd7f4
travis matrix for ci of each project
pandafulmanda Aug 5, 2016
bb92087
update BS.Modal use for coach to newer current version, update spec a…
pandafulmanda Aug 5, 2016
de24440
take out node_js version in travis, travis will fallback to .nvmrc
pandafulmanda Aug 5, 2016
1c4b8a7
darn i thought node 4.4 installs with npm@^3
pandafulmanda Aug 5, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/coverage
/coverage-selenium.json
/docs*

archive.tar.gz
/*/dist
*.cjsx.js

/phantomjsdriver.log
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# `sudo:false` for faster builds.
sudo: false
language: node_js
node_js:
- "0.12.10"
env:
- OX_PROJECT=tutor
- OX_PROJECT=coach
- OX_PROJECT=exercises
- OX_PROJECT=shared
before_install:
- "npm install -g npm@^3"
script:
- npm run ci
after_failure:
Expand Down
7 changes: 0 additions & 7 deletions Gulpfile.coffee

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![dependency status][dependency-image]][dependency-url]
[![dev dependency status][dev-dependency-image]][dev-dependency-url]

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

## Install

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


## Development

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

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

Expand Down
22 changes: 22 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

bin/checkinputs "$@"

export OX_PROJECT=$1
echo Building: $OX_PROJECT
export NODE_ENV=production

[ -d $OX_PROJECT/dist ] && rm -r $OX_PROJECT/dist

webpack --progress --config webpack.config.js

if [ $2 == "archive" ]; then
cd $OX_PROJECT
# credit/blame to: http://stackoverflow.com/questions/8201729/rename-files-to-md5-sum-extension-bash
for F in dist/*.min.*; do
mv $F `md5sum $F | perl -MFile::Basename -ne '($m, $f) = split(/\s+/,$_); $f=basename($f); $f =~ m/(.*?)\.(.*)/; print "dist/$1-$m.$2"'`
done
tar -czf ../archive.tar.gz dist/*
fi
7 changes: 7 additions & 0 deletions bin/checkinputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo "No project to build was given. usage:"
echo "$0 <tutor|exercises|coach>"
exit 1
fi
10 changes: 10 additions & 0 deletions bin/serve
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

bin/checkinputs "$@"

export OX_PROJECT=$1
echo Serving: $OX_PROJECT

webpack-dev-server --progress --config webpack.config.js
23 changes: 23 additions & 0 deletions bin/tdd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

on_termination() {
echo killing webpack $WEBPACK_PID
kill -TERM $WEBPACK_PID 2>/dev/null
}

bin/checkinputs "$@"

trap on_termination SIGTERM SIGINT

export OX_PROJECT=$1
echo TDD: $OX_PROJECT


webpack-dev-server --config webpack.config.js &
WEBPACK_PID=$!
echo webpack started pid: $WEBPACK_PID


karma start test/karma.config.js --auto-watch --no-single-run
10 changes: 10 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

bin/checkinputs "$@"

export OX_PROJECT=$1
echo Test: $OX_PROJECT

karma start test/karma.config.js --single-run
8 changes: 8 additions & 0 deletions bin/test-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -ev

# travis should be setting the OX_PROJECT variable
# export OX_PROJECT='tutor'

karma start test/karma.config.js --single-run
2 changes: 0 additions & 2 deletions coach/configs/base.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
module.exports =
devPort: '3005'
basePath: 'coach'
devEntry: 'demo'
12 changes: 4 additions & 8 deletions coach/configs/webpack.development.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module.exports =
entry:
'demo.js': [
'./coach/demo'
]
'demo': [
'./coach/resources/styles/demo.less'
]
'main': [
'./coach/resources/styles/main.less'
demo: [
'demo'
'resources/styles/main.less'
'resources/styles/demo.less'
]
2 changes: 1 addition & 1 deletion coach/configs/webpack.production.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ webpackUMDExternal = require 'webpack-umd-external'

module.exports =
entry:
main: './coach/index'
main: 'index'
output:
filename: 'main.min.js'
plugins: [
Expand Down
6 changes: 3 additions & 3 deletions coach/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<link rel="stylesheet" href="/assets/demo.css" />
<link rel="stylesheet" href="/assets/main.css" />
<link rel="stylesheet" href="./dist/demo.css" />
<link rel="stylesheet" href="./dist/main.css" />
<script src="//cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&amp;delayStartupUntil=configured" async></script>
<script src="/assets/demo.js" async></script>
<script src="./dist/demo.js" async></script>
</head>
<body>
<div class="container cc-demo" id="react-root-container">
Expand Down
2 changes: 1 addition & 1 deletion coach/src/api/loader.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_ = require 'underscore'
deepMerge = require 'lodash/object/merge'
deepMerge = require 'lodash.merge'
$ = require 'jquery'
interpolate = require 'interpolate'

Expand Down
2 changes: 1 addition & 1 deletion coach/src/breadcrumbs/index.cjsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
React = require 'react'
classnames = require 'classnames'
{Breadcrumb} = require 'openstax-react-components'
{Breadcrumb} = require 'shared'
_ = require 'underscore'

tasks = require '../task/collection'
Expand Down
2 changes: 1 addition & 1 deletion coach/src/concept-coach/base.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _ = require 'underscore'
classnames = require 'classnames'
EventEmitter2 = require 'eventemitter2'

{SmartOverflow, SpyMode} = require 'openstax-react-components'
{SmartOverflow, SpyMode} = require 'shared'

{Task} = require '../task'
navigation = {Navigation} = require '../navigation'
Expand Down
16 changes: 14 additions & 2 deletions coach/src/concept-coach/error-notification.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ makeContactURL = (errors, windowContext) ->
ErrorNotification = React.createClass

getInitialState: ->
error: false, isShowingDetails: false
errors: false, isShowingDetails: false

componentWillMount: ->
api.channel.on 'error', @onError
Expand Down Expand Up @@ -69,7 +69,19 @@ ErrorNotification = React.createClass

render: ->
return null unless @state.errors
<BS.Modal className='errors' onRequestHide={@onHide} title="Error encountered">

modalProps = _.pick(@props, 'container')

<BS.Modal
{...modalProps}
className='errors'
show={not _.isEmpty(@state.errors)}
onHide={@onHide}>

<BS.Modal.Header closeButton>
<BS.Modal.Title>Error encountered</BS.Modal.Title>
</BS.Modal.Header>

<div className='modal-body'>
<p>
An unexpected error has occured. Please
Expand Down
2 changes: 1 addition & 1 deletion coach/src/course/confirm-join.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RequestStudentId = require './request-student-id'

Course = require './model'
ErrorList = require './error-list'
{AsyncButton} = require 'openstax-react-components'
{AsyncButton} = require 'shared'

ConfirmJoin = React.createClass

Expand Down
2 changes: 1 addition & 1 deletion coach/src/course/enrollment-code-input.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENTER = 'Enter'
{CourseListing} = require './listing'
ErrorList = require './error-list'
Course = require './model'
{AsyncButton} = require 'openstax-react-components'
{AsyncButton} = require 'shared'
User = require '../user/model'

EnrollmentCodeInput = React.createClass
Expand Down
2 changes: 1 addition & 1 deletion coach/src/course/request-student-id.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENTER = 'Enter'
User = require '../user/model'
Course = require './model'
ErrorList = require './error-list'
{AsyncButton} = require 'openstax-react-components'
{AsyncButton} = require 'shared'

RequestStudentId = React.createClass

Expand Down
2 changes: 1 addition & 1 deletion coach/src/course/update-student-identifier.cjsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_ = require 'underscore'
React = require 'react'
BS = require 'react-bootstrap'
{AsyncButton} = require 'openstax-react-components'
{AsyncButton} = require 'shared'
ENTER = 'Enter'

Course = require './model'
Expand Down
2 changes: 1 addition & 1 deletion coach/src/exercise/index.cjsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
React = require 'react'
_ = require 'underscore'
{Exercise, ChapterSectionMixin} = require 'openstax-react-components'
{Exercise, ChapterSectionMixin} = require 'shared'

{channel, getCurrentPanel} = exercises = require './collection'
tasks = require '../task/collection'
Expand Down
4 changes: 2 additions & 2 deletions coach/src/navigation/index.cjsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
React = require 'react'
BS = require 'react-bootstrap'
{CloseButton} = require 'openstax-react-components'
{CloseButton} = require 'shared'
{CourseNameBase} = require './course-name'

Course = require '../course/model'
user = require '../user/model'
{channel} = require './model'
api = require '../api'
UserMenu = require '../user/menu'
{NotificationsBar} = require 'openstax-react-components'
{NotificationsBar} = require 'shared'

Navigation = React.createClass
displayName: 'Navigation'
Expand Down
2 changes: 1 addition & 1 deletion coach/src/progress/chapter.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ React = require 'react'
_ = require 'underscore'
classnames = require 'classnames'

{ChapterSectionMixin} = require 'openstax-react-components'
{ChapterSectionMixin} = require 'shared'
{PageProgress} = require './page'

ChapterProgress = React.createClass
Expand Down
2 changes: 1 addition & 1 deletion coach/src/progress/index.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ React = require 'react'
_ = require 'underscore'
classnames = require 'classnames'

{ChapterSectionMixin} = require 'openstax-react-components'
{ChapterSectionMixin} = require 'shared'
{Reactive} = require '../reactive'
{ExerciseButton} = require '../buttons'
{SectionProgress} = require './section'
Expand Down
2 changes: 1 addition & 1 deletion coach/src/progress/page.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dateFormat = require 'dateformat'
classnames = require 'classnames'
EventEmitter2 = require 'eventemitter2'

{ChapterSectionMixin, ResizeListenerMixin} = require 'openstax-react-components'
{ChapterSectionMixin, ResizeListenerMixin} = require 'shared'
{ExerciseProgress} = require './exercise'

PageProgress = React.createClass
Expand Down
2 changes: 1 addition & 1 deletion coach/src/task/index.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ React = require 'react'
EventEmitter2 = require 'eventemitter2'
_ = require 'underscore'
classnames = require 'classnames'
{SpyMode} = require 'openstax-react-components'
{SpyMode} = require 'shared'

{channel} = tasks = require './collection'
api = require '../api'
Expand Down
2 changes: 1 addition & 1 deletion coach/src/task/review.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BS = require 'react-bootstrap'
_ = require 'underscore'
tasks = require './collection'

{ChapterSectionMixin} = require 'openstax-react-components'
{ChapterSectionMixin} = require 'shared'
{ExerciseStep} = require '../exercise'
{ExerciseButton, ContinueToBookButton, ReturnToBookButton} = require '../buttons'

Expand Down
2 changes: 1 addition & 1 deletion coach/src/task/title.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _ = require 'underscore'
classnames = require 'classnames'
tasks = require './collection'

{ChapterSectionMixin} = require 'openstax-react-components'
{ChapterSectionMixin} = require 'shared'
{GoToBookLink} = require '../buttons'

TaskTitle = React.createClass
Expand Down
2 changes: 1 addition & 1 deletion coach/src/user/menu.cjsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
React = require 'react'
BS = require 'react-bootstrap'
EventEmitter2 = require 'eventemitter2'
{CloseButton} = require 'openstax-react-components'
{CloseButton} = require 'shared'

Status = require './status-mixin'

Expand Down
2 changes: 1 addition & 1 deletion coach/src/user/model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ React = require 'react'
EventEmitter2 = require 'eventemitter2'
Course = require '../course/model'
api = require '../api'
{BootrapURLs, NotificationActions} = require 'openstax-react-components'
{BootrapURLs, NotificationActions} = require 'shared'

BLANK_USER =
is_admin: false
Expand Down
2 changes: 0 additions & 2 deletions coach/test/all-source-files.coffee

This file was deleted.

Loading