Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/subspaces/default/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "58011e1085f2aad3dc842a758d45841ef7b79c4e",
"pnpmShrinkwrapHash": "bf42ec3e79f384de8e702662661546c4a52798fe",
"preferredVersionsHash": "61cd419c533464b580f653eb5f5a7e27fe7055ca"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "debug-certificate-manager",
"version": "0.0.1",
"version": "0.0.2",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rushstack.git",
Expand All @@ -25,7 +25,7 @@
"theme": "light"
},
"engines": {
"vscode": "^1.98.0"
"vscode": "^1.103.0"
},
"main": "./extension.js",
"scripts": {
Expand Down Expand Up @@ -120,7 +120,7 @@
"@rushstack/heft-vscode-extension-rig": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/node": "20.17.19",
"@types/vscode": "^1.63.0",
"@types/vscode": "1.103.0",
"@types/webpack-env": "1.18.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
EXTENSION_ID,
VSCODE_COMMAND_WORKSPACE_OPEN_SETTINGS
} from './constants';
import { runWorkspaceCommandAsync } from './terminal';

export function activate(context: vscode.ExtensionContext): void {
const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel(EXTENSION_DISPLAY_NAME);
Expand Down Expand Up @@ -205,26 +206,34 @@ export function activate(context: vscode.ExtensionContext): void {
let resolvedWorkspaceStorePath: string;
if (storePath.startsWith('/')) {
resolvedWorkspaceStorePath = storePath;
} else {
resolvedWorkspaceStorePath = vscode.Uri.joinPath(workspaceUri, storePath).path;
}

let storePathUri: vscode.Uri | undefined;
if (vscode.env.remoteName) {
storePathUri = vscode.Uri.from({
scheme: 'vscode-remote',
} else if (storePath.startsWith('~')) {
let homeDir: string;
if (vscode.env.remoteName) {
homeDir = await runWorkspaceCommandAsync({
terminalOptions: { name: 'debug-certificate-manager', hideFromUser: true },
commandLine: `node -p "require('os').homedir()"`,
terminal
});
} else {
homeDir = require('os').homedir();
}
terminal.writeLine(`Resolved home directory: ${homeDir}`);
const homeDirUri: vscode.Uri = vscode.Uri.from({
scheme: workspaceUri.scheme,
authority: workspaceUri.authority,
path: resolvedWorkspaceStorePath
path: homeDir
});
resolvedWorkspaceStorePath = vscode.Uri.joinPath(homeDirUri, storePath.slice(1)).path;
} else {
storePathUri = vscode.Uri.file(resolvedWorkspaceStorePath);
}
if (!storePathUri) {
terminal.writeLine('Failed to resolve store path URI.');
void vscode.window.showErrorMessage('Failed to resolve store path URI.');
return;
resolvedWorkspaceStorePath = vscode.Uri.joinPath(workspaceUri, storePath).path;
}

const storePathUri: vscode.Uri = vscode.Uri.from({
scheme: workspaceUri.scheme,
authority: workspaceUri.authority,
path: resolvedWorkspaceStorePath
});

const caCertificateUri: vscode.Uri = vscode.Uri.joinPath(storePathUri, caCertificateFilename);
const certificateUri: vscode.Uri = vscode.Uri.joinPath(storePathUri, certificateFilename);
const keyUri: vscode.Uri = vscode.Uri.joinPath(storePathUri, keyFilename);
Expand Down Expand Up @@ -252,6 +261,7 @@ export function activate(context: vscode.ExtensionContext): void {
const { autoSync } = getConfig(terminal);
if (autoSync) {
terminal.writeLine(`Auto-sync is enabled. Synchronizing certificates on activation...`);
void handleSync();
}

context.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import { ITerminal } from '@rushstack/terminal';
import * as vscode from 'vscode';
import { stripVTControlCharacters } from 'node:util';

export async function runWorkspaceCommandAsync({
terminalOptions,
commandLine,
terminal
}: {
terminalOptions: vscode.TerminalOptions;
commandLine: string;
terminal: ITerminal;
}): Promise<string> {
const vsTerminal: vscode.Terminal = vscode.window.createTerminal(terminalOptions);

// wait for shell to bootup and vs code shell integration to kick-in
const shellIntegration: vscode.TerminalShellIntegration =
vsTerminal.shellIntegration ??
(await new Promise((resolve, reject) => {
let timeoutId: NodeJS.Timeout | undefined;
const shellIntegrationDisposable: vscode.Disposable = vscode.window.onDidChangeTerminalShellIntegration(
(event) => {
if (event.terminal !== vsTerminal) {
return;
}
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = undefined;
}
resolve(event.shellIntegration);
shellIntegrationDisposable?.dispose();
}
);
timeoutId = setTimeout(() => {
shellIntegrationDisposable?.dispose();
reject(new Error('Shell integration timeout'));
}, 5000);
}));

// Run the command through shell integration and grab output
return new Promise<string>((resolve, reject) => {
let outputStream: string = '';

// start output capturing with the start execution event
const startExecutionDisposable: vscode.Disposable = vscode.window.onDidStartTerminalShellExecution(
async (event) => {
if (event.terminal !== vsTerminal) {
return;
}
terminal.writeLine(`Terminal shell execution started`);

for await (const chunk of event.execution.read()) {
outputStream += chunk;
}
}
);

// collect output and exit code
const endExecutionDisposable: vscode.Disposable = vscode.window.onDidEndTerminalShellExecution(
(event) => {
if (event.terminal !== vsTerminal) {
return;
}

terminal.writeLine(`Terminal shell execution ended with exit code ${event.exitCode}`);
outputStream = outputStream.trim();
outputStream = stripVTControlCharacters(outputStream);
terminal.writeLine(`Terminal output: ${outputStream}`);

endExecutionDisposable.dispose();
startExecutionDisposable.dispose();

if (event.exitCode === 0) {
resolve(outputStream);
} else {
reject(outputStream);
}
}
);

shellIntegration.executeCommand(commandLine);
terminal.writeLine(`Executing command: ${commandLine}`);
}).finally(() => {
vsTerminal.dispose();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/react": "17.0.74",
"@types/react-dom": "17.0.25",
"@types/react-redux": "~7.1.22",
"@types/vscode": "^1.63.0",
"@types/vscode": "1.103.0",
"eslint": "~9.25.1",
"html-webpack-plugin": "~5.5.0",
"local-web-rig": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions vscode-extensions/rush-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
"@rushstack/heft": "workspace:*",
"@types/glob": "7.1.1",
"@types/mocha": "10.0.6",
"@types/vscode": "^1.63.0",
"@types/vscode": "1.103.0",
"@types/webpack-env": "1.18.8",
"@vscode/test-electron": "^1.6.2",
"eslint": "~9.25.1",
Expand All @@ -273,6 +273,6 @@
"mocha": "^10.1.0"
},
"engines": {
"vscode": "^1.63.0"
"vscode": "^1.103.0"
}
}
2 changes: 1 addition & 1 deletion vscode-extensions/vscode-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"@rushstack/heft-node-rig": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/node": "20.17.19",
"@types/vscode": "^1.63.0"
"@types/vscode": "1.103.0"
}
}
Loading