From cbc42c451d87a7321e6ce44c8e81ac39d8e1a1fa Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:29:50 -0800 Subject: [PATCH 01/13] creates tls certificates --- .../rush/nonbrowser-approved-packages.json | 2 +- common/config/rush/pnpm-lock.yaml | 7 ++- common/config/rush/repo-state.json | 2 +- .../rush-vscode-extension/config/heft.json | 10 ++++ .../rush-vscode-extension/package.json | 3 +- .../src/scripts/generate-tls-certificate.ts | 53 +++++++++++++++++++ 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts diff --git a/common/config/rush/nonbrowser-approved-packages.json b/common/config/rush/nonbrowser-approved-packages.json index c96b93283f7..e4ff5da73fa 100644 --- a/common/config/rush/nonbrowser-approved-packages.json +++ b/common/config/rush/nonbrowser-approved-packages.json @@ -96,7 +96,7 @@ }, { "name": "@rushstack/debug-certificate-manager", - "allowedCategories": [ "libraries" ] + "allowedCategories": [ "libraries", "vscode-extensions" ] }, { "name": "@rushstack/eslint-config", diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index fdc2aa7f187..6c088d6603a 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -4061,6 +4061,9 @@ importers: ../../vscode-extensions/rush-vscode-extension: dependencies: + '@rushstack/debug-certificate-manager': + specifier: workspace:* + version: link:../../libraries/debug-certificate-manager '@rushstack/node-core-library': specifier: workspace:* version: link:../../libraries/node-core-library @@ -8588,7 +8591,7 @@ packages: dependencies: '@jest/console': 29.7.0 '@jest/types': 29.6.3 - '@types/istanbul-lib-coverage': 2.0.4 + '@types/istanbul-lib-coverage': 2.0.6 collect-v8-coverage: 1.0.2(@types/node@18.17.15) jest-haste-map: 29.7.0 jest-resolve: 29.7.0 @@ -25891,7 +25894,7 @@ packages: engines: {node: '>=10.12.0'} dependencies: '@jridgewell/trace-mapping': 0.3.22 - '@types/istanbul-lib-coverage': 2.0.4 + '@types/istanbul-lib-coverage': 2.0.6 convert-source-map: 2.0.0 /validate-npm-package-license@3.0.4: diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 73e287bc5fd..c4e630d5110 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "eea8b6e9184ef13a202936a9b855668654757e62", + "pnpmShrinkwrapHash": "81d1d2d2a1a13dbfefc99fc2ba27e03fa286cdba", "preferredVersionsHash": "40d4640a94cff77f7808a2f1960cc76231eb6f86" } diff --git a/vscode-extensions/rush-vscode-extension/config/heft.json b/vscode-extensions/rush-vscode-extension/config/heft.json index 15b954e3644..00c1daf5d3b 100644 --- a/vscode-extensions/rush-vscode-extension/config/heft.json +++ b/vscode-extensions/rush-vscode-extension/config/heft.json @@ -44,6 +44,16 @@ "scriptPath": "lib/scripts/generate-vscodeignore.js" } } + }, + "generate-tls-certificate": { + "taskDependencies": ["copy-webview", "typescript", "webpack"], + "taskPlugin": { + "pluginPackage": "@rushstack/heft", + "pluginName": "run-script-plugin", + "options": { + "scriptPath": "lib/scripts/generate-tls-certificate.js" + } + } } } } diff --git a/vscode-extensions/rush-vscode-extension/package.json b/vscode-extensions/rush-vscode-extension/package.json index 966d18d162f..408b9e79485 100644 --- a/vscode-extensions/rush-vscode-extension/package.json +++ b/vscode-extensions/rush-vscode-extension/package.json @@ -260,7 +260,8 @@ "@rushstack/rush-sdk": "workspace:*", "@rushstack/ts-command-line": "workspace:*", "@rushstack/rush-vscode-command-webview": "workspace:*", - "@rushstack/terminal": "workspace:*" + "@rushstack/terminal": "workspace:*", + "@rushstack/debug-certificate-manager": "workspace:*" }, "devDependencies": { "@microsoft/rush-lib": "workspace:*", diff --git a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts new file mode 100644 index 00000000000..3ecae6830c7 --- /dev/null +++ b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import type { IRunScriptOptions } from '@rushstack/heft'; +import { FileSystem } from '@rushstack/node-core-library'; +import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; +import { homedir } from 'node:os'; +import * as path from 'path'; + +export async function runAsync({ heftTaskSession: { logger } }: IRunScriptOptions): Promise { + const certificateManager: CertificateManager = new CertificateManager(); + + // logger.terminal.writeLine(`Untrusting existing CA certificate`); + // await certificateManager.untrustCertificateAsync(logger.terminal); + + logger.terminal.writeLine( + `Obtaining a TLS certificate signed by a local self-signed Certificate Authority` + ); + + const { + pemCaCertificate, + pemCertificate, + pemKey + }: ICertificate & { + pemCaCertificate?: string; + } = await certificateManager.ensureCertificateAsync(true, logger.terminal); + + if (!pemCertificate || !pemKey) { + throw new Error(`No certificate available, exiting.`); + } + + logger.terminal.writeLine(`Trusted TLS certificate successfully obtained`); + + const unresolvedUserFolder: string = homedir(); + const userProfilePath: string = path.resolve(unresolvedUserFolder); + if (!FileSystem.exists(userProfilePath)) { + throw new Error("Unable to determine the current user's home directory"); + } + + const serveDataPath: string = path.join(userProfilePath, '.rushstack'); + FileSystem.ensureFolder(serveDataPath); + + const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); + const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); + const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); + + if (pemCaCertificate) { + await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); + } + + await FileSystem.writeFileAsync(certificatePath, pemCertificate); + await FileSystem.writeFileAsync(keyPath, pemKey); +} From f0939ddf464f5bf2556c8e59d57c0f1fa82e1906 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:53:09 -0800 Subject: [PATCH 02/13] modified way of creating tls certificates and saving --- .../workspace/common/pnpm-lock.yaml | 147 +++++++++--------- .../rush-vscode-extension/src/extension.ts | 45 ++++++ .../src/scripts/generate-tls-certificate.ts | 53 ------- 3 files changed, 116 insertions(+), 129 deletions(-) delete mode 100644 vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts diff --git a/build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml b/build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml index b2f6a8706d4..b6812ff7fc4 100644 --- a/build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml +++ b/build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: specifier: file:microsoft-rush-lib-5.115.0.tgz version: file:../temp/tarballs/microsoft-rush-lib-5.115.0.tgz(@types/node@18.17.15) '@rushstack/terminal': - specifier: file:rushstack-terminal-0.9.0.tgz - version: file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + specifier: file:rushstack-terminal-0.10.0.tgz + version: file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) devDependencies: '@types/node': specifier: 18.17.15 @@ -52,14 +52,14 @@ importers: specifier: file:rushstack-eslint-config-3.6.4.tgz version: file:../temp/tarballs/rushstack-eslint-config-3.6.4.tgz(eslint@8.7.0)(typescript@5.3.3) '@rushstack/heft': - specifier: file:rushstack-heft-0.65.4.tgz - version: file:../temp/tarballs/rushstack-heft-0.65.4.tgz + specifier: file:rushstack-heft-0.65.5.tgz + version: file:../temp/tarballs/rushstack-heft-0.65.5.tgz '@rushstack/heft-lint-plugin': - specifier: file:rushstack-heft-lint-plugin-0.3.13.tgz - version: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.13.tgz(@rushstack/heft@0.65.4) + specifier: file:rushstack-heft-lint-plugin-0.3.14.tgz + version: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.14.tgz(@rushstack/heft@0.65.5) '@rushstack/heft-typescript-plugin': - specifier: file:rushstack-heft-typescript-plugin-0.3.13.tgz - version: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.13.tgz(@rushstack/heft@0.65.4) + specifier: file:rushstack-heft-typescript-plugin-0.3.14.tgz + version: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.14.tgz(@rushstack/heft@0.65.5) eslint: specifier: ~8.7.0 version: 8.7.0 @@ -76,14 +76,14 @@ importers: specifier: file:rushstack-eslint-config-3.6.4.tgz version: file:../temp/tarballs/rushstack-eslint-config-3.6.4.tgz(eslint@8.7.0)(typescript@4.7.4) '@rushstack/heft': - specifier: file:rushstack-heft-0.65.4.tgz - version: file:../temp/tarballs/rushstack-heft-0.65.4.tgz + specifier: file:rushstack-heft-0.65.5.tgz + version: file:../temp/tarballs/rushstack-heft-0.65.5.tgz '@rushstack/heft-lint-plugin': - specifier: file:rushstack-heft-lint-plugin-0.3.13.tgz - version: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.13.tgz(@rushstack/heft@0.65.4) + specifier: file:rushstack-heft-lint-plugin-0.3.14.tgz + version: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.14.tgz(@rushstack/heft@0.65.5) '@rushstack/heft-typescript-plugin': - specifier: file:rushstack-heft-typescript-plugin-0.3.13.tgz - version: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.13.tgz(@rushstack/heft@0.65.4) + specifier: file:rushstack-heft-typescript-plugin-0.3.14.tgz + version: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.14.tgz(@rushstack/heft@0.65.5) eslint: specifier: ~8.7.0 version: 8.7.0 @@ -1179,10 +1179,6 @@ packages: resolution: {integrity: sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw==} engines: {node: '>=0.1.90'} - /colors@1.2.5: - resolution: {integrity: sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==} - engines: {node: '>=0.1.90'} - /combined-stream@1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} @@ -4248,14 +4244,14 @@ packages: dependencies: '@pnpm/dependency-path': 2.1.2 '@pnpm/link-bins': 5.3.25 - '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz(@types/node@18.17.15) + '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz(@types/node@18.17.15) '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/package-deps-hash': file:../temp/tarballs/rushstack-package-deps-hash-4.1.31.tgz(@types/node@18.17.15) - '@rushstack/package-extractor': file:../temp/tarballs/rushstack-package-extractor-0.6.33.tgz(@types/node@18.17.15) + '@rushstack/package-deps-hash': file:../temp/tarballs/rushstack-package-deps-hash-4.1.32.tgz(@types/node@18.17.15) + '@rushstack/package-extractor': file:../temp/tarballs/rushstack-package-extractor-0.6.34.tgz(@types/node@18.17.15) '@rushstack/rig-package': file:../temp/tarballs/rushstack-rig-package-0.5.2.tgz - '@rushstack/stream-collator': file:../temp/tarballs/rushstack-stream-collator-4.1.31.tgz(@types/node@18.17.15) - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) - '@rushstack/ts-command-line': file:../temp/tarballs/rushstack-ts-command-line-4.17.3.tgz(@types/node@18.17.15) + '@rushstack/stream-collator': file:../temp/tarballs/rushstack-stream-collator-4.1.32.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) + '@rushstack/ts-command-line': file:../temp/tarballs/rushstack-ts-command-line-4.17.4.tgz(@types/node@18.17.15) '@types/node-fetch': 2.6.2 '@yarnpkg/lockfile': 1.0.2 builtin-modules: 3.1.0 @@ -4441,19 +4437,19 @@ packages: - typescript dev: true - file:../temp/tarballs/rushstack-heft-0.65.4.tgz: - resolution: {tarball: file:../temp/tarballs/rushstack-heft-0.65.4.tgz} + file:../temp/tarballs/rushstack-heft-0.65.5.tgz: + resolution: {tarball: file:../temp/tarballs/rushstack-heft-0.65.5.tgz} name: '@rushstack/heft' - version: 0.65.4 + version: 0.65.5 engines: {node: '>=10.13.0'} hasBin: true dependencies: - '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz(@types/node@18.17.15) + '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz(@types/node@18.17.15) '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/operation-graph': file:../temp/tarballs/rushstack-operation-graph-0.2.13.tgz + '@rushstack/operation-graph': file:../temp/tarballs/rushstack-operation-graph-0.2.14.tgz '@rushstack/rig-package': file:../temp/tarballs/rushstack-rig-package-0.5.2.tgz - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) - '@rushstack/ts-command-line': file:../temp/tarballs/rushstack-ts-command-line-4.17.3.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) + '@rushstack/ts-command-line': file:../temp/tarballs/rushstack-ts-command-line-4.17.4.tgz(@types/node@18.17.15) '@types/tapable': 1.0.6 fast-glob: 3.3.1 git-repo-info: 2.1.1 @@ -4465,45 +4461,45 @@ packages: - '@types/node' dev: true - file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz} - id: file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz + file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz} + id: file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz name: '@rushstack/heft-config-file' - version: 0.14.13 + version: 0.14.14 engines: {node: '>=10.13.0'} dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) '@rushstack/rig-package': file:../temp/tarballs/rushstack-rig-package-0.5.2.tgz - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) jsonpath-plus: 4.0.0 transitivePeerDependencies: - '@types/node' - file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.13.tgz(@rushstack/heft@0.65.4): - resolution: {tarball: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.13.tgz} - id: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.13.tgz + file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.14.tgz(@rushstack/heft@0.65.5): + resolution: {tarball: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.14.tgz} + id: file:../temp/tarballs/rushstack-heft-lint-plugin-0.3.14.tgz name: '@rushstack/heft-lint-plugin' - version: 0.3.13 + version: 0.3.14 peerDependencies: '@rushstack/heft': '*' dependencies: - '@rushstack/heft': file:../temp/tarballs/rushstack-heft-0.65.4.tgz + '@rushstack/heft': file:../temp/tarballs/rushstack-heft-0.65.5.tgz '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) semver: 7.5.4 transitivePeerDependencies: - '@types/node' dev: true - file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.13.tgz(@rushstack/heft@0.65.4): - resolution: {tarball: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.13.tgz} - id: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.13.tgz + file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.14.tgz(@rushstack/heft@0.65.5): + resolution: {tarball: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.14.tgz} + id: file:../temp/tarballs/rushstack-heft-typescript-plugin-0.3.14.tgz name: '@rushstack/heft-typescript-plugin' - version: 0.3.13 + version: 0.3.14 peerDependencies: '@rushstack/heft': '*' dependencies: - '@rushstack/heft': file:../temp/tarballs/rushstack-heft-0.65.4.tgz - '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.13.tgz(@types/node@18.17.15) + '@rushstack/heft': file:../temp/tarballs/rushstack-heft-0.65.5.tgz + '@rushstack/heft-config-file': file:../temp/tarballs/rushstack-heft-config-file-0.14.14.tgz(@types/node@18.17.15) '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) '@types/tapable': 1.0.6 semver: 7.5.4 @@ -4531,10 +4527,10 @@ packages: semver: 7.5.4 z-schema: 5.0.3 - file:../temp/tarballs/rushstack-operation-graph-0.2.13.tgz: - resolution: {tarball: file:../temp/tarballs/rushstack-operation-graph-0.2.13.tgz} + file:../temp/tarballs/rushstack-operation-graph-0.2.14.tgz: + resolution: {tarball: file:../temp/tarballs/rushstack-operation-graph-0.2.14.tgz} name: '@rushstack/operation-graph' - version: 0.2.13 + version: 0.2.14 peerDependencies: '@types/node': '*' peerDependenciesMeta: @@ -4542,28 +4538,28 @@ packages: optional: true dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) dev: true - file:../temp/tarballs/rushstack-package-deps-hash-4.1.31.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-package-deps-hash-4.1.31.tgz} - id: file:../temp/tarballs/rushstack-package-deps-hash-4.1.31.tgz + file:../temp/tarballs/rushstack-package-deps-hash-4.1.32.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-package-deps-hash-4.1.32.tgz} + id: file:../temp/tarballs/rushstack-package-deps-hash-4.1.32.tgz name: '@rushstack/package-deps-hash' - version: 4.1.31 + version: 4.1.32 dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) transitivePeerDependencies: - '@types/node' - file:../temp/tarballs/rushstack-package-extractor-0.6.33.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-package-extractor-0.6.33.tgz} - id: file:../temp/tarballs/rushstack-package-extractor-0.6.33.tgz + file:../temp/tarballs/rushstack-package-extractor-0.6.34.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-package-extractor-0.6.34.tgz} + id: file:../temp/tarballs/rushstack-package-extractor-0.6.34.tgz name: '@rushstack/package-extractor' - version: 0.6.33 + version: 0.6.34 dependencies: '@pnpm/link-bins': 5.3.25 '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) ignore: 5.1.9 jszip: 3.8.0 minimatch: 3.0.8 @@ -4587,29 +4583,29 @@ packages: version: 5.115.0 dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) '@types/node-fetch': 2.6.2 tapable: 2.2.1 transitivePeerDependencies: - '@types/node' dev: false - file:../temp/tarballs/rushstack-stream-collator-4.1.31.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-stream-collator-4.1.31.tgz} - id: file:../temp/tarballs/rushstack-stream-collator-4.1.31.tgz + file:../temp/tarballs/rushstack-stream-collator-4.1.32.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-stream-collator-4.1.32.tgz} + id: file:../temp/tarballs/rushstack-stream-collator-4.1.32.tgz name: '@rushstack/stream-collator' - version: 4.1.31 + version: 4.1.32 dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) transitivePeerDependencies: - '@types/node' - file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-terminal-0.9.0.tgz} - id: file:../temp/tarballs/rushstack-terminal-0.9.0.tgz + file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-terminal-0.10.0.tgz} + id: file:../temp/tarballs/rushstack-terminal-0.10.0.tgz name: '@rushstack/terminal' - version: 0.9.0 + version: 0.10.0 peerDependencies: '@types/node': '*' peerDependenciesMeta: @@ -4618,7 +4614,6 @@ packages: dependencies: '@rushstack/node-core-library': file:../temp/tarballs/rushstack-node-core-library-4.0.2.tgz(@types/node@18.17.15) '@types/node': 18.17.15 - colors: 1.2.5 supports-color: 8.1.1 file:../temp/tarballs/rushstack-tree-pattern-0.3.3.tgz: @@ -4627,13 +4622,13 @@ packages: version: 0.3.3 dev: true - file:../temp/tarballs/rushstack-ts-command-line-4.17.3.tgz(@types/node@18.17.15): - resolution: {tarball: file:../temp/tarballs/rushstack-ts-command-line-4.17.3.tgz} - id: file:../temp/tarballs/rushstack-ts-command-line-4.17.3.tgz + file:../temp/tarballs/rushstack-ts-command-line-4.17.4.tgz(@types/node@18.17.15): + resolution: {tarball: file:../temp/tarballs/rushstack-ts-command-line-4.17.4.tgz} + id: file:../temp/tarballs/rushstack-ts-command-line-4.17.4.tgz name: '@rushstack/ts-command-line' - version: 4.17.3 + version: 4.17.4 dependencies: - '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.9.0.tgz(@types/node@18.17.15) + '@rushstack/terminal': file:../temp/tarballs/rushstack-terminal-0.10.0.tgz(@types/node@18.17.15) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.1 diff --git a/vscode-extensions/rush-vscode-extension/src/extension.ts b/vscode-extensions/rush-vscode-extension/src/extension.ts index f9034d3eed5..5b7ca98d7c6 100644 --- a/vscode-extensions/rush-vscode-extension/src/extension.ts +++ b/vscode-extensions/rush-vscode-extension/src/extension.ts @@ -9,10 +9,15 @@ import { RushWorkspace } from './logic/RushWorkspace'; import { RushProjectsProvider } from './providers/RushProjectsProvider'; import { RushTaskProvider } from './providers/TaskProvider'; import { RushCommandWebViewPanel } from './logic/RushCommandWebViewPanel'; +import { FileSystem } from '@rushstack/node-core-library'; +import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; +import { homedir } from 'node:os'; +import * as path from 'path'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext): Promise { + vscode.window.showInformationMessage('Rush Stack extension is now active!'); context.subscriptions.push( vscode.commands.registerCommand('rushstack.selectWorkspace', async () => { await RushWorkspace.selectWorkspace(); @@ -60,6 +65,46 @@ export async function activate(context: vscode.ExtensionContext): Promise RushCommandWebViewPanel.initialize(context).reveal(); } + + const certificateManager: CertificateManager = new CertificateManager(); + + // logger.terminal.writeLine(`Untrusting existing CA certificate`); + // await certificateManager.untrustCertificateAsync(logger.terminal); + + terminal.writeLine(`Obtaining a TLS certificate signed by a local self-signed Certificate Authority`); + + const { + pemCaCertificate, + pemCertificate, + pemKey + }: ICertificate & { + pemCaCertificate?: string; + } = await certificateManager.ensureCertificateAsync(true, terminal); + + if (!pemCertificate || !pemKey) { + throw new Error(`No certificate available, exiting.`); + } + terminal.writeLine(`Trusted TLS certificate successfully obtained`); + + const unresolvedUserFolder: string = homedir(); + const userProfilePath: string = path.resolve(unresolvedUserFolder); + if (!FileSystem.exists(userProfilePath)) { + throw new Error("Unable to determine the current user's home directory"); + } + + const serveDataPath: string = path.join(userProfilePath, '.rushstack'); + FileSystem.ensureFolder(serveDataPath); + + const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); + const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); + const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); + + if (pemCaCertificate) { + await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); + } + + await FileSystem.writeFileAsync(certificatePath, pemCertificate); + await FileSystem.writeFileAsync(keyPath, pemKey); } // this method is called when your extension is deactivated diff --git a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts deleted file mode 100644 index 3ecae6830c7..00000000000 --- a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. -// See LICENSE in the project root for license information. - -import type { IRunScriptOptions } from '@rushstack/heft'; -import { FileSystem } from '@rushstack/node-core-library'; -import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; -import { homedir } from 'node:os'; -import * as path from 'path'; - -export async function runAsync({ heftTaskSession: { logger } }: IRunScriptOptions): Promise { - const certificateManager: CertificateManager = new CertificateManager(); - - // logger.terminal.writeLine(`Untrusting existing CA certificate`); - // await certificateManager.untrustCertificateAsync(logger.terminal); - - logger.terminal.writeLine( - `Obtaining a TLS certificate signed by a local self-signed Certificate Authority` - ); - - const { - pemCaCertificate, - pemCertificate, - pemKey - }: ICertificate & { - pemCaCertificate?: string; - } = await certificateManager.ensureCertificateAsync(true, logger.terminal); - - if (!pemCertificate || !pemKey) { - throw new Error(`No certificate available, exiting.`); - } - - logger.terminal.writeLine(`Trusted TLS certificate successfully obtained`); - - const unresolvedUserFolder: string = homedir(); - const userProfilePath: string = path.resolve(unresolvedUserFolder); - if (!FileSystem.exists(userProfilePath)) { - throw new Error("Unable to determine the current user's home directory"); - } - - const serveDataPath: string = path.join(userProfilePath, '.rushstack'); - FileSystem.ensureFolder(serveDataPath); - - const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); - const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); - const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); - - if (pemCaCertificate) { - await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); - } - - await FileSystem.writeFileAsync(certificatePath, pemCertificate); - await FileSystem.writeFileAsync(keyPath, pemKey); -} From e9bb67cf467ba2480fa6c06dff0f8eeb5825a1cb Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:30:14 -0800 Subject: [PATCH 03/13] init new tls certification ui extension --- .vscode/launch.json | 13 ++ .../tls-certification-ui-publish.yaml | 45 ++++ .../rush/browser-approved-packages.json | 2 +- .../rush/nonbrowser-approved-packages.json | 14 +- common/config/rush/pnpm-lock.yaml | 80 ++++++- common/config/rush/repo-state.json | 2 +- .../src/test.ts | 30 +++ rush.json | 6 + .../src/scripts/generate-tls-certificate.ts | 43 ++++ .../tls-certification-ui/.eslintrc.js | 13 ++ .../tls-certification-ui/.gitignore | 4 + .../tls-certification-ui/.npmignore | 20 ++ .../tls-certification-ui/LICENSE | 24 +++ .../tls-certification-ui/README.md | 26 +++ .../tls-certification-ui/config/heft.json | 41 ++++ .../tls-certification-ui/config/rig.json | 5 + .../tls-certification-ui/package.json | 203 ++++++++++++++++++ .../tls-certification-ui/src/extension.ts | 59 +++++ .../tls-certification-ui/src/logic/logger.ts | 24 +++ .../tls-certification-ui/tsconfig.json | 7 + .../tls-certification-ui/webpack.config.js | 49 +++++ 21 files changed, 694 insertions(+), 16 deletions(-) create mode 100644 common/config/azure-pipelines/tls-certification-ui-publish.yaml create mode 100644 rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts create mode 100644 vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts create mode 100644 vscode-extensions/tls-certification-ui/.eslintrc.js create mode 100644 vscode-extensions/tls-certification-ui/.gitignore create mode 100644 vscode-extensions/tls-certification-ui/.npmignore create mode 100644 vscode-extensions/tls-certification-ui/LICENSE create mode 100644 vscode-extensions/tls-certification-ui/README.md create mode 100644 vscode-extensions/tls-certification-ui/config/heft.json create mode 100644 vscode-extensions/tls-certification-ui/config/rig.json create mode 100644 vscode-extensions/tls-certification-ui/package.json create mode 100644 vscode-extensions/tls-certification-ui/src/extension.ts create mode 100644 vscode-extensions/tls-certification-ui/src/logic/logger.ts create mode 100644 vscode-extensions/tls-certification-ui/tsconfig.json create mode 100644 vscode-extensions/tls-certification-ui/webpack.config.js diff --git a/.vscode/launch.json b/.vscode/launch.json index ba209eeed00..3218261cb33 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -82,6 +82,19 @@ "${workspaceFolder}/vscode-extensions/rush-vscode-extension/dist/**/*.js" ] // "preLaunchTask": "npm: build:watch - vscode-extensions/rush-vscode-extension" + }, + { + "name": "Launch TLS Certification UI", + "type": "extensionHost", + "request": "launch", + "cwd": "${workspaceFolder}/vscode-extensions/tls-certification-ui", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/tls-certification-ui" + ], + "outFiles": [ + "${workspaceFolder}/vscode-extensions/tls-certification-ui/dist/**/*.js" + ] + // "preLaunchTask": "npm: build:watch - vscode-extensions/tls-certification-ui" } ] } diff --git a/common/config/azure-pipelines/tls-certification-ui-publish.yaml b/common/config/azure-pipelines/tls-certification-ui-publish.yaml new file mode 100644 index 00000000000..b4e9a5e0dd6 --- /dev/null +++ b/common/config/azure-pipelines/tls-certification-ui-publish.yaml @@ -0,0 +1,45 @@ +variables: + - name: FORCE_COLOR + value: 1 + +resources: + repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines + parameters: + pool: + name: Azure-Pipelines-1ESPT-ExDShared + os: windows + stages: + - stage: + jobs: + - job: + pool: + name: publish-tls-certification-ui + os: linux + steps: + - checkout: self + persistCredentials: true + + - template: /common/config/azure-pipelines/templates/install-node.yaml@self + + - template: /common/config/azure-pipelines/templates/build.yaml@self + parameters: + BuildParameters: > + --to rushstack + PerformValidation: false + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js package + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-ui + displayName: 'Package tls certification ui extension' + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js deploy + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-ui + displayName: 'Publish tls certification ui extension' + env: + VSCE_PAT: $(vscePat) diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json index e3f7ddb1205..fdb13d57bcc 100644 --- a/common/config/rush/browser-approved-packages.json +++ b/common/config/rush/browser-approved-packages.json @@ -48,7 +48,7 @@ }, { "name": "@rushstack/rush-vscode-command-webview", - "allowedCategories": [ "vscode-extensions" ] + "allowedCategories": [ "tests", "vscode-extensions" ] }, { "name": "axios", diff --git a/common/config/rush/nonbrowser-approved-packages.json b/common/config/rush/nonbrowser-approved-packages.json index e4ff5da73fa..54b40b7ec85 100644 --- a/common/config/rush/nonbrowser-approved-packages.json +++ b/common/config/rush/nonbrowser-approved-packages.json @@ -96,7 +96,7 @@ }, { "name": "@rushstack/debug-certificate-manager", - "allowedCategories": [ "libraries", "vscode-extensions" ] + "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] }, { "name": "@rushstack/eslint-config", @@ -204,7 +204,7 @@ }, { "name": "@rushstack/package-extractor", - "allowedCategories": [ "libraries", "vscode-extensions" ] + "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] }, { "name": "@rushstack/rig-package", @@ -264,7 +264,7 @@ }, { "name": "@rushstack/webpack-preserve-dynamic-require-plugin", - "allowedCategories": [ "libraries", "vscode-extensions" ] + "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] }, { "name": "@rushstack/webpack4-localization-plugin", @@ -356,7 +356,7 @@ }, { "name": "@vscode/test-electron", - "allowedCategories": [ "vscode-extensions" ] + "allowedCategories": [ "tests", "vscode-extensions" ] }, { "name": "@yarnpkg/lockfile", @@ -516,7 +516,7 @@ }, { "name": "glob", - "allowedCategories": [ "libraries", "vscode-extensions" ] + "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] }, { "name": "glob-escape", @@ -672,7 +672,7 @@ }, { "name": "mocha", - "allowedCategories": [ "vscode-extensions" ] + "allowedCategories": [ "tests", "vscode-extensions" ] }, { "name": "node-fetch", @@ -852,7 +852,7 @@ }, { "name": "vsce", - "allowedCategories": [ "vscode-extensions" ] + "allowedCategories": [ "tests", "vscode-extensions" ] }, { "name": "watchpack", diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 6c088d6603a..396caf56ee0 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1774,7 +1774,7 @@ importers: version: 29.5.12 '@types/node': specifier: ts4.9 - version: 20.11.20 + version: 20.11.24 eslint: specifier: ~8.7.0 version: 8.7.0(supports-color@8.1.1) @@ -4123,6 +4123,70 @@ importers: specifier: ~2.14.0 version: 2.14.0 + ../../vscode-extensions/tls-certification-ui: + dependencies: + '@rushstack/debug-certificate-manager': + specifier: workspace:* + version: link:../../libraries/debug-certificate-manager + '@rushstack/node-core-library': + specifier: workspace:* + version: link:../../libraries/node-core-library + '@rushstack/rush-sdk': + specifier: workspace:* + version: link:../../libraries/rush-sdk + '@rushstack/rush-vscode-command-webview': + specifier: workspace:* + version: link:../rush-vscode-command-webview + '@rushstack/terminal': + specifier: workspace:* + version: link:../../libraries/terminal + '@rushstack/ts-command-line': + specifier: workspace:* + version: link:../../libraries/ts-command-line + devDependencies: + '@microsoft/rush-lib': + specifier: workspace:* + version: link:../../libraries/rush-lib + '@rushstack/heft': + specifier: workspace:* + version: link:../../apps/heft + '@rushstack/heft-webpack5-plugin': + specifier: workspace:* + version: link:../../heft-plugins/heft-webpack5-plugin + '@rushstack/package-extractor': + specifier: workspace:* + version: link:../../libraries/package-extractor + '@rushstack/webpack-preserve-dynamic-require-plugin': + specifier: workspace:* + version: link:../../webpack/preserve-dynamic-require-plugin + '@types/glob': + specifier: 7.1.1 + version: 7.1.1 + '@types/mocha': + specifier: ^9.0.0 + version: 9.1.1 + '@types/vscode': + specifier: ^1.63.0 + version: 1.86.0 + '@types/webpack-env': + specifier: 1.18.0 + version: 1.18.0 + '@vscode/test-electron': + specifier: ^1.6.2 + version: 1.6.2 + glob: + specifier: ~7.0.5 + version: 7.0.6 + local-node-rig: + specifier: workspace:* + version: link:../../rigs/local-node-rig + mocha: + specifier: ^9.1.3 + version: 9.2.2 + vsce: + specifier: ~2.14.0 + version: 2.14.0 + ../../webpack/hashed-folder-copy-plugin: dependencies: '@rushstack/node-core-library': @@ -11777,8 +11841,8 @@ packages: /@types/node@18.17.15: resolution: {integrity: sha512-2yrWpBk32tvV/JAd3HNHWuZn/VDN1P+72hWirHnvsvTGSqbANi+kSeuQR9yAHnbvaBvHDsoTdXV0Fe+iRtHLKA==} - /@types/node@20.11.20: - resolution: {integrity: sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==} + /@types/node@20.11.24: + resolution: {integrity: sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==} dependencies: undici-types: 5.26.5 dev: true @@ -13903,7 +13967,7 @@ packages: resolution: {integrity: sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==} dependencies: base64-js: 1.5.1 - ieee754: 1.1.13 + ieee754: 1.2.1 isarray: 1.0.0 /buffer@5.7.1: @@ -18384,6 +18448,7 @@ packages: /ieee754@1.1.13: resolution: {integrity: sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==} + dev: true /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} @@ -26538,7 +26603,7 @@ packages: /wide-align@1.1.5: resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} dependencies: - string-width: 1.0.2 + string-width: 4.2.3 dev: true /widest-line@3.1.0: @@ -26714,7 +26779,7 @@ packages: resolution: {integrity: sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==} engines: {node: '>=4.0.0'} dependencies: - sax: 1.2.1 + sax: 1.3.0 xmlbuilder: 11.0.1 dev: true @@ -26781,6 +26846,7 @@ packages: /yargs-parser@20.2.4: resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==} engines: {node: '>=10'} + dev: true /yargs-parser@20.2.9: resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} @@ -26842,7 +26908,7 @@ packages: require-directory: 2.1.1 string-width: 4.2.3 y18n: 5.0.8 - yargs-parser: 20.2.4 + yargs-parser: 20.2.9 /yargs@17.7.2: resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index c4e630d5110..6ae1e8a9ff5 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "81d1d2d2a1a13dbfefc99fc2ba27e03fa286cdba", + "pnpmShrinkwrapHash": "dc4624f648069e498a0c46255b0349827d6f9972", "preferredVersionsHash": "40d4640a94cff77f7808a2f1960cc76231eb6f86" } diff --git a/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts b/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts new file mode 100644 index 00000000000..6585fcadf93 --- /dev/null +++ b/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts @@ -0,0 +1,30 @@ +import { DeviceCodeCredential } from '@azure/identity'; +import { ITerminal } from '@rushstack/node-core-library'; +import { IAzureAuthenticationConfiguration, ICredentialResultWithId } from './RushAzureInteractiveAuthPlugin'; + +async function fetchCredentialsUsingDeviceCodeAsync( + deviceCodeCredential: DeviceCodeCredential, + terminal: ITerminal, + options: IAzureAuthenticationConfiguration +): Promise { + const { keyVaultSecretName = '' } = options; + + // const keyVaultCredential: KeyVaultAuthentication = new KeyVaultAuthentication({ + // vaultName: keyVaultName, + // secretName: keyVaultSecretName, + // deviceCodeCredentails: deviceCodeCredential + // }); + + // const keyVaultCoreCredentials: ICredentialResult = + // await keyVaultCredential._getCredentialFromDeviceCodeAsync(terminal, deviceCodeCredential); + const keyVaultCacheId: string = `azure-key-vault|AzurePublicCloud|odsp-web-tests|${keyVaultSecretName}`; + + return { + credentialId: keyVaultCacheId, + credential: { + credentialString: 'succesafjoisaef' + } + }; +} + +export { fetchCredentialsUsingDeviceCodeAsync }; diff --git a/rush.json b/rush.json index 99df570f7ac..c86b1b89644 100644 --- a/rush.json +++ b/rush.json @@ -919,6 +919,12 @@ "reviewCategory": "tests", "shouldPublish": false }, + { + "packageName": "tls-certification-ui", + "projectFolder": "vscode-extensions/tls-certification-ui", + "reviewCategory": "tests", + "shouldPublish": false + }, { "packageName": "ts-command-line-test", "projectFolder": "build-tests/ts-command-line-test", diff --git a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts new file mode 100644 index 00000000000..41553df7b81 --- /dev/null +++ b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import type { IRunScriptOptions } from '@rushstack/heft'; +import { FileSystem } from '@rushstack/node-core-library'; +import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; +import { homedir } from 'node:os'; +import * as path from 'path'; + +export async function runAsync({ heftTaskSession: { logger } }: IRunScriptOptions): Promise { + // const certificateManager: CertificateManager = new CertificateManager(); + // // logger.terminal.writeLine(`Untrusting existing CA certificate`); + // // await certificateManager.untrustCertificateAsync(logger.terminal); + // logger.terminal.writeLine( + // `Obtaining a TLS certificate signed by a local self-signed Certificate Authority` + // ); + // const { + // pemCaCertificate, + // pemCertificate, + // pemKey + // }: ICertificate & { + // pemCaCertificate?: string; + // } = await certificateManager.ensureCertificateAsync(true, logger.terminal); + // if (!pemCertificate || !pemKey) { + // throw new Error(`No certificate available, exiting.`); + // } + // logger.terminal.writeLine(`Trusted TLS certificate successfully obtained`); + // const unresolvedUserFolder: string = homedir(); + // const userProfilePath: string = path.resolve(unresolvedUserFolder); + // if (!FileSystem.exists(userProfilePath)) { + // throw new Error("Unable to determine the current user's home directory"); + // } + // const serveDataPath: string = path.join(userProfilePath, '.rushstack'); + // FileSystem.ensureFolder(serveDataPath); + // const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); + // const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); + // const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); + // if (pemCaCertificate) { + // await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); + // } + // await FileSystem.writeFileAsync(certificatePath, pemCertificate); + // await FileSystem.writeFileAsync(keyPath, pemKey); +} diff --git a/vscode-extensions/tls-certification-ui/.eslintrc.js b/vscode-extensions/tls-certification-ui/.eslintrc.js new file mode 100644 index 00000000000..9d28e9e2a85 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/.eslintrc.js @@ -0,0 +1,13 @@ +// This is a workaround for https://github.com/eslint/eslint/issues/3458 +require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); +// This is a workaround for https://github.com/microsoft/rushstack/issues/3021 +require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); + +module.exports = { + ignorePatterns: ['out', 'dist', '**/*.d.ts'], + extends: [ + 'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool', + 'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals' + ], + parserOptions: { tsconfigRootDir: __dirname } +}; diff --git a/vscode-extensions/tls-certification-ui/.gitignore b/vscode-extensions/tls-certification-ui/.gitignore new file mode 100644 index 00000000000..a9abfdf2fa7 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/.gitignore @@ -0,0 +1,4 @@ +webview/ +.vscode-test/ +*.vsix +.vscodeignore \ No newline at end of file diff --git a/vscode-extensions/tls-certification-ui/.npmignore b/vscode-extensions/tls-certification-ui/.npmignore new file mode 100644 index 00000000000..4724baf483e --- /dev/null +++ b/vscode-extensions/tls-certification-ui/.npmignore @@ -0,0 +1,20 @@ +# Ignore all files by default, to avoid accidentally publishing unintended files. +* + +# Use negative patterns to bring back the specific things we want to publish. +!/bin/** +!/lib/** +!/lib-*/** +!/dist/** +!ThirdPartyNotice.txt +!resources/** +!webview/** + +# Ignore certain patterns that should not get published. +/dist/*.stats.* +/lib/**/test/ +/lib-*/**/test/ +lib/scripts/ +lib-*/scripts/ +*.test.js +*.map diff --git a/vscode-extensions/tls-certification-ui/LICENSE b/vscode-extensions/tls-certification-ui/LICENSE new file mode 100644 index 00000000000..462853efafa --- /dev/null +++ b/vscode-extensions/tls-certification-ui/LICENSE @@ -0,0 +1,24 @@ +rushstack vscode extension + +Copyright (c) Microsoft Corporation. All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vscode-extensions/tls-certification-ui/README.md b/vscode-extensions/tls-certification-ui/README.md new file mode 100644 index 00000000000..12af0566460 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/README.md @@ -0,0 +1,26 @@ +# Rush Stack monorepo tools + + + +This VS Code extension provides various enhancements when working with a TypeScript monorepo +that uses the [Rush Stack](https://rushstack.io/) family of tools. + + +> 🚨 *EARLY PREVIEW RELEASE* 🚨 +> +> Not all features are implemented yet. If you have questions or ideas +> to improve this extension, please [let us know](https://rushstack.io/pages/help/support/). +> Thanks! + + +## Installation + +Install through VS Code extensions. Search for `Rush Stack monorepo tools` + +[Visual Studio Code Market Place: Rush Stack monorepo tools](https://marketplace.visualstudio.com/items?itemName=RushStack.rushstack) + +Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. + +``` +ext install RushStack.rushstack +``` diff --git a/vscode-extensions/tls-certification-ui/config/heft.json b/vscode-extensions/tls-certification-ui/config/heft.json new file mode 100644 index 00000000000..cbe6219e953 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/config/heft.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", + + "extends": "local-node-rig/profiles/default/config/heft.json", + + "aliasesByName": { + "start": { + "actionName": "build-watch", + "defaultParameters": ["--serve"] + } + }, + + "phasesByName": { + "build": { + "cleanFiles": [{ "includeGlobs": ["webview"] }], + "tasksByName": { + "webpack": { + "taskDependencies": ["typescript"], + "taskPlugin": { + "pluginPackage": "@rushstack/heft-webpack5-plugin" + } + }, + "copy-webview": { + "taskPlugin": { + "pluginName": "copy-files-plugin", + "pluginPackage": "@rushstack/heft", + "options": { + "copyOperations": [ + { + "sourcePath": "node_modules/@rushstack/rush-vscode-command-webview/dist", + "destinationFolders": ["webview/rush-command-webview"], + "includeGlobs": ["*.{html,js,txt}"] + } + ] + } + } + } + } + } + } +} diff --git a/vscode-extensions/tls-certification-ui/config/rig.json b/vscode-extensions/tls-certification-ui/config/rig.json new file mode 100644 index 00000000000..9d412b88354 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/config/rig.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + "rigPackageName": "local-node-rig" +} diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json new file mode 100644 index 00000000000..39cdf5c000e --- /dev/null +++ b/vscode-extensions/tls-certification-ui/package.json @@ -0,0 +1,203 @@ +{ + "name": "tls-certification-ui", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "https://github.com/microsoft/rushstack.git", + "directory": "vscode-extensions/tls-certification-ui" + }, + "license": "MIT", + "publisher": "rushstack", + "preview": true, + "displayName": "TLS Certification UI", + "description": "Creates TLS Certificates as a UI Extension", + "homepage": "https://rushstack.io", + "categories": [ + "Formatters", + "Other", + "Extension Packs", + "Visualization" + ], + "keywords": [ + "api-extractor", + "build", + "heft", + "js", + "lockfile", + "monorepo", + "orchestrator", + "rig", + "rush", + "ts", + "tsdoc", + "typescript", + "web" + ], + "galleryBanner": { + "color": "#f0f0f0", + "theme": "light" + }, + "icon": "resources/rushstack-icon.png", + "badges": [ + { + "url": "https://img.shields.io/badge/Rush-db714a", + "href": "https://rushjs.io/", + "description": "Rush build orchestrator" + }, + { + "url": "https://img.shields.io/badge/Heft-db714a", + "href": "https://heft.rushstack.io/", + "description": "Heft toolchain" + }, + { + "url": "https://img.shields.io/badge/Lockfile%20Explorer-db714a", + "href": "https://lfx.rushstack.io/", + "description": "Lockfile Explorer dependency visualizer" + }, + { + "url": "https://img.shields.io/badge/API%20Extractor-db714a", + "href": "https://api-extractor.com/", + "description": "API Extractor review and documentation engine" + }, + { + "url": "https://img.shields.io/badge/TSDoc-db714a", + "href": "https://tsdoc.org", + "description": "TSDoc standard for API doc comments" + }, + { + "url": "https://img.shields.io/badge/Get%20Help-0078d4?label=%F0%9F%97%A8%EF%B8%8F", + "href": "https://rushstack.io/pages/help/support/", + "description": "Rush Stack community support" + } + ], + "main": "./dist/extension.js", + "scripts": { + "build": "heft build --clean", + "build:watch": "heft build-watch", + "vscode:prepublish": "heft build --clean --production", + "deploy": "vsce publish --no-dependencies", + "package": "vsce package --no-dependencies", + "start": "heft start", + "pretest": "npm run build", + "test": "node ./lib/test/runTest.js", + "_phase:build": "heft build --clean", + "_phase:test": "" + }, + "contributes": { + "commands": [ + { + "command": "rushstack.ensureDebugCertificate", + "category": "RushStack", + "title": "Ensure Debug Certificate" + }, + { + "command": "rushstack.saveDebugCertificate", + "category": "RushStack", + "title": "Save Debug Certificate" + } + ], + "taskDefinitions": [ + { + "type": "rush", + "required": [ + "cwd", + "displayName", + "command", + "args" + ], + "properties": { + "cwd": { + "type": "string", + "description": "The working directory for the task" + }, + "displayName": { + "type": "string", + "description": "The display name for the command" + }, + "command": { + "type": "string", + "description": "The command to run" + }, + "args": { + "type": "array", + "description": "The arguments to pass to the command" + } + } + }, + { + "type": "rushx", + "required": [ + "cwd", + "command" + ], + "properties": { + "cwd": { + "type": "string", + "description": "The working directory for the command" + }, + "displayName": { + "type": "string", + "description": "The display name for the command" + }, + "command": { + "type": "string", + "description": "The command to run" + } + } + } + ], + "viewsContainers": { + "activitybar": [ + { + "id": "rushstack", + "title": "Rush Stack", + "icon": "resources/rushstack-icon.svg" + } + ] + }, + "configuration": { + "title": "TLS Certificate UI monorepo tools", + "properties": { + "rushstack.logLevelTLS": { + "type": "string", + "default": "info", + "enum": [ + "info", + "debug" + ], + "description": "The log level to use for the VS Code extension" + } + } + } + }, + "activationEvents": [ + "onView:rushCommands" + ], + "dependencies": { + "@rushstack/node-core-library": "workspace:*", + "@rushstack/rush-sdk": "workspace:*", + "@rushstack/ts-command-line": "workspace:*", + "@rushstack/rush-vscode-command-webview": "workspace:*", + "@rushstack/terminal": "workspace:*", + "@rushstack/debug-certificate-manager": "workspace:*" + }, + "devDependencies": { + "@microsoft/rush-lib": "workspace:*", + "local-node-rig": "workspace:*", + "@rushstack/heft-webpack5-plugin": "workspace:*", + "@rushstack/heft": "workspace:*", + "@rushstack/package-extractor": "workspace:*", + "@rushstack/webpack-preserve-dynamic-require-plugin": "workspace:*", + "@types/glob": "7.1.1", + "@types/mocha": "^9.0.0", + "@types/vscode": "^1.63.0", + "@types/webpack-env": "1.18.0", + "@vscode/test-electron": "^1.6.2", + "glob": "~7.0.5", + "mocha": "^9.1.3", + "vsce": "~2.14.0" + }, + "engines": { + "vscode": "^1.63.0" + } +} diff --git a/vscode-extensions/tls-certification-ui/src/extension.ts b/vscode-extensions/tls-certification-ui/src/extension.ts new file mode 100644 index 00000000000..24b3ba58ae0 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/src/extension.ts @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// The module 'vscode' contains the VS Code extensibility API +// Import the module and reference it with the alias vscode in your code below +import * as vscode from 'vscode'; +import { CertificateManager } from '@rushstack/debug-certificate-manager'; +import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; + +const consoleTerminalProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); + +export const terminal: Terminal = new Terminal(consoleTerminalProvider); + +// this method is called when your extension is activated +// your extension is activated the very first time the command is executed +export async function activate(context: vscode.ExtensionContext): Promise { + //const extensionConfiguration: vscode.WorkspaceConfiguration = + //vscode.workspace.getConfiguration('tls-certification-ui'); + + // terminal.writeLine(`Extension configuration: ${JSON.stringify(extensionConfiguration)}`); + + // const extensionLogLevel: LogLevel | undefined = extensionConfiguration.get('logLevel'); + // if (extensionLogLevel) { + // setLogLevel(extensionLogLevel); + // } + // vscode.window.showInformationMessage('TLS Cetification UI Extension is now active!'); + terminal.writeLine('was here'); + context.subscriptions.push( + vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { + terminal.writeLine('was here 2'); + const manager: CertificateManager = new CertificateManager(); + terminal.writeLine('was here 3'); + const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( + true, + terminal + ); + + terminal.writeLine(`pemCaCertificate: ${pemCaCertificate}`); + terminal.writeLine(`pemCertificate: ${pemCertificate}`); + terminal.writeLine(`pemKey: ${pemKey}`); + + if (pemCaCertificate && pemCertificate && pemKey) { + await vscode.window.showInformationMessage('Certificate successfully generated'); + } else { + await vscode.window.showErrorMessage('Certificate was not generated'); + } + + await vscode.commands.executeCommand( + 'rushstack.saveDebugCertificate', + pemCaCertificate, + pemCertificate, + pemKey + ); + }) + ); +} + +// this method is called when your extension is deactivated +export function deactivate(): void {} diff --git a/vscode-extensions/tls-certification-ui/src/logic/logger.ts b/vscode-extensions/tls-certification-ui/src/logic/logger.ts new file mode 100644 index 00000000000..cc281933961 --- /dev/null +++ b/vscode-extensions/tls-certification-ui/src/logic/logger.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; + +const consoleTerminalProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); + +export const terminal: Terminal = new Terminal(consoleTerminalProvider); + +export type LogLevel = 'info' | 'debug'; + +export const setLogLevel = (level: LogLevel): void => { + switch (level) { + case 'debug': { + consoleTerminalProvider.debugEnabled = true; + break; + } + case 'info': + default: { + consoleTerminalProvider.debugEnabled = false; + break; + } + } +}; diff --git a/vscode-extensions/tls-certification-ui/tsconfig.json b/vscode-extensions/tls-certification-ui/tsconfig.json new file mode 100644 index 00000000000..a42ac59b34b --- /dev/null +++ b/vscode-extensions/tls-certification-ui/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json", + "compilerOptions": { + "lib": ["es2015", "DOM"], + "types": ["mocha", "node", "webpack-env"] + } +} diff --git a/vscode-extensions/tls-certification-ui/webpack.config.js b/vscode-extensions/tls-certification-ui/webpack.config.js new file mode 100644 index 00000000000..7e35e8bdc3f --- /dev/null +++ b/vscode-extensions/tls-certification-ui/webpack.config.js @@ -0,0 +1,49 @@ +// @ts-check +/* eslint-env es6 */ + +'use strict'; + +const path = require('path'); +// eslint-disable-next-line @typescript-eslint/naming-convention +const { PreserveDynamicRequireWebpackPlugin } = require('@rushstack/webpack-preserve-dynamic-require-plugin'); + +// @ts-check +/** @typedef {import('webpack').Configuration} WebpackConfig **/ + +function createExtensionConfig({ production, webpack }) { + /** @type WebpackConfig */ + const extensionConfig = { + target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ + mode: production ? 'production' : 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + + entry: './lib/extension.js', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ + output: { + // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ + path: path.resolve(__dirname, 'dist'), + filename: 'extension.js', + libraryTarget: 'commonjs2' + }, + externals: { + // eslint-disable-next-line @typescript-eslint/naming-convention + '@microsoft/rush-lib': 'commonjs @microsoft/rush-lib', + vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ + // modules added here also need to be added in the .vscodeignore file + }, + devtool: production ? 'hidden-source-map' : 'source-map', + infrastructureLogging: { + level: 'log' // enables logging required for problem matchers + }, + plugins: [ + // @ts-ignore + new PreserveDynamicRequireWebpackPlugin(), + new webpack.DefinePlugin({ + ___DEV___: JSON.stringify(!production) + }) + ], + optimization: { + minimize: false // Ensure licenses are included in the bundle + } + }; + return extensionConfig; +} +module.exports = createExtensionConfig; From 02c6457c004422d4d65b474981d26a42b350bdd1 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:31:08 -0800 Subject: [PATCH 04/13] remove comments --- vscode-extensions/tls-certification-ui/src/extension.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/vscode-extensions/tls-certification-ui/src/extension.ts b/vscode-extensions/tls-certification-ui/src/extension.ts index 24b3ba58ae0..316bda3537e 100644 --- a/vscode-extensions/tls-certification-ui/src/extension.ts +++ b/vscode-extensions/tls-certification-ui/src/extension.ts @@ -24,12 +24,9 @@ export async function activate(context: vscode.ExtensionContext): Promise // setLogLevel(extensionLogLevel); // } // vscode.window.showInformationMessage('TLS Cetification UI Extension is now active!'); - terminal.writeLine('was here'); context.subscriptions.push( vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { - terminal.writeLine('was here 2'); const manager: CertificateManager = new CertificateManager(); - terminal.writeLine('was here 3'); const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( true, terminal From 2772adc8d30ad8005bae92b168cf6b12e749438b Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:57:26 -0800 Subject: [PATCH 05/13] removed changes to rush-vscode-extension and created ui and workspace tls certification extensions --- .vscode/launch.json | 13 ++ .../tls-certification-workspace | 45 ++++ .../rush/browser-approved-packages.json | 8 + common/config/rush/pnpm-lock.yaml | 72 ++++++- common/config/rush/repo-state.json | 2 +- rush.json | 8 +- .../rush-vscode-extension/config/heft.json | 10 - .../rush-vscode-extension/package.json | 3 +- .../rush-vscode-extension/src/extension.ts | 45 ---- .../src/scripts/generate-tls-certificate.ts | 43 ---- .../tls-certification-ui/.eslintrc.js | 13 -- .../tls-certification-ui/package.json | 2 +- .../tls-certification-ui/src/extension.ts | 14 +- .../tls-certification-workspace/.gitignore | 4 + .../tls-certification-workspace/.npmignore | 20 ++ .../tls-certification-workspace/LICENSE | 24 +++ .../tls-certification-workspace/README.md | 26 +++ .../config/heft.json | 41 ++++ .../config/rig.json | 5 + .../tls-certification-workspace/package.json | 204 ++++++++++++++++++ .../src/extension.ts | 45 ++++ .../tls-certification-workspace/tsconfig.json | 7 + .../webpack.config.js | 49 +++++ 23 files changed, 570 insertions(+), 133 deletions(-) create mode 100644 common/config/azure-pipelines/tls-certification-workspace delete mode 100644 vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts delete mode 100644 vscode-extensions/tls-certification-ui/.eslintrc.js create mode 100644 vscode-extensions/tls-certification-workspace/.gitignore create mode 100644 vscode-extensions/tls-certification-workspace/.npmignore create mode 100644 vscode-extensions/tls-certification-workspace/LICENSE create mode 100644 vscode-extensions/tls-certification-workspace/README.md create mode 100644 vscode-extensions/tls-certification-workspace/config/heft.json create mode 100644 vscode-extensions/tls-certification-workspace/config/rig.json create mode 100644 vscode-extensions/tls-certification-workspace/package.json create mode 100644 vscode-extensions/tls-certification-workspace/src/extension.ts create mode 100644 vscode-extensions/tls-certification-workspace/tsconfig.json create mode 100644 vscode-extensions/tls-certification-workspace/webpack.config.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 3218261cb33..d50b3cb084a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -95,6 +95,19 @@ "${workspaceFolder}/vscode-extensions/tls-certification-ui/dist/**/*.js" ] // "preLaunchTask": "npm: build:watch - vscode-extensions/tls-certification-ui" + }, + { + "name": "Launch TLS Certification Workspace", + "type": "extensionHost", + "request": "launch", + "cwd": "${workspaceFolder}/vscode-extensions/tls-certification-workspace", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/tls-certification-workspace" + ], + "outFiles": [ + "${workspaceFolder}/vscode-extensions/tls-certification-workspace/dist/**/*.js" + ] + // "preLaunchTask": "npm: build:watch - vscode-extensions/tls-certification-workspace" } ] } diff --git a/common/config/azure-pipelines/tls-certification-workspace b/common/config/azure-pipelines/tls-certification-workspace new file mode 100644 index 00000000000..5319d39e8e5 --- /dev/null +++ b/common/config/azure-pipelines/tls-certification-workspace @@ -0,0 +1,45 @@ +variables: + - name: FORCE_COLOR + value: 1 + +resources: + repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines + parameters: + pool: + name: Azure-Pipelines-1ESPT-ExDShared + os: windows + stages: + - stage: + jobs: + - job: + pool: + name: publish-tls-certification-workspace + os: linux + steps: + - checkout: self + persistCredentials: true + + - template: /common/config/azure-pipelines/templates/install-node.yaml@self + + - template: /common/config/azure-pipelines/templates/build.yaml@self + parameters: + BuildParameters: > + --to rushstack + PerformValidation: false + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js package + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace + displayName: 'Package tls certification workspace extension' + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js deploy + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace + displayName: 'Publish tls certification workspace extension' + env: + VSCE_PAT: $(vscePat) diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json index fdb13d57bcc..8fd78fe4b8a 100644 --- a/common/config/rush/browser-approved-packages.json +++ b/common/config/rush/browser-approved-packages.json @@ -50,6 +50,14 @@ "name": "@rushstack/rush-vscode-command-webview", "allowedCategories": [ "tests", "vscode-extensions" ] }, + { + "name": "@rushstack/tls-certification-ui", + "allowedCategories": [ "tests" ] + }, + { + "name": "@rushstack/tls-certificcation-ui", + "allowedCategories": [ "tests" ] + }, { "name": "axios", "allowedCategories": [ "libraries" ] diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 396caf56ee0..8671f10872a 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1774,7 +1774,7 @@ importers: version: 29.5.12 '@types/node': specifier: ts4.9 - version: 20.11.24 + version: 20.11.25 eslint: specifier: ~8.7.0 version: 8.7.0(supports-color@8.1.1) @@ -4060,6 +4060,67 @@ importers: version: 4.5.0 ../../vscode-extensions/rush-vscode-extension: + dependencies: + '@rushstack/node-core-library': + specifier: workspace:* + version: link:../../libraries/node-core-library + '@rushstack/rush-sdk': + specifier: workspace:* + version: link:../../libraries/rush-sdk + '@rushstack/rush-vscode-command-webview': + specifier: workspace:* + version: link:../rush-vscode-command-webview + '@rushstack/terminal': + specifier: workspace:* + version: link:../../libraries/terminal + '@rushstack/ts-command-line': + specifier: workspace:* + version: link:../../libraries/ts-command-line + devDependencies: + '@microsoft/rush-lib': + specifier: workspace:* + version: link:../../libraries/rush-lib + '@rushstack/heft': + specifier: workspace:* + version: link:../../apps/heft + '@rushstack/heft-webpack5-plugin': + specifier: workspace:* + version: link:../../heft-plugins/heft-webpack5-plugin + '@rushstack/package-extractor': + specifier: workspace:* + version: link:../../libraries/package-extractor + '@rushstack/webpack-preserve-dynamic-require-plugin': + specifier: workspace:* + version: link:../../webpack/preserve-dynamic-require-plugin + '@types/glob': + specifier: 7.1.1 + version: 7.1.1 + '@types/mocha': + specifier: ^9.0.0 + version: 9.1.1 + '@types/vscode': + specifier: ^1.63.0 + version: 1.86.0 + '@types/webpack-env': + specifier: 1.18.0 + version: 1.18.0 + '@vscode/test-electron': + specifier: ^1.6.2 + version: 1.6.2 + glob: + specifier: ~7.0.5 + version: 7.0.6 + local-node-rig: + specifier: workspace:* + version: link:../../rigs/local-node-rig + mocha: + specifier: ^9.1.3 + version: 9.2.2 + vsce: + specifier: ~2.14.0 + version: 2.14.0 + + ../../vscode-extensions/tls-certification-ui: dependencies: '@rushstack/debug-certificate-manager': specifier: workspace:* @@ -4123,7 +4184,7 @@ importers: specifier: ~2.14.0 version: 2.14.0 - ../../vscode-extensions/tls-certification-ui: + ../../vscode-extensions/tls-certification-workspace: dependencies: '@rushstack/debug-certificate-manager': specifier: workspace:* @@ -4140,6 +4201,9 @@ importers: '@rushstack/terminal': specifier: workspace:* version: link:../../libraries/terminal + '@rushstack/tls-certification-ui': + specifier: workspace:* + version: link:../tls-certification-ui '@rushstack/ts-command-line': specifier: workspace:* version: link:../../libraries/ts-command-line @@ -11841,8 +11905,8 @@ packages: /@types/node@18.17.15: resolution: {integrity: sha512-2yrWpBk32tvV/JAd3HNHWuZn/VDN1P+72hWirHnvsvTGSqbANi+kSeuQR9yAHnbvaBvHDsoTdXV0Fe+iRtHLKA==} - /@types/node@20.11.24: - resolution: {integrity: sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==} + /@types/node@20.11.25: + resolution: {integrity: sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==} dependencies: undici-types: 5.26.5 dev: true diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 6ae1e8a9ff5..09dd543d903 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "dc4624f648069e498a0c46255b0349827d6f9972", + "pnpmShrinkwrapHash": "4023da3135d905aa214198bb4bbcb3e55c274b6c", "preferredVersionsHash": "40d4640a94cff77f7808a2f1960cc76231eb6f86" } diff --git a/rush.json b/rush.json index c86b1b89644..956123e5af5 100644 --- a/rush.json +++ b/rush.json @@ -920,11 +920,17 @@ "shouldPublish": false }, { - "packageName": "tls-certification-ui", + "packageName": "@rushstack/tls-certification-ui", "projectFolder": "vscode-extensions/tls-certification-ui", "reviewCategory": "tests", "shouldPublish": false }, + { + "packageName": "@rushstack/tls-certification-workspace", + "projectFolder": "vscode-extensions/tls-certification-workspace", + "reviewCategory": "tests", + "shouldPublish": false + }, { "packageName": "ts-command-line-test", "projectFolder": "build-tests/ts-command-line-test", diff --git a/vscode-extensions/rush-vscode-extension/config/heft.json b/vscode-extensions/rush-vscode-extension/config/heft.json index 00c1daf5d3b..15b954e3644 100644 --- a/vscode-extensions/rush-vscode-extension/config/heft.json +++ b/vscode-extensions/rush-vscode-extension/config/heft.json @@ -44,16 +44,6 @@ "scriptPath": "lib/scripts/generate-vscodeignore.js" } } - }, - "generate-tls-certificate": { - "taskDependencies": ["copy-webview", "typescript", "webpack"], - "taskPlugin": { - "pluginPackage": "@rushstack/heft", - "pluginName": "run-script-plugin", - "options": { - "scriptPath": "lib/scripts/generate-tls-certificate.js" - } - } } } } diff --git a/vscode-extensions/rush-vscode-extension/package.json b/vscode-extensions/rush-vscode-extension/package.json index 408b9e79485..966d18d162f 100644 --- a/vscode-extensions/rush-vscode-extension/package.json +++ b/vscode-extensions/rush-vscode-extension/package.json @@ -260,8 +260,7 @@ "@rushstack/rush-sdk": "workspace:*", "@rushstack/ts-command-line": "workspace:*", "@rushstack/rush-vscode-command-webview": "workspace:*", - "@rushstack/terminal": "workspace:*", - "@rushstack/debug-certificate-manager": "workspace:*" + "@rushstack/terminal": "workspace:*" }, "devDependencies": { "@microsoft/rush-lib": "workspace:*", diff --git a/vscode-extensions/rush-vscode-extension/src/extension.ts b/vscode-extensions/rush-vscode-extension/src/extension.ts index 5b7ca98d7c6..f9034d3eed5 100644 --- a/vscode-extensions/rush-vscode-extension/src/extension.ts +++ b/vscode-extensions/rush-vscode-extension/src/extension.ts @@ -9,15 +9,10 @@ import { RushWorkspace } from './logic/RushWorkspace'; import { RushProjectsProvider } from './providers/RushProjectsProvider'; import { RushTaskProvider } from './providers/TaskProvider'; import { RushCommandWebViewPanel } from './logic/RushCommandWebViewPanel'; -import { FileSystem } from '@rushstack/node-core-library'; -import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; -import { homedir } from 'node:os'; -import * as path from 'path'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext): Promise { - vscode.window.showInformationMessage('Rush Stack extension is now active!'); context.subscriptions.push( vscode.commands.registerCommand('rushstack.selectWorkspace', async () => { await RushWorkspace.selectWorkspace(); @@ -65,46 +60,6 @@ export async function activate(context: vscode.ExtensionContext): Promise RushCommandWebViewPanel.initialize(context).reveal(); } - - const certificateManager: CertificateManager = new CertificateManager(); - - // logger.terminal.writeLine(`Untrusting existing CA certificate`); - // await certificateManager.untrustCertificateAsync(logger.terminal); - - terminal.writeLine(`Obtaining a TLS certificate signed by a local self-signed Certificate Authority`); - - const { - pemCaCertificate, - pemCertificate, - pemKey - }: ICertificate & { - pemCaCertificate?: string; - } = await certificateManager.ensureCertificateAsync(true, terminal); - - if (!pemCertificate || !pemKey) { - throw new Error(`No certificate available, exiting.`); - } - terminal.writeLine(`Trusted TLS certificate successfully obtained`); - - const unresolvedUserFolder: string = homedir(); - const userProfilePath: string = path.resolve(unresolvedUserFolder); - if (!FileSystem.exists(userProfilePath)) { - throw new Error("Unable to determine the current user's home directory"); - } - - const serveDataPath: string = path.join(userProfilePath, '.rushstack'); - FileSystem.ensureFolder(serveDataPath); - - const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); - const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); - const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); - - if (pemCaCertificate) { - await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); - } - - await FileSystem.writeFileAsync(certificatePath, pemCertificate); - await FileSystem.writeFileAsync(keyPath, pemKey); } // this method is called when your extension is deactivated diff --git a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts b/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts deleted file mode 100644 index 41553df7b81..00000000000 --- a/vscode-extensions/rush-vscode-extension/src/scripts/generate-tls-certificate.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. -// See LICENSE in the project root for license information. - -import type { IRunScriptOptions } from '@rushstack/heft'; -import { FileSystem } from '@rushstack/node-core-library'; -import { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager'; -import { homedir } from 'node:os'; -import * as path from 'path'; - -export async function runAsync({ heftTaskSession: { logger } }: IRunScriptOptions): Promise { - // const certificateManager: CertificateManager = new CertificateManager(); - // // logger.terminal.writeLine(`Untrusting existing CA certificate`); - // // await certificateManager.untrustCertificateAsync(logger.terminal); - // logger.terminal.writeLine( - // `Obtaining a TLS certificate signed by a local self-signed Certificate Authority` - // ); - // const { - // pemCaCertificate, - // pemCertificate, - // pemKey - // }: ICertificate & { - // pemCaCertificate?: string; - // } = await certificateManager.ensureCertificateAsync(true, logger.terminal); - // if (!pemCertificate || !pemKey) { - // throw new Error(`No certificate available, exiting.`); - // } - // logger.terminal.writeLine(`Trusted TLS certificate successfully obtained`); - // const unresolvedUserFolder: string = homedir(); - // const userProfilePath: string = path.resolve(unresolvedUserFolder); - // if (!FileSystem.exists(userProfilePath)) { - // throw new Error("Unable to determine the current user's home directory"); - // } - // const serveDataPath: string = path.join(userProfilePath, '.rushstack'); - // FileSystem.ensureFolder(serveDataPath); - // const caCertificatePath: string = path.join(serveDataPath, 'rushstack-ca.pem'); - // const certificatePath: string = path.join(serveDataPath, 'rushstack-serve.pem'); - // const keyPath: string = path.join(serveDataPath, 'rushstack-serve.key'); - // if (pemCaCertificate) { - // await FileSystem.writeFileAsync(caCertificatePath, pemCaCertificate); - // } - // await FileSystem.writeFileAsync(certificatePath, pemCertificate); - // await FileSystem.writeFileAsync(keyPath, pemKey); -} diff --git a/vscode-extensions/tls-certification-ui/.eslintrc.js b/vscode-extensions/tls-certification-ui/.eslintrc.js deleted file mode 100644 index 9d28e9e2a85..00000000000 --- a/vscode-extensions/tls-certification-ui/.eslintrc.js +++ /dev/null @@ -1,13 +0,0 @@ -// This is a workaround for https://github.com/eslint/eslint/issues/3458 -require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); -// This is a workaround for https://github.com/microsoft/rushstack/issues/3021 -require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); - -module.exports = { - ignorePatterns: ['out', 'dist', '**/*.d.ts'], - extends: [ - 'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool', - 'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals' - ], - parserOptions: { tsconfigRootDir: __dirname } -}; diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json index 39cdf5c000e..e73d073869b 100644 --- a/vscode-extensions/tls-certification-ui/package.json +++ b/vscode-extensions/tls-certification-ui/package.json @@ -1,5 +1,5 @@ { - "name": "tls-certification-ui", + "name": "@rushstack/tls-certification-ui", "version": "0.0.1", "repository": { "type": "git", diff --git a/vscode-extensions/tls-certification-ui/src/extension.ts b/vscode-extensions/tls-certification-ui/src/extension.ts index 316bda3537e..6a73b8aa83d 100644 --- a/vscode-extensions/tls-certification-ui/src/extension.ts +++ b/vscode-extensions/tls-certification-ui/src/extension.ts @@ -14,16 +14,8 @@ export const terminal: Terminal = new Terminal(consoleTerminalProvider); // this method is called when your extension is activated // your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext): Promise { - //const extensionConfiguration: vscode.WorkspaceConfiguration = - //vscode.workspace.getConfiguration('tls-certification-ui'); + vscode.window.showInformationMessage('TLS Cetification UI Extension is now active!'); - // terminal.writeLine(`Extension configuration: ${JSON.stringify(extensionConfiguration)}`); - - // const extensionLogLevel: LogLevel | undefined = extensionConfiguration.get('logLevel'); - // if (extensionLogLevel) { - // setLogLevel(extensionLogLevel); - // } - // vscode.window.showInformationMessage('TLS Cetification UI Extension is now active!'); context.subscriptions.push( vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { const manager: CertificateManager = new CertificateManager(); @@ -32,10 +24,6 @@ export async function activate(context: vscode.ExtensionContext): Promise terminal ); - terminal.writeLine(`pemCaCertificate: ${pemCaCertificate}`); - terminal.writeLine(`pemCertificate: ${pemCertificate}`); - terminal.writeLine(`pemKey: ${pemKey}`); - if (pemCaCertificate && pemCertificate && pemKey) { await vscode.window.showInformationMessage('Certificate successfully generated'); } else { diff --git a/vscode-extensions/tls-certification-workspace/.gitignore b/vscode-extensions/tls-certification-workspace/.gitignore new file mode 100644 index 00000000000..a9abfdf2fa7 --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/.gitignore @@ -0,0 +1,4 @@ +webview/ +.vscode-test/ +*.vsix +.vscodeignore \ No newline at end of file diff --git a/vscode-extensions/tls-certification-workspace/.npmignore b/vscode-extensions/tls-certification-workspace/.npmignore new file mode 100644 index 00000000000..4724baf483e --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/.npmignore @@ -0,0 +1,20 @@ +# Ignore all files by default, to avoid accidentally publishing unintended files. +* + +# Use negative patterns to bring back the specific things we want to publish. +!/bin/** +!/lib/** +!/lib-*/** +!/dist/** +!ThirdPartyNotice.txt +!resources/** +!webview/** + +# Ignore certain patterns that should not get published. +/dist/*.stats.* +/lib/**/test/ +/lib-*/**/test/ +lib/scripts/ +lib-*/scripts/ +*.test.js +*.map diff --git a/vscode-extensions/tls-certification-workspace/LICENSE b/vscode-extensions/tls-certification-workspace/LICENSE new file mode 100644 index 00000000000..462853efafa --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/LICENSE @@ -0,0 +1,24 @@ +rushstack vscode extension + +Copyright (c) Microsoft Corporation. All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vscode-extensions/tls-certification-workspace/README.md b/vscode-extensions/tls-certification-workspace/README.md new file mode 100644 index 00000000000..12af0566460 --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/README.md @@ -0,0 +1,26 @@ +# Rush Stack monorepo tools + + + +This VS Code extension provides various enhancements when working with a TypeScript monorepo +that uses the [Rush Stack](https://rushstack.io/) family of tools. + + +> 🚨 *EARLY PREVIEW RELEASE* 🚨 +> +> Not all features are implemented yet. If you have questions or ideas +> to improve this extension, please [let us know](https://rushstack.io/pages/help/support/). +> Thanks! + + +## Installation + +Install through VS Code extensions. Search for `Rush Stack monorepo tools` + +[Visual Studio Code Market Place: Rush Stack monorepo tools](https://marketplace.visualstudio.com/items?itemName=RushStack.rushstack) + +Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. + +``` +ext install RushStack.rushstack +``` diff --git a/vscode-extensions/tls-certification-workspace/config/heft.json b/vscode-extensions/tls-certification-workspace/config/heft.json new file mode 100644 index 00000000000..cbe6219e953 --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/config/heft.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", + + "extends": "local-node-rig/profiles/default/config/heft.json", + + "aliasesByName": { + "start": { + "actionName": "build-watch", + "defaultParameters": ["--serve"] + } + }, + + "phasesByName": { + "build": { + "cleanFiles": [{ "includeGlobs": ["webview"] }], + "tasksByName": { + "webpack": { + "taskDependencies": ["typescript"], + "taskPlugin": { + "pluginPackage": "@rushstack/heft-webpack5-plugin" + } + }, + "copy-webview": { + "taskPlugin": { + "pluginName": "copy-files-plugin", + "pluginPackage": "@rushstack/heft", + "options": { + "copyOperations": [ + { + "sourcePath": "node_modules/@rushstack/rush-vscode-command-webview/dist", + "destinationFolders": ["webview/rush-command-webview"], + "includeGlobs": ["*.{html,js,txt}"] + } + ] + } + } + } + } + } + } +} diff --git a/vscode-extensions/tls-certification-workspace/config/rig.json b/vscode-extensions/tls-certification-workspace/config/rig.json new file mode 100644 index 00000000000..9d412b88354 --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/config/rig.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + "rigPackageName": "local-node-rig" +} diff --git a/vscode-extensions/tls-certification-workspace/package.json b/vscode-extensions/tls-certification-workspace/package.json new file mode 100644 index 00000000000..fa707beb07f --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/package.json @@ -0,0 +1,204 @@ +{ + "name": "@rushstack/tls-certification-workspace", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "https://github.com/microsoft/rushstack.git", + "directory": "vscode-extensions/tls-certification-workspace" + }, + "license": "MIT", + "publisher": "rushstack", + "preview": true, + "displayName": "TLS Certification Workspace", + "description": "Creates TLS Certificates as a Workspace Extension", + "homepage": "https://rushstack.io", + "categories": [ + "Formatters", + "Other", + "Extension Packs", + "Visualization" + ], + "keywords": [ + "api-extractor", + "build", + "heft", + "js", + "lockfile", + "monorepo", + "orchestrator", + "rig", + "rush", + "ts", + "tsdoc", + "typescript", + "web" + ], + "galleryBanner": { + "color": "#f0f0f0", + "theme": "light" + }, + "icon": "resources/rushstack-icon.png", + "badges": [ + { + "url": "https://img.shields.io/badge/Rush-db714a", + "href": "https://rushjs.io/", + "description": "Rush build orchestrator" + }, + { + "url": "https://img.shields.io/badge/Heft-db714a", + "href": "https://heft.rushstack.io/", + "description": "Heft toolchain" + }, + { + "url": "https://img.shields.io/badge/Lockfile%20Explorer-db714a", + "href": "https://lfx.rushstack.io/", + "description": "Lockfile Explorer dependency visualizer" + }, + { + "url": "https://img.shields.io/badge/API%20Extractor-db714a", + "href": "https://api-extractor.com/", + "description": "API Extractor review and documentation engine" + }, + { + "url": "https://img.shields.io/badge/TSDoc-db714a", + "href": "https://tsdoc.org", + "description": "TSDoc standard for API doc comments" + }, + { + "url": "https://img.shields.io/badge/Get%20Help-0078d4?label=%F0%9F%97%A8%EF%B8%8F", + "href": "https://rushstack.io/pages/help/support/", + "description": "Rush Stack community support" + } + ], + "main": "./dist/extension.js", + "scripts": { + "build": "heft build --clean", + "build:watch": "heft build-watch", + "vscode:prepublish": "heft build --clean --production", + "deploy": "vsce publish --no-dependencies", + "package": "vsce package --no-dependencies", + "start": "heft start", + "pretest": "npm run build", + "test": "node ./lib/test/runTest.js", + "_phase:build": "heft build --clean", + "_phase:test": "" + }, + "contributes": { + "commands": [ + { + "command": "rushstack.ensureDebugCertificate", + "category": "RushStack", + "title": "Ensure Debug Certificate" + }, + { + "command": "rushstack.saveDebugCertificate", + "category": "RushStack", + "title": "Save Debug Certificate" + } + ], + "taskDefinitions": [ + { + "type": "rush", + "required": [ + "cwd", + "displayName", + "command", + "args" + ], + "properties": { + "cwd": { + "type": "string", + "description": "The working directory for the task" + }, + "displayName": { + "type": "string", + "description": "The display name for the command" + }, + "command": { + "type": "string", + "description": "The command to run" + }, + "args": { + "type": "array", + "description": "The arguments to pass to the command" + } + } + }, + { + "type": "rushx", + "required": [ + "cwd", + "command" + ], + "properties": { + "cwd": { + "type": "string", + "description": "The working directory for the command" + }, + "displayName": { + "type": "string", + "description": "The display name for the command" + }, + "command": { + "type": "string", + "description": "The command to run" + } + } + } + ], + "viewsContainers": { + "activitybar": [ + { + "id": "rushstack", + "title": "Rush Stack", + "icon": "resources/rushstack-icon.svg" + } + ] + }, + "configuration": { + "title": "TLS Certificate Workspace monorepo tools", + "properties": { + "rushstack.logLevelTLS": { + "type": "string", + "default": "info", + "enum": [ + "info", + "debug" + ], + "description": "The log level to use for the VS Code extension" + } + } + } + }, + "activationEvents": [ + "onView:rushCommands" + ], + "dependencies": { + "@rushstack/node-core-library": "workspace:*", + "@rushstack/rush-sdk": "workspace:*", + "@rushstack/ts-command-line": "workspace:*", + "@rushstack/rush-vscode-command-webview": "workspace:*", + "@rushstack/terminal": "workspace:*", + "@rushstack/debug-certificate-manager": "workspace:*", + "@rushstack/tls-certification-ui": "workspace:*" + }, + "devDependencies": { + "@microsoft/rush-lib": "workspace:*", + "local-node-rig": "workspace:*", + "@rushstack/heft-webpack5-plugin": "workspace:*", + "@rushstack/heft": "workspace:*", + "@rushstack/package-extractor": "workspace:*", + "@rushstack/webpack-preserve-dynamic-require-plugin": "workspace:*", + "@types/glob": "7.1.1", + "@types/mocha": "^9.0.0", + "@types/vscode": "^1.63.0", + "@types/webpack-env": "1.18.0", + "@vscode/test-electron": "^1.6.2", + "glob": "~7.0.5", + "mocha": "^9.1.3", + "vsce": "~2.14.0" + }, + "engines": { + "vscode": "^1.63.0" + } +} diff --git a/vscode-extensions/tls-certification-workspace/src/extension.ts b/vscode-extensions/tls-certification-workspace/src/extension.ts new file mode 100644 index 00000000000..76641501288 --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/src/extension.ts @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// The module 'vscode' contains the VS Code extensibility API +// Import the module and reference it with the alias vscode in your code below +import * as vscode from 'vscode'; +import { CertificateManager } from '@rushstack/debug-certificate-manager'; +import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; + +const consoleTerminalProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); + +export const terminal: Terminal = new Terminal(consoleTerminalProvider); + +// this method is called when your extension is activated +// your extension is activated the very first time the command is executed +export async function activate(context: vscode.ExtensionContext): Promise { + vscode.window.showInformationMessage('TLS Cetification Workspace Extension is now active!'); + + context.subscriptions.push( + vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { + const manager: CertificateManager = new CertificateManager(); + + const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( + true, + terminal + ); + + if (pemCaCertificate && pemCertificate && pemKey) { + await vscode.window.showInformationMessage('Certificate successfully generated'); + } else { + await vscode.window.showErrorMessage('Certificate was not generated'); + } + + await vscode.commands.executeCommand( + 'rushstack.saveDebugCertificate', + pemCaCertificate, + pemCertificate, + pemKey + ); + }) + ); +} + +// this method is called when your extension is deactivated +export function deactivate(): void {} diff --git a/vscode-extensions/tls-certification-workspace/tsconfig.json b/vscode-extensions/tls-certification-workspace/tsconfig.json new file mode 100644 index 00000000000..a42ac59b34b --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json", + "compilerOptions": { + "lib": ["es2015", "DOM"], + "types": ["mocha", "node", "webpack-env"] + } +} diff --git a/vscode-extensions/tls-certification-workspace/webpack.config.js b/vscode-extensions/tls-certification-workspace/webpack.config.js new file mode 100644 index 00000000000..7e35e8bdc3f --- /dev/null +++ b/vscode-extensions/tls-certification-workspace/webpack.config.js @@ -0,0 +1,49 @@ +// @ts-check +/* eslint-env es6 */ + +'use strict'; + +const path = require('path'); +// eslint-disable-next-line @typescript-eslint/naming-convention +const { PreserveDynamicRequireWebpackPlugin } = require('@rushstack/webpack-preserve-dynamic-require-plugin'); + +// @ts-check +/** @typedef {import('webpack').Configuration} WebpackConfig **/ + +function createExtensionConfig({ production, webpack }) { + /** @type WebpackConfig */ + const extensionConfig = { + target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ + mode: production ? 'production' : 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + + entry: './lib/extension.js', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ + output: { + // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ + path: path.resolve(__dirname, 'dist'), + filename: 'extension.js', + libraryTarget: 'commonjs2' + }, + externals: { + // eslint-disable-next-line @typescript-eslint/naming-convention + '@microsoft/rush-lib': 'commonjs @microsoft/rush-lib', + vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ + // modules added here also need to be added in the .vscodeignore file + }, + devtool: production ? 'hidden-source-map' : 'source-map', + infrastructureLogging: { + level: 'log' // enables logging required for problem matchers + }, + plugins: [ + // @ts-ignore + new PreserveDynamicRequireWebpackPlugin(), + new webpack.DefinePlugin({ + ___DEV___: JSON.stringify(!production) + }) + ], + optimization: { + minimize: false // Ensure licenses are included in the bundle + } + }; + return extensionConfig; +} +module.exports = createExtensionConfig; From 2db45c46607a43c2fc05572f357766006f5ed486 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:38:05 -0700 Subject: [PATCH 06/13] extensions can run separatly --- common/config/rush/browser-approved-packages.json | 4 ++++ common/config/rush/pnpm-lock.yaml | 6 +++--- rush.json | 4 ++-- vscode-extensions/tls-certification-ui/package.json | 9 +++++++-- .../tls-certification-workspace/package.json | 5 ++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json index 8fd78fe4b8a..4dc40e902e6 100644 --- a/common/config/rush/browser-approved-packages.json +++ b/common/config/rush/browser-approved-packages.json @@ -102,6 +102,10 @@ "name": "scheduler", "allowedCategories": [ "vscode-extensions" ] }, + { + "name": "tls-certification-workspace", + "allowedCategories": [ "tests" ] + }, { "name": "tslib", "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 8671f10872a..292d78ccf3e 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -4140,6 +4140,9 @@ importers: '@rushstack/ts-command-line': specifier: workspace:* version: link:../../libraries/ts-command-line + tls-certification-workspace: + specifier: workspace:* + version: link:../tls-certification-workspace devDependencies: '@microsoft/rush-lib': specifier: workspace:* @@ -4201,9 +4204,6 @@ importers: '@rushstack/terminal': specifier: workspace:* version: link:../../libraries/terminal - '@rushstack/tls-certification-ui': - specifier: workspace:* - version: link:../tls-certification-ui '@rushstack/ts-command-line': specifier: workspace:* version: link:../../libraries/ts-command-line diff --git a/rush.json b/rush.json index 956123e5af5..8f51f367aae 100644 --- a/rush.json +++ b/rush.json @@ -920,13 +920,13 @@ "shouldPublish": false }, { - "packageName": "@rushstack/tls-certification-ui", + "packageName": "tls-certification-ui", "projectFolder": "vscode-extensions/tls-certification-ui", "reviewCategory": "tests", "shouldPublish": false }, { - "packageName": "@rushstack/tls-certification-workspace", + "packageName": "tls-certification-workspace", "projectFolder": "vscode-extensions/tls-certification-workspace", "reviewCategory": "tests", "shouldPublish": false diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json index e73d073869b..84e2fc0668c 100644 --- a/vscode-extensions/tls-certification-ui/package.json +++ b/vscode-extensions/tls-certification-ui/package.json @@ -1,5 +1,5 @@ { - "name": "@rushstack/tls-certification-ui", + "name": "tls-certification-ui", "version": "0.0.1", "repository": { "type": "git", @@ -12,6 +12,7 @@ "displayName": "TLS Certification UI", "description": "Creates TLS Certificates as a UI Extension", "homepage": "https://rushstack.io", + "api": "none", "categories": [ "Formatters", "Other", @@ -179,7 +180,8 @@ "@rushstack/ts-command-line": "workspace:*", "@rushstack/rush-vscode-command-webview": "workspace:*", "@rushstack/terminal": "workspace:*", - "@rushstack/debug-certificate-manager": "workspace:*" + "@rushstack/debug-certificate-manager": "workspace:*", + "tls-certification-workspace": "workspace:*" }, "devDependencies": { "@microsoft/rush-lib": "workspace:*", @@ -197,6 +199,9 @@ "mocha": "^9.1.3", "vsce": "~2.14.0" }, + "extensionDependencies": [ + "rushstack.tls-certification-workspace" + ], "engines": { "vscode": "^1.63.0" } diff --git a/vscode-extensions/tls-certification-workspace/package.json b/vscode-extensions/tls-certification-workspace/package.json index fa707beb07f..9225614906a 100644 --- a/vscode-extensions/tls-certification-workspace/package.json +++ b/vscode-extensions/tls-certification-workspace/package.json @@ -1,5 +1,5 @@ { - "name": "@rushstack/tls-certification-workspace", + "name": "tls-certification-workspace", "version": "0.0.1", "repository": { "type": "git", @@ -179,8 +179,7 @@ "@rushstack/ts-command-line": "workspace:*", "@rushstack/rush-vscode-command-webview": "workspace:*", "@rushstack/terminal": "workspace:*", - "@rushstack/debug-certificate-manager": "workspace:*", - "@rushstack/tls-certification-ui": "workspace:*" + "@rushstack/debug-certificate-manager": "workspace:*" }, "devDependencies": { "@microsoft/rush-lib": "workspace:*", From 4f61fda5cf96d7445dc632c0cd679fce35923c04 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Mon, 11 Mar 2024 13:47:21 -0700 Subject: [PATCH 07/13] working implementation --- .vscode/launch.json | 6 ++-- .../tls-certification-ui/package.json | 5 --- .../tls-certification-ui/src/extension.ts | 18 ++++++---- .../tls-certification-workspace/package.json | 8 ++--- .../src/extension.ts | 33 +++++++------------ 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d50b3cb084a..389246a6c2d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -89,10 +89,12 @@ "request": "launch", "cwd": "${workspaceFolder}/vscode-extensions/tls-certification-ui", "args": [ - "--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/tls-certification-ui" + "--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/tls-certification-ui", + "--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/tls-certification-workspace" ], "outFiles": [ - "${workspaceFolder}/vscode-extensions/tls-certification-ui/dist/**/*.js" + "${workspaceFolder}/vscode-extensions/tls-certification-ui/dist/**/*.js", + "${workspaceFolder}/vscode-extensions/tls-certification-workspace/dist/**/*.js"` ] // "preLaunchTask": "npm: build:watch - vscode-extensions/tls-certification-ui" }, diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json index 84e2fc0668c..f34d5070038 100644 --- a/vscode-extensions/tls-certification-ui/package.json +++ b/vscode-extensions/tls-certification-ui/package.json @@ -90,11 +90,6 @@ "command": "rushstack.ensureDebugCertificate", "category": "RushStack", "title": "Ensure Debug Certificate" - }, - { - "command": "rushstack.saveDebugCertificate", - "category": "RushStack", - "title": "Save Debug Certificate" } ], "taskDefinitions": [ diff --git a/vscode-extensions/tls-certification-ui/src/extension.ts b/vscode-extensions/tls-certification-ui/src/extension.ts index 6a73b8aa83d..d1c4e29e927 100644 --- a/vscode-extensions/tls-certification-ui/src/extension.ts +++ b/vscode-extensions/tls-certification-ui/src/extension.ts @@ -30,12 +30,18 @@ export async function activate(context: vscode.ExtensionContext): Promise await vscode.window.showErrorMessage('Certificate was not generated'); } - await vscode.commands.executeCommand( - 'rushstack.saveDebugCertificate', - pemCaCertificate, - pemCertificate, - pemKey - ); + await vscode.commands + .executeCommand('rushstack.saveDebugCertificate', pemCaCertificate, pemCertificate, pemKey) + .then( + () => { + vscode.window.showInformationMessage('Certificate successfully saved (UI message)'); + }, + (error) => { + vscode.window.showErrorMessage(`Error saving certificate: ${error}`); + } + ); + + vscode.window.showInformationMessage('TLS UI finished running'); }) ); } diff --git a/vscode-extensions/tls-certification-workspace/package.json b/vscode-extensions/tls-certification-workspace/package.json index 9225614906a..d0e6fb0cc5b 100644 --- a/vscode-extensions/tls-certification-workspace/package.json +++ b/vscode-extensions/tls-certification-workspace/package.json @@ -18,6 +18,7 @@ "Extension Packs", "Visualization" ], + "api": "none", "keywords": [ "api-extractor", "build", @@ -85,11 +86,6 @@ }, "contributes": { "commands": [ - { - "command": "rushstack.ensureDebugCertificate", - "category": "RushStack", - "title": "Ensure Debug Certificate" - }, { "command": "rushstack.saveDebugCertificate", "category": "RushStack", @@ -158,7 +154,7 @@ "configuration": { "title": "TLS Certificate Workspace monorepo tools", "properties": { - "rushstack.logLevelTLS": { + "rushstack.logLevelTLSWorkspace": { "type": "string", "default": "info", "enum": [ diff --git a/vscode-extensions/tls-certification-workspace/src/extension.ts b/vscode-extensions/tls-certification-workspace/src/extension.ts index 76641501288..8ff1be597fc 100644 --- a/vscode-extensions/tls-certification-workspace/src/extension.ts +++ b/vscode-extensions/tls-certification-workspace/src/extension.ts @@ -4,7 +4,7 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; -import { CertificateManager } from '@rushstack/debug-certificate-manager'; +import { CertificateStore } from '@rushstack/debug-certificate-manager'; import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; const consoleTerminalProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); @@ -17,27 +17,18 @@ export async function activate(context: vscode.ExtensionContext): Promise vscode.window.showInformationMessage('TLS Cetification Workspace Extension is now active!'); context.subscriptions.push( - vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { - const manager: CertificateManager = new CertificateManager(); - - const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( - true, - terminal - ); - - if (pemCaCertificate && pemCertificate && pemKey) { - await vscode.window.showInformationMessage('Certificate successfully generated'); - } else { - await vscode.window.showErrorMessage('Certificate was not generated'); - } + vscode.commands.registerCommand( + 'rushstack.saveDebugCertificate', + async (pemCaCertificate: string, pemCertificate: string, pemKey: string) => { + const store: CertificateStore = new CertificateStore(); + + store.caCertificateData = pemCaCertificate; + store.certificateData = pemCertificate; + store.keyData = pemKey; - await vscode.commands.executeCommand( - 'rushstack.saveDebugCertificate', - pemCaCertificate, - pemCertificate, - pemKey - ); - }) + await vscode.window.showInformationMessage('Certificate successfully saved'); + } + ) ); } From ee756bf3221dc19cfb3719b9db91da2618a357f2 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Tue, 12 Mar 2024 11:54:06 -0700 Subject: [PATCH 08/13] rush change --- .../ating-tls-certification-sync_2024-03-12-18-53.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/ating-tls-certification-sync_2024-03-12-18-53.json diff --git a/common/changes/@microsoft/rush/ating-tls-certification-sync_2024-03-12-18-53.json b/common/changes/@microsoft/rush/ating-tls-certification-sync_2024-03-12-18-53.json new file mode 100644 index 00000000000..3a3e4f42ec5 --- /dev/null +++ b/common/changes/@microsoft/rush/ating-tls-certification-sync_2024-03-12-18-53.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Added new extension projects tls-certification-ui and tls-certification-workspace", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From 30cc0212a5131d07664cc7d17aff32cdd1343f26 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:20:38 -0700 Subject: [PATCH 09/13] PR fixes and code cleanup --- common/config/rush/pnpm-lock.yaml | 24 +------ common/config/rush/repo-state.json | 2 +- .../src/test.ts | 30 --------- .../tls-certification-ui/LICENSE | 2 +- .../tls-certification-ui/README.md | 2 +- .../tls-certification-ui/package.json | 62 ------------------- .../tls-certification-ui/webpack.config.js | 2 - .../tls-certification-workspace/LICENSE | 2 +- .../tls-certification-workspace/README.md | 2 +- .../tls-certification-workspace/package.json | 62 ------------------- .../webpack.config.js | 2 - 11 files changed, 8 insertions(+), 184 deletions(-) delete mode 100644 rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 292d78ccf3e..55d10d4e4b2 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1774,7 +1774,7 @@ importers: version: 29.5.12 '@types/node': specifier: ts4.9 - version: 20.11.25 + version: 20.11.26 eslint: specifier: ~8.7.0 version: 8.7.0(supports-color@8.1.1) @@ -4128,18 +4128,9 @@ importers: '@rushstack/node-core-library': specifier: workspace:* version: link:../../libraries/node-core-library - '@rushstack/rush-sdk': - specifier: workspace:* - version: link:../../libraries/rush-sdk - '@rushstack/rush-vscode-command-webview': - specifier: workspace:* - version: link:../rush-vscode-command-webview '@rushstack/terminal': specifier: workspace:* version: link:../../libraries/terminal - '@rushstack/ts-command-line': - specifier: workspace:* - version: link:../../libraries/ts-command-line tls-certification-workspace: specifier: workspace:* version: link:../tls-certification-workspace @@ -4195,18 +4186,9 @@ importers: '@rushstack/node-core-library': specifier: workspace:* version: link:../../libraries/node-core-library - '@rushstack/rush-sdk': - specifier: workspace:* - version: link:../../libraries/rush-sdk - '@rushstack/rush-vscode-command-webview': - specifier: workspace:* - version: link:../rush-vscode-command-webview '@rushstack/terminal': specifier: workspace:* version: link:../../libraries/terminal - '@rushstack/ts-command-line': - specifier: workspace:* - version: link:../../libraries/ts-command-line devDependencies: '@microsoft/rush-lib': specifier: workspace:* @@ -11905,8 +11887,8 @@ packages: /@types/node@18.17.15: resolution: {integrity: sha512-2yrWpBk32tvV/JAd3HNHWuZn/VDN1P+72hWirHnvsvTGSqbANi+kSeuQR9yAHnbvaBvHDsoTdXV0Fe+iRtHLKA==} - /@types/node@20.11.25: - resolution: {integrity: sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==} + /@types/node@20.11.26: + resolution: {integrity: sha512-YwOMmyhNnAWijOBQweOJnQPl068Oqd4K3OFbTc6AHJwzweUwwWG3GIFY74OKks2PJUDkQPeddOQES9mLn1CTEQ==} dependencies: undici-types: 5.26.5 dev: true diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 09dd543d903..95f5e026e12 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "4023da3135d905aa214198bb4bbcb3e55c274b6c", + "pnpmShrinkwrapHash": "ccb0e132cffc3151312a4b5f11a0fb10b11f45fa", "preferredVersionsHash": "40d4640a94cff77f7808a2f1960cc76231eb6f86" } diff --git a/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts b/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts deleted file mode 100644 index 6585fcadf93..00000000000 --- a/rush-plugins/rush-azure-storage-build-cache-plugin/src/test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { DeviceCodeCredential } from '@azure/identity'; -import { ITerminal } from '@rushstack/node-core-library'; -import { IAzureAuthenticationConfiguration, ICredentialResultWithId } from './RushAzureInteractiveAuthPlugin'; - -async function fetchCredentialsUsingDeviceCodeAsync( - deviceCodeCredential: DeviceCodeCredential, - terminal: ITerminal, - options: IAzureAuthenticationConfiguration -): Promise { - const { keyVaultSecretName = '' } = options; - - // const keyVaultCredential: KeyVaultAuthentication = new KeyVaultAuthentication({ - // vaultName: keyVaultName, - // secretName: keyVaultSecretName, - // deviceCodeCredentails: deviceCodeCredential - // }); - - // const keyVaultCoreCredentials: ICredentialResult = - // await keyVaultCredential._getCredentialFromDeviceCodeAsync(terminal, deviceCodeCredential); - const keyVaultCacheId: string = `azure-key-vault|AzurePublicCloud|odsp-web-tests|${keyVaultSecretName}`; - - return { - credentialId: keyVaultCacheId, - credential: { - credentialString: 'succesafjoisaef' - } - }; -} - -export { fetchCredentialsUsingDeviceCodeAsync }; diff --git a/vscode-extensions/tls-certification-ui/LICENSE b/vscode-extensions/tls-certification-ui/LICENSE index 462853efafa..1af4866b855 100644 --- a/vscode-extensions/tls-certification-ui/LICENSE +++ b/vscode-extensions/tls-certification-ui/LICENSE @@ -1,4 +1,4 @@ -rushstack vscode extension +tls-certification-ui vscode extension Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/vscode-extensions/tls-certification-ui/README.md b/vscode-extensions/tls-certification-ui/README.md index 12af0566460..a47c3976d4f 100644 --- a/vscode-extensions/tls-certification-ui/README.md +++ b/vscode-extensions/tls-certification-ui/README.md @@ -22,5 +22,5 @@ Install through VS Code extensions. Search for `Rush Stack monorepo tools` Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. ``` -ext install RushStack.rushstack +ext install rushstack.tls-certification-ui ``` diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json index f34d5070038..77c8106894b 100644 --- a/vscode-extensions/tls-certification-ui/package.json +++ b/vscode-extensions/tls-certification-ui/package.json @@ -92,65 +92,6 @@ "title": "Ensure Debug Certificate" } ], - "taskDefinitions": [ - { - "type": "rush", - "required": [ - "cwd", - "displayName", - "command", - "args" - ], - "properties": { - "cwd": { - "type": "string", - "description": "The working directory for the task" - }, - "displayName": { - "type": "string", - "description": "The display name for the command" - }, - "command": { - "type": "string", - "description": "The command to run" - }, - "args": { - "type": "array", - "description": "The arguments to pass to the command" - } - } - }, - { - "type": "rushx", - "required": [ - "cwd", - "command" - ], - "properties": { - "cwd": { - "type": "string", - "description": "The working directory for the command" - }, - "displayName": { - "type": "string", - "description": "The display name for the command" - }, - "command": { - "type": "string", - "description": "The command to run" - } - } - } - ], - "viewsContainers": { - "activitybar": [ - { - "id": "rushstack", - "title": "Rush Stack", - "icon": "resources/rushstack-icon.svg" - } - ] - }, "configuration": { "title": "TLS Certificate UI monorepo tools", "properties": { @@ -171,9 +112,6 @@ ], "dependencies": { "@rushstack/node-core-library": "workspace:*", - "@rushstack/rush-sdk": "workspace:*", - "@rushstack/ts-command-line": "workspace:*", - "@rushstack/rush-vscode-command-webview": "workspace:*", "@rushstack/terminal": "workspace:*", "@rushstack/debug-certificate-manager": "workspace:*", "tls-certification-workspace": "workspace:*" diff --git a/vscode-extensions/tls-certification-ui/webpack.config.js b/vscode-extensions/tls-certification-ui/webpack.config.js index 7e35e8bdc3f..371b60ad49e 100644 --- a/vscode-extensions/tls-certification-ui/webpack.config.js +++ b/vscode-extensions/tls-certification-ui/webpack.config.js @@ -24,8 +24,6 @@ function createExtensionConfig({ production, webpack }) { libraryTarget: 'commonjs2' }, externals: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '@microsoft/rush-lib': 'commonjs @microsoft/rush-lib', vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ // modules added here also need to be added in the .vscodeignore file }, diff --git a/vscode-extensions/tls-certification-workspace/LICENSE b/vscode-extensions/tls-certification-workspace/LICENSE index 462853efafa..2e80bfe6fdf 100644 --- a/vscode-extensions/tls-certification-workspace/LICENSE +++ b/vscode-extensions/tls-certification-workspace/LICENSE @@ -1,4 +1,4 @@ -rushstack vscode extension +tls-certification-workspace vscode extension Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/vscode-extensions/tls-certification-workspace/README.md b/vscode-extensions/tls-certification-workspace/README.md index 12af0566460..c9d942f656f 100644 --- a/vscode-extensions/tls-certification-workspace/README.md +++ b/vscode-extensions/tls-certification-workspace/README.md @@ -22,5 +22,5 @@ Install through VS Code extensions. Search for `Rush Stack monorepo tools` Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. ``` -ext install RushStack.rushstack +ext install rushstack.tls-certification-workspace ``` diff --git a/vscode-extensions/tls-certification-workspace/package.json b/vscode-extensions/tls-certification-workspace/package.json index d0e6fb0cc5b..202fcffb05b 100644 --- a/vscode-extensions/tls-certification-workspace/package.json +++ b/vscode-extensions/tls-certification-workspace/package.json @@ -92,65 +92,6 @@ "title": "Save Debug Certificate" } ], - "taskDefinitions": [ - { - "type": "rush", - "required": [ - "cwd", - "displayName", - "command", - "args" - ], - "properties": { - "cwd": { - "type": "string", - "description": "The working directory for the task" - }, - "displayName": { - "type": "string", - "description": "The display name for the command" - }, - "command": { - "type": "string", - "description": "The command to run" - }, - "args": { - "type": "array", - "description": "The arguments to pass to the command" - } - } - }, - { - "type": "rushx", - "required": [ - "cwd", - "command" - ], - "properties": { - "cwd": { - "type": "string", - "description": "The working directory for the command" - }, - "displayName": { - "type": "string", - "description": "The display name for the command" - }, - "command": { - "type": "string", - "description": "The command to run" - } - } - } - ], - "viewsContainers": { - "activitybar": [ - { - "id": "rushstack", - "title": "Rush Stack", - "icon": "resources/rushstack-icon.svg" - } - ] - }, "configuration": { "title": "TLS Certificate Workspace monorepo tools", "properties": { @@ -171,9 +112,6 @@ ], "dependencies": { "@rushstack/node-core-library": "workspace:*", - "@rushstack/rush-sdk": "workspace:*", - "@rushstack/ts-command-line": "workspace:*", - "@rushstack/rush-vscode-command-webview": "workspace:*", "@rushstack/terminal": "workspace:*", "@rushstack/debug-certificate-manager": "workspace:*" }, diff --git a/vscode-extensions/tls-certification-workspace/webpack.config.js b/vscode-extensions/tls-certification-workspace/webpack.config.js index 7e35e8bdc3f..371b60ad49e 100644 --- a/vscode-extensions/tls-certification-workspace/webpack.config.js +++ b/vscode-extensions/tls-certification-workspace/webpack.config.js @@ -24,8 +24,6 @@ function createExtensionConfig({ production, webpack }) { libraryTarget: 'commonjs2' }, externals: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '@microsoft/rush-lib': 'commonjs @microsoft/rush-lib', vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ // modules added here also need to be added in the .vscodeignore file }, From 4bedb45b17506730f7e4b450570316ee8c21a631 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:35:01 -0700 Subject: [PATCH 10/13] updated README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e9172a2c4ce..cd984c2f278 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,8 @@ These GitHub repositories provide supplementary resources for Rush Stack: | [/rush-plugins/rush-litewatch-plugin](./rush-plugins/rush-litewatch-plugin/) | An experimental alternative approach for multi-project watch mode | | [/vscode-extensions/rush-vscode-command-webview](./vscode-extensions/rush-vscode-command-webview/) | Part of the Rush Stack VSCode extension, provides a UI for invoking Rush commands | | [/vscode-extensions/rush-vscode-extension](./vscode-extensions/rush-vscode-extension/) | Enhanced experience for monorepos that use the Rush Stack toolchain | +| [/vscode-extensions/tls-certification-ui](./vscode-extensions/tls-certification-ui/) | Creates TLS Certificates as a UI Extension | +| [/vscode-extensions/tls-certification-workspace](./vscode-extensions/tls-certification-workspace/) | Creates TLS Certificates as a Workspace Extension | | [/webpack/webpack-deep-imports-plugin](./webpack/webpack-deep-imports-plugin/) | This plugin creates a bundle and commonJS files in a 'lib' folder mirroring modules in another 'lib' folder. | From 1bd1cf3d79d46da6e2a8dbd4b099c47a1027b2f9 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:13:20 -0700 Subject: [PATCH 11/13] kept upload extensions under one pipeline instead of two. --- .../tls-certification-ui-publish.yaml | 25 +++++++++++ .../tls-certification-workspace | 45 ------------------- 2 files changed, 25 insertions(+), 45 deletions(-) delete mode 100644 common/config/azure-pipelines/tls-certification-workspace diff --git a/common/config/azure-pipelines/tls-certification-ui-publish.yaml b/common/config/azure-pipelines/tls-certification-ui-publish.yaml index b4e9a5e0dd6..428737b8cb3 100644 --- a/common/config/azure-pipelines/tls-certification-ui-publish.yaml +++ b/common/config/azure-pipelines/tls-certification-ui-publish.yaml @@ -43,3 +43,28 @@ extends: displayName: 'Publish tls certification ui extension' env: VSCE_PAT: $(vscePat) + - job: + pool: + name: publish-tls-certification-workspace + os: linux + steps: + - checkout: self + persistCredentials: true + + - template: /common/config/azure-pipelines/templates/install-node.yaml@self + + - template: /common/config/azure-pipelines/templates/build.yaml@self + parameters: + BuildParameters: > + --to rushstack + PerformValidation: false + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js package + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace + displayName: 'Package tls certification workspace extension' + + - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js deploy + workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace + displayName: 'Publish tls certification workspace extension' + env: + VSCE_PAT: $(vscePat) diff --git a/common/config/azure-pipelines/tls-certification-workspace b/common/config/azure-pipelines/tls-certification-workspace deleted file mode 100644 index 5319d39e8e5..00000000000 --- a/common/config/azure-pipelines/tls-certification-workspace +++ /dev/null @@ -1,45 +0,0 @@ -variables: - - name: FORCE_COLOR - value: 1 - -resources: - repositories: - - repository: 1esPipelines - type: git - name: 1ESPipelineTemplates/1ESPipelineTemplates - ref: refs/tags/release - -extends: - template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines - parameters: - pool: - name: Azure-Pipelines-1ESPT-ExDShared - os: windows - stages: - - stage: - jobs: - - job: - pool: - name: publish-tls-certification-workspace - os: linux - steps: - - checkout: self - persistCredentials: true - - - template: /common/config/azure-pipelines/templates/install-node.yaml@self - - - template: /common/config/azure-pipelines/templates/build.yaml@self - parameters: - BuildParameters: > - --to rushstack - PerformValidation: false - - - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js package - workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace - displayName: 'Package tls certification workspace extension' - - - script: node $(Build.SourcesDirectory)/common/scripts/install-run-rushx.js deploy - workingDirectory: $(Build.SourcesDirectory)/vscode-extensions/tls-certification-workspace - displayName: 'Publish tls certification workspace extension' - env: - VSCE_PAT: $(vscePat) From 91096a7a44192db388a6e38577804ed994ab77b0 Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:49:08 -0700 Subject: [PATCH 12/13] fix async bug --- .../tls-certification-ui/src/extension.ts | 36 ++++++++----------- .../src/extension.ts | 2 +- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/vscode-extensions/tls-certification-ui/src/extension.ts b/vscode-extensions/tls-certification-ui/src/extension.ts index d1c4e29e927..d1c9f5b00ed 100644 --- a/vscode-extensions/tls-certification-ui/src/extension.ts +++ b/vscode-extensions/tls-certification-ui/src/extension.ts @@ -14,32 +14,24 @@ export const terminal: Terminal = new Terminal(consoleTerminalProvider); // this method is called when your extension is activated // your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext): Promise { - vscode.window.showInformationMessage('TLS Cetification UI Extension is now active!'); - context.subscriptions.push( vscode.commands.registerCommand('rushstack.ensureDebugCertificate', async () => { - const manager: CertificateManager = new CertificateManager(); - const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( - true, - terminal - ); - - if (pemCaCertificate && pemCertificate && pemKey) { - await vscode.window.showInformationMessage('Certificate successfully generated'); - } else { - await vscode.window.showErrorMessage('Certificate was not generated'); - } + try { + const manager: CertificateManager = new CertificateManager(); + const { pemCaCertificate, pemCertificate, pemKey } = await manager.ensureCertificateAsync( + true, + terminal + ); - await vscode.commands - .executeCommand('rushstack.saveDebugCertificate', pemCaCertificate, pemCertificate, pemKey) - .then( - () => { - vscode.window.showInformationMessage('Certificate successfully saved (UI message)'); - }, - (error) => { - vscode.window.showErrorMessage(`Error saving certificate: ${error}`); - } + await vscode.commands.executeCommand( + 'rushstack.saveDebugCertificate', + pemCaCertificate, + pemCertificate, + pemKey ); + } catch (error) { + vscode.window.showErrorMessage(`Certificate was not generated with error: ${error}`); + } vscode.window.showInformationMessage('TLS UI finished running'); }) diff --git a/vscode-extensions/tls-certification-workspace/src/extension.ts b/vscode-extensions/tls-certification-workspace/src/extension.ts index 8ff1be597fc..1b8798af471 100644 --- a/vscode-extensions/tls-certification-workspace/src/extension.ts +++ b/vscode-extensions/tls-certification-workspace/src/extension.ts @@ -26,7 +26,7 @@ export async function activate(context: vscode.ExtensionContext): Promise store.certificateData = pemCertificate; store.keyData = pemKey; - await vscode.window.showInformationMessage('Certificate successfully saved'); + vscode.window.showInformationMessage('Certificate successfully saved'); } ) ); From 1f715aaf82cf43567b08aea39f5c9523d972ef8d Mon Sep 17 00:00:00 2001 From: atingmicrosoft <115047461+atingmicrosoft@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:28:10 -0700 Subject: [PATCH 13/13] added extensionKind parameter to package.json --- vscode-extensions/tls-certification-ui/package.json | 3 +++ vscode-extensions/tls-certification-workspace/package.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/vscode-extensions/tls-certification-ui/package.json b/vscode-extensions/tls-certification-ui/package.json index 77c8106894b..bb9d5eeeea2 100644 --- a/vscode-extensions/tls-certification-ui/package.json +++ b/vscode-extensions/tls-certification-ui/package.json @@ -132,6 +132,9 @@ "mocha": "^9.1.3", "vsce": "~2.14.0" }, + "extensionKind": [ + "ui" + ], "extensionDependencies": [ "rushstack.tls-certification-workspace" ], diff --git a/vscode-extensions/tls-certification-workspace/package.json b/vscode-extensions/tls-certification-workspace/package.json index 202fcffb05b..c7779ebf46c 100644 --- a/vscode-extensions/tls-certification-workspace/package.json +++ b/vscode-extensions/tls-certification-workspace/package.json @@ -115,6 +115,9 @@ "@rushstack/terminal": "workspace:*", "@rushstack/debug-certificate-manager": "workspace:*" }, + "extensionKind": [ + "workspace" + ], "devDependencies": { "@microsoft/rush-lib": "workspace:*", "local-node-rig": "workspace:*",