@@ -44,13 +44,19 @@ import { allToolsInformation } from './goToolsInformation';
44
44
45
45
const STATUS_BAR_ITEM_NAME = 'Go Tools' ;
46
46
47
- // minimum go version required for tools installation.
47
+ /**
48
+ * Minimum go version required for tools installation.
49
+ */
48
50
const MINIMUM_GO_VERSION = '1.21.0' ;
49
51
50
- // declinedUpdates tracks the tools that the user has declined to update.
52
+ /**
53
+ * Tracks the tools that the user has declined to update.
54
+ */
51
55
const declinedUpdates : Tool [ ] = [ ] ;
52
56
53
- // declinedUpdates tracks the tools that the user has declined to install.
57
+ /**
58
+ * Tracks the tools that the user has declined to install.
59
+ */
54
60
const declinedInstalls : Tool [ ] = [ ] ;
55
61
56
62
export interface IToolsManager {
@@ -107,10 +113,11 @@ export async function installAllTools(updateExistingToolsOnly = false) {
107
113
goVersion
108
114
) ;
109
115
}
110
-
111
- // Returns the go version to be used for tools installation.
112
- // If `go.toolsManagement.go` is set, it is preferred. Otherwise, the provided
113
- // goVersion or the default version returned by getGoVersion is returned.
116
+ /**
117
+ * Returns the go version to be used for tools installation.
118
+ * If `go.toolsManagement.go` is set, it is preferred. Otherwise, the provided
119
+ * goVersion or the default version returned by getGoVersion is returned.
120
+ */
114
121
export const getGoVersionForInstall = _getGoVersionForInstall ;
115
122
async function _getGoVersionForInstall ( goVersion ?: GoVersion ) : Promise < GoVersion | undefined > {
116
123
let configuredGoForInstall = getGoConfig ( ) . get < string > ( 'toolsManagement.go' ) ;
@@ -282,8 +289,10 @@ async function tmpDirForToolInstallation() {
282
289
return toolsTmpDir ;
283
290
}
284
291
285
- // installTool is used by goEnvironmentStatus.ts.
286
- // TODO(hyangah): replace the callsite to use defaultToolsManager and remove this.
292
+ /**
293
+ * installTool is used by goEnvironmentStatus.ts.
294
+ * TODO(hyangah): replace the callsite to use defaultToolsManager and remove this.
295
+ */
287
296
export async function installTool ( tool : ToolAtVersion ) : Promise < string | undefined > {
288
297
const goVersionForInstall = await getGoVersionForInstall ( ) ;
289
298
if ( ! goVersionForInstall ) {
@@ -553,9 +562,11 @@ export function updateGoVarsFromConfig(goCtx: GoExtensionContext): Promise<void>
553
562
} ) ;
554
563
}
555
564
556
- // maybeInstallImportantTools checks whether important tools are installed
557
- // and they meet the version requirement.
558
- // Then it tries to auto-install them if missing.
565
+ /**
566
+ * Checks whether important tools are installed and they meet the version
567
+ * requirement.
568
+ * Then it tries to auto-install them if missing.
569
+ */
559
570
export async function maybeInstallImportantTools (
560
571
alternateTools : { [ key : string ] : string } | undefined ,
561
572
tm : IToolsManager = defaultToolsManager
@@ -648,8 +659,10 @@ async function updateImportantToolsStatus(tm: IToolsManager = defaultToolsManage
648
659
}
649
660
}
650
661
651
- // getMissingTools returns missing tools.
652
- // If matcher is provided, only the tools that match the filter will be checked.
662
+ /**
663
+ * Returns missing tools.
664
+ * If matcher is provided, only the tools that match the filter will be checked.
665
+ */
653
666
function getMissingTools ( matcher ?: ( value : Tool ) => boolean ) : Promise < Tool [ ] > {
654
667
let keys = getConfiguredTools ( getGoConfig ( ) , getGoplsConfig ( ) ) ;
655
668
if ( matcher ) {
@@ -688,13 +701,17 @@ async function suggestDownloadGo() {
688
701
suggestedDownloadGo = true ;
689
702
}
690
703
691
- // ListVersionsOutput is the output of `go list -m -versions -json`.
704
+ /**
705
+ * The output of `go list -m -versions -json`.
706
+ */
692
707
interface ListVersionsOutput {
693
708
Version : string ; // module version
694
709
Versions ?: string [ ] ; // available module versions (with -versions)
695
710
}
696
711
697
- // latestToolVersion returns the latest version of the tool.
712
+ /**
713
+ * Returns the latest version of the tool.
714
+ */
698
715
export async function latestToolVersion ( tool : Tool , includePrerelease ?: boolean ) : Promise < semver . SemVer | null > {
699
716
const goCmd = getBinPath ( 'go' ) ;
700
717
const tmpDir = await tmpDirForToolInstallation ( ) ;
@@ -729,8 +746,10 @@ export async function latestToolVersion(tool: Tool, includePrerelease?: boolean)
729
746
return ret ;
730
747
}
731
748
732
- // inspectGoToolVersion reads the go version and module version
733
- // of the given go tool using `go version -m` command.
749
+ /**
750
+ * Reads the go version and module version of the given go tool using
751
+ * `go version -m` command.
752
+ */
734
753
export const inspectGoToolVersion = defaultInspectGoToolVersion ;
735
754
async function defaultInspectGoToolVersion (
736
755
binPath : string
@@ -803,6 +822,10 @@ export async function shouldUpdateTool(tool: Tool, toolPath: string): Promise<bo
803
822
// tool.latestVersion is released when checkForUpdates === 'proxy'
804
823
}
805
824
825
+ /**
826
+ * Updates outdated Go tools, prompting for approval if user setting
827
+ * `go.toolsManagement.autoUpdate` is unset or disabled.
828
+ */
806
829
export async function suggestUpdates ( ) {
807
830
const configuredGoVersion = await getGoVersionForInstall ( ) ;
808
831
if ( ! configuredGoVersion || configuredGoVersion . lt ( MINIMUM_GO_VERSION ) ) {
@@ -895,9 +918,11 @@ export async function listOutdatedTools(configuredGoVersion: GoVersion | undefin
895
918
return oldTools . filter ( ( tool ) : tool is Tool => ! ! tool ) ;
896
919
}
897
920
898
- // maybeInstallVSCGO is a special program released and installed with the Go extension.
899
- // Unlike other tools, it is installed under the extension path (which is cleared
900
- // when a new version is installed).
921
+ /**
922
+ * VSCGO is a special program released and installed with the Go extension.
923
+ * Unlike other tools, it is installed under the extension path
924
+ * (which is cleared when a new version is installed).
925
+ */
901
926
export async function maybeInstallVSCGO (
902
927
extensionMode : vscode . ExtensionMode ,
903
928
extensionId : string ,
0 commit comments