Skip to content

Commit

Permalink
Merge branch 'master' of github.com:daquinoaldo/https-localhost into …
Browse files Browse the repository at this point in the history
…v5.0.0
  • Loading branch information
daquinoaldo committed Feb 24, 2020
2 parents e946fad + ac9c7ad commit c8d1f83
Show file tree
Hide file tree
Showing 8 changed files with 1,672 additions and 2,537 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
@@ -1,7 +1,7 @@
# These are supported funding model platforms

github: daquinoaldo
custom: paypal.me/daquinoaldo
# github: daquinoaldo

# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
# patreon: # Replace with a single Patreon username
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -5,12 +5,12 @@ on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ${{matrix.os}}
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node: [8, 10, 11, 12]
os: [ubuntu-latest, macOS-latest]
node: [10, 12, 13]
exclude:
- os: ubuntu-latest
node: 8
Expand Down
123 changes: 54 additions & 69 deletions .github/workflows/publish.yml
@@ -1,74 +1,59 @@
name: publish
name: publish

on: release
on: release

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test

build:
name: Build binaries
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: npm run build
run: |
npm install
npm run build
- name: upload linux binary
uses: actions/upload-artifact@master
with:
name: https-localhost-linux
build:
name: Build binaries
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: npm run build
run: |
npm install
npm run build
- name: upload linux binary
uses: actions/upload-artifact@master
with:
name: https-localhost-linux
path: build
- name: upload macos binary
uses: actions/upload-artifact@master
with:
name: https-localhost-macos
path: build
- name: upload windows binary
uses: actions/upload-artifact@master
with:
name: https-localhost-win.exe
path: build
- name: upload macos binary
uses: actions/upload-artifact@master
with:
name: https-localhost-macos
path: build
- name: upload windows binary
uses: actions/upload-artifact@master
with:
name: https-localhost-win.exe
path: build

publish-npm:
name: Publish NPM
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

publish-gpr:
name: Publish GitHub Packages
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: '@daquinoaldo'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
npm-publish:
name: Publish NPM
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -6,7 +6,5 @@ language: node_js
node_js:
- node
- 12
- 11
- 10
- 8
after_success: npm run coveralls
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -122,8 +122,8 @@ Checkout the updated list [here](https://github.com/FiloSottile/mkcert/blob/mast

## Troubleshooting
### Node.js version
https-localhost requires Node.js 8 or higher.
<sub>If you need compatibility with previously Node.js versions let me know, we'll try to rearrange the code.</sub>
https-localhost is compatible with the LTS and latest version of Node.js.
<sub>If you need compatibility with other Node.js versions let me know, we'll try to rearrange the code.</sub>

### root required
- **At first run** this tool generate a trusted certificate. The sudo password may be required. If you cannot provide the sudo password generate a `localhost.key` and `localhost.crt` and specify its path with `CERT_PATH=/diractory/containing/certificates/ serve ~/myproj`.
Expand Down
27 changes: 19 additions & 8 deletions certs.js
Expand Up @@ -6,7 +6,7 @@ const exec = require("child_process").exec
const https = require("https")
const getAppDataPath = require("appdata-path")

const MKCERT_VERSION = "v1.4.0"
const MKCERT_VERSION = "v1.4.1"
const CERT_PATH = getAppDataPath("https-localhost")

// check for updates
Expand Down Expand Up @@ -70,13 +70,24 @@ function download(url, path) {

// execute the binary executable to generate the certificates
function mkcert(appDataPath, exe, domain) {
const logPath = path.join(appDataPath, "mkcert.log")
const errPath = path.join(appDataPath, "mkcert.err")
// escape spaces in appDataPath (Mac OS)
appDataPath = appDataPath.replace(" ", "\\ ")
const exePath = path.join(appDataPath, exe)
const crtPath = path.join(appDataPath, domain + ".crt")
const keyPath = path.join(appDataPath, domain + ".key")
// fix problems with spaces
/* istanbul ignore next: platform dependent */
const ensureValidPath = function(path) {
// use apex on Windows
if (process.platform === "win32")
return "\"" + path + "\""
// escape spaces in Mac OS
if (process.platform === "darwin")
return path.replace(/ /g, "\\ ")
return path
}

const logPath = ensureValidPath(path.join(appDataPath, "mkcert.log"))
const errPath = ensureValidPath(path.join(appDataPath, "mkcert.err"))
const exePath = ensureValidPath(path.join(appDataPath, exe))
const crtPath = ensureValidPath(path.join(appDataPath, domain + ".crt"))
const keyPath = ensureValidPath(path.join(appDataPath, domain + ".key"))

const cmd = exePath + " -install -cert-file " + crtPath +
" -key-file " + keyPath + " " + domain
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit c8d1f83

Please sign in to comment.