@@ -91,7 +91,7 @@ const USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
9191
9292async function runCli ( ) {
9393 const isLocal = process . argv . includes ( "--local" ) ;
94- const cliContext = new CliContext ( process . stdout , process . stderr , { isLocal } ) ;
94+ const cliContext = await CliContext . create ( process . stdout , process . stderr , { isLocal } ) ;
9595
9696 const exit = async ( ) => {
9797 await cliContext . exit ( ) ;
@@ -131,7 +131,7 @@ async function runCli() {
131131 } ) ;
132132 }
133133 } catch ( error ) {
134- await cliContext . instrumentPostHogEvent ( {
134+ cliContext . instrumentPostHogEvent ( {
135135 command : process . argv . join ( " " ) ,
136136 properties : {
137137 failed : true ,
@@ -532,7 +532,7 @@ function addSdkDiffCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext)
532532 description : "Output result as JSON"
533533 } ) ,
534534 async ( argv ) => {
535- await cliContext . instrumentPostHogEvent ( {
535+ cliContext . instrumentPostHogEvent ( {
536536 command : "fern sdk-diff"
537537 } ) ;
538538
@@ -1347,7 +1347,7 @@ function addUpdateApiSpecCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCon
13471347 default : 2
13481348 } ) ,
13491349 async ( argv ) => {
1350- await cliContext . instrumentPostHogEvent ( {
1350+ cliContext . instrumentPostHogEvent ( {
13511351 command : "fern api update"
13521352 } ) ;
13531353 await updateApiSpec ( {
@@ -1378,7 +1378,7 @@ function addSelfUpdateCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContex
13781378 default : false
13791379 } ) ,
13801380 async ( argv ) => {
1381- await cliContext . instrumentPostHogEvent ( {
1381+ cliContext . instrumentPostHogEvent ( {
13821382 command : "fern self-update"
13831383 } ) ;
13841384 await selfUpdate ( {
@@ -1407,7 +1407,7 @@ function addLoginCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14071407 } ) ,
14081408 async ( argv ) => {
14091409 await cliContext . runTask ( async ( context ) => {
1410- await cliContext . instrumentPostHogEvent ( {
1410+ cliContext . instrumentPostHogEvent ( {
14111411 command : "fern login"
14121412 } ) ;
14131413 await login ( context , { useDeviceCodeFlow : argv . deviceCode , email : argv . email } ) ;
@@ -1423,7 +1423,7 @@ function addLogoutCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14231423 ( yargs ) => yargs ,
14241424 async ( ) => {
14251425 await cliContext . runTask ( async ( context ) => {
1426- await cliContext . instrumentPostHogEvent ( {
1426+ cliContext . instrumentPostHogEvent ( {
14271427 command : "fern logout"
14281428 } ) ;
14291429 await logout ( context ) ;
@@ -1448,7 +1448,7 @@ function addFormatCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14481448 description : "Only run the command on the provided API"
14491449 } ) ,
14501450 async ( argv ) => {
1451- await cliContext . instrumentPostHogEvent ( {
1451+ cliContext . instrumentPostHogEvent ( {
14521452 command : "fern format"
14531453 } ) ;
14541454 await formatWorkspaces ( {
@@ -1482,7 +1482,7 @@ function addTestCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14821482 description : "Run the tests configured to a specific language"
14831483 } ) ,
14841484 async ( argv ) => {
1485- await cliContext . instrumentPostHogEvent ( {
1485+ cliContext . instrumentPostHogEvent ( {
14861486 command : "fern test"
14871487 } ) ;
14881488 await testOutput ( {
@@ -1515,7 +1515,7 @@ function addMockCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
15151515 description : "The API to mock."
15161516 } ) ,
15171517 async ( argv ) => {
1518- await cliContext . instrumentPostHogEvent ( {
1518+ cliContext . instrumentPostHogEvent ( {
15191519 command : "fern mock"
15201520 } ) ;
15211521 await mockServer ( {
@@ -1560,7 +1560,7 @@ function addOverridesCompareCommand(cli: Argv<GlobalCliOptions>, cliContext: Cli
15601560 description : "Path to write the overrides file (defaults to <original>-overrides.yml)"
15611561 } ) ,
15621562 async ( argv ) => {
1563- await cliContext . instrumentPostHogEvent ( {
1563+ cliContext . instrumentPostHogEvent ( {
15641564 command : "fern overrides compare"
15651565 } ) ;
15661566 const originalPath = resolve ( cwd ( ) , argv . original as string ) ;
@@ -1593,7 +1593,7 @@ function addOverridesWriteCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
15931593 } )
15941594 ] ,
15951595 async ( argv ) => {
1596- await cliContext . instrumentPostHogEvent ( {
1596+ cliContext . instrumentPostHogEvent ( {
15971597 command : "fern overrides write"
15981598 } ) ;
15991599 await writeOverridesForWorkspaces ( {
@@ -1629,7 +1629,7 @@ function addWriteOverridesCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
16291629 ] ,
16301630 async ( argv ) => {
16311631 cliContext . logger . warn ( "The 'write-overrides' command is deprecated. Use 'fern overrides write' instead." ) ;
1632- await cliContext . instrumentPostHogEvent ( {
1632+ cliContext . instrumentPostHogEvent ( {
16331633 command : "fern write-overrides"
16341634 } ) ;
16351635 await writeOverridesForWorkspaces ( {
@@ -1664,7 +1664,7 @@ function addWriteDefinitionCommand(cli: Argv<GlobalCliOptions>, cliContext: CliC
16641664 } ) ,
16651665 async ( argv ) => {
16661666 const preserveSchemaIds = argv . preserveSchemas != null ;
1667- await cliContext . instrumentPostHogEvent ( {
1667+ cliContext . instrumentPostHogEvent ( {
16681668 command : "fern write-definition"
16691669 } ) ;
16701670 await writeDefinitionForWorkspaces ( {
@@ -1713,7 +1713,7 @@ function addDocsMdGenerateCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
17131713 description : "Name of a specific library defined in docs.yml to generate docs for"
17141714 } ) ,
17151715 async ( argv ) => {
1716- await cliContext . instrumentPostHogEvent ( {
1716+ cliContext . instrumentPostHogEvent ( {
17171717 command : "fern docs md generate"
17181718 } ) ;
17191719
@@ -1754,7 +1754,7 @@ function addDocsDiffCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext)
17541754 description : "Output directory for diff images"
17551755 } ) ,
17561756 async ( argv ) => {
1757- await cliContext . instrumentPostHogEvent ( {
1757+ cliContext . instrumentPostHogEvent ( {
17581758 command : "fern docs diff"
17591759 } ) ;
17601760
@@ -1799,7 +1799,7 @@ function addDocsPreviewListCommand(cli: Argv<GlobalCliOptions>, cliContext: CliC
17991799 description : "Page number for pagination (starts at 1)"
18001800 } ) ,
18011801 async ( argv ) => {
1802- await cliContext . instrumentPostHogEvent ( {
1802+ cliContext . instrumentPostHogEvent ( {
18031803 command : "fern docs preview list"
18041804 } ) ;
18051805 await listDocsPreview ( {
@@ -1823,7 +1823,7 @@ function addDocsPreviewDeleteCommand(cli: Argv<GlobalCliOptions>, cliContext: Cl
18231823 demandOption : true
18241824 } ) ,
18251825 async ( argv ) => {
1826- await cliContext . instrumentPostHogEvent ( {
1826+ cliContext . instrumentPostHogEvent ( {
18271827 command : "fern docs preview delete"
18281828 } ) ;
18291829 await deleteDocsPreview ( {
@@ -1942,7 +1942,7 @@ function addDocsMdCheckCommand(cli: Argv<GlobalCliOptions>, cliContext: CliConte
19421942 // No additional options for this command
19431943 } ,
19441944 async ( ) => {
1945- await cliContext . instrumentPostHogEvent ( {
1945+ cliContext . instrumentPostHogEvent ( {
19461946 command : "fern docs md check"
19471947 } ) ;
19481948
@@ -1998,7 +1998,7 @@ function addGenerateJsonschemaCommand(cli: Argv<GlobalCliOptions>, cliContext: C
19981998 description : "The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"
19991999 } ) ,
20002000 async ( argv ) => {
2001- await cliContext . instrumentPostHogEvent ( {
2001+ cliContext . instrumentPostHogEvent ( {
20022002 command : "fern jsonschema" ,
20032003 properties : {
20042004 output : argv . output
@@ -2028,7 +2028,7 @@ function addWriteDocsDefinitionCommand(cli: Argv<GlobalCliOptions>, cliContext:
20282028 demandOption : true
20292029 } ) ,
20302030 async ( argv ) => {
2031- await cliContext . instrumentPostHogEvent ( {
2031+ cliContext . instrumentPostHogEvent ( {
20322032 command : "fern write-docs-definition" ,
20332033 properties : {
20342034 outputPath : argv . outputPath
@@ -2059,7 +2059,7 @@ function addWriteTranslationCommand(cli: Argv<GlobalCliOptions>, cliContext: Cli
20592059 description : "Return content as-is without calling the translation service"
20602060 } ) ,
20612061 async ( argv ) => {
2062- await cliContext . instrumentPostHogEvent ( {
2062+ cliContext . instrumentPostHogEvent ( {
20632063 command : "fern write-translation"
20642064 } ) ;
20652065
@@ -2096,7 +2096,7 @@ function addExportCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
20962096 default : 2
20972097 } ) ,
20982098 async ( argv ) => {
2099- await cliContext . instrumentPostHogEvent ( {
2099+ cliContext . instrumentPostHogEvent ( {
21002100 command : "fern export" ,
21012101 properties : {
21022102 outputPath : argv . outputPath
@@ -2140,7 +2140,7 @@ function addEnrichCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
21402140 demandOption : true
21412141 } ) ,
21422142 async ( argv ) => {
2143- await cliContext . instrumentPostHogEvent ( {
2143+ cliContext . instrumentPostHogEvent ( {
21442144 command : "fern api enrich"
21452145 } ) ;
21462146 const openapiPath = resolve ( cwd ( ) , argv . openapi as string ) ;
@@ -2187,7 +2187,7 @@ function addSdkPreviewCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContex
21872187 description : "Output result as JSON"
21882188 } ) ,
21892189 async ( argv ) => {
2190- await cliContext . instrumentPostHogEvent ( {
2190+ cliContext . instrumentPostHogEvent ( {
21912191 command : "fern sdk preview"
21922192 } ) ;
21932193 const generatorFilter =
@@ -2346,7 +2346,7 @@ function addReplayInitCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContex
23462346 description : "Overwrite existing lockfile if Replay is already initialized"
23472347 } ) ,
23482348 async ( argv ) => {
2349- await cliContext . instrumentPostHogEvent ( {
2349+ cliContext . instrumentPostHogEvent ( {
23502350 command : "fern replay init"
23512351 } ) ;
23522352
@@ -2468,7 +2468,7 @@ function addReplayResolveCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCon
24682468 description : "Skip checking for remaining conflict markers before committing"
24692469 } ) ,
24702470 async ( argv ) => {
2471- await cliContext . instrumentPostHogEvent ( {
2471+ cliContext . instrumentPostHogEvent ( {
24722472 command : "fern replay resolve"
24732473 } ) ;
24742474
0 commit comments