mirror of
https://github.com/jakejarvis/netlify-plugin-cache.git
synced 2025-04-26 02:55:22 -04:00
add very basic linting & expand CI tests to Node >=10
This commit is contained in:
parent
a32494baca
commit
29cf08d5ff
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -4,14 +4,23 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
node: [14.x, 13.x, 12.x, 10.x]
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
name: Node ${{ matrix.node }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12'
|
||||
- run: npm install -g netlify-cli
|
||||
- run: netlify build
|
||||
node-version: ${{ matrix.node }}
|
||||
- name: Install dependencies
|
||||
run: npm install --no-package-lock --no-optional
|
||||
- name: Run tests
|
||||
run: npm run test
|
||||
- name: Build example site locally with plugin
|
||||
run: npm run build
|
||||
env:
|
||||
NETLIFY_SITE_ID: '8ceb6251-650b-481a-976c-fec1a4f95800'
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,6 @@
|
||||
# Local Netlify folder
|
||||
.netlify
|
||||
|
||||
node_modules/
|
||||
package-lock.json
|
||||
npm-debug.log*
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "1.0.0",
|
||||
"description": "Just a test of netlify-plugin-cache.",
|
||||
"dependencies": {
|
||||
"netlify-plugin-cache": "*",
|
||||
"netlify-plugin-cache": "file:../",
|
||||
"netlify-plugin-debug-cache": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
21
index.js
21
index.js
@ -1,7 +1,11 @@
|
||||
// Netlify Plugin: netlify-plugin-cache
|
||||
// https://github.com/jakejarvis/netlify-plugin-cache
|
||||
//
|
||||
// This plugin is essentially a wrapper around Netlify's native `cache-utils`:
|
||||
// https://github.com/netlify/build/blob/master/packages/cache-utils/README.md
|
||||
|
||||
module.exports = {
|
||||
// try to restore cache before build begins, if it exists
|
||||
// Try to restore cache before build begins, if it exists
|
||||
onPreBuild: async ({ utils: { cache }, inputs }) => {
|
||||
if (await cache.restore(inputs.paths)) {
|
||||
const files = await cache.list(inputs.paths)
|
||||
@ -11,24 +15,23 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
// only save/update cache if build was successful
|
||||
// Only save/update cache if build was successful
|
||||
onSuccess: async ({ utils: { cache, status }, inputs }) => {
|
||||
if (await cache.save(inputs.paths)) {
|
||||
const files = await cache.list(inputs.paths)
|
||||
console.log(`Successfully cached: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
|
||||
|
||||
// show success & more detail in deploy summary
|
||||
// Show success & more detail in deploy summary
|
||||
status.show({
|
||||
title: `${files.length} files cached`,
|
||||
summary: 'These will be restored on the next build! ⚡',
|
||||
text: `${inputs.paths.join(', ')}`,
|
||||
text: `${inputs.paths.join(', ')}`
|
||||
})
|
||||
} else {
|
||||
// this probably happened because the default `paths` is set, so provide instructions to fix
|
||||
// This probably happened because the default `paths` is set, so provide instructions to fix
|
||||
console.log(`Attempted to cache: ${inputs.paths.join(', ')} ... but failed. :(`)
|
||||
console.log(`Try setting the 'paths' input appropriately in your netlify.toml configuration.`)
|
||||
console.log(`More details: https://jrvs.io/netlify-cache-usage`)
|
||||
console.log('Try setting the \'paths\' input appropriately in your netlify.toml configuration.')
|
||||
console.log('More details: https://jrvs.io/netlify-cache-usage')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
28
package.json
28
package.json
@ -2,17 +2,30 @@
|
||||
"name": "netlify-plugin-cache",
|
||||
"version": "1.0.3",
|
||||
"description": "Generic cache plugin for saving and restoring files and/or folders between Netlify builds",
|
||||
"author": "Jake Jarvis <jake@jarv.is>",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"author": {
|
||||
"name": "Jake Jarvis",
|
||||
"email": "jake@jarv.is",
|
||||
"url": "http://jarv.is/"
|
||||
},
|
||||
"homepage": "https://github.com/jakejarvis/netlify-plugin-cache#readme",
|
||||
"bugs": "https://github.com/jakejarvis/netlify-plugin-cache/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jakejarvis/netlify-plugin-cache.git"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"build": "netlify build",
|
||||
"test": "xo"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"netlify-cli": "*",
|
||||
"xo": "~0.32.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.18"
|
||||
},
|
||||
"keywords": [
|
||||
"netlify",
|
||||
@ -21,5 +34,12 @@
|
||||
"ci",
|
||||
"build",
|
||||
"plugin"
|
||||
]
|
||||
],
|
||||
"xo": {
|
||||
"semicolon": false,
|
||||
"space": 2,
|
||||
"rules": {
|
||||
"object-curly-spacing": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user