Skip to content
Merged
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
/.husky/_/
/*.vsix

# downloaded resources
/src/vscode-python-environments/index.ts

# yarn
/.pnp.*
/.yarn/*
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

The scripts in `packagage.json` are used to manage this project.

- running `yarn install` runs the `postinstall` script, which.
1. sets up `pre-commit` scripts that run `lint`s (see below) before each `git commit`.
2. downloads `src/vscode-python-environments.ts` which isn’t published to npm yet.
- running `yarn install` runs the `postinstall` script,
which sets up `pre-commit` scripts that run `lint`s (see below) before each `git commit`.
- `watch` and `compile` can be used to compile the TypeScript sources,
but “Run Extension” in `.vscode/launch.json` also runs `watch` for you.
- `lint` runs the following:
Expand Down
1 change: 0 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"useAwaitThenable": "warn",
},
},
"includes": ["**", "!**/src/vscode-python-environments/*.ts"],
},
"javascript": {
"formatter": {
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,15 @@
},
"main": "./dist/extension.js",
"scripts": {
"postinstall": "concurrently -c auto -n husky,sync \"$npm_execpath postinstall:husky\" \"$npm_execpath sync\"",
"postinstall:husky": "husky",
"sync": "curl -sf -o src/vscode-python-environments/index.ts -L \"https://github.com/microsoft/vscode-python-environments/raw/refs/heads/main/src/api.ts\"",
"postinstall": "husky",
"build": "rolldown -c",
"watch": "rolldown -cw",
"lint": "concurrently -c auto -n types,check,deps \"$npm_execpath lint:types\" \"$npm_execpath lint:check\" \"$npm_execpath lint:deps\"",
"lint:types": "tsc --noEmit",
"lint:check": "biome check --write --error-on-warnings .",
"lint:deps": "knip --use-tsconfig-files",
"test": "$npm_execpath run build && vscode-test",
"vscode:prepublish": "$npm_execpath run sync && $npm_execpath run build",
"vscode:prepublish": "$npm_execpath run build",
"vsce-package": "vsce package --yarn --no-dependencies"
},
"lint-staged": {
Expand Down Expand Up @@ -91,6 +89,7 @@
},
"packageManager": "yarn@4.14.1",
"dependencies": {
"@vscode/python-environments": "^1.0.0",
"untildify": "^6.0.0",
"which": "^6.0.1"
}
Expand Down
3 changes: 2 additions & 1 deletion rolldown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export default defineConfig({
swc({
swc: {
jsc: {
target: 'esnext',
parser: { decorators: true, syntax: 'typescript' },
transform: { decoratorVersion: '2023-11' },
},
},
}),
// Only run this transform if the file contains a decorator.
{ transform: { code: '@' } },
{ transform: { code: /\n\s*@/ } },
),
// https://github.com/npm/node-which/issues/174
esmExternalRequirePlugin({ external: [/^node:/, 'path'] }),
Expand Down
30 changes: 15 additions & 15 deletions src/hatch-env-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import paths from 'node:path'
import {
type DidChangeEnvironmentEventArgs,
type DidChangeEnvironmentsEventArgs,
EnvironmentChangeKind,
type EnvironmentManager,
type GetEnvironmentScope,
type GetEnvironmentsScope,
type PythonCommandRunConfiguration,
type PythonEnvironment,
type PythonEnvironmentApi,
type PythonEnvironmentInfo,
type RefreshEnvironmentsScope,
type ResolveEnvironmentContext,
type SetEnvironmentScope,
} from '@vscode/python-environments'
import {
EventEmitter,
type LogOutputChannel,
Expand All @@ -19,21 +34,6 @@ import {
setGlobalEnvId,
setProjectEnvId,
} from './utils.js'
import {
type DidChangeEnvironmentEventArgs,
type DidChangeEnvironmentsEventArgs,
EnvironmentChangeKind,
type EnvironmentManager,
type GetEnvironmentScope,
type GetEnvironmentsScope,
type PythonCommandRunConfiguration,
type PythonEnvironment,
type PythonEnvironmentApi,
type PythonEnvironmentInfo,
type RefreshEnvironmentsScope,
type ResolveEnvironmentContext,
type SetEnvironmentScope,
} from './vscode-python-environments/index.js'

interface HatchEnvironment extends PythonEnvironment {
hatch: HatchEnvInfo
Expand Down
18 changes: 9 additions & 9 deletions src/hatch-pkg-manager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
type DidChangePackagesEventArgs,
type Package,
PackageChangeKind,
type PackageManagementOptions,
type PackageManager,
type PythonEnvironment,
type PythonEnvironmentApi,
} from '@vscode/python-environments'
import {
EventEmitter,
type LogOutputChannel,
Expand All @@ -9,15 +18,6 @@ import type { HatchExecutableTracker } from './cli/index.js'
import { HATCH_ID, HATCH_NAME } from './common/constants.js'
import { traceVerbose } from './common/logging.js'
import { isHatchEnv } from './hatch-env-manager.js'
import {
type DidChangePackagesEventArgs,
type Package,
PackageChangeKind,
type PackageManagementOptions,
type PackageManager,
type PythonEnvironment,
type PythonEnvironmentApi,
} from './vscode-python-environments/index.js'

export class HatchPackageManager implements PackageManager {
readonly name = HATCH_ID
Expand Down
2 changes: 1 addition & 1 deletion src/python-envs-api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// See https://github.com/microsoft/vscode-python-environments/blob/main/examples/README.md#create-your-extension

import type { PythonEnvironmentApi } from '@vscode/python-environments'
import * as vscode from 'vscode'
import { ENVS_EXT_ID } from './common/constants.js'
import type { PythonEnvironmentApi } from './vscode-python-environments/index.js'

let _extApi: PythonEnvironmentApi | undefined
export async function getEnvExtApi(): Promise<PythonEnvironmentApi> {
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as assert from 'node:assert'
import type {
EnvironmentManager,
PythonEnvironmentApi,
} from '@vscode/python-environments'
import { before, beforeEach } from 'mocha'
import * as vscode from 'vscode'
import { ENVS_EXT_ID, EXTENSION_ID } from '../src/common/constants'
import type * as extension from '../src/extension'
import type {
EnvironmentManager,
PythonEnvironmentApi,
} from '../src/vscode-python-environments'
import MockExec from './mock-exec'
import { tmpdir, waitForCondition } from './test-utils'

Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,13 @@ __metadata:
languageName: node
linkType: hard

"@vscode/python-environments@npm:^1.0.0":
version: 1.0.0
resolution: "@vscode/python-environments@npm:1.0.0"
checksum: 10/ad953e678f66f58b9522bb4e48628801b21cdc473663c58cd205b762201ed4abbb401ee92a6ae35aa14251a71c154c8808a9a0fca7bf4fa1eccd1d3a53463085
languageName: node
linkType: hard

"@vscode/test-cli@npm:^0.0.12":
version: 0.0.12
resolution: "@vscode/test-cli@npm:0.0.12"
Expand Down Expand Up @@ -2778,6 +2785,7 @@ __metadata:
"@types/node": "npm:25.x"
"@types/vscode": "npm:1.99.1"
"@types/which": "npm:^3.0.4"
"@vscode/python-environments": "npm:^1.0.0"
"@vscode/test-cli": "npm:^0.0.12"
"@vscode/test-electron": "npm:^2.5.2"
"@vscode/vsce": "npm:^3.9.1"
Expand Down