From 1d8bcf62cc38aa66cb73bfc2fc1c9f8452350804 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Jul 2023 21:04:33 +0000 Subject: [PATCH 1/5] Use correct `tsconfig.json` when generating npm package --- pythonExtensionApi/package-lock.json | 22 ++++++++++++++++++++++ pythonExtensionApi/package.json | 5 ++++- pythonExtensionApi/tsconfig.json | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pythonExtensionApi/package-lock.json b/pythonExtensionApi/package-lock.json index 9c7c4046870e..9590a9c565f1 100644 --- a/pythonExtensionApi/package-lock.json +++ b/pythonExtensionApi/package-lock.json @@ -11,6 +11,9 @@ "dependencies": { "@types/vscode": "^1.78.0" }, + "devDependencies": { + "typescript": "5.0.4" + }, "engines": { "node": ">=16.17.1", "vscode": "^1.78.0" @@ -20,6 +23,19 @@ "version": "1.80.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.80.0.tgz", "integrity": "sha512-qK/CmOdS2o7ry3k6YqU4zD3R2AYlJfbwBoSbKpBoP+GpXNE+0NEgJOli4n0bm0diK5kfBnchgCEj4igQz/44Hg==" + }, + "node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } } }, "dependencies": { @@ -27,6 +43,12 @@ "version": "1.80.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.80.0.tgz", "integrity": "sha512-qK/CmOdS2o7ry3k6YqU4zD3R2AYlJfbwBoSbKpBoP+GpXNE+0NEgJOli4n0bm0diK5kfBnchgCEj4igQz/44Hg==" + }, + "typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true } } } diff --git a/pythonExtensionApi/package.json b/pythonExtensionApi/package.json index 43b4c19877c3..6b26257c6a8d 100644 --- a/pythonExtensionApi/package.json +++ b/pythonExtensionApi/package.json @@ -28,10 +28,13 @@ "dependencies": { "@types/vscode": "^1.78.0" }, + "devDependencies": { + "typescript": "5.0.4" + }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/fail", "prepack": "npm run all:publish", - "compile": "node ../node_modules/typescript/lib/tsc.js -b ./tsconfig.json", + "compile": "node ./node_modules/typescript/lib/tsc.js -b ./tsconfig.json", "clean": "node ../node_modules/rimraf/bin.js out", "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", "all": "npm run clean && npm run compile", diff --git a/pythonExtensionApi/tsconfig.json b/pythonExtensionApi/tsconfig.json index d90209b3a4b6..9ab7617023df 100644 --- a/pythonExtensionApi/tsconfig.json +++ b/pythonExtensionApi/tsconfig.json @@ -25,7 +25,7 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "resolveJsonModule": true, - "removeComments": true + "declaration": true }, "exclude": [ "node_modules", From 48394fb1585fb8ef5868df595f754ab1a4ea5a19 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Jul 2023 21:11:47 +0000 Subject: [PATCH 2/5] Add comment --- pythonExtensionApi/src/main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pythonExtensionApi/src/main.ts b/pythonExtensionApi/src/main.ts index b9266a732826..52bfd07da078 100644 --- a/pythonExtensionApi/src/main.ts +++ b/pythonExtensionApi/src/main.ts @@ -392,6 +392,9 @@ export const PVSC_EXTENSION_ID = 'ms-python.python'; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace PythonExtension { + /** + * Returns the API exposed by the Python extension in VS Code. + */ export async function api(): Promise { const extension = extensions.getExtension(PVSC_EXTENSION_ID); if (extension === undefined) { From afc973fc7d1024d15330ce580b71f288dd9ab646 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Jul 2023 21:44:45 +0000 Subject: [PATCH 3/5] Update version --- pythonExtensionApi/README.md | 2 ++ pythonExtensionApi/package-lock.json | 4 ++-- pythonExtensionApi/package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pythonExtensionApi/README.md b/pythonExtensionApi/README.md index 3f313721d17c..1587635aae40 100644 --- a/pythonExtensionApi/README.md +++ b/pythonExtensionApi/README.md @@ -28,6 +28,8 @@ The actual source code to get the active environment to run some script could lo // Import the API import { PythonExtension } from '@vscode/python-extension'; +... + // Load the Python extension API const pythonApi: PythonExtension = await PythonExtension.api(); diff --git a/pythonExtensionApi/package-lock.json b/pythonExtensionApi/package-lock.json index 9590a9c565f1..a8abd6d85bfc 100644 --- a/pythonExtensionApi/package-lock.json +++ b/pythonExtensionApi/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vscode/python-extension", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@vscode/python-extension", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "@types/vscode": "^1.78.0" diff --git a/pythonExtensionApi/package.json b/pythonExtensionApi/package.json index 6b26257c6a8d..717aa95b68cd 100644 --- a/pythonExtensionApi/package.json +++ b/pythonExtensionApi/package.json @@ -1,7 +1,7 @@ { "name": "@vscode/python-extension", "description": "An API facade for the Python extension in VS Code", - "version": "1.0.0", + "version": "1.0.1", "author": { "name": "Microsoft Corporation" }, From 4509cac0bad0a670e8bbbeb4ca94c3168b3e5d76 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Jul 2023 22:50:52 +0000 Subject: [PATCH 4/5] Nicely format declaration files --- pythonExtensionApi/.eslintrc | 8 ++++++++ pythonExtensionApi/package.json | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 pythonExtensionApi/.eslintrc diff --git a/pythonExtensionApi/.eslintrc b/pythonExtensionApi/.eslintrc new file mode 100644 index 000000000000..cbf1a6350029 --- /dev/null +++ b/pythonExtensionApi/.eslintrc @@ -0,0 +1,8 @@ +{ + "rules": { + "padding-line-between-statements": [ + "error", + { "blankLine": "always", "prev": "export", "next": "*" } + ] + } +} diff --git a/pythonExtensionApi/package.json b/pythonExtensionApi/package.json index 717aa95b68cd..aaeaaf54a0c4 100644 --- a/pythonExtensionApi/package.json +++ b/pythonExtensionApi/package.json @@ -38,6 +38,7 @@ "clean": "node ../node_modules/rimraf/bin.js out", "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", "all": "npm run clean && npm run compile", - "all:publish": "git clean -xfd . && npm install && npm run compile" + "formatTypings": "node ../node_modules/eslint/bin/eslint.js --fix ./out/main.d.ts", + "all:publish": "git clean -xfd . && npm install && npm run compile && npm run formatTypings" } } From 6179069ff28ad3132f8507247b1c08366e33ce15 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Jul 2023 22:56:11 +0000 Subject: [PATCH 5/5] Fix main.ts --- pythonExtensionApi/src/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pythonExtensionApi/src/main.ts b/pythonExtensionApi/src/main.ts index 52bfd07da078..b980a06b72f8 100644 --- a/pythonExtensionApi/src/main.ts +++ b/pythonExtensionApi/src/main.ts @@ -316,6 +316,7 @@ export type EnvironmentPath = { * was contributed. */ export type EnvironmentTools = KnownEnvironmentTools | string; + /** * Tools or plugins the Python extension currently has built-in support for. Note this list is expected to shrink * once tools have their own separate extensions. @@ -334,6 +335,7 @@ export type KnownEnvironmentTools = * Type of the environment. It can be {@link KnownEnvironmentTypes} or custom string which was contributed. */ export type EnvironmentType = KnownEnvironmentTypes | string; + /** * Environment types the Python extension is aware of. Note this list is expected to shrink once tools have their * own separate extensions, in which case they're expected to provide the type themselves.