mod: fvmrc [skip ci]

This commit is contained in:
My-Responsitories
2026-01-10 20:20:45 +08:00
parent b435a312a6
commit 500fd7f454
3 changed files with 18 additions and 10 deletions

3
.fvmrc
View File

@@ -1,3 +0,0 @@
{
"flutter": "3.38.6"
}

4
.gitignore vendored
View File

@@ -146,4 +146,6 @@ pili_release.json
dist
test.dart
test.dart
.fvmrc

View File

@@ -5,27 +5,36 @@ param(
try {
$versionName = $null
$flutterVersion = $null
$versionCode = [int](git rev-list --count HEAD).Trim()
$commitHash = (git rev-parse HEAD).Trim()
$updatedContent = foreach ($line in (Get-Content -Path 'pubspec.yaml' -Encoding UTF8)) {
if ($line -match '^\s*version:\s*([\d\.]+)') {
$versionName = $matches[1]
if ($Arg -eq 'android') {
$versionName += '-' + $commitHash.Substring(0, 9)
if ($line -match '^\s*(version|flutter):\s*([\d\.]+)') {
if ('version' -eq $matches[1]) {
$versionName = $matches[2]
if ('android' -eq $Arg) {
$versionName += '-' + $commitHash.Substring(0, 9)
}
"version: $versionName+$versionCode"
} else {
$flutterVersion = $matches[2]
$line
}
"version: $versionName+$versionCode"
}
else {
$line
}
}
if ($null -eq $versionName) {
if ($null -eq $versionName -or $null -eq $flutterVersion) {
throw 'version not found'
}
Set-Content -Path '.fvmrc' -Value "{`"flutter`":`"$flutterVersion`"}"
$updatedContent | Set-Content -Path 'pubspec.yaml' -Encoding UTF8
$buildTime = [int]([DateTimeOffset]::Now.ToUnixTimeSeconds())