diff --git a/.github/workflows/ci_eslint_and_test.yml b/.github/workflows/ci_eslint_and_test.yml index e78854e100..775d5a5613 100644 --- a/.github/workflows/ci_eslint_and_test.yml +++ b/.github/workflows/ci_eslint_and_test.yml @@ -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: npm run certificate:install + run: npm run https:setup - name: Fix lightningcss windows if: runner.os == 'Windows' run: npm install lightningcss-win32-x64-msvc diff --git a/.github/workflows/ci_test_workspace.yml b/.github/workflows/ci_test_workspace.yml index 4d0b55b879..041374d91a 100644 --- a/.github/workflows/ci_test_workspace.yml +++ b/.github/workflows/ci_test_workspace.yml @@ -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: npm run certificate:install + run: npm run https:setup - name: Fix lightningcss windows if: runner.os == 'Windows' run: npm install lightningcss-win32-x64-msvc diff --git a/package.json b/package.json index 8250b159c7..757e5b18a3 100644 --- a/package.json +++ b/package.json @@ -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": "npx @jsenv/https-local install", + "https:setup": "npx @jsenv/https-local setup", "prepublishOnly": "npm run build" }, "dependencies": { diff --git a/packages/independent/https-local/package.json b/packages/independent/https-local/package.json index dafe532079..260d6463d6 100644 --- a/packages/independent/https-local/package.json +++ b/packages/independent/https-local/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/https-local", - "version": "3.1.1", + "version": "3.2.0", "description": "A programmatic way to generate locally trusted certificates", "license": "MIT", "repository": { diff --git a/packages/independent/https-local/src/https_local_cli.mjs b/packages/independent/https-local/src/https_local_cli.mjs index 12a6a68a5c..aa79feeb65 100755 --- a/packages/independent/https-local/src/https_local_cli.mjs +++ b/packages/independent/https-local/src/https_local_cli.mjs @@ -25,6 +25,9 @@ if (values.help || positionals.length === 0) { Usage: +npx @jsenv/https-local setup + Install root certificate, try to trust it and ensure localhost is mapped to 127.0.0.1 + npx @jsenv/https-local install --trust Install root certificate on the filesystem - trust: Try to add root certificate to os and browser trusted stores. @@ -43,6 +46,18 @@ https://github.com/jsenv/core/tree/main/packages/independent/https-local } const commandHandlers = { + setup: async () => { + await installCertificateAuthority({ + tryToTrust: true, + NSSDynamicInstall: true, + }); + await verifyHostsFile({ + ipMappings: { + "127.0.0.1": ["localhost"], + }, + tryToUpdatesHostsFile: true, + }); + }, install: async ({ tryToTrust }) => { await installCertificateAuthority({ tryToTrust,