From a4c9b732f3fb1e259deb854a6f01e4c74b080ab8 Mon Sep 17 00:00:00 2001 From: Prasang Prajapati Date: Tue, 9 Sep 2025 17:55:11 -0400 Subject: [PATCH] add timestamp script to generate vsix with timestamp added --- package.json | 2 ++ scripts/update-version-timestamp.js | 40 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 scripts/update-version-timestamp.js diff --git a/package.json b/package.json index f7f351d3fc..94fc0df9f7 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,10 @@ "bundle:nightly": "turbo bundle:nightly --log-order grouped --output-logs new-only", "vsix": "turbo vsix --log-order grouped --output-logs new-only", "vsix:nightly": "turbo vsix:nightly --log-order grouped --output-logs new-only", + "vsix:timestamp": "node scripts/update-version-timestamp.js && turbo vsix --log-order grouped --output-logs new-only", "clean": "turbo clean --log-order grouped --output-logs new-only && rimraf dist out bin .vite-port .turbo", "install:vsix": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix && node scripts/install-vsix.js", + "install:vsix:timestamp": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix:timestamp && node scripts/install-vsix.js", "changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .", "knip": "knip --include files", "update-contributors": "node scripts/update-contributors.js", diff --git a/scripts/update-version-timestamp.js b/scripts/update-version-timestamp.js new file mode 100755 index 0000000000..d5ef9ee2f0 --- /dev/null +++ b/scripts/update-version-timestamp.js @@ -0,0 +1,40 @@ +#!/usr/bin/env node + +const fs = require("fs") +const path = require("path") + +/** + * Updates the version in package.json with a timestamp suffix + */ +function updateVersionWithTimestamp() { + const packageJsonPath = path.join(__dirname, "../src/package.json") + + try { + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")) + const currentVersion = packageJson.version + const versionMatch = currentVersion.match(/^(\d+\.\d+\.\d+)/) + const baseVersion = versionMatch ? versionMatch[1] : currentVersion + const now = new Date() + const month = String(now.getMonth() + 1).padStart(2, "0") + const day = String(now.getDate()).padStart(2, "0") + const year = now.getFullYear() + const hours = String(now.getHours()).padStart(2, "0") + const minutes = String(now.getMinutes()).padStart(2, "0") + const seconds = String(now.getSeconds()).padStart(2, "0") + const timestamp = `${month}${day}${year}-${hours}${minutes}${seconds}` + const newVersion = `${baseVersion}-${timestamp}` + packageJson.version = newVersion + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, "\t")) + console.log(`Version updated from ${currentVersion} to ${newVersion}`) + return newVersion + } catch (error) { + console.error("Error updating version with timestamp:", error) + process.exit(1) + } +} + +if (require.main === module) { + updateVersionWithTimestamp() +} + +module.exports = { updateVersionWithTimestamp }