Skip to content

Commit 077cd6f

Browse files
committed
Address PR feedback.
1 parent 31dcaf9 commit 077cd6f

File tree

10 files changed

+184
-258
lines changed

10 files changed

+184
-258
lines changed

common/reviews/api/debug-certificate-generator.api.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

common/reviews/api/debug-certificate-manager.api.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
55
```ts
66

7+
import { Terminal } from '@microsoft/node-core-library';
8+
79
// @public (undocumented)
810
export class CertificateStore {
11+
constructor();
912
// (undocumented)
1013
certificateData: string | undefined;
1114
// (undocumented)
1215
readonly certificatePath: string;
1316
// (undocumented)
14-
static readonly instance: CertificateStore;
15-
// (undocumented)
1617
keyData: string | undefined;
1718
}
1819

1920
// @public
20-
export function ensureCertificate(canGenerateNewCertificate: boolean, parentLogger: ILogging): ICertificate;
21+
export function ensureCertificate(canGenerateNewCertificate: boolean, terminal: Terminal): ICertificate;
2122

2223
// @public (undocumented)
2324
export interface ICertificate {
@@ -27,20 +28,8 @@ export interface ICertificate {
2728
pemKey: string | undefined;
2829
}
2930

30-
// @public (undocumented)
31-
export interface ILogging {
32-
// (undocumented)
33-
log: (string: any) => void;
34-
// (undocumented)
35-
logError: (string: any) => void;
36-
// (undocumented)
37-
logVerbose: (string: any) => void;
38-
// (undocumented)
39-
logWarning: (string: any) => void;
40-
}
41-
4231
// @public
43-
export function untrustCertificate(parentLogger: ILogging): boolean;
32+
export function untrustCertificate(terminal: Terminal): boolean;
4433

4534

4635
// (No @packageDocumentation comment for this package)

core-build/gulp-core-build-serve/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ The certificate is generated and self-signed with a unique private key and an at
121121
it (Windows and macOS only). If the user does not agree to trust the certificate, provides invalid root
122122
credentials, or something else goes wrong, the `TrustCertTask` will fail and the `ServeTask` will serve
123123
with the default, non-trusted certificate. If trust succeeds, the certificate and the private key are
124-
dropped in the `.rushstack-serve-data` directory in the user's home folder in `PEM` format. On platforms
124+
dropped in the `.rushstack` directory in the user's home folder in `PEM` format. On platforms
125125
other than Windows and macOS, the certificate and key are always dropped in that directory, and the user
126126
must trust the certificate manually.
127127

@@ -134,6 +134,6 @@ signature is found by its serial number and then the certificate is deleted from
134134
signature. Regardless of whether the untrust succeeds or not, the certificate and key are deleted
135135
from the user's home directory.
136136

137-
To manually untrust the certificate, delete the files in the `.rushstack-serve-data` directory under your
137+
To manually untrust the certificate, delete the files in the `.rushstack` directory under your
138138
home directory and untrust the certificate with the
139139
`73 1c 32 17 44 e3 46 50 a2 02 e3 ef 91 c3 c1 b9` serial number.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
2+
require("@rushstack/eslint-config/patch-eslint6");
3+
4+
module.exports = {
5+
extends: [ "@rushstack/eslint-config" ],
6+
parserOptions: { tsconfigRootDir: __dirname },
7+
};

libraries/debug-certificate-manager/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ This library contains utilities for managing debug certificates in a development
1212
[![Build Status](https://travis-ci.org/Microsoft/debug-certificate-manager.svg?branch=master)](https://travis-ci.org/Microsoft/debug-certificate-manager) [![Dependencies](https://david-dm.org/Microsoft/debug-certificate-manager.svg)](https://david-dm.org/Microsoft/debug-certificate-manager)
1313

1414

15-
## CertificateStore
15+
## `CertificateStore`
1616

17-
The CertificateStore class follows a singleton pattern and provides accessors and mutators for the certificate data stored in `.rushstack-serve-data`.
17+
The CertificateStore class follows a singleton pattern and provides accessors and mutators for the certificate data stored in `.rushstack`.
1818

1919
Retrieve an instance with `CertificateStore.instance`.
2020

21-
## ensureCertificate
21+
## `ensureCertificate`
2222

2323
Get the dev certificate from the store, or optionally, generate a new one and trust it if one does not exist in the store. Returns a certificate object following the `ICertificate` interface.
2424

@@ -29,7 +29,7 @@ export interface ICertificate {
2929
}
3030
```
3131

32-
## untrustCertificate
32+
## `untrustCertificate`
3333

3434
Attempts to locate a previously generated debug certificate and untrust it. Returns a `boolean` value to denote success.
3535

libraries/debug-certificate-manager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"description": "Cross-platform functionality to create debug ssl certificates.",
55
"main": "lib/index.js",
6-
"typings": "dist/node-core-library.d.ts",
6+
"typings": "dist/debug-certificate-manager.d.ts",
77
"license": "MIT",
88
"repository": {
99
"url": "https://github.com/microsoft/rushstack/tree/master/libraries/debug-certificate-manager"

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

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ import { FileSystem } from '@microsoft/node-core-library';
1010
* @public
1111
*/
1212
export class CertificateStore {
13-
private static _instance: CertificateStore;
14-
15-
public static get instance(): CertificateStore {
16-
if (!CertificateStore._instance) {
17-
CertificateStore._instance = new CertificateStore();
18-
CertificateStore._instance._initialize();
19-
}
20-
21-
return CertificateStore._instance;
22-
}
23-
2413
private _userProfilePath: string;
2514
private _serveDataPath: string;
2615
private _certificatePath: string;
@@ -29,6 +18,20 @@ export class CertificateStore {
2918
private _certificateData: string | undefined;
3019
private _keyData: string | undefined;
3120

21+
public constructor() {
22+
const unresolvedUserFolder: string = homedir();
23+
this._userProfilePath = path.resolve(unresolvedUserFolder);
24+
if (!FileSystem.exists(this._userProfilePath)) {
25+
throw new Error('Unable to determine the current user\'s home directory');
26+
}
27+
28+
this._serveDataPath = path.join(this._userProfilePath, '.rushstack');
29+
FileSystem.ensureFolder(this._serveDataPath);
30+
31+
this._certificatePath = path.join(this._serveDataPath, 'rushstack-serve.pem');
32+
this._keyPath = path.join(this._serveDataPath, 'rushstack-serve.key');
33+
}
34+
3235
public get certificatePath(): string {
3336
return this._certificatePath;
3437
}
@@ -76,18 +79,4 @@ export class CertificateStore {
7679

7780
this._keyData = key;
7881
}
79-
80-
private _initialize(): void {
81-
const unresolvedUserFolder: string = homedir();
82-
this._userProfilePath = path.resolve(unresolvedUserFolder);
83-
if (!FileSystem.exists(this._userProfilePath)) {
84-
throw new Error('Unable to determine the current user\'s home directory');
85-
}
86-
87-
this._serveDataPath = path.join(this._userProfilePath, '.rushstack-serve-data');
88-
FileSystem.ensureFolder(this._serveDataPath);
89-
90-
this._certificatePath = path.join(this._serveDataPath, 'rushstack-serve.pem');
91-
this._keyPath = path.join(this._serveDataPath, 'rushstack-serve.key');
92-
}
9382
}

0 commit comments

Comments
 (0)