Skip to content

Commit

Permalink
improve an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Aug 14, 2024
1 parent 110a400 commit 3030be8
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_eslint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: npx playwright install-deps
- name: Install certificate # needed for @jsenv/service-worker tests
if: runner.os == 'Linux' # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
run: node ./scripts/test/certificate_install.mjs
run: npm run certificate:install
- name: Fix lightningcss windows
if: runner.os == 'Windows'
run: npm install lightningcss-win32-x64-msvc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_test_workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: npx playwright install-deps
- name: Install certificate # needed for @jsenv/service-worker tests
if: runner.os == 'Linux' # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
run: node ./scripts/test/certificate_install.mjs
run: npm run certificate:install
- name: Fix lightningcss windows
if: runner.os == 'Windows'
run: npm install lightningcss-win32-x64-msvc
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"workspace:test:ci": "CI=1 npm run workspace:test",
"dev": "node --conditions=development ./scripts/dev/dev.mjs",
"playwright:install": "npx playwright install-deps && npx playwright install",
"certificate:install": "node ./scripts/dev/install_certificate_authority.mjs",
"certificate:install": "npx @jsenv/https-local install",
"prepublishOnly": "npm run build"
},
"dependencies": {
Expand Down Expand Up @@ -97,7 +97,7 @@
"@jsenv/core": "./",
"@jsenv/eslint-config-relax": "workspace:*",
"@jsenv/file-size-impact": "workspace:*",
"@jsenv/https-local": "3.0.7",
"@jsenv/https-local": "workspace:*",
"@jsenv/monorepo": "workspace:*",
"@jsenv/performance-impact": "workspace:*",
"@jsenv/plugin-as-js-classic": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/independent/https-local/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/https-local",
"version": "3.1.0",
"version": "3.1.1",
"description": "A programmatic way to generate locally trusted certificates",
"license": "MIT",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion packages/independent/https-local/src/certificate_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const requestCertificate = ({
} = getAuthorityFileInfos();
if (!rootCertificateFileInfo.exists) {
throw new Error(
`Certificate authority not found, "installCertificateAuthority" must be called before "requestServerCertificate"`,
`Certificate authority not found, "installCertificateAuthority" must be called before "requestServerCertificate".
--- Suggested command to run ---
npx @jsenv/https-local install --trust`,
);
}
if (!rootCertificatePrivateKeyFileInfo.exists) {
Expand Down
17 changes: 16 additions & 1 deletion packages/independent/https-local/src/https_local_cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {
installCertificateAuthority,
uninstallCertificateAuthority,
verifyHostsFile,
} from "@jsenv/https-local";
import { parseArgs } from "node:util";

Expand All @@ -23,10 +24,16 @@ if (values.help || positionals.length === 0) {
console.log(`https-local: Generate https certificates to use on your machine.
Usage:
npx @jsenv/https-local install --trust
Install root certificate on the filesystem
- trust: Try to add root certificate to os and browser trusted stores.
npx @jsenv/https-local uninstall
Uninstall root certificate from the filesystem
trust: Try to add root certificate to os and browser trusted stores.
npx @jsenv/https-local localhost-mapping
Ensure localhost mapping to 127.0.0.1 is set on the filesystem
https://github.com/jsenv/core/tree/main/packages/independent/https-local
Expand All @@ -47,6 +54,14 @@ const commandHandlers = {
tryToUntrust: true,
});
},
["localhost-mapping"]: async () => {
await verifyHostsFile({
ipMappings: {
"127.0.0.1": ["localhost"],
},
tryToUpdatesHostsFile: true,
});
},
};

const [command] = positionals;
Expand Down
23 changes: 0 additions & 23 deletions scripts/dev/install_certificate_authority.mjs

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/test/certificate_install.mjs

This file was deleted.

3 changes: 1 addition & 2 deletions tests/build_server/manual/start_build_server.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { requestCertificate } from "@jsenv/https-local";

import { startBuildServer } from "@jsenv/core";
import { requestCertificate } from "@jsenv/https-local";

const { certificate, privateKey } = requestCertificate({ altNames: ["local"] });
await startBuildServer({
Expand Down

0 comments on commit 3030be8

Please sign in to comment.