@@ -24,9 +24,6 @@ let newVersion = mainPackageJson.version;
2424
2525// Async function to publish a package
2626async function publishPackage ( dir ) {
27- if ( dryRun ) {
28- return ;
29- }
3027
3128 const packageJsonPath = join ( dir , 'package.json' ) ;
3229 if ( ! existsSync ( packageJsonPath ) ) {
@@ -41,8 +38,12 @@ async function publishPackage(dir) {
4138
4239 try {
4340 console . log ( `Publishing package: ${ packageJson . name } from ${ dir } ...` ) ;
44- // await execAsync('npm publish', { cwd: dir }); // COMMENTED OUT FOR TESTING
45- console . log ( `[DRY RUN] Would publish: ${ packageJson . name } ` ) ;
41+ if ( dryRun ) {
42+ console . log ( `[DRY RUN] Would publish: ${ packageJson . name } ` ) ;
43+ } else {
44+ await execAsync ( 'npm publish' , { cwd : dir } ) ;
45+ console . log ( `Successfully published: ${ packageJson . name } ` ) ;
46+ }
4647 }
4748 catch ( error ) {
4849 console . error ( `Failed to publish ${ packageJson . name } : ${ error . message } ` ) ;
@@ -67,15 +68,19 @@ const workspaceGlobs = mainPackageJson.workspaces;
6768 console . log ( 'All packages have been processed.' ) ;
6869
6970 console . log ( `Updated versions of all packages to ${ newVersion } ` ) ;
70- // Update the root package-lock.json to reflect updated sub-package versions.
71- if ( ! dryRun ) {
72- console . log ( 'Updating root package-lock.json...' ) ;
73- await execAsync ( 'npm install' , { cwd : process . cwd ( ) } ) ;
71+
72+ if ( dryRun ) {
73+ console . log ( '[DRY RUN] Would update package-lock.json, commit changes, and create tag' ) ;
74+ console . log ( '[DRY RUN] No git operations performed' ) ;
75+ return ;
7476 }
77+
78+ // Update the root package-lock.json to reflect updated sub-package versions.
79+ console . log ( 'Updating root package-lock.json...' ) ;
80+ await execAsync ( 'npm install' , { cwd : process . cwd ( ) } ) ;
7581
7682 // committing package-lock changes and tagging
77- if ( ! dryRun ) {
78- try {
83+ try {
7984 // Stage changes
8085 console . log ( 'Staging changes...' ) ;
8186 await execAsync ( 'git add ./' ) ;
@@ -105,6 +110,5 @@ const workspaceGlobs = mainPackageJson.workspaces;
105110 catch ( error ) {
106111 console . error ( `Failed to commit and push changes: ${ error . message } ` ) ;
107112 }
108- }
109113
110114} ) ( ) ;
0 commit comments