@@ -72,9 +72,10 @@ const getPublishes = async ({ force }) => {
72
72
}
73
73
74
74
const main = async ( opts ) => {
75
- const { isLocal, smokePublish, packDestination } = opts
76
- const isPack = ! ! packDestination
77
- const publishes = await getPublishes ( { force : isPack } )
75
+ const { test, otp, dryRun, smokePublish, packDestination } = opts
76
+
77
+ const hasPackDest = ! ! packDestination
78
+ const publishes = await getPublishes ( { force : smokePublish } )
78
79
79
80
if ( ! publishes . length ) {
80
81
throw new Error (
@@ -88,13 +89,15 @@ const main = async (opts) => {
88
89
table . push ( [ publish . name , publish . version , publish . tag ] )
89
90
}
90
91
92
+ const preformOperations = hasPackDest ? [ 'publish' , 'pack' ] : [ 'publish' ]
93
+
91
94
const confirmMessage = [
92
- `Ready to ${ isPack ? 'pack' : 'publish' } the following packages:` ,
95
+ `Ready to ${ preformOperations . join ( ',' ) } the following packages:` ,
93
96
table . toString ( ) ,
94
- isPack ? null : 'Ok to proceed? ' ,
97
+ smokePublish ? null : 'Ok to proceed? ' ,
95
98
] . filter ( Boolean ) . join ( '\n' )
96
99
97
- if ( isPack ) {
100
+ if ( smokePublish ) {
98
101
log . info ( confirmMessage )
99
102
} else {
100
103
const confirm = await read ( { prompt : confirmMessage , default : 'y' } )
@@ -109,38 +112,43 @@ const main = async (opts) => {
109
112
await npm ( 'rm' , '--global' , '--force' , 'npm' )
110
113
await npm ( 'link' , '--force' , '--ignore-scripts' )
111
114
112
- if ( opts . test ) {
115
+ if ( test ) {
113
116
await npm ( 'run' , 'lint-all' , '--ignore-scripts' )
114
117
await npm ( 'run' , 'postlint' , '--ignore-scripts' )
115
118
await npm ( 'run' , 'test-all' , '--ignore-scripts' )
116
119
}
117
120
118
121
await npm ( 'prune' , '--omit=dev' , '--no-save' , '--no-audit' , '--no-fund' )
119
122
await npm ( 'install' , '-w' , 'docs' , '--ignore-scripts' , '--no-audit' , '--no-fund' )
120
- if ( isLocal && smokePublish ) {
123
+
124
+ if ( smokePublish ) {
121
125
log . info ( `Skipping git dirty check due to local smoke publish test being run` )
122
126
} else {
123
127
await git . dirty ( )
124
128
}
125
129
130
+ let count = - 1
126
131
for ( const publish of publishes ) {
132
+ log . info ( `Publishing ${ publish . name } @${ publish . version } to ${ publish . tag } ${ count ++ } /${ publishes . length } ` )
127
133
const workspace = publish . workspace && `--workspace=${ publish . name } `
128
134
const publishPkg = ( ...args ) => npm ( 'publish' , workspace , `--tag=${ publish . tag } ` , ...args )
129
135
130
- await npm ( 'version' , 'prerelease' , workspace , '--preid=smoke' )
131
- if ( isPack ) {
136
+ if ( hasPackDest ) {
132
137
await npm (
133
138
'pack' ,
134
139
workspace ,
135
- opts . packDestination && `--pack-destination=${ opts . packDestination } `
140
+ packDestination && `--pack-destination=${ packDestination } `
136
141
)
137
- if ( smokePublish ) {
138
- await publishPkg ( '--dry-run' )
139
- }
142
+ }
143
+
144
+ if ( smokePublish ) {
145
+ // when we have a smoke test run we'd want to bump the version or else npm will throw an error even with dry-run
146
+ await npm ( 'version' , 'prerelease' , workspace , '--preid=smoke' , '--ignore-scripts' , '--no-git-tag-version' )
147
+ await publishPkg ( '--dry-run' , '--ignore-scripts' )
140
148
} else {
141
149
await publishPkg (
142
- opts . dryRun && '--dry-run' ,
143
- opts . otp && `--otp=${ opts . otp === 'op' ? await op ( ) : opts . otp } `
150
+ dryRun && '--dry-run' ,
151
+ otp && `--otp=${ otp === 'op' ? await op ( ) : otp } `
144
152
)
145
153
}
146
154
}
0 commit comments