-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
39 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 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,41 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { DIRNAME } from "./constants.js"; | ||
|
||
const filePath = path.resolve(DIRNAME, "../src-tauri/tauri.conf.json"); | ||
const newVersion = process.argv[2]; | ||
|
||
if (!newVersion) { | ||
console.error("Version argument is required"); | ||
process.exit(1); | ||
} | ||
|
||
// Lire le contenu du fichier tauri.conf.json | ||
const fileContent = fs.readFileSync(filePath, "utf8"); | ||
const config = JSON.parse(fileContent); | ||
const currentVersion = config.package.version; | ||
|
||
// Fonction pour comparer les versions | ||
function isVersionGreater(newVer, currentVer) { | ||
const newParts = newVer.split(".").map(Number); | ||
const currentParts = currentVer.split(".").map(Number); | ||
|
||
for (let i = 0; i < newParts.length; i++) { | ||
if (newParts[i] > currentParts[i]) return true; | ||
if (newParts[i] < currentParts[i]) return false; | ||
} | ||
return false; | ||
} | ||
|
||
if (!isVersionGreater(newVersion, currentVersion)) { | ||
console.error("New version must be greater than the current version"); | ||
process.exit(1); | ||
} | ||
|
||
const updatedContent = fileContent.replace( | ||
/"version": "\d+\.\d+\.\d+"/, | ||
`"version": "${newVersion}"` | ||
); | ||
|
||
fs.writeFileSync(filePath, updatedContent, "utf8"); | ||
console.log(`Version updated to ${newVersion}`); |
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,3 @@ | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
export const DIRNAME = path.dirname(fileURLToPath(import.meta.url)); |
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