Skip to content

Commit

Permalink
add npx @jsenv/https-local setup command
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Aug 14, 2024
1 parent 3030be8 commit 4376464
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 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: npm run certificate:install
run: npm run https:setup
- 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: npm run certificate:install
run: npm run https:setup
- name: Fix lightningcss windows
if: runner.os == 'Windows'
run: npm install lightningcss-win32-x64-msvc
Expand Down
2 changes: 1 addition & 1 deletion 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": "npx @jsenv/https-local install",
"https:setup": "npx @jsenv/https-local setup",
"prepublishOnly": "npm run build"
},
"dependencies": {
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.1",
"version": "3.2.0",
"description": "A programmatic way to generate locally trusted certificates",
"license": "MIT",
"repository": {
Expand Down
15 changes: 15 additions & 0 deletions packages/independent/https-local/src/https_local_cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down

0 comments on commit 4376464

Please sign in to comment.