diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 9ffa7ee25971..7cf2b62dd485 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -20628,7 +20628,7 @@ packages: dev: false file:projects/eventgrid.tgz: - resolution: {integrity: sha512-lEVmH829YPH2tBtjHpzR427SM3QuZnyTRP4kE5W46/1bi4mqZdIQjqqS15QQktmrFF34R/fLzBv9mhmUszQ/Cg==, tarball: file:projects/eventgrid.tgz} + resolution: {integrity: sha512-xNO7uSbCB0gSezDYBsFLGRv0mgFhuRovCGLgicVWr3KBzCHr9fZn2OdSSIIsBAx68K8Ha0nHjeHPC0jlhL/cCQ==, tarball: file:projects/eventgrid.tgz} name: '@rush-temp/eventgrid' version: 0.0.0 dependencies: @@ -20664,7 +20664,7 @@ packages: tsx: 4.19.2 typescript: 5.6.3 uuid: 8.3.2 - vitest: 2.1.6(@types/node@18.19.66)(@vitest/browser@2.1.6)(tsx@4.19.2) + vitest: 2.1.6(@types/node@18.19.66)(@vitest/browser@2.1.6) transitivePeerDependencies: - '@edge-runtime/vm' - '@vitest/ui' @@ -20682,6 +20682,7 @@ packages: - sugarss - supports-color - terser + - tsx - utf-8-validate - vite - webdriverio @@ -21061,7 +21062,7 @@ packages: dev: false file:projects/identity-vscode.tgz: - resolution: {integrity: sha512-7wFwOEU77YA+6eg2Xs7S8xD4eXOUfUcPc4Ic8g2JDQ1COfG1Sh6MiADCcnB8jFbjLrTLGUr/XsqI0eu9oOX/bA==, tarball: file:projects/identity-vscode.tgz} + resolution: {integrity: sha512-7ZCkOJ5EpiwE6unR/9sLeKKDm08nNFWFJQ/x352UGCqMPm1xhLAkQ090/WoEmGc0fn5qlK//QlzuSTBphKgLmw==, tarball: file:projects/identity-vscode.tgz} name: '@rush-temp/identity-vscode' version: 0.0.0 dependencies: @@ -21072,24 +21073,43 @@ packages: '@types/qs': 6.9.17 '@types/sinon': 17.0.3 '@types/uuid': 8.3.4 + '@vitest/browser': 2.1.6(@types/node@18.19.66)(playwright@1.49.0)(typescript@5.6.3)(vitest@2.1.6) + '@vitest/coverage-istanbul': 2.1.6(vitest@2.1.6) dotenv: 16.4.5 eslint: 9.15.0 inherits: 2.0.4 keytar: 7.9.0 mocha: 10.8.2 + playwright: 1.49.0 puppeteer: 23.9.0(typescript@5.6.3) sinon: 17.0.1 ts-node: 10.9.2(@types/node@18.19.66)(typescript@5.6.3) tslib: 2.8.1 typescript: 5.6.3 util: 0.12.5 + vitest: 2.1.6(@types/node@18.19.66)(@vitest/browser@2.1.6) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - tsx - utf-8-validate + - vite + - webdriverio + - yaml dev: false file:projects/identity.tgz: diff --git a/sdk/identity/identity-vscode/api-extractor.json b/sdk/identity/identity-vscode/api-extractor.json index 9ce43119c136..2338e03adfca 100644 --- a/sdk/identity/identity-vscode/api-extractor.json +++ b/sdk/identity/identity-vscode/api-extractor.json @@ -1,6 +1,6 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "./types/src/index.d.ts", + "mainEntryPointFilePath": "dist/esm/index.d.ts", "docModel": { "enabled": true }, @@ -11,7 +11,7 @@ "dtsRollup": { "enabled": true, "untrimmedFilePath": "", - "publicTrimmedFilePath": "./types/identity-vscode.d.ts" + "publicTrimmedFilePath": "dist/identity-vscode.d.ts" }, "messages": { "tsdocMessageReporting": { diff --git a/sdk/identity/identity-vscode/package.json b/sdk/identity/identity-vscode/package.json index f493ac4c0783..5b9ad7528706 100644 --- a/sdk/identity/identity-vscode/package.json +++ b/sdk/identity/identity-vscode/package.json @@ -3,17 +3,17 @@ "version": "1.0.1", "sdk-type": "client", "description": "Use the Azure Account extension for Visual Studio Code to authenticate with Azure Identity", - "main": "dist/index.js", - "module": "dist-esm/src/index.js", - "types": "./types/identity-vscode.d.ts", + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/commonjs/index.d.ts", "scripts": { - "build": "npm run clean && npm run extract-api && tsc -p . && dev-tool run bundle", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", "build:samples": "echo skipped", - "build:test": "tsc -p . && dev-tool run bundle", + "build:test": "echo skipped", "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"", "clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log", "execute:samples": "echo skipped", - "extract-api": "tsc -p . && dev-tool run extract-api", + "extract-api": "dev-tool run build-package && dev-tool run extract-api", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", @@ -26,13 +26,11 @@ "test:node": "npm run clean && npm run build:test && npm run unit-test:node && npm run integration-test:node", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "echo skipped", - "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 300000 --exclude 'test/**/browser/**/*.spec.ts' 'test/**/**/*.spec.ts'", + "unit-test:node": "echo skipped", "update-snippets": "echo skipped" }, "files": [ "dist/", - "dist-esm/src", - "types/identity-vscode.d.ts", "README.md", "LICENSE" ], @@ -58,30 +56,60 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode/README.md", "sideEffects": false, "dependencies": { - "@azure/identity": "^4.0.1", + "@azure/identity": "^4.5.0", "keytar": "^7.6.0", - "tslib": "^2.2.0" + "tslib": "^2.8.1" }, "devDependencies": { - "@azure-tools/test-recorder": "^3.0.0", - "@azure-tools/test-utils": "^1.0.1", + "@azure-tools/test-recorder": "^4.1.0", + "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/core-client": "^1.7.0", "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@types/jws": "^3.2.2", - "@types/mocha": "^10.0.0", "@types/node": "^18.0.0", - "@types/qs": "^6.5.3", - "@types/sinon": "^17.0.0", - "@types/uuid": "^8.0.0", + "@vitest/coverage-istanbul": "^2.1.6", "dotenv": "^16.0.0", "eslint": "^9.9.0", - "inherits": "^2.0.3", - "mocha": "^10.0.0", - "puppeteer": "^23.0.2", - "sinon": "^17.0.0", - "ts-node": "^10.0.0", + "playwright": "^1.49.0", "typescript": "~5.6.2", - "util": "^0.12.1" + "vitest": "^2.1.6" + }, + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "browser": "./dist/browser/index.js", + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } } } diff --git a/sdk/identity/identity-vscode/samples-dev/extension.ts b/sdk/identity/identity-vscode/samples-dev/extension.ts index 1d26392a81be..1fcdeeebe9ba 100644 --- a/sdk/identity/identity-vscode/samples-dev/extension.ts +++ b/sdk/identity/identity-vscode/samples-dev/extension.ts @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /** @@ -20,7 +20,7 @@ import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity"; import { vsCodePlugin } from "@azure/identity-vscode"; useIdentityPlugin(vsCodePlugin); -export async function main() { +export async function main(): Promise { const credential = new DefaultAzureCredential(); // This is the scope we will use to get a token from the Microsoft Entra token endpoint. diff --git a/sdk/identity/identity-vscode/samples-dev/nodeEnv.ts b/sdk/identity/identity-vscode/samples-dev/nodeEnv.ts index d6e5a1f6de7c..12f84e6bd7b2 100644 --- a/sdk/identity/identity-vscode/samples-dev/nodeEnv.ts +++ b/sdk/identity/identity-vscode/samples-dev/nodeEnv.ts @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /** diff --git a/sdk/identity/identity-vscode/test/public/node/setup.spec.ts b/sdk/identity/identity-vscode/test/public/node/setup.spec.ts index fa0189eb2baa..d31b3f7094d3 100644 --- a/sdk/identity/identity-vscode/test/public/node/setup.spec.ts +++ b/sdk/identity/identity-vscode/test/public/node/setup.spec.ts @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { vsCodePlugin as plugin } from "../../../src"; +import { vsCodePlugin as plugin } from "../../../src/index.js"; import { useIdentityPlugin } from "@azure/identity"; +import { beforeAll } from "vitest"; -before(function () { +beforeAll(function () { useIdentityPlugin(plugin); }); diff --git a/sdk/identity/identity-vscode/test/public/node/visualStudioCodeCredential.spec.ts b/sdk/identity/identity-vscode/test/public/node/visualStudioCodeCredential.spec.ts index 5c5b29b3b845..36bb4bf1a5a9 100644 --- a/sdk/identity/identity-vscode/test/public/node/visualStudioCodeCredential.spec.ts +++ b/sdk/identity/identity-vscode/test/public/node/visualStudioCodeCredential.spec.ts @@ -1,15 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable sort-imports */ - -import type { Recorder } from "@azure-tools/test-recorder"; +import { Recorder } from "@azure-tools/test-recorder"; import { isRecordMode } from "@azure-tools/test-recorder"; import { VisualStudioCodeCredential } from "@azure/identity"; -import assert from "assert"; -import sinon from "sinon"; +import { describe, it, assert, vi, beforeEach } from "vitest"; const mockedResponse = [ { @@ -19,12 +14,12 @@ const mockedResponse = [ ]; // TODO: Enable again once the VisualStudio cache bug is fixed. -describe.skip("VisualStudioCodeCredential", function (this: Mocha.Suite) { +describe.skip("VisualStudioCodeCredential", () => { let recorder: Recorder; - beforeEach(async function (this: Mocha.Context) {}); - - afterEach(async function () {}); + beforeEach(async (ctx) => { + recorder = new Recorder(ctx); + }); const scope = "https://graph.microsoft.com/.default"; @@ -32,8 +27,12 @@ describe.skip("VisualStudioCodeCredential", function (this: Mocha.Suite) { if (!isRecordMode()) { // In live CI or playback CI, we need to avoid actually using keytar // to try to read the Azure Account state, since it won't be available - const mock = sinon.mock(require("keytar")); - mock.expects("findCredentials").onFirstCall().returns(mockedResponse); + vi.mock("keytar", (importActual) => { + return { + ...importActual, + findCredentials: async () => mockedResponse, + }; + }); } const cred = new VisualStudioCodeCredential(recorder.configureClientOptions({})); diff --git a/sdk/identity/identity-vscode/tsconfig.json b/sdk/identity/identity-vscode/tsconfig.json index 6a1899b344a8..e7c2155a9b9b 100644 --- a/sdk/identity/identity-vscode/tsconfig.json +++ b/sdk/identity/identity-vscode/tsconfig.json @@ -3,12 +3,21 @@ "compilerOptions": { "target": "es6", "lib": ["DOM"], - "declarationDir": "./types", - "outDir": "./dist-esm", "resolveJsonModule": true, "paths": { "@azure/identity-vscode": ["./src/index"] - } + }, + "module": "NodeNext", + "moduleResolution": "NodeNext", + "rootDir": "." }, - "include": ["src/**/*", "test/**/*", "samples-dev/**/*"] + "include": [ + "src/**/*.ts", + "src/**/*.mts", + "src/**/*.cts", + "samples-dev/**/*.ts", + "test/**/*.ts", + "test/**/*.mts", + "test/**/*.cts" + ] } diff --git a/sdk/identity/identity-vscode/vitest.config.ts b/sdk/identity/identity-vscode/vitest.config.ts new file mode 100644 index 000000000000..39267dd2f56f --- /dev/null +++ b/sdk/identity/identity-vscode/vitest.config.ts @@ -0,0 +1,15 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["test/**/*.spec.ts"], + }, + }), +);