1
1
import path from 'path' ;
2
- import { LERNA_BIN , PROJECT_ROOT } from './constants' ;
2
+ import {
3
+ EXCLUDE_RELEASE_PACKAGES ,
4
+ LERNA_BIN ,
5
+ MONGOSH_RELEASE_PACKAGES ,
6
+ PROJECT_ROOT ,
7
+ } from './constants' ;
3
8
import type { LernaPackageDescription } from './list' ;
4
9
import { listNpmPackages as listNpmPackagesFn } from './list' ;
5
10
import { spawnSync } from '../helpers/spawn-sync' ;
11
+ import type { SpawnSyncOptionsWithStringEncoding } from 'child_process' ;
6
12
7
13
export function publishNpmPackages (
8
14
isDryRun : boolean ,
15
+ isAuxiliaryOnly = false ,
9
16
listNpmPackages : typeof listNpmPackagesFn = listNpmPackagesFn ,
10
17
markBumpedFilesAsAssumeUnchangedFn : typeof markBumpedFilesAsAssumeUnchanged = markBumpedFilesAsAssumeUnchanged ,
11
18
spawnSyncFn : typeof spawnSync = spawnSync
12
19
) : void {
13
- const packages = listNpmPackages ( ) ;
20
+ const commandOptions : SpawnSyncOptionsWithStringEncoding = {
21
+ stdio : 'inherit' ,
22
+ cwd : PROJECT_ROOT ,
23
+ encoding : 'utf8' ,
24
+ env : {
25
+ ...process . env ,
26
+ ...( isDryRun ? { npm_config_dry_run : 'true' } : { } ) ,
27
+ } ,
28
+ } ;
29
+ let packages = listNpmPackages ( ) . filter (
30
+ ( packageConfig ) => ! EXCLUDE_RELEASE_PACKAGES . includes ( packageConfig . name )
31
+ ) ;
14
32
33
+ if ( isAuxiliaryOnly ) {
34
+ packages = packages . filter (
35
+ ( packageConfig ) => ! MONGOSH_RELEASE_PACKAGES . includes ( packageConfig . name )
36
+ ) ;
37
+ }
15
38
// Lerna requires a clean repository for a publish from-package (--force-publish does not have any effect here)
16
39
// we use git update-index --assume-unchanged on files we know have been bumped
17
40
markBumpedFilesAsAssumeUnchangedFn ( packages , true ) ;
@@ -23,26 +46,36 @@ export function publishNpmPackages(
23
46
'from-package' ,
24
47
'--no-private' ,
25
48
'--no-changelog' ,
26
- '--no-push' ,
27
49
'--exact' ,
28
- '--no-git-tag-version' ,
50
+ // During mongosh releases we handle the tags manually
51
+ ...( ! isAuxiliaryOnly ? [ '--no-git-tag-version' , '--no-push' ] : [ ] ) ,
29
52
'--force-publish' ,
30
53
'--yes' ,
31
54
'--no-verify-access' ,
32
55
] ,
33
- {
34
- stdio : 'inherit' ,
35
- cwd : PROJECT_ROOT ,
36
- encoding : 'utf8' ,
37
- env : {
38
- ...process . env ,
39
- ...( isDryRun ? { npm_config_dry_run : 'true' } : { } ) ,
40
- } ,
41
- }
56
+ commandOptions
42
57
) ;
43
58
} finally {
44
59
markBumpedFilesAsAssumeUnchangedFn ( packages , false ) ;
45
60
}
61
+
62
+ if ( ! isAuxiliaryOnly ) {
63
+ const mongoshVersion = packages . find (
64
+ ( packageConfig ) => packageConfig . name === 'mongosh'
65
+ ) ?. version ;
66
+
67
+ if ( ! mongoshVersion ) {
68
+ throw new Error ( 'Mongosh package not found' ) ;
69
+ }
70
+
71
+ spawnSync (
72
+ 'git' ,
73
+ [ 'tag' , '-a' , mongoshVersion , '-m' , mongoshVersion ] ,
74
+ commandOptions
75
+ ) ;
76
+
77
+ spawnSync ( 'git' , [ 'push' , '--follow-tags' ] , commandOptions ) ;
78
+ }
46
79
}
47
80
48
81
export function markBumpedFilesAsAssumeUnchanged (
0 commit comments