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

Add package scripts and cli library, enable integration testing#536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jaggederest wants to merge13 commits intomain
base:main
Choose a base branch
Loading
fromjaggederest/integration_tests
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
7e1bce9
pretest working
jaggederestJun 16, 2025
c693a46
enable vscode-test and bump tsconfig to modern settings
jaggederestJun 16, 2025
240b649
Merge branch 'main' into jaggederest/integration_tests
jaggederestJun 16, 2025
0e58a31
test: fix integration tests to run without Remote SSH extension
jaggederestJun 16, 2025
872b7e8
Merge remote-tracking branch 'origin/jaggederest/integration_tests' i…
jaggederestJun 16, 2025
01c2d80
autocorrect formatting
jaggederestJun 16, 2025
8ddbf26
bump node version to 22
jaggederestJun 16, 2025
9b74df4
fix: configure Vitest to properly exclude VS Code integration tests
jaggederestJun 16, 2025
adec211
whitespace
jaggederestJun 16, 2025
d9b543a
fix: update tsconfig.json and convert pretty-bytes imports to standar…
jaggederestJun 17, 2025
a7afdd6
Remove testmode flag in favor of checking existence of remote ssh ext…
jaggederestJun 17, 2025
3097d8f
remove superfluous async, enable lint rule
jaggederestJun 18, 2025
a2d2bc8
fix: resolve ESLint @typescript-eslint/require-await errors
jaggederestJun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.eslintignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
vitest.config.ts
12 changes: 9 additions & 3 deletions.eslintrc.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,8 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
Expand All@@ -17,7 +18,10 @@
"overrides": [
{
"files": ["*.md"],
"parser": "markdown-eslint-parser"
"parser": "markdown-eslint-parser",
"rules": {
"@typescript-eslint/require-await": "off"
}
}
],
"rules": {
Expand DownExpand Up@@ -54,7 +58,9 @@
"sublings_only": true
}
}
]
],
"require-await": "off",
"@typescript-eslint/require-await": "error"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
4 changes: 2 additions & 2 deletions.github/workflows/ci.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ jobs:

-uses:actions/setup-node@v4
with:
node-version:"18"
node-version:"22"

-run:yarn

Expand All@@ -36,7 +36,7 @@ jobs:

-uses:actions/setup-node@v4
with:
node-version:"18"
node-version:"22"

-run:yarn

Expand Down
2 changes: 1 addition & 1 deletion.github/workflows/release.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: "18"
node-version: "22"

- run: yarn

Expand Down
12 changes: 12 additions & 0 deletions.vscode-test.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: "out/test/**/*.test.js",
extensionDevelopmentPath: ".",
extensionTestsPath: "./out/test",
launchArgs: ["--enable-proposed-api", "coder.coder-remote"],
mocha: {
ui: "tdd",
timeout: 20000,
},
});
2 changes: 1 addition & 1 deletion.vscodeignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,4 +12,4 @@ node_modules/**
**/.editorconfig
**/*.map
**/*.ts
*.gif
*.gif
1 change: 1 addition & 0 deletionsCLAUDE.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@
- Run all tests: `yarn test`
- Run specific test: `vitest ./src/filename.test.ts`
- CI test mode: `yarn test:ci`
- Integration tests: `yarn test:integration`

## Code Style Guidelines

Expand Down
12 changes: 8 additions & 4 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -278,8 +278,11 @@
"package:prerelease": "npx vsce package --pre-release",
"lint": "eslint . --ext ts,md",
"lint:fix": "yarn lint --fix",
"test": "vitest ./src",
"test:ci": "CI=true yarn test"
"test": "vitest",
"test:ci": "CI=true yarn test",
"test:integration": "vscode-test",
"pretest": "yarn run compile-tests && yarn run build && yarn run lint",
"compile-tests": "tsc -p . --outDir out"
},
"devDependencies": {
"@types/eventsource": "^3.0.0",
Expand DownExpand Up@@ -311,7 +314,8 @@
"vitest": "^0.34.6",
"vscode-test": "^1.5.0",
"webpack": "^5.99.6",
"webpack-cli": "^5.1.4"
"webpack-cli": "^5.1.4",
"@vscode/test-cli": "^0.0.10"
},
"dependencies": {
"axios": "1.8.4",
Expand All@@ -326,7 +330,7 @@
"semver": "^7.7.1",
"ua-parser-js": "1.0.40",
"ws": "^8.18.2",
"zod": "^3.25.1"
"zod": "^3.25.65"
},
"resolutions": {
"semver": "7.7.1",
Expand Down
4 changes: 2 additions & 2 deletionssrc/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,11 +71,11 @@ export async function createHttpAgent(): Promise<ProxyAgent> {
* configuration. The token may be undefined if some other form of
* authentication is being used.
*/
exportasyncfunction makeCoderSdk(
export function makeCoderSdk(
baseUrl: string,
token: string | undefined,
storage: Storage,
):Promise<Api> {
): Api {
const restClient = new Api();
restClient.setHost(baseUrl);
if (token) {
Expand Down
2 changes: 1 addition & 1 deletionsrc/error.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,7 +126,7 @@ export class CertificateError extends Error {
}

// allowInsecure updates the value of the "coder.insecure" property.
asyncallowInsecure():Promise<void> {
allowInsecure(): void {
vscode.workspace
.getConfiguration()
.update("coder.insecure", true, vscode.ConfigurationTarget.Global);
Expand Down
34 changes: 23 additions & 11 deletionssrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,25 +21,31 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
//
// Cursor and VSCode are covered by ms remote, and the only other is windsurf for now
// Means that vscodium is not supported by this for now

const remoteSSHExtension =
vscode.extensions.getExtension("jeanp413.open-remote-ssh") ||
vscode.extensions.getExtension("codeium.windsurf-remote-openssh") ||
vscode.extensions.getExtension("anysphere.remote-ssh") ||
vscode.extensions.getExtension("ms-vscode-remote.remote-ssh");

let vscodeProposed: typeof vscode = vscode;

if (!remoteSSHExtension) {
vscode.window.showErrorMessage(
"Remote SSH extension not found, cannot activate Coder extension",
"Remote SSH extension not found, this may not work as expected.\n" +
// NB should we link to documentation or marketplace?
"Please install your choice of Remote SSH extension from the VS Code Marketplace.",
);
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
vscodeProposed = (module as any)._load(
"vscode",
{
filename: remoteSSHExtension.extensionPath,
},
false,
);
Comment on lines +40 to 47
Copy link
Preview

CopilotAIJun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Using 'module as any' bypasses type safety; consider a more type-safe approach or adding documentation to justify this workaround.

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I get it buddy I don't like it either but we're polymorphic on the SSH extensions.

code-asher reacted with laugh emoji
throw new Error("Remote SSH extension not found");
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const vscodeProposed: typeof vscode = (module as any)._load(
"vscode",
{
filename: remoteSSHExtension?.extensionPath,
},
false,
);

const output = vscode.window.createOutputChannel("Coder");
const storage = new Storage(
Expand DownExpand Up@@ -278,7 +284,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
// in package.json we're able to perform actions before the authority is
// resolved by the remote SSH extension.
if (vscodeProposed.env.remoteAuthority) {
//
// In addition, if we don't have a remote SSH extension, we skip this
// activation event. This may allow the user to install the extension
// after the Coder extension is installed, instead of throwing a fatal error
// (this would require the user to uninstall the Coder extension and
// reinstall after installing the remote SSH extension, which is annoying)
Comment on lines +291 to +292
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🎉

if (remoteSSHExtension && vscodeProposed.env.remoteAuthority) {
const remote = new Remote(
vscodeProposed,
storage,
Expand Down
4 changes: 2 additions & 2 deletionssrc/remote.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -910,9 +910,9 @@ export class Remote {
.then((content) => {
return JSON.parse(content);
})
.then((parsed) => {
.then(async(parsed) => {
try {
updateStatus(parsed);
awaitupdateStatus(parsed);
} catch (ex) {
// Ignore
}
Expand Down
56 changes: 56 additions & 0 deletionssrc/test/extension.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
import * as assert from "assert";
import * as vscode from "vscode";

suite("Extension Test Suite", () => {
vscode.window.showInformationMessage("Start all tests.");

test("Extension should be present", () => {
assert.ok(vscode.extensions.getExtension("coder.coder-remote"));
});

test("Extension should activate", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);

if (!extension.isActive) {
await extension.activate();
}

assert.ok(extension.isActive);
});

test("Extension should export activate function", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);

await extension.activate();
// The extension doesn't export anything, which is fine
// The test was expecting exports.activate but the extension
// itself is the activate function
assert.ok(extension.isActive);
});

test("Commands should be registered", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);

if (!extension.isActive) {
await extension.activate();
}

// Give a small delay for commands to register
await new Promise((resolve) => setTimeout(resolve, 100));

const commands = await vscode.commands.getCommands(true);
const coderCommands = commands.filter((cmd) => cmd.startsWith("coder."));

assert.ok(
coderCommands.length > 0,
"Should have registered Coder commands",
);
assert.ok(
coderCommands.includes("coder.login"),
"Should have coder.login command",
);
});
});
8 changes: 4 additions & 4 deletionssrc/util.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from "vitest";
import { countSubstring, parseRemoteAuthority, toSafeHost } from "./util";

it("ignore unrelated authorities",async() => {
it("ignore unrelated authorities", () => {
const tests = [
"vscode://ssh-remote+some-unrelated-host.com",
"vscode://ssh-remote+coder-vscode",
Expand All@@ -15,7 +15,7 @@ it("ignore unrelated authorities", async () => {
}
});

it("should error on invalid authorities",async() => {
it("should error on invalid authorities", () => {
const tests = [
"vscode://ssh-remote+coder-vscode--foo",
"vscode://ssh-remote+coder-vscode--",
Expand All@@ -27,7 +27,7 @@ it("should error on invalid authorities", async () => {
}
});

it("should parse authority",async() => {
it("should parse authority", () => {
expect(
parseRemoteAuthority("vscode://ssh-remote+coder-vscode--foo--bar"),
).toStrictEqual({
Expand DownExpand Up@@ -81,7 +81,7 @@ it("should parse authority", async () => {
});
});

it("escapes url host",async() => {
it("escapes url host", () => {
expect(toSafeHost("https://foobar:8080")).toBe("foobar");
expect(toSafeHost("https://ほげ")).toBe("xn--18j4d");
expect(toSafeHost("https://test.😉.invalid")).toBe("test.xn--n28h.invalid");
Expand Down
2 changes: 1 addition & 1 deletionsrc/util.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ export const RemoteSSHLogPortRegex =
*
* Returns null if no port is found.
*/
exportasyncfunction findPort(text: string):Promise<number | null> {
export function findPort(text: string): number | null {
const matches = text.match(RemoteSSHLogPortRegex);
if (!matches) {
return null;
Expand Down
4 changes: 2 additions & 2 deletionssrc/workspacesProvider.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,7 +156,7 @@ export class WorkspaceProvider

// Create tree items for each workspace
const workspaceTreeItems = await Promise.all(
resp.workspaces.map(async(workspace) => {
resp.workspaces.map((workspace) => {
const workspaceTreeItem = new WorkspaceTreeItem(
workspace,
this.getWorkspacesQuery === WorkspaceQuery.All,
Expand DownExpand Up@@ -235,7 +235,7 @@ export class WorkspaceProvider
this._onDidChangeTreeData.fire(item);
}

asyncgetTreeItem(element: vscode.TreeItem):Promise<vscode.TreeItem> {
getTreeItem(element: vscode.TreeItem): vscode.TreeItem {
return element;
}

Expand Down
13 changes: 8 additions & 5 deletionstsconfig.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"target": "ES2022",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we know whether our minimum version of VS Code (1.73.0) supported es2022? Looks like it was Electron 19.0.17 based on Node 16.14.2 but I am not sure how to find the compatibility.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I will check on that, thank you for pointing that out.

"moduleResolution": "node",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I was reading thatnode was renamed tonode10 andnode is a deprecated alias now.

This is a change from the default, right? Supposedlynode10 is not meant to be used anymore but idk exactly what the consequences are.

jaggederest reacted with eyes emoji
"outDir": "out",
// "dom" is required for importing the API from coder/coder.
"lib": ["es6", "dom"],
"lib": ["ES2022", "dom"],
"sourceMap": true,
"rootDirs": ["node_modules", "src"],
"strict": true,
"esModuleInterop": true
"esModuleInterop": true,
"skipLibCheck": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This loosens some type checking, right? Do we need to disable it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't believe we do, I'll revert that.

"forceConsistentCasingInFileNames": true
},
"exclude": ["node_modules", ".vscode-test"]
"exclude": ["node_modules", "vitest.config.ts"],
"include": ["src/**/*"]
}
17 changes: 17 additions & 0 deletionsvitest.config.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["src/**/*.test.ts"],
exclude: [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/out/**",
"**/src/test/**",
"src/test/**",
"./src/test/**",
],
environment: "node",
},
});
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp