mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
20260711存档01
This commit is contained in:
+10
-7
@@ -1,4 +1,4 @@
|
||||
const { cpSync, existsSync } = require('fs');
|
||||
const { cpSync, existsSync, mkdirSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const mode = process.argv[2];
|
||||
@@ -10,10 +10,11 @@ if (!mode || !validModes.includes(mode)) {
|
||||
}
|
||||
|
||||
const root = join(__dirname, '..');
|
||||
const publicDir = join(root, 'public');
|
||||
const srcDir = join(root, 'public', 'icons', mode);
|
||||
const buildDir = join(root, 'build');
|
||||
|
||||
const png = join(publicDir, `${mode}.png`);
|
||||
const ico = join(publicDir, `${mode}.ico`);
|
||||
const png = join(srcDir, 'icon.png');
|
||||
const ico = join(srcDir, 'icon.ico');
|
||||
|
||||
if (!existsSync(png)) {
|
||||
console.error(`Icon not found: ${png}`);
|
||||
@@ -24,7 +25,9 @@ if (!existsSync(ico)) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
cpSync(png, join(publicDir, 'icon.png'), { overwrite: true });
|
||||
cpSync(ico, join(publicDir, 'icon.ico'), { overwrite: true });
|
||||
mkdirSync(buildDir, { recursive: true });
|
||||
|
||||
console.log(`[switch-icon] Mode: ${mode} → icon.png + icon.ico updated`);
|
||||
cpSync(png, join(buildDir, 'icon.png'), { overwrite: true });
|
||||
cpSync(ico, join(buildDir, 'icon.ico'), { overwrite: true });
|
||||
|
||||
console.log(`[switch-icon] Mode: ${mode} → build/icon.png + build/icon.ico updated`);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const { readFileSync, writeFileSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const root = join(__dirname, '..');
|
||||
const pkgPath = join(root, 'package.json');
|
||||
|
||||
function getCurrentVersion() {
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
function setVersion(version) {
|
||||
// Update package.json
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
||||
pkg.version = version;
|
||||
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
||||
|
||||
console.log(`Version updated to ${version}`);
|
||||
console.log(` - package.json`);
|
||||
}
|
||||
|
||||
// Parse args
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0) {
|
||||
console.log(`Current version: ${getCurrentVersion()}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args[0] === '--help' || args[0] === '-h') {
|
||||
console.log('Usage:');
|
||||
console.log(' node scripts/version.js <version> Set version');
|
||||
console.log(' node scripts/version.js Show current version');
|
||||
console.log('');
|
||||
console.log('Examples:');
|
||||
console.log(' node scripts/version.js 1.0.0');
|
||||
console.log(' node scripts/version.js 1.1.0-beta.1');
|
||||
console.log(' node scripts/version.js 2.0.0-rc.1');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const newVersion = args[0];
|
||||
|
||||
// Validate semver-ish format
|
||||
if (!/^\d+\.\d+\.\d+/.test(newVersion)) {
|
||||
console.error(`Invalid version: ${newVersion}`);
|
||||
console.error('Expected format: x.y.z or x.y.z-tag');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const current = getCurrentVersion();
|
||||
console.log(`Current version: ${current}`);
|
||||
setVersion(newVersion);
|
||||
Reference in New Issue
Block a user