unplugin-https-reverse-proxy 0.0.10 → 0.0.12
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 +11 -3
- package/dist/{chunk-J2XKEZPC.js → chunk-ARWX57QE.js} +1 -1
- package/dist/{chunk-AJ47BPUG.js → chunk-WUSTJHAZ.js} +22 -6
- package/dist/{chunk-FD66DR3R.js → chunk-YP6CZ57A.js} +1 -1
- package/dist/esbuild.cjs +22 -6
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +22 -6
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +22 -6
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +22 -6
- 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 -6
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +22 -6
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
- package/src/caddy/index.ts +12 -3
- package/src/index.ts +12 -1
- package/src/types.ts +2 -0
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ UHRP_AUTO_INSTALL_CADDY=true npm i unplugin-https-reverse-proxy --save-dev
|
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
interface Options {
|
|
19
|
+
enable?: boolean // <- default: true
|
|
19
20
|
target: string // <- https target hostname
|
|
21
|
+
showCaddyLog?: boolean // <- default: false
|
|
20
22
|
}
|
|
21
23
|
```
|
|
22
24
|
|
|
@@ -25,11 +27,11 @@ interface Options {
|
|
|
25
27
|
|
|
26
28
|
```ts
|
|
27
29
|
// vite.config.ts
|
|
28
|
-
import
|
|
30
|
+
import HttpsReverseProxy from 'unplugin-https-reverse-proxy/vite'
|
|
29
31
|
|
|
30
32
|
export default defineConfig({
|
|
31
33
|
plugins: [
|
|
32
|
-
|
|
34
|
+
HttpsReverseProxy({ /* options */ }),
|
|
33
35
|
],
|
|
34
36
|
})
|
|
35
37
|
```
|
|
@@ -115,4 +117,10 @@ sudo -E npm run dev # your dev script
|
|
|
115
117
|
# windows
|
|
116
118
|
# use powershell as administrator
|
|
117
119
|
npm run dev # your dev script
|
|
118
|
-
```
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If your broswer shows a not trusted certificate warning, please check the keychain.
|
|
123
|
+
|
|
124
|
+

|
|
125
|
+
|
|
126
|
+
More info, you can check [caddy about CA Root](https://caddyserver.com/docs/automatic-https#ca-root).
|
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -324,8 +329,11 @@ var unpluginFactory = (options) => ({
|
|
|
324
329
|
},
|
|
325
330
|
configureServer(server) {
|
|
326
331
|
const {
|
|
332
|
+
enable = true,
|
|
327
333
|
target = ""
|
|
328
334
|
} = options;
|
|
335
|
+
if (!enable)
|
|
336
|
+
return;
|
|
329
337
|
if (!target) {
|
|
330
338
|
consola.fail("please provide target");
|
|
331
339
|
return;
|
|
@@ -344,7 +352,8 @@ var unpluginFactory = (options) => ({
|
|
|
344
352
|
try {
|
|
345
353
|
const caddy2 = new CaddyInstant();
|
|
346
354
|
caddy2.run(source, target, {
|
|
347
|
-
base
|
|
355
|
+
base,
|
|
356
|
+
showCaddyLog: options.showCaddyLog
|
|
348
357
|
}).then((stop) => {
|
|
349
358
|
const colorUrl = (url2) => c.green(url2.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
350
359
|
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -353,6 +362,8 @@ var unpluginFactory = (options) => ({
|
|
|
353
362
|
server.close();
|
|
354
363
|
process3.exit();
|
|
355
364
|
});
|
|
365
|
+
}).catch((e) => {
|
|
366
|
+
throw e;
|
|
356
367
|
});
|
|
357
368
|
} catch (e) {
|
|
358
369
|
consola.error(e);
|
|
@@ -362,8 +373,11 @@ var unpluginFactory = (options) => ({
|
|
|
362
373
|
},
|
|
363
374
|
webpack(compiler) {
|
|
364
375
|
const {
|
|
376
|
+
enable = true,
|
|
365
377
|
target = ""
|
|
366
378
|
} = options;
|
|
379
|
+
if (!enable)
|
|
380
|
+
return;
|
|
367
381
|
if (!target) {
|
|
368
382
|
consola.fail("please provide target");
|
|
369
383
|
return;
|
|
@@ -374,7 +388,9 @@ var unpluginFactory = (options) => ({
|
|
|
374
388
|
if (caddy)
|
|
375
389
|
return;
|
|
376
390
|
caddy = new CaddyInstant();
|
|
377
|
-
caddy.run(source, target
|
|
391
|
+
caddy.run(source, target, {
|
|
392
|
+
showCaddyLog: options.showCaddyLog
|
|
393
|
+
}).then((stop) => {
|
|
378
394
|
const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
379
395
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
380
396
|
if (stats.hasErrors())
|
package/dist/esbuild.cjs
CHANGED
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -363,8 +368,11 @@ var unpluginFactory = (options) => ({
|
|
|
363
368
|
},
|
|
364
369
|
configureServer(server) {
|
|
365
370
|
const {
|
|
371
|
+
enable = true,
|
|
366
372
|
target = ""
|
|
367
373
|
} = options;
|
|
374
|
+
if (!enable)
|
|
375
|
+
return;
|
|
368
376
|
if (!target) {
|
|
369
377
|
consola.fail("please provide target");
|
|
370
378
|
return;
|
|
@@ -383,7 +391,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
391
|
try {
|
|
384
392
|
const caddy2 = new CaddyInstant();
|
|
385
393
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
394
|
+
base,
|
|
395
|
+
showCaddyLog: options.showCaddyLog
|
|
387
396
|
}).then((stop) => {
|
|
388
397
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
398
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -392,6 +401,8 @@ var unpluginFactory = (options) => ({
|
|
|
392
401
|
server.close();
|
|
393
402
|
import_node_process3.default.exit();
|
|
394
403
|
});
|
|
404
|
+
}).catch((e) => {
|
|
405
|
+
throw e;
|
|
395
406
|
});
|
|
396
407
|
} catch (e) {
|
|
397
408
|
consola.error(e);
|
|
@@ -401,8 +412,11 @@ var unpluginFactory = (options) => ({
|
|
|
401
412
|
},
|
|
402
413
|
webpack(compiler) {
|
|
403
414
|
const {
|
|
415
|
+
enable = true,
|
|
404
416
|
target = ""
|
|
405
417
|
} = options;
|
|
418
|
+
if (!enable)
|
|
419
|
+
return;
|
|
406
420
|
if (!target) {
|
|
407
421
|
consola.fail("please provide target");
|
|
408
422
|
return;
|
|
@@ -413,7 +427,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
427
|
if (caddy)
|
|
414
428
|
return;
|
|
415
429
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
430
|
+
caddy.run(source, target, {
|
|
431
|
+
showCaddyLog: options.showCaddyLog
|
|
432
|
+
}).then((stop) => {
|
|
417
433
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
434
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
435
|
if (stats.hasErrors())
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -362,8 +367,11 @@ var unpluginFactory = (options) => ({
|
|
|
362
367
|
},
|
|
363
368
|
configureServer(server) {
|
|
364
369
|
const {
|
|
370
|
+
enable = true,
|
|
365
371
|
target = ""
|
|
366
372
|
} = options;
|
|
373
|
+
if (!enable)
|
|
374
|
+
return;
|
|
367
375
|
if (!target) {
|
|
368
376
|
consola.fail("please provide target");
|
|
369
377
|
return;
|
|
@@ -382,7 +390,8 @@ var unpluginFactory = (options) => ({
|
|
|
382
390
|
try {
|
|
383
391
|
const caddy2 = new CaddyInstant();
|
|
384
392
|
caddy2.run(source, target, {
|
|
385
|
-
base
|
|
393
|
+
base,
|
|
394
|
+
showCaddyLog: options.showCaddyLog
|
|
386
395
|
}).then((stop) => {
|
|
387
396
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
388
397
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -391,6 +400,8 @@ var unpluginFactory = (options) => ({
|
|
|
391
400
|
server.close();
|
|
392
401
|
import_node_process3.default.exit();
|
|
393
402
|
});
|
|
403
|
+
}).catch((e) => {
|
|
404
|
+
throw e;
|
|
394
405
|
});
|
|
395
406
|
} catch (e) {
|
|
396
407
|
consola.error(e);
|
|
@@ -400,8 +411,11 @@ var unpluginFactory = (options) => ({
|
|
|
400
411
|
},
|
|
401
412
|
webpack(compiler) {
|
|
402
413
|
const {
|
|
414
|
+
enable = true,
|
|
403
415
|
target = ""
|
|
404
416
|
} = options;
|
|
417
|
+
if (!enable)
|
|
418
|
+
return;
|
|
405
419
|
if (!target) {
|
|
406
420
|
consola.fail("please provide target");
|
|
407
421
|
return;
|
|
@@ -412,7 +426,9 @@ var unpluginFactory = (options) => ({
|
|
|
412
426
|
if (caddy)
|
|
413
427
|
return;
|
|
414
428
|
caddy = new CaddyInstant();
|
|
415
|
-
caddy.run(source, target
|
|
429
|
+
caddy.run(source, target, {
|
|
430
|
+
showCaddyLog: options.showCaddyLog
|
|
431
|
+
}).then((stop) => {
|
|
416
432
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
417
433
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
418
434
|
if (stats.hasErrors())
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -366,8 +371,11 @@ var unpluginFactory = (options) => ({
|
|
|
366
371
|
},
|
|
367
372
|
configureServer(server) {
|
|
368
373
|
const {
|
|
374
|
+
enable = true,
|
|
369
375
|
target = ""
|
|
370
376
|
} = options;
|
|
377
|
+
if (!enable)
|
|
378
|
+
return;
|
|
371
379
|
if (!target) {
|
|
372
380
|
consola.fail("please provide target");
|
|
373
381
|
return;
|
|
@@ -386,7 +394,8 @@ var unpluginFactory = (options) => ({
|
|
|
386
394
|
try {
|
|
387
395
|
const caddy2 = new CaddyInstant();
|
|
388
396
|
caddy2.run(source, target, {
|
|
389
|
-
base
|
|
397
|
+
base,
|
|
398
|
+
showCaddyLog: options.showCaddyLog
|
|
390
399
|
}).then((stop) => {
|
|
391
400
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
392
401
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -395,6 +404,8 @@ var unpluginFactory = (options) => ({
|
|
|
395
404
|
server.close();
|
|
396
405
|
import_node_process3.default.exit();
|
|
397
406
|
});
|
|
407
|
+
}).catch((e) => {
|
|
408
|
+
throw e;
|
|
398
409
|
});
|
|
399
410
|
} catch (e) {
|
|
400
411
|
consola.error(e);
|
|
@@ -404,8 +415,11 @@ var unpluginFactory = (options) => ({
|
|
|
404
415
|
},
|
|
405
416
|
webpack(compiler) {
|
|
406
417
|
const {
|
|
418
|
+
enable = true,
|
|
407
419
|
target = ""
|
|
408
420
|
} = options;
|
|
421
|
+
if (!enable)
|
|
422
|
+
return;
|
|
409
423
|
if (!target) {
|
|
410
424
|
consola.fail("please provide target");
|
|
411
425
|
return;
|
|
@@ -416,7 +430,9 @@ var unpluginFactory = (options) => ({
|
|
|
416
430
|
if (caddy)
|
|
417
431
|
return;
|
|
418
432
|
caddy = new CaddyInstant();
|
|
419
|
-
caddy.run(source, target
|
|
433
|
+
caddy.run(source, target, {
|
|
434
|
+
showCaddyLog: options.showCaddyLog
|
|
435
|
+
}).then((stop) => {
|
|
420
436
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
421
437
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
422
438
|
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-YP6CZ57A.js";
|
|
4
4
|
import {
|
|
5
5
|
webpack_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-ARWX57QE.js";
|
|
7
|
+
import "./chunk-WUSTJHAZ.js";
|
|
8
8
|
import "./chunk-3HKPYCSE.js";
|
|
9
9
|
|
|
10
10
|
// src/nuxt.ts
|
package/dist/rollup.cjs
CHANGED
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -363,8 +368,11 @@ var unpluginFactory = (options) => ({
|
|
|
363
368
|
},
|
|
364
369
|
configureServer(server) {
|
|
365
370
|
const {
|
|
371
|
+
enable = true,
|
|
366
372
|
target = ""
|
|
367
373
|
} = options;
|
|
374
|
+
if (!enable)
|
|
375
|
+
return;
|
|
368
376
|
if (!target) {
|
|
369
377
|
consola.fail("please provide target");
|
|
370
378
|
return;
|
|
@@ -383,7 +391,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
391
|
try {
|
|
384
392
|
const caddy2 = new CaddyInstant();
|
|
385
393
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
394
|
+
base,
|
|
395
|
+
showCaddyLog: options.showCaddyLog
|
|
387
396
|
}).then((stop) => {
|
|
388
397
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
398
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -392,6 +401,8 @@ var unpluginFactory = (options) => ({
|
|
|
392
401
|
server.close();
|
|
393
402
|
import_node_process3.default.exit();
|
|
394
403
|
});
|
|
404
|
+
}).catch((e) => {
|
|
405
|
+
throw e;
|
|
395
406
|
});
|
|
396
407
|
} catch (e) {
|
|
397
408
|
consola.error(e);
|
|
@@ -401,8 +412,11 @@ var unpluginFactory = (options) => ({
|
|
|
401
412
|
},
|
|
402
413
|
webpack(compiler) {
|
|
403
414
|
const {
|
|
415
|
+
enable = true,
|
|
404
416
|
target = ""
|
|
405
417
|
} = options;
|
|
418
|
+
if (!enable)
|
|
419
|
+
return;
|
|
406
420
|
if (!target) {
|
|
407
421
|
consola.fail("please provide target");
|
|
408
422
|
return;
|
|
@@ -413,7 +427,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
427
|
if (caddy)
|
|
414
428
|
return;
|
|
415
429
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
430
|
+
caddy.run(source, target, {
|
|
431
|
+
showCaddyLog: options.showCaddyLog
|
|
432
|
+
}).then((stop) => {
|
|
417
433
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
434
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
435
|
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
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -363,8 +368,11 @@ var unpluginFactory = (options) => ({
|
|
|
363
368
|
},
|
|
364
369
|
configureServer(server) {
|
|
365
370
|
const {
|
|
371
|
+
enable = true,
|
|
366
372
|
target = ""
|
|
367
373
|
} = options;
|
|
374
|
+
if (!enable)
|
|
375
|
+
return;
|
|
368
376
|
if (!target) {
|
|
369
377
|
consola.fail("please provide target");
|
|
370
378
|
return;
|
|
@@ -383,7 +391,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
391
|
try {
|
|
384
392
|
const caddy2 = new CaddyInstant();
|
|
385
393
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
394
|
+
base,
|
|
395
|
+
showCaddyLog: options.showCaddyLog
|
|
387
396
|
}).then((stop) => {
|
|
388
397
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
398
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -392,6 +401,8 @@ var unpluginFactory = (options) => ({
|
|
|
392
401
|
server.close();
|
|
393
402
|
import_node_process3.default.exit();
|
|
394
403
|
});
|
|
404
|
+
}).catch((e) => {
|
|
405
|
+
throw e;
|
|
395
406
|
});
|
|
396
407
|
} catch (e) {
|
|
397
408
|
consola.error(e);
|
|
@@ -401,8 +412,11 @@ var unpluginFactory = (options) => ({
|
|
|
401
412
|
},
|
|
402
413
|
webpack(compiler) {
|
|
403
414
|
const {
|
|
415
|
+
enable = true,
|
|
404
416
|
target = ""
|
|
405
417
|
} = options;
|
|
418
|
+
if (!enable)
|
|
419
|
+
return;
|
|
406
420
|
if (!target) {
|
|
407
421
|
consola.fail("please provide target");
|
|
408
422
|
return;
|
|
@@ -413,7 +427,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
427
|
if (caddy)
|
|
414
428
|
return;
|
|
415
429
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
430
|
+
caddy.run(source, target, {
|
|
431
|
+
showCaddyLog: options.showCaddyLog
|
|
432
|
+
}).then((stop) => {
|
|
417
433
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
434
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
435
|
if (stats.hasErrors())
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -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.includes("Error:") || 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) => {
|
|
@@ -363,8 +368,11 @@ var unpluginFactory = (options) => ({
|
|
|
363
368
|
},
|
|
364
369
|
configureServer(server) {
|
|
365
370
|
const {
|
|
371
|
+
enable = true,
|
|
366
372
|
target = ""
|
|
367
373
|
} = options;
|
|
374
|
+
if (!enable)
|
|
375
|
+
return;
|
|
368
376
|
if (!target) {
|
|
369
377
|
consola.fail("please provide target");
|
|
370
378
|
return;
|
|
@@ -383,7 +391,8 @@ var unpluginFactory = (options) => ({
|
|
|
383
391
|
try {
|
|
384
392
|
const caddy2 = new CaddyInstant();
|
|
385
393
|
caddy2.run(source, target, {
|
|
386
|
-
base
|
|
394
|
+
base,
|
|
395
|
+
showCaddyLog: options.showCaddyLog
|
|
387
396
|
}).then((stop) => {
|
|
388
397
|
const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
389
398
|
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
|
|
@@ -392,6 +401,8 @@ var unpluginFactory = (options) => ({
|
|
|
392
401
|
server.close();
|
|
393
402
|
import_node_process3.default.exit();
|
|
394
403
|
});
|
|
404
|
+
}).catch((e) => {
|
|
405
|
+
throw e;
|
|
395
406
|
});
|
|
396
407
|
} catch (e) {
|
|
397
408
|
consola.error(e);
|
|
@@ -401,8 +412,11 @@ var unpluginFactory = (options) => ({
|
|
|
401
412
|
},
|
|
402
413
|
webpack(compiler) {
|
|
403
414
|
const {
|
|
415
|
+
enable = true,
|
|
404
416
|
target = ""
|
|
405
417
|
} = options;
|
|
418
|
+
if (!enable)
|
|
419
|
+
return;
|
|
406
420
|
if (!target) {
|
|
407
421
|
consola.fail("please provide target");
|
|
408
422
|
return;
|
|
@@ -413,7 +427,9 @@ var unpluginFactory = (options) => ({
|
|
|
413
427
|
if (caddy)
|
|
414
428
|
return;
|
|
415
429
|
caddy = new CaddyInstant();
|
|
416
|
-
caddy.run(source, target
|
|
430
|
+
caddy.run(source, target, {
|
|
431
|
+
showCaddyLog: options.showCaddyLog
|
|
432
|
+
}).then((stop) => {
|
|
417
433
|
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
418
434
|
compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
|
|
419
435
|
if (stats.hasErrors())
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/src/caddy/index.ts
CHANGED
|
@@ -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.includes('Error:') || (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
|
@@ -20,8 +20,11 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
20
20
|
},
|
|
21
21
|
configureServer(server) {
|
|
22
22
|
const {
|
|
23
|
+
enable = true,
|
|
23
24
|
target = '',
|
|
24
25
|
} = options
|
|
26
|
+
if (!enable)
|
|
27
|
+
return
|
|
25
28
|
if (!target) {
|
|
26
29
|
consola.fail('please provide target')
|
|
27
30
|
return
|
|
@@ -40,6 +43,7 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
40
43
|
const caddy = new CaddyInstant()
|
|
41
44
|
caddy.run(source, target, {
|
|
42
45
|
base,
|
|
46
|
+
showCaddyLog: options.showCaddyLog,
|
|
43
47
|
}).then((stop) => {
|
|
44
48
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
45
49
|
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`https://${target}${base}`)}`)
|
|
@@ -49,6 +53,8 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
49
53
|
server.close()
|
|
50
54
|
process.exit()
|
|
51
55
|
})
|
|
56
|
+
}).catch((e) => {
|
|
57
|
+
throw e
|
|
52
58
|
})
|
|
53
59
|
}
|
|
54
60
|
catch (e) {
|
|
@@ -59,8 +65,11 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
59
65
|
},
|
|
60
66
|
webpack(compiler) {
|
|
61
67
|
const {
|
|
68
|
+
enable = true,
|
|
62
69
|
target = '',
|
|
63
70
|
} = options
|
|
71
|
+
if (!enable)
|
|
72
|
+
return
|
|
64
73
|
if (!target) {
|
|
65
74
|
consola.fail('please provide target')
|
|
66
75
|
return
|
|
@@ -75,7 +84,9 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
75
84
|
|
|
76
85
|
caddy = new CaddyInstant()
|
|
77
86
|
|
|
78
|
-
caddy.run(source, target
|
|
87
|
+
caddy.run(source, target, {
|
|
88
|
+
showCaddyLog: options.showCaddyLog,
|
|
89
|
+
}).then((stop) => {
|
|
79
90
|
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
80
91
|
|
|
81
92
|
compiler.hooks.done.tap('unplugin-https-reverse-proxy', (stats) => {
|