@@ -66,7 +66,7 @@ function runPushy(args: string[], cwd: string) {
6666 }
6767 const result = spawnSync ( 'node' , [ cliEntry , ...args ] , {
6868 cwd,
69- stdio : 'pipe ' ,
69+ stdio : 'inherit ' ,
7070 env : {
7171 ...process . env ,
7272 NODE_PATH : nodePath . join ( path . delimiter ) ,
@@ -77,12 +77,9 @@ function runPushy(args: string[], cwd: string) {
7777 timeout : 120_000 ,
7878 } ) ;
7979
80- const stdout = result . stdout ?. toString ( ) ?? '' ;
81- const stderr = result . stderr ?. toString ( ) ?? '' ;
82- if ( stdout ) console . log ( `[pushy ${ args [ 0 ] } ] stdout:` , stdout . trim ( ) ) ;
83- if ( stderr ) console . log ( `[pushy ${ args [ 0 ] } ] stderr:` , stderr . trim ( ) ) ;
84- console . log ( `[pushy ${ args [ 0 ] } ] exit code: ${ result . status } , signal: ${ result . signal } ` ) ;
85-
80+ if ( result . error ) {
81+ throw result . error ;
82+ }
8683 if ( result . status !== 0 ) {
8784 throw new Error (
8885 `pushy ${ args . join ( ' ' ) } failed with exit code ${ result . status } ` ,
@@ -126,32 +123,6 @@ function prepareDir() {
126123 fs . mkdirSync ( artifactsDir , { recursive : true } ) ;
127124}
128125
129- function runHdiffWrapper ( mode : 'ppk' | 'apk' , oldFile : string , newFile : string , outputFile : string ) {
130- // Use projectRoot (source dir) not __dirname (which may be .ts-build/)
131- const wrapperScript = path . join ( projectRoot , 'scripts' , 'run-hdiff-wrapper.js' ) ;
132- console . log ( `[runHdiffWrapper] script=${ wrapperScript } cliRoot=${ cliRoot } mode=${ mode } ` ) ;
133- console . log ( `[runHdiffWrapper] args: [${ cliRoot } , ${ mode } , ${ oldFile } , ${ newFile } , ${ outputFile } ]` ) ;
134- const result = spawnSync (
135- process . execPath ,
136- [ wrapperScript , cliRoot , mode , oldFile , newFile , outputFile ] ,
137- {
138- cwd : projectRoot ,
139- stdio : 'inherit' ,
140- env : {
141- ...process . env ,
142- NODE_PATH : [
143- path . join ( projectRoot , 'node_modules' ) ,
144- path . join ( cliRoot , 'node_modules' ) ,
145- ] . join ( path . delimiter ) ,
146- } ,
147- } ,
148- ) ;
149-
150- if ( result . status !== 0 ) {
151- throw new Error ( `${ mode } wrapper failed with exit code ${ result . status } ` ) ;
152- }
153- }
154-
155126function bundleTo ( entryFile : string , outputFile : string ) {
156127 runPushy (
157128 [
@@ -171,6 +142,35 @@ function bundleTo(entryFile: string, outputFile: string) {
171142 ) ;
172143}
173144
145+ function verifyGeneratedFile ( label : string , filePath : string ) {
146+ if ( ! fs . existsSync ( filePath ) ) {
147+ throw new Error ( `${ label } file not found after generation: ${ filePath } ` ) ;
148+ }
149+ console . log (
150+ `Verified ${ label } : ${ filePath } (${ fs . statSync ( filePath ) . size } bytes)` ,
151+ ) ;
152+ }
153+
154+ function generatePpkDiff ( origin : string , next : string , output : string ) {
155+ runPushy (
156+ [ 'hdiff' , origin , next , '--output' , output , '--no-interactive' ] ,
157+ projectRoot ,
158+ ) ;
159+ verifyGeneratedFile ( 'ppk diff' , output ) ;
160+ }
161+
162+ function generateAndroidPackageDiff (
163+ apkPath : string ,
164+ next : string ,
165+ output : string ,
166+ ) {
167+ runPushy (
168+ [ 'hdiffFromApk' , apkPath , next , '--output' , output , '--no-interactive' ] ,
169+ projectRoot ,
170+ ) ;
171+ verifyGeneratedFile ( 'package diff' , output ) ;
172+ }
173+
174174async function main ( ) {
175175 prepareDir ( ) ;
176176
@@ -186,11 +186,7 @@ async function main() {
186186 ensureHdiffModule ( ) ;
187187
188188 console . log ( 'Generating ppk diff...' ) ;
189- runHdiffWrapper ( 'ppk' , v1 , v2 , ppkDiff ) ;
190- if ( ! fs . existsSync ( ppkDiff ) ) {
191- throw new Error ( `ppk diff file not found after generation: ${ ppkDiff } ` ) ;
192- }
193- console . log ( `Verified ppk diff: ${ ppkDiff } (${ fs . statSync ( ppkDiff ) . size } bytes)` ) ;
189+ generatePpkDiff ( v1 , v2 , ppkDiff ) ;
194190
195191 if ( platform === 'android' ) {
196192 const apkPath = path . join (
@@ -206,17 +202,15 @@ async function main() {
206202
207203 fs . copyFileSync ( apkPath , path . join ( artifactsDir , LOCAL_UPDATE_FILES . apk ) ) ;
208204 console . log ( 'Generating package diff...' ) ;
209- runHdiffWrapper (
210- 'apk' ,
205+ const packageDiffPath = path . join (
206+ artifactsDir ,
207+ LOCAL_UPDATE_FILES . packageDiff ,
208+ ) ;
209+ generateAndroidPackageDiff (
211210 apkPath ,
212211 v3 ,
213- path . join ( artifactsDir , LOCAL_UPDATE_FILES . packageDiff ) ,
212+ packageDiffPath ,
214213 ) ;
215- const packageDiffPath = path . join ( artifactsDir , LOCAL_UPDATE_FILES . packageDiff ) ;
216- if ( ! fs . existsSync ( packageDiffPath ) ) {
217- throw new Error ( `Package diff file not found after generation: ${ packageDiffPath } ` ) ;
218- }
219- console . log ( `Verified package diff: ${ packageDiffPath } (${ fs . statSync ( packageDiffPath ) . size } bytes)` ) ;
220214 }
221215
222216 const manifestPath = path . join ( artifactsDir , 'manifest.json' ) ;
0 commit comments