Get notified when stuff changes.
Install Homebrew.
brew bundleConfigure your shell for asdf. Restart your terminal session.
asdf plugin install deno
asdf installCopy the example config to the default location and customise as necessary.
mkdir -p ~/.config/checker
cp config.example.yml ~/.config/checker/config.yml
vim ~/.config/checker/config.yml # Set up at least one source and destinationSource plugins by default go in ~/.config/checker/plugins/source. Here's an example, sheeran.ts, which is a plugin
that checks whether Ed Sheeran is playing in certain countries any time soon.
import BaseSourcePlugin, {
zod as z,
} from 'https://raw.githubusercontent.com/cameronmurphy/checker/main/src/plugins/source/base.ts';
import StrlenComparator from 'https://raw.githubusercontent.com/cameronmurphy/checker/main/src/comparator/strlen.ts';
import { DOMParser } from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts';
export default class SheeranSource extends BaseSourcePlugin {
private schema = BaseSourcePlugin.ConfigSchema.extend({
items: z.array(z.string()).min(1, 'Sheeran plugin requires at least one country name'),
});
public getSchema() {
return this.schema;
}
public async read(item: string) {
const response = await fetch('https://www.edsheeran.com/#tour');
const text = await response.text();
const doc = new DOMParser().parseFromString(text, 'text/html');
const locations = Array.from(doc?.querySelectorAll('.event_location') || []);
const relevantLocations = locations.filter((el) => el.textContent?.includes(item));
const dates = relevantLocations.map((el) => el.parentElement?.querySelector('.event_dates')?.textContent?.trim());
return dates.filter(Boolean).join();
}
public updated(before: string, after: string) {
return new StrlenComparator().updated(before, after);
}
public message(_before: string, after: string, item?: string) {
return `Ed Sheeran is playing in ${item} on ${after}!`;
}
}Then you would configure this plugin like so:
config:
sources:
sheeran:
items:
- 'Australia'Run the app and automatically reload when the code changes.
deno task devRun the app.
deno task runRun the app against a different config file.
deno task run --config-file /usr/local/etc/checker/config.ymlTo upgrade all dependencies:
deno task upgrade-deps