11/* eslint-disable no-console */
2- import { readFile , writeFile } from 'fs/promises' ;
2+ import { readFile } from 'fs/promises' ;
33import { join } from 'path' ;
44import { bump } from './bump.mjs' ;
55import { spawn } from './spawn.mjs' ;
@@ -21,34 +21,6 @@ const readJsonFile = async (filePath) => {
2121 }
2222} ;
2323
24- /**
25- * Write a JSON object to a file
26- * @param {string } filePath - Path to write the file
27- * @param {Object } data - Data to write
28- */
29- const writeJsonFile = async ( filePath , data ) => {
30- try {
31- const content = `${ JSON . stringify ( data , null , 2 ) } \n` ;
32-
33- await writeFile ( filePath , content , 'utf8' ) ;
34- } catch ( error ) {
35- throw new Error ( `Failed to write JSON file ${ filePath } : ${ error . message } ` ) ;
36- }
37- } ;
38-
39- /**
40- * Update package.json version
41- * @param {string } packagePath - Path to package.json
42- * @param {string } newVersion - New version to set
43- */
44- const updatePackageVersion = async ( packagePath , newVersion ) => {
45- const packageJson = await readJsonFile ( packagePath ) ;
46-
47- packageJson . version = newVersion ;
48- await writeJsonFile ( packagePath , packageJson ) ;
49- console . log ( `Updated ${ packagePath } to version ${ newVersion } ` ) ;
50- } ;
51-
5224/**
5325 * Bump the version of the package and update all relevant package.json files
5426 * @returns {Promise<string> } The next version
@@ -70,17 +42,8 @@ const version = async () => {
7042 // Update root package.json using npm version command
7143 console . log ( 'Updating root package.json...' ) ;
7244 await spawn ( 'npm' , [ 'version' , nextVersion ] ) ;
73-
74- // Update assetpack package.json
75- const assetpackPackagePath = join ( rootDir , 'packages' , 'assetpack' , 'package.json' ) ;
76-
77- console . log ( 'Updating assetpack package.json...' ) ;
78- await updatePackageVersion ( assetpackPackagePath , nextVersion ) ;
79- await spawn ( 'git' , [ 'add' , assetpackPackagePath ] ) ;
80- await spawn ( 'git' , [ 'commit' , '-m' , `chore: bump version to ${ nextVersion } ` ] ) ;
81- // push changes to git
82- await spawn ( 'git' , [ 'push' ] ) ;
83- await spawn ( 'git' , [ 'push' , '--tags' ] ) ;
45+ // push commit and its tag
46+ await spawn ( 'git' , [ 'push' , '--follow-tags' ] ) ;
8447
8548 console . log ( `✅ Version bump completed: ${ currentVersion } → ${ nextVersion } ` ) ;
8649 } catch ( error ) {
0 commit comments