Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb19660

Browse files
committed
Add service container and improve import/order
1 parent2800162 commitcb19660

17 files changed

+275
-350
lines changed

‎.eslintrc.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,16 @@
5353
"groups": [
5454
["builtin","external"],
5555
"internal",
56-
["parent","sibling","index"],
56+
"parent",
57+
["sibling","index"],
5758
"type"
5859
],
5960
"pathGroups": [
60-
{"pattern":"@/**","group":"internal","position":"after" }
61+
{"pattern":"@/**","group":"internal","position":"before" }
6162
],
62-
// Don't reclassify real externals like @babel/* into the alias group
6363
"pathGroupsExcludedImportTypes": ["builtin","external"],
6464
"newlines-between":"always",
65-
"alphabetize": {"order":"asc","caseInsensitive":true },
66-
"distinctGroup":true// separates type imports into the "type" group
65+
"alphabetize": {"order":"asc","caseInsensitive":true }
6766
}
6867
],
6968
// Prevent duplicates and prefer merging into a single import

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
"eslint-plugin-prettier":"^5.5.4",
353353
"glob":"^10.4.2",
354354
"jsonc-eslint-parser":"^2.4.0",
355+
"markdown-eslint-parser":"^1.2.1",
355356
"memfs":"^4.46.0",
356357
"nyc":"^17.1.0",
357358
"prettier":"^3.5.3",

‎src/api/coderApi.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { type ClientOptions } from "ws";
1212

1313
import{CertificateError}from"../error";
1414
import{getHeaderCommand,getHeaders}from"../headers";
15-
import{createHttpAgent}from"./utils";
1615
import{
1716
createRequestMeta,
1817
logRequest,
@@ -30,6 +29,8 @@ import {
3029
typeOneWayWebSocketInit,
3130
}from"../websocket/oneWayWebSocket";
3231

32+
import{createHttpAgent}from"./utils";
33+
3334
constcoderSessionTokenHeader="Coder-Session-Token";
3435

3536
typeWorkspaceConfigurationProvider=()=>WorkspaceConfiguration;

‎src/api/utils.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import fs from "fs";
22
import{ProxyAgent}from"proxy-agent";
33
import{typeWorkspaceConfiguration}from"vscode";
44

5-
import{getProxyForUrl}from"./proxy";
65
import{expandPath}from"../util";
76

7+
import{getProxyForUrl}from"./proxy";
8+
89
/**
910
* Return whether the API will need a token for authorization.
1011
* If mTLS is in use (as specified by the cert or key files being set) then

‎src/api/workspace.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as vscode from "vscode";
66
import{typeFeatureSet}from"../featureSet";
77
import{getGlobalFlags}from"../globalFlags";
88
import{escapeCommandArg}from"../util";
9+
910
import{errToStr,createWorkspaceIdentifier}from"./api-helper";
1011
import{typeCoderApi}from"./coderApi";
1112

‎src/cliUtils.test.ts‎

Lines changed: 0 additions & 155 deletions
This file was deleted.

‎src/commands.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { createWorkspaceIdentifier, extractAgents } from "./api/api-helper";
1111
import{CoderApi}from"./api/coderApi";
1212
import{needToken}from"./api/utils";
1313
import{typeCliManager}from"./core/cliManager";
14+
import{typeServiceContainer}from"./core/container";
1415
import{typeMementoManager}from"./core/mementoManager";
1516
import{typePathResolver}from"./core/pathResolver";
1617
import{typeSecretsManager}from"./core/secretsManager";
@@ -25,6 +26,12 @@ import {
2526
}from"./workspace/workspacesProvider";
2627

2728
exportclassCommands{
29+
privatereadonlyvscodeProposed:typeofvscode;
30+
privatereadonlylogger:Logger;
31+
privatereadonlypathResolver:PathResolver;
32+
privatereadonlymementoManager:MementoManager;
33+
privatereadonlysecretsManager:SecretsManager;
34+
privatereadonlycliManager:CliManager;
2835
// These will only be populated when actively connected to a workspace and are
2936
// used in commands. Because commands can be executed by the user, it is not
3037
// possible to pass in arguments, so we have to store the current workspace
@@ -37,14 +44,16 @@ export class Commands {
3744
publicworkspaceRestClient?:Api;
3845

3946
publicconstructor(
40-
privatereadonlyvscodeProposed:typeofvscode,
47+
serviceContainer:ServiceContainer,
4148
privatereadonlyrestClient:Api,
42-
privatereadonlylogger:Logger,
43-
privatereadonlypathResolver:PathResolver,
44-
privatereadonlymementoManager:MementoManager,
45-
privatereadonlysecretsManager:SecretsManager,
46-
privatereadonlycliManager:CliManager,
47-
){}
49+
){
50+
this.vscodeProposed=serviceContainer.getVsCodeProposed();
51+
this.logger=serviceContainer.getLogger();
52+
this.pathResolver=serviceContainer.getPathResolver();
53+
this.mementoManager=serviceContainer.getMementoManager();
54+
this.secretsManager=serviceContainer.getSecretsManager();
55+
this.cliManager=serviceContainer.getCliManager();
56+
}
4857

4958
/**
5059
* Find the requested agent if specified, otherwise return the agent if there

‎src/core/cliManager.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import * as semver from "semver";
1212
import*asvscodefrom"vscode";
1313

1414
import{errToStr}from"../api/api-helper";
15-
import*asclifrom"./cliUtils";
1615
import{typeLogger}from"../logging/logger";
1716
import*aspgpfrom"../pgp";
17+
18+
import*ascliUtilsfrom"./cliUtils";
1819
import{typePathResolver}from"./pathResolver";
1920

2021
exportclassCliManager{
@@ -58,16 +59,16 @@ export class CliManager {
5859
// downloads are disabled, we can return early.
5960
constbinPath=path.join(
6061
this.pathResolver.getBinaryCachePath(label),
61-
cli.name(),
62+
cliUtils.name(),
6263
);
6364
this.output.info("Using binary path",binPath);
64-
conststat=awaitcli.stat(binPath);
65+
conststat=awaitcliUtils.stat(binPath);
6566
if(stat===undefined){
6667
this.output.info("No existing binary found, starting download");
6768
}else{
6869
this.output.info("Existing binary size is",prettyBytes(stat.size));
6970
try{
70-
constversion=awaitcli.version(binPath);
71+
constversion=awaitcliUtils.version(binPath);
7172
this.output.info("Existing binary version is",version);
7273
// If we have the right version we can avoid the request entirely.
7374
if(version===buildInfo.version){
@@ -97,7 +98,7 @@ export class CliManager {
9798
}
9899

99100
// Remove any left-over old or temporary binaries and signatures.
100-
constremoved=awaitcli.rmOld(binPath);
101+
constremoved=awaitcliUtils.rmOld(binPath);
101102
removed.forEach(({ fileName, error})=>{
102103
if(error){
103104
this.output.warn("Failed to remove",fileName,error);
@@ -107,7 +108,7 @@ export class CliManager {
107108
});
108109

109110
// Figure out where to get the binary.
110-
constbinName=cli.name();
111+
constbinName=cliUtils.name();
111112
constconfigSource=cfg.get("binarySource");
112113
constbinSource=
113114
configSource&&String(configSource).trim().length>0
@@ -117,7 +118,7 @@ export class CliManager {
117118

118119
// Ideally we already caught that this was the right version and returned
119120
// early, but just in case set the ETag.
120-
constetag=stat!==undefined ?awaitcli.eTag(binPath) :"";
121+
constetag=stat!==undefined ?awaitcliUtils.eTag(binPath) :"";
121122
this.output.info("Using ETag",etag);
122123

123124
// Download the binary to a temporary file.
@@ -173,14 +174,14 @@ export class CliManager {
173174
awaitfs.rename(tempFile,binPath);
174175

175176
// For debugging, to see if the binary only partially downloaded.
176-
constnewStat=awaitcli.stat(binPath);
177+
constnewStat=awaitcliUtils.stat(binPath);
177178
this.output.info(
178179
"Downloaded binary size is",
179180
prettyBytes(newStat?.size||0),
180181
);
181182

182183
// Make sure we can execute this new binary.
183-
constversion=awaitcli.version(binPath);
184+
constversion=awaitcliUtils.version(binPath);
184185
this.output.info("Downloaded binary version is",version);
185186

186187
returnbinPath;
@@ -199,8 +200,8 @@ export class CliManager {
199200
if(!value){
200201
return;
201202
}
202-
constos=cli.goos();
203-
constarch=cli.goarch();
203+
constos=cliUtils.goos();
204+
constarch=cliUtils.goarch();
204205
constparams=newURLSearchParams({
205206
title:`Support the \`${os}-${arch}\` platform`,
206207
body:`I'd like to use the \`${os}-${arch}\` architecture with the VS Code extension.`,
@@ -223,7 +224,7 @@ export class CliManager {
223224
return;
224225
}
225226
constparams=newURLSearchParams({
226-
title:`Failed to download binary on \`${cli.goos()}-${cli.goarch()}\``,
227+
title:`Failed to download binary on \`${cliUtils.goos()}-${cliUtils.goarch()}\``,
227228
body:`Received status code \`${status}\` when downloading the binary.`,
228229
});
229230
consturi=vscode.Uri.parse(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp