configorama 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "configorama",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Variable support for configuration files",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"packageManager": "pnpm@10.33.0",
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "05dde9eefc90001bcea7f7e40f173cb87d18b4b6"
|
|
115
115
|
}
|
|
@@ -78,15 +78,7 @@ function parseCronExpression(input) {
|
|
|
78
78
|
// Parse "at X:XX" patterns (e.g., "at 9:30", "at 14:00")
|
|
79
79
|
const atTimeMatch = normalizedInput.match(/^at (\d{1,2}):(\d{2})(\s*(am|pm))?$/i)
|
|
80
80
|
if (atTimeMatch) {
|
|
81
|
-
|
|
82
|
-
const minute = parseInt(atTimeMatch[2])
|
|
83
|
-
const amPm = atTimeMatch[4]
|
|
84
|
-
|
|
85
|
-
if (amPm && amPm.toLowerCase() === 'pm' && hour !== 12) {
|
|
86
|
-
hour += 12
|
|
87
|
-
} else if (amPm && amPm.toLowerCase() === 'am' && hour === 12) {
|
|
88
|
-
hour = 0
|
|
89
|
-
}
|
|
81
|
+
const { minute, hour } = parseTimeMatch(atTimeMatch, 1, 2, 4)
|
|
90
82
|
|
|
91
83
|
return `${minute} ${hour} * * *`
|
|
92
84
|
}
|
|
@@ -118,15 +110,7 @@ function parseCronExpression(input) {
|
|
|
118
110
|
const ordinalDateMatch = normalizedInput.match(/^on (\d+)(?:st|nd|rd|th) of month at (\d{1,2}):(\d{2})(\s*(am|pm))?$/i)
|
|
119
111
|
if (ordinalDateMatch) {
|
|
120
112
|
const dayOfMonth = parseInt(ordinalDateMatch[1])
|
|
121
|
-
|
|
122
|
-
const minute = parseInt(ordinalDateMatch[3])
|
|
123
|
-
const amPm = ordinalDateMatch[5]
|
|
124
|
-
|
|
125
|
-
if (amPm && amPm.toLowerCase() === 'pm' && hour !== 12) {
|
|
126
|
-
hour += 12
|
|
127
|
-
} else if (amPm && amPm.toLowerCase() === 'am' && hour === 12) {
|
|
128
|
-
hour = 0
|
|
129
|
-
}
|
|
113
|
+
const { minute, hour } = parseTimeMatch(ordinalDateMatch, 2, 3, 5)
|
|
130
114
|
|
|
131
115
|
return `${minute} ${hour} ${dayOfMonth} * *`
|
|
132
116
|
}
|
|
@@ -143,15 +127,7 @@ function parseCronExpression(input) {
|
|
|
143
127
|
const days = weekdayTimeMatch[1].split(',').map(day => day.trim())
|
|
144
128
|
const dayOfWeek = days.map(day => dayMap[day.toLowerCase()]).join(',')
|
|
145
129
|
|
|
146
|
-
|
|
147
|
-
const minute = parseInt(weekdayTimeMatch[3])
|
|
148
|
-
const amPm = weekdayTimeMatch[5]
|
|
149
|
-
|
|
150
|
-
if (amPm && amPm.toLowerCase() === 'pm' && hour !== 12) {
|
|
151
|
-
hour += 12
|
|
152
|
-
} else if (amPm && amPm.toLowerCase() === 'am' && hour === 12) {
|
|
153
|
-
hour = 0
|
|
154
|
-
}
|
|
130
|
+
const { minute, hour } = parseTimeMatch(weekdayTimeMatch, 2, 3, 5)
|
|
155
131
|
|
|
156
132
|
return `${minute} ${hour} * * ${dayOfWeek}`
|
|
157
133
|
}
|
|
@@ -160,15 +136,7 @@ function parseCronExpression(input) {
|
|
|
160
136
|
const weekdaysTimeMatch = normalizedInput.match(/^on (weekdays|weekends) at (\d{1,2}):(\d{2})(\s*(am|pm))?$/i)
|
|
161
137
|
if (weekdaysTimeMatch) {
|
|
162
138
|
const dayRange = weekdaysTimeMatch[1].toLowerCase() === 'weekdays' ? '1-5' : '0,6'
|
|
163
|
-
|
|
164
|
-
const minute = parseInt(weekdaysTimeMatch[3])
|
|
165
|
-
const amPm = weekdaysTimeMatch[5]
|
|
166
|
-
|
|
167
|
-
if (amPm && amPm.toLowerCase() === 'pm' && hour !== 12) {
|
|
168
|
-
hour += 12
|
|
169
|
-
} else if (amPm && amPm.toLowerCase() === 'am' && hour === 12) {
|
|
170
|
-
hour = 0
|
|
171
|
-
}
|
|
139
|
+
const { minute, hour } = parseTimeMatch(weekdaysTimeMatch, 2, 3, 5)
|
|
172
140
|
|
|
173
141
|
return `${minute} ${hour} * * ${dayRange}`
|
|
174
142
|
}
|
|
@@ -187,6 +155,20 @@ function parseCronExpression(input) {
|
|
|
187
155
|
throw new Error(`Unrecognized cron pattern: "${input}". Supported patterns include: ${suggestions}`)
|
|
188
156
|
}
|
|
189
157
|
|
|
158
|
+
function parseTimeMatch(match, hourIndex, minuteIndex, amPmIndex) {
|
|
159
|
+
let hour = parseInt(match[hourIndex])
|
|
160
|
+
const minute = parseInt(match[minuteIndex])
|
|
161
|
+
const amPm = match[amPmIndex]
|
|
162
|
+
|
|
163
|
+
if (amPm && amPm.toLowerCase() === 'pm' && hour !== 12) {
|
|
164
|
+
hour += 12
|
|
165
|
+
} else if (amPm && amPm.toLowerCase() === 'am' && hour === 12) {
|
|
166
|
+
hour = 0
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return { minute, hour }
|
|
170
|
+
}
|
|
171
|
+
|
|
190
172
|
function getValueFromCron(variableString) {
|
|
191
173
|
// Get value from cron(expression)
|
|
192
174
|
const cronExpression = variableString.match(/cron\((.*)\)/)[1]
|
|
@@ -232,4 +214,4 @@ module.exports = {
|
|
|
232
214
|
resolver: getValueFromCron,
|
|
233
215
|
// Export the parser for testing
|
|
234
216
|
_parseCronExpression: parseCronExpression
|
|
235
|
-
}
|
|
217
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFromCron.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromCron.js"],"names":[],"mappings":"AACA,oCAAkF;
|
|
1
|
+
{"version":3,"file":"valueFromCron.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromCron.js"],"names":[],"mappings":"AACA,oCAAkF;AA0KlF,8EAiCC;AAzMD;;;GAGG;AACH,sDAoJC"}
|