Skip to content

Commit

Permalink
Merge pull request #228 from recurly/v4
Browse files Browse the repository at this point in the history
Version 4.0.0
  • Loading branch information
cbarton committed Jan 14, 2016
2 parents 551fd65 + 6b55878 commit b468d48
Show file tree
Hide file tree
Showing 64 changed files with 1,453 additions and 829 deletions.
12 changes: 12 additions & 0 deletions .travis-install-phantom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

# check to see if protobuf folder is empty
if [ ! -d "$HOME/travis-phantomjs" ]; then
mkdir $HOME/travis-phantomjs
wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $HOME/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
tar -xvf $HOME/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $HOME/travis-phantomjs
export PATH=$HOME/travis-phantomjs:$PATH
else
echo 'Using cached phantom-js';
fi
50 changes: 27 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
language: node_js
sudo: false
node_js:
- '0.12'
install:
- mkdir travis-phantomjs
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs:$PATH
- '4.1'
before_install:
- bash .travis-install-phantom.sh
cache:
directories:
- $HOME/travis-phantomjs
script:
- 'if [ -n "$ARTIFACT" ]; then make test; else make test-sauce; fi'
before_script:
- 'if [ -n "$ARTIFACT" ]; then gem install travis-artifacts; fi'
after_success:
- 'if [ -n "$ARTIFACT" ]; then cd build; travis-artifacts upload --path recurly.min.js --target-path artifacts/$TRAVIS_COMMIT; fi'
addons:
artifacts:
paths:
- build
target_paths:
- artifacts/$TRAVIS_COMMIT
s3_region: us-west-1
permissions: public-read
env:
global:
- secure: 1Fve9UwwgFSoX0Qemh2CkAN9Nyo/bkT5nrHx0MVbc4jRziw8IWdluOPNnzg+Zpx7NXu1BPIUsOvMCjsfJcpJhiuqNPMZZHFfT7vOXW3Htj3UbxrQKpNpyFPQSfCoO4Xz7a3VNusLLqx1RTnFr7plV9F7vrUf8IsL1yYXCyWa6W0=
- secure: QLUFB2xoxYmlhIgsuyZzcOY9qKeB6Ct/WOmXXfOkX5bOMyWvjnTtWK5x2qRn813qFBX3/xED9CcQhmJBEgzCBCXodFkgAXGON1mIqJvN5ubBs2fsejF4+/dnVnSiZ3zy0bQKEofTJJZisESaQ4N7a/CmIXgBJtFedDGvxB4ibSs=
- secure: NUIojJW7KxzxTvWDKAwPb9ph8x1G/tEE3UL50HRsCOjEbtKYWJT887T3ZAzTXMslZictEeBUD9d4/BymUUy6dOfvohhMCZbXy5ebFHDnCiayPnoxtYXDjaoSZoMTM/wkcFBCNXtauzrkAD1q+aSauONLcSSu0IM5V4LMsCRAz3E=
- secure: hP6DZjohCePpsqNoD0gzaOwWij4GIh3znS0SY87HCVzsymkrL23t0R4vKxmqOp+qQ3erSwDFT0B6NImWMnIhroIBNzWXrZ8AsT8PACv/fCOzxpR0UuiBOZMPXnkCzygoSmLYF/Xg72kyDSAABdWNwPxLEc0tBIH/e0iN8G2R2sg=
- ARTIFACTS_BUCKET=recurly-js
- secure: dzZNq3i4t8fMRoQWSKr4QQNSh4dBk9u1pDtwBh+dNx4bbgNC2EyXOcjL6vTPH0poDf71ggbt5VpyiqebU9bTA3+hMrMLJPPqKT54z7o58ESoUB1VHzWh40p++2uvZwIJC2HSWTdQDp/Hl3JDG4dCyD4sxuJrACa50gHp8xj0Pcc=
- secure: HcEuKA0wbmbdDo9xXzZ8ICZW750EYNKzqeAYIXJWAVhnMwKQ/LXbJhbBhV4jSjWc73pTAi9ZD57UqxoH4/14KpwK8MKPxN5QZV5l4O/1HtOyL/REMhM1dr9RCM0wbSPMeVU/vwggIeW/YSk2WHYEc+smtWAjQeJJiV8+WS4eAu8=
- secure: jQt9v3zZAKmq774J4TOm8a6Zgxea83faf++RRM3azsgLSz5vLfZK6IH4UiC9SmiMZVTYa87mTA71+IO8Mg0lUDJoF8F3EHB+U957el4fDdGak5OULz6FCh0tME1lsstHi+GJ3GtdJGA1DsC6bUR+DsPB5anZZ+wl3QGdUCJToeY=
- secure: Bv5h9pXMa5O0EdOuN2Dt1n9/+T1dMHimnn6XQb0ozjfwzjfhcPR6eKHkOxDVJ0c1rzne48ql0FK0P42QaCdZpEmy8wUyUTmI1gTMhjILcFbQFk+r9GOwGJsPttLNRS2J9+8u5tEDZjf5LiCnPBjy6vIinK7nlas93xTLTQwNEmI=
- secure: yIrHdkLhWtO37N24cRU71PK80zvkPzlJ1Jm+1MS3C6/icgJ8At1N/UgpBdxuBs1tlJm1O7Ahk+/MhpGWlspx9tCF7Hzw9Rj0xpKhqsvM155zgH582xNPwNebiCr/tmsH2/ELgFBBgC9sCW5luzeKx9nyuedGA4fmD2fK5Phc5EE=
matrix:
- BROWSER: chrome
- BROWSER: firefox
- BROWSER: safari
- BROWSER: ie:11
- BROWSER: ie:10
- BROWSER: ie:9
- BROWSER: iphone:8
- BROWSER: iphone:7
- BROWSER: iphone:6
# - BROWSER: chrome
# - BROWSER: firefox
# - BROWSER: safari
# - BROWSER: ie:11
# - BROWSER: ie:10
# - BROWSER: ie:9
# - BROWSER: iphone:8
# - BROWSER: iphone:7
# - BROWSER: iphone:6
- ARTIFACT: 1
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Recurly.js CHANGELOG

### Version 4.0.0 (Jan 13, 2016)

* Adds support for hosted fields for card transactions: recurly-hosted iframes
are injected in place of card fields
* Adds recurly.ready
* Adds eventing to main recurly instance
* Adds 'ready', 'change', and 'field:submit' events

### Version 3.1.1 (June 11, 2015)

* Adds single use coupon support to discount calculations [#204][204]
Expand Down
56 changes: 31 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
BIN = node_modules/.bin
DUO = $(BIN)/duo
T = $(BIN)/duo-test -m test/api.js -R spec -P 8378
# T = $(BIN)/duo-test -m test/api.js -R spec -P 8378

BIN = node_modules/.bin
WEBPACK = $(BIN)/webpack
KARMA = $(BIN)/karma
SERVER = $(BIN)/webpack-dev-server
SRC = index.js $(shell find lib -type f -name '*.js')
TESTS = $(wildcard test/*.test.js)

test: test-phantomjs

test-phantomjs: build build/test.js
@$(T) phantomjs

test-browser: build build/test.js
@$(T) browser
TESTS = $(shell find test -type f -name '*.js')

test-sauce: BROWSER ?= ie:9
test-sauce: build build/test.js
@$(T) saucelabs -b $(BROWSER)
server: build
@$(SERVER) --inline --hot --port 8020

build: build/recurly.min.js

build/recurly.js: index.js $(SRC) node_modules component.json
build/recurly.js: index.js $(SRC) node_modules
@mkdir -p $(@D)
@$(DUO) --quiet --stdout --global recurly < $< > $@
@$(WEBPACK) --display-reasons --display-chunks

build/recurly.min.js: build/recurly.js
@$(BIN)/uglifyjs $< --output $@
@$(WEBPACK) -p

build/test.js: $(SRC) $(TESTS)
@$(WEBPACK) --config webpack.test.config.js

test: build build/test.js
@$(KARMA) start karma.conf.js

test-sauce:

# test: test-phantomjs

# test-phantomjs: build build/test.js
# @$(T) phantomjs

build/test.js: TESTFILE = $(foreach test, $(TESTS), 'require("./$(test)");')
build/test.js: $(TESTS)
@echo $(TESTFILE) | $(DUO) --quiet --development --type js --stdout > $@
# test-browser: build build/test.js
# @$(T) browser

watch: node_modules
@$(BIN)/wr $(MAKE) component.json $(SRC)
# test-sauce: BROWSER ?= ie:9
# test-sauce: build build/test.js
# @$(T) saucelabs -b $(BROWSER)

node_modules: package.json
@npm install --silent

clean:
@rm -rf node_modules components/duo.json build
@rm -rf node_modules build

.PHONY: test watch clean
.PHONY: test clean
34 changes: 0 additions & 34 deletions component.json

This file was deleted.

3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

/*!
* Module dependencies.
*/

var Recurly = require('./lib/recurly');
const Recurly = require('./lib/recurly').Recurly;

/**
* Export a single instance.
Expand Down
29 changes: 29 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'fixture', 'sinon', 'phantomjs-shim', 'source-map-support'],
files: [
'build/recurly.js',
'build/test.js',
{ pattern: 'test/support/fixtures/*' },
],
proxies: { '/api': 'http://localhost:9877' },
preprocessors: {
'test/support/fixtures/*.html': ['html2js'],
'test/support/fixtures/*.json': ['json_fixtures']
},
jsonFixturesPreprocessor: {
variableName: '__json__'
},
reporters: ['mocha'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: true,
concurrency: Infinity
});
};

var server = require('./test/server');
18 changes: 16 additions & 2 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ errors.add = function (name, config) {
Error.call(this);

this.name = this.code = name;
this.message = config.message;
if (config.message instanceof Function) {
this.message = config.message(context);
} else {
this.message = config.message;
}
mixin(this, context || {});

if (config.help) {
Expand Down Expand Up @@ -116,11 +120,21 @@ errors.add('not-configured', {
help: '#identify-your-site'
});

errors.add('missing-public-key', {
errors.add('config-missing-public-key', {
message: 'The publicKey setting is required.',
help: '#identify-your-site'
});

errors.add('config-missing-fields', {
message: 'The fields setting is required.',
// TODO: Link to docs
// help: '#identify-your-site'
});

errors.add('missing-hosted-field-target', {
message: c => `Target element not found for ${c.type} field using selector '${c.selector}'`
});

errors.add('api-error', {
message: 'There was an error with your request.'
});
Expand Down
Loading

0 comments on commit b468d48

Please sign in to comment.