From 03ed48fb70089963ded1cbfa2a51ec12469b8ee1 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 11:49:35 -0500 Subject: [PATCH 01/11] typo fix --- src/Client/index.ts | 85 +++++++++---------- ...liableLocation.ts => AvailableLocation.ts} | 6 +- ...tionDates.ts => AvailableLocationDates.ts} | 10 +-- 3 files changed, 49 insertions(+), 52 deletions(-) rename src/Interfaces/{AvaliableLocation.ts => AvailableLocation.ts} (62%) rename src/Interfaces/{AvaliableLocationDates.ts => AvailableLocationDates.ts} (62%) diff --git a/src/Client/index.ts b/src/Client/index.ts index 9117b1e..949433a 100644 --- a/src/Client/index.ts +++ b/src/Client/index.ts @@ -8,13 +8,12 @@ import isBetween from 'dayjs/plugin/isBetween'; dayjs.extend(isBetween); import prompts from 'prompts'; import type { EligibilityPayload } from '../Interfaces/Eligibility'; -import type { AvaliableLocationPayload, AvaliableLocationResponse } from '../Interfaces/AvaliableLocation'; -import type { AvaliableLocationDatesPayload, AvaliableLocationDatesResponse, AvaliableTimeSlots } from '../Interfaces/AvaliableLocationDates'; +import type { AvailableLocationPayload, AvailableLocationResponse } from '../Interfaces/AvailableLocation'; +import type { AvailableLocationDatesPayload, AvailableLocationDatesResponse, AvailableTimeSlots } from '../Interfaces/AvailableLocationDates'; import type { HoldSlotPayload, HoldSlotResponse } from '../Interfaces/HoldSlot'; import type { BookSlotPayload, BookSlotResponse } from '../Interfaces/BookSlot'; import type { ExistBookingPayload, ExistBookingResponse } from '../Interfaces/ExistBooking'; import type { CancelBookingPayload } from '../Interfaces/CancelBooking'; -import type { webhookPayload } from '../Interfaces/Webhook'; import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'; @@ -34,7 +33,7 @@ class TexasScheduler { public config = parseConfig(); public existBooking: { exist: boolean; response: ExistBookingResponse[] } | undefined; - private avaliableLocation: AvaliableLocationResponse[] | null = null; + private availableLocation: AvailableLocationResponse[] | null = null; private isBooked = false; private isHolded = false; private queue = new pQueue({ concurrency: 1 }); @@ -43,7 +42,7 @@ class TexasScheduler { // eslint-disable-next-line @typescript-eslint/no-var-requires, prettier/prettier if (this.config.appSettings.webserver) require('http').createServer((req: any, res: any) => res.end('Bot is alive!')).listen(process.env.PORT || 3000); log.info(`Texas Scheduler v${packagejson.version} is starting...`); - log.info('Requesting Avaliable Location....'); + log.info('Requesting Available Location....'); if (!existsSync('cache')) mkdirSync('cache'); this.run(); } @@ -55,7 +54,7 @@ class TexasScheduler { log.warn(`You have an existing booking at ${response[0].SiteName} ${dayjs(response[0].BookingDateTime).format('MM/DD/YYYY hh:mm A')}`); log.warn(`The bot will continue to run, but will cancel existing booking if it found a new one`); } - await this.requestAvaliableLocation(); + await this.requestAvailableLocation(); await this.getLocationDatesAll(); } @@ -101,19 +100,19 @@ class TexasScheduler { return response[0].ResponseId; } - public async getAllLocationFromZipCodes(): Promise { + public async getAllLocationFromZipCodes(): Promise { const zipcodeList = this.config.location.zipCode; - const finalArray: AvaliableLocationResponse[] = []; + const finalArray: AvailableLocationResponse[] = []; for (let i = 0; i < zipcodeList.length; i++) { - const requestBody: AvaliableLocationPayload = { + const requestBody: AvailableLocationPayload = { CityName: '', PreferredDay: 0, // 71 is new driver license TypeId: this.config.personalInfo.typeId || 71, ZipCode: zipcodeList[i], }; - const response: AvaliableLocationResponse[] = await this.requestApi('/api/AvailableLocation/', 'POST', requestBody).then( - res => res.body.json() as Promise, + const response: AvailableLocationResponse[] = await this.requestApi('/api/AvailableLocation/', 'POST', requestBody).then( + res => res.body.json() as Promise, ); response.forEach(el => (el.ZipCode = zipcodeList[i])); finalArray.push(...response); @@ -121,11 +120,11 @@ class TexasScheduler { return finalArray.sort((a, b) => a.Distance - b.Distance).filter((elem, index) => finalArray.findIndex(obj => obj.Id === elem.Id) === index); } - public async requestAvaliableLocation(): Promise { + public async requestAvailableLocation(): Promise { const response = await this.getAllLocationFromZipCodes(); if (this.config.location.pickDPSLocation) { if (existsSync('././cache/location.json')) { - this.avaliableLocation = JSON.parse(readFileSync('././cache/location.json', 'utf-8')); + this.availableLocation = JSON.parse(readFileSync('././cache/location.json', 'utf-8')); log.info('Found cached location selection, using cached location selection'); log.info('If you want to change location selection, please delete cache folder!'); return; @@ -140,25 +139,25 @@ class TexasScheduler { log.error('You must choose at least one location!'); process.exit(1); } - this.avaliableLocation = userResponse.location; + this.availableLocation = userResponse.location; writeFileSync('././cache/location.json', JSON.stringify(userResponse.location)); return; } - const filteredResponse = response.filter((location: AvaliableLocationResponse) => location.Distance < this.config.location.miles); + const filteredResponse = response.filter((location: AvailableLocationResponse) => location.Distance < this.config.location.miles); if (filteredResponse.length === 0) { - log.error(`No avaliable location found! Nearest location is ${response[0].Distance} miles away! Please change your config and try again!`); + log.error(`No Available location found! Nearest location is ${response[0].Distance} miles away! Please change your config and try again!`); process.exit(0); } - log.info(`Found ${filteredResponse.length} avaliable location that match your criteria`); + log.info(`Found ${filteredResponse.length} Available location that match your criteria`); log.info(`${filteredResponse.map(el => el.Name).join(', ')}`); - this.avaliableLocation = filteredResponse; + this.availableLocation = filteredResponse; return; } private async getLocationDatesAll() { - log.info('Checking Avaliable Location Dates....'); - if (!this.avaliableLocation) return; - const getLocationFunctions = this.avaliableLocation.map(location => () => this.getLocationDates(location)); + log.info('Checking Available Location Dates....'); + if (!this.availableLocation) return; + const getLocationFunctions = this.availableLocation.map(location => () => this.getLocationDates(location)); for (;;) { console.log('--------------------------------------------------------------------------------'); await this.queue.addAll(getLocationFunctions).catch(() => null); @@ -166,20 +165,20 @@ class TexasScheduler { } } - private async getLocationDates(location: AvaliableLocationResponse) { + private async getLocationDates(location: AvailableLocationResponse) { const locationConfig = this.config.location; - const requestBody: AvaliableLocationDatesPayload = { + const requestBody: AvailableLocationDatesPayload = { LocationId: location.Id, PreferredDay: 0, SameDay: locationConfig.sameDay, StartDate: null, TypeId: this.config.personalInfo.typeId || 71, }; - const response = (await this.requestApi('/api/AvailableLocationDates', 'POST', requestBody).then(res => res.body.json())) as AvaliableLocationDatesResponse; - let avaliableDates = response.LocationAvailabilityDates; + const response = (await this.requestApi('/api/AvailableLocationDates', 'POST', requestBody).then(res => res.body.json())) as AvailableLocationDatesResponse; + let AvailableDates = response.LocationAvailabilityDates; if (!locationConfig.sameDay) { - avaliableDates = response.LocationAvailabilityDates.filter(date => { + AvailableDates = response.LocationAvailabilityDates.filter(date => { const AvailabilityDate = dayjs(date.AvailabilityDate); const today = dayjs(); let preferredDaysCondition = true; @@ -192,24 +191,22 @@ class TexasScheduler { }); } - if (avaliableDates.length !== 0) { - const filteredAvailabilityDates = avaliableDates - .map(date => { - const filteredTimeSlots = date.AvailableTimeSlots.filter(timeSlot => { - const startDateTime = dayjs(timeSlot.StartDateTime); - const startHour = startDateTime.hour(); - return startHour >= this.config.location.timesAround.start && startHour < this.config.location.timesAround.end; - }); - return { - ...date, - AvailableTimeSlots: filteredTimeSlots, - }; - }) - .filter(date => date.AvailableTimeSlots.length > 0); + if (AvailableDates.length !== 0) { + const filteredAvailabilityDates = AvailableDates.map(date => { + const filteredTimeSlots = date.AvailableTimeSlots.filter(timeSlot => { + const startDateTime = dayjs(timeSlot.StartDateTime); + const startHour = startDateTime.hour(); + return startHour >= this.config.location.timesAround.start && startHour < this.config.location.timesAround.end; + }); + return { + ...date, + AvailableTimeSlots: filteredTimeSlots, + }; + }).filter(date => date.AvailableTimeSlots.length > 0); const booking = filteredAvailabilityDates[0].AvailableTimeSlots[0]; - log.info(`${location.Name} is avaliable on ${booking.FormattedStartDateTime}`); + log.info(`${location.Name} is Available on ${booking.FormattedStartDateTime}`); if (!this.queue.isPaused) this.queue.pause(); if (!this.config.appSettings.cancelIfExist && this.existBooking?.exist) { log.warn('cancelIfExist is disabled! Please cancel existing appointment manually!'); @@ -219,7 +216,7 @@ class TexasScheduler { return Promise.resolve(true); } log.info( - `${location.Name} is not avaliable in ${ + `${location.Name} is not Available in ${ locationConfig.sameDay ? 'the same day' : `around ${locationConfig.daysAround.start}-${locationConfig.daysAround.end} days from today! ` } `, ); @@ -251,7 +248,7 @@ class TexasScheduler { return response; } - private async holdSlot(booking: AvaliableTimeSlots, location: AvaliableLocationResponse) { + private async holdSlot(booking: AvailableTimeSlots, location: AvailableLocationResponse) { if (this.isHolded) return; const requestBody: HoldSlotPayload = { DateOfBirth: this.config.personalInfo.dob, @@ -271,7 +268,7 @@ class TexasScheduler { await this.bookSlot(booking, location); } - private async bookSlot(booking: AvaliableTimeSlots, location: AvaliableLocationResponse) { + private async bookSlot(booking: AvailableTimeSlots, location: AvailableLocationResponse) { if (this.isBooked) return; log.info('Booking slot....'); if (this.existBooking?.exist) { diff --git a/src/Interfaces/AvaliableLocation.ts b/src/Interfaces/AvailableLocation.ts similarity index 62% rename from src/Interfaces/AvaliableLocation.ts rename to src/Interfaces/AvailableLocation.ts index af02617..4705e45 100644 --- a/src/Interfaces/AvaliableLocation.ts +++ b/src/Interfaces/AvailableLocation.ts @@ -1,5 +1,5 @@ -// This type request to AvaliableLocation endpoints and check avaliable locations -export interface AvaliableLocationPayload { +// This type request to AvailableLocation endpoints and check available locations +export interface AvailableLocationPayload { CityName: string; PreferredDay: number; TypeId: number; @@ -7,7 +7,7 @@ export interface AvaliableLocationPayload { } // The response is more than this but i only use stuff I needed -export interface AvaliableLocationResponse { +export interface AvailableLocationResponse { Id: number; Address: string; Distance: number; diff --git a/src/Interfaces/AvaliableLocationDates.ts b/src/Interfaces/AvailableLocationDates.ts similarity index 62% rename from src/Interfaces/AvaliableLocationDates.ts rename to src/Interfaces/AvailableLocationDates.ts index 6e1ef88..d0a8617 100644 --- a/src/Interfaces/AvaliableLocationDates.ts +++ b/src/Interfaces/AvailableLocationDates.ts @@ -1,6 +1,6 @@ -// This type request to AvaliableLocationDates endpoints and check avaliable dates on specific location +// This type request to AvailableLocationDates endpoints and check available dates on specific location -export interface AvaliableLocationDatesPayload { +export interface AvailableLocationDatesPayload { LocationId: number; PreferredDay: number; SameDay: boolean; @@ -8,7 +8,7 @@ export interface AvaliableLocationDatesPayload { TypeId: number; } -export interface AvaliableLocationDatesResponse { +export interface AvailableLocationDatesResponse { MoreDatesAvailable: boolean; FirstAvailableDate: Date; LocationAvailabilityDates: LocationAvailabilityDates[]; @@ -18,10 +18,10 @@ interface LocationAvailabilityDates { LocationId: number; ServiceTypeId: number; AvailabilityDate: string; - AvailableTimeSlots: AvaliableTimeSlots[]; + AvailableTimeSlots: AvailableTimeSlots[]; } -export interface AvaliableTimeSlots { +export interface AvailableTimeSlots { FormattedStartDateTime: string; SlotId: number; Duration: number; From e08460446ef5ed116aa8eae9e23162dd120f67e5 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 11:52:15 -0500 Subject: [PATCH 02/11] remove webhook --- example.config.yml | 15 +-------------- src/Client/index.ts | 33 --------------------------------- src/Interfaces/Config.ts | 8 -------- src/Interfaces/Webhook.ts | 9 --------- 4 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 src/Interfaces/Webhook.ts diff --git a/example.config.yml b/example.config.yml index f1606db..108a890 100644 --- a/example.config.yml +++ b/example.config.yml @@ -53,17 +53,4 @@ appSettings: # Set this to higher if you encounter Header Timeout error. This one is in miliseconds headersTimeout: 20000 # How many times to retry if the request to DPS server failled - maxRetry: 3 - -# If you dont know what to change here, dont change it :) -webhook: - # If your using Bluebubbles webhook/api put this to true otherwise, keep it false - enable: false - url: '' - password: '' - # phone number with country code (EX: +11111111111) - phoneNumber: '' - # private-api or apple-script - sendMethod: 'apple-script' - # iMessage or SMS - phoneNumberType: 'SMS' \ No newline at end of file + maxRetry: 3 \ No newline at end of file diff --git a/src/Client/index.ts b/src/Client/index.ts index 949433a..40719a7 100644 --- a/src/Client/index.ts +++ b/src/Client/index.ts @@ -309,17 +309,6 @@ class TexasScheduler { log.info(`Slot booked successfully. Confirmation Number: ${bookingInfo.Booking.ConfirmationNumber}`); log.info(`Visiting this link to print your booking:`); log.info(appointmentURL); - if (this.config.webhook.enable) - await this.sendWebhook( - // this string kinda long so i put it in a array and join it :) - [ - `Booking for ${this.config.personalInfo.firstName} ${this.config.personalInfo.lastName} has been booked.`, - `Confirmation Number: ${bookingInfo.Booking.ConfirmationNumber}`, - `Location: ${location.Name} DPS`, - `Time: ${booking.FormattedStartDateTime}`, - `Appointment URL: ${appointmentURL}`, - ].join('\n'), - ); process.exit(0); } else { if (this.queue.isPaused) this.queue.start(); @@ -327,28 +316,6 @@ class TexasScheduler { log.error(await response.body.text()); } } - - private async sendWebhook(message: string) { - const requestBody: webhookPayload = { - chatGuid: `${this.config.webhook.phoneNumberType};-;${this.config.webhook.phoneNumber}`, - tempGuild: '', - message, - method: this.config.webhook.sendMethod, - subject: '', - effectId: '', - selectedMessageGuild: '', - }; - const response = await undici.request(`${this.config.webhook.url}/api/v1/message/text?password=${this.config.webhook.password}`, { - method: 'POST', - body: JSON.stringify(requestBody), - headers: { 'Content-Type': 'application/json' }, - }); - if (response.statusCode === 200) log.info('[INFO] Webhook sent successfully'); - else { - log.error('Failed to send webhook'); - log.error(await response.body.text()); - } - } } export default TexasScheduler; diff --git a/src/Interfaces/Config.ts b/src/Interfaces/Config.ts index 99326ad..a818985 100644 --- a/src/Interfaces/Config.ts +++ b/src/Interfaces/Config.ts @@ -39,14 +39,6 @@ const configZod = z.object({ headersTimeout: z.number().default(20000), maxRetry: z.number().default(3), }), - webhook: z.object({ - enable: z.boolean().default(false), - url: z.string().nullable(), - password: z.string().nullable(), - phoneNumber: z.string().nullable(), - sendMethod: z.union([z.literal('private-api'), z.literal('apple-script')]).default('apple-script'), - phoneNumberType: z.union([z.literal('iMessage'), z.literal('SMS')]).nullable(), - }), }); type Config = z.infer; diff --git a/src/Interfaces/Webhook.ts b/src/Interfaces/Webhook.ts deleted file mode 100644 index 5d1cf64..0000000 --- a/src/Interfaces/Webhook.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface webhookPayload { - chatGuid: string; - tempGuild: string; - message: string; - method: 'private-api' | 'apple-script'; - subject: string; - effectId: string; - selectedMessageGuild: string; -} From 19b649a5446481f49c648182e4f632ad3a0c0d32 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 11:52:41 -0500 Subject: [PATCH 03/11] update deps --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 293a067..c7f10ee 100644 --- a/package.json +++ b/package.json @@ -20,30 +20,30 @@ }, "homepage": "https://github.com/phamleduy04/texas-dps-scheduler#readme", "devDependencies": { - "@eslint/create-config": "^0.4.6", + "@eslint/create-config": "^1.1.1", "@types/ms": "^0.7.34", - "@types/node": "^20.11.21", + "@types/node": "^20.12.12", "@types/prompts": "^2.4.9", - "@typescript-eslint/eslint-plugin": "^7.1.0", - "@typescript-eslint/parser": "^7.1.0", - "eslint": "^8.57.0", + "@typescript-eslint/eslint-plugin": "^7.10.0", + "@typescript-eslint/parser": "^7.10.0", + "eslint": "^9.3.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "typescript": "^5.4.5" }, "dependencies": { "colorette": "^2.0.20", - "dayjs": "^1.11.10", + "dayjs": "^1.11.11", "dotenv": "^16.4.5", "js-yaml": "^4.1.0", "p-queue": "6.6.2", "prompts": "^2.4.2", "tslib": "^2.6.2", - "undici": "^6.6.2", - "yaml": "^2.4.0", - "zod": "^3.22.4" + "undici": "^6.18.1", + "yaml": "^2.4.2", + "zod": "^3.23.8" }, "engines": { "node": ">=18.0" From 38e2d04c72a9d8f07b3609c31397359be8636b44 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 13:38:52 -0500 Subject: [PATCH 04/11] add startDate feature --- example.config.yml | 6 +++++- package.json | 2 +- src/Client/index.ts | 4 ++-- src/Config/index.ts | 7 +++++++ src/Interfaces/Config.ts | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/example.config.yml b/example.config.yml index 108a890..8d18f8f 100644 --- a/example.config.yml +++ b/example.config.yml @@ -22,7 +22,7 @@ personalInfo: typeId: 71 location: - # Zipcode of your location can add more by using ',' + # Zipcode of your location. Can add more DPS location by using ',' for multiple zipcode zipCode: ['75067', '75080'] # Choose your DPS location by yourself when running the application if set to true pickDPSLocation: false @@ -35,6 +35,10 @@ location: sameDay: false # Put how many day from today you want to book from start to end (7 is a good number) daysAround: + ## Start date: start and end will start counting from this date + # MM/DD/YYYY format, if blank will use current date + # If the date input is invalid or in the past, the app will automatically use the current date as start date + startDate: null start: 0 end: 7 # Put what time you want to book diff --git a/package.json b/package.json index 9f87b79..5a4b06b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "texas-dps-scheduler", - "version": "2.1.0", + "version": "2.2.0", "description": "Texas DPS Automatic Scheduler", "main": "dist/index.js", "scripts": { diff --git a/src/Client/index.ts b/src/Client/index.ts index 3cf2a48..801900f 100644 --- a/src/Client/index.ts +++ b/src/Client/index.ts @@ -178,11 +178,11 @@ class TexasScheduler { if (!locationConfig.sameDay) { AvailableDates = response.LocationAvailabilityDates.filter(date => { const AvailabilityDate = dayjs(date.AvailabilityDate); - const today = dayjs(); + const startDate = dayjs(this.config.location.daysAround.startDate); let preferredDaysCondition = true; if (locationConfig.preferredDays.length > 0) preferredDaysCondition = locationConfig.preferredDays.includes(AvailabilityDate.day()); return ( - AvailabilityDate.isBetween(today.add(locationConfig.daysAround.start, 'day'), today.add(locationConfig.daysAround.end, 'day'), 'day') && + AvailabilityDate.isBetween(startDate.add(locationConfig.daysAround.start, 'day'), startDate.add(locationConfig.daysAround.end, 'day'), 'day') && date.AvailableTimeSlots.length > 0 && preferredDaysCondition ); diff --git a/src/Config/index.ts b/src/Config/index.ts index 9ef173a..783b41d 100644 --- a/src/Config/index.ts +++ b/src/Config/index.ts @@ -4,6 +4,7 @@ import { configZod, Config } from '../Interfaces/Config'; import preferredDayList from '../Assets/preferredDay'; import * as log from '../Log'; import 'dotenv/config'; +import dayjs from 'dayjs'; const parseConfig = (): Config => { if (!existsSync('./config.yml')) { @@ -16,6 +17,12 @@ const parseConfig = (): Config => { configData = parsePersonalInfo(configData); configData.location.preferredDays = parsePreferredDays(configData.location.preferredDays); configData.personalInfo.phoneNumber = parsePhoneNumber(configData.personalInfo.phoneNumber); + let startDate = dayjs(configData.location.daysAround.startDate); + if (!startDate.isValid() || startDate.isBefore(dayjs())) { + log.warn('Invalid date in config.yml, using current date'); + startDate = dayjs(); + } + configData.location.daysAround.startDate = startDate.format('MM/DD/YYYY'); try { return configZod.parse(configData); diff --git a/src/Interfaces/Config.ts b/src/Interfaces/Config.ts index a818985..afe898b 100644 --- a/src/Interfaces/Config.ts +++ b/src/Interfaces/Config.ts @@ -21,6 +21,7 @@ const configZod = z.object({ sameDay: z.boolean(), daysAround: z .object({ + startDate: z.string(), start: z.number(), end: z.number(), }) From 2549bdcf781fc8999fa34170fca80228cbf94ef3 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 13:49:12 -0500 Subject: [PATCH 05/11] downgrade eslint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a4b06b..4df0167 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@types/prompts": "^2.4.9", "@typescript-eslint/eslint-plugin": "^7.10.0", "@typescript-eslint/parser": "^7.10.0", - "eslint": "^9.3.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", From 025363bf0f2bd53df7d27df099f816d6c3220101 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 13:49:23 -0500 Subject: [PATCH 06/11] show warning for old config file --- src/Config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/index.ts b/src/Config/index.ts index 783b41d..bade01c 100644 --- a/src/Config/index.ts +++ b/src/Config/index.ts @@ -18,7 +18,7 @@ const parseConfig = (): Config => { configData.location.preferredDays = parsePreferredDays(configData.location.preferredDays); configData.personalInfo.phoneNumber = parsePhoneNumber(configData.personalInfo.phoneNumber); let startDate = dayjs(configData.location.daysAround.startDate); - if (!startDate.isValid() || startDate.isBefore(dayjs())) { + if (!configData.location.daysAround.startDate || !startDate.isValid() || startDate.isBefore(dayjs())) { log.warn('Invalid date in config.yml, using current date'); startDate = dayjs(); } From a1f822a6df5011222790913bf54d7a2b9092ea26 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Thu, 23 May 2024 13:50:23 -0500 Subject: [PATCH 07/11] fix analysis workflow --- .github/workflows/analysis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 6dc463e..2c5970c 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -3,7 +3,10 @@ name: Code Analysis on: push: branches: - - main + - '*' + pull_request: + branches: + - '*' jobs: From ada58d077db0452f0e038c53453a77ae0938da6a Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Fri, 14 Jun 2024 00:40:29 -0500 Subject: [PATCH 08/11] update dependencies --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4df0167..b693813 100644 --- a/package.json +++ b/package.json @@ -20,16 +20,16 @@ }, "homepage": "https://github.com/phamleduy04/texas-dps-scheduler#readme", "devDependencies": { - "@eslint/create-config": "^1.1.1", + "@eslint/create-config": "^1.1.4", "@types/ms": "^0.7.34", - "@types/node": "^20.12.12", + "@types/node": "^20.14.2", "@types/prompts": "^2.4.9", - "@typescript-eslint/eslint-plugin": "^7.10.0", - "@typescript-eslint/parser": "^7.10.0", + "@typescript-eslint/eslint-plugin": "^7.13.0", + "@typescript-eslint/parser": "^7.13.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", - "prettier": "^3.2.5", + "prettier": "^3.3.2", "ts-node": "^10.9.2", "typescript": "^5.4.5" }, @@ -40,9 +40,9 @@ "js-yaml": "^4.1.0", "p-queue": "6.6.2", "prompts": "^2.4.2", - "tslib": "^2.6.2", - "undici": "^6.18.1", - "yaml": "^2.4.2", + "tslib": "^2.6.3", + "undici": "^6.18.2", + "yaml": "^2.4.5", "zod": "^3.23.8" }, "engines": { From 62666b26f895cae8f2ec0b259be2df4241570d4e Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Fri, 14 Jun 2024 00:40:50 -0500 Subject: [PATCH 09/11] fix #119 --- package.json | 2 +- src/Client/index.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b693813..f2fab0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "texas-dps-scheduler", - "version": "2.2.0", + "version": "2.2.1", "description": "Texas DPS Automatic Scheduler", "main": "dist/index.js", "scripts": { diff --git a/src/Client/index.ts b/src/Client/index.ts index 801900f..e6e063c 100644 --- a/src/Client/index.ts +++ b/src/Client/index.ts @@ -215,7 +215,9 @@ class TexasScheduler { } log.info( `${location.Name} is not Available in ${ - locationConfig.sameDay ? 'the same day' : `around ${locationConfig.daysAround.start}-${locationConfig.daysAround.end} days from today! ` + locationConfig.sameDay + ? 'the same day' + : `around ${locationConfig.daysAround.start}-${locationConfig.daysAround.end} days from ${this.config.location.daysAround.startDate}!` } `, ); From 9962317fe1eabcde9369b0f81daa1e3adc13bba2 Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Fri, 14 Jun 2024 00:45:25 -0500 Subject: [PATCH 10/11] Update sonar-project.properties --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index a1a2827..d5143b5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1 +1 @@ -sonar.projectKey=phamleduy04_texas-dps-scheduler_AYe8IhBbv36W27jo1CFw +sonar.projectKey=phamleduy04_texas-dps-scheduler_b3fbdf43-d41e-4b47-b2c2-5697eaa25892 From e49646b085776c1716d2d2fbc12e0f30098013eb Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Fri, 14 Jun 2024 00:48:43 -0500 Subject: [PATCH 11/11] Update analysis.yml --- .github/workflows/analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 2c5970c..da4fe33 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -3,7 +3,7 @@ name: Code Analysis on: push: branches: - - '*' + - 'main' pull_request: branches: - '*' @@ -14,7 +14,7 @@ jobs: name: scan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: sonarsource/sonarqube-scan-action@master