@@ -49,6 +49,21 @@ Flags:
49
49
const EXPECTED_BRANCH = 'v2'
50
50
// this package will use tags like v1.0.0 while the rest will use the full package name like @pinia/[email protected]
51
51
const MAIN_PKG_NAME = 'pinia'
52
+ // whether the main package is at the root of the mono repo or this is not a mono repo
53
+ const IS_MAIN_PKG_ROOT = false
54
+ // array of folders of packages to release
55
+ const PKG_FOLDERS = [
56
+ // comment for multiline format
57
+ join ( __dirname , '../packages/pinia' ) ,
58
+ join ( __dirname , '../packages/testing' ) ,
59
+ join ( __dirname , '../packages/nuxt' ) ,
60
+ ]
61
+ // files to add and commit after building a new version
62
+ const FILES_TO_COMMIT = [
63
+ // comment for multiline format
64
+ 'packages/*/package.json' ,
65
+ 'packages/*/CHANGELOG.md' ,
66
+ ]
52
67
53
68
/**
54
69
* @type {typeof execa }
@@ -60,7 +75,7 @@ const run = (bin, args, opts = {}) =>
60
75
* @param args {string[]}
61
76
* @param opts {import('execa').Options}
62
77
*/
63
- const dryRun = ( bin , args , opts = { } ) =>
78
+ const dryRun = async ( bin , args , opts = { } ) =>
64
79
console . log ( chalk . blue ( `[dry-run] ${ bin } ${ args . join ( ' ' ) } ` ) , opts )
65
80
const runIfNotDry = isDryRun ? dryRun : run
66
81
@@ -112,13 +127,7 @@ async function main() {
112
127
}
113
128
}
114
129
115
- const packagesFolders = [
116
- join ( __dirname , '../packages/pinia' ) ,
117
- join ( __dirname , '../packages/testing' ) ,
118
- join ( __dirname , '../packages/nuxt' ) ,
119
- ]
120
-
121
- const changedPackages = await getChangedPackages ( ...packagesFolders )
130
+ const changedPackages = await getChangedPackages ( ...PKG_FOLDERS )
122
131
123
132
if ( ! changedPackages . length ) {
124
133
console . log ( chalk . red ( `No packages have changed since last release` ) )
@@ -129,24 +138,29 @@ async function main() {
129
138
console . log ( `\n${ chalk . bold . blue ( 'This is a dry run' ) } \n` )
130
139
}
131
140
132
- // allow to select which packages
133
- const { pickedPackages } = await prompts ( {
134
- type : 'multiselect' ,
135
- name : 'pickedPackages' ,
136
- message : 'What packages do you want to release?' ,
137
- instructions : false ,
138
- min : 1 ,
139
- choices : changedPackages . map ( ( pkg ) => ( {
140
- title : pkg . name ,
141
- value : pkg . name ,
142
- selected : true ,
143
- } ) ) ,
144
- } )
141
+ let packagesToRelease = changedPackages
142
+
143
+ // if there are more than one package, ask which ones to release
144
+ if ( packagesToRelease . length > 1 ) {
145
+ // allow to select which packages
146
+ const { pickedPackages } = await prompts ( {
147
+ type : 'multiselect' ,
148
+ name : 'pickedPackages' ,
149
+ message : 'What packages do you want to release?' ,
150
+ instructions : false ,
151
+ min : 1 ,
152
+ choices : changedPackages . map ( ( pkg ) => ( {
153
+ title : pkg . name ,
154
+ value : pkg . name ,
155
+ selected : true ,
156
+ } ) ) ,
157
+ } )
145
158
146
- // const packagesToRelease = changedPackages
147
- const packagesToRelease = changedPackages . filter ( ( pkg ) =>
148
- pickedPackages . includes ( pkg . name )
149
- )
159
+ // const packagesToRelease = changedPackages
160
+ packagesToRelease = changedPackages . filter ( ( pkg ) =>
161
+ pickedPackages . includes ( pkg . name )
162
+ )
163
+ }
150
164
151
165
step (
152
166
`Ready to release ${ packagesToRelease . map ( ( { name } ) => chalk . bold . white ( name ) ) . join ( ', ' ) } `
@@ -271,8 +285,9 @@ async function main() {
271
285
changelogExists ? '1' : '0' ,
272
286
'--commit-path' ,
273
287
'.' ,
274
- '--lerna-package' ,
275
- pkg . name ,
288
+ ...( pkg . name === MAIN_PKG_NAME && IS_MAIN_PKG_ROOT
289
+ ? [ ]
290
+ : [ '--lerna-package' , pkg . name ] ) ,
276
291
...( pkg . name === MAIN_PKG_NAME
277
292
? [ ]
278
293
: [ '--tag-prefix' , `${ pkg . name } @` ] ) ,
@@ -312,11 +327,7 @@ async function main() {
312
327
const { stdout } = await run ( 'git' , [ 'diff' ] , { stdio : 'pipe' } )
313
328
if ( stdout ) {
314
329
step ( '\nCommitting changes...' )
315
- await runIfNotDry ( 'git' , [
316
- 'add' ,
317
- 'packages/*/CHANGELOG.md' ,
318
- 'packages/*/package.json' ,
319
- ] )
330
+ await runIfNotDry ( 'git' , [ 'add' , ...FILES_TO_COMMIT ] )
320
331
await runIfNotDry ( 'git' , [
321
332
'commit' ,
322
333
'-m' ,
0 commit comments