Skip to content

Commit

Permalink
Significant packaging changes
Browse files Browse the repository at this point in the history
- Build two bundles: graphlib.js and graphlib.core.js
- Use karma to verify the bundles
- Prepare to use this repo as the canonical source for bower
- Remove some unused code, like src/watch.js
  • Loading branch information
cpettitt committed Oct 19, 2014
1 parent d27d87e commit 44be8f4
Show file tree
Hide file tree
Showing 29 changed files with 9,463 additions and 55 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/build
/dist
/node_modules
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/browser.js
/bench
/build
/dist
/doc
/Makefile
/node_modules
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
language: node_js
node_js:
- "0.10"
script: make test
script: KARMA_OPTS="--browsers Firefox,PhantomJS" make -e test
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
37 changes: 23 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ BROWSERIFY = ./node_modules/browserify/bin/cmd.js
ISTANBUL = ./node_modules/istanbul/lib/cli.js
JSHINT = ./node_modules/jshint/bin/jshint
JSCS = ./node_modules/jscs/bin/jscs
KARMA = ./node_modules/karma/bin/karma
MOCHA = ./node_modules/mocha/bin/_mocha
UGLIFY = ./node_modules/uglify-js/bin/uglifyjs

Expand All @@ -17,16 +18,16 @@ COVERAGE_DIR = $(BUILD_DIR)/cov
DIST_DIR = dist

SRC_FILES = index.js lib/version.js $(shell find lib -type f -name '*.js')
TEST_FILES = $(shell find test -type f -name '*.js')
TEST_FILES = $(shell find test -type f -name '*.js' | grep -v 'bundle-test.js')
BUILD_FILES = $(addprefix $(BUILD_DIR)/, \
$(MOD).js $(MOD).min.js \
bower.json)
$(MOD).core.js $(MOD).core.min.js)

DIRS = $(BUILD_DIR)

.PHONY: all clean test dist watch
.PHONY: all clean browser-test unit-test test dist

all: test
all: unit-test

bench: test
@src/bench.js
Expand All @@ -37,35 +38,43 @@ lib/version.js: package.json
$(DIRS):
@mkdir -p $@

test: $(SRC_FILES) $(TEST_FILES) node_modules | $(BUILD_DIR)
test: unit-test browser-test

unit-test: $(SRC_FILES) $(TEST_FILES) node_modules | $(BUILD_DIR)
@$(ISTANBUL) cover $(ISTANBUL_OPTS) $(MOCHA) --dir $(COVERAGE_DIR) -- $(MOCHA_OPTS) $(TEST_FILES) || $(MOCHA) $(MOCHA_OPTS) $(TEST_FILES)
@$(JSHINT) $(JSHINT_OPTS) $(filter-out node_modules, $?)
@$(JSCS) $(filter-out node_modules, $?)

$(BUILD_DIR)/bower.json: package.json src/release/make-bower.json.js
browser-test: $(BUILD_DIR)/$(MOD).js $(BUILD_DIR)/$(MOD).core.js
$(KARMA) start --single-run $(KARMA_OPTS)
$(KARMA) start karma.core.conf.js --single-run $(KARMA_OPTS)

bower.json: package.json src/release/make-bower.json.js
@src/release/make-bower.json.js > $@

$(BUILD_DIR)/$(MOD).js: browser.js | test
$(BUILD_DIR)/$(MOD).js: browser.js | unit-test
@$(BROWSERIFY) $< > $@

$(BUILD_DIR)/$(MOD).min.js: $(BUILD_DIR)/$(MOD).js
@$(UGLIFY) $< --comments '@license' > $@

dist: $(BUILD_FILES)
$(BUILD_DIR)/$(MOD).core.js: browser.js | unit-test
@$(BROWSERIFY) $< > $@ -x node_modules/lodash/dist/lodash.js

$(BUILD_DIR)/$(MOD).core.min.js: $(BUILD_DIR)/$(MOD).core.js
@$(UGLIFY) $< --comments '@license' > $@

dist: $(BUILD_FILES) | bower.json test
@rm -rf $@
@mkdir $@
cp -r $^ $@
cp LICENSE $@
@mkdir -p dist
@cp $^ dist

release: dist
@echo
@echo Starting release...
@echo
@src/release/release.sh $(MOD) dist

watch:
@src/watch.js | xargs -I{} make

clean:
rm -rf $(BUILD_DIR) dist

Expand Down
14 changes: 14 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "graphlib",
"version": "0.8.4-pre",
"main": [
"dist/graphlib.core.js",
"dist/graphlib.core.min.js"
],
"ignore": [
"README.md"
],
"dependencies": {
"lodash": "2.4.1"
}
}
Loading

0 comments on commit 44be8f4

Please sign in to comment.