-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…version-in-ui feat: show Fink version in Footer
- Loading branch information
Showing
5 changed files
with
82 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { execSync } from "node:child_process" | ||
import fs from "node:fs" | ||
|
||
// Function to execute shell commands | ||
function execCommand(command) { | ||
try { | ||
return execSync(command).toString() | ||
} catch (error) { | ||
console.error(`Error executing command: ${command}`, error) | ||
return undefined | ||
} | ||
} | ||
|
||
// Function to update the version.json file | ||
function updateVersionFile() { | ||
// Fetch package versions | ||
const pnpmOutput = execCommand("pnpm m ls --depth -1 --json") | ||
if (!pnpmOutput) return | ||
|
||
const packages = JSON.parse(pnpmOutput) | ||
const inlangVersion = packages.find((pkg) => pkg.name === "@inlang/sdk").version | ||
const lixVersion = packages.find((pkg) => pkg.name === "@lix-js/client").version | ||
// if working directory is not clean set commit hash to "dev" | ||
const gitStatus = execCommand("git status --porcelain") | ||
const commitHash = gitStatus ? "dev" : execCommand("git rev-parse HEAD").trim() | ||
|
||
// Read the current version.json | ||
const versionFilePath = "./version.json" | ||
// Create version.json if it does not exist | ||
if (!fs.existsSync(versionFilePath)) { | ||
fs.writeFileSync( | ||
versionFilePath, | ||
`{ | ||
"@inlang/sdk": "", | ||
"@lix-js/client": "", | ||
"commit-hash": "" | ||
} | ||
` | ||
) | ||
} | ||
const versionFile = JSON.parse(fs.readFileSync(versionFilePath)) | ||
|
||
// Update version.json file | ||
versionFile["@inlang/sdk"] = inlangVersion | ||
versionFile["@lix-js/client"] = lixVersion | ||
versionFile["commit-hash"] = commitHash | ||
|
||
// Write the updated version.json | ||
fs.writeFileSync(versionFilePath, JSON.stringify(versionFile, undefined, 2)) | ||
} | ||
|
||
// Execute the update | ||
updateVersionFile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters