@@ -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 ( {
@@ -1402,7 +1402,7 @@ function addLoginCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14021402 } ) ,
14031403 async ( argv ) => {
14041404 await cliContext . runTask ( async ( context ) => {
1405- await cliContext . instrumentPostHogEvent ( {
1405+ cliContext . instrumentPostHogEvent ( {
14061406 command : "fern login"
14071407 } ) ;
14081408 await login ( context , { useDeviceCodeFlow : argv . deviceCode } ) ;
@@ -1418,7 +1418,7 @@ function addLogoutCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14181418 ( yargs ) => yargs ,
14191419 async ( ) => {
14201420 await cliContext . runTask ( async ( context ) => {
1421- await cliContext . instrumentPostHogEvent ( {
1421+ cliContext . instrumentPostHogEvent ( {
14221422 command : "fern logout"
14231423 } ) ;
14241424 await logout ( context ) ;
@@ -1443,7 +1443,7 @@ function addFormatCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14431443 description : "Only run the command on the provided API"
14441444 } ) ,
14451445 async ( argv ) => {
1446- await cliContext . instrumentPostHogEvent ( {
1446+ cliContext . instrumentPostHogEvent ( {
14471447 command : "fern format"
14481448 } ) ;
14491449 await formatWorkspaces ( {
@@ -1477,7 +1477,7 @@ function addTestCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
14771477 description : "Run the tests configured to a specific language"
14781478 } ) ,
14791479 async ( argv ) => {
1480- await cliContext . instrumentPostHogEvent ( {
1480+ cliContext . instrumentPostHogEvent ( {
14811481 command : "fern test"
14821482 } ) ;
14831483 await testOutput ( {
@@ -1510,7 +1510,7 @@ function addMockCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
15101510 description : "The API to mock."
15111511 } ) ,
15121512 async ( argv ) => {
1513- await cliContext . instrumentPostHogEvent ( {
1513+ cliContext . instrumentPostHogEvent ( {
15141514 command : "fern mock"
15151515 } ) ;
15161516 await mockServer ( {
@@ -1555,7 +1555,7 @@ function addOverridesCompareCommand(cli: Argv<GlobalCliOptions>, cliContext: Cli
15551555 description : "Path to write the overrides file (defaults to <original>-overrides.yml)"
15561556 } ) ,
15571557 async ( argv ) => {
1558- await cliContext . instrumentPostHogEvent ( {
1558+ cliContext . instrumentPostHogEvent ( {
15591559 command : "fern overrides compare"
15601560 } ) ;
15611561 const originalPath = resolve ( cwd ( ) , argv . original as string ) ;
@@ -1588,7 +1588,7 @@ function addOverridesWriteCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
15881588 } )
15891589 ] ,
15901590 async ( argv ) => {
1591- await cliContext . instrumentPostHogEvent ( {
1591+ cliContext . instrumentPostHogEvent ( {
15921592 command : "fern overrides write"
15931593 } ) ;
15941594 await writeOverridesForWorkspaces ( {
@@ -1624,7 +1624,7 @@ function addWriteOverridesCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
16241624 ] ,
16251625 async ( argv ) => {
16261626 cliContext . logger . warn ( "The 'write-overrides' command is deprecated. Use 'fern overrides write' instead." ) ;
1627- await cliContext . instrumentPostHogEvent ( {
1627+ cliContext . instrumentPostHogEvent ( {
16281628 command : "fern write-overrides"
16291629 } ) ;
16301630 await writeOverridesForWorkspaces ( {
@@ -1659,7 +1659,7 @@ function addWriteDefinitionCommand(cli: Argv<GlobalCliOptions>, cliContext: CliC
16591659 } ) ,
16601660 async ( argv ) => {
16611661 const preserveSchemaIds = argv . preserveSchemas != null ;
1662- await cliContext . instrumentPostHogEvent ( {
1662+ cliContext . instrumentPostHogEvent ( {
16631663 command : "fern write-definition"
16641664 } ) ;
16651665 await writeDefinitionForWorkspaces ( {
@@ -1708,7 +1708,7 @@ function addDocsMdGenerateCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCo
17081708 description : "Name of a specific library defined in docs.yml to generate docs for"
17091709 } ) ,
17101710 async ( argv ) => {
1711- await cliContext . instrumentPostHogEvent ( {
1711+ cliContext . instrumentPostHogEvent ( {
17121712 command : "fern docs md generate"
17131713 } ) ;
17141714
@@ -1749,7 +1749,7 @@ function addDocsDiffCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext)
17491749 description : "Output directory for diff images"
17501750 } ) ,
17511751 async ( argv ) => {
1752- await cliContext . instrumentPostHogEvent ( {
1752+ cliContext . instrumentPostHogEvent ( {
17531753 command : "fern docs diff"
17541754 } ) ;
17551755
@@ -1794,7 +1794,7 @@ function addDocsPreviewListCommand(cli: Argv<GlobalCliOptions>, cliContext: CliC
17941794 description : "Page number for pagination (starts at 1)"
17951795 } ) ,
17961796 async ( argv ) => {
1797- await cliContext . instrumentPostHogEvent ( {
1797+ cliContext . instrumentPostHogEvent ( {
17981798 command : "fern docs preview list"
17991799 } ) ;
18001800 await listDocsPreview ( {
@@ -1818,7 +1818,7 @@ function addDocsPreviewDeleteCommand(cli: Argv<GlobalCliOptions>, cliContext: Cl
18181818 demandOption : true
18191819 } ) ,
18201820 async ( argv ) => {
1821- await cliContext . instrumentPostHogEvent ( {
1821+ cliContext . instrumentPostHogEvent ( {
18221822 command : "fern docs preview delete"
18231823 } ) ;
18241824 await deleteDocsPreview ( {
@@ -1937,7 +1937,7 @@ function addDocsMdCheckCommand(cli: Argv<GlobalCliOptions>, cliContext: CliConte
19371937 // No additional options for this command
19381938 } ,
19391939 async ( ) => {
1940- await cliContext . instrumentPostHogEvent ( {
1940+ cliContext . instrumentPostHogEvent ( {
19411941 command : "fern docs md check"
19421942 } ) ;
19431943
@@ -1993,7 +1993,7 @@ function addGenerateJsonschemaCommand(cli: Argv<GlobalCliOptions>, cliContext: C
19931993 description : "The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"
19941994 } ) ,
19951995 async ( argv ) => {
1996- await cliContext . instrumentPostHogEvent ( {
1996+ cliContext . instrumentPostHogEvent ( {
19971997 command : "fern jsonschema" ,
19981998 properties : {
19991999 output : argv . output
@@ -2023,7 +2023,7 @@ function addWriteDocsDefinitionCommand(cli: Argv<GlobalCliOptions>, cliContext:
20232023 demandOption : true
20242024 } ) ,
20252025 async ( argv ) => {
2026- await cliContext . instrumentPostHogEvent ( {
2026+ cliContext . instrumentPostHogEvent ( {
20272027 command : "fern write-docs-definition" ,
20282028 properties : {
20292029 outputPath : argv . outputPath
@@ -2054,7 +2054,7 @@ function addWriteTranslationCommand(cli: Argv<GlobalCliOptions>, cliContext: Cli
20542054 description : "Return content as-is without calling the translation service"
20552055 } ) ,
20562056 async ( argv ) => {
2057- await cliContext . instrumentPostHogEvent ( {
2057+ cliContext . instrumentPostHogEvent ( {
20582058 command : "fern write-translation"
20592059 } ) ;
20602060
@@ -2091,7 +2091,7 @@ function addExportCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
20912091 default : 2
20922092 } ) ,
20932093 async ( argv ) => {
2094- await cliContext . instrumentPostHogEvent ( {
2094+ cliContext . instrumentPostHogEvent ( {
20952095 command : "fern export" ,
20962096 properties : {
20972097 outputPath : argv . outputPath
@@ -2135,7 +2135,7 @@ function addEnrichCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContext) {
21352135 demandOption : true
21362136 } ) ,
21372137 async ( argv ) => {
2138- await cliContext . instrumentPostHogEvent ( {
2138+ cliContext . instrumentPostHogEvent ( {
21392139 command : "fern api enrich"
21402140 } ) ;
21412141 const openapiPath = resolve ( cwd ( ) , argv . openapi as string ) ;
@@ -2182,7 +2182,7 @@ function addSdkPreviewCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContex
21822182 description : "Output result as JSON"
21832183 } ) ,
21842184 async ( argv ) => {
2185- await cliContext . instrumentPostHogEvent ( {
2185+ cliContext . instrumentPostHogEvent ( {
21862186 command : "fern sdk preview"
21872187 } ) ;
21882188 const generatorFilter =
@@ -2339,7 +2339,7 @@ function addReplayInitCommand(cli: Argv<GlobalCliOptions>, cliContext: CliContex
23392339 description : "Overwrite existing lockfile if Replay is already initialized"
23402340 } ) ,
23412341 async ( argv ) => {
2342- await cliContext . instrumentPostHogEvent ( {
2342+ cliContext . instrumentPostHogEvent ( {
23432343 command : "fern replay init"
23442344 } ) ;
23452345
@@ -2457,7 +2457,7 @@ function addReplayResolveCommand(cli: Argv<GlobalCliOptions>, cliContext: CliCon
24572457 description : "Skip checking for remaining conflict markers before committing"
24582458 } ) ,
24592459 async ( argv ) => {
2460- await cliContext . instrumentPostHogEvent ( {
2460+ cliContext . instrumentPostHogEvent ( {
24612461 command : "fern replay resolve"
24622462 } ) ;
24632463
0 commit comments