feat(docs): add mkdocs

This commit is contained in:
Jef LeCompte
2020-12-07 00:18:43 -05:00
parent bc2272e59a
commit 243109a4ff
53 changed files with 1112 additions and 644 deletions
+4 -2
View File
@@ -31,7 +31,7 @@ export function sendDiscordMessage(link: Link, store: Store) {
'> provided by [streetmerchant](https://github.com/jef/streetmerchant) with :heart:'
)
.setThumbnail(
'https://raw.githubusercontent.com/jef/streetmerchant/main/media/streetmerchant-square.png'
'https://raw.githubusercontent.com/jef/streetmerchant/main/docs/assets/images/streetmerchant-square.png'
)
.setColor('#52b788')
.setTimestamp();
@@ -57,7 +57,9 @@ export function sendDiscordMessage(link: Link, store: Store) {
});
}
(await Promise.all(promises)).forEach(({client}) => client.destroy());
(await Promise.all(promises)).forEach(({client}) =>
client.destroy()
);
logger.info('✔ discord message sent');
} catch (error: unknown) {
+23 -11
View File
@@ -45,13 +45,14 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
const arrayOfIDs = lightIds.split(',');
arrayOfIDs.forEach((light) => {
logger.debug('adjusting all hue lights');
(hueBridge.lights.setLightState(light, lightState) as Promise<any>).catch(
(error: Error) => {
logger.error('Failed to adjust all lights.');
logger.error(error);
throw error;
}
);
(hueBridge.lights.setLightState(
light,
lightState
) as Promise<any>).catch((error: Error) => {
logger.error('Failed to adjust all lights.');
logger.error(error);
throw error;
});
});
} else {
// Adjust all light IDs
@@ -102,15 +103,26 @@ export function adjustPhilipsHueLights() {
} else if (hue.apiKey && hue.clientId && hue.clientSecret) {
logger.info('↗ adjusting Philips Hue lights over cloud');
(async () => {
logger.debug('Attempting to connect to Philips Hue bridge over cloud');
const remoteBootstrap = hueAPI.api.createRemote(clientId, clientSecret);
logger.debug(
'Attempting to connect to Philips Hue bridge over cloud'
);
const remoteBootstrap = hueAPI.api.createRemote(
clientId,
clientSecret
);
if (hue.accessToken && hue.refreshToken) {
remoteBootstrap
.connectWithTokens(accessToken, refreshToken, remoteApiUsername)
.connectWithTokens(
accessToken,
refreshToken,
remoteApiUsername
)
.then(
(hueBridge) => {
adjustLightsWithAPI(hueBridge);
logger.info('✔ adjusted Philips Hue lights over cloud');
logger.info(
'✔ adjusted Philips Hue lights over cloud'
);
},
(error: Error) => {
logger.error(
+1 -1
View File
@@ -4,7 +4,7 @@ import {WebClient} from '@slack/web-api';
import {config} from '../config';
const slack = config.notifications.slack;
const channel = slack.channel;
const channel = slack.channel.replace('#', '');
const token = slack.token;
const web = new WebClient(token);
+17 -11
View File
@@ -20,19 +20,25 @@ export function playSound() {
if (config.notifications.playSound && player.player !== null) {
logger.debug('↗ playing sound');
fs.access(config.notifications.playSound, fs.constants.F_OK, (error) => {
if (error) {
logger.error(`✖ error opening sound file: ${error.message}`);
return;
}
player.play(config.notifications.playSound, (error: Error) => {
fs.access(
config.notifications.playSound,
fs.constants.F_OK,
(error) => {
if (error) {
logger.error("✖ couldn't play sound", error);
logger.error(
`✖ error opening sound file: ${error.message}`
);
return;
}
logger.info('✔ played sound');
});
});
player.play(config.notifications.playSound, (error: Error) => {
if (error) {
logger.error("✖ couldn't play sound", error);
}
logger.info('✔ played sound');
});
}
);
}
}
+6 -2
View File
@@ -39,7 +39,9 @@ const chatClient: ChatClient = new ChatClient(
{
accessToken,
expiryTimestamp:
expiryDate === null ? null : expiryDate.getTime(),
expiryDate === null
? null
: expiryDate.getTime(),
refreshToken
},
null,
@@ -90,7 +92,9 @@ export function sendTwitchMessage(link: Link, store: Store) {
logger.debug('↗ sending twitch message');
messages.push(
`${Print.inStock(link, store)}\n${link.cartUrl ? link.cartUrl : link.url}`
`${Print.inStock(link, store)}\n${
link.cartUrl ? link.cartUrl : link.url
}`
);
if (!alreadySaying) {