17
17
18
18
import { spawn } from 'child-process-promise' ;
19
19
import { projectRoot , readPackageJson } from '../utils' ;
20
- import { writeFile as _writeFile } from 'fs' ;
20
+ import { writeFile as _writeFile , readFile as _readFile } from 'fs' ;
21
21
import { promisify } from 'util' ;
22
- import { removeExpSuffix } from './remove-exp' ;
22
+ import path from 'path' ;
23
+
23
24
const writeFile = promisify ( _writeFile ) ;
25
+ const readFile = promisify ( _readFile ) ;
24
26
const packagePath = `${ projectRoot } /packages/firestore` ;
25
27
26
28
// Prepare @firebase /firestore, so scripts/exp/release.ts can be used to release it
@@ -34,6 +36,7 @@ export async function prepare() {
34
36
// Update package.json
35
37
const packageJson = await readPackageJson ( packagePath ) ;
36
38
const expPackageJson = await readPackageJson ( `${ packagePath } /exp` ) ;
39
+ const litePackageJson = await readPackageJson ( `${ packagePath } /lite` ) ;
37
40
packageJson . version = '0.0.800' ;
38
41
39
42
packageJson . peerDependencies = {
@@ -60,7 +63,23 @@ export async function prepare() {
60
63
{ encoding : 'utf-8' }
61
64
) ;
62
65
66
+ const expTypingPath = `${ packagePath } /${ packageJson . typing } ` ;
67
+ const liteTypingPath = path . resolve (
68
+ `${ packagePath } /lite` ,
69
+ litePackageJson . typing
70
+ ) ;
71
+
63
72
// remove -exp in typings files
64
- removeExpSuffix ( `${ packagePath } /exp-types` ) ;
65
- removeExpSuffix ( `${ packagePath } /lite-types` ) ;
73
+ await replaceAppTypesExpInFile ( expTypingPath ) ;
74
+ await replaceAppTypesExpInFile ( liteTypingPath ) ;
75
+ }
76
+
77
+ async function replaceAppTypesExpInFile ( filePath : string ) : Promise < void > {
78
+ const fileContent = await readFile ( filePath , { encoding : 'utf-8' } ) ;
79
+ const newFileContent = fileContent . replace (
80
+ '@firebase/app-types-exp' ,
81
+ '@firebase/app-types'
82
+ ) ;
83
+
84
+ await writeFile ( filePath , newFileContent , { encoding : 'utf-8' } ) ;
66
85
}
0 commit comments