unplugin-https-reverse-proxy 1.0.0-beta.17 → 1.0.0-beta.18
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 -1
- package/dist/{chunk-WCFY7NJQ.js → chunk-ZDL3GBDQ.js} +39 -31
- package/dist/esbuild.cjs +39 -31
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +39 -31
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +39 -31
- package/dist/nuxt.js +1 -1
- package/dist/rollup.cjs +39 -31
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +39 -31
- package/dist/rspack.js +1 -1
- package/dist/vite.cjs +39 -31
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +39 -31
- package/dist/webpack.js +1 -1
- package/package.json +1 -1
- package/src/caddy/index.ts +41 -37
package/README.md
CHANGED
|
@@ -220,7 +220,17 @@ export default defineNuxtConfig({
|
|
|
220
220
|
})
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
**!important:** You need to update the `nuxt dev` script by adding `--fork=false` to enable host restoration.
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
// package.json
|
|
227
|
+
|
|
228
|
+
{
|
|
229
|
+
"scripts": {
|
|
230
|
+
"dev": "nuxt dev --fork=false"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
224
234
|
|
|
225
235
|
<br></details>
|
|
226
236
|
|
|
@@ -379,6 +379,8 @@ var CaddyInstant = class {
|
|
|
379
379
|
showCaddyLog = false,
|
|
380
380
|
https = false
|
|
381
381
|
} = options || {};
|
|
382
|
+
this._source = source;
|
|
383
|
+
this._target = target;
|
|
382
384
|
if (!this.inited)
|
|
383
385
|
await this.init();
|
|
384
386
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -407,17 +409,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
407
409
|
var _a, _b;
|
|
408
410
|
const setupCleanup = () => {
|
|
409
411
|
process3.on("SIGINT", async () => {
|
|
410
|
-
if (
|
|
412
|
+
if (this.stoped)
|
|
411
413
|
return;
|
|
412
|
-
|
|
414
|
+
process3.stdin.resume();
|
|
413
415
|
try {
|
|
414
|
-
|
|
415
|
-
consola.success("Restore host success.\n");
|
|
416
|
-
else
|
|
417
|
-
consola.fail("Restore host failed.\n");
|
|
418
|
-
} catch (e) {
|
|
419
|
-
consola.error(e);
|
|
420
|
-
consola.fail("Restore host failed.\n");
|
|
416
|
+
await this.baseCleanup(restore);
|
|
421
417
|
} finally {
|
|
422
418
|
this.stoped = true;
|
|
423
419
|
process3.nextTick(() => {
|
|
@@ -433,24 +429,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
433
429
|
const pwd = process3.cwd();
|
|
434
430
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
435
431
|
if (existsSync(viteCacheDir))
|
|
436
|
-
chmodRecursive(viteCacheDir, 511)
|
|
432
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
433
|
+
});
|
|
437
434
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
438
435
|
if (existsSync(nuxtCacheDir))
|
|
439
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
436
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
437
|
+
});
|
|
440
438
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
441
439
|
if (existsSync(webpackCacheDir))
|
|
442
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
443
|
-
|
|
440
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
441
|
+
});
|
|
442
|
+
if (this.stoped)
|
|
444
443
|
return originalExit(code);
|
|
445
|
-
|
|
444
|
+
process3.stdin.resume();
|
|
446
445
|
try {
|
|
447
|
-
|
|
448
|
-
consola.success("Restore host success.\n");
|
|
449
|
-
else
|
|
450
|
-
consola.fail("Restore host failed.\n");
|
|
451
|
-
} catch (e) {
|
|
452
|
-
consola.error(e);
|
|
453
|
-
consola.fail("Restore host failed.\n");
|
|
446
|
+
await this.baseCleanup();
|
|
454
447
|
} finally {
|
|
455
448
|
this.stoped = true;
|
|
456
449
|
process3.nextTick(() => {
|
|
@@ -460,12 +453,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
460
453
|
};
|
|
461
454
|
};
|
|
462
455
|
if (!this.locked) {
|
|
463
|
-
this.
|
|
456
|
+
this._caddyChild = process3.platform !== "win32" ? spawn("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : spawn(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
464
457
|
lockfile.lockSync(caddyLockFilePath);
|
|
465
|
-
this.
|
|
458
|
+
this._caddyChild.on("error", (err) => {
|
|
466
459
|
return reject(err);
|
|
467
460
|
});
|
|
468
|
-
(_a = this.
|
|
461
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
469
462
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
470
463
|
for (const line of lines) {
|
|
471
464
|
showCaddyLog && line && console.info(line);
|
|
@@ -480,7 +473,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
480
473
|
return resolve();
|
|
481
474
|
}
|
|
482
475
|
});
|
|
483
|
-
(_b = this.
|
|
476
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
484
477
|
consola.info(_data.toString());
|
|
485
478
|
resolve();
|
|
486
479
|
});
|
|
@@ -492,15 +485,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
492
485
|
}
|
|
493
486
|
});
|
|
494
487
|
}
|
|
495
|
-
async baseCleanup() {
|
|
488
|
+
async baseCleanup(restore = true) {
|
|
496
489
|
var _a;
|
|
497
|
-
|
|
498
|
-
(
|
|
490
|
+
try {
|
|
491
|
+
if (restore && this._source && this._target) {
|
|
492
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
493
|
+
consola.success("Restore host success.\n");
|
|
494
|
+
else
|
|
495
|
+
consola.fail("Restore host failed.\n");
|
|
496
|
+
}
|
|
497
|
+
} catch (e) {
|
|
498
|
+
consola.error(e);
|
|
499
|
+
consola.fail("Restore host failed.\n");
|
|
500
|
+
}
|
|
501
|
+
if (!this.locked && !this.stoped) {
|
|
502
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
499
503
|
try {
|
|
500
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
501
|
-
|
|
502
|
-
await unlink(
|
|
504
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
505
|
+
});
|
|
506
|
+
await unlink(caddyFilePath).catch(() => {
|
|
507
|
+
});
|
|
508
|
+
await unlink(caddyLockFilePath).catch(() => {
|
|
509
|
+
});
|
|
503
510
|
} catch (e) {
|
|
511
|
+
consola.error(e);
|
|
504
512
|
}
|
|
505
513
|
}
|
|
506
514
|
}
|
package/dist/esbuild.cjs
CHANGED
|
@@ -448,6 +448,8 @@ var CaddyInstant = class {
|
|
|
448
448
|
showCaddyLog = false,
|
|
449
449
|
https = false
|
|
450
450
|
} = options || {};
|
|
451
|
+
this._source = source;
|
|
452
|
+
this._target = target;
|
|
451
453
|
if (!this.inited)
|
|
452
454
|
await this.init();
|
|
453
455
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -476,17 +478,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
476
478
|
var _a, _b;
|
|
477
479
|
const setupCleanup = () => {
|
|
478
480
|
import_node_process4.default.on("SIGINT", async () => {
|
|
479
|
-
if (
|
|
481
|
+
if (this.stoped)
|
|
480
482
|
return;
|
|
481
|
-
|
|
483
|
+
import_node_process4.default.stdin.resume();
|
|
482
484
|
try {
|
|
483
|
-
|
|
484
|
-
consola.success("Restore host success.\n");
|
|
485
|
-
else
|
|
486
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
-
} catch (e) {
|
|
488
|
-
consola.error(e);
|
|
489
|
-
consola.fail("Restore host failed.\n");
|
|
485
|
+
await this.baseCleanup(restore);
|
|
490
486
|
} finally {
|
|
491
487
|
this.stoped = true;
|
|
492
488
|
import_node_process4.default.nextTick(() => {
|
|
@@ -502,24 +498,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
502
498
|
const pwd = import_node_process4.default.cwd();
|
|
503
499
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
504
500
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
505
|
-
chmodRecursive(viteCacheDir, 511)
|
|
501
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
502
|
+
});
|
|
506
503
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
507
504
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
508
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
505
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
506
|
+
});
|
|
509
507
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
510
508
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
511
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
512
|
-
|
|
509
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
510
|
+
});
|
|
511
|
+
if (this.stoped)
|
|
513
512
|
return originalExit(code);
|
|
514
|
-
|
|
513
|
+
import_node_process4.default.stdin.resume();
|
|
515
514
|
try {
|
|
516
|
-
|
|
517
|
-
consola.success("Restore host success.\n");
|
|
518
|
-
else
|
|
519
|
-
consola.fail("Restore host failed.\n");
|
|
520
|
-
} catch (e) {
|
|
521
|
-
consola.error(e);
|
|
522
|
-
consola.fail("Restore host failed.\n");
|
|
515
|
+
await this.baseCleanup();
|
|
523
516
|
} finally {
|
|
524
517
|
this.stoped = true;
|
|
525
518
|
import_node_process4.default.nextTick(() => {
|
|
@@ -529,12 +522,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
529
522
|
};
|
|
530
523
|
};
|
|
531
524
|
if (!this.locked) {
|
|
532
|
-
this.
|
|
525
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
533
526
|
lockfile.lockSync(caddyLockFilePath);
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild.on("error", (err) => {
|
|
535
528
|
return reject(err);
|
|
536
529
|
});
|
|
537
|
-
(_a = this.
|
|
530
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
538
531
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
539
532
|
for (const line of lines) {
|
|
540
533
|
showCaddyLog && line && console.info(line);
|
|
@@ -549,7 +542,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
549
542
|
return resolve();
|
|
550
543
|
}
|
|
551
544
|
});
|
|
552
|
-
(_b = this.
|
|
545
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
553
546
|
consola.info(_data.toString());
|
|
554
547
|
resolve();
|
|
555
548
|
});
|
|
@@ -561,15 +554,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
561
554
|
}
|
|
562
555
|
});
|
|
563
556
|
}
|
|
564
|
-
async baseCleanup() {
|
|
557
|
+
async baseCleanup(restore = true) {
|
|
565
558
|
var _a;
|
|
566
|
-
|
|
567
|
-
(
|
|
559
|
+
try {
|
|
560
|
+
if (restore && this._source && this._target) {
|
|
561
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
562
|
+
consola.success("Restore host success.\n");
|
|
563
|
+
else
|
|
564
|
+
consola.fail("Restore host failed.\n");
|
|
565
|
+
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
consola.error(e);
|
|
568
|
+
consola.fail("Restore host failed.\n");
|
|
569
|
+
}
|
|
570
|
+
if (!this.locked && !this.stoped) {
|
|
571
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
568
572
|
try {
|
|
569
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
570
|
-
|
|
571
|
-
await (0, import_promises2.unlink)(
|
|
573
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
574
|
+
});
|
|
575
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
578
|
+
});
|
|
572
579
|
} catch (e) {
|
|
580
|
+
consola.error(e);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
}
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -448,6 +448,8 @@ var CaddyInstant = class {
|
|
|
448
448
|
showCaddyLog = false,
|
|
449
449
|
https = false
|
|
450
450
|
} = options || {};
|
|
451
|
+
this._source = source;
|
|
452
|
+
this._target = target;
|
|
451
453
|
if (!this.inited)
|
|
452
454
|
await this.init();
|
|
453
455
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -476,17 +478,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
476
478
|
var _a, _b;
|
|
477
479
|
const setupCleanup = () => {
|
|
478
480
|
import_node_process4.default.on("SIGINT", async () => {
|
|
479
|
-
if (
|
|
481
|
+
if (this.stoped)
|
|
480
482
|
return;
|
|
481
|
-
|
|
483
|
+
import_node_process4.default.stdin.resume();
|
|
482
484
|
try {
|
|
483
|
-
|
|
484
|
-
consola.success("Restore host success.\n");
|
|
485
|
-
else
|
|
486
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
-
} catch (e) {
|
|
488
|
-
consola.error(e);
|
|
489
|
-
consola.fail("Restore host failed.\n");
|
|
485
|
+
await this.baseCleanup(restore);
|
|
490
486
|
} finally {
|
|
491
487
|
this.stoped = true;
|
|
492
488
|
import_node_process4.default.nextTick(() => {
|
|
@@ -502,24 +498,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
502
498
|
const pwd = import_node_process4.default.cwd();
|
|
503
499
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
504
500
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
505
|
-
chmodRecursive(viteCacheDir, 511)
|
|
501
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
502
|
+
});
|
|
506
503
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
507
504
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
508
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
505
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
506
|
+
});
|
|
509
507
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
510
508
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
511
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
512
|
-
|
|
509
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
510
|
+
});
|
|
511
|
+
if (this.stoped)
|
|
513
512
|
return originalExit(code);
|
|
514
|
-
|
|
513
|
+
import_node_process4.default.stdin.resume();
|
|
515
514
|
try {
|
|
516
|
-
|
|
517
|
-
consola.success("Restore host success.\n");
|
|
518
|
-
else
|
|
519
|
-
consola.fail("Restore host failed.\n");
|
|
520
|
-
} catch (e) {
|
|
521
|
-
consola.error(e);
|
|
522
|
-
consola.fail("Restore host failed.\n");
|
|
515
|
+
await this.baseCleanup();
|
|
523
516
|
} finally {
|
|
524
517
|
this.stoped = true;
|
|
525
518
|
import_node_process4.default.nextTick(() => {
|
|
@@ -529,12 +522,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
529
522
|
};
|
|
530
523
|
};
|
|
531
524
|
if (!this.locked) {
|
|
532
|
-
this.
|
|
525
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
533
526
|
lockfile.lockSync(caddyLockFilePath);
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild.on("error", (err) => {
|
|
535
528
|
return reject(err);
|
|
536
529
|
});
|
|
537
|
-
(_a = this.
|
|
530
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
538
531
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
539
532
|
for (const line of lines) {
|
|
540
533
|
showCaddyLog && line && console.info(line);
|
|
@@ -549,7 +542,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
549
542
|
return resolve();
|
|
550
543
|
}
|
|
551
544
|
});
|
|
552
|
-
(_b = this.
|
|
545
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
553
546
|
consola.info(_data.toString());
|
|
554
547
|
resolve();
|
|
555
548
|
});
|
|
@@ -561,15 +554,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
561
554
|
}
|
|
562
555
|
});
|
|
563
556
|
}
|
|
564
|
-
async baseCleanup() {
|
|
557
|
+
async baseCleanup(restore = true) {
|
|
565
558
|
var _a;
|
|
566
|
-
|
|
567
|
-
(
|
|
559
|
+
try {
|
|
560
|
+
if (restore && this._source && this._target) {
|
|
561
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
562
|
+
consola.success("Restore host success.\n");
|
|
563
|
+
else
|
|
564
|
+
consola.fail("Restore host failed.\n");
|
|
565
|
+
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
consola.error(e);
|
|
568
|
+
consola.fail("Restore host failed.\n");
|
|
569
|
+
}
|
|
570
|
+
if (!this.locked && !this.stoped) {
|
|
571
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
568
572
|
try {
|
|
569
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
570
|
-
|
|
571
|
-
await (0, import_promises2.unlink)(
|
|
573
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
574
|
+
});
|
|
575
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
578
|
+
});
|
|
572
579
|
} catch (e) {
|
|
580
|
+
consola.error(e);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
}
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -450,6 +450,8 @@ var CaddyInstant = class {
|
|
|
450
450
|
showCaddyLog = false,
|
|
451
451
|
https = false
|
|
452
452
|
} = options || {};
|
|
453
|
+
this._source = source;
|
|
454
|
+
this._target = target;
|
|
453
455
|
if (!this.inited)
|
|
454
456
|
await this.init();
|
|
455
457
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -478,17 +480,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
478
480
|
var _a, _b;
|
|
479
481
|
const setupCleanup = () => {
|
|
480
482
|
import_node_process4.default.on("SIGINT", async () => {
|
|
481
|
-
if (
|
|
483
|
+
if (this.stoped)
|
|
482
484
|
return;
|
|
483
|
-
|
|
485
|
+
import_node_process4.default.stdin.resume();
|
|
484
486
|
try {
|
|
485
|
-
|
|
486
|
-
consola.success("Restore host success.\n");
|
|
487
|
-
else
|
|
488
|
-
consola.fail("Restore host failed.\n");
|
|
489
|
-
} catch (e) {
|
|
490
|
-
consola.error(e);
|
|
491
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
+
await this.baseCleanup(restore);
|
|
492
488
|
} finally {
|
|
493
489
|
this.stoped = true;
|
|
494
490
|
import_node_process4.default.nextTick(() => {
|
|
@@ -504,24 +500,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
504
500
|
const pwd = import_node_process4.default.cwd();
|
|
505
501
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
506
502
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
507
|
-
chmodRecursive(viteCacheDir, 511)
|
|
503
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
504
|
+
});
|
|
508
505
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
509
506
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
510
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
507
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
508
|
+
});
|
|
511
509
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
512
510
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
513
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
514
|
-
|
|
511
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
512
|
+
});
|
|
513
|
+
if (this.stoped)
|
|
515
514
|
return originalExit(code);
|
|
516
|
-
|
|
515
|
+
import_node_process4.default.stdin.resume();
|
|
517
516
|
try {
|
|
518
|
-
|
|
519
|
-
consola.success("Restore host success.\n");
|
|
520
|
-
else
|
|
521
|
-
consola.fail("Restore host failed.\n");
|
|
522
|
-
} catch (e) {
|
|
523
|
-
consola.error(e);
|
|
524
|
-
consola.fail("Restore host failed.\n");
|
|
517
|
+
await this.baseCleanup();
|
|
525
518
|
} finally {
|
|
526
519
|
this.stoped = true;
|
|
527
520
|
import_node_process4.default.nextTick(() => {
|
|
@@ -531,12 +524,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
531
524
|
};
|
|
532
525
|
};
|
|
533
526
|
if (!this.locked) {
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
535
528
|
lockfile.lockSync(caddyLockFilePath);
|
|
536
|
-
this.
|
|
529
|
+
this._caddyChild.on("error", (err) => {
|
|
537
530
|
return reject(err);
|
|
538
531
|
});
|
|
539
|
-
(_a = this.
|
|
532
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
540
533
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
541
534
|
for (const line of lines) {
|
|
542
535
|
showCaddyLog && line && console.info(line);
|
|
@@ -551,7 +544,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
551
544
|
return resolve();
|
|
552
545
|
}
|
|
553
546
|
});
|
|
554
|
-
(_b = this.
|
|
547
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
555
548
|
consola.info(_data.toString());
|
|
556
549
|
resolve();
|
|
557
550
|
});
|
|
@@ -563,15 +556,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
563
556
|
}
|
|
564
557
|
});
|
|
565
558
|
}
|
|
566
|
-
async baseCleanup() {
|
|
559
|
+
async baseCleanup(restore = true) {
|
|
567
560
|
var _a;
|
|
568
|
-
|
|
569
|
-
(
|
|
561
|
+
try {
|
|
562
|
+
if (restore && this._source && this._target) {
|
|
563
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
564
|
+
consola.success("Restore host success.\n");
|
|
565
|
+
else
|
|
566
|
+
consola.fail("Restore host failed.\n");
|
|
567
|
+
}
|
|
568
|
+
} catch (e) {
|
|
569
|
+
consola.error(e);
|
|
570
|
+
consola.fail("Restore host failed.\n");
|
|
571
|
+
}
|
|
572
|
+
if (!this.locked && !this.stoped) {
|
|
573
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
570
574
|
try {
|
|
571
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
572
|
-
|
|
573
|
-
await (0, import_promises2.unlink)(
|
|
575
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
578
|
+
});
|
|
579
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
580
|
+
});
|
|
574
581
|
} catch (e) {
|
|
582
|
+
consola.error(e);
|
|
575
583
|
}
|
|
576
584
|
}
|
|
577
585
|
}
|
package/dist/nuxt.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -448,6 +448,8 @@ var CaddyInstant = class {
|
|
|
448
448
|
showCaddyLog = false,
|
|
449
449
|
https = false
|
|
450
450
|
} = options || {};
|
|
451
|
+
this._source = source;
|
|
452
|
+
this._target = target;
|
|
451
453
|
if (!this.inited)
|
|
452
454
|
await this.init();
|
|
453
455
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -476,17 +478,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
476
478
|
var _a, _b;
|
|
477
479
|
const setupCleanup = () => {
|
|
478
480
|
import_node_process4.default.on("SIGINT", async () => {
|
|
479
|
-
if (
|
|
481
|
+
if (this.stoped)
|
|
480
482
|
return;
|
|
481
|
-
|
|
483
|
+
import_node_process4.default.stdin.resume();
|
|
482
484
|
try {
|
|
483
|
-
|
|
484
|
-
consola.success("Restore host success.\n");
|
|
485
|
-
else
|
|
486
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
-
} catch (e) {
|
|
488
|
-
consola.error(e);
|
|
489
|
-
consola.fail("Restore host failed.\n");
|
|
485
|
+
await this.baseCleanup(restore);
|
|
490
486
|
} finally {
|
|
491
487
|
this.stoped = true;
|
|
492
488
|
import_node_process4.default.nextTick(() => {
|
|
@@ -502,24 +498,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
502
498
|
const pwd = import_node_process4.default.cwd();
|
|
503
499
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
504
500
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
505
|
-
chmodRecursive(viteCacheDir, 511)
|
|
501
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
502
|
+
});
|
|
506
503
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
507
504
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
508
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
505
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
506
|
+
});
|
|
509
507
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
510
508
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
511
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
512
|
-
|
|
509
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
510
|
+
});
|
|
511
|
+
if (this.stoped)
|
|
513
512
|
return originalExit(code);
|
|
514
|
-
|
|
513
|
+
import_node_process4.default.stdin.resume();
|
|
515
514
|
try {
|
|
516
|
-
|
|
517
|
-
consola.success("Restore host success.\n");
|
|
518
|
-
else
|
|
519
|
-
consola.fail("Restore host failed.\n");
|
|
520
|
-
} catch (e) {
|
|
521
|
-
consola.error(e);
|
|
522
|
-
consola.fail("Restore host failed.\n");
|
|
515
|
+
await this.baseCleanup();
|
|
523
516
|
} finally {
|
|
524
517
|
this.stoped = true;
|
|
525
518
|
import_node_process4.default.nextTick(() => {
|
|
@@ -529,12 +522,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
529
522
|
};
|
|
530
523
|
};
|
|
531
524
|
if (!this.locked) {
|
|
532
|
-
this.
|
|
525
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
533
526
|
lockfile.lockSync(caddyLockFilePath);
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild.on("error", (err) => {
|
|
535
528
|
return reject(err);
|
|
536
529
|
});
|
|
537
|
-
(_a = this.
|
|
530
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
538
531
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
539
532
|
for (const line of lines) {
|
|
540
533
|
showCaddyLog && line && console.info(line);
|
|
@@ -549,7 +542,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
549
542
|
return resolve();
|
|
550
543
|
}
|
|
551
544
|
});
|
|
552
|
-
(_b = this.
|
|
545
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
553
546
|
consola.info(_data.toString());
|
|
554
547
|
resolve();
|
|
555
548
|
});
|
|
@@ -561,15 +554,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
561
554
|
}
|
|
562
555
|
});
|
|
563
556
|
}
|
|
564
|
-
async baseCleanup() {
|
|
557
|
+
async baseCleanup(restore = true) {
|
|
565
558
|
var _a;
|
|
566
|
-
|
|
567
|
-
(
|
|
559
|
+
try {
|
|
560
|
+
if (restore && this._source && this._target) {
|
|
561
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
562
|
+
consola.success("Restore host success.\n");
|
|
563
|
+
else
|
|
564
|
+
consola.fail("Restore host failed.\n");
|
|
565
|
+
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
consola.error(e);
|
|
568
|
+
consola.fail("Restore host failed.\n");
|
|
569
|
+
}
|
|
570
|
+
if (!this.locked && !this.stoped) {
|
|
571
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
568
572
|
try {
|
|
569
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
570
|
-
|
|
571
|
-
await (0, import_promises2.unlink)(
|
|
573
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
574
|
+
});
|
|
575
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
578
|
+
});
|
|
572
579
|
} catch (e) {
|
|
580
|
+
consola.error(e);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
}
|
package/dist/rollup.js
CHANGED
package/dist/rspack.cjs
CHANGED
|
@@ -447,6 +447,8 @@ var CaddyInstant = class {
|
|
|
447
447
|
showCaddyLog = false,
|
|
448
448
|
https = false
|
|
449
449
|
} = options || {};
|
|
450
|
+
this._source = source;
|
|
451
|
+
this._target = target;
|
|
450
452
|
if (!this.inited)
|
|
451
453
|
await this.init();
|
|
452
454
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -475,17 +477,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
475
477
|
var _a, _b;
|
|
476
478
|
const setupCleanup = () => {
|
|
477
479
|
import_node_process4.default.on("SIGINT", async () => {
|
|
478
|
-
if (
|
|
480
|
+
if (this.stoped)
|
|
479
481
|
return;
|
|
480
|
-
|
|
482
|
+
import_node_process4.default.stdin.resume();
|
|
481
483
|
try {
|
|
482
|
-
|
|
483
|
-
consola.success("Restore host success.\n");
|
|
484
|
-
else
|
|
485
|
-
consola.fail("Restore host failed.\n");
|
|
486
|
-
} catch (e) {
|
|
487
|
-
consola.error(e);
|
|
488
|
-
consola.fail("Restore host failed.\n");
|
|
484
|
+
await this.baseCleanup(restore);
|
|
489
485
|
} finally {
|
|
490
486
|
this.stoped = true;
|
|
491
487
|
import_node_process4.default.nextTick(() => {
|
|
@@ -501,24 +497,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
501
497
|
const pwd = import_node_process4.default.cwd();
|
|
502
498
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
503
499
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
504
|
-
chmodRecursive(viteCacheDir, 511)
|
|
500
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
501
|
+
});
|
|
505
502
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
506
503
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
507
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
504
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
505
|
+
});
|
|
508
506
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
509
507
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
510
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
511
|
-
|
|
508
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
509
|
+
});
|
|
510
|
+
if (this.stoped)
|
|
512
511
|
return originalExit(code);
|
|
513
|
-
|
|
512
|
+
import_node_process4.default.stdin.resume();
|
|
514
513
|
try {
|
|
515
|
-
|
|
516
|
-
consola.success("Restore host success.\n");
|
|
517
|
-
else
|
|
518
|
-
consola.fail("Restore host failed.\n");
|
|
519
|
-
} catch (e) {
|
|
520
|
-
consola.error(e);
|
|
521
|
-
consola.fail("Restore host failed.\n");
|
|
514
|
+
await this.baseCleanup();
|
|
522
515
|
} finally {
|
|
523
516
|
this.stoped = true;
|
|
524
517
|
import_node_process4.default.nextTick(() => {
|
|
@@ -528,12 +521,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
528
521
|
};
|
|
529
522
|
};
|
|
530
523
|
if (!this.locked) {
|
|
531
|
-
this.
|
|
524
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
532
525
|
lockfile.lockSync(caddyLockFilePath);
|
|
533
|
-
this.
|
|
526
|
+
this._caddyChild.on("error", (err) => {
|
|
534
527
|
return reject(err);
|
|
535
528
|
});
|
|
536
|
-
(_a = this.
|
|
529
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
537
530
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
538
531
|
for (const line of lines) {
|
|
539
532
|
showCaddyLog && line && console.info(line);
|
|
@@ -548,7 +541,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
548
541
|
return resolve();
|
|
549
542
|
}
|
|
550
543
|
});
|
|
551
|
-
(_b = this.
|
|
544
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
552
545
|
consola.info(_data.toString());
|
|
553
546
|
resolve();
|
|
554
547
|
});
|
|
@@ -560,15 +553,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
560
553
|
}
|
|
561
554
|
});
|
|
562
555
|
}
|
|
563
|
-
async baseCleanup() {
|
|
556
|
+
async baseCleanup(restore = true) {
|
|
564
557
|
var _a;
|
|
565
|
-
|
|
566
|
-
(
|
|
558
|
+
try {
|
|
559
|
+
if (restore && this._source && this._target) {
|
|
560
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
561
|
+
consola.success("Restore host success.\n");
|
|
562
|
+
else
|
|
563
|
+
consola.fail("Restore host failed.\n");
|
|
564
|
+
}
|
|
565
|
+
} catch (e) {
|
|
566
|
+
consola.error(e);
|
|
567
|
+
consola.fail("Restore host failed.\n");
|
|
568
|
+
}
|
|
569
|
+
if (!this.locked && !this.stoped) {
|
|
570
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
567
571
|
try {
|
|
568
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
569
|
-
|
|
570
|
-
await (0, import_promises2.unlink)(
|
|
572
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
573
|
+
});
|
|
574
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
575
|
+
});
|
|
576
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
577
|
+
});
|
|
571
578
|
} catch (e) {
|
|
579
|
+
consola.error(e);
|
|
572
580
|
}
|
|
573
581
|
}
|
|
574
582
|
}
|
package/dist/rspack.js
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -448,6 +448,8 @@ var CaddyInstant = class {
|
|
|
448
448
|
showCaddyLog = false,
|
|
449
449
|
https = false
|
|
450
450
|
} = options || {};
|
|
451
|
+
this._source = source;
|
|
452
|
+
this._target = target;
|
|
451
453
|
if (!this.inited)
|
|
452
454
|
await this.init();
|
|
453
455
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -476,17 +478,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
476
478
|
var _a, _b;
|
|
477
479
|
const setupCleanup = () => {
|
|
478
480
|
import_node_process4.default.on("SIGINT", async () => {
|
|
479
|
-
if (
|
|
481
|
+
if (this.stoped)
|
|
480
482
|
return;
|
|
481
|
-
|
|
483
|
+
import_node_process4.default.stdin.resume();
|
|
482
484
|
try {
|
|
483
|
-
|
|
484
|
-
consola.success("Restore host success.\n");
|
|
485
|
-
else
|
|
486
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
-
} catch (e) {
|
|
488
|
-
consola.error(e);
|
|
489
|
-
consola.fail("Restore host failed.\n");
|
|
485
|
+
await this.baseCleanup(restore);
|
|
490
486
|
} finally {
|
|
491
487
|
this.stoped = true;
|
|
492
488
|
import_node_process4.default.nextTick(() => {
|
|
@@ -502,24 +498,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
502
498
|
const pwd = import_node_process4.default.cwd();
|
|
503
499
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
504
500
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
505
|
-
chmodRecursive(viteCacheDir, 511)
|
|
501
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
502
|
+
});
|
|
506
503
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
507
504
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
508
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
505
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
506
|
+
});
|
|
509
507
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
510
508
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
511
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
512
|
-
|
|
509
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
510
|
+
});
|
|
511
|
+
if (this.stoped)
|
|
513
512
|
return originalExit(code);
|
|
514
|
-
|
|
513
|
+
import_node_process4.default.stdin.resume();
|
|
515
514
|
try {
|
|
516
|
-
|
|
517
|
-
consola.success("Restore host success.\n");
|
|
518
|
-
else
|
|
519
|
-
consola.fail("Restore host failed.\n");
|
|
520
|
-
} catch (e) {
|
|
521
|
-
consola.error(e);
|
|
522
|
-
consola.fail("Restore host failed.\n");
|
|
515
|
+
await this.baseCleanup();
|
|
523
516
|
} finally {
|
|
524
517
|
this.stoped = true;
|
|
525
518
|
import_node_process4.default.nextTick(() => {
|
|
@@ -529,12 +522,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
529
522
|
};
|
|
530
523
|
};
|
|
531
524
|
if (!this.locked) {
|
|
532
|
-
this.
|
|
525
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
533
526
|
lockfile.lockSync(caddyLockFilePath);
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild.on("error", (err) => {
|
|
535
528
|
return reject(err);
|
|
536
529
|
});
|
|
537
|
-
(_a = this.
|
|
530
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
538
531
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
539
532
|
for (const line of lines) {
|
|
540
533
|
showCaddyLog && line && console.info(line);
|
|
@@ -549,7 +542,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
549
542
|
return resolve();
|
|
550
543
|
}
|
|
551
544
|
});
|
|
552
|
-
(_b = this.
|
|
545
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
553
546
|
consola.info(_data.toString());
|
|
554
547
|
resolve();
|
|
555
548
|
});
|
|
@@ -561,15 +554,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
561
554
|
}
|
|
562
555
|
});
|
|
563
556
|
}
|
|
564
|
-
async baseCleanup() {
|
|
557
|
+
async baseCleanup(restore = true) {
|
|
565
558
|
var _a;
|
|
566
|
-
|
|
567
|
-
(
|
|
559
|
+
try {
|
|
560
|
+
if (restore && this._source && this._target) {
|
|
561
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
562
|
+
consola.success("Restore host success.\n");
|
|
563
|
+
else
|
|
564
|
+
consola.fail("Restore host failed.\n");
|
|
565
|
+
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
consola.error(e);
|
|
568
|
+
consola.fail("Restore host failed.\n");
|
|
569
|
+
}
|
|
570
|
+
if (!this.locked && !this.stoped) {
|
|
571
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
568
572
|
try {
|
|
569
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
570
|
-
|
|
571
|
-
await (0, import_promises2.unlink)(
|
|
573
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
574
|
+
});
|
|
575
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
578
|
+
});
|
|
572
579
|
} catch (e) {
|
|
580
|
+
consola.error(e);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
}
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -448,6 +448,8 @@ var CaddyInstant = class {
|
|
|
448
448
|
showCaddyLog = false,
|
|
449
449
|
https = false
|
|
450
450
|
} = options || {};
|
|
451
|
+
this._source = source;
|
|
452
|
+
this._target = target;
|
|
451
453
|
if (!this.inited)
|
|
452
454
|
await this.init();
|
|
453
455
|
if (!await addHost(source.split(":")[0], target.split(":")[0]))
|
|
@@ -476,17 +478,11 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
476
478
|
var _a, _b;
|
|
477
479
|
const setupCleanup = () => {
|
|
478
480
|
import_node_process4.default.on("SIGINT", async () => {
|
|
479
|
-
if (
|
|
481
|
+
if (this.stoped)
|
|
480
482
|
return;
|
|
481
|
-
|
|
483
|
+
import_node_process4.default.stdin.resume();
|
|
482
484
|
try {
|
|
483
|
-
|
|
484
|
-
consola.success("Restore host success.\n");
|
|
485
|
-
else
|
|
486
|
-
consola.fail("Restore host failed.\n");
|
|
487
|
-
} catch (e) {
|
|
488
|
-
consola.error(e);
|
|
489
|
-
consola.fail("Restore host failed.\n");
|
|
485
|
+
await this.baseCleanup(restore);
|
|
490
486
|
} finally {
|
|
491
487
|
this.stoped = true;
|
|
492
488
|
import_node_process4.default.nextTick(() => {
|
|
@@ -502,24 +498,21 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
502
498
|
const pwd = import_node_process4.default.cwd();
|
|
503
499
|
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
504
500
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
505
|
-
chmodRecursive(viteCacheDir, 511)
|
|
501
|
+
await chmodRecursive(viteCacheDir, 511).catch(() => {
|
|
502
|
+
});
|
|
506
503
|
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
507
504
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
508
|
-
await chmodRecursive(nuxtCacheDir, 511)
|
|
505
|
+
await chmodRecursive(nuxtCacheDir, 511).catch(() => {
|
|
506
|
+
});
|
|
509
507
|
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
510
508
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
511
|
-
chmodRecursive(webpackCacheDir, 511)
|
|
512
|
-
|
|
509
|
+
await chmodRecursive(webpackCacheDir, 511).catch(() => {
|
|
510
|
+
});
|
|
511
|
+
if (this.stoped)
|
|
513
512
|
return originalExit(code);
|
|
514
|
-
|
|
513
|
+
import_node_process4.default.stdin.resume();
|
|
515
514
|
try {
|
|
516
|
-
|
|
517
|
-
consola.success("Restore host success.\n");
|
|
518
|
-
else
|
|
519
|
-
consola.fail("Restore host failed.\n");
|
|
520
|
-
} catch (e) {
|
|
521
|
-
consola.error(e);
|
|
522
|
-
consola.fail("Restore host failed.\n");
|
|
515
|
+
await this.baseCleanup();
|
|
523
516
|
} finally {
|
|
524
517
|
this.stoped = true;
|
|
525
518
|
import_node_process4.default.nextTick(() => {
|
|
@@ -529,12 +522,12 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
529
522
|
};
|
|
530
523
|
};
|
|
531
524
|
if (!this.locked) {
|
|
532
|
-
this.
|
|
525
|
+
this._caddyChild = import_node_process4.default.platform !== "win32" ? (0, import_node_child_process4.spawn)("sudo", ["-E", caddyPath, "run", "--config", caddyFilePath, "--watch"]) : (0, import_node_child_process4.spawn)(caddyPath, ["run", "--config", caddyFilePath, "--watch"]);
|
|
533
526
|
lockfile.lockSync(caddyLockFilePath);
|
|
534
|
-
this.
|
|
527
|
+
this._caddyChild.on("error", (err) => {
|
|
535
528
|
return reject(err);
|
|
536
529
|
});
|
|
537
|
-
(_a = this.
|
|
530
|
+
(_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
|
|
538
531
|
const lines = data.toString().split("\n").map((line) => line.trim());
|
|
539
532
|
for (const line of lines) {
|
|
540
533
|
showCaddyLog && line && console.info(line);
|
|
@@ -549,7 +542,7 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
549
542
|
return resolve();
|
|
550
543
|
}
|
|
551
544
|
});
|
|
552
|
-
(_b = this.
|
|
545
|
+
(_b = this._caddyChild.stdout) == null ? void 0 : _b.on("data", (_data) => {
|
|
553
546
|
consola.info(_data.toString());
|
|
554
547
|
resolve();
|
|
555
548
|
});
|
|
@@ -561,15 +554,30 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
561
554
|
}
|
|
562
555
|
});
|
|
563
556
|
}
|
|
564
|
-
async baseCleanup() {
|
|
557
|
+
async baseCleanup(restore = true) {
|
|
565
558
|
var _a;
|
|
566
|
-
|
|
567
|
-
(
|
|
559
|
+
try {
|
|
560
|
+
if (restore && this._source && this._target) {
|
|
561
|
+
if (await removeHost(this._source.split(":")[0], this._target.split(":")[0]))
|
|
562
|
+
consola.success("Restore host success.\n");
|
|
563
|
+
else
|
|
564
|
+
consola.fail("Restore host failed.\n");
|
|
565
|
+
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
consola.error(e);
|
|
568
|
+
consola.fail("Restore host failed.\n");
|
|
569
|
+
}
|
|
570
|
+
if (!this.locked && !this.stoped) {
|
|
571
|
+
(_a = this._caddyChild) == null ? void 0 : _a.kill();
|
|
568
572
|
try {
|
|
569
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
570
|
-
|
|
571
|
-
await (0, import_promises2.unlink)(
|
|
573
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => {
|
|
574
|
+
});
|
|
575
|
+
await (0, import_promises2.unlink)(caddyFilePath).catch(() => {
|
|
576
|
+
});
|
|
577
|
+
await (0, import_promises2.unlink)(caddyLockFilePath).catch(() => {
|
|
578
|
+
});
|
|
572
579
|
} catch (e) {
|
|
580
|
+
consola.error(e);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
}
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/src/caddy/index.ts
CHANGED
|
@@ -108,7 +108,10 @@ export class CaddyInstant {
|
|
|
108
108
|
private locked = false
|
|
109
109
|
private caddyfile: string | undefined
|
|
110
110
|
|
|
111
|
-
private
|
|
111
|
+
private _caddyChild: ReturnType<typeof spawn> | undefined
|
|
112
|
+
|
|
113
|
+
private _source: string | undefined
|
|
114
|
+
private _target: string | undefined
|
|
112
115
|
|
|
113
116
|
constructor() {
|
|
114
117
|
testCaddy().then(async () => {
|
|
@@ -173,6 +176,9 @@ export class CaddyInstant {
|
|
|
173
176
|
https = false,
|
|
174
177
|
} = options || {}
|
|
175
178
|
|
|
179
|
+
this._source = source
|
|
180
|
+
this._target = target
|
|
181
|
+
|
|
176
182
|
if (!this.inited)
|
|
177
183
|
await this.init()
|
|
178
184
|
|
|
@@ -206,21 +212,13 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
206
212
|
return new Promise<void>((resolve, reject) => {
|
|
207
213
|
const setupCleanup = () => {
|
|
208
214
|
process.on('SIGINT', async () => {
|
|
209
|
-
if (
|
|
215
|
+
if (this.stoped)
|
|
210
216
|
return
|
|
211
217
|
|
|
212
|
-
|
|
218
|
+
process.stdin.resume()
|
|
213
219
|
|
|
214
220
|
try {
|
|
215
|
-
|
|
216
|
-
consola.success('Restore host success.\n')
|
|
217
|
-
|
|
218
|
-
else
|
|
219
|
-
consola.fail('Restore host failed.\n')
|
|
220
|
-
}
|
|
221
|
-
catch (e) {
|
|
222
|
-
consola.error(e)
|
|
223
|
-
consola.fail('Restore host failed.\n')
|
|
221
|
+
await this.baseCleanup(restore)
|
|
224
222
|
}
|
|
225
223
|
finally {
|
|
226
224
|
this.stoped = true
|
|
@@ -242,30 +240,23 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
242
240
|
const pwd = process.cwd()
|
|
243
241
|
const viteCacheDir = `${pwd}/node_modules/.vite`
|
|
244
242
|
if (existsSync(viteCacheDir))
|
|
245
|
-
chmodRecursive(viteCacheDir, 0o777)
|
|
243
|
+
await chmodRecursive(viteCacheDir, 0o777).catch(() => { })
|
|
246
244
|
const nuxtCacheDir = `${pwd}/.nuxt`
|
|
247
245
|
if (existsSync(nuxtCacheDir))
|
|
248
|
-
await chmodRecursive(nuxtCacheDir, 0o777)
|
|
246
|
+
await chmodRecursive(nuxtCacheDir, 0o777).catch(() => { })
|
|
249
247
|
const webpackCacheDir = `${pwd}/node_modules/.cache`
|
|
250
248
|
if (existsSync(webpackCacheDir))
|
|
251
|
-
chmodRecursive(webpackCacheDir, 0o777)
|
|
249
|
+
await chmodRecursive(webpackCacheDir, 0o777).catch(() => { })
|
|
252
250
|
|
|
253
|
-
if (
|
|
251
|
+
if (this.stoped)
|
|
254
252
|
return originalExit(code)
|
|
255
253
|
|
|
256
|
-
|
|
254
|
+
process.stdin.resume()
|
|
257
255
|
|
|
258
256
|
try {
|
|
259
|
-
|
|
260
|
-
consola.success('Restore host success.\n')
|
|
261
|
-
|
|
262
|
-
else
|
|
263
|
-
consola.fail('Restore host failed.\n')
|
|
264
|
-
}
|
|
265
|
-
catch (e) {
|
|
266
|
-
consola.error(e)
|
|
267
|
-
consola.fail('Restore host failed.\n')
|
|
257
|
+
await this.baseCleanup()
|
|
268
258
|
}
|
|
259
|
+
|
|
269
260
|
finally {
|
|
270
261
|
this.stoped = true
|
|
271
262
|
process.nextTick(() => {
|
|
@@ -276,17 +267,17 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
276
267
|
}
|
|
277
268
|
|
|
278
269
|
if (!this.locked) {
|
|
279
|
-
this.
|
|
270
|
+
this._caddyChild = process.platform !== 'win32'
|
|
280
271
|
? spawn('sudo', ['-E', caddyPath, 'run', '--config', caddyFilePath, '--watch'])
|
|
281
272
|
: spawn(caddyPath, ['run', '--config', caddyFilePath, '--watch'])
|
|
282
273
|
|
|
283
274
|
lockfile.lockSync(caddyLockFilePath)
|
|
284
275
|
|
|
285
|
-
this.
|
|
276
|
+
this._caddyChild!.on('error', (err) => {
|
|
286
277
|
return reject(err)
|
|
287
278
|
})
|
|
288
279
|
|
|
289
|
-
this.
|
|
280
|
+
this._caddyChild!.stderr?.on('data', (data) => {
|
|
290
281
|
const lines = (data.toString() as string).split('\n').map(line => line.trim())
|
|
291
282
|
for (const line of lines) {
|
|
292
283
|
// caddy log
|
|
@@ -305,7 +296,7 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
305
296
|
}
|
|
306
297
|
})
|
|
307
298
|
|
|
308
|
-
this.
|
|
299
|
+
this._caddyChild!.stdout?.on('data', (_data) => {
|
|
309
300
|
consola.info(_data.toString())
|
|
310
301
|
resolve()
|
|
311
302
|
})
|
|
@@ -322,16 +313,29 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
322
313
|
})
|
|
323
314
|
}
|
|
324
315
|
|
|
325
|
-
async baseCleanup() {
|
|
326
|
-
|
|
327
|
-
this.
|
|
316
|
+
async baseCleanup(restore: boolean = true) {
|
|
317
|
+
try {
|
|
318
|
+
if (restore && this._source && this._target) {
|
|
319
|
+
if (await removeHost(this._source.split(':')[0], this._target.split(':')[0]))
|
|
320
|
+
consola.success('Restore host success.\n')
|
|
321
|
+
|
|
322
|
+
else
|
|
323
|
+
consola.fail('Restore host failed.\n')
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch (e) {
|
|
327
|
+
consola.error(e)
|
|
328
|
+
consola.fail('Restore host failed.\n')
|
|
329
|
+
}
|
|
330
|
+
if (!this.locked && !this.stoped) {
|
|
331
|
+
this._caddyChild?.kill()
|
|
328
332
|
try {
|
|
329
|
-
await lockfile.unlock(caddyLockFilePath)
|
|
330
|
-
await unlink(caddyFilePath)
|
|
331
|
-
await unlink(caddyLockFilePath)
|
|
333
|
+
await lockfile.unlock(caddyLockFilePath).catch(() => { })
|
|
334
|
+
await unlink(caddyFilePath).catch(() => { })
|
|
335
|
+
await unlink(caddyLockFilePath).catch(() => { })
|
|
332
336
|
}
|
|
333
337
|
catch (e) {
|
|
334
|
-
|
|
338
|
+
consola.error(e)
|
|
335
339
|
}
|
|
336
340
|
}
|
|
337
341
|
}
|