@@ -54,8 +54,12 @@ const exec = (command, arguments_, options) => {
5454@param {import('./cli-implementation.js').Options } options
5555@param {{package_: import('read-pkg').NormalizedPackageJson; projectDirectory?: string; rootDirectory: string} } context
5656*/
57- const np = async ( input = 'patch' , { packageManager, ...options } , { package_, projectDirectory, rootDirectory} ) => {
57+ const np = async ( input = 'patch' , { packageManager, ...rawOptions } , { package_, projectDirectory, rootDirectory} ) => {
5858 projectDirectory ??= rootDirectory ;
59+
60+ const { preview, ...options } = rawOptions ;
61+ options . dryRun ??= preview ;
62+
5963 // TODO: Remove sometime far in the future
6064 if ( options . skipCleanup ) {
6165 options . cleanup = false ;
@@ -103,7 +107,7 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
103107 } ) ;
104108
105109 asyncExitHook ( async ( ) => {
106- if ( options . preview || publishStatus === 'SUCCESS' ) {
110+ if ( options . dryRun || publishStatus === 'SUCCESS' ) {
107111 return ;
108112 }
109113
@@ -152,8 +156,8 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
152156 title : 'Cleanup' ,
153157 enabled : ( ) => runCleanup && ! lockfile ,
154158 skip ( ) {
155- if ( options . preview ) {
156- return '[Preview ] Command not executed: delete node_modules.' ;
159+ if ( options . dryRun ) {
160+ return '[Dry run ] Command not executed: delete node_modules.' ;
157161 }
158162 } ,
159163 task : ( ) => deleteAsync ( path . join ( projectDirectory , 'node_modules' ) ) ,
@@ -162,8 +166,8 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
162166 title : `Installing dependencies using ${ packageManager . id } ` ,
163167 enabled : ( ) => runInstall ,
164168 skip ( ) {
165- if ( options . preview ) {
166- return `[Preview ] Command not executed: ${ printCommand ( getInstallCommand ( ) ) } .` ;
169+ if ( options . dryRun ) {
170+ return `[Dry run ] Command not executed: ${ printCommand ( getInstallCommand ( ) ) } .` ;
167171 }
168172 } ,
169173 task : ( ) => new Listr ( [
@@ -183,23 +187,23 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
183187 title : 'Running tests' ,
184188 enabled : ( ) => runTests ,
185189 skip ( ) {
186- if ( options . preview ) {
187- return `[Preview ] Command not executed: ${ packageManager . cli } run ${ testScript } .` ;
190+ if ( options . dryRun ) {
191+ return `[Dry run ] Command not executed: ${ packageManager . cli } run ${ testScript } .` ;
188192 }
189193 } ,
190194 task : ( ) => exec ( packageManager . cli , [ 'run' , testScript ] , { ...ciEnvOptions , cwd : projectDirectory } ) ,
191195 } ,
192196 {
193197 title : 'Bumping version' ,
194198 skip ( ) {
195- if ( options . preview ) {
199+ if ( options . dryRun ) {
196200 const [ cli , arguments_ ] = packageManager . versionCommand ( input ) ;
197201
198202 if ( options . message ) {
199203 arguments_ . push ( '--message' , options . message . replaceAll ( '%s' , input ) ) ;
200204 }
201205
202- return `[Preview ] Command not executed: ${ printCommand ( [ cli , arguments_ ] ) } ` ;
206+ return `[Dry run ] Command not executed: ${ printCommand ( [ cli , arguments_ ] ) } ` ;
203207 }
204208 } ,
205209 task ( ) {
@@ -218,9 +222,9 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
218222 {
219223 title : 'Publishing package' ,
220224 skip ( ) {
221- if ( options . preview ) {
225+ if ( options . dryRun ) {
222226 const command = getPublishCommand ( options ) ;
223- return `[Preview ] Command not executed: ${ printCommand ( command ) } .` ;
227+ return `[Dry run ] Command not executed: ${ printCommand ( command ) } .` ;
224228 }
225229 } ,
226230 /** @type {(context, task) => Listr.ListrTaskResult<any> } */
@@ -252,9 +256,9 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
252256 ? [ {
253257 title : 'Enabling two-factor authentication' ,
254258 async skip ( ) {
255- if ( options . preview ) {
259+ if ( options . dryRun ) {
256260 const arguments_ = await getEnable2faArguments ( package_ . name , options ) ;
257- return `[Preview ] Command not executed: npm ${ arguments_ . join ( ' ' ) } .` ;
261+ return `[Dry run ] Command not executed: npm ${ arguments_ . join ( ' ' ) } .` ;
258262 }
259263 } ,
260264 task : ( context , task ) => enable2fa ( task , package_ . name , { otp : context . otp } ) ,
@@ -269,9 +273,9 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
269273 return 'Upstream branch not found; not pushing.' ;
270274 }
271275
272- if ( options . preview ) {
276+ if ( options . dryRun ) {
273277 const remote = options . remote ? `${ options . remote } ` : '' ;
274- return `[Preview ] Command not executed: git push ${ remote } --follow-tags.` ;
278+ return `[Dry run ] Command not executed: git push ${ remote } --follow-tags.` ;
275279 }
276280
277281 if ( publishStatus === 'FAILED' && options . runPublish ) {
@@ -287,8 +291,8 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
287291 title : 'Creating release draft on GitHub' ,
288292 enabled : ( ) => isOnGitHub === true ,
289293 skip ( ) {
290- if ( options . preview ) {
291- return '[Preview ] GitHub Releases draft will not be opened in preview mode.' ;
294+ if ( options . dryRun ) {
295+ return '[Dry run ] GitHub Releases draft will not be opened in dry-run mode.' ;
292296 }
293297 } ,
294298 task : ( ) => releaseTaskHelper ( options , package_ , packageManager ) ,
@@ -297,7 +301,7 @@ const np = async (input = 'patch', {packageManager, ...options}, {package_, proj
297301 ] , {
298302 showSubtasks : false ,
299303 renderer : options . renderer ?? 'default' ,
300- clearOutput : ! options . preview && ! options . releaseDraftOnly ,
304+ clearOutput : ! options . dryRun && ! options . releaseDraftOnly ,
301305 } ) ;
302306
303307 if ( ! options . runPublish ) {
0 commit comments