unplugin-https-reverse-proxy 0.0.9 → 0.0.11
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 +8 -1
- package/dist/{chunk-H5P77DDT.js → chunk-5K6D2TTS.js} +15 -7
- package/dist/{chunk-JN5C2QIT.js → chunk-BFAT7WWW.js} +1 -1
- package/dist/{chunk-HSJJYR6E.js → chunk-UGVWTB7L.js} +1 -1
- package/dist/esbuild.cjs +15 -7
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +15 -7
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +15 -7
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +15 -7
- package/dist/rollup.js +1 -1
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/vite.cjs +15 -7
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +15 -7
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
- package/src/caddy/index.ts +13 -4
- package/src/index.ts +4 -1
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ UHRP_AUTO_INSTALL_CADDY=true npm i unplugin-https-reverse-proxy --save-dev
|
|
|
17
17
|
```ts
|
|
18
18
|
interface Options {
|
|
19
19
|
target: string // <- https target hostname
|
|
20
|
+
showCaddyLog?: boolean // <- default: false
|
|
20
21
|
}
|
|
21
22
|
```
|
|
22
23
|
|
|
@@ -115,4 +116,10 @@ sudo -E npm run dev # your dev script
|
|
|
115
116
|
# windows
|
|
116
117
|
# use powershell as administrator
|
|
117
118
|
npm run dev # your dev script
|
|
118
|
-
```
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If your broswer shows a not trusted certificate warning, please check the keychain.
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
More info, you can check [caddy about CA Root](https://caddyserver.com/docs/automatic-https#ca-root).
|
|
@@ -197,7 +197,7 @@ function testCaddy() {
|
|
|
197
197
|
chmodSync(caddyPath, 493);
|
|
198
198
|
const child = process2.platform === "win32" ? spawn(caddyPath, []) : spawn("sudo", [caddyPath]);
|
|
199
199
|
child.on("close", () => {
|
|
200
|
-
return resolve(
|
|
200
|
+
return resolve(false);
|
|
201
201
|
});
|
|
202
202
|
child.on("error", (err) => {
|
|
203
203
|
return reject(err);
|
|
@@ -275,7 +275,8 @@ var CaddyInstant = class {
|
|
|
275
275
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
276
276
|
const {
|
|
277
277
|
restore = true,
|
|
278
|
-
base = "/"
|
|
278
|
+
base = "/",
|
|
279
|
+
showCaddyLog = false
|
|
279
280
|
} = options || {};
|
|
280
281
|
if (!this.inited)
|
|
281
282
|
await this.init();
|
|
@@ -291,9 +292,13 @@ var CaddyInstant = class {
|
|
|
291
292
|
return reject(err);
|
|
292
293
|
});
|
|
293
294
|
child.stderr.on("data", (data) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
296
|
+
for (const line of lines) {
|
|
297
|
+
showCaddyLog && line && console.info(line);
|
|
298
|
+
if (line && JSON.parse(line).level === "error") {
|
|
299
|
+
consola.error(line);
|
|
300
|
+
return reject(line);
|
|
301
|
+
}
|
|
297
302
|
}
|
|
298
303
|
});
|
|
299
304
|
child.stdout.on("data", (_data) => {
|
|
@@ -344,7 +349,8 @@ var unpluginFactory = (options) => ({
|
|
|
344
349
|
try {
|
|
345
350
|
const caddy2 = new CaddyInstant();
|
|
346
351
|
caddy2.run(source, target, {
|
|
347
|
-
base
|
|
352
|
+
base,
|
|
353
|
+
showCaddyLog: options.showCaddyLog
|
|
348
354
|
}).then((stop) => {
|
|
349
355
|
const colorUrl = (url2) => c.green(url2.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
350
356
|
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -374,7 +380,9 @@ var unpluginFactory = (options) => ({
|
|
|
374
380
|
if (caddy)
|
|
375
381
|
return;
|
|
376
382
|
caddy = new CaddyInstant();
|
|
377
|
-
caddy.run(source, target
|
|
383
|
+
caddy.run(source, target, {
|
|
384
|
+
showCaddyLog: options.showCaddyLog
|
|
385
|
+
}).then((stop) => {
|
|
378
386
|
const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
379
387
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
380
388
|
if (stats.hasErrors())
|
package/dist/esbuild.cjs
CHANGED
|
@@ -236,7 +236,7 @@ function testCaddy() {
|
|
|
236
236
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
237
237
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
238
238
|
child.on("close", () => {
|
|
239
|
-
return resolve(
|
|
239
|
+
return resolve(false);
|
|
240
240
|
});
|
|
241
241
|
child.on("error", (err) => {
|
|
242
242
|
return reject(err);
|
|
@@ -314,7 +314,8 @@ var CaddyInstant = class {
|
|
|
314
314
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
315
315
|
const {
|
|
316
316
|
restore = true,
|
|
317
|
-
base = "/"
|
|
317
|
+
base = "/",
|
|
318
|
+
showCaddyLog = false
|
|
318
319
|
} = options || {};
|
|
319
320
|
if (!this.inited)
|
|
320
321
|
await this.init();
|
|
@@ -330,9 +331,13 @@ var CaddyInstant = class {
|
|
|
330
331
|
return reject(err);
|
|
331
332
|
});
|
|
332
333
|
child.stderr.on("data", (data) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
335
|
+
for (const line of lines) {
|
|
336
|
+
showCaddyLog && line && console.info(line);
|
|
337
|
+
if (line && JSON.parse(line).level === "error") {
|
|
338
|
+
consola.error(line);
|
|
339
|
+
return reject(line);
|
|
340
|
+
}
|
|
336
341
|
}
|
|
337
342
|
});
|
|
338
343
|
child.stdout.on("data", (_data) => {
|
|
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
388
|
try {
|
|
384
389
|
const caddy2 = new CaddyInstant();
|
|
385
390
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
391
|
+
base,
|
|
392
|
+
showCaddyLog: options.showCaddyLog
|
|
387
393
|
}).then((stop) => {
|
|
388
394
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
395
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
419
|
if (caddy)
|
|
414
420
|
return;
|
|
415
421
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
422
|
+
caddy.run(source, target, {
|
|
423
|
+
showCaddyLog: options.showCaddyLog
|
|
424
|
+
}).then((stop) => {
|
|
417
425
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
426
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
427
|
if (stats.hasErrors())
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -235,7 +235,7 @@ function testCaddy() {
|
|
|
235
235
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
236
236
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
237
237
|
child.on("close", () => {
|
|
238
|
-
return resolve(
|
|
238
|
+
return resolve(false);
|
|
239
239
|
});
|
|
240
240
|
child.on("error", (err) => {
|
|
241
241
|
return reject(err);
|
|
@@ -313,7 +313,8 @@ var CaddyInstant = class {
|
|
|
313
313
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
314
314
|
const {
|
|
315
315
|
restore = true,
|
|
316
|
-
base = "/"
|
|
316
|
+
base = "/",
|
|
317
|
+
showCaddyLog = false
|
|
317
318
|
} = options || {};
|
|
318
319
|
if (!this.inited)
|
|
319
320
|
await this.init();
|
|
@@ -329,9 +330,13 @@ var CaddyInstant = class {
|
|
|
329
330
|
return reject(err);
|
|
330
331
|
});
|
|
331
332
|
child.stderr.on("data", (data) => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
334
|
+
for (const line of lines) {
|
|
335
|
+
showCaddyLog && line && console.info(line);
|
|
336
|
+
if (line && JSON.parse(line).level === "error") {
|
|
337
|
+
consola.error(line);
|
|
338
|
+
return reject(line);
|
|
339
|
+
}
|
|
335
340
|
}
|
|
336
341
|
});
|
|
337
342
|
child.stdout.on("data", (_data) => {
|
|
@@ -382,7 +387,8 @@ var unpluginFactory = (options) => ({
|
|
|
382
387
|
try {
|
|
383
388
|
const caddy2 = new CaddyInstant();
|
|
384
389
|
caddy2.run(source, target, {
|
|
385
|
-
base
|
|
390
|
+
base,
|
|
391
|
+
showCaddyLog: options.showCaddyLog
|
|
386
392
|
}).then((stop) => {
|
|
387
393
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
388
394
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -412,7 +418,9 @@ var unpluginFactory = (options) => ({
|
|
|
412
418
|
if (caddy)
|
|
413
419
|
return;
|
|
414
420
|
caddy = new CaddyInstant();
|
|
415
|
-
caddy.run(source, target
|
|
421
|
+
caddy.run(source, target, {
|
|
422
|
+
showCaddyLog: options.showCaddyLog
|
|
423
|
+
}).then((stop) => {
|
|
416
424
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
417
425
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
418
426
|
if (stats.hasErrors())
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -239,7 +239,7 @@ function testCaddy() {
|
|
|
239
239
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
240
240
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
241
241
|
child.on("close", () => {
|
|
242
|
-
return resolve(
|
|
242
|
+
return resolve(false);
|
|
243
243
|
});
|
|
244
244
|
child.on("error", (err) => {
|
|
245
245
|
return reject(err);
|
|
@@ -317,7 +317,8 @@ var CaddyInstant = class {
|
|
|
317
317
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
318
318
|
const {
|
|
319
319
|
restore = true,
|
|
320
|
-
base = "/"
|
|
320
|
+
base = "/",
|
|
321
|
+
showCaddyLog = false
|
|
321
322
|
} = options || {};
|
|
322
323
|
if (!this.inited)
|
|
323
324
|
await this.init();
|
|
@@ -333,9 +334,13 @@ var CaddyInstant = class {
|
|
|
333
334
|
return reject(err);
|
|
334
335
|
});
|
|
335
336
|
child.stderr.on("data", (data) => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
337
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
338
|
+
for (const line of lines) {
|
|
339
|
+
showCaddyLog && line && console.info(line);
|
|
340
|
+
if (line && JSON.parse(line).level === "error") {
|
|
341
|
+
consola.error(line);
|
|
342
|
+
return reject(line);
|
|
343
|
+
}
|
|
339
344
|
}
|
|
340
345
|
});
|
|
341
346
|
child.stdout.on("data", (_data) => {
|
|
@@ -386,7 +391,8 @@ var unpluginFactory = (options) => ({
|
|
|
386
391
|
try {
|
|
387
392
|
const caddy2 = new CaddyInstant();
|
|
388
393
|
caddy2.run(source, target, {
|
|
389
|
-
base
|
|
394
|
+
base,
|
|
395
|
+
showCaddyLog: options.showCaddyLog
|
|
390
396
|
}).then((stop) => {
|
|
391
397
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
392
398
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -416,7 +422,9 @@ var unpluginFactory = (options) => ({
|
|
|
416
422
|
if (caddy)
|
|
417
423
|
return;
|
|
418
424
|
caddy = new CaddyInstant();
|
|
419
|
-
caddy.run(source, target
|
|
425
|
+
caddy.run(source, target, {
|
|
426
|
+
showCaddyLog: options.showCaddyLog
|
|
427
|
+
}).then((stop) => {
|
|
420
428
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
421
429
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
422
430
|
if (stats.hasErrors())
|
package/dist/nuxt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vite_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UGVWTB7L.js";
|
|
4
4
|
import {
|
|
5
5
|
webpack_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-BFAT7WWW.js";
|
|
7
|
+
import "./chunk-5K6D2TTS.js";
|
|
8
8
|
import "./chunk-3HKPYCSE.js";
|
|
9
9
|
|
|
10
10
|
// src/nuxt.ts
|
package/dist/rollup.cjs
CHANGED
|
@@ -236,7 +236,7 @@ function testCaddy() {
|
|
|
236
236
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
237
237
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
238
238
|
child.on("close", () => {
|
|
239
|
-
return resolve(
|
|
239
|
+
return resolve(false);
|
|
240
240
|
});
|
|
241
241
|
child.on("error", (err) => {
|
|
242
242
|
return reject(err);
|
|
@@ -314,7 +314,8 @@ var CaddyInstant = class {
|
|
|
314
314
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
315
315
|
const {
|
|
316
316
|
restore = true,
|
|
317
|
-
base = "/"
|
|
317
|
+
base = "/",
|
|
318
|
+
showCaddyLog = false
|
|
318
319
|
} = options || {};
|
|
319
320
|
if (!this.inited)
|
|
320
321
|
await this.init();
|
|
@@ -330,9 +331,13 @@ var CaddyInstant = class {
|
|
|
330
331
|
return reject(err);
|
|
331
332
|
});
|
|
332
333
|
child.stderr.on("data", (data) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
335
|
+
for (const line of lines) {
|
|
336
|
+
showCaddyLog && line && console.info(line);
|
|
337
|
+
if (line && JSON.parse(line).level === "error") {
|
|
338
|
+
consola.error(line);
|
|
339
|
+
return reject(line);
|
|
340
|
+
}
|
|
336
341
|
}
|
|
337
342
|
});
|
|
338
343
|
child.stdout.on("data", (_data) => {
|
|
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
388
|
try {
|
|
384
389
|
const caddy2 = new CaddyInstant();
|
|
385
390
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
391
|
+
base,
|
|
392
|
+
showCaddyLog: options.showCaddyLog
|
|
387
393
|
}).then((stop) => {
|
|
388
394
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
395
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
419
|
if (caddy)
|
|
414
420
|
return;
|
|
415
421
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
422
|
+
caddy.run(source, target, {
|
|
423
|
+
showCaddyLog: options.showCaddyLog
|
|
424
|
+
}).then((stop) => {
|
|
417
425
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
426
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
427
|
if (stats.hasErrors())
|
package/dist/rollup.js
CHANGED
package/dist/types.d.cts
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -236,7 +236,7 @@ function testCaddy() {
|
|
|
236
236
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
237
237
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
238
238
|
child.on("close", () => {
|
|
239
|
-
return resolve(
|
|
239
|
+
return resolve(false);
|
|
240
240
|
});
|
|
241
241
|
child.on("error", (err) => {
|
|
242
242
|
return reject(err);
|
|
@@ -314,7 +314,8 @@ var CaddyInstant = class {
|
|
|
314
314
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
315
315
|
const {
|
|
316
316
|
restore = true,
|
|
317
|
-
base = "/"
|
|
317
|
+
base = "/",
|
|
318
|
+
showCaddyLog = false
|
|
318
319
|
} = options || {};
|
|
319
320
|
if (!this.inited)
|
|
320
321
|
await this.init();
|
|
@@ -330,9 +331,13 @@ var CaddyInstant = class {
|
|
|
330
331
|
return reject(err);
|
|
331
332
|
});
|
|
332
333
|
child.stderr.on("data", (data) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
335
|
+
for (const line of lines) {
|
|
336
|
+
showCaddyLog && line && console.info(line);
|
|
337
|
+
if (line && JSON.parse(line).level === "error") {
|
|
338
|
+
consola.error(line);
|
|
339
|
+
return reject(line);
|
|
340
|
+
}
|
|
336
341
|
}
|
|
337
342
|
});
|
|
338
343
|
child.stdout.on("data", (_data) => {
|
|
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
388
|
try {
|
|
384
389
|
const caddy2 = new CaddyInstant();
|
|
385
390
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
391
|
+
base,
|
|
392
|
+
showCaddyLog: options.showCaddyLog
|
|
387
393
|
}).then((stop) => {
|
|
388
394
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
395
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
419
|
if (caddy)
|
|
414
420
|
return;
|
|
415
421
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
422
|
+
caddy.run(source, target, {
|
|
423
|
+
showCaddyLog: options.showCaddyLog
|
|
424
|
+
}).then((stop) => {
|
|
417
425
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
426
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
427
|
if (stats.hasErrors())
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -236,7 +236,7 @@ function testCaddy() {
|
|
|
236
236
|
(0, import_node_fs.chmodSync)(caddyPath, 493);
|
|
237
237
|
const child = import_node_process2.default.platform === "win32" ? (0, import_node_child_process.spawn)(caddyPath, []) : (0, import_node_child_process.spawn)("sudo", [caddyPath]);
|
|
238
238
|
child.on("close", () => {
|
|
239
|
-
return resolve(
|
|
239
|
+
return resolve(false);
|
|
240
240
|
});
|
|
241
241
|
child.on("error", (err) => {
|
|
242
242
|
return reject(err);
|
|
@@ -314,7 +314,8 @@ var CaddyInstant = class {
|
|
|
314
314
|
source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
|
|
315
315
|
const {
|
|
316
316
|
restore = true,
|
|
317
|
-
base = "/"
|
|
317
|
+
base = "/",
|
|
318
|
+
showCaddyLog = false
|
|
318
319
|
} = options || {};
|
|
319
320
|
if (!this.inited)
|
|
320
321
|
await this.init();
|
|
@@ -330,9 +331,13 @@ var CaddyInstant = class {
|
|
|
330
331
|
return reject(err);
|
|
331
332
|
});
|
|
332
333
|
child.stderr.on("data", (data) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
335
|
+
for (const line of lines) {
|
|
336
|
+
showCaddyLog && line && console.info(line);
|
|
337
|
+
if (line && JSON.parse(line).level === "error") {
|
|
338
|
+
consola.error(line);
|
|
339
|
+
return reject(line);
|
|
340
|
+
}
|
|
336
341
|
}
|
|
337
342
|
});
|
|
338
343
|
child.stdout.on("data", (_data) => {
|
|
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
388
|
try {
|
|
384
389
|
const caddy2 = new CaddyInstant();
|
|
385
390
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
391
|
+
base,
|
|
392
|
+
showCaddyLog: options.showCaddyLog
|
|
387
393
|
}).then((stop) => {
|
|
388
394
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
395
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
419
|
if (caddy)
|
|
414
420
|
return;
|
|
415
421
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
422
|
+
caddy.run(source, target, {
|
|
423
|
+
showCaddyLog: options.showCaddyLog
|
|
424
|
+
}).then((stop) => {
|
|
417
425
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
426
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
427
|
if (stats.hasErrors())
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/src/caddy/index.ts
CHANGED
|
@@ -67,7 +67,7 @@ function testCaddy() {
|
|
|
67
67
|
chmodSync(caddyPath, 0o755)
|
|
68
68
|
const child = process.platform === 'win32' ? spawn(caddyPath, []) : spawn('sudo', [caddyPath])
|
|
69
69
|
child.on('close', () => {
|
|
70
|
-
return resolve(
|
|
70
|
+
return resolve(false)
|
|
71
71
|
})
|
|
72
72
|
child.on('error', (err) => {
|
|
73
73
|
return reject(err)
|
|
@@ -81,6 +81,7 @@ function testCaddy() {
|
|
|
81
81
|
interface RunOptions {
|
|
82
82
|
restore: boolean
|
|
83
83
|
base: string
|
|
84
|
+
showCaddyLog: boolean
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
export class CaddyInstant {
|
|
@@ -161,6 +162,7 @@ export class CaddyInstant {
|
|
|
161
162
|
const {
|
|
162
163
|
restore = true,
|
|
163
164
|
base = '/',
|
|
165
|
+
showCaddyLog = false,
|
|
164
166
|
} = options || {}
|
|
165
167
|
|
|
166
168
|
if (!this.inited)
|
|
@@ -185,9 +187,16 @@ export class CaddyInstant {
|
|
|
185
187
|
})
|
|
186
188
|
|
|
187
189
|
child.stderr.on('data', (data) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
const lines = (data.toString() as string).split('\n').map(line => line.trim())
|
|
191
|
+
for (const line of lines) {
|
|
192
|
+
// caddy log
|
|
193
|
+
// eslint-disable-next-line no-console
|
|
194
|
+
showCaddyLog && line && console.info(line)
|
|
195
|
+
if (line && JSON.parse(line).level === 'error') {
|
|
196
|
+
consola.error(line)
|
|
197
|
+
// child.kill()
|
|
198
|
+
return reject(line)
|
|
199
|
+
}
|
|
191
200
|
}
|
|
192
201
|
})
|
|
193
202
|
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
40
40
|
const caddy = new CaddyInstant()
|
|
41
41
|
caddy.run(source, target, {
|
|
42
42
|
base,
|
|
43
|
+
showCaddyLog: options.showCaddyLog,
|
|
43
44
|
}).then((stop) => {
|
|
44
45
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
45
46
|
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`https://${target}${base}`)}`)
|
|
@@ -75,7 +76,9 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
75
76
|
|
|
76
77
|
caddy = new CaddyInstant()
|
|
77
78
|
|
|
78
|
-
caddy.run(source, target
|
|
79
|
+
caddy.run(source, target, {
|
|
80
|
+
showCaddyLog: options.showCaddyLog,
|
|
81
|
+
}).then((stop) => {
|
|
79
82
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
80
83
|
|
|
81
84
|
compiler.hooks.done.tap('unplugin-https-reverse-proxy', (stats) => {
|