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

Commit8997a98

Browse files
committed
Move files around
1 parent70ff6b8 commit8997a98

17 files changed

+196
-35
lines changed
File renamed without changes.

‎src/api/utils.ts‎

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

5-
import{getProxyForUrl}from"../proxy";
5+
import{getProxyForUrl}from"./proxy";
66
import{expandPath}from"../util";
77

88
/**

‎src/cliUtils.test.ts‎

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
importfsfrom"fs/promises";
2+
importosfrom"os";
3+
importpathfrom"path";
4+
import{beforeAll,describe,expect,it}from"vitest";
5+
import*asclifrom"./core/cliUtils";
6+
7+
describe("cliUtils",()=>{
8+
consttmp=path.join(os.tmpdir(),"vscode-coder-tests");
9+
10+
beforeAll(async()=>{
11+
// Clean up from previous tests, if any.
12+
awaitfs.rm(tmp,{recursive:true,force:true});
13+
awaitfs.mkdir(tmp,{recursive:true});
14+
});
15+
16+
it("name",()=>{
17+
expect(cli.name().startsWith("coder-")).toBeTruthy();
18+
});
19+
20+
it("stat",async()=>{
21+
constbinPath=path.join(tmp,"stat");
22+
expect(awaitcli.stat(binPath)).toBeUndefined();
23+
24+
awaitfs.writeFile(binPath,"test");
25+
expect((awaitcli.stat(binPath))?.size).toBe(4);
26+
});
27+
28+
// TODO: CI only runs on Linux but we should run it on Windows too.
29+
it("version",async()=>{
30+
constbinPath=path.join(tmp,"version");
31+
awaitexpect(cli.version(binPath)).rejects.toThrow("ENOENT");
32+
33+
constbinTmpl=awaitfs.readFile(
34+
path.join(__dirname,"../fixtures/bin.bash"),
35+
"utf8",
36+
);
37+
awaitfs.writeFile(binPath,binTmpl.replace("$ECHO","hello"));
38+
awaitexpect(cli.version(binPath)).rejects.toThrow("EACCES");
39+
40+
awaitfs.chmod(binPath,"755");
41+
awaitexpect(cli.version(binPath)).rejects.toThrow("Unexpected token");
42+
43+
awaitfs.writeFile(binPath,binTmpl.replace("$ECHO","{}"));
44+
awaitexpect(cli.version(binPath)).rejects.toThrow(
45+
"No version found in output",
46+
);
47+
48+
awaitfs.writeFile(
49+
binPath,
50+
binTmpl.replace(
51+
"$ECHO",
52+
JSON.stringify({
53+
version:"v0.0.0",
54+
}),
55+
),
56+
);
57+
expect(awaitcli.version(binPath)).toBe("v0.0.0");
58+
59+
constoldTmpl=awaitfs.readFile(
60+
path.join(__dirname,"../fixtures/bin.old.bash"),
61+
"utf8",
62+
);
63+
constold=(stderr:string,stdout:string):string=>{
64+
returnoldTmpl.replace("$STDERR",stderr).replace("$STDOUT",stdout);
65+
};
66+
67+
// Should fall back only if it says "unknown flag".
68+
awaitfs.writeFile(binPath,old("foobar","Coder v1.1.1"));
69+
awaitexpect(cli.version(binPath)).rejects.toThrow("foobar");
70+
71+
awaitfs.writeFile(binPath,old("unknown flag: --output","Coder v1.1.1"));
72+
expect(awaitcli.version(binPath)).toBe("v1.1.1");
73+
74+
// Should trim off the newline if necessary.
75+
awaitfs.writeFile(
76+
binPath,
77+
old("unknown flag: --output\n","Coder v1.1.1\n"),
78+
);
79+
expect(awaitcli.version(binPath)).toBe("v1.1.1");
80+
81+
// Error with original error if it does not begin with "Coder".
82+
awaitfs.writeFile(binPath,old("unknown flag: --output","Unrelated"));
83+
awaitexpect(cli.version(binPath)).rejects.toThrow("unknown flag");
84+
85+
// Error if no version.
86+
awaitfs.writeFile(binPath,old("unknown flag: --output","Coder"));
87+
awaitexpect(cli.version(binPath)).rejects.toThrow("No version found");
88+
});
89+
90+
it("rmOld",async()=>{
91+
constbinDir=path.join(tmp,"bins");
92+
expect(awaitcli.rmOld(path.join(binDir,"bin1"))).toStrictEqual([]);
93+
94+
awaitfs.mkdir(binDir,{recursive:true});
95+
awaitfs.writeFile(path.join(binDir,"bin.old-1"),"echo hello");
96+
awaitfs.writeFile(path.join(binDir,"bin.old-2"),"echo hello");
97+
awaitfs.writeFile(path.join(binDir,"bin.temp-1"),"echo hello");
98+
awaitfs.writeFile(path.join(binDir,"bin.temp-2"),"echo hello");
99+
awaitfs.writeFile(path.join(binDir,"bin1"),"echo hello");
100+
awaitfs.writeFile(path.join(binDir,"bin2"),"echo hello");
101+
awaitfs.writeFile(path.join(binDir,"bin.asc"),"echo hello");
102+
awaitfs.writeFile(path.join(binDir,"bin.old-1.asc"),"echo hello");
103+
awaitfs.writeFile(path.join(binDir,"bin.temp-2.asc"),"echo hello");
104+
105+
expect(awaitcli.rmOld(path.join(binDir,"bin1"))).toStrictEqual([
106+
{
107+
fileName:"bin.asc",
108+
error:undefined,
109+
},
110+
{
111+
fileName:"bin.old-1",
112+
error:undefined,
113+
},
114+
{
115+
fileName:"bin.old-1.asc",
116+
error:undefined,
117+
},
118+
{
119+
fileName:"bin.old-2",
120+
error:undefined,
121+
},
122+
{
123+
fileName:"bin.temp-1",
124+
error:undefined,
125+
},
126+
{
127+
fileName:"bin.temp-2",
128+
error:undefined,
129+
},
130+
{
131+
fileName:"bin.temp-2.asc",
132+
error:undefined,
133+
},
134+
]);
135+
136+
expect(awaitfs.readdir(path.join(tmp,"bins"))).toStrictEqual([
137+
"bin1",
138+
"bin2",
139+
]);
140+
});
141+
142+
it("ETag",async()=>{
143+
constbinPath=path.join(tmp,"hash");
144+
145+
awaitfs.writeFile(binPath,"foobar");
146+
expect(awaitcli.eTag(binPath)).toBe(
147+
"8843d7f92416211de9ebb963ff4ce28125932878",
148+
);
149+
150+
awaitfs.writeFile(binPath,"test");
151+
expect(awaitcli.eTag(binPath)).toBe(
152+
"a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
153+
);
154+
});
155+
});

‎src/commands.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
AgentTreeItem,
2323
typeOpenableTreeItem,
2424
WorkspaceTreeItem,
25-
}from"./workspacesProvider";
25+
}from"./workspace/workspacesProvider";
2626

2727
exportclassCommands{
2828
// These will only be populated when actively connected to a workspace and are

‎src/core/cliManager.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as semver from "semver";
1212
import*asvscodefrom"vscode";
1313

1414
import{errToStr}from"../api/api-helper";
15-
import*asclifrom"../cliUtils";
15+
import*asclifrom"./cliUtils";
1616
import{typeLogger}from"../logging/logger";
1717
import*aspgpfrom"../pgp";
1818
import{typePathResolver}from"./pathResolver";
File renamed without changes.

‎src/core/container.ts‎

Whitespace-only changes.

‎src/extension.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ import { MementoManager } from "./core/mementoManager";
1313
import{PathResolver}from"./core/pathResolver";
1414
import{SecretsManager}from"./core/secretsManager";
1515
import{CertificateError,getErrorDetail}from"./error";
16-
import{Remote}from"./remote";
16+
import{Remote}from"./remote/remote";
1717
import{toSafeHost}from"./util";
18-
import{WorkspaceProvider,WorkspaceQuery}from"./workspacesProvider";
18+
import{
19+
WorkspaceProvider,
20+
WorkspaceQuery,
21+
}from"./workspace/workspacesProvider";
1922

2023
exportasyncfunctionactivate(ctx:vscode.ExtensionContext):Promise<void>{
2124
// The Remote SSH extension's proposed APIs are used to override the SSH host

‎src/remote.ts‎renamed to ‎src/remote/remote.ts‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,32 @@ import {
1818
getEventValue,
1919
formatEventLabel,
2020
formatMetadataError,
21-
}from"./agentMetadataHelper";
22-
import{createWorkspaceIdentifier,extractAgents}from"./api/api-helper";
23-
import{CoderApi}from"./api/coderApi";
24-
import{needToken}from"./api/utils";
25-
import{startWorkspaceIfStoppedOrFailed,waitForBuild}from"./api/workspace";
26-
import*ascliUtilsfrom"./cliUtils";
27-
import{typeCommands}from"./commands";
28-
import{typeCliManager}from"./core/cliManager";
29-
import{typePathResolver}from"./core/pathResolver";
30-
import{featureSetForVersion,typeFeatureSet}from"./featureSet";
31-
import{getGlobalFlags}from"./globalFlags";
32-
import{Inbox}from"./inbox";
33-
import{typeLogger}from"./logging/logger";
34-
import{SSHConfig,typeSSHValues,mergeSSHConfigValues}from"./sshConfig";
21+
}from"../agentMetadataHelper";
3522
import{computeSSHProperties,sshSupportsSetEnv}from"./sshSupport";
23+
import{createWorkspaceIdentifier,extractAgents}from"../api/api-helper";
24+
import{CoderApi}from"../api/coderApi";
25+
import{needToken}from"../api/utils";
26+
import{
27+
startWorkspaceIfStoppedOrFailed,
28+
waitForBuild,
29+
}from"../api/workspace";
30+
import*ascliUtilsfrom"../core/cliUtils";
31+
import{typeCommands}from"../commands";
32+
import{typeCliManager}from"../core/cliManager";
33+
import{typePathResolver}from"../core/pathResolver";
34+
import{featureSetForVersion,typeFeatureSet}from"../featureSet";
35+
import{getGlobalFlags}from"../globalFlags";
36+
import{Inbox}from"../inbox";
37+
import{SSHConfig,typeSSHValues,mergeSSHConfigValues}from"./sshConfig";
38+
import{typeLogger}from"../logging/logger";
3639
import{
3740
AuthorityPrefix,
3841
escapeCommandArg,
3942
expandPath,
4043
findPort,
4144
parseRemoteAuthority,
42-
}from"./util";
43-
import{WorkspaceMonitor}from"./workspaceMonitor";
45+
}from"../util";
46+
import{WorkspaceMonitor}from"../workspace/workspaceMonitor";
4447

4548
exportinterfaceRemoteDetailsextendsvscode.Disposable{
4649
url:string;

‎src/sshConfig.ts‎renamed to ‎src/remote/sshConfig.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{mkdir,readFile,rename,stat,writeFile}from"fs/promises";
22
importpathfrom"path";
33

4-
import{countSubstring}from"./util";
4+
import{countSubstring}from"../util";
55

66
classSSHConfigBadFormatextendsError{}
77

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp