Skip to content

Commit

Permalink
Merge pull request #9 from Brightspace/polymer-3-conversion
Browse files Browse the repository at this point in the history
Polymer 3 Conversion [increment major]
  • Loading branch information
awikkerink authored Jan 9, 2019
2 parents 4af990e + 15c7bd9 commit 7782499
Show file tree
Hide file tree
Showing 20 changed files with 7,962 additions and 8,841 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

# Ignore built files except build/index.js
**/dist/*
test/acceptance/*
reports
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "brightspace/node-config"
"extends": "brightspace/node-config",
"parserOptions": {
"sourceType": "module"
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules/
dist/
es6/
test/dist/
test/coverage/
coverage/
bower_components


### Windows ###
Expand Down
89 changes: 89 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Created by https://www.gitignore.io

### Node ###
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules/
test/dist/
test/coverage/
coverage/


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

.vagrant

### Linux ###
*~

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*


### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Webstorm
.idea
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ env:
- secure: YdrAgVuS00fN2vydsIrCZHvao7tq6IzxMVY7q7DA1sYIAbv8UgghDSjJJheF+bm9KZ9wpMQ9O64nDTfHZApxvAj2ahjAmFbsPujBtOk7ojRcdKoOgCCrowehZrwiRQ8ZJJGjF9om2ZZKUceHXhMw/PCpJQDvm+safAs66dAsqfAExduGbq+a668iyBsxJER1AppO3erYSYrxVLLQgKtVbq86WLR5ckOmySfTTXa5wBixxYsEs5lZRJfK2fnq5iKLxyFfOu767IeRK9uia2WW8Rz6qj/R1XX0lsS+XXixMqgM8fF1yzuUggm7k1Luo2xnOPyjyjZjM6saxqFoMwBg0y9UAvdToh4yIVtBSSnA39QfQZPTWQK0kHzXz6D6w9ik6Z8TwA5WyOde1AZwqAkKIhdWhUEzC9a+OXEiBssbqvmjrA7lCU6pLQmUvBZt+FjfFQNaABTdSgSNDeu0zB0V2lsGy/85m7hlxrIxUtotjUbYBSwgiiChWFN5yQu1JP6361Mhlbfjz7MQvW4fSMJxfAw1sNrXrnefOasu8WcRaPSe1MCp6AfvS3ReAqjv9PNa7jZQFa3KuKNUoBzQ+uOaX4J3VXCRgw5234Pfng1ssTbLAdmNAH+zM8gvH9p2qO5TFsUtUzS3xQVIkf2jCH0+tIOaYL5gNnyumxHYhSzyuD4=
# GITHUB_RELEASE_TOKEN
- secure: jz/0DAzyR2V8Cy49d27qkX6WdvIImJ6AgqwxXrLYhgAShz4YCUqRu6yJjtfdx2Q8nbfRCwEQi2Qc//TPTX4Z9nadZMnQn+uXIIWqacu3M5kT/n0NzPNJ5Z6RBdlIwTqlRAWcqx2IpocmMD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ogBYGqHQ7NrE6IyXpkqee8b9JYCet6YT55a5OMxd41FV+zkebpr9vx1MF4vUm4dUn/vat9VeYSDMtA+dIKCzT5YrBx0mVQuHNMj0Qj7/ivH8KMoNC6RDpXq2DqShTd1bPeZOHwHAAQT2tJ/qnHWaE8OIuJOUmyqlCFiCVvmVDVLOGY2dRN2igS83J3lb8EM/twTOftdrgmNTGyVj837Q/2HTIhroY2w=
on:
branch: master
repo: Brightspace/d2l-fetch-simple-cache
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@ npm run build

Reference the script in your html after your reference to `d2l-fetch` (see [here](https://github.com/Brightspace/d2l-fetch) for details on d2l-fetch):

```html
<script src="https://s.brightspace.com/lib/d2lfetch/1.0.2/d2lfetch.js"></script>
<script src="../dist/d2lfetch-simple-cache.js"></script>
```

This will add the `simple-cache` middleware function to the `d2lfetch` object. Alternatively, you can install `d2l-fetch-simple-cache` via bower:

Install `d2l-fetch-simple-cache` via npm:
```sh
bower install Brightspace/d2l-fetch-simple-cache
npm install d2l-fetch-simple-cache
```

and reference it as you would any other bower package:

```html
<link rel="import" href="../d2l-fetch-simple-cache/d2l-fetch-simple-cache.html">
```javascript
import simpleCache from 'd2l-fetch-simple-cache';
```

### Simple-cache

Install the `simple-cache` middleware to d2lfetch via the `use` function and then start making your requests.

```js
window.d2lfetch.use({name: 'simple-cache' fn: window.d2lfetch.simpleCache});
d2lfetch.use({name: 'simple-cache' fn: simpleCache});

window.d2lfetch.fetch(new Request('http://example.com/api/someentity/'))
d2lfetch.fetch(new Request('http://example.com/api/someentity/'))
.then(function(response) {
// do something with the response
});
Expand All @@ -61,19 +53,19 @@ As of `d2l-fetch v1.2.0` it is possible to provide configuration options during
* `cacheLengthInSeconds`: This can be used to override the default cache length. (Default is 120 seconds)
```js
//cache responses for 5 minutes
window.d2lfetch.use({
d2lfetch.use({
name: 'simple-cache',
fn: window.d2lfetch.simpleCache,
fn: simpleCache,
options: { cacheLengthInSeconds: 600 }
});
```

* `methods`: This can be used to override the default http methods that are allowed to be cached. (Default is `['GET', 'HEAD', 'OPTIONS']`)
```js
//only cache responses from GET requests
window.d2lfetch.use({
d2lfetch.use({
name: 'simple-cache',
fn: window.d2lfetch.simpleCache,
fn: simpleCache,
options: { methods: ['GET'] }
});
```
Expand Down
2 changes: 0 additions & 2 deletions d2l-fetch-simple-cache.html

This file was deleted.

4 changes: 4 additions & 0 deletions d2l-fetch-simple-cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import simpleCache from './src/index.js';

window.d2lfetch = window.d2lfetch || {};
window.d2lfetch.simpleCache = simpleCache;
3 changes: 3 additions & 0 deletions index.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import fetchSimpleCache from './es6/d2lfetch-simple-cache.js';

export { fetchSimpleCache };
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fetchSimpleCache = require('./dist/d2lfetch-simple-cache.js');

module.exports = { fetchSimpleCache };
35 changes: 13 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,42 @@
"name": "d2l-fetch-simple-cache",
"description": "Provides a middleware function for caching fetch responses for the same url+auth combination",
"main": "index.js",
"module": "index.es6.js",
"author": "D2L Corporation",
"license": "Apache-2.0",
"scripts": {
"postinstall": "polymer install",
"build": "rollup -c rollup/rollup.config.js",
"prepare": "npm run build",
"pretest": "npm run build",
"test:lint:js": "eslint src/ test/ --ext .js",
"test:lint": "npm run test:lint:js",
"test": "npm run test:lint && npm run test:polymer:local",
"test:polymer:local": "cross-env LAUNCHPAD_BROWSERS=firefox polymer test --skip-plugin sauce",
"test:polymer:sauce": "polymer test --skip-plugin local",
"test:polymer:local": "cross-env LAUNCHPAD_BROWSERS=firefox polymer test --skip-plugin sauce --npm",
"test:polymer:sauce": "polymer test --skip-plugin local --npm",
"publish-location": "node publishLocation",
"prepublish-release": "npm run build",
"publish-release": "frau-publisher && npm run publish-location"
},
"config": {
"frauPublisher": {
"files": "./dist/**",
"moduleType": "lib",
"targetDirectory": "d2lfetch-simple-cache",
"creds": {
"key": "AKIAJY65S22AMNMEXEMQ",
"secretVar": "CDN_SECRET"
},
"devTagVar": "TRAVIS_COMMIT",
"versionVar": "TRAVIS_TAG"
}
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"babel-eslint": "^10.0.1",
"cross-env": "^5.0.0",
"eslint": "^3.19.0",
"eslint-config-brightspace": "^0.2.4",
"eslint-plugin-html": "^2.0.1",
"frau-publisher": "^2.6.2",
"polymer-cli": "^1.9.0",
"polymer-cli": "^1.9.1",
"rollup": "^0.67.1",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^3.0.0"
"wct-browser-legacy": "^1.0.1"
},
"dependencies": {
"parse-cache-control": "^1.0.1"
},
"resolutions": {
"inherits": "2.0.3",
"samsam": "1.1.3",
"supports-color": "3.1.2",
"type-detect": "1.0.0"
}
}
6 changes: 0 additions & 6 deletions publishLocation.js

This file was deleted.

35 changes: 35 additions & 0 deletions rollup/rollup.common.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';

export const config = (name, input, output, cjsOutput) => ([{
input,
plugins: [
resolve({
browser: true
}),
commonjs(),
json()
],
output: {
file: output,
format: 'esm',
name,
sourcemap: true
}
}].concat(cjsOutput ? {
input,
plugins: [
resolve({
browser: true
}),
commonjs(),
json()
],
output: {
file: cjsOutput,
format: 'cjs',
name,
sourcemap: true
}
} : []));
32 changes: 3 additions & 29 deletions rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import { config } from './rollup.common.config.js';

const config = (name, input, output) => ({
input,
plugins: [
resolve({
browser: true
}),
commonjs(),
json(),
babel({
presets: ['@babel/preset-env']
}),
terser()
],
output: {
file: `${output}`,
format: 'umd',
name,
sourcemap: false
}
});

export default [
config('d2lfetch.simpleCache', './src/index.js', './dist/d2lfetch-simple-cache.js')
];
export default
config('d2lfetch.simpleCache', './src/index.js', './es6/d2lfetch-simple-cache.js', './dist/d2lfetch-simple-cache.js');
5 changes: 4 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "brightspace/wct-config"
"extends": "brightspace/wct-config",
"parserOptions": {
"sourceType": "module"
}
}
5 changes: 2 additions & 3 deletions test/d2l-fetch-simple-cache/d2l-fetch-simple-cache.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<script src="../../../web-component-tester/browser.js"></script>
<script src="../../dist/d2lfetch-simple-cache.js"></script>
<script src="../../../wct-browser-legacy/browser.js"></script>
</head>
<body>
<test-fixture id="d2l-fetch-simple-cache-fixture">
Expand All @@ -13,6 +12,6 @@
</template>
</test-fixture>

<script src="d2l-fetch-simple-cache.js"></script>
<script type="module" src="d2l-fetch-simple-cache.js"></script>
</body>
</html>
Loading

0 comments on commit 7782499

Please sign in to comment.