Updater for forked Beaker sites. It simply checks the version in package.json and downloads a set of files from the upstream.
npm i -S forkup
package.json:
{
"update": {
"url": "dat://b89507488b68892978dcdc6cb32e21040b2cd0fdcd304c502e17289aad10d95e/",
"files": [
"/bundle.js"
]
}
}Somewhere in your project:
const update = require('forkup')
update() // with package.json (recommended)
update('dat://b89507488b68892978dcdc6cb32e21040b2cd0fdcd304c502e17289aad10d95e/', ['/bundle.js']) // alternatively, without package.json (not recommended)Add an "update" field to your package.json (located in the root folder).
{
"update": {
"url": "<upstream dat url>",
"files": [
"<file>",
"<file>"
]
}
}I usually add an /update route to my Choo pages that calls this method. See in solo.
Alternatively you can use the check and update functions separately.
Parameters required only if not using package.json. Updates every file in files if the version is less then the version at dat_url (the URL of the upstream site).
Parameter required only if not using package.json. Checks if update is available. If yes returns an Array, else false.
files is only required if not using package.json. archives is the output of check. Does the update.