@warp-drive/holodeck 0.0.0-alpha.96 → 0.0.0-alpha.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/server/ensure-cert.js +20 -12
- package/server/index.js +10 -22
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/holodeck",
|
|
3
3
|
"description": "⚡️ Simple, Fast HTTP Mocking for Tests",
|
|
4
|
-
"version": "0.0.0-alpha.
|
|
4
|
+
"version": "0.0.0-alpha.98",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
7
7
|
"repository": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"sync-hardlinks": "bun run sync-dependencies-meta-injected"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
48
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
47
|
+
"@ember-data/request": "5.4.0-alpha.112",
|
|
48
|
+
"@warp-drive/core-types": "0.0.0-alpha.98"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/core": "^7.24.5",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@babel/preset-env": "^7.24.5",
|
|
54
54
|
"@babel/preset-typescript": "^7.24.1",
|
|
55
55
|
"@babel/runtime": "^7.24.5",
|
|
56
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
57
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
58
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
56
|
+
"@ember-data/request": "5.4.0-alpha.112",
|
|
57
|
+
"@warp-drive/core-types": "0.0.0-alpha.98",
|
|
58
|
+
"@warp-drive/internal-config": "5.4.0-alpha.112",
|
|
59
59
|
"pnpm-sync-dependencies-meta-injected": "0.0.14",
|
|
60
60
|
"typescript": "^5.4.5",
|
|
61
61
|
"vite": "^5.2.11"
|
package/server/ensure-cert.js
CHANGED
|
@@ -23,18 +23,26 @@ function main() {
|
|
|
23
23
|
let KEY_PATH = process.env.HOLODECK_SSL_KEY_PATH;
|
|
24
24
|
const configFilePath = getShellConfigFilePath();
|
|
25
25
|
|
|
26
|
-
if (!CERT_PATH) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
if (!CERT_PATH || !KEY_PATH) {
|
|
27
|
+
console.log(`Environment variables not found, updating the environment config file...\n`);
|
|
28
|
+
|
|
29
|
+
if (!CERT_PATH) {
|
|
30
|
+
CERT_PATH = path.join(homedir(), 'holodeck-localhost.pem');
|
|
31
|
+
process.env.HOLODECK_SSL_CERT_PATH = CERT_PATH;
|
|
32
|
+
execSync(`echo '\nexport HOLODECK_SSL_CERT_PATH="${CERT_PATH}"' >> ${configFilePath}`);
|
|
33
|
+
console.log(`Added HOLODECK_SSL_CERT_PATH to ${configFilePath}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!KEY_PATH) {
|
|
37
|
+
KEY_PATH = path.join(homedir(), 'holodeck-localhost-key.pem');
|
|
38
|
+
process.env.HOLODECK_SSL_KEY_PATH = KEY_PATH;
|
|
39
|
+
execSync(`echo '\nexport HOLODECK_SSL_KEY_PATH="${KEY_PATH}"' >> ${configFilePath}`);
|
|
40
|
+
console.log(`Added HOLODECK_SSL_KEY_PATH to ${configFilePath}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(
|
|
44
|
+
`\n*** Please restart your terminal session to apply the changes or run \`source ${configFilePath}\`. ***\n`
|
|
45
|
+
);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
if (!fs.existsSync(CERT_PATH) || !fs.existsSync(KEY_PATH)) {
|
package/server/index.js
CHANGED
|
@@ -5,12 +5,11 @@ import { Hono } from 'hono';
|
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
6
6
|
import { HTTPException } from 'hono/http-exception';
|
|
7
7
|
import { logger } from 'hono/logger';
|
|
8
|
-
import { execSync } from 'node:child_process';
|
|
9
8
|
import crypto from 'node:crypto';
|
|
10
9
|
import fs from 'node:fs';
|
|
11
10
|
import http2 from 'node:http2';
|
|
12
11
|
import zlib from 'node:zlib';
|
|
13
|
-
import { homedir
|
|
12
|
+
import { homedir } from 'os';
|
|
14
13
|
import path from 'path';
|
|
15
14
|
|
|
16
15
|
/** @type {import('bun-types')} */
|
|
@@ -18,41 +17,30 @@ const isBun = typeof Bun !== 'undefined';
|
|
|
18
17
|
const DEBUG = process.env.DEBUG?.includes('holodeck') || process.env.DEBUG === '*';
|
|
19
18
|
const CURRENT_FILE = new URL(import.meta.url).pathname;
|
|
20
19
|
|
|
21
|
-
function getShellConfigFilePath() {
|
|
22
|
-
const shell = userInfo().shell;
|
|
23
|
-
switch (shell) {
|
|
24
|
-
case '/bin/zsh':
|
|
25
|
-
return path.join(homedir(), '.zshrc');
|
|
26
|
-
case '/bin/bash':
|
|
27
|
-
return path.join(homedir(), '.bashrc');
|
|
28
|
-
default:
|
|
29
|
-
throw Error(
|
|
30
|
-
`Unable to determine configuration file for shell: ${shell}. Manual SSL Cert Setup Required for Holodeck.`
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
20
|
function getCertInfo() {
|
|
36
21
|
let CERT_PATH = process.env.HOLODECK_SSL_CERT_PATH;
|
|
37
22
|
let KEY_PATH = process.env.HOLODECK_SSL_KEY_PATH;
|
|
38
|
-
const configFilePath = getShellConfigFilePath();
|
|
39
23
|
|
|
40
24
|
if (!CERT_PATH) {
|
|
41
25
|
CERT_PATH = path.join(homedir(), 'holodeck-localhost.pem');
|
|
42
26
|
process.env.HOLODECK_SSL_CERT_PATH = CERT_PATH;
|
|
43
|
-
|
|
44
|
-
console.log(
|
|
27
|
+
|
|
28
|
+
console.log(
|
|
29
|
+
`HOLODECK_SSL_CERT_PATH was not found in the current environment. Setting it to default value of ${CERT_PATH}`
|
|
30
|
+
);
|
|
45
31
|
}
|
|
46
32
|
|
|
47
33
|
if (!KEY_PATH) {
|
|
48
34
|
KEY_PATH = path.join(homedir(), 'holodeck-localhost-key.pem');
|
|
49
35
|
process.env.HOLODECK_SSL_KEY_PATH = KEY_PATH;
|
|
50
|
-
|
|
51
|
-
console.log(
|
|
36
|
+
|
|
37
|
+
console.log(
|
|
38
|
+
`HOLODECK_SSL_KEY_PATH was not found in the current environment. Setting it to default value of ${KEY_PATH}`
|
|
39
|
+
);
|
|
52
40
|
}
|
|
53
41
|
|
|
54
42
|
if (!fs.existsSync(CERT_PATH) || !fs.existsSync(KEY_PATH)) {
|
|
55
|
-
throw new Error('SSL certificate or key not found, you may need to run `
|
|
43
|
+
throw new Error('SSL certificate or key not found, you may need to run `pnpx @warp-drive/holodeck ensure-cert`');
|
|
56
44
|
}
|
|
57
45
|
|
|
58
46
|
return {
|