refactor: env, cartUrl optional, other consistencies

Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Jef LeCompte
2020-09-19 17:35:46 -04:00
parent 393d5f6898
commit 8c5d7d0c49
19 changed files with 80 additions and 83 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import {Logger} from '../logger';
import open from 'open';
import {Store} from './model';
import {sendNotification} from '../notification';
import {isOutOfStock as includesLabels} from './out-of-stock';
import {includesLabels} from './out-of-stock';
/**
* Returns true if the brand should be checked for stock
@@ -1,74 +1,84 @@
import {Store} from './store';
export const amazonca: Store = {
cartUrl: '',
export const AmazonCa: Store = {
links: [
{
brand: 'msi',
model: 'gaming trio',
url: 'https://www.amazon.ca/MSI-GeForce-RTX-3080-10G/dp/B08HR7SV3M?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'evga',
model: 'ftw3gaming',
url: 'https://www.amazon.ca/EVGA-GeForce-Technology-Backplate-10G-P5-3895-KR/dp/B08HR3DPGW?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'evga',
model: 'ftw3ultra',
url: 'https://www.amazon.ca/EVGA-GeForce-Technology-Backplate-10G-P5-3897-KR/dp/B08HR3Y5GQ?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'evga',
model: 'xc3ultra',
url: 'https://www.amazon.ca/EVGA-GeForce-Cooling-Backplate-10G-P5-3885-KR/dp/B08HR55YB5?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'evga',
model: 'xc3gaming',
url: 'https://www.amazon.ca/EVGA-GeForce-Cooling-Backplate-10G-P5-3883-KR/dp/B08HR4RJ3Q?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'evga',
model: 'xc3black',
url: 'https://www.amazon.ca/EVGA-GeForce-Gaming-Cooling-10G-P5-3881-KR/dp/B08HR6FMF3?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'gigabyte',
model: 'windforce',
url: 'https://www.amazon.ca/GIGABYTE-GeForce-Graphics-WINDFORCE-GV-N3080GAMING/dp/B08HJTH61J?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'gigabyte',
model: 'windforce eagle',
url: 'https://www.amazon.ca/GIGABYTE-GeForce-Graphics-WINDFORCE-GV-N3080EAGLE/dp/B08HJS2JLJ?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'asus',
model: 'tuf',
url: 'https://www.amazon.ca/Asus-90YV0FB0-M0AM00-TUF-RTX3080-10G-GAMING/dp/B08HHDP9DW?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'asus',
model: 'tufoc',
url: 'https://www.amazon.ca/Asus-90YV0FB1-M0AM00-TUF-RTX3080-O10G-GAMING/dp/B08HH5WF97?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
},
{
brand: 'msi',
model: 'ventus',
url: 'https://www.amazon.ca/MSI-GeForce-RTX-3080-10G/dp/B08HR5SXPS?ref_=ast_sto_dp',
oosLabels: ['currently unavailable', 'enter the characters you see below']
oosLabels: ['currently unavailable'],
captchaLabels: ['enter the characters you see below']
}
],
name: 'amazonca'
name: 'amazonCa'
};
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const Amazon: Store = {
cartUrl: '',
links: [
{
brand: 'pny',
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const BAndH: Store = {
cartUrl: '',
links: [
{
brand: 'gigabyte',
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const BestBuy: Store = {
cartUrl: '',
links: [
{
brand: 'asus',
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const Evga: Store = {
cartUrl: '',
links: [
{
brand: 'evga',
+3 -5
View File
@@ -6,11 +6,11 @@ import {Amazon} from './amazon';
import {MicroCenter} from './microcenter';
import {Config} from '../../config';
import {Nvidia} from './nvidia';
import {amazonca} from './amazonca';
import {AmazonCa} from './amazon-ca';
const masterList = new Map([
['amazon', Amazon],
['amazonca', amazonca],
['amazonca', AmazonCa],
['bestbuy', BestBuy],
['bandh', BAndH],
['evga', Evga],
@@ -21,9 +21,7 @@ const masterList = new Map([
const list = new Map();
const storeArray = Config.stores.split(',');
for (const name of storeArray) {
for (const name of Config.stores) {
list.set(name, masterList.get(name));
}
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const MicroCenter: Store = {
cartUrl: '',
links: [
{
brand: 'evga',
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const NewEgg: Store = {
cartUrl: '',
links: [
{
brand: 'asus',
-1
View File
@@ -1,7 +1,6 @@
import {Store} from './store';
export const Nvidia: Store = {
cartUrl: '',
links: [
{
brand: 'nvidia',
+1 -1
View File
@@ -7,7 +7,7 @@ interface Link {
}
export interface Store {
cartUrl: string;
cartUrl?: string;
links: Link[];
name: string;
}
+1 -1
View File
@@ -4,7 +4,7 @@
* @param domText Complete DOM of website.
* @param oosLabels Out-of-stock labels.
*/
export function isOutOfStock(domText: string, oosLabels: string[]) {
export function includesLabels(domText: string, oosLabels: string[]): boolean {
const domTextLowerCase = domText.toLowerCase();
return oosLabels.some(label => domTextLowerCase.includes(label));
}