@@ -25,6 +25,7 @@ import { jsonChangelog } from './changelog-renderers/json-changelog';
2525import * as Types from '../../client/optic-backend-types' ;
2626import { openUrl } from '../../utils/open-url' ;
2727import { renderCloudSetup } from '../../utils/render-cloud' ;
28+ import { CustomUploadFn } from '../../types' ;
2829
2930const usage = ( ) => `
3031 optic diff-all
@@ -42,7 +43,11 @@ Example usage:
4243 $ optic diff-all --standard @org/example-standard --web --check
4344 ` ;
4445
45- export const registerDiffAll = ( cli : Command , config : OpticCliConfig ) => {
46+ export const registerDiffAll = (
47+ cli : Command ,
48+ config : OpticCliConfig ,
49+ options : { customUpload ?: CustomUploadFn }
50+ ) => {
4651 cli
4752 . command ( 'diff-all' , { hidden : true } )
4853 . configureHelp ( {
@@ -106,7 +111,9 @@ comma separated values (e.g. "**/*.yml,**/*.json")'
106111 '[deprecated] all matching APIs are now added by default' ,
107112 false
108113 )
109- . action ( errorHandler ( getDiffAllAction ( config ) , { command : 'diff-all' } ) ) ;
114+ . action (
115+ errorHandler ( getDiffAllAction ( config , options ) , { command : 'diff-all' } )
116+ ) ;
110117} ;
111118
112119type DiffAllActionOptions = {
@@ -196,7 +203,8 @@ function matchCandidates(
196203async function computeAll (
197204 candidateMap : CandidateMap ,
198205 config : OpticCliConfig ,
199- options : DiffAllActionOptions
206+ options : DiffAllActionOptions ,
207+ customOptions : { customUpload ?: CustomUploadFn }
200208) : Promise < {
201209 warnings : Warnings ;
202210 results : Result [ ] ;
@@ -398,21 +406,25 @@ async function computeAll(
398406 let changelogUrl : string | null = null ;
399407 let specUrl : string | null = null ;
400408 if ( options . upload ) {
401- const uploadResults = await uploadDiff (
402- {
403- from : fromParseResults ,
404- to : toParseResults ,
405- } ,
406- specResults ,
407- config ,
408- specDetails ,
409- {
410- headTag : options . headTag ,
411- standard,
412- }
413- ) ;
414- specUrl = uploadResults ?. headSpecUrl ?? null ;
415- changelogUrl = uploadResults ?. changelogUrl ?? null ;
409+ if ( customOptions . customUpload ) {
410+ await customOptions . customUpload ( toParseResults ) ;
411+ } else {
412+ const uploadResults = await uploadDiff (
413+ {
414+ from : fromParseResults ,
415+ to : toParseResults ,
416+ } ,
417+ specResults ,
418+ config ,
419+ specDetails ,
420+ {
421+ headTag : options . headTag ,
422+ standard,
423+ }
424+ ) ;
425+ specUrl = uploadResults ?. headSpecUrl ?? null ;
426+ changelogUrl = uploadResults ?. changelogUrl ?? null ;
427+ }
416428 }
417429
418430 let sourcemapOptions : GetSourcemapOptions = {
@@ -619,7 +631,8 @@ function applyGlobFilter(
619631}
620632
621633const getDiffAllAction =
622- ( config : OpticCliConfig ) => async ( options : DiffAllActionOptions ) => {
634+ ( config : OpticCliConfig , customOptions : { customUpload ?: CustomUploadFn } ) =>
635+ async ( options : DiffAllActionOptions ) => {
623636 if ( options . generated ) {
624637 logger . warn (
625638 chalk . yellow . bold (
@@ -729,7 +742,8 @@ const getDiffAllAction =
729742 const { warnings, results } = await computeAll (
730743 candidateMap ,
731744 config ,
732- options
745+ options ,
746+ customOptions
733747 ) ;
734748
735749 for ( const result of results ) {
0 commit comments