Skip to content

fix: improve https CLI output #3673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2021
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
14 changes: 8 additions & 6 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class Server {
const del = require("del");

this.logger.info(
"SSL Certificate is more than 30 days old. Removing."
"SSL Certificate is more than 30 days old. Removing..."
);

del.sync([certificatePath], { force: true });
Expand All @@ -339,7 +339,7 @@ class Server {
}

if (!certificateExists) {
this.logger.info("Generating SSL Certificate");
this.logger.info("Generating SSL Certificate...");

const selfsigned = require("selfsigned");
const attributes = [{ name: "commonName", value: "localhost" }];
Expand All @@ -348,10 +348,10 @@ class Server {
days: 30,
keySize: 2048,
extensions: [
// {
// name: 'basicConstraints',
// cA: true,
// },
{
name: "basicConstraints",
cA: true,
},
{
name: "keyUsage",
keyCertSign: true,
Expand Down Expand Up @@ -412,6 +412,8 @@ class Server {
}

fakeCert = fs.readFileSync(certificatePath);

this.logger.info(`SSL certificate: ${certificatePath}`);
}

options.https.key = options.https.key || fakeCert;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"bonjour" CLI option should work using "--bonjour and --https" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"bonjour" CLI option should work using "--bonjour and --https" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
4 changes: 3 additions & 1 deletion test/cli/__snapshots__/http2-option.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"http2" CLI option should work using "--http2" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
4 changes: 3 additions & 1 deletion test/cli/__snapshots__/http2-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"http2" CLI option should work using "--http2" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
12 changes: 9 additions & 3 deletions test/cli/__snapshots__/https-option.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"https" CLI option should work using "--https" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand All @@ -25,7 +27,9 @@ exports[`"https" CLI option should work using "--https-key <path> --https-pfx <p
`;

exports[`"https" CLI option should work using "--https-request-cert" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand All @@ -41,7 +45,9 @@ exports[`"https" CLI option should work using "--no-https" 1`] = `
`;

exports[`"https" CLI option should work using "--no-https-request-cert" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
12 changes: 9 additions & 3 deletions test/cli/__snapshots__/https-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"https" CLI option should work using "--https" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand All @@ -25,7 +27,9 @@ exports[`"https" CLI option should work using "--https-key <path> --https-pfx <p
`;

exports[`"https" CLI option should work using "--https-request-cert" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand All @@ -41,7 +45,9 @@ exports[`"https" CLI option should work using "--no-https" 1`] = `
`;

exports[`"https" CLI option should work using "--no-https-request-cert" 1`] = `
"<i> [webpack-dev-server] Project is running at:
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
Expand Down
8 changes: 8 additions & 0 deletions test/cli/bonjour-option.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"use strict";

const del = require("del");
const Server = require("../../lib/Server");
const { testBin, normalizeStderr } = require("../helpers/test-bin");
const port = require("../ports-map")["cli-bonjour"];

const defaultCertificateDir = Server.findCacheDir();

describe('"bonjour" CLI option', () => {
beforeEach(async () => {
await del([defaultCertificateDir]);
});

it('should work using "--bonjour"', async () => {
const { exitCode, stderr } = await testBin(["--port", port, "--bonjour"]);

Expand Down
8 changes: 8 additions & 0 deletions test/cli/http2-option.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"use strict";

const del = require("del");
const Server = require("../../lib/Server");
const { testBin, normalizeStderr } = require("../helpers/test-bin");
const port = require("../ports-map")["cli-http2"];

const defaultCertificateDir = Server.findCacheDir();

describe('"http2" CLI option', () => {
beforeEach(async () => {
await del([defaultCertificateDir]);
});

it('should work using "--http2"', async () => {
const { exitCode, stderr } = await testBin(["--port", port, "--http2"]);

Expand Down
8 changes: 8 additions & 0 deletions test/cli/https-option.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";

const path = require("path");
const del = require("del");
const Server = require("../../lib/Server");
const { testBin, normalizeStderr } = require("../helpers/test-bin");
const port = require("../ports-map")["cli-https"];

Expand All @@ -9,7 +11,13 @@ const httpsCertificateDirectory = path.resolve(
"../fixtures/https-certificate"
);

const defaultCertificateDir = Server.findCacheDir();

describe('"https" CLI option', () => {
beforeEach(async () => {
await del([defaultCertificateDir]);
});

it('should work using "--https"', async () => {
const { exitCode, stderr } = await testBin(["--port", port, "--https"]);

Expand Down
3 changes: 0 additions & 3 deletions test/helpers/test-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ const normalizeStderr = (stderr, options = {}) => {
if (options.https) {
// We have deprecation warning on windows in some cases
normalizedStderr = normalizedStderr.split("\n");
normalizedStderr = normalizedStderr.filter(
(item) => !/Generating SSL Certificate/g.test(item)
);
normalizedStderr = normalizedStderr.filter(
(item) =>
!/DeprecationWarning: The legacy HTTP parser is deprecated/g.test(item)
Expand Down