Skip to content

Commit 5596a0d

Browse files
authored
[debug-certificate-manager] add vs code extension info to log messages (#5380)
1 parent b703dea commit 5596a0d

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/debug-certificate-manager",
5+
"comment": "Add message to use VS Code extension to errors.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/debug-certificate-manager"
10+
}

libraries/debug-certificate-manager/src/CertificateManager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ export interface ICertificateManagerOptions extends ICertificateStoreOptions {}
145145

146146
const MAX_CERTIFICATE_VALIDITY_DAYS: 365 = 365;
147147

148+
const VS_CODE_EXTENSION_FIX_MESSAGE: string =
149+
'Use the "Debug Certificate Manager" Extension for VS Code (ms-RushStack.debug-certificate-manager) and run the ' +
150+
'"Debug Certificate Manager: Ensure and Sync TLS Certificates" command to fix certificate issues. ';
151+
148152
/**
149153
* A utility class to handle generating, trusting, and untrustring a debug certificate.
150154
* Contains two public methods to `ensureCertificate` and `untrustCertificate`.
@@ -177,7 +181,8 @@ export class CertificateManager {
177181
if (process.env[DISABLE_CERT_GENERATION_VARIABLE_NAME] === '1') {
178182
// Allow the environment (e.g. GitHub codespaces) to forcibly disable dev cert generation
179183
terminal.writeLine(
180-
`Found environment variable ${DISABLE_CERT_GENERATION_VARIABLE_NAME}=1, disabling certificate generation.`
184+
`Found environment variable ${DISABLE_CERT_GENERATION_VARIABLE_NAME}=1, disabling certificate generation. ` +
185+
VS_CODE_EXTENSION_FIX_MESSAGE
181186
);
182187
canGenerateNewCertificate = false;
183188
}
@@ -207,7 +212,8 @@ export class CertificateManager {
207212
} else {
208213
validationResult.validationMessages.push(
209214
'Untrust the certificate and generate a new one, or set the ' +
210-
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`.'
215+
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`. ' +
216+
VS_CODE_EXTENSION_FIX_MESSAGE
211217
);
212218
throw new Error(validationResult.validationMessages.join(' '));
213219
}
@@ -216,7 +222,8 @@ export class CertificateManager {
216222
} else {
217223
throw new Error(
218224
'No development certificate found. Generate a new certificate manually, or set the ' +
219-
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`.'
225+
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`. ' +
226+
VS_CODE_EXTENSION_FIX_MESSAGE
220227
);
221228
}
222229
}

libraries/debug-certificate-manager/src/CertificateStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class CertificateStore {
7575
storePath = path.resolve(currentDir, debugCertificateManagerConfig.storePath);
7676
}
7777
}
78+
break; // found the config file, stop searching
7879
}
7980
const parentDir: string | undefined = path.dirname(currentDir);
8081
if (parentDir === currentDir) {

0 commit comments

Comments
 (0)