Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 20 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,35 @@ on:
branches: [master]

jobs:
linux:
name: Linux
runs-on: ubuntu-latest
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 14
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

- name: Install Node.js modules
run: npm install

- name: Lint
run: npm run lint

- name: VSCE Packge
run: npx vsce package

windows:
name: Windows
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
cache: npm

- name: Install Node.js modules
run: npm install
run: npm ci

- name: Compile
run: npm run compile

- name: Lint
run: npm run lint

- name: VSCE Packge
run: npx vsce package
- name: Unit tests
run: npm run test:unit

- name: Package VSIX
run: npx @vscode/vsce package
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ out

# Mac
.DS_Store

# Diagnostic tooling artifacts
.playwright-mcp/
28 changes: 28 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from "@vscode/test-cli";
import * as os from "os";
import * as path from "path";
import * as fs from "fs";

/**
* The extension wipes `~/.lc` (the leetcode-cli session directory) the first
* time it activates in a profile. Integration tests always run in a fresh
* profile, so without redirecting HOME they would destroy the developer's real
* LeetCode session. Every test run gets a throwaway home instead.
*/
const sandboxHome = path.join(os.tmpdir(), "vscode-leetcode-test-home");
fs.mkdirSync(sandboxHome, { recursive: true });

export default defineConfig({
files: "out/test/integration/*.test.js",
version: "stable",
mocha: {
ui: "tdd",
timeout: 120000,
},
launchArgs: ["--disable-extensions"],
env: {
HOME: sandboxHome,
USERPROFILE: sandboxHome,
VSCODE_LEETCODE_TEST_HOME: sandboxHome,
},
});
38 changes: 13 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,26 @@

- English Document | [中文文档](https://github.com/LeetCode-OpenSource/vscode-leetcode/blob/master/docs/README_zh-CN.md)

## ❗️ Attention ❗️- Workaround to login to LeetCode endpoint
## ❗️ This build targets leetcode.cn only

> Note: If you are using `leetcode.cn`, you can just ignore this section.
This fork supports the **leetcode.cn** endpoint exclusively. The `leetcode.com`
endpoint and the endpoint switcher have been removed, along with the
`leetcode.endpoint` setting.

Recently we observed that [the extension cannot login to leetcode.com endpoint anymore](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478). The root cause of this issue is that leetcode.com changed its login mechanism and so far there is no ideal way to fix that issue.
Sign in with either method offered by **LeetCode: Sign in**:

Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround which can somehow mitigate this. Now you can simply click the `Sign In` button and then select `Third Party` login or `Cookie` login.
- **Web Authorization** (recommended) opens `leetcode.cn` in your browser and
hands the session back to VS Code automatically.
- **LeetCode Cookie** lets you paste a cookie copied from your browser. It must
contain both `LEETCODE_SESSION` and `csrftoken`.

> Note: If you want to use third-party login(**Recommended**), please make sure your account has been connected to the third-party. If you want to use `Cookie` login, click [here](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478#issuecomment-564757098) to see the steps.
If the cookie is invalid or expired you now get a clear error straight away.
Previously sign-in hung indefinitely with no message at all.

## Requirements

- [VS Code 1.30.1+](https://code.visualstudio.com/)
- [Node.js 10+](https://nodejs.org)
- [VS Code 1.57.0+](https://code.visualstudio.com/)
- [Node.js 18+](https://nodejs.org)
> NOTE: Please make sure that `Node` is in your `PATH` environment variable. You can also use the setting `leetcode.nodePath` to specify the location of your `Node.js` executable.

## Quick Start
Expand All @@ -58,23 +64,6 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh

---

### Switch Endpoint

<p align="center">
<img src="https://raw.githubusercontent.com/LeetCode-OpenSource/vscode-leetcode/master/docs/imgs/endpoint.png" alt="Switch Endpoint" />
</p>

- By clicking the button ![btn_endpoint](https://raw.githubusercontent.com/LeetCode-OpenSource/vscode-leetcode/master/docs/imgs/btn_endpoint.png) at the **explorer's navigation bar**, you can switch between different endpoints.

- The supported endpoints are:

- **leetcode.com**
- **leetcode.cn**

> Note: The accounts of different endpoints are **not** shared. Please make sure you are using the right endpoint. The extension will use `leetcode.com` by default.

---

### Pick a Problem

<p align="center">
Expand Down Expand Up @@ -135,7 +124,6 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`,`rust`, `scala`, `swift`, `typescript` | `N/A` |
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.workspaceFolder` | Specify the path of the workspace folder to store the problem files. | `""` |
| `leetcode.filePath` | Specify the relative path under the workspace and the file name to save the problem files. More details can be found [here](https://github.com/LeetCode-OpenSource/vscode-leetcode/wiki/Customize-the-Relative-Folder-and-the-File-Name-of-the-Problem-File). | |
| `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` |
Expand Down
Loading