Skip to content

Commit

Permalink
Merge pull request #18 from aaronmars/master
Browse files Browse the repository at this point in the history
Add release workflow
  • Loading branch information
aaronmars authored Mar 17, 2017
2 parents 20f25f0 + 126261c commit 3d6ec70
Show file tree
Hide file tree
Showing 48 changed files with 26,973 additions and 28 deletions.
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"valid-jsdoc": [ 1, {
"prefer": { "return": "returns" },
"preferType": { "object": "Object", "string": "String", "number": "Number" },
"requireReturn": false,
"requireReturnType": true,
"requireParamDescription": true,
"requireReturnDescription": true
} ]
}
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules/
__coverage-*__/
.idea
.DS_Store
npm-debug.log
.idea/
yarn.lock
26 changes: 26 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"tags": {
"allowUnknownTags": false,
"dictionaries": [ "jsdoc", "closure" ]
},
"source": {
"include": [ "." ],
"exclude": [ "main.js" ],
"includePattern": ".+\\.js?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"opts": {
"recurse": false,
"pedantic": true,
"destination": "./docs/",
"readme": "README.md"
},
"plugins": [],
"templates": {
"cleverLinks": true,
"monospaceLinks": false,
"default": {
"includeDate": false
}
}
}
29 changes: 29 additions & 0 deletions .makerelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [ -z $1 ]; then
echo "A version number must be supplied."
exit 1
fi

yarn docs
if [ $? -gt 0 ]; then
echo "Failed while generating the docs for release $1."
exit 1
fi

yarn bundle
if [ $? -gt 0 ]; then
echo "Failed while generating CJS bundle $1."
exit 1
fi

# TODO: Commit the docs and bundle
# TODO: Remove the `--no-git-tag-version` argument below so a tag will be created along with the version bump.

yarn version --new-version $1 --no-git-tag-version
if [ $? -gt 0 ]; then
echo "Failure setting the new version."
exit 1
fi

# TODO: Create a github release based on the new tag
5 changes: 5 additions & 0 deletions .rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
entry: './main.js',
format: 'cjs',
dest: 'dist/index.js'
};
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ notifications:

# engineering-webdevs
- secure: "Zcql51JT8oqV0dhYEThtkd0jPD34z2fyIShCmFeEs/2Mj7vvl3c4OYG5fKJTZPC6zt3rmptCQU/wrzgQKJ6WQ2Aj4mkMVjf+6BUl+vXcEY3+/V+ciNulgsVnAR2WN8W4XvXIZNNvdDuiEZDB/rIc5q1ksueGUNLPEWYz2aRxp7kSoZRv3fQpc8AaIFjY0DmBI/X7C/BLN5MH++qA+3T5uzHt/ny2h6HJXKBTKifhlm/viJZTb6fpS0CZyUTgBSpjh1JRPKBPYeXUC5aODz/z5dp2l3/Y6nr7uhfFMdjvpNAI0juw/2v6qx313iuY9/cso1mnFW1y23GciyAS4dx2iffy7nyCPpd+xA644cxM83PqkIcZNFNyU3gcDhCVXjMEM+rsXvBDwmxq+TbABLGLElSQ93Qvf57enXBAZ10qW3WTV7H+NlHueI0ncgnX8DF+apmNHdMm38yTEcJ0Wy/LTwYuwzZyRnZ6UDjBIJtXiiNcD6VdxL6vUm6SHbLC4ZQq2L3vE47gj8pBveFoS3/jLMf3Ahc3+9f65GV6l83mvKkBnyHe/hhfdMdSVFith03KwbgwS0AONyCNYTQdfrxBuZEO9Co9KDsz0xu2WHVcX36Ts/vVhTSNei4R7Gj4P3EZO2Z8TcHbNjlmvF4Or3Ji7B1lMCCVRoJlrJzUXdWsCpQ="
cache:
directories:
- $HOME/.npm

before_install: npm -g install npm@3
cache: yarn

install: npm install
# Since we have yarn.lock, package.json, and node >= v4, the `install` step is implied

script:
- npm run test
- npm run test-node
- npm run inspect
- yarn inspect
- yarn test-jsdom
- yarn test-node

after_success: bash <(curl -s https://codecov.io/bash)
24 changes: 13 additions & 11 deletions __tests__/plug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,24 @@ describe('Plug JS', () => {
p = null;
});
describe('GET', () => {
pit('can do a basic GET request', () => {
it('can do a basic GET request', () => {
return p.get();
});
pit('can do a basic HEAD request', () => {
it('can do a basic HEAD request', () => {
return p.head();
});
pit('can do a basic OPTIONS request', () => {
it('can do a basic OPTIONS request', () => {
return p.options();
});
});
describe('POST', () => {
pit('can do a basic POST request', () => {
it('can do a basic POST request', () => {
return p.post('{"foo": "BAZ"}', 'application/json');
});
pit('can do a basic PUT request', () => {
it('can do a basic PUT request', () => {
return p.put('{"foo": "BAZ"}', 'application/json');
});
pit('can do a basic DELETE request', () => {
it('can do a basic DELETE request', () => {
return p.delete();
});
});
Expand All @@ -136,7 +136,7 @@ describe('Plug JS', () => {
afterEach(() => {
p = null;
});
pit('can hook into the beforeRequest handler', () => {
it('can hook into the beforeRequest handler', () => {
return p.at('foo', 'bar').withParam('dog', 'cat').withHeaders({ 'X-Some-Custom-Header': 'Hello' }).get().then(() => {
expect(mockBeforeRequest).toBeCalled();
});
Expand All @@ -150,32 +150,34 @@ describe('Plug JS', () => {
afterEach(() => {
p = null;
});
pit('can fail with a 5xx error', () => {
it('can fail with a 5xx error', () => {
global.fetch = jest.genMockFunction().mockReturnValueOnce(Promise.resolve(new Response('', { status: 500 })));
return p.get().catch((e) => expect(e).toBeDefined());
});
pit('can pass with a 304 status', () => {
it('can pass with a 304 status', () => {
global.fetch = jest.genMockFunction().mockReturnValueOnce(Promise.resolve(new Response('', { status: 304 })));
return p.get();
});
});
describe('Cookie Jar', () => {
let p = null;
const cookieJar = require('../lib/cookieJar');
beforeEach(() => {
global.fetch = jest.genMockFunction().mockReturnValueOnce(Promise.resolve(new Response()));
p = new Plug('http://example.com/', { cookieManager: cookieJar });
});
afterEach(() => {
p = null;
global.fetch = null;
});
it('can do requests with a cookie jar in place', () => {
const cookieJar = require('../lib/cookieJar');
cookieJar.getCookieString = jest.genMockFunction().mockReturnValueOnce(Promise.resolve('value=this is a cookie value'));
p = new Plug('http://example.com/', { cookieManager: cookieJar });
return p.get();
});
it('can do requests with a cookie jar in place (empty cookie)', () => {
const cookieJar = require('../lib/cookieJar');
cookieJar.getCookieString = jest.genMockFunction().mockReturnValueOnce(Promise.resolve(''));
p = new Plug('http://example.com/', { cookieManager: cookieJar });
return p.get();
});
});
Expand Down
1 change: 1 addition & 0 deletions __tests__/uri.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('URI', () => {
it('can construct a plain URI', () => {
let uri = new Uri('http://www.example.com');
expect(uri).toBeDefined();
expect(uri.search).toBe('');
});
it('can construct an empty URI', () => {
let uri = new Uri();
Expand Down
Loading

0 comments on commit 3d6ec70

Please sign in to comment.