Skip to content

Commit 5ea7515

Browse files
authored
chore(deps): upgrade cronstrue to 3.38.0 (#9891)
Use cronstrue's trimHoursLeadingZero option instead of a regex over its output, and update the schedule description tests to the new English wording.
1 parent be29ea1 commit 5ea7515

4 files changed

Lines changed: 19 additions & 27 deletions

File tree

‎apps/sim/lib/workflows/schedules/utils.test.ts‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -421,27 +421,20 @@ describe('Schedule Utilities', () => {
421421
})
422422

423423
describe('parseCronToHumanReadable', () => {
424-
it.concurrent('should parse common cron patterns using cronstrue', () => {
425-
// cronstrue produces "Every minute" for '* * * * *'
424+
it.concurrent('should describe the schedules the builder generates', () => {
426425
expect(parseCronToHumanReadable('* * * * *')).toBe('Every minute')
427-
428-
// cronstrue produces "Every 15 minutes" for '*/15 * * * *'
429426
expect(parseCronToHumanReadable('*/15 * * * *')).toBe('Every 15 minutes')
427+
expect(parseCronToHumanReadable('1 * * * *')).toBe('At 1 minute past the hour')
428+
expect(parseCronToHumanReadable('30 * * * *')).toBe('At 30 minutes past the hour')
429+
expect(parseCronToHumanReadable('0 9 * * *')).toBe('At 9:00 AM')
430+
expect(parseCronToHumanReadable('30 14 * * *')).toBe('At 2:30 PM')
431+
expect(parseCronToHumanReadable('0 9 * * 1')).toBe('At 9:00 AM, only on Monday')
432+
expect(parseCronToHumanReadable('30 14 15 * *')).toBe('At 2:30 PM, on day 15 of the month')
433+
})
430434

431-
// cronstrue produces "At 30 minutes past the hour" for '30 * * * *'
432-
expect(parseCronToHumanReadable('30 * * * *')).toContain('30 minutes past the hour')
433-
434-
// cronstrue produces "At 9:00 AM" for '0 9 * * *' (no leading zero on hour)
435-
expect(parseCronToHumanReadable('0 9 * * *')).toContain('9:00 AM')
436-
437-
// cronstrue produces "At 2:30 PM" for '30 14 * * *' (no leading zero on hour)
438-
expect(parseCronToHumanReadable('30 14 * * *')).toContain('2:30 PM')
439-
440-
// cronstrue produces "At 09:00 AM, only on Monday" for '0 9 * * 1'
441-
expect(parseCronToHumanReadable('0 9 * * 1')).toContain('Monday')
442-
443-
// cronstrue produces "At 02:30 PM, on day 15 of the month" for '30 14 15 * *'
444-
expect(parseCronToHumanReadable('30 14 15 * *')).toContain('15')
435+
it.concurrent('should describe step schedules in custom cron expressions', () => {
436+
expect(parseCronToHumanReadable('0 */2 * * *')).toBe('On the hour, every 2 hours')
437+
expect(parseCronToHumanReadable('0 0 */2 * *')).toBe('At 12:00 AM, every 2 days in a month')
445438
})
446439

447440
it.concurrent('should describe the nth weekday of the month', () => {

‎apps/sim/lib/workflows/schedules/utils.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,11 @@ export function calculateNextRunTime(
450450
export const parseCronToHumanReadable = (cronExpression: string, timezone?: string): string => {
451451
try {
452452
const forDisplay = cronExpression.replace(/([0-7])#L\b/g, '$1L')
453-
const baseDescription = cronstrue
454-
.toString(forDisplay, {
455-
use24HourTimeFormat: false,
456-
verbose: false,
457-
})
458-
.replace(/\b0(\d:\d{2})/g, '$1')
453+
const baseDescription = cronstrue.toString(forDisplay, {
454+
use24HourTimeFormat: false,
455+
trimHoursLeadingZero: true,
456+
verbose: false,
457+
})
459458

460459
if (timezone && timezone !== 'UTC') {
461460
const tzAbbr = getTimezoneAbbreviation(timezone)

‎apps/sim/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"class-variance-authority": "^0.7.1",
207207
"cmdk": "^1.0.0",
208208
"croner": "^9.0.0",
209-
"cronstrue": "3.3.0",
209+
"cronstrue": "3.38.0",
210210
"csv-parse": "7.0.3",
211211
"date-fns": "4.4.0",
212212
"decimal.js": "10.6.0",

‎bun.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)