chore: clean up and bump node version

This commit is contained in:
Jef LeCompte
2021-01-17 13:44:05 -05:00
parent b2ebac36c0
commit dbde7814af
19 changed files with 38 additions and 40 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.4 - uses: actions/setup-node@v2.1.4
with: with:
node-version: 14.15.0 node-version: 14.15.4
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: ~/.npm path: ~/.npm
+1 -1
View File
@@ -1 +1 @@
14.15.0 14.15.4
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "streetmerchant", "name": "streetmerchant",
"description": "🔮 For all your Nvidia needs", "description": "The world's easiest, most powerful stock checker",
"main": "src/index.ts", "main": "src/index.ts",
"scripts": { "scripts": {
"all": "npm run build && npm run lint", "all": "npm run build && npm run lint",
+1 -1
View File
@@ -4,7 +4,7 @@ import {config} from '../config';
import {join} from 'path'; import {join} from 'path';
import notifier from 'node-notifier'; import notifier from 'node-notifier';
const desktop = config.notifications.desktop; const {desktop} = config.notifications;
export function sendDesktopNotification(link: Link, store: Store) { export function sendDesktopNotification(link: Link, store: Store) {
if (desktop) { if (desktop) {
+1 -2
View File
@@ -3,8 +3,7 @@ import Discord from 'discord.js';
import {config} from '../config'; import {config} from '../config';
import {logger} from '../logger'; import {logger} from '../logger';
const discord = config.notifications.discord; const {notifyGroup, webhooks, notifyGroupSeries} = config.notifications.discord;
const {notifyGroup, webhooks, notifyGroupSeries} = discord;
function getIdAndToken(webhook: string) { function getIdAndToken(webhook: string) {
const match = /.*\/webhooks\/(\d+)\/(.+)/.exec(webhook); const match = /.*\/webhooks\/(\d+)\/(.+)/.exec(webhook);
+1 -1
View File
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
import {config} from '../config'; import {config} from '../config';
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
const email = config.notifications.email; const {email} = config.notifications;
const transportOptions: any = {}; const transportOptions: any = {};
+1 -1
View File
@@ -3,7 +3,7 @@ import MqttClient, {IClientOptions, IClientPublishOptions} from 'mqtt';
import {Print, logger} from '../logger'; import {Print, logger} from '../logger';
import {config} from '../config'; import {config} from '../config';
const mqtt = config.notifications.mqtt; const {mqtt} = config.notifications;
let client: MqttClient.Client; let client: MqttClient.Client;
if (mqtt.broker) { if (mqtt.broker) {
+16 -15
View File
@@ -3,18 +3,19 @@ import {config} from '../config';
import {v3 as hueAPI} from 'node-hue-api'; import {v3 as hueAPI} from 'node-hue-api';
import {logger} from '../logger'; import {logger} from '../logger';
const hue = config.notifications.philips_hue; const {LightState} = hueAPI.lightStates;
const apiKey = hue.apiKey; const {
const bridgeIp = hue.bridgeIp; apiKey,
const lightIds = hue.lightIds; bridgeIp,
const lightColor = hue.lightColor; lightIds,
const lightPattern = hue.lightPattern; lightColor,
const LightState = hueAPI.lightStates.LightState; lightPattern,
const clientId = hue.clientId; clientId,
const clientSecret = hue.clientSecret; clientSecret,
const accessToken = hue.accessToken; accessToken,
const refreshToken = hue.refreshToken; refreshToken,
const remoteApiUsername = hue.remoteApiUsername; remoteApiUsername
} = config.notifications.philips_hue;
// Default Light State // Default Light State
const lightState = new LightState() const lightState = new LightState()
@@ -81,7 +82,7 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
export function adjustPhilipsHueLights() { export function adjustPhilipsHueLights() {
// Check if the required variables have been set // Check if the required variables have been set
if (hue.apiKey && hue.bridgeIp) { if (apiKey && bridgeIp) {
logger.info('↗ adjusting Philips Hue lights over LAN'); logger.info('↗ adjusting Philips Hue lights over LAN');
(async () => { (async () => {
logger.debug( logger.debug(
@@ -100,7 +101,7 @@ export function adjustPhilipsHueLights() {
} }
); );
})(); })();
} else if (hue.apiKey && hue.clientId && hue.clientSecret) { } else if (apiKey && clientId && clientSecret) {
logger.info('↗ adjusting Philips Hue lights over cloud'); logger.info('↗ adjusting Philips Hue lights over cloud');
(async () => { (async () => {
logger.debug( logger.debug(
@@ -110,7 +111,7 @@ export function adjustPhilipsHueLights() {
clientId, clientId,
clientSecret clientSecret
); );
if (hue.accessToken && hue.refreshToken) { if (accessToken && refreshToken) {
remoteBootstrap remoteBootstrap
.connectWithTokens( .connectWithTokens(
accessToken, accessToken,
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import PushBullet from '@jef/pushbullet'; import PushBullet from '@jef/pushbullet';
import {config} from '../config'; import {config} from '../config';
const pushbullet = config.notifications.pushbullet; const {pushbullet} = config.notifications;
export function sendPushbulletNotification(link: Link, store: Store) { export function sendPushbulletNotification(link: Link, store: Store) {
if (pushbullet) { if (pushbullet) {
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import Push, {PushoverMessage} from 'pushover-notifications'; import Push, {PushoverMessage} from 'pushover-notifications';
import {config} from '../config'; import {config} from '../config';
const pushover = config.notifications.pushover; const {pushover} = config.notifications;
export function sendPushoverNotification(link: Link, store: Store) { export function sendPushoverNotification(link: Link, store: Store) {
if (pushover.token && pushover.username) { if (pushover.token && pushover.username) {
+3 -5
View File
@@ -3,13 +3,11 @@ import {Print, logger} from '../logger';
import {WebClient} from '@slack/web-api'; import {WebClient} from '@slack/web-api';
import {config} from '../config'; import {config} from '../config';
const slack = config.notifications.slack; const {channel, token} = config.notifications.slack;
const channel = slack.channel.replace('#', '');
const token = slack.token;
const web = new WebClient(token); const web = new WebClient(token);
export function sendSlackMessage(link: Link, store: Store) { export function sendSlackMessage(link: Link, store: Store) {
if (slack.channel && slack.token) { if (channel && token) {
logger.debug('↗ sending slack message'); logger.debug('↗ sending slack message');
(async () => { (async () => {
@@ -17,7 +15,7 @@ export function sendSlackMessage(link: Link, store: Store) {
try { try {
const result = await web.chat.postMessage({ const result = await web.chat.postMessage({
channel, channel: channel.replace('#', ''),
text: `${Print.inStock(link, store)}\n${givenUrl}` text: `${Print.inStock(link, store)}\n${givenUrl}`
}); });
+1 -1
View File
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
import {config} from '../config'; import {config} from '../config';
import {transporter} from './email'; import {transporter} from './email';
const [email, phone] = [config.notifications.email, config.notifications.phone]; const {email, phone} = config.notifications;
if (phone.number.length > 0 && (!email.username || !email.password)) { if (phone.number.length > 0 && (!email.username || !email.password)) {
logger.warn( logger.warn(
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import {TelegramClient} from 'messaging-api-telegram'; import {TelegramClient} from 'messaging-api-telegram';
import {config} from '../config'; import {config} from '../config';
const telegram = config.notifications.telegram; const {telegram} = config.notifications;
const client = new TelegramClient({ const client = new TelegramClient({
accessToken: telegram.accessToken accessToken: telegram.accessToken
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import {Twilio} from 'twilio'; import {Twilio} from 'twilio';
import {config} from '../config'; import {config} from '../config';
const twilio = config.notifications.twilio; const {twilio} = config.notifications;
let client: Twilio; let client: Twilio;
if (twilio.accountSid && twilio.authToken) { if (twilio.accountSid && twilio.authToken) {
+1 -1
View File
@@ -5,7 +5,7 @@ import {existsSync, promises, readFileSync} from 'fs';
import {ChatClient} from 'twitch-chat-client'; import {ChatClient} from 'twitch-chat-client';
import {config} from '../config'; import {config} from '../config';
const twitch = config.notifications.twitch; const {twitch} = config.notifications;
const messages: string[] = []; const messages: string[] = [];
let alreadySaying = false; let alreadySaying = false;
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import Twitter from 'twitter'; import Twitter from 'twitter';
import {config} from '../config'; import {config} from '../config';
const twitter = config.notifications.twitter; const {twitter} = config.notifications;
const client = new Twitter({ const client = new Twitter({
access_token_key: twitter.accessTokenKey, access_token_key: twitter.accessTokenKey,
+1 -1
View File
@@ -21,7 +21,7 @@ export async function processBackoffDelay(
* the page renders fine and its content is accessible. * the page renders fine and its content is accessible.
*/ */
let backoffStatusCodes = store.backoffStatusCodes; let {backoffStatusCodes} = store;
if (!backoffStatusCodes) { if (!backoffStatusCodes) {
backoffStatusCodes = [403]; backoffStatusCodes = [403];
+3 -3
View File
@@ -366,15 +366,15 @@ export function updateStores() {
updateStores(); updateStores();
export function getAllBrands() { export function getAllBrands() {
return Array.from(brands); return [...brands];
} }
export function getAllSeries() { export function getAllSeries() {
return Array.from(series); return [...series];
} }
export function getAllModels() { export function getAllModels() {
return Array.from(models); return [...models];
} }
export function getStores() { export function getStores() {
+1 -1
View File
@@ -120,7 +120,7 @@ function handleAPI(
sendConfig(response); sendConfig(response);
return; return;
case 'stores': case 'stores':
sendJSON(response, Array.from(storeList.keys())); sendJSON(response, [...storeList.keys()]);
return; return;
case 'brands': case 'brands':
sendJSON(response, getAllBrands()); sendJSON(response, getAllBrands());