15
15
* limitations under the License.
16
16
*/
17
17
18
- const { spawn, exec } = require ( 'child-process-promise' ) ;
19
- const ora = require ( 'ora' ) ;
20
- const { projectRoot } = require ( '../utils' ) ;
21
- const simpleGit = require ( 'simple-git/promise' ) ;
22
- const git = simpleGit ( projectRoot ) ;
23
- const { mapWorkspaceToPackages } = require ( '../release/utils/workspace' ) ;
24
- const { inc } = require ( 'semver' ) ;
25
- const { readFile : _readFile , writeFile : _writeFile } = require ( 'fs' ) ;
26
- const { promisify } = require ( 'util' ) ;
18
+ import { spawn , exec } from 'child-process-promise' ;
19
+ import ora from 'ora' ;
20
+ import { projectRoot } from '../utils' ;
21
+ import simpleGit from 'simple-git/promise' ;
22
+
23
+ import { mapWorkspaceToPackages } from '../release/utils/workspace' ;
24
+ import { inc } from 'semver' ;
25
+ import { readFile as _readFile , writeFile as _writeFile } from 'fs' ;
26
+ import { promisify } from 'util' ;
27
+ import chalk from 'chalk' ;
28
+ import Listr from 'listr' ;
29
+
27
30
const readFile = promisify ( _readFile ) ;
28
31
const writeFile = promisify ( _writeFile ) ;
29
- const chalk = require ( 'chalk' ) ;
30
- const Listr = require ( 'listr' ) ;
31
-
32
+ const git = simpleGit ( projectRoot ) ;
32
33
const FIREBASE_UMBRELLA_PACKAGE_NAME = 'firebase-exp' ;
33
34
34
35
async function publishExpPackages ( ) {
@@ -43,11 +44,6 @@ async function publishExpPackages() {
43
44
*/
44
45
await buildPackages ( ) ;
45
46
46
- /**
47
- * run tests
48
- */
49
- await runTests ( ) ;
50
-
51
47
// path to exp packages
52
48
const packagePaths = await mapWorkspaceToPackages ( [
53
49
`${ projectRoot } /packages-exp/*`
@@ -73,7 +69,7 @@ async function publishExpPackages() {
73
69
* reset the working tree to recover package names with -exp in the package.json files,
74
70
* then bump patch version of firebase-exp (the umbrella package) only
75
71
*/
76
- const firebaseExpVersion = new Map ( ) ;
72
+ const firebaseExpVersion = new Map < string , string > ( ) ;
77
73
firebaseExpVersion . set (
78
74
FIREBASE_UMBRELLA_PACKAGE_NAME ,
79
75
versions . get ( FIREBASE_UMBRELLA_PACKAGE_NAME )
@@ -110,14 +106,7 @@ async function buildPackages() {
110
106
} ) ;
111
107
}
112
108
113
- async function runTests ( ) {
114
- await spawn ( 'yarn' , [ 'test:exp' ] , {
115
- cwd : projectRoot ,
116
- stdio : 'inherit'
117
- } ) ;
118
- }
119
-
120
- async function updatePackageNamesAndVersions ( packagePaths ) {
109
+ async function updatePackageNamesAndVersions ( packagePaths : string [ ] ) {
121
110
// get package name -> next version mapping
122
111
const versions = new Map ( ) ;
123
112
for ( const path of packagePaths ) {
@@ -145,7 +134,7 @@ async function updatePackageNamesAndVersions(packagePaths) {
145
134
return versions ;
146
135
}
147
136
148
- async function publishToNpm ( packagePaths ) {
137
+ async function publishToNpm ( packagePaths : string [ ] ) {
149
138
const taskArray = await Promise . all (
150
139
packagePaths . map ( async pp => {
151
140
const { version, name } = await readPackageJson ( pp ) ;
@@ -165,12 +154,15 @@ async function publishToNpm(packagePaths) {
165
154
return tasks . run ( ) ;
166
155
}
167
156
168
- async function publishPackage ( packagePath ) {
157
+ async function publishPackage ( packagePath : string ) {
169
158
const args = [ 'publish' , '--access' , 'public' , '--tag' , 'exp' ] ;
170
159
await spawn ( 'npm' , args , { cwd : packagePath } ) ;
171
160
}
172
161
173
- async function resetWorkingTreeAndBumpVersions ( packagePaths , versions ) {
162
+ async function resetWorkingTreeAndBumpVersions (
163
+ packagePaths : string [ ] ,
164
+ versions : Map < string , string >
165
+ ) {
174
166
console . log ( 'Resetting working tree' ) ;
175
167
await git . checkout ( '.' ) ;
176
168
@@ -182,9 +174,17 @@ async function resetWorkingTreeAndBumpVersions(packagePaths, versions) {
182
174
}
183
175
184
176
async function updatePackageJsons (
185
- packagePaths ,
186
- versions ,
187
- { removeExpInName, updateVersions, makePublic }
177
+ packagePaths : string [ ] ,
178
+ versions : Map < string , string > ,
179
+ {
180
+ removeExpInName,
181
+ updateVersions,
182
+ makePublic
183
+ } : {
184
+ removeExpInName : boolean ;
185
+ updateVersions : boolean ;
186
+ makePublic : boolean ;
187
+ }
188
188
) {
189
189
for ( const path of packagePaths ) {
190
190
const packageJsonPath = `${ path } /package.json` ;
@@ -210,7 +210,7 @@ async function updatePackageJsons(
210
210
// update dep version and remove -exp in dep names
211
211
// don't care about devDependencies because they are irrelavant when using the package
212
212
const dependencies = packageJson . dependencies || { } ;
213
- const newDependenciesObj = { } ;
213
+ const newDependenciesObj : { [ key : string ] : string } = { } ;
214
214
for ( const d of Object . keys ( dependencies ) ) {
215
215
const dNextVersion = versions . get ( d ) ;
216
216
const nameWithoutExp = removeExpInPackageName ( d ) ;
@@ -237,7 +237,7 @@ async function updatePackageJsons(
237
237
}
238
238
}
239
239
240
- async function commitAndPush ( versions ) {
240
+ async function commitAndPush ( versions : Map < string , string > ) {
241
241
await exec ( 'git add */package.json yarn.lock' ) ;
242
242
243
243
const firebaseExpVersion = versions . get ( FIREBASE_UMBRELLA_PACKAGE_NAME ) ;
@@ -255,7 +255,7 @@ async function commitAndPush(versions) {
255
255
} ) ;
256
256
}
257
257
258
- function removeExpInPackageName ( name ) {
258
+ function removeExpInPackageName ( name : string ) {
259
259
const regex = / ^ ( .* f i r e b a s e .* ) - e x p ( .* ) $ / g;
260
260
261
261
const captures = regex . exec ( name ) ;
@@ -266,7 +266,7 @@ function removeExpInPackageName(name) {
266
266
return `${ captures [ 1 ] } ${ captures [ 2 ] } ` ;
267
267
}
268
268
269
- async function readPackageJson ( packagePath ) {
269
+ async function readPackageJson ( packagePath : string ) {
270
270
/**
271
271
* Can't require here because require caches the file
272
272
* in memory, so it may not contain the updates that are made by e.g. git commands
0 commit comments