diff --git a/package-lock.json b/package-lock.json index d908b443..56dbb0de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-objectscript", - "version": "2.12.9-SNAPSHOT", + "version": "2.12.10-SNAPSHOT", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-objectscript", - "version": "2.12.9-SNAPSHOT", + "version": "2.12.10-SNAPSHOT", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -24,12 +24,13 @@ "ws": "^8.14.2" }, "devDependencies": { + "@intersystems-community/intersystems-servermanager": "^3.8.0", "@types/istextorbinary": "2.3.1", "@types/minimatch": "5.1.2", "@types/mocha": "^7.0.2", "@types/node": "20.16.5", "@types/semver": "7.5.4", - "@types/vscode": "1.91.0", + "@types/vscode": "1.93.0", "@types/ws": "8.5.4", "@types/xmldom": "^0.1.29", "@typescript-eslint/eslint-plugin": "^4.32.0", @@ -55,7 +56,7 @@ "webpack-cli": "^4.5.0" }, "engines": { - "vscode": "^1.91.0" + "vscode": "^1.93.0" } }, "node_modules/@babel/code-frame": { @@ -268,6 +269,13 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "node_modules/@intersystems-community/intersystems-servermanager": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@intersystems-community/intersystems-servermanager/-/intersystems-servermanager-3.8.0.tgz", + "integrity": "sha512-D3/LoQXOsApLo07BLHipuibUYIQLz5MK57GWLtmtYIiNa2gJ0Igaz0Fv5SuZ+gdPL3tlN1g88iQ4vJ7E+arRiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -425,10 +433,11 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.91.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.91.0.tgz", - "integrity": "sha512-PgPr+bUODjG3y+ozWUCyzttqR9EHny9sPAfJagddQjDwdtf66y2sDKJMnFZRuzBA2YtBGASqJGPil8VDUPvO6A==", - "dev": true + "version": "1.93.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.93.0.tgz", + "integrity": "sha512-kUK6jAHSR5zY8ps42xuW89NLcBpw1kOabah7yv38J8MyiYuOHxLQBi0e7zeXbQgVefDy/mZZetqEFC+Fl5eIEQ==", + "dev": true, + "license": "MIT" }, "node_modules/@types/ws": { "version": "8.5.4", @@ -1218,12 +1227,13 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2392,10 +2402,11 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -3083,6 +3094,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -3507,13 +3519,14 @@ } }, "node_modules/micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, + "license": "MIT", "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.3", + "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" @@ -4053,10 +4066,11 @@ "dev": true }, "node_modules/picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.6" }, @@ -4814,6 +4828,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -5345,9 +5360,10 @@ "dev": true }, "node_modules/ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -5606,6 +5622,12 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@intersystems-community/intersystems-servermanager": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@intersystems-community/intersystems-servermanager/-/intersystems-servermanager-3.8.0.tgz", + "integrity": "sha512-D3/LoQXOsApLo07BLHipuibUYIQLz5MK57GWLtmtYIiNa2gJ0Igaz0Fv5SuZ+gdPL3tlN1g88iQ4vJ7E+arRiQ==", + "dev": true + }, "@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -5742,9 +5764,9 @@ "dev": true }, "@types/vscode": { - "version": "1.91.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.91.0.tgz", - "integrity": "sha512-PgPr+bUODjG3y+ozWUCyzttqR9EHny9sPAfJagddQjDwdtf66y2sDKJMnFZRuzBA2YtBGASqJGPil8VDUPvO6A==", + "version": "1.93.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.93.0.tgz", + "integrity": "sha512-kUK6jAHSR5zY8ps42xuW89NLcBpw1kOabah7yv38J8MyiYuOHxLQBi0e7zeXbQgVefDy/mZZetqEFC+Fl5eIEQ==", "dev": true }, "@types/ws": { @@ -6342,12 +6364,12 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browser-stdout": { @@ -7221,9 +7243,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "requires": { "to-regex-range": "^5.0.1" @@ -8021,13 +8043,13 @@ "dev": true }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.3", + "picomatch": "^2.3.1" } }, "mime-db": { @@ -8424,9 +8446,9 @@ "dev": true }, "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, "pkg-dir": { @@ -9354,9 +9376,9 @@ "dev": true }, "ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "requires": {} }, "y18n": { diff --git a/package.json b/package.json index 0fb2e581..12e3e972 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ } ], "engines": { - "vscode": "^1.91.0" + "vscode": "^1.93.0" }, "enabledApiProposals": [ "fileSearchProvider", @@ -1815,16 +1815,17 @@ "test": "node ./out/test/runTest.js", "lint": "eslint src/**", "lint-fix": "eslint --fix src/**", - "download-api": "dts dev 1.91.0", + "download-api": "dts dev 1.93.0", "postinstall": "npm run download-api" }, "devDependencies": { + "@intersystems-community/intersystems-servermanager": "^3.8.0", "@types/istextorbinary": "2.3.1", "@types/minimatch": "5.1.2", "@types/mocha": "^7.0.2", "@types/node": "20.16.5", "@types/semver": "7.5.4", - "@types/vscode": "1.91.0", + "@types/vscode": "1.93.0", "@types/ws": "8.5.4", "@types/xmldom": "^0.1.29", "@typescript-eslint/eslint-plugin": "^4.32.0", diff --git a/src/extension.ts b/src/extension.ts index bbcf17a4..750a7c61 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,6 +4,7 @@ export const smExtensionId = "intersystems-community.servermanager"; import vscode = require("vscode"); import * as semver from "semver"; +import * as serverManager from "@intersystems-community/intersystems-servermanager"; import { AtelierJob, Content, Response, ServerInfo } from "./api/atelier"; export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript"; @@ -198,7 +199,7 @@ let reporter: TelemetryReporter = null; export let checkingConnection = false; -let serverManagerApi: any; +let serverManagerApi: serverManager.ServerManagerAPI; // Map of the intersystems.server connection specs we have resolved via the API to that extension const resolvedConnSpecs = new Map(); @@ -222,8 +223,6 @@ export async function resolveConnectionSpec(serverName: string): Promise { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export async function resolvePassword(serverSpec, ignoreUnauthenticated = false): Promise { - const AUTHENTICATION_PROVIDER = "intersystems-server-credentials"; - // This arises if setting says to use authentication provider if ( // Connection isn't unauthenticated (!isUnauthenticated(serverSpec.username) || ignoreUnauthenticated) && @@ -231,9 +230,19 @@ export async function resolvePassword(serverSpec, ignoreUnauthenticated = false) typeof serverSpec.password == "undefined" ) { const scopes = [serverSpec.name, serverSpec.username || ""]; - let session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { silent: true }); + + // Handle Server Manager extension version < 3.8.0 + const account = serverManagerApi.getAccount ? serverManagerApi.getAccount(serverSpec) : undefined; + + let session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { + silent: true, + account, + }); if (!session) { - session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { createIfNone: true }); + session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { + createIfNone: true, + account, + }); } if (session) { // If original spec lacked username use the one obtained by the authprovider @@ -1164,7 +1173,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { } const fileName = filePathNoWorkspaceArr.join("."); // Generate the new content - const newContent = generateFileContent(uri, fileName, Buffer.from(await vscode.workspace.fs.readFile(uri))); + const newContent = generateFileContent(uri, fileName, await vscode.workspace.fs.readFile(uri)); // Write the new content to the file return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n"))); }) diff --git a/src/providers/FileSystemProvider/FileSystemProvider.ts b/src/providers/FileSystemProvider/FileSystemProvider.ts index 935d4d74..44064279 100644 --- a/src/providers/FileSystemProvider/FileSystemProvider.ts +++ b/src/providers/FileSystemProvider/FileSystemProvider.ts @@ -30,7 +30,7 @@ export type Entry = File | Directory; export function generateFileContent( uri: vscode.Uri, fileName: string, - sourceContent: Buffer + sourceContent: Uint8Array ): { content: string[]; enc: boolean } { const sourceLines = sourceContent.length ? new TextDecoder().decode(sourceContent).split("\n") : []; const fileExt = fileName.split(".").pop().toLowerCase(); @@ -104,7 +104,7 @@ export function generateFileContent( } } return { - content: [sourceContent.toString("base64")], + content: [Buffer.from(sourceContent).toString("base64")], enc: true, }; } @@ -396,7 +396,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider { public writeFile( uri: vscode.Uri, - content: Buffer, + content: Uint8Array, options: { create: boolean; overwrite: boolean; @@ -659,11 +659,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider { const newCsp = newParams.has("csp") && ["", "1"].includes(newParams.get("csp")); const newFileName = newCsp ? newUri.path : newUri.path.slice(1).replace(/\//g, "."); // Generate content for the new file - const newContent = generateFileContent( - newUri, - newFileName, - Buffer.from(await vscode.workspace.fs.readFile(oldUri)) - ); + const newContent = generateFileContent(newUri, newFileName, await vscode.workspace.fs.readFile(oldUri)); if (newFileStat) { // We're overwriting an existing file so prompt the user to check it out await fireOtherStudioAction(OtherStudioAction.AttemptedEdit, newUri);