pgflow 0.2.3 → 0.2.5
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.
|
@@ -53,17 +53,17 @@ function getTimestampFromFilename(filename) {
|
|
|
53
53
|
}
|
|
54
54
|
return '';
|
|
55
55
|
}
|
|
56
|
-
// Helper function to format a Date object into a migration timestamp string (YYYYMMDDhhmmss)
|
|
56
|
+
// Helper function to format a Date object into a migration timestamp string (YYYYMMDDhhmmss) using UTC
|
|
57
57
|
function formatDateToTimestamp(date) {
|
|
58
|
-
const year = date.
|
|
59
|
-
const month = String(date.
|
|
60
|
-
const day = String(date.
|
|
61
|
-
const hours = String(date.
|
|
62
|
-
const minutes = String(date.
|
|
63
|
-
const seconds = String(date.
|
|
58
|
+
const year = date.getUTCFullYear();
|
|
59
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
60
|
+
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
61
|
+
const hours = String(date.getUTCHours()).padStart(2, '0');
|
|
62
|
+
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
|
63
|
+
const seconds = String(date.getUTCSeconds()).padStart(2, '0');
|
|
64
64
|
return `${year}${month}${day}${hours}${minutes}${seconds}`;
|
|
65
65
|
}
|
|
66
|
-
// Helper function to parse a timestamp string into a Date object
|
|
66
|
+
// Helper function to parse a timestamp string into a Date object (interpreted as UTC)
|
|
67
67
|
function parseTimestampToDate(timestamp) {
|
|
68
68
|
// Validate format: YYYYMMDDhhmmss
|
|
69
69
|
if (!timestamp || timestamp.length !== 14 || !/^\d{14}$/.test(timestamp)) {
|
|
@@ -75,31 +75,31 @@ function parseTimestampToDate(timestamp) {
|
|
|
75
75
|
const hours = parseInt(timestamp.substring(8, 10), 10);
|
|
76
76
|
const minutes = parseInt(timestamp.substring(10, 12), 10);
|
|
77
77
|
const seconds = parseInt(timestamp.substring(12, 14), 10);
|
|
78
|
-
// Create date and validate (invalid dates like Feb 31 will be auto-corrected by JS Date)
|
|
79
|
-
const date = new Date(year, month, day, hours, minutes, seconds);
|
|
78
|
+
// Create date in UTC and validate (invalid dates like Feb 31 will be auto-corrected by JS Date)
|
|
79
|
+
const date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
|
|
80
80
|
// Additional validation to ensure the parsed date matches the input
|
|
81
81
|
// This catches edge cases like month=13 that JS Date would autocorrect
|
|
82
|
-
if (date.
|
|
83
|
-
date.
|
|
84
|
-
date.
|
|
85
|
-
date.
|
|
86
|
-
date.
|
|
87
|
-
date.
|
|
82
|
+
if (date.getUTCFullYear() !== year ||
|
|
83
|
+
date.getUTCMonth() !== month ||
|
|
84
|
+
date.getUTCDate() !== day ||
|
|
85
|
+
date.getUTCHours() !== hours ||
|
|
86
|
+
date.getUTCMinutes() !== minutes ||
|
|
87
|
+
date.getUTCSeconds() !== seconds) {
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
return date;
|
|
91
91
|
}
|
|
92
|
-
// Helper function to generate a new timestamp that's higher than the reference timestamp
|
|
92
|
+
// Helper function to generate a new timestamp that's higher than the reference timestamp (using UTC)
|
|
93
93
|
function generateNewTimestamp(referenceTimestamp, increment = 1) {
|
|
94
94
|
// First try to parse the reference timestamp to a Date
|
|
95
95
|
const parsedDate = parseTimestampToDate(referenceTimestamp);
|
|
96
|
-
// If we couldn't parse it, use current time
|
|
96
|
+
// If we couldn't parse it, use current UTC time
|
|
97
97
|
if (!parsedDate) {
|
|
98
98
|
return formatDateToTimestamp(new Date());
|
|
99
99
|
}
|
|
100
100
|
// Add the specified number of seconds (default: 1)
|
|
101
|
-
parsedDate.
|
|
102
|
-
// Get current time for comparison
|
|
101
|
+
parsedDate.setUTCSeconds(parsedDate.getUTCSeconds() + increment);
|
|
102
|
+
// Get current UTC time for comparison
|
|
103
103
|
const now = new Date();
|
|
104
104
|
// Return either the incremented timestamp or current time, whichever is later
|
|
105
105
|
// This ensures we never go backwards in time
|
|
@@ -108,7 +108,7 @@ function generateNewTimestamp(referenceTimestamp, increment = 1) {
|
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
110
|
// If we're already at or past current time, add increment to now
|
|
111
|
-
now.
|
|
111
|
+
now.setUTCSeconds(now.getUTCSeconds() + increment);
|
|
112
112
|
return formatDateToTimestamp(now);
|
|
113
113
|
}
|
|
114
114
|
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"chalk": "^5.4.1",
|
|
25
25
|
"commander": "^13.1.0",
|
|
26
26
|
"toml-patch": "^0.2.3",
|
|
27
|
-
"@pgflow/core": "0.2.
|
|
27
|
+
"@pgflow/core": "0.2.5"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|