Verified Commit e6887436 authored by Aral Balkan's avatar Aral Balkan
Browse files

Log format now matches that of Site.js

parent 720f5193
......@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Nothing yet.
## [5.1.1] - 2020-06-15
### Changed
- Log output now matches format of Site.js.
## [5.1.0] - 2020-04-16
### Added
......
......@@ -74,7 +74,7 @@ class AutoEncryptLocalhost {
// Create certificates.
if (!allOK()) {
log('\n 📜 ❨Auto Encrypt Localhost❩ Setting up…')
log('\n 📜 ❨auto-encrypt-localhost❩ Setting up…')
// On Linux and on macOS, mkcert uses the Mozilla nss library.
// Try to install this automatically and warn the person if we can’t so
......@@ -91,18 +91,18 @@ class AutoEncryptLocalhost {
try {
// Create the local certificate authority.
log(' 📜 ❨Auto Encrypt Localhost❩ Creating local certificate authority (local CA) using mkcert…')
log(' 📜 ❨auto-encrypt-localhost❩ Creating local certificate authority (local CA) using mkcert…')
childProcess.execFileSync(mkcertBinary, ['-install'], mkcertProcessOptions)
log(' 📜 ❨Auto Encrypt Localhost❩ Local certificate authority created.')
log(' 📜 ❨auto-encrypt-localhost❩ Local certificate authority created.')
// Create the local certificate.
log(' 📜 ❨Auto Encrypt Localhost❩ Creating local TLS certificates using mkcert…')
log(' 📜 ❨auto-encrypt-localhost❩ Creating local TLS certificates using mkcert…')
const createCertificateArguments = [
`-key-file=${keyFilePath}`,
`-cert-file=${certFilePath}`,
'localhost', '127.0.0.1', '::1'
]
childProcess.execFileSync(mkcertBinary, createCertificateArguments, mkcertProcessOptions)
log(' 📜 ❨Auto Encrypt Localhost❩ Local TLS certificates created.')
log(' 📜 ❨auto-encrypt-localhost❩ Local TLS certificates created.')
} catch (error) {
log('\n', error)
}
......@@ -111,7 +111,7 @@ class AutoEncryptLocalhost {
process.exit(1)
}
} else {
log('\n 📜 ❨Auto Encrypt Localhost❩ Local development TLS certificate exists.')
log('\n 📜 ❨auto-encrypt-localhost❩ Local development TLS certificate exists.')
}
// Add root store to Node to ensure Node recognises the certificates (e.g., when using https.get(), etc.)
......
......@@ -16,7 +16,7 @@ function installCertutil () {
// required on Windows.
} else {
// Unknown platform. This should have been caught earlier. Panic.
throw new Error(' 🤯 ❨Auto Encrypt Localhost❩ Panic: Unknown platform detected.', platform)
throw new Error(' 🤯 ❨auto-encrypt-localhost❩ Panic: Unknown platform detected.', platform)
}
}
......@@ -30,7 +30,7 @@ function installCertutil () {
function installCertutilOnLinux () {
if (commandExists('certutil')) return // Already installed
print(' 📜 ❨Auto Encrypt Localhost❩ Installing certutil dependency (Linux) ')
print(' 📜 ❨auto-encrypt-localhost❩ Installing certutil dependency (Linux) ')
let options = { env: process.env }
try {
if (commandExists('apt')) {
......@@ -39,19 +39,19 @@ function installCertutilOnLinux () {
childProcess.execSync('sudo apt-get install -y -q libnss3-tools', options)
} else if (commandExists('yum')) {
// Untested: if you test this, please let me know https://github.com/indie-mirror/https-server/issues
log('\n 🤪 ❨Auto Encrypt Localhost❩ Attempting to install required dependency using yum. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n')
log('\n 🤪 ❨auto-encrypt-localhost❩ Attempting to install required dependency using yum. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n')
childProcess.execSync('sudo yum install nss-tools', options)
log(' 📜 ❨Auto Encrypt Localhost❩ Certutil installed using yum.')
log(' 📜 ❨auto-encrypt-localhost❩ Certutil installed using yum.')
} else if (commandExists('pacman')) {
childProcess.execSync('sudo pacman -S nss', options)
log(' 📜 ❨Auto Encrypt Localhost❩ Certutil installed using pacman.')
log(' 📜 ❨auto-encrypt-localhost❩ Certutil installed using pacman.')
} else {
// Neither Homebrew nor MacPorts is installed. Warn the person.
log('\n ⚠️ ❨Auto Encrypt Localhost❩ Linux: No supported package manager found for installing certutil on Linux (tried apt, yum, and pacman. Please install certutil manually and run Auto Encrypt Localhost again. For more instructions on installing mkcert dependencies, please see https://github.com/FiloSottile/mkcert/\n')
log('\n ⚠️ ❨auto-encrypt-localhost❩ Linux: No supported package manager found for installing certutil on Linux (tried apt, yum, and pacman. Please install certutil manually and run Auto Encrypt Localhost again. For more instructions on installing mkcert dependencies, please see https://github.com/FiloSottile/mkcert/\n')
}
} catch (error) {
// There was an error and we couldn’t install the dependency. Warn the person.
log('\n ⚠️ ❨Auto Encrypt Localhost❩ Linux: Failed to install nss. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Chrome and Firefox', error)
log('\n ⚠️ ❨auto-encrypt-localhost❩ Linux: Failed to install nss. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Chrome and Firefox', error)
}
}
......@@ -70,17 +70,17 @@ function installCertutilOnDarwin() {
// with Firefox crashing).
try {
// Homebrew can take a long time start, show current status.
print(' 📜 ❨Auto Encrypt Localhost❩ Checking if certutil dependency is installed (Darwin) using Homebrew… ')
print(' 📜 ❨auto-encrypt-localhost❩ Checking if certutil dependency is installed (Darwin) using Homebrew… ')
childProcess.execSync('brew list nss >/dev/null 2>&1', options)
log(' ok.')
} catch (error) {
// NSS is not installed. Install it.
try {
print(' 📜 ❨Auto Encrypt Localhost❩ Installing certutil dependency (Darwin) using Homebrew… ')
print(' 📜 ❨auto-encrypt-localhost❩ Installing certutil dependency (Darwin) using Homebrew… ')
childProcess.execSync('brew install nss >/dev/null 2>&1', options)
log('done.')
} catch (error) {
log('\n ⚠️ ❨Auto Encrypt Localhost❩ macOS: Failed to install nss via Homebrew. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', error)
log('\n ⚠️ ❨auto-encrypt-localhost❩ macOS: Failed to install nss via Homebrew. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', error)
return
}
}
......@@ -88,7 +88,7 @@ function installCertutilOnDarwin() {
// Untested. This is based on the documentation at https://guide.macports.org/#using.port.installed. I don’t have MacPorts installed
// and it doesn’t play well with Homebrew so I won’t be testing this anytime soon. If you do, please let me know how it works
// by opening an issue on https://github.com/indie-mirror/https-server/issues
log('\n 🤪 ❨Auto Encrypt Localhost❩ Attempting to install required dependency using MacPorts. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n')
log('\n 🤪 ❨auto-encrypt-localhost❩ Attempting to install required dependency using MacPorts. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n')
try {
childProcess.execSync('port installed nss', options)
......@@ -97,13 +97,13 @@ function installCertutilOnDarwin() {
try {
childProcess.execSync('sudo port install nss', options)
} catch (error) {
log('\n ⚠️ ❨Auto Encrypt Localhost❩ macOS: Failed to install nss via MacPorts. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', error)
log('\n ⚠️ ❨auto-encrypt-localhost❩ macOS: Failed to install nss via MacPorts. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', error)
return
}
}
} else {
// Neither Homebrew nor MacPorts is installed. Warn the person.
log('\n ⚠️ ❨Auto Encrypt Localhost❩ macOS: Cannot install certutil (nss) as you don’t have Homebrew or MacPorts installed.\n\n If you want your certificate to work in Firefox, please install one of those package managers and then install nss manually:\n\n * Homebrew (https://brew.sh): brew install nss\n * MacPorts(https://macports.org): sudo port install nss\n')
log('\n ⚠️ ❨auto-encrypt-localhost❩ macOS: Cannot install certutil (nss) as you don’t have Homebrew or MacPorts installed.\n\n If you want your certificate to work in Firefox, please install one of those package managers and then install nss manually:\n\n * Homebrew (https://brew.sh): brew install nss\n * MacPorts(https://macports.org): sudo port install nss\n')
return
}
}
......
......@@ -49,7 +49,7 @@ function mkcertBinaryForThisMachine (settingsPath) {
const versionRegularExpression = /^mkcert-v(\d+\.\d+\.\d+)-/
const oldVersion = currentMkcertBinaryName.match(versionRegularExpression)[1]
const newVersion = mkcertBinaryName.match(versionRegularExpression)[1]
log(`\n 🔼 ❨Auto Encrypt Localhost❩ Upgrading mkcert from version ${oldVersion} to version ${newVersion}. Certificates will be recreated.`)
log(`\n 🔼 ❨auto-encrypt-localhost❩ Upgrading mkcert from version ${oldVersion} to version ${newVersion}. Certificates will be recreated.`)
fs.removeSync(settingsPath)
fs.ensureDirSync(settingsPath)
}
......@@ -65,7 +65,7 @@ function mkcertBinaryForThisMachine (settingsPath) {
const mkcertBuffer = fs.readFileSync(mkcertBinaryInternalPath, 'binary')
fs.writeFileSync(mkcertBinaryExternalPath, mkcertBuffer, {encoding: 'binary', mode: 0o755})
} catch (error) {
throw new Error(` 🤯 ❨Auto Encrypt Localhost❩ Panic: Could not copy mkcert to external directory: ${error.message}`)
throw new Error(` 🤯 ❨auto-encrypt-localhost❩ Panic: Could not copy mkcert to external directory: ${error.message}`)
}
}
......
{
"name": "@small-tech/auto-encrypt-localhost",
"version": "5.1.0",
"version": "5.1.1",
"description": "Automatically provisions and installs locally-trusted TLS certificates for Node.js https servers (including Express.js, etc.) using mkcert.",
"keywords": [
"mkcert",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment