mirror of
				https://github.com/ionic-team/ionic-framework.git
				synced 2025-11-04 13:17:56 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const fs = require('fs');
 | 
						|
const path = require('path');
 | 
						|
const semver = require('semver')
 | 
						|
 | 
						|
const pkgJsonPath = path.join(__dirname, '../package.json');
 | 
						|
const pkgLockPath = path.join(__dirname, '../package-lock.json');
 | 
						|
const readmePath = path.join(__dirname, '../README.md');
 | 
						|
 | 
						|
// get the version number from the last arg
 | 
						|
const newVersion = process.argv[2];
 | 
						|
semver.valid(newVersion);
 | 
						|
if (!newVersion) {
 | 
						|
  throw new Error('invalid version number: ' + newVersion);
 | 
						|
}
 | 
						|
 | 
						|
// update the package.json
 | 
						|
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
 | 
						|
pkgJson.version = newVersion;
 | 
						|
 | 
						|
// update the package-lock.json
 | 
						|
const pkgLock = JSON.parse(fs.readFileSync(pkgLockPath, 'utf-8'));
 | 
						|
pkgLock.version = pkgJson.version;
 | 
						|
 | 
						|
// update the readme script tag
 | 
						|
let readme = fs.readFileSync(readmePath, 'utf-8');
 | 
						|
const cdnUrl = 'https://unpkg.com/' + pkgJson.name + '@' + pkgJson.version + '/dist/ionic.js'
 | 
						|
readme = readme.replace(/https:\/\/unpkg.com(.*)ionic.js/, cdnUrl);
 | 
						|
 | 
						|
// save our changes
 | 
						|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
 | 
						|
fs.writeFileSync(pkgLockPath, JSON.stringify(pkgLock, null, 2) + '\n');
 | 
						|
fs.writeFileSync(readmePath, readme);
 |