@@ -29,6 +29,8 @@ const writeFile = promisify(_writeFile);
29
29
const chalk = require ( 'chalk' ) ;
30
30
const Listr = require ( 'listr' ) ;
31
31
32
+ const FIREBASE_UMBRELLA_PACKAGE_NAME = 'firebase-exp' ;
33
+
32
34
async function publishExpPackages ( ) {
33
35
try {
34
36
/**
@@ -54,7 +56,7 @@ async function publishExpPackages() {
54
56
/**
55
57
* It does 2 things:
56
58
*
57
- * 1. Bumps the patch version of exp packages regardless if there is any update
59
+ * 1. Bumps the patch version of firebase- exp package regardless if there is any update
58
60
* since the last release. This simplifies the script and works fine for exp packages.
59
61
*
60
62
* 2. Removes -exp in package names because we will publish them using
@@ -69,9 +71,17 @@ async function publishExpPackages() {
69
71
70
72
/**
71
73
* reset the working tree to recover package names with -exp in the package.json files,
72
- * then bump patch version of all exp packages
74
+ * then bump patch version of firebase- exp (the umbrella package) only
73
75
*/
74
- await resetWorkingTreeAndBumpVersions ( packagePaths , versions ) ;
76
+ const firebaseExpVersion = new Map ( ) ;
77
+ firebaseExpVersion . set (
78
+ FIREBASE_UMBRELLA_PACKAGE_NAME ,
79
+ versions . get ( FIREBASE_UMBRELLA_PACKAGE_NAME )
80
+ ) ;
81
+ const firebaseExpPath = packagePaths . filter ( p =>
82
+ p . includes ( FIREBASE_UMBRELLA_PACKAGE_NAME )
83
+ ) ;
84
+ await resetWorkingTreeAndBumpVersions ( firebaseExpPath , firebaseExpVersion ) ;
75
85
76
86
/**
77
87
* push to github
@@ -112,9 +122,18 @@ async function updatePackageNamesAndVersions(packagePaths) {
112
122
const versions = new Map ( ) ;
113
123
for ( const path of packagePaths ) {
114
124
const { version, name } = await readPackageJson ( path ) ;
115
- // increase the patch version of all exp packages
116
- const nextVersion = inc ( version , 'patch' ) ;
117
- versions . set ( name , nextVersion ) ;
125
+
126
+ // increment firebase-exp's patch version
127
+ if ( name === FIREBASE_UMBRELLA_PACKAGE_NAME ) {
128
+ const nextVersion = inc ( version , 'patch' ) ;
129
+ versions . set ( name , nextVersion ) ;
130
+ } else {
131
+ // create individual packages version
132
+ // we can't use minor version for them because most of them
133
+ // are still in the pre-major version officially.
134
+ const nextVersion = `${ version } -exp.${ await getCurrentSha ( ) } ` ;
135
+ versions . set ( name , nextVersion ) ;
136
+ }
118
137
}
119
138
120
139
await updatePackageJsons ( packagePaths , versions , {
@@ -221,7 +240,7 @@ async function updatePackageJsons(
221
240
async function commitAndPush ( versions ) {
222
241
await exec ( 'git add */package.json yarn.lock' ) ;
223
242
224
- const firebaseExpVersion = versions . get ( 'firebase-exp' ) ;
243
+ const firebaseExpVersion = versions . get ( FIREBASE_UMBRELLA_PACKAGE_NAME ) ;
225
244
await exec (
226
245
`git commit -m "Publish firebase@exp ${ firebaseExpVersion || '' } "`
227
246
) ;
@@ -237,7 +256,7 @@ async function commitAndPush(versions) {
237
256
}
238
257
239
258
function removeExpInPackageName ( name ) {
240
- const regex = / ^ ( @ f i r e b a s e .* ) - e x p ( .* ) $ / g;
259
+ const regex = / ^ ( . * f i r e b a s e .* ) - e x p ( .* ) $ / g;
241
260
242
261
const captures = regex . exec ( name ) ;
243
262
if ( ! captures ) {
@@ -255,4 +274,8 @@ async function readPackageJson(packagePath) {
255
274
return JSON . parse ( await readFile ( `${ packagePath } /package.json` , 'utf8' ) ) ;
256
275
}
257
276
277
+ async function getCurrentSha ( ) {
278
+ return ( await git . revparse ( [ '--short' , 'HEAD' ] ) ) . trim ( ) ;
279
+ }
280
+
258
281
publishExpPackages ( ) ;
0 commit comments