unplugin-https-reverse-proxy 1.0.0-beta.7 → 1.0.0-beta.9
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 +85 -1
- package/dist/{chunk-IUFVJYJ5.js → chunk-ZSHTX2B6.js} +46 -9
- package/dist/esbuild.cjs +46 -9
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +46 -9
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +8 -6
- package/dist/nuxt.js +1 -1
- package/dist/rollup.cjs +46 -9
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +643 -0
- package/dist/rspack.d.cts +5 -0
- package/dist/rspack.d.ts +5 -0
- package/dist/rspack.js +10 -0
- package/dist/vite.cjs +46 -9
- package/dist/vite.d.cts +1 -2
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +46 -9
- package/dist/webpack.js +1 -1
- package/package.json +40 -24
- package/src/caddy/constants.ts +3 -1
- package/src/index.ts +48 -2
- package/src/rspack.ts +5 -0
package/dist/vite.cjs
CHANGED
|
@@ -155,7 +155,9 @@ var import_node_path2 = require("path");
|
|
|
155
155
|
var import_node_os = __toESM(require("os"), 1);
|
|
156
156
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
157
157
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
158
|
-
import_dotenv_flow.default.config(
|
|
158
|
+
import_dotenv_flow.default.config({
|
|
159
|
+
silent: true
|
|
160
|
+
});
|
|
159
161
|
function resolvePath(path2) {
|
|
160
162
|
if (path2.startsWith("~"))
|
|
161
163
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -454,14 +456,14 @@ var CaddyInstant = class {
|
|
|
454
456
|
const port = Number(source.split(":")[1]);
|
|
455
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
456
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
457
|
-
const
|
|
458
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
459
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
460
462
|
chmodRecursive(viteCacheDir, 511);
|
|
461
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
462
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
463
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
464
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
465
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
466
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
467
469
|
if (!restore || this.stoped)
|
|
@@ -502,7 +504,7 @@ var CaddyInstant = class {
|
|
|
502
504
|
// src/index.ts
|
|
503
505
|
var config;
|
|
504
506
|
var caddy;
|
|
505
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
506
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
507
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
508
510
|
if (caddy)
|
|
@@ -554,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
554
556
|
}
|
|
555
557
|
},
|
|
556
558
|
webpack(compiler) {
|
|
557
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
558
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
559
561
|
return;
|
|
560
562
|
if (!isAdmin()) {
|
|
@@ -574,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
574
576
|
const devServer = __spreadValues(__spreadValues({
|
|
575
577
|
host: "localhost",
|
|
576
578
|
port: 8080
|
|
577
|
-
}, compiler.options.devServer), import_node_process5.default.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
579
|
+
}, compiler.options.devServer), (_a = import_node_process5.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
578
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
579
581
|
if (caddy)
|
|
580
582
|
return;
|
|
581
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
582
584
|
if (_close) {
|
|
583
585
|
compiler.close = async (callback) => {
|
|
584
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -597,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
597
599
|
}).catch((e) => {
|
|
598
600
|
throw e;
|
|
599
601
|
});
|
|
602
|
+
},
|
|
603
|
+
async rspack(compiler) {
|
|
604
|
+
var _a, _b, _c;
|
|
605
|
+
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
606
|
+
return;
|
|
607
|
+
if (!isAdmin()) {
|
|
608
|
+
consola.warn("please run as administrator");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const {
|
|
612
|
+
enable = true,
|
|
613
|
+
target = ""
|
|
614
|
+
} = options;
|
|
615
|
+
if (!enable)
|
|
616
|
+
return;
|
|
617
|
+
if (!target) {
|
|
618
|
+
consola.fail("please provide target");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const devServer = __spreadValues(__spreadValues({
|
|
622
|
+
host: "localhost",
|
|
623
|
+
port: 8080
|
|
624
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
625
|
+
cwd
|
|
626
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
627
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
628
|
+
if (caddy)
|
|
629
|
+
return;
|
|
630
|
+
caddy = new CaddyInstant();
|
|
631
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
632
|
+
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
633
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
634
|
+
}).catch((e) => {
|
|
635
|
+
throw e;
|
|
636
|
+
});
|
|
600
637
|
}
|
|
601
638
|
});
|
|
602
639
|
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -155,7 +155,9 @@ var import_node_path2 = require("path");
|
|
|
155
155
|
var import_node_os = __toESM(require("os"), 1);
|
|
156
156
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
157
157
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
158
|
-
import_dotenv_flow.default.config(
|
|
158
|
+
import_dotenv_flow.default.config({
|
|
159
|
+
silent: true
|
|
160
|
+
});
|
|
159
161
|
function resolvePath(path2) {
|
|
160
162
|
if (path2.startsWith("~"))
|
|
161
163
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -454,14 +456,14 @@ var CaddyInstant = class {
|
|
|
454
456
|
const port = Number(source.split(":")[1]);
|
|
455
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
456
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
457
|
-
const
|
|
458
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
459
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
460
462
|
chmodRecursive(viteCacheDir, 511);
|
|
461
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
462
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
463
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
464
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
465
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
466
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
467
469
|
if (!restore || this.stoped)
|
|
@@ -502,7 +504,7 @@ var CaddyInstant = class {
|
|
|
502
504
|
// src/index.ts
|
|
503
505
|
var config;
|
|
504
506
|
var caddy;
|
|
505
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
506
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
507
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
508
510
|
if (caddy)
|
|
@@ -554,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
554
556
|
}
|
|
555
557
|
},
|
|
556
558
|
webpack(compiler) {
|
|
557
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
558
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
559
561
|
return;
|
|
560
562
|
if (!isAdmin()) {
|
|
@@ -574,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
574
576
|
const devServer = __spreadValues(__spreadValues({
|
|
575
577
|
host: "localhost",
|
|
576
578
|
port: 8080
|
|
577
|
-
}, compiler.options.devServer), import_node_process5.default.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
579
|
+
}, compiler.options.devServer), (_a = import_node_process5.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
578
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
579
581
|
if (caddy)
|
|
580
582
|
return;
|
|
581
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
582
584
|
if (_close) {
|
|
583
585
|
compiler.close = async (callback) => {
|
|
584
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -597,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
597
599
|
}).catch((e) => {
|
|
598
600
|
throw e;
|
|
599
601
|
});
|
|
602
|
+
},
|
|
603
|
+
async rspack(compiler) {
|
|
604
|
+
var _a, _b, _c;
|
|
605
|
+
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
606
|
+
return;
|
|
607
|
+
if (!isAdmin()) {
|
|
608
|
+
consola.warn("please run as administrator");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const {
|
|
612
|
+
enable = true,
|
|
613
|
+
target = ""
|
|
614
|
+
} = options;
|
|
615
|
+
if (!enable)
|
|
616
|
+
return;
|
|
617
|
+
if (!target) {
|
|
618
|
+
consola.fail("please provide target");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const devServer = __spreadValues(__spreadValues({
|
|
622
|
+
host: "localhost",
|
|
623
|
+
port: 8080
|
|
624
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
625
|
+
cwd
|
|
626
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
627
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
628
|
+
if (caddy)
|
|
629
|
+
return;
|
|
630
|
+
caddy = new CaddyInstant();
|
|
631
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
632
|
+
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
633
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
634
|
+
}).catch((e) => {
|
|
635
|
+
throw e;
|
|
636
|
+
});
|
|
600
637
|
}
|
|
601
638
|
});
|
|
602
639
|
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-https-reverse-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "1.0.0-beta.9",
|
|
5
|
+
"packageManager": "pnpm@8.15.3",
|
|
6
6
|
"description": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"import": "./dist/webpack.js",
|
|
37
37
|
"require": "./dist/webpack.cjs"
|
|
38
38
|
},
|
|
39
|
+
"./rspack": {
|
|
40
|
+
"types": "./dist/rspack.d.ts",
|
|
41
|
+
"import": "./dist/rspack.js",
|
|
42
|
+
"require": "./dist/rspack.cjs"
|
|
43
|
+
},
|
|
39
44
|
"./rollup": {
|
|
40
45
|
"types": "./dist/rollup.d.ts",
|
|
41
46
|
"import": "./dist/rollup.js",
|
|
@@ -77,6 +82,8 @@
|
|
|
77
82
|
"peerDependencies": {
|
|
78
83
|
"@nuxt/kit": "^3",
|
|
79
84
|
"@nuxt/schema": "^3",
|
|
85
|
+
"@rsbuild/core": "^0.4.3",
|
|
86
|
+
"@rspack/core": "^0.5.4",
|
|
80
87
|
"esbuild": "*",
|
|
81
88
|
"rollup": "^3",
|
|
82
89
|
"vite": ">=3",
|
|
@@ -86,6 +93,12 @@
|
|
|
86
93
|
"webpack": {
|
|
87
94
|
"optional": true
|
|
88
95
|
},
|
|
96
|
+
"@rspack/core": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@rsbuild/core": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
89
102
|
"rollup": {
|
|
90
103
|
"optional": true
|
|
91
104
|
},
|
|
@@ -105,48 +118,51 @@
|
|
|
105
118
|
"dependencies": {
|
|
106
119
|
"consola": "^3.2.3",
|
|
107
120
|
"dotenv-flow": "^4.1.0",
|
|
108
|
-
"esno": "^0.17.0",
|
|
109
121
|
"got-cjs": "^12.5.4",
|
|
110
122
|
"hosts-so-easy": "^1.2.9",
|
|
111
|
-
"http-proxy-agent": "^7.0.
|
|
112
|
-
"https-proxy-agent": "^7.0.
|
|
123
|
+
"http-proxy-agent": "^7.0.2",
|
|
124
|
+
"https-proxy-agent": "^7.0.4",
|
|
113
125
|
"kill-port": "^2.0.1",
|
|
114
126
|
"ora": "5",
|
|
115
127
|
"picocolors": "^1.0.0",
|
|
116
|
-
"
|
|
128
|
+
"tsx": "^4.7.1",
|
|
129
|
+
"unplugin": "^1.7.1"
|
|
117
130
|
},
|
|
118
131
|
"devDependencies": {
|
|
119
|
-
"@antfu/eslint-config": "^0.40.
|
|
120
|
-
"@nuxt/kit": "^3.
|
|
121
|
-
"@nuxt/schema": "^3.
|
|
132
|
+
"@antfu/eslint-config": "^0.40.3",
|
|
133
|
+
"@nuxt/kit": "^3.10.2",
|
|
134
|
+
"@nuxt/schema": "^3.10.2",
|
|
135
|
+
"@rsbuild/core": "^0.4.3",
|
|
136
|
+
"@rspack/core": "^0.5.4",
|
|
122
137
|
"@types/kill-port": "^2.0.3",
|
|
123
|
-
"@types/node": "^20.
|
|
138
|
+
"@types/node": "^20.11.19",
|
|
124
139
|
"@vue/cli": "^5.0.8",
|
|
125
|
-
"bumpp": "^9.
|
|
140
|
+
"bumpp": "^9.3.0",
|
|
126
141
|
"chalk": "^5.3.0",
|
|
127
|
-
"eslint": "^8.
|
|
128
|
-
"fast-glob": "^3.3.
|
|
129
|
-
"nodemon": "^3.0.
|
|
130
|
-
"rimraf": "^5.0.
|
|
131
|
-
"rollup": "^3.
|
|
132
|
-
"tsup": "^7.
|
|
133
|
-
"typescript": "^5.
|
|
134
|
-
"vite": "^4.
|
|
135
|
-
"vitest": "^0.34.
|
|
136
|
-
"webpack": "^5.
|
|
142
|
+
"eslint": "^8.56.0",
|
|
143
|
+
"fast-glob": "^3.3.2",
|
|
144
|
+
"nodemon": "^3.0.3",
|
|
145
|
+
"rimraf": "^5.0.5",
|
|
146
|
+
"rollup": "^3.29.4",
|
|
147
|
+
"tsup": "^7.3.0",
|
|
148
|
+
"typescript": "^5.3.3",
|
|
149
|
+
"vite": "^4.5.2",
|
|
150
|
+
"vitest": "^0.34.6",
|
|
151
|
+
"webpack": "^5.90.3"
|
|
137
152
|
},
|
|
138
153
|
"scripts": {
|
|
139
|
-
"postinstall": "
|
|
154
|
+
"postinstall": "tsx scripts/postinstall.ts",
|
|
140
155
|
"build": "tsup",
|
|
141
156
|
"dev": "tsup --watch src",
|
|
142
|
-
"build:fix": "
|
|
157
|
+
"build:fix": "tsx scripts/postbuild.ts",
|
|
143
158
|
"lint": "eslint .",
|
|
144
159
|
"play": "npm -C examples/vite run dev",
|
|
160
|
+
"play:rsbuild": "npm -C examples/rsbuild run dev",
|
|
145
161
|
"play:nuxt": "npm -C examples/nuxt run dev",
|
|
146
162
|
"play:vuecli": "npm -C examples/vuecli run serve",
|
|
147
163
|
"play:vuecli4": "npm -C examples/vuecli4 run serve",
|
|
148
164
|
"release": "bumpp",
|
|
149
|
-
"start": "
|
|
165
|
+
"start": "tsx src/index.ts",
|
|
150
166
|
"test": "vitest"
|
|
151
167
|
}
|
|
152
168
|
}
|
package/src/caddy/constants.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ let config: ResolvedConfig
|
|
|
11
11
|
|
|
12
12
|
let caddy: CaddyInstant
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const cwd = process.cwd()
|
|
15
15
|
|
|
16
16
|
export const vitePrintUrls = once((
|
|
17
17
|
options: Options,
|
|
@@ -102,7 +102,7 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
102
102
|
port: 8080,
|
|
103
103
|
...compiler.options.devServer,
|
|
104
104
|
// @ts-expect-error vuecli
|
|
105
|
-
...process.VUE_CLI_SERVICE
|
|
105
|
+
...(process.VUE_CLI_SERVICE?.projectOptions.devServer),
|
|
106
106
|
}
|
|
107
107
|
const source = `${devServer.host}:${devServer.port}`
|
|
108
108
|
|
|
@@ -137,6 +137,52 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
137
137
|
throw e
|
|
138
138
|
})
|
|
139
139
|
},
|
|
140
|
+
async rspack(compiler) {
|
|
141
|
+
if (process.env.NODE_ENV !== 'development')
|
|
142
|
+
return
|
|
143
|
+
|
|
144
|
+
if (!isAdmin()) {
|
|
145
|
+
consola.warn('please run as administrator')
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const {
|
|
150
|
+
enable = true,
|
|
151
|
+
target = '',
|
|
152
|
+
} = options
|
|
153
|
+
if (!enable)
|
|
154
|
+
return
|
|
155
|
+
if (!target) {
|
|
156
|
+
consola.fail('please provide target')
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const devServer = {
|
|
161
|
+
host: 'localhost',
|
|
162
|
+
port: 8080,
|
|
163
|
+
...compiler.options.devServer,
|
|
164
|
+
...(await (await import('@rsbuild/core'))?.loadConfig({
|
|
165
|
+
cwd,
|
|
166
|
+
}))?.content?.server,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const source = `${devServer.host}:${devServer.port}`
|
|
170
|
+
|
|
171
|
+
if (caddy)
|
|
172
|
+
return
|
|
173
|
+
|
|
174
|
+
caddy = new CaddyInstant()
|
|
175
|
+
|
|
176
|
+
caddy.run(source, target, {
|
|
177
|
+
...options,
|
|
178
|
+
}).then(() => {
|
|
179
|
+
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
180
|
+
|
|
181
|
+
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`${options.https ? 'https' : 'http'}://${target}`)}`)
|
|
182
|
+
}).catch((e) => {
|
|
183
|
+
throw e
|
|
184
|
+
})
|
|
185
|
+
},
|
|
140
186
|
})
|
|
141
187
|
|
|
142
188
|
export const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)
|