@@ -8,6 +8,7 @@ import execute from "./execute.js"
88import { displayFactBox , FactBoxOptions } from "./facts.js"
99import logMessage from "./log-message.js"
1010import ProcessManager from "./process-manager.js"
11+ import { updatePackageVersion } from "./update-package-version.js"
1112
1213const NEXTJS_REPO = "https://github.com/medusajs/nextjs-starter-medusa"
1314const NEXTJS_BRANCH = "main"
@@ -75,24 +76,7 @@ export async function installNextjsStarter({
7576
7677 if ( version ) {
7778 const packageJsonPath = path . join ( nextjsDirectory , "package.json" )
78- const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , "utf-8" ) )
79-
80- if ( packageJson . dependencies ) {
81- for ( const dependency of Object . keys ( packageJson . dependencies ) ) {
82- if ( dependency . startsWith ( "@medusajs/" ) ) {
83- packageJson . dependencies [ dependency ] = version
84- }
85- }
86- }
87- if ( packageJson . devDependencies ) {
88- for ( const dependency of Object . keys ( packageJson . devDependencies ) ) {
89- if ( dependency . startsWith ( "@medusajs/" ) ) {
90- packageJson . devDependencies [ dependency ] = version
91- }
92- }
93- }
94-
95- fs . writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) )
79+ updatePackageVersion ( packageJsonPath , version , { applyChanges : true } )
9680 }
9781
9882 const execOptions = {
0 commit comments