mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
feat:热更新
This commit is contained in:
35
scripts/bump-version.js
Normal file
35
scripts/bump-version.js
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
// Read app.json
|
||||
const appJsonPath = path.join(root, 'app.json');
|
||||
const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'));
|
||||
const currentVersion = appJson.expo.version;
|
||||
|
||||
// Parse semver
|
||||
const parts = currentVersion.split('.').map(Number);
|
||||
parts[2] += 1;
|
||||
const newVersion = parts.join('.');
|
||||
const newVersionCode = parts[0] * 10000 + parts[1] * 100 + parts[2];
|
||||
|
||||
// Update app.json
|
||||
appJson.expo.version = newVersion;
|
||||
fs.writeFileSync(appJsonPath, JSON.stringify(appJson, null, 2) + '\n');
|
||||
|
||||
// Update package.json
|
||||
const pkgJsonPath = path.join(root, 'package.json');
|
||||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
||||
pkgJson.version = newVersion;
|
||||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
|
||||
|
||||
// Update android/app/build.gradle
|
||||
const gradlePath = path.join(root, 'android', 'app', 'build.gradle');
|
||||
let gradle = fs.readFileSync(gradlePath, 'utf8');
|
||||
gradle = gradle.replace(/versionCode\s+\d+/, `versionCode ${newVersionCode}`);
|
||||
gradle = gradle.replace(/versionName\s+"[^"]+"/, `versionName "${newVersion}"`);
|
||||
fs.writeFileSync(gradlePath, gradle);
|
||||
|
||||
console.log(newVersion);
|
||||
Reference in New Issue
Block a user