@@ -95,7 +95,7 @@ function createMockServer(requests: string[], options: MockServerOptions = {}) {
9595 return ;
9696 }
9797
98- if ( url === '/api/app/100 /version/create' ) {
98+ if ( url . startsWith ( '/api/app/' ) && url . endsWith ( ' /version/create') ) {
9999 const body = await readBody ( request ) ;
100100 options . createdVersions ?. push ( JSON . parse ( body ) ) ;
101101 sendJson ( response , 200 , { id : '200' } ) ;
@@ -324,4 +324,82 @@ describe('CLI e2e', () => {
324324 }
325325 }
326326 } ) ;
327+
328+ test ( 'publishes a ppk using custom config path' , async ( ) => {
329+ const requests : string [ ] = [ ] ;
330+ const createdVersions : unknown [ ] = [ ] ;
331+ const server = createMockServer ( requests , { createdVersions } ) ;
332+ let tempRoot : string | undefined ;
333+
334+ await new Promise < void > ( ( resolve ) => {
335+ server . listen ( 0 , '127.0.0.1' , resolve ) ;
336+ } ) ;
337+ closeServer = ( ) =>
338+ new Promise ( ( resolve ) => {
339+ if ( ! server . listening ) {
340+ resolve ( ) ;
341+ return ;
342+ }
343+ server . close ( ( ) => {
344+ server . closeAllConnections ?.( ) ;
345+ resolve ( ) ;
346+ } ) ;
347+ } ) ;
348+
349+ try {
350+ tempRoot = await mkdtemp ( path . join ( tmpdir ( ) , 'rn-update-cli-e2e-' ) ) ;
351+ await writeFile (
352+ path . join ( tempRoot , 'update-custom.json' ) ,
353+ JSON . stringify ( {
354+ android : {
355+ appId : 105 ,
356+ appKey : 'android-key-custom' ,
357+ } ,
358+ } ) ,
359+ ) ;
360+ await writeFile ( path . join ( tempRoot , 'bundle.ppk' ) , 'fake-ppk' ) ;
361+
362+ const { port } = server . address ( ) as AddressInfo ;
363+ const origin = `http://127.0.0.1:${ port } ` ;
364+ const result = await runCli ( {
365+ args : [
366+ path . join ( repoRoot , 'src/bin.ts' ) ,
367+ 'publish' ,
368+ 'bundle.ppk' ,
369+ '--platform' ,
370+ 'android' ,
371+ '--name' ,
372+ 'v1-custom' ,
373+ '--config' ,
374+ 'update-custom.json' ,
375+ '--no-interactive' ,
376+ ] ,
377+ cwd : tempRoot ,
378+ env : {
379+ ...process . env ,
380+ NO_INTERACTIVE : 'true' ,
381+ PUSHY_REGISTRY : `${ origin } /api` ,
382+ npm_config_registry : `${ origin } /registry/` ,
383+ } ,
384+ } ) ;
385+
386+ expect ( result . status ) . toBe ( 0 ) ;
387+ expect ( result . stderr . trim ( ) ) . toBe ( '' ) ;
388+ expect ( requests ) . toContain ( 'POST /api/upload' ) ;
389+ expect ( requests ) . toContain ( 'POST /oss/upload' ) ;
390+ expect ( requests ) . toContain ( 'POST /api/app/105/version/create' ) ;
391+ expect ( createdVersions ) . toEqual ( [
392+ expect . objectContaining ( {
393+ name : 'v1-custom' ,
394+ hash : 'hash-from-oss' ,
395+ description : '' ,
396+ metaInfo : '' ,
397+ } ) ,
398+ ] ) ;
399+ } finally {
400+ if ( tempRoot ) {
401+ await rm ( tempRoot , { force : true , recursive : true } ) ;
402+ }
403+ }
404+ } ) ;
327405} ) ;
0 commit comments