From 4aa8314823ee37b0f01e81a3010a63b0dec91e74 Mon Sep 17 00:00:00 2001 From: Uday R <82779467+uday-rana@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:18:32 -0400 Subject: [PATCH 1/4] fix: add padding to version timestamp --- scripts/determine-version.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/determine-version.js b/scripts/determine-version.js index 5700c7ed381..63c9dfdf2f6 100755 --- a/scripts/determine-version.js +++ b/scripts/determine-version.js @@ -118,11 +118,21 @@ async function main() { } else { // Dev const timestamp = await getCommitTimestamp(); - const ts = `${timestamp.getUTCFullYear()}${ - timestamp.getUTCMonth() + 1 - }${timestamp.getUTCDate()}${timestamp.getUTCHours()}${ - timestamp.getUTCMinutes() + 0 - }${timestamp.getUTCSeconds()}`; + const ts = `${timestamp.getUTCFullYear()}${(timestamp.getUTCMonth() + 1) + .toString() + .padStart(2, "0")}${timestamp + .getUTCDate() + .toString() + .padStart(2, "0")}${timestamp + .getUTCHours() + .toString() + .padStart(2, "0")}${timestamp + .getUTCMinutes() + .toString() + .padStart(2, "0")}${timestamp + .getUTCSeconds() + .toString() + .padStart(2, "0")}`; versionSuffix = `dev.${ts}`; packageVersion = `${versionPrefix}-${versionSuffix}`; versionSuffix += `+${commitHash}`; From 42fb66e52a4f64d62e30e228d3efd3280a951acf Mon Sep 17 00:00:00 2001 From: Uday R <82779467+uday-rana@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:39:25 -0400 Subject: [PATCH 2/4] refactor: extract date formatting logic outside template literal for readability --- scripts/determine-version.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/determine-version.js b/scripts/determine-version.js index 63c9dfdf2f6..26bd5514099 100755 --- a/scripts/determine-version.js +++ b/scripts/determine-version.js @@ -118,21 +118,20 @@ async function main() { } else { // Dev const timestamp = await getCommitTimestamp(); - const ts = `${timestamp.getUTCFullYear()}${(timestamp.getUTCMonth() + 1) + const formattedMonth = (timestamp.getUTCMonth() + 1) .toString() - .padStart(2, "0")}${timestamp - .getUTCDate() - .toString() - .padStart(2, "0")}${timestamp - .getUTCHours() - .toString() - .padStart(2, "0")}${timestamp + .padStart(2, "0"); + const formattedDate = timestamp.getUTCDate().toString().padStart(2, "0"); + const formattedHours = timestamp.getUTCHours().toString().padStart(2, "0"); + const formattedMinutes = timestamp .getUTCMinutes() .toString() - .padStart(2, "0")}${timestamp + .padStart(2, "0"); + const formattedSeconds = timestamp .getUTCSeconds() .toString() - .padStart(2, "0")}`; + .padStart(2, "0"); + const ts = `${timestamp.getUTCFullYear()}${formattedMonth}${formattedDate}${formattedHours}${formattedMinutes}${formattedSeconds}`; versionSuffix = `dev.${ts}`; packageVersion = `${versionPrefix}-${versionSuffix}`; versionSuffix += `+${commitHash}`; From 501e6249f42d842a132897756d9fd2dd40b94858 Mon Sep 17 00:00:00 2001 From: Uday R <82779467+uday-rana@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:21:51 -0400 Subject: [PATCH 3/4] refactor: split template literal for readability --- scripts/determine-version.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/determine-version.js b/scripts/determine-version.js index 26bd5514099..ce77642c825 100755 --- a/scripts/determine-version.js +++ b/scripts/determine-version.js @@ -131,7 +131,12 @@ async function main() { .getUTCSeconds() .toString() .padStart(2, "0"); - const ts = `${timestamp.getUTCFullYear()}${formattedMonth}${formattedDate}${formattedHours}${formattedMinutes}${formattedSeconds}`; + const ts = `${timestamp.getUTCFullYear() + }${formattedMonth + }${formattedDate + }${formattedHours + }${formattedMinutes + }${formattedSeconds}`; versionSuffix = `dev.${ts}`; packageVersion = `${versionPrefix}-${versionSuffix}`; versionSuffix += `+${commitHash}`; From 3490b616f2f2c2f9b15ca9150b99a1ec6ce9880c Mon Sep 17 00:00:00 2001 From: Uday R <82779467+uday-rana@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:09:02 -0400 Subject: [PATCH 4/4] refactor: format timestamp in-line --- scripts/determine-version.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/scripts/determine-version.js b/scripts/determine-version.js index ce77642c825..5bd252ed05e 100755 --- a/scripts/determine-version.js +++ b/scripts/determine-version.js @@ -118,25 +118,13 @@ async function main() { } else { // Dev const timestamp = await getCommitTimestamp(); - const formattedMonth = (timestamp.getUTCMonth() + 1) - .toString() - .padStart(2, "0"); - const formattedDate = timestamp.getUTCDate().toString().padStart(2, "0"); - const formattedHours = timestamp.getUTCHours().toString().padStart(2, "0"); - const formattedMinutes = timestamp - .getUTCMinutes() - .toString() - .padStart(2, "0"); - const formattedSeconds = timestamp - .getUTCSeconds() - .toString() - .padStart(2, "0"); - const ts = `${timestamp.getUTCFullYear() - }${formattedMonth - }${formattedDate - }${formattedHours - }${formattedMinutes - }${formattedSeconds}`; + const ts = + timestamp.getUTCFullYear().toString() + + (timestamp.getUTCMonth() + 1).toString().padStart(2, "0") + + timestamp.getUTCDate().toString().padStart(2, "0") + + timestamp.getUTCHours().toString().padStart(2, "0") + + timestamp.getUTCMinutes().toString().padStart(2, "0") + + timestamp.getUTCSeconds().toString().padStart(2, "0"); versionSuffix = `dev.${ts}`; packageVersion = `${versionPrefix}-${versionSuffix}`; versionSuffix += `+${commitHash}`;