diff --git a/.gitignore b/.gitignore index d5e78a3..3aa17a5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,6 @@ /.husky/_/ /*.vsix -# downloaded resources -/src/vscode-python-environments/index.ts - # yarn /.pnp.* /.yarn/* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2826bd..08fb843 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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: diff --git a/biome.jsonc b/biome.jsonc index 9a99e12..62e2b69 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -30,7 +30,6 @@ "useAwaitThenable": "warn", }, }, - "includes": ["**", "!**/src/vscode-python-environments/*.ts"], }, "javascript": { "formatter": { diff --git a/package.json b/package.json index e5057a8..60afcb2 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,7 @@ }, "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\"", @@ -59,7 +57,7 @@ "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": { @@ -91,6 +89,7 @@ }, "packageManager": "yarn@4.14.1", "dependencies": { + "@vscode/python-environments": "^1.0.0", "untildify": "^6.0.0", "which": "^6.0.1" } diff --git a/rolldown.config.ts b/rolldown.config.ts index cde8d10..09ec3ee 100644 --- a/rolldown.config.ts +++ b/rolldown.config.ts @@ -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'] }), diff --git a/src/hatch-env-manager.ts b/src/hatch-env-manager.ts index cb8fe19..e46c00c 100644 --- a/src/hatch-env-manager.ts +++ b/src/hatch-env-manager.ts @@ -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, @@ -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 diff --git a/src/hatch-pkg-manager.ts b/src/hatch-pkg-manager.ts index fb7820a..7a52eff 100644 --- a/src/hatch-pkg-manager.ts +++ b/src/hatch-pkg-manager.ts @@ -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, @@ -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 diff --git a/src/python-envs-api.ts b/src/python-envs-api.ts index 1f2c17c..0edff1b 100644 --- a/src/python-envs-api.ts +++ b/src/python-envs-api.ts @@ -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 { diff --git a/src/vscode-python-environments/.gitkeep b/src/vscode-python-environments/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/test/extension.test.ts b/test/extension.test.ts index e99ae14..c256ca8 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -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' diff --git a/yarn.lock b/yarn.lock index 5656747..ab3ff4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"