Skip to content

Commit 5f34aa7

Browse files
Nikola HristovNikola Hristov
authored andcommitted
2 parents 7cec85f + 4d27e65 commit 5f34aa7

File tree

10 files changed

+11322
-589
lines changed

10 files changed

+11322
-589
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 'Build VSIX'
2+
description: "Build the extension's VSIX"
3+
4+
inputs:
5+
node_version:
6+
description: 'Version of Node to install'
7+
required: true
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Install Node
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: ${{ inputs.node_version }}
16+
cache: 'npm'
17+
18+
# Minimum supported version is Python 3.8
19+
- name: Use Python 3.8
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.8
23+
24+
- name: Pip cache
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-build-vsix-${{ hashFiles('**/requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-build-vsix-
31+
32+
# For faster/better builds of sdists.
33+
- name: Update pip, install pipx and install wheel
34+
run: python -m pip install -U pip pipx wheel
35+
shell: bash
36+
37+
- name: Run npm ci
38+
run: npm ci --prefer-offline
39+
shell: bash
40+
41+
- name: Install bundled python libraries
42+
run: pipx run nox --session install_bundled_libs
43+
shell: bash
44+
45+
# Use the GITHUB_RUN_ID environment variable to update the build number.
46+
# GITHUB_RUN_ID is a unique number for each run within a repository.
47+
# This number does not change if you re-run the workflow run.
48+
- name: Update extension build number
49+
run: pipx run nox --session update_build_number -- $GITHUB_RUN_ID
50+
shell: bash
51+
52+
- name: Build VSIX
53+
run: npm run vsce-package
54+
shell: bash
55+
56+
- name: Upload VSIX
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: linter-package
60+
path: |
61+
**/*.vsix
62+
if-no-files-found: error
63+
retention-days: 7

Source/extension/noConfigDebugInit.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
import * as fs from 'fs';
55
import * as path from 'path';
66
import * as crypto from 'crypto';
7-
import * as os from 'os';
8-
import { DebugSessionOptions, Disposable, GlobalEnvironmentVariableCollection, l10n, RelativePattern } from 'vscode';
7+
import {
8+
DebugSessionOptions,
9+
Disposable,
10+
GlobalEnvironmentVariableCollection,
11+
l10n,
12+
RelativePattern,
13+
workspace,
14+
} from 'vscode';
915
import { createFileSystemWatcher, debugStartDebugging } from './utils';
10-
import { traceError, traceLog, traceVerbose } from './common/log/logging';
16+
import { traceError, traceVerbose } from './common/log/logging';
1117

1218
/**
1319
* Registers the configuration-less debugging setup for the extension.
@@ -30,21 +36,33 @@ export async function registerNoConfigDebug(
3036
const collection = envVarCollection;
3137

3238
// create a temp directory for the noConfigDebugAdapterEndpoints
33-
// file path format: tempDir/noConfigDebugAdapterEndpoints-<randomString>/debuggerAdapterEndpoint.txt
34-
const randomSuffix = crypto.randomBytes(10).toString('hex');
35-
const tempDirName = `noConfigDebugAdapterEndpoints-${randomSuffix}`;
36-
let tempDirPath = path.join(os.tmpdir(), tempDirName);
37-
try {
38-
traceLog('Attempting to use temp directory for noConfigDebugAdapterEndpoints, dir name:', tempDirName);
39-
await fs.promises.mkdir(tempDirPath, { recursive: true });
40-
} catch (error) {
41-
// Handle the error when accessing the temp directory
42-
traceError('Error accessing temp directory:', error, ' Attempt to use extension root dir instead');
43-
// Make new temp directory in extension root dird
44-
tempDirPath = path.join(extPath, '.temp');
45-
await fs.promises.mkdir(tempDirPath, { recursive: true });
39+
// file path format: extPath/.noConfigDebugAdapterEndpoints/endpoint-stableWorkspaceHash.txt
40+
let workspaceString = workspace.workspaceFile?.fsPath;
41+
if (!workspaceString) {
42+
workspaceString = workspace.workspaceFolders?.map((e) => e.uri.fsPath).join(';');
43+
}
44+
if (!workspaceString) {
45+
traceError('No workspace folder found');
46+
return Promise.resolve(new Disposable(() => {}));
47+
}
48+
49+
// create a stable hash for the workspace folder, reduce terminal variable churn
50+
const hash = crypto.createHash('sha256');
51+
hash.update(workspaceString.toString());
52+
const stableWorkspaceHash = hash.digest('hex').slice(0, 16);
53+
54+
const tempDirPath = path.join(extPath, '.noConfigDebugAdapterEndpoints');
55+
const tempFilePath = path.join(tempDirPath, `endpoint-${stableWorkspaceHash}.txt`);
56+
57+
// create the temp directory if it doesn't exist
58+
if (!fs.existsSync(tempDirPath)) {
59+
fs.mkdirSync(tempDirPath, { recursive: true });
60+
} else {
61+
// remove endpoint file in the temp directory if it exists
62+
if (fs.existsSync(tempFilePath)) {
63+
fs.unlinkSync(tempFilePath);
64+
}
4665
}
47-
const tempFilePath = path.join(tempDirPath, 'debuggerAdapterEndpoint.txt');
4866

4967
// Add env var for PYDEVD_DISABLE_FILE_VALIDATION to disable extra output in terminal when starting the debug session.
5068
collection.replace('PYDEVD_DISABLE_FILE_VALIDATION', '1');
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PowerShell script
2-
if ($PSVersionTable.OS -match "Windows") {
2+
$os = [System.Environment]::OSVersion.Platform
3+
if ($os -eq [System.PlatformID]::Win32NT) {
34
python $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client $args
45
} else {
56
python3 $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client $args
6-
}
7+
}

0 commit comments

Comments
 (0)