Skip to content

Commit 9b47004

Browse files
committed
cli: Suppress noisy TLS cert generation output
Pipe stdio for openssl and mkcert subprocesses so their banners don't clutter the terminal. Condense log messages to a single "TLS: ..." line for all three cert resolution paths. A DEBUG_CERT_GENERATION flag allows surfacing the subprocess output when needed. Made-with: Cursor
1 parent cc2e879 commit 9b47004

File tree

1 file changed

+12
-6
lines changed
  • packages/playground/cli/src

1 file changed

+12
-6
lines changed

packages/playground/cli/src/tls.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { join } from 'path';
44
import { tmpdir } from 'os';
55
import { logger } from '@php-wasm/logger';
66

7+
// Flip to true to surface openssl/mkcert output for debugging
8+
const DEBUG_CERT_GENERATION = false;
9+
const CERT_STDIO: ('pipe' | 'inherit')[] = DEBUG_CERT_GENERATION
10+
? ['inherit', 'inherit', 'inherit']
11+
: ['pipe', 'pipe', 'pipe'];
12+
713
export interface TlsCertificate {
814
key: string;
915
cert: string;
@@ -50,7 +56,7 @@ subjectAltName = DNS:localhost,IP:127.0.0.1
5056
'30',
5157
'-config',
5258
confPath,
53-
]);
59+
], { stdio: CERT_STDIO });
5460
return {
5561
key: readFileSync(keyPath, 'utf8'),
5662
cert: readFileSync(certPath, 'utf8'),
@@ -117,7 +123,7 @@ export function generateMkcertCert(): TlsCertificate {
117123
certPath,
118124
'localhost',
119125
'127.0.0.1',
120-
]);
126+
], { stdio: CERT_STDIO });
121127
return {
122128
key: readFileSync(keyPath, 'utf8'),
123129
cert: readFileSync(certPath, 'utf8'),
@@ -147,7 +153,7 @@ export function resolveTlsCertificate(options: {
147153
sslKey?: string;
148154
}): TlsCertificate {
149155
if (options.sslCert && options.sslKey) {
150-
logger.log('Using user-supplied TLS certificates.');
156+
logger.log('TLS: using provided certificates');
151157
return {
152158
key: readFileSync(options.sslKey, 'utf8'),
153159
cert: readFileSync(options.sslCert, 'utf8'),
@@ -156,13 +162,13 @@ export function resolveTlsCertificate(options: {
156162

157163
const caRoot = getMkcertCaRoot();
158164
if (caRoot) {
159-
logger.log('Using mkcert for locally-trusted TLS certificates.');
165+
logger.log('TLS: using mkcert (locally-trusted)');
160166
return generateMkcertCert();
161167
}
162168

163-
logger.log('Generating self-signed TLS certificate for HTTPS.');
164169
logger.log(
165-
'Tip: Install mkcert (https://github.com/FiloSottile/mkcert) for warning-free HTTPS.'
170+
'TLS: using self-signed certificate' +
171+
' (install mkcert for warning-free HTTPS)'
166172
);
167173
return generateSelfSignedCert();
168174
}

0 commit comments

Comments
 (0)