Skip to content

Commit 6d3c3e7

Browse files
committed
fix: preserve config formatting in version bump
1 parent 2082f79 commit 6d3c3e7

3 files changed

Lines changed: 69 additions & 79 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"name": "tauri-app",
33
"private": true,
44
"version": "1.0.1",

scripts/bump-version.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@ if (-not (Test-Path -LiteralPath $packageJsonPath)) { throw "Missing file: $pack
1717
if (-not (Test-Path -LiteralPath $cargoTomlPath)) { throw "Missing file: $cargoTomlPath" }
1818
if (-not (Test-Path -LiteralPath $tauriConfPath)) { throw "Missing file: $tauriConfPath" }
1919

20-
$packageJson = Get-Content -LiteralPath $packageJsonPath -Raw | ConvertFrom-Json
21-
$packageJson.version = $Version
22-
$packageJsonJson = $packageJson | ConvertTo-Json -Depth 100
23-
[System.IO.File]::WriteAllText($packageJsonPath, $packageJsonJson, [System.Text.UTF8Encoding]::new($false))
20+
$packageJson = Get-Content -LiteralPath $packageJsonPath -Raw
21+
$packageJson = [regex]::Replace($packageJson, '(?m)^(\s*"version"\s*:\s*")[^"]+(")', "`$1$Version`$2", 1)
22+
[System.IO.File]::WriteAllText($packageJsonPath, $packageJson, [System.Text.UTF8Encoding]::new($false))
2423

2524
$cargoToml = Get-Content -LiteralPath $cargoTomlPath -Raw
2625
$cargoToml = [regex]::Replace($cargoToml, '(?m)^version\s*=\s*"[^"]+"$', "version = `"$Version`"", 1)
2726
[System.IO.File]::WriteAllText($cargoTomlPath, $cargoToml, [System.Text.UTF8Encoding]::new($false))
2827

29-
$tauriConf = Get-Content -LiteralPath $tauriConfPath -Raw | ConvertFrom-Json
30-
$tauriConf.version = $Version
31-
$tauriConfJson = $tauriConf | ConvertTo-Json -Depth 100
32-
[System.IO.File]::WriteAllText($tauriConfPath, $tauriConfJson, [System.Text.UTF8Encoding]::new($false))
28+
$tauriConf = Get-Content -LiteralPath $tauriConfPath -Raw
29+
$tauriConf = [regex]::Replace($tauriConf, '(?m)^(\s*"version"\s*:\s*")[^"]+(")', "`$1$Version`$2", 1)
30+
[System.IO.File]::WriteAllText($tauriConfPath, $tauriConf, [System.Text.UTF8Encoding]::new($false))
3331

3432
Write-Host "Updated version to $Version in:" -ForegroundColor Green
3533
Write-Host "- $packageJsonPath"

src-tauri/tauri.conf.json

Lines changed: 62 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,63 @@
1-
{
2-
"$schema": "https://schema.tauri.app/config/2",
3-
"productName": "DevStack",
4-
"version": "1.0.1",
5-
"identifier": "com.devstack.desktop",
6-
"build": {
7-
"beforeDevCommand": "npm run dev",
8-
"devUrl": "http://localhost:1420",
9-
"beforeBuildCommand": "npm run build",
10-
"frontendDist": "../dist"
11-
},
12-
"app": {
13-
"windows": [
14-
{
15-
"label": "main",
16-
"title": "DevStack",
17-
"width": 1024,
18-
"height": 720,
19-
"resizable": true,
20-
"fullscreen": false,
21-
"decorations": false,
22-
"zoomHotkeysEnabled": true
23-
}
24-
],
25-
"security": {
26-
"csp": null
27-
},
28-
"trayIcon": {
29-
"iconPath": "icons/icon.ico",
30-
"iconAsTemplate": false,
31-
"menuOnLeftClick": false
32-
}
33-
},
34-
"bundle": {
35-
"active": true,
36-
"createUpdaterArtifacts": true,
37-
"targets": "all",
38-
"icon": [
39-
"icons/32x32.png",
40-
"icons/128x128.png",
41-
"icons/128x128@2x.png",
42-
"icons/icon.icns",
43-
"icons/icon.ico"
44-
],
45-
"windows": {
46-
"nsis": {
47-
48-
},
49-
"wix": {
50-
51-
}
52-
}
53-
},
54-
"plugins": {
55-
"shell": {
56-
57-
},
58-
"fs": {
59-
60-
},
61-
"updater": {
62-
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwMEI4NDcyNzY2OTMwQ0MKUldUTU1HbDJjb1FMSUNpSmsrZzdGL3hjSDVpaGgwSTFWS3VnclB4ZGR5YTdrYW1CTElWekpPSzQK",
63-
"endpoints": [
64-
"https://github.com/holdon1996/dev-stack/releases/latest/download/latest.json"
65-
],
66-
"windows": {
67-
"installMode": "passive"
68-
}
69-
}
70-
}
1+
{
2+
"$schema": "https://schema.tauri.app/config/2",
3+
"productName": "DevStack",
4+
"version": "1.0.1",
5+
"identifier": "com.devstack.desktop",
6+
"build": {
7+
"beforeDevCommand": "npm run dev",
8+
"devUrl": "http://localhost:1420",
9+
"beforeBuildCommand": "npm run build",
10+
"frontendDist": "../dist"
11+
},
12+
"app": {
13+
"windows": [
14+
{
15+
"label": "main",
16+
"title": "DevStack",
17+
"width": 1024,
18+
"height": 720,
19+
"resizable": true,
20+
"fullscreen": false,
21+
"decorations": false,
22+
"zoomHotkeysEnabled": true
23+
}
24+
],
25+
"security": {
26+
"csp": null
27+
},
28+
"trayIcon": {
29+
"iconPath": "icons/icon.ico",
30+
"iconAsTemplate": false,
31+
"menuOnLeftClick": false
32+
}
33+
},
34+
"bundle": {
35+
"active": true,
36+
"createUpdaterArtifacts": true,
37+
"targets": "all",
38+
"icon": [
39+
"icons/32x32.png",
40+
"icons/128x128.png",
41+
"icons/128x128@2x.png",
42+
"icons/icon.icns",
43+
"icons/icon.ico"
44+
],
45+
"windows": {
46+
"nsis": {},
47+
"wix": {}
48+
}
49+
},
50+
"plugins": {
51+
"shell": {},
52+
"fs": {},
53+
"updater": {
54+
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwMEI4NDcyNzY2OTMwQ0MKUldUTU1HbDJjb1FMSUNpSmsrZzdGL3hjSDVpaGgwSTFWS3VnclB4ZGR5YTdrYW1CTElWekpPSzQK",
55+
"endpoints": [
56+
"https://github.com/holdon1996/dev-stack/releases/latest/download/latest.json"
57+
],
58+
"windows": {
59+
"installMode": "passive"
60+
}
61+
}
62+
}
7163
}

0 commit comments

Comments
 (0)