@@ -13,7 +13,6 @@ import * as vscode from "vscode";
13
13
import { errToStr } from "./api/api-helper" ;
14
14
import * as cli from "./cliManager" ;
15
15
import { PathResolver } from "./core/pathResolver" ;
16
- import { getHeaderCommand , getHeaders } from "./headers" ;
17
16
import * as pgp from "./pgp" ;
18
17
19
18
// Maximium number of recent URLs to store.
@@ -588,107 +587,4 @@ export class Storage {
588
587
}
589
588
return status ;
590
589
}
591
-
592
- /**
593
- * Configure the CLI for the deployment with the provided label.
594
- *
595
- * Falsey URLs and null tokens are a no-op; we avoid unconfiguring the CLI to
596
- * avoid breaking existing connections.
597
- */
598
- public async configureCli (
599
- label : string ,
600
- url : string | undefined ,
601
- token : string | null ,
602
- ) {
603
- await Promise . all ( [
604
- this . updateUrlForCli ( label , url ) ,
605
- this . updateTokenForCli ( label , token ) ,
606
- ] ) ;
607
- }
608
-
609
- /**
610
- * Update the URL for the deployment with the provided label on disk which can
611
- * be used by the CLI via --url-file. If the URL is falsey, do nothing.
612
- *
613
- * If the label is empty, read the old deployment-unaware config instead.
614
- */
615
- private async updateUrlForCli (
616
- label : string ,
617
- url : string | undefined ,
618
- ) : Promise < void > {
619
- if ( url ) {
620
- const urlPath = this . pathResolver . getUrlPath ( label ) ;
621
- await fs . mkdir ( path . dirname ( urlPath ) , { recursive : true } ) ;
622
- await fs . writeFile ( urlPath , url ) ;
623
- }
624
- }
625
-
626
- /**
627
- * Update the session token for a deployment with the provided label on disk
628
- * which can be used by the CLI via --session-token-file. If the token is
629
- * null, do nothing.
630
- *
631
- * If the label is empty, read the old deployment-unaware config instead.
632
- */
633
- private async updateTokenForCli (
634
- label : string ,
635
- token : string | undefined | null ,
636
- ) {
637
- if ( token !== null ) {
638
- const tokenPath = this . pathResolver . getSessionTokenPath ( label ) ;
639
- await fs . mkdir ( path . dirname ( tokenPath ) , { recursive : true } ) ;
640
- await fs . writeFile ( tokenPath , token ?? "" ) ;
641
- }
642
- }
643
-
644
- /**
645
- * Read the CLI config for a deployment with the provided label.
646
- *
647
- * IF a config file does not exist, return an empty string.
648
- *
649
- * If the label is empty, read the old deployment-unaware config.
650
- */
651
- public async readCliConfig (
652
- label : string ,
653
- ) : Promise < { url : string ; token : string } > {
654
- const urlPath = this . pathResolver . getUrlPath ( label ) ;
655
- const tokenPath = this . pathResolver . getSessionTokenPath ( label ) ;
656
- const [ url , token ] = await Promise . allSettled ( [
657
- fs . readFile ( urlPath , "utf8" ) ,
658
- fs . readFile ( tokenPath , "utf8" ) ,
659
- ] ) ;
660
- return {
661
- url : url . status === "fulfilled" ? url . value . trim ( ) : "" ,
662
- token : token . status === "fulfilled" ? token . value . trim ( ) : "" ,
663
- } ;
664
- }
665
-
666
- /**
667
- * Migrate the session token file from "session_token" to "session", if needed.
668
- */
669
- public async migrateSessionToken ( label : string ) {
670
- const oldTokenPath = this . pathResolver . getLegacySessionTokenPath ( label ) ;
671
- const newTokenPath = this . pathResolver . getSessionTokenPath ( label ) ;
672
- try {
673
- await fs . rename ( oldTokenPath , newTokenPath ) ;
674
- } catch ( error ) {
675
- if ( ( error as NodeJS . ErrnoException ) ?. code === "ENOENT" ) {
676
- return ;
677
- }
678
- throw error ;
679
- }
680
- }
681
-
682
- /**
683
- * Run the header command and return the generated headers.
684
- */
685
- public async getHeaders (
686
- url : string | undefined ,
687
- ) : Promise < Record < string , string > > {
688
- return getHeaders (
689
- url ,
690
- getHeaderCommand ( vscode . workspace . getConfiguration ( ) ) ,
691
- this . output ,
692
- ) ;
693
- }
694
590
}
0 commit comments