unplugin-https-reverse-proxy 0.0.14 → 0.0.16
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 +5 -4
- package/dist/{chunk-IOQLAF3J.js → chunk-G5VIL2MO.js} +22 -17
- package/dist/{chunk-YJCVUFTG.js → chunk-HWUN3C5Q.js} +1 -1
- package/dist/{chunk-5OTBSQ6U.js → chunk-MPY62XIL.js} +1 -1
- package/dist/esbuild.cjs +22 -17
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +22 -17
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +22 -17
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +22 -17
- package/dist/rollup.js +1 -1
- package/dist/types.d.cts +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/vite.cjs +22 -17
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +22 -17
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
- package/src/caddy/index.ts +8 -3
- package/src/index.ts +13 -8
- package/src/types.ts +2 -0
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ interface Options {
|
|
|
19
19
|
enable?: boolean // <- default: true
|
|
20
20
|
target: string // <- https target hostname
|
|
21
21
|
showCaddyLog?: boolean // <- default: false
|
|
22
|
+
https?: boolean // <- default: false
|
|
22
23
|
}
|
|
23
24
|
```
|
|
24
25
|
|
|
@@ -51,9 +52,9 @@ module.exports = {
|
|
|
51
52
|
client: {
|
|
52
53
|
// ↓ for HMR
|
|
53
54
|
webSocketURL: {
|
|
54
|
-
protocol: 'wss',
|
|
55
|
+
// protocol: 'wss', // <- if you set options.https to `true`
|
|
56
|
+
// port: 443, // <- if you set options.https to `true`
|
|
55
57
|
hostname: 'xxx', // <- target hostname
|
|
56
|
-
port: 443,
|
|
57
58
|
},
|
|
58
59
|
},
|
|
59
60
|
setupExitSignals: true,
|
|
@@ -93,8 +94,8 @@ module.exports = {
|
|
|
93
94
|
client: {
|
|
94
95
|
// ↓ for HMR
|
|
95
96
|
webSocketURL: {
|
|
96
|
-
protocol: 'wss',
|
|
97
|
-
|
|
97
|
+
// protocol: 'wss', // <- if you set options.https to `true`
|
|
98
|
+
// port: 443, // <- if you set options.https to `true`
|
|
98
99
|
port: 443,
|
|
99
100
|
},
|
|
100
101
|
},
|
|
@@ -260,9 +260,11 @@ var CaddyInstant = class {
|
|
|
260
260
|
await download();
|
|
261
261
|
this.inited = true;
|
|
262
262
|
}
|
|
263
|
-
updateHost(ip, host) {
|
|
263
|
+
async updateHost(ip, host) {
|
|
264
264
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
265
|
+
this.host.add("127.0.0.1", "localhost");
|
|
265
266
|
this.host.add(ip, host);
|
|
267
|
+
await this.host.updateFinish();
|
|
266
268
|
return new Promise((resolve, reject) => {
|
|
267
269
|
if (process2.platform === "win32") {
|
|
268
270
|
spawn("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -281,9 +283,10 @@ var CaddyInstant = class {
|
|
|
281
283
|
}
|
|
282
284
|
});
|
|
283
285
|
}
|
|
284
|
-
restoreHost(ip, host) {
|
|
286
|
+
async restoreHost(ip, host) {
|
|
285
287
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
286
288
|
this.host.remove(ip, host);
|
|
289
|
+
await this.host.updateFinish();
|
|
287
290
|
return new Promise((resolve, reject) => {
|
|
288
291
|
if (process2.platform === "win32") {
|
|
289
292
|
spawn("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -312,7 +315,8 @@ var CaddyInstant = class {
|
|
|
312
315
|
const {
|
|
313
316
|
restore = true,
|
|
314
317
|
base = "/",
|
|
315
|
-
showCaddyLog = false
|
|
318
|
+
showCaddyLog = false,
|
|
319
|
+
https = false
|
|
316
320
|
} = options || {};
|
|
317
321
|
if (!this.inited)
|
|
318
322
|
await this.init();
|
|
@@ -324,7 +328,7 @@ var CaddyInstant = class {
|
|
|
324
328
|
throw new Error("update host failed");
|
|
325
329
|
consola.success("update host success\n");
|
|
326
330
|
return new Promise((resolve, reject) => {
|
|
327
|
-
const child = process2.platform !== "win32" ? spawn("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : spawn(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
331
|
+
const child = process2.platform !== "win32" ? spawn("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : spawn(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
328
332
|
child.on("error", (err) => {
|
|
329
333
|
return reject(err);
|
|
330
334
|
});
|
|
@@ -402,10 +406,12 @@ var unpluginFactory = (options) => ({
|
|
|
402
406
|
registerExit(async () => {
|
|
403
407
|
var _a;
|
|
404
408
|
try {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
if (_servce) {
|
|
410
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
411
|
+
_stop && await _stop();
|
|
412
|
+
});
|
|
413
|
+
_servce.close();
|
|
414
|
+
}
|
|
409
415
|
_stop && await _stop();
|
|
410
416
|
} catch (e) {
|
|
411
417
|
consola.error(e);
|
|
@@ -413,6 +419,8 @@ var unpluginFactory = (options) => ({
|
|
|
413
419
|
});
|
|
414
420
|
},
|
|
415
421
|
configureServer(server) {
|
|
422
|
+
if (config.command === "build")
|
|
423
|
+
return;
|
|
416
424
|
const {
|
|
417
425
|
enable = true,
|
|
418
426
|
target = ""
|
|
@@ -439,12 +447,11 @@ var unpluginFactory = (options) => ({
|
|
|
439
447
|
if (caddy)
|
|
440
448
|
return;
|
|
441
449
|
caddy = new CaddyInstant();
|
|
442
|
-
caddy.run(source, target, {
|
|
443
|
-
base
|
|
444
|
-
|
|
445
|
-
}).then((stop) => {
|
|
450
|
+
caddy.run(source, target, __spreadValues({
|
|
451
|
+
base
|
|
452
|
+
}, options)).then((stop) => {
|
|
446
453
|
const colorUrl = (url2) => c.green(url2.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
447
|
-
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
454
|
+
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
448
455
|
!_stop && (_stop = once(stop));
|
|
449
456
|
}).catch((e) => {
|
|
450
457
|
throw e;
|
|
@@ -486,12 +493,10 @@ var unpluginFactory = (options) => ({
|
|
|
486
493
|
}
|
|
487
494
|
};
|
|
488
495
|
caddy = new CaddyInstant();
|
|
489
|
-
caddy.run(source, target, {
|
|
490
|
-
showCaddyLog: options.showCaddyLog
|
|
491
|
-
}).then((stop) => {
|
|
496
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
492
497
|
const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
493
498
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
494
|
-
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
499
|
+
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
495
500
|
!_stop && (_stop = once(stop));
|
|
496
501
|
});
|
|
497
502
|
}).catch((e) => {
|
package/dist/esbuild.cjs
CHANGED
|
@@ -320,9 +320,11 @@ var CaddyInstant = class {
|
|
|
320
320
|
await download();
|
|
321
321
|
this.inited = true;
|
|
322
322
|
}
|
|
323
|
-
updateHost(ip, host) {
|
|
323
|
+
async updateHost(ip, host) {
|
|
324
324
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
325
|
+
this.host.add("127.0.0.1", "localhost");
|
|
325
326
|
this.host.add(ip, host);
|
|
327
|
+
await this.host.updateFinish();
|
|
326
328
|
return new Promise((resolve, reject) => {
|
|
327
329
|
if (import_node_process2.default.platform === "win32") {
|
|
328
330
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -341,9 +343,10 @@ var CaddyInstant = class {
|
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
345
|
}
|
|
344
|
-
restoreHost(ip, host) {
|
|
346
|
+
async restoreHost(ip, host) {
|
|
345
347
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
346
348
|
this.host.remove(ip, host);
|
|
349
|
+
await this.host.updateFinish();
|
|
347
350
|
return new Promise((resolve, reject) => {
|
|
348
351
|
if (import_node_process2.default.platform === "win32") {
|
|
349
352
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -372,7 +375,8 @@ var CaddyInstant = class {
|
|
|
372
375
|
const {
|
|
373
376
|
restore = true,
|
|
374
377
|
base = "/",
|
|
375
|
-
showCaddyLog = false
|
|
378
|
+
showCaddyLog = false,
|
|
379
|
+
https = false
|
|
376
380
|
} = options || {};
|
|
377
381
|
if (!this.inited)
|
|
378
382
|
await this.init();
|
|
@@ -384,7 +388,7 @@ var CaddyInstant = class {
|
|
|
384
388
|
throw new Error("update host failed");
|
|
385
389
|
consola.success("update host success\n");
|
|
386
390
|
return new Promise((resolve, reject) => {
|
|
387
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
391
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
388
392
|
child.on("error", (err) => {
|
|
389
393
|
return reject(err);
|
|
390
394
|
});
|
|
@@ -462,10 +466,12 @@ var unpluginFactory = (options) => ({
|
|
|
462
466
|
registerExit(async () => {
|
|
463
467
|
var _a;
|
|
464
468
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
if (_servce) {
|
|
470
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
471
|
+
_stop && await _stop();
|
|
472
|
+
});
|
|
473
|
+
_servce.close();
|
|
474
|
+
}
|
|
469
475
|
_stop && await _stop();
|
|
470
476
|
} catch (e) {
|
|
471
477
|
consola.error(e);
|
|
@@ -473,6 +479,8 @@ var unpluginFactory = (options) => ({
|
|
|
473
479
|
});
|
|
474
480
|
},
|
|
475
481
|
configureServer(server) {
|
|
482
|
+
if (config.command === "build")
|
|
483
|
+
return;
|
|
476
484
|
const {
|
|
477
485
|
enable = true,
|
|
478
486
|
target = ""
|
|
@@ -499,12 +507,11 @@ var unpluginFactory = (options) => ({
|
|
|
499
507
|
if (caddy)
|
|
500
508
|
return;
|
|
501
509
|
caddy = new CaddyInstant();
|
|
502
|
-
caddy.run(source, target, {
|
|
503
|
-
base
|
|
504
|
-
|
|
505
|
-
}).then((stop) => {
|
|
510
|
+
caddy.run(source, target, __spreadValues({
|
|
511
|
+
base
|
|
512
|
+
}, options)).then((stop) => {
|
|
506
513
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
507
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
514
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
508
515
|
!_stop && (_stop = once(stop));
|
|
509
516
|
}).catch((e) => {
|
|
510
517
|
throw e;
|
|
@@ -546,12 +553,10 @@ var unpluginFactory = (options) => ({
|
|
|
546
553
|
}
|
|
547
554
|
};
|
|
548
555
|
caddy = new CaddyInstant();
|
|
549
|
-
caddy.run(source, target, {
|
|
550
|
-
showCaddyLog: options.showCaddyLog
|
|
551
|
-
}).then((stop) => {
|
|
556
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
552
557
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
553
558
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
554
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
559
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
555
560
|
!_stop && (_stop = once(stop));
|
|
556
561
|
});
|
|
557
562
|
}).catch((e) => {
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -319,9 +319,11 @@ var CaddyInstant = class {
|
|
|
319
319
|
await download();
|
|
320
320
|
this.inited = true;
|
|
321
321
|
}
|
|
322
|
-
updateHost(ip, host) {
|
|
322
|
+
async updateHost(ip, host) {
|
|
323
323
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
324
|
+
this.host.add("127.0.0.1", "localhost");
|
|
324
325
|
this.host.add(ip, host);
|
|
326
|
+
await this.host.updateFinish();
|
|
325
327
|
return new Promise((resolve, reject) => {
|
|
326
328
|
if (import_node_process2.default.platform === "win32") {
|
|
327
329
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -340,9 +342,10 @@ var CaddyInstant = class {
|
|
|
340
342
|
}
|
|
341
343
|
});
|
|
342
344
|
}
|
|
343
|
-
restoreHost(ip, host) {
|
|
345
|
+
async restoreHost(ip, host) {
|
|
344
346
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
345
347
|
this.host.remove(ip, host);
|
|
348
|
+
await this.host.updateFinish();
|
|
346
349
|
return new Promise((resolve, reject) => {
|
|
347
350
|
if (import_node_process2.default.platform === "win32") {
|
|
348
351
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -371,7 +374,8 @@ var CaddyInstant = class {
|
|
|
371
374
|
const {
|
|
372
375
|
restore = true,
|
|
373
376
|
base = "/",
|
|
374
|
-
showCaddyLog = false
|
|
377
|
+
showCaddyLog = false,
|
|
378
|
+
https = false
|
|
375
379
|
} = options || {};
|
|
376
380
|
if (!this.inited)
|
|
377
381
|
await this.init();
|
|
@@ -383,7 +387,7 @@ var CaddyInstant = class {
|
|
|
383
387
|
throw new Error("update host failed");
|
|
384
388
|
consola.success("update host success\n");
|
|
385
389
|
return new Promise((resolve, reject) => {
|
|
386
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
390
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
387
391
|
child.on("error", (err) => {
|
|
388
392
|
return reject(err);
|
|
389
393
|
});
|
|
@@ -461,10 +465,12 @@ var unpluginFactory = (options) => ({
|
|
|
461
465
|
registerExit(async () => {
|
|
462
466
|
var _a;
|
|
463
467
|
try {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
+
if (_servce) {
|
|
469
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
470
|
+
_stop && await _stop();
|
|
471
|
+
});
|
|
472
|
+
_servce.close();
|
|
473
|
+
}
|
|
468
474
|
_stop && await _stop();
|
|
469
475
|
} catch (e) {
|
|
470
476
|
consola.error(e);
|
|
@@ -472,6 +478,8 @@ var unpluginFactory = (options) => ({
|
|
|
472
478
|
});
|
|
473
479
|
},
|
|
474
480
|
configureServer(server) {
|
|
481
|
+
if (config.command === "build")
|
|
482
|
+
return;
|
|
475
483
|
const {
|
|
476
484
|
enable = true,
|
|
477
485
|
target = ""
|
|
@@ -498,12 +506,11 @@ var unpluginFactory = (options) => ({
|
|
|
498
506
|
if (caddy)
|
|
499
507
|
return;
|
|
500
508
|
caddy = new CaddyInstant();
|
|
501
|
-
caddy.run(source, target, {
|
|
502
|
-
base
|
|
503
|
-
|
|
504
|
-
}).then((stop) => {
|
|
509
|
+
caddy.run(source, target, __spreadValues({
|
|
510
|
+
base
|
|
511
|
+
}, options)).then((stop) => {
|
|
505
512
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
506
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
513
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
507
514
|
!_stop && (_stop = once(stop));
|
|
508
515
|
}).catch((e) => {
|
|
509
516
|
throw e;
|
|
@@ -545,12 +552,10 @@ var unpluginFactory = (options) => ({
|
|
|
545
552
|
}
|
|
546
553
|
};
|
|
547
554
|
caddy = new CaddyInstant();
|
|
548
|
-
caddy.run(source, target, {
|
|
549
|
-
showCaddyLog: options.showCaddyLog
|
|
550
|
-
}).then((stop) => {
|
|
555
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
551
556
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
552
557
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
553
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
558
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
554
559
|
!_stop && (_stop = once(stop));
|
|
555
560
|
});
|
|
556
561
|
}).catch((e) => {
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -323,9 +323,11 @@ var CaddyInstant = class {
|
|
|
323
323
|
await download();
|
|
324
324
|
this.inited = true;
|
|
325
325
|
}
|
|
326
|
-
updateHost(ip, host) {
|
|
326
|
+
async updateHost(ip, host) {
|
|
327
327
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
328
|
+
this.host.add("127.0.0.1", "localhost");
|
|
328
329
|
this.host.add(ip, host);
|
|
330
|
+
await this.host.updateFinish();
|
|
329
331
|
return new Promise((resolve, reject) => {
|
|
330
332
|
if (import_node_process2.default.platform === "win32") {
|
|
331
333
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -344,9 +346,10 @@ var CaddyInstant = class {
|
|
|
344
346
|
}
|
|
345
347
|
});
|
|
346
348
|
}
|
|
347
|
-
restoreHost(ip, host) {
|
|
349
|
+
async restoreHost(ip, host) {
|
|
348
350
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
349
351
|
this.host.remove(ip, host);
|
|
352
|
+
await this.host.updateFinish();
|
|
350
353
|
return new Promise((resolve, reject) => {
|
|
351
354
|
if (import_node_process2.default.platform === "win32") {
|
|
352
355
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -375,7 +378,8 @@ var CaddyInstant = class {
|
|
|
375
378
|
const {
|
|
376
379
|
restore = true,
|
|
377
380
|
base = "/",
|
|
378
|
-
showCaddyLog = false
|
|
381
|
+
showCaddyLog = false,
|
|
382
|
+
https = false
|
|
379
383
|
} = options || {};
|
|
380
384
|
if (!this.inited)
|
|
381
385
|
await this.init();
|
|
@@ -387,7 +391,7 @@ var CaddyInstant = class {
|
|
|
387
391
|
throw new Error("update host failed");
|
|
388
392
|
consola.success("update host success\n");
|
|
389
393
|
return new Promise((resolve, reject) => {
|
|
390
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
394
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
391
395
|
child.on("error", (err) => {
|
|
392
396
|
return reject(err);
|
|
393
397
|
});
|
|
@@ -465,10 +469,12 @@ var unpluginFactory = (options) => ({
|
|
|
465
469
|
registerExit(async () => {
|
|
466
470
|
var _a;
|
|
467
471
|
try {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
+
if (_servce) {
|
|
473
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
474
|
+
_stop && await _stop();
|
|
475
|
+
});
|
|
476
|
+
_servce.close();
|
|
477
|
+
}
|
|
472
478
|
_stop && await _stop();
|
|
473
479
|
} catch (e) {
|
|
474
480
|
consola.error(e);
|
|
@@ -476,6 +482,8 @@ var unpluginFactory = (options) => ({
|
|
|
476
482
|
});
|
|
477
483
|
},
|
|
478
484
|
configureServer(server) {
|
|
485
|
+
if (config.command === "build")
|
|
486
|
+
return;
|
|
479
487
|
const {
|
|
480
488
|
enable = true,
|
|
481
489
|
target = ""
|
|
@@ -502,12 +510,11 @@ var unpluginFactory = (options) => ({
|
|
|
502
510
|
if (caddy)
|
|
503
511
|
return;
|
|
504
512
|
caddy = new CaddyInstant();
|
|
505
|
-
caddy.run(source, target, {
|
|
506
|
-
base
|
|
507
|
-
|
|
508
|
-
}).then((stop) => {
|
|
513
|
+
caddy.run(source, target, __spreadValues({
|
|
514
|
+
base
|
|
515
|
+
}, options)).then((stop) => {
|
|
509
516
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
510
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
517
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
511
518
|
!_stop && (_stop = once(stop));
|
|
512
519
|
}).catch((e) => {
|
|
513
520
|
throw e;
|
|
@@ -549,12 +556,10 @@ var unpluginFactory = (options) => ({
|
|
|
549
556
|
}
|
|
550
557
|
};
|
|
551
558
|
caddy = new CaddyInstant();
|
|
552
|
-
caddy.run(source, target, {
|
|
553
|
-
showCaddyLog: options.showCaddyLog
|
|
554
|
-
}).then((stop) => {
|
|
559
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
555
560
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
556
561
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
557
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
562
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
558
563
|
!_stop && (_stop = once(stop));
|
|
559
564
|
});
|
|
560
565
|
}).catch((e) => {
|
package/dist/nuxt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vite_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HWUN3C5Q.js";
|
|
4
4
|
import {
|
|
5
5
|
webpack_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-MPY62XIL.js";
|
|
7
|
+
import "./chunk-G5VIL2MO.js";
|
|
8
8
|
import "./chunk-CQC5SSJR.js";
|
|
9
9
|
|
|
10
10
|
// src/nuxt.ts
|
package/dist/rollup.cjs
CHANGED
|
@@ -320,9 +320,11 @@ var CaddyInstant = class {
|
|
|
320
320
|
await download();
|
|
321
321
|
this.inited = true;
|
|
322
322
|
}
|
|
323
|
-
updateHost(ip, host) {
|
|
323
|
+
async updateHost(ip, host) {
|
|
324
324
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
325
|
+
this.host.add("127.0.0.1", "localhost");
|
|
325
326
|
this.host.add(ip, host);
|
|
327
|
+
await this.host.updateFinish();
|
|
326
328
|
return new Promise((resolve, reject) => {
|
|
327
329
|
if (import_node_process2.default.platform === "win32") {
|
|
328
330
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -341,9 +343,10 @@ var CaddyInstant = class {
|
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
345
|
}
|
|
344
|
-
restoreHost(ip, host) {
|
|
346
|
+
async restoreHost(ip, host) {
|
|
345
347
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
346
348
|
this.host.remove(ip, host);
|
|
349
|
+
await this.host.updateFinish();
|
|
347
350
|
return new Promise((resolve, reject) => {
|
|
348
351
|
if (import_node_process2.default.platform === "win32") {
|
|
349
352
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -372,7 +375,8 @@ var CaddyInstant = class {
|
|
|
372
375
|
const {
|
|
373
376
|
restore = true,
|
|
374
377
|
base = "/",
|
|
375
|
-
showCaddyLog = false
|
|
378
|
+
showCaddyLog = false,
|
|
379
|
+
https = false
|
|
376
380
|
} = options || {};
|
|
377
381
|
if (!this.inited)
|
|
378
382
|
await this.init();
|
|
@@ -384,7 +388,7 @@ var CaddyInstant = class {
|
|
|
384
388
|
throw new Error("update host failed");
|
|
385
389
|
consola.success("update host success\n");
|
|
386
390
|
return new Promise((resolve, reject) => {
|
|
387
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
391
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
388
392
|
child.on("error", (err) => {
|
|
389
393
|
return reject(err);
|
|
390
394
|
});
|
|
@@ -462,10 +466,12 @@ var unpluginFactory = (options) => ({
|
|
|
462
466
|
registerExit(async () => {
|
|
463
467
|
var _a;
|
|
464
468
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
if (_servce) {
|
|
470
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
471
|
+
_stop && await _stop();
|
|
472
|
+
});
|
|
473
|
+
_servce.close();
|
|
474
|
+
}
|
|
469
475
|
_stop && await _stop();
|
|
470
476
|
} catch (e) {
|
|
471
477
|
consola.error(e);
|
|
@@ -473,6 +479,8 @@ var unpluginFactory = (options) => ({
|
|
|
473
479
|
});
|
|
474
480
|
},
|
|
475
481
|
configureServer(server) {
|
|
482
|
+
if (config.command === "build")
|
|
483
|
+
return;
|
|
476
484
|
const {
|
|
477
485
|
enable = true,
|
|
478
486
|
target = ""
|
|
@@ -499,12 +507,11 @@ var unpluginFactory = (options) => ({
|
|
|
499
507
|
if (caddy)
|
|
500
508
|
return;
|
|
501
509
|
caddy = new CaddyInstant();
|
|
502
|
-
caddy.run(source, target, {
|
|
503
|
-
base
|
|
504
|
-
|
|
505
|
-
}).then((stop) => {
|
|
510
|
+
caddy.run(source, target, __spreadValues({
|
|
511
|
+
base
|
|
512
|
+
}, options)).then((stop) => {
|
|
506
513
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
507
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
514
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
508
515
|
!_stop && (_stop = once(stop));
|
|
509
516
|
}).catch((e) => {
|
|
510
517
|
throw e;
|
|
@@ -546,12 +553,10 @@ var unpluginFactory = (options) => ({
|
|
|
546
553
|
}
|
|
547
554
|
};
|
|
548
555
|
caddy = new CaddyInstant();
|
|
549
|
-
caddy.run(source, target, {
|
|
550
|
-
showCaddyLog: options.showCaddyLog
|
|
551
|
-
}).then((stop) => {
|
|
556
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
552
557
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
553
558
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
554
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
559
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
555
560
|
!_stop && (_stop = once(stop));
|
|
556
561
|
});
|
|
557
562
|
}).catch((e) => {
|
package/dist/rollup.js
CHANGED
package/dist/types.d.cts
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -320,9 +320,11 @@ var CaddyInstant = class {
|
|
|
320
320
|
await download();
|
|
321
321
|
this.inited = true;
|
|
322
322
|
}
|
|
323
|
-
updateHost(ip, host) {
|
|
323
|
+
async updateHost(ip, host) {
|
|
324
324
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
325
|
+
this.host.add("127.0.0.1", "localhost");
|
|
325
326
|
this.host.add(ip, host);
|
|
327
|
+
await this.host.updateFinish();
|
|
326
328
|
return new Promise((resolve, reject) => {
|
|
327
329
|
if (import_node_process2.default.platform === "win32") {
|
|
328
330
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -341,9 +343,10 @@ var CaddyInstant = class {
|
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
345
|
}
|
|
344
|
-
restoreHost(ip, host) {
|
|
346
|
+
async restoreHost(ip, host) {
|
|
345
347
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
346
348
|
this.host.remove(ip, host);
|
|
349
|
+
await this.host.updateFinish();
|
|
347
350
|
return new Promise((resolve, reject) => {
|
|
348
351
|
if (import_node_process2.default.platform === "win32") {
|
|
349
352
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -372,7 +375,8 @@ var CaddyInstant = class {
|
|
|
372
375
|
const {
|
|
373
376
|
restore = true,
|
|
374
377
|
base = "/",
|
|
375
|
-
showCaddyLog = false
|
|
378
|
+
showCaddyLog = false,
|
|
379
|
+
https = false
|
|
376
380
|
} = options || {};
|
|
377
381
|
if (!this.inited)
|
|
378
382
|
await this.init();
|
|
@@ -384,7 +388,7 @@ var CaddyInstant = class {
|
|
|
384
388
|
throw new Error("update host failed");
|
|
385
389
|
consola.success("update host success\n");
|
|
386
390
|
return new Promise((resolve, reject) => {
|
|
387
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
391
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
388
392
|
child.on("error", (err) => {
|
|
389
393
|
return reject(err);
|
|
390
394
|
});
|
|
@@ -462,10 +466,12 @@ var unpluginFactory = (options) => ({
|
|
|
462
466
|
registerExit(async () => {
|
|
463
467
|
var _a;
|
|
464
468
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
if (_servce) {
|
|
470
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
471
|
+
_stop && await _stop();
|
|
472
|
+
});
|
|
473
|
+
_servce.close();
|
|
474
|
+
}
|
|
469
475
|
_stop && await _stop();
|
|
470
476
|
} catch (e) {
|
|
471
477
|
consola.error(e);
|
|
@@ -473,6 +479,8 @@ var unpluginFactory = (options) => ({
|
|
|
473
479
|
});
|
|
474
480
|
},
|
|
475
481
|
configureServer(server) {
|
|
482
|
+
if (config.command === "build")
|
|
483
|
+
return;
|
|
476
484
|
const {
|
|
477
485
|
enable = true,
|
|
478
486
|
target = ""
|
|
@@ -499,12 +507,11 @@ var unpluginFactory = (options) => ({
|
|
|
499
507
|
if (caddy)
|
|
500
508
|
return;
|
|
501
509
|
caddy = new CaddyInstant();
|
|
502
|
-
caddy.run(source, target, {
|
|
503
|
-
base
|
|
504
|
-
|
|
505
|
-
}).then((stop) => {
|
|
510
|
+
caddy.run(source, target, __spreadValues({
|
|
511
|
+
base
|
|
512
|
+
}, options)).then((stop) => {
|
|
506
513
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
507
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
514
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
508
515
|
!_stop && (_stop = once(stop));
|
|
509
516
|
}).catch((e) => {
|
|
510
517
|
throw e;
|
|
@@ -546,12 +553,10 @@ var unpluginFactory = (options) => ({
|
|
|
546
553
|
}
|
|
547
554
|
};
|
|
548
555
|
caddy = new CaddyInstant();
|
|
549
|
-
caddy.run(source, target, {
|
|
550
|
-
showCaddyLog: options.showCaddyLog
|
|
551
|
-
}).then((stop) => {
|
|
556
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
552
557
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
553
558
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
554
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
559
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
555
560
|
!_stop && (_stop = once(stop));
|
|
556
561
|
});
|
|
557
562
|
}).catch((e) => {
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -320,9 +320,11 @@ var CaddyInstant = class {
|
|
|
320
320
|
await download();
|
|
321
321
|
this.inited = true;
|
|
322
322
|
}
|
|
323
|
-
updateHost(ip, host) {
|
|
323
|
+
async updateHost(ip, host) {
|
|
324
324
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
325
|
+
this.host.add("127.0.0.1", "localhost");
|
|
325
326
|
this.host.add(ip, host);
|
|
327
|
+
await this.host.updateFinish();
|
|
326
328
|
return new Promise((resolve, reject) => {
|
|
327
329
|
if (import_node_process2.default.platform === "win32") {
|
|
328
330
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -341,9 +343,10 @@ var CaddyInstant = class {
|
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
345
|
}
|
|
344
|
-
restoreHost(ip, host) {
|
|
346
|
+
async restoreHost(ip, host) {
|
|
345
347
|
["localhost", "0.0.0.0"].includes(ip) && (ip = "127.0.0.1");
|
|
346
348
|
this.host.remove(ip, host);
|
|
349
|
+
await this.host.updateFinish();
|
|
347
350
|
return new Promise((resolve, reject) => {
|
|
348
351
|
if (import_node_process2.default.platform === "win32") {
|
|
349
352
|
(0, import_node_child_process.spawn)("ipconfig", ["/flushdns"]).on("error", (err) => {
|
|
@@ -372,7 +375,8 @@ var CaddyInstant = class {
|
|
|
372
375
|
const {
|
|
373
376
|
restore = true,
|
|
374
377
|
base = "/",
|
|
375
|
-
showCaddyLog = false
|
|
378
|
+
showCaddyLog = false,
|
|
379
|
+
https = false
|
|
376
380
|
} = options || {};
|
|
377
381
|
if (!this.inited)
|
|
378
382
|
await this.init();
|
|
@@ -384,7 +388,7 @@ var CaddyInstant = class {
|
|
|
384
388
|
throw new Error("update host failed");
|
|
385
389
|
consola.success("update host success\n");
|
|
386
390
|
return new Promise((resolve, reject) => {
|
|
387
|
-
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
391
|
+
const child = import_node_process2.default.platform !== "win32" ? (0, import_node_child_process.spawn)("sudo", ["-E", caddyPath, "reverse-proxy", "--from", `${target.split(":")[0]}${https ? "" : ":80"}`, "--to", `${source}`, "--internal-certs", "--insecure", "--disable-redirects"]) : (0, import_node_child_process.spawn)(caddyPath, ["reverse-proxy", "--from", `${target.split(":")[0]}`, "--to", `${source}`, "--internal-certs"]);
|
|
388
392
|
child.on("error", (err) => {
|
|
389
393
|
return reject(err);
|
|
390
394
|
});
|
|
@@ -462,10 +466,12 @@ var unpluginFactory = (options) => ({
|
|
|
462
466
|
registerExit(async () => {
|
|
463
467
|
var _a;
|
|
464
468
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
if (_servce) {
|
|
470
|
+
(_a = _servce.httpServer) == null ? void 0 : _a.close(async () => {
|
|
471
|
+
_stop && await _stop();
|
|
472
|
+
});
|
|
473
|
+
_servce.close();
|
|
474
|
+
}
|
|
469
475
|
_stop && await _stop();
|
|
470
476
|
} catch (e) {
|
|
471
477
|
consola.error(e);
|
|
@@ -473,6 +479,8 @@ var unpluginFactory = (options) => ({
|
|
|
473
479
|
});
|
|
474
480
|
},
|
|
475
481
|
configureServer(server) {
|
|
482
|
+
if (config.command === "build")
|
|
483
|
+
return;
|
|
476
484
|
const {
|
|
477
485
|
enable = true,
|
|
478
486
|
target = ""
|
|
@@ -499,12 +507,11 @@ var unpluginFactory = (options) => ({
|
|
|
499
507
|
if (caddy)
|
|
500
508
|
return;
|
|
501
509
|
caddy = new CaddyInstant();
|
|
502
|
-
caddy.run(source, target, {
|
|
503
|
-
base
|
|
504
|
-
|
|
505
|
-
}).then((stop) => {
|
|
510
|
+
caddy.run(source, target, __spreadValues({
|
|
511
|
+
base
|
|
512
|
+
}, options)).then((stop) => {
|
|
506
513
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
507
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
514
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
508
515
|
!_stop && (_stop = once(stop));
|
|
509
516
|
}).catch((e) => {
|
|
510
517
|
throw e;
|
|
@@ -546,12 +553,10 @@ var unpluginFactory = (options) => ({
|
|
|
546
553
|
}
|
|
547
554
|
};
|
|
548
555
|
caddy = new CaddyInstant();
|
|
549
|
-
caddy.run(source, target, {
|
|
550
|
-
showCaddyLog: options.showCaddyLog
|
|
551
|
-
}).then((stop) => {
|
|
556
|
+
caddy.run(source, target, __spreadValues({}, options)).then((stop) => {
|
|
552
557
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
553
558
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", () => {
|
|
554
|
-
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(
|
|
559
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
555
560
|
!_stop && (_stop = once(stop));
|
|
556
561
|
});
|
|
557
562
|
}).catch((e) => {
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/src/caddy/index.ts
CHANGED
|
@@ -89,6 +89,7 @@ interface RunOptions {
|
|
|
89
89
|
restore: boolean
|
|
90
90
|
base: string
|
|
91
91
|
showCaddyLog: boolean
|
|
92
|
+
https: boolean
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
export class CaddyInstant {
|
|
@@ -108,9 +109,11 @@ export class CaddyInstant {
|
|
|
108
109
|
this.inited = true
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
private updateHost(ip: string, host: string) {
|
|
112
|
+
private async updateHost(ip: string, host: string) {
|
|
112
113
|
['localhost', '0.0.0.0'].includes(ip) && (ip = '127.0.0.1')
|
|
114
|
+
this.host.add('127.0.0.1', 'localhost')
|
|
113
115
|
this.host.add(ip, host)
|
|
116
|
+
await this.host.updateFinish()
|
|
114
117
|
return new Promise<boolean>((resolve, reject) => {
|
|
115
118
|
if (process.platform === 'win32') {
|
|
116
119
|
spawn('ipconfig', ['/flushdns']).on('error', (err) => {
|
|
@@ -131,9 +134,10 @@ export class CaddyInstant {
|
|
|
131
134
|
})
|
|
132
135
|
}
|
|
133
136
|
|
|
134
|
-
private restoreHost(ip: string, host: string) {
|
|
137
|
+
private async restoreHost(ip: string, host: string) {
|
|
135
138
|
['localhost', '0.0.0.0'].includes(ip) && (ip = '127.0.0.1')
|
|
136
139
|
this.host.remove(ip, host)
|
|
140
|
+
await this.host.updateFinish()
|
|
137
141
|
return new Promise<boolean>((resolve, reject) => {
|
|
138
142
|
if (process.platform === 'win32') {
|
|
139
143
|
spawn('ipconfig', ['/flushdns']).on('error', (err) => {
|
|
@@ -165,6 +169,7 @@ export class CaddyInstant {
|
|
|
165
169
|
restore = true,
|
|
166
170
|
base = '/',
|
|
167
171
|
showCaddyLog = false,
|
|
172
|
+
https = false,
|
|
168
173
|
} = options || {}
|
|
169
174
|
|
|
170
175
|
if (!this.inited)
|
|
@@ -182,7 +187,7 @@ export class CaddyInstant {
|
|
|
182
187
|
return new Promise<(callback?: () => any) => Promise<void>>((resolve, reject) => {
|
|
183
188
|
// caddy reverse-proxy --from target --to source --internal-certs
|
|
184
189
|
const child = process.platform !== 'win32'
|
|
185
|
-
? spawn('sudo', ['-E', caddyPath, 'reverse-proxy', '--from', `${target.split(':')[0]}`, '--to', `${source}`, '--internal-certs'])
|
|
190
|
+
? spawn('sudo', ['-E', caddyPath, 'reverse-proxy', '--from', `${target.split(':')[0]}${https ? '' : ':80'}`, '--to', `${source}`, '--internal-certs', '--insecure', '--disable-redirects'])
|
|
186
191
|
: spawn(caddyPath, ['reverse-proxy', '--from', `${target.split(':')[0]}`, '--to', `${source}`, '--internal-certs'])
|
|
187
192
|
|
|
188
193
|
child.on('error', (err) => {
|
package/src/index.ts
CHANGED
|
@@ -54,10 +54,12 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
54
54
|
config = _config
|
|
55
55
|
registerExit(async () => {
|
|
56
56
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
if (_servce) {
|
|
58
|
+
_servce.httpServer?.close(async () => {
|
|
59
|
+
_stop && await _stop()
|
|
60
|
+
})
|
|
61
|
+
_servce.close()
|
|
62
|
+
}
|
|
61
63
|
_stop && await _stop()
|
|
62
64
|
}
|
|
63
65
|
catch (e) {
|
|
@@ -66,6 +68,9 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
66
68
|
})
|
|
67
69
|
},
|
|
68
70
|
configureServer(server) {
|
|
71
|
+
if (config.command === 'build')
|
|
72
|
+
return
|
|
73
|
+
|
|
69
74
|
const {
|
|
70
75
|
enable = true,
|
|
71
76
|
target = '',
|
|
@@ -95,10 +100,10 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
95
100
|
caddy = new CaddyInstant()
|
|
96
101
|
caddy.run(source, target, {
|
|
97
102
|
base,
|
|
98
|
-
|
|
103
|
+
...options,
|
|
99
104
|
}).then((stop) => {
|
|
100
105
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
101
|
-
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(
|
|
106
|
+
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`${options.https ? 'https' : 'http'}://${target}${base}`)}`)
|
|
102
107
|
!_stop && (_stop = once(stop))
|
|
103
108
|
}).catch((e) => {
|
|
104
109
|
throw e
|
|
@@ -161,12 +166,12 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
161
166
|
caddy = new CaddyInstant()
|
|
162
167
|
|
|
163
168
|
caddy.run(source, target, {
|
|
164
|
-
|
|
169
|
+
...options,
|
|
165
170
|
}).then((stop) => {
|
|
166
171
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
167
172
|
|
|
168
173
|
compiler.hooks.done.tap('unplugin-https-reverse-proxy', () => {
|
|
169
|
-
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(
|
|
174
|
+
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`${options.https ? 'https' : 'http'}://${target}`)}`)
|
|
170
175
|
|
|
171
176
|
!_stop && (_stop = once(stop))
|
|
172
177
|
})
|