unplugin-https-reverse-proxy 1.0.0-beta.9 → 2.0.0
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/README.md +17 -3
- package/dist/chunk-2P7SUCQ3.js +63 -0
- package/dist/{chunk-ZSHTX2B6.js → chunk-SO2FMQ2Q.js} +324 -135
- package/dist/esbuild.cjs +352 -160
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +352 -160
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +325 -142
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +7 -7
- package/dist/rollup.cjs +352 -160
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +352 -160
- package/dist/rspack.js +2 -2
- package/dist/types.cjs +1 -1
- package/dist/utils.cjs +26 -6
- package/dist/utils.d.cts +6 -4
- package/dist/utils.d.ts +6 -4
- package/dist/utils.js +5 -1
- package/dist/vite.cjs +352 -160
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +352 -160
- package/dist/webpack.js +2 -2
- package/package.json +38 -32
- package/scripts/postinstall.cjs +314 -0
- package/src/caddy/constants.ts +3 -2
- package/src/caddy/index.ts +254 -102
- package/src/caddy/utils.ts +24 -6
- package/src/host/index.ts +18 -23
- package/src/index.ts +68 -25
- package/src/nuxt.ts +10 -8
- package/src/utils.ts +33 -6
- package/dist/chunk-RUJE3YFB.js +0 -63
- package/scripts/postinstall.ts +0 -19
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-https-reverse-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
5
|
-
"packageManager": "pnpm@8.15.3",
|
|
4
|
+
"version": "2.0.0",
|
|
6
5
|
"description": "",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
},
|
|
77
76
|
"files": [
|
|
78
77
|
"dist",
|
|
79
|
-
"scripts/postinstall.
|
|
78
|
+
"scripts/postinstall.cjs",
|
|
80
79
|
"src"
|
|
81
80
|
],
|
|
82
81
|
"peerDependencies": {
|
|
@@ -85,73 +84,80 @@
|
|
|
85
84
|
"@rsbuild/core": "^0.4.3",
|
|
86
85
|
"@rspack/core": "^0.5.4",
|
|
87
86
|
"esbuild": "*",
|
|
87
|
+
"proper-lockfile": "^4.1.2",
|
|
88
88
|
"rollup": "^3",
|
|
89
89
|
"vite": ">=3",
|
|
90
90
|
"webpack": "^4 || ^5"
|
|
91
91
|
},
|
|
92
92
|
"peerDependenciesMeta": {
|
|
93
|
-
"
|
|
93
|
+
"@nuxt/kit": {
|
|
94
94
|
"optional": true
|
|
95
95
|
},
|
|
96
|
-
"@
|
|
96
|
+
"@nuxt/schema": {
|
|
97
97
|
"optional": true
|
|
98
98
|
},
|
|
99
99
|
"@rsbuild/core": {
|
|
100
100
|
"optional": true
|
|
101
101
|
},
|
|
102
|
-
"
|
|
102
|
+
"@rspack/core": {
|
|
103
103
|
"optional": true
|
|
104
104
|
},
|
|
105
|
-
"
|
|
105
|
+
"esbuild": {
|
|
106
106
|
"optional": true
|
|
107
107
|
},
|
|
108
|
-
"
|
|
108
|
+
"rollup": {
|
|
109
109
|
"optional": true
|
|
110
110
|
},
|
|
111
|
-
"
|
|
111
|
+
"vite": {
|
|
112
112
|
"optional": true
|
|
113
113
|
},
|
|
114
|
-
"
|
|
114
|
+
"webpack": {
|
|
115
115
|
"optional": true
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"consola": "^3.2
|
|
119
|
+
"consola": "^3.4.2",
|
|
120
|
+
"console-table-printer": "^2.12.1",
|
|
120
121
|
"dotenv-flow": "^4.1.0",
|
|
121
122
|
"got-cjs": "^12.5.4",
|
|
122
|
-
"
|
|
123
|
+
"hostile": "^1.4.0",
|
|
123
124
|
"http-proxy-agent": "^7.0.2",
|
|
124
|
-
"https-proxy-agent": "^7.0.
|
|
125
|
-
"kill-port": "^2.0.1",
|
|
125
|
+
"https-proxy-agent": "^7.0.6",
|
|
126
126
|
"ora": "5",
|
|
127
|
-
"picocolors": "^1.
|
|
128
|
-
"
|
|
129
|
-
"unplugin": "^
|
|
127
|
+
"picocolors": "^1.1.1",
|
|
128
|
+
"qrcode-terminal": "^0.12.0",
|
|
129
|
+
"unplugin": "^2.2.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"@antfu/eslint-config": "^
|
|
133
|
-
"@nuxt/kit": "^3.
|
|
134
|
-
"@nuxt/schema": "^3.
|
|
135
|
-
"@rsbuild/core": "^0.4.
|
|
136
|
-
"@rspack/core": "^0.5.
|
|
132
|
+
"@antfu/eslint-config": "^4.10.2",
|
|
133
|
+
"@nuxt/kit": "^3.16.1",
|
|
134
|
+
"@nuxt/schema": "^3.16.1",
|
|
135
|
+
"@rsbuild/core": "^0.4.15",
|
|
136
|
+
"@rspack/core": "^0.5.9",
|
|
137
|
+
"@types/hostile": "^1.3.5",
|
|
137
138
|
"@types/kill-port": "^2.0.3",
|
|
138
139
|
"@types/node": "^20.11.19",
|
|
140
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
141
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
139
142
|
"@vue/cli": "^5.0.8",
|
|
140
|
-
"bumpp": "^9.
|
|
141
|
-
"chalk": "^5.
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
143
|
+
"bumpp": "^9.11.1",
|
|
144
|
+
"chalk": "^5.4.1",
|
|
145
|
+
"cross-env": "^7.0.3",
|
|
146
|
+
"eslint": "^9.20.0",
|
|
147
|
+
"fast-glob": "^3.3.3",
|
|
148
|
+
"nodemon": "^3.1.9",
|
|
149
|
+
"proper-lockfile": "^4.1.2",
|
|
150
|
+
"rimraf": "^5.0.10",
|
|
146
151
|
"rollup": "^3.29.4",
|
|
147
152
|
"tsup": "^7.3.0",
|
|
148
|
-
"
|
|
153
|
+
"tsx": "^4.19.3",
|
|
154
|
+
"typescript": "^5.8.0",
|
|
149
155
|
"vite": "^4.5.2",
|
|
150
|
-
"vitest": "^0.
|
|
156
|
+
"vitest": "^3.0.9",
|
|
151
157
|
"webpack": "^5.90.3"
|
|
152
158
|
},
|
|
153
159
|
"scripts": {
|
|
154
|
-
"postinstall": "
|
|
160
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
155
161
|
"build": "tsup",
|
|
156
162
|
"dev": "tsup --watch src",
|
|
157
163
|
"build:fix": "tsx scripts/postbuild.ts",
|
|
@@ -163,6 +169,6 @@
|
|
|
163
169
|
"play:vuecli4": "npm -C examples/vuecli4 run serve",
|
|
164
170
|
"release": "bumpp",
|
|
165
171
|
"start": "tsx src/index.ts",
|
|
166
|
-
"test": "vitest"
|
|
172
|
+
"test": "cross-env UHRP_CADDY_PATH='./test/.uhrp' vitest"
|
|
167
173
|
}
|
|
168
174
|
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// scripts/postinstall.ts
|
|
26
|
+
var import_node_fs3 = require("fs");
|
|
27
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
28
|
+
|
|
29
|
+
// src/caddy/index.ts
|
|
30
|
+
var import_node_child_process4 = require("child_process");
|
|
31
|
+
var import_node_fs2 = require("fs");
|
|
32
|
+
var import_promises2 = require("fs/promises");
|
|
33
|
+
var import_node_os3 = require("os");
|
|
34
|
+
var import_node_path3 = require("path");
|
|
35
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
36
|
+
var import_got_cjs = require("got-cjs");
|
|
37
|
+
var import_http_proxy_agent = require("http-proxy-agent");
|
|
38
|
+
var import_https_proxy_agent = require("https-proxy-agent");
|
|
39
|
+
var lockfile = __toESM(require("proper-lockfile"), 1);
|
|
40
|
+
|
|
41
|
+
// src/host/index.ts
|
|
42
|
+
var import_node_child_process2 = require("child_process");
|
|
43
|
+
var import_node_fs = require("fs");
|
|
44
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
45
|
+
var import_node_util = require("util");
|
|
46
|
+
var import_hostile = __toESM(require("hostile"), 1);
|
|
47
|
+
|
|
48
|
+
// src/utils.ts
|
|
49
|
+
var import_node_child_process = require("child_process");
|
|
50
|
+
var import_promises = require("fs/promises");
|
|
51
|
+
var import_node_os = require("os");
|
|
52
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
53
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
54
|
+
var import_consola = require("consola");
|
|
55
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
56
|
+
var import_qrcode_terminal = __toESM(require("qrcode-terminal"), 1);
|
|
57
|
+
var consola = (0, import_consola.createConsola)({
|
|
58
|
+
level: 3
|
|
59
|
+
}).withTag("reverse-proxy");
|
|
60
|
+
function once(fn) {
|
|
61
|
+
let called = false;
|
|
62
|
+
return (...args) => {
|
|
63
|
+
if (called)
|
|
64
|
+
return;
|
|
65
|
+
called = true;
|
|
66
|
+
return fn(...args);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/host/index.ts
|
|
71
|
+
var _setHost = (0, import_node_util.promisify)(import_hostile.default.set);
|
|
72
|
+
var _removeHost = (0, import_node_util.promisify)(import_hostile.default.remove);
|
|
73
|
+
|
|
74
|
+
// src/caddy/constants.ts
|
|
75
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
76
|
+
var import_node_path2 = require("path");
|
|
77
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
78
|
+
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
79
|
+
import_dotenv_flow.default.config({
|
|
80
|
+
silent: true
|
|
81
|
+
});
|
|
82
|
+
function resolvePath(path2) {
|
|
83
|
+
if (path2.startsWith("~"))
|
|
84
|
+
return (0, import_node_path2.join)(import_node_os2.default.homedir() || "", path2.slice(1));
|
|
85
|
+
return path2;
|
|
86
|
+
}
|
|
87
|
+
var TEMP_DIR = resolvePath(import_node_process3.default.env.UHRP_CADDY_PATH || import_node_process3.default.env.TEMP || import_node_process3.default.env.TMPDIR || "/tmp");
|
|
88
|
+
var caddyPath = (0, import_node_path2.join)(TEMP_DIR, `caddy${import_node_process3.default.platform === "win32" ? ".exe" : ""}`);
|
|
89
|
+
var caddyFilePath = (0, import_node_path2.join)(TEMP_DIR, "CADDYFILE");
|
|
90
|
+
var caddyLockFilePath = (0, import_node_path2.join)(TEMP_DIR, "caddylock");
|
|
91
|
+
var supportList = [
|
|
92
|
+
{
|
|
93
|
+
platform: "dragonfly",
|
|
94
|
+
arch: "amd64"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
platform: "freebsd",
|
|
98
|
+
arch: "amd64"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
platform: "freebsd",
|
|
102
|
+
arch: "arm-6"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
platform: "freebsd",
|
|
106
|
+
arch: "arm-7"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
platform: "freebsd",
|
|
110
|
+
arch: "arm64"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
platform: "linux",
|
|
114
|
+
arch: "amd64"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
platform: "linux",
|
|
118
|
+
arch: "arm-5"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
platform: "linux",
|
|
122
|
+
arch: "arm-6"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
platform: "linux",
|
|
126
|
+
arch: "arm-7"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
platform: "linux",
|
|
130
|
+
arch: "arm64"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
platform: "linux",
|
|
134
|
+
arch: "mips"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
platform: "linux",
|
|
138
|
+
arch: "mips64"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
platform: "linux",
|
|
142
|
+
arch: "mips64le"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
platform: "linux",
|
|
146
|
+
arch: "mipsle"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
platform: "linux",
|
|
150
|
+
arch: "ppc64"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
platform: "linux",
|
|
154
|
+
arch: "ppc64le"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
platform: "linux",
|
|
158
|
+
arch: "s390x"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
platform: "darwin",
|
|
162
|
+
arch: "amd64"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
platform: "darwin",
|
|
166
|
+
arch: "arm64"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
platform: "openbsd",
|
|
170
|
+
arch: "amd64"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
platform: "openbsd",
|
|
174
|
+
arch: "arm-6"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
platform: "openbsd",
|
|
178
|
+
arch: "arm-7"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
platform: "openbsd",
|
|
182
|
+
arch: "arm64"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
platform: "windows",
|
|
186
|
+
arch: "amd64"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
platform: "windows",
|
|
190
|
+
arch: "arm-6"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
platform: "windows",
|
|
194
|
+
arch: "arm-7"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
platform: "windows",
|
|
198
|
+
arch: "arm64"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
// src/caddy/utils.ts
|
|
203
|
+
var import_node_child_process3 = require("child_process");
|
|
204
|
+
var import_node_net = require("net");
|
|
205
|
+
var import_ora = __toESM(require("ora"), 1);
|
|
206
|
+
var spinner;
|
|
207
|
+
function getNumber(number) {
|
|
208
|
+
if (number <= 0)
|
|
209
|
+
return "0%";
|
|
210
|
+
else if (number < 100)
|
|
211
|
+
return `${number.toFixed(2)}%`;
|
|
212
|
+
else
|
|
213
|
+
return "100%";
|
|
214
|
+
}
|
|
215
|
+
function logProgress(percent) {
|
|
216
|
+
if (!spinner) {
|
|
217
|
+
consola.log("");
|
|
218
|
+
spinner = (0, import_ora.default)({
|
|
219
|
+
text: "Start Download Caddy: 0%",
|
|
220
|
+
indent: 2
|
|
221
|
+
});
|
|
222
|
+
spinner.start();
|
|
223
|
+
} else {
|
|
224
|
+
spinner.text = `Download Caddy: ${getNumber(Number(percent) * 100)}`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function logProgressOver() {
|
|
228
|
+
if (!spinner) {
|
|
229
|
+
spinner = (0, import_ora.default)({
|
|
230
|
+
text: "Start Download Caddy: 100%",
|
|
231
|
+
indent: 2
|
|
232
|
+
});
|
|
233
|
+
spinner.start();
|
|
234
|
+
} else {
|
|
235
|
+
spinner.succeed();
|
|
236
|
+
consola.log("");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/caddy/index.ts
|
|
241
|
+
async function download() {
|
|
242
|
+
if (await testCaddy())
|
|
243
|
+
return caddyPath;
|
|
244
|
+
return new Promise((resolve, reject) => {
|
|
245
|
+
if (!(0, import_node_fs2.existsSync)(TEMP_DIR)) {
|
|
246
|
+
(0, import_node_fs2.mkdirSync)(TEMP_DIR, { recursive: true });
|
|
247
|
+
(0, import_node_fs2.chmodSync)(TEMP_DIR, 511);
|
|
248
|
+
}
|
|
249
|
+
const file = (0, import_node_fs2.createWriteStream)(caddyPath);
|
|
250
|
+
let _platform = (0, import_node_os3.platform)().toString();
|
|
251
|
+
_platform === "win32" && (_platform = "windows");
|
|
252
|
+
let _arch = import_node_process4.default.arch.toString();
|
|
253
|
+
_arch === "x64" && (_arch = "amd64");
|
|
254
|
+
const support = supportList.find((item) => item.platform === _platform && item.arch === _arch);
|
|
255
|
+
if (!support)
|
|
256
|
+
return reject(new Error("not support"));
|
|
257
|
+
const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}&p=github.com%2Fcaddyserver%2Fforwardproxy`;
|
|
258
|
+
(0, import_node_fs2.existsSync)(caddyPath) && (0, import_node_fs2.unlinkSync)(caddyPath);
|
|
259
|
+
const httpProxy = import_node_process4.default.env.HTTP_PROXY || import_node_process4.default.env.http_proxy;
|
|
260
|
+
const httpsProxy = import_node_process4.default.env.HTTPS_PROXY || import_node_process4.default.env.https_proxy;
|
|
261
|
+
const httpAgent = httpProxy ? new import_http_proxy_agent.HttpProxyAgent(httpProxy) : void 0;
|
|
262
|
+
const httpsAgent = httpsProxy ? new import_https_proxy_agent.HttpsProxyAgent(httpsProxy) : void 0;
|
|
263
|
+
const chmodCaddyOnce = once(() => {
|
|
264
|
+
(0, import_node_fs2.chmodSync)(caddyPath, 511);
|
|
265
|
+
});
|
|
266
|
+
import_got_cjs.got.stream(dowmloadLink, {
|
|
267
|
+
agent: {
|
|
268
|
+
http: httpAgent,
|
|
269
|
+
https: httpsAgent
|
|
270
|
+
}
|
|
271
|
+
}).on("downloadProgress", (progress) => {
|
|
272
|
+
logProgress(progress.percent);
|
|
273
|
+
chmodCaddyOnce();
|
|
274
|
+
}).pipe(file).on("finish", () => {
|
|
275
|
+
logProgressOver();
|
|
276
|
+
if (import_node_process4.default.platform === "win32")
|
|
277
|
+
return resolve(caddyPath);
|
|
278
|
+
(0, import_node_fs2.chmodSync)(caddyPath, 511);
|
|
279
|
+
resolve(caddyPath);
|
|
280
|
+
}).on("error", (err) => {
|
|
281
|
+
reject(err);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function testCaddy() {
|
|
286
|
+
return new Promise((resolve, reject) => {
|
|
287
|
+
if (!(0, import_node_fs2.existsSync)(caddyPath))
|
|
288
|
+
return resolve(false);
|
|
289
|
+
(0, import_node_fs2.chmodSync)(caddyPath, 511);
|
|
290
|
+
const child = import_node_process4.default.platform === "win32" ? (0, import_node_child_process4.spawn)(caddyPath, []) : (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath]);
|
|
291
|
+
child.on("close", () => {
|
|
292
|
+
return resolve(false);
|
|
293
|
+
});
|
|
294
|
+
child.on("error", (err) => {
|
|
295
|
+
return reject(err);
|
|
296
|
+
});
|
|
297
|
+
child.stdout.on("data", (_data) => {
|
|
298
|
+
return resolve(true);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// scripts/postinstall.ts
|
|
304
|
+
async function run() {
|
|
305
|
+
try {
|
|
306
|
+
if (import_node_process5.default.env.UHRP_AUTO_INSTALL_CADDY) {
|
|
307
|
+
(0, import_node_fs3.existsSync)(caddyPath) && (0, import_node_fs3.unlinkSync)(caddyPath);
|
|
308
|
+
await download();
|
|
309
|
+
}
|
|
310
|
+
} catch (e) {
|
|
311
|
+
consola.error(e.code);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
run();
|
package/src/caddy/constants.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
1
|
import os from 'node:os'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
3
|
import process from 'node:process'
|
|
4
4
|
import dotenvFlow from 'dotenv-flow'
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ dotenvFlow.config({
|
|
|
7
7
|
silent: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
-
function resolvePath(path: string) {
|
|
10
|
+
function resolvePath(path: string): string {
|
|
11
11
|
if (path.startsWith('~'))
|
|
12
12
|
return join(os.homedir() || '', path.slice(1))
|
|
13
13
|
return path
|
|
@@ -16,6 +16,7 @@ function resolvePath(path: string) {
|
|
|
16
16
|
export const TEMP_DIR = resolvePath(process.env.UHRP_CADDY_PATH || process.env.TEMP || process.env.TMPDIR || '/tmp')
|
|
17
17
|
export const caddyPath = join(TEMP_DIR, `caddy${process.platform === 'win32' ? '.exe' : ''}`)
|
|
18
18
|
export const caddyFilePath = join(TEMP_DIR, 'CADDYFILE')
|
|
19
|
+
export const caddyLockFilePath = join(TEMP_DIR, 'caddylock')
|
|
19
20
|
|
|
20
21
|
export const supportList = [
|
|
21
22
|
{
|