unplugin-https-reverse-proxy 1.0.0-beta.14 → 1.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2VGRJ3QS.js +45 -0
- package/dist/chunk-QMYDD3HL.js +651 -0
- package/dist/esbuild.cjs +41 -1667
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +41 -1667
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +22 -1657
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +41 -1667
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +41 -1667
- package/dist/rspack.js +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/vite.cjs +41 -1667
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +41 -1667
- package/dist/webpack.js +2 -2
- package/package.json +4 -3
- package/scripts/postinstall.cjs +1 -0
- package/src/caddy/index.ts +20 -28
- package/dist/chunk-SD5AGUG6.js +0 -2261
- package/dist/chunk-UGWFCSQS.js +0 -80
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-https-reverse-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.16",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"@rsbuild/core": "^0.4.3",
|
|
85
85
|
"@rspack/core": "^0.5.4",
|
|
86
86
|
"esbuild": "*",
|
|
87
|
+
"proper-lockfile": "^4.1.2",
|
|
87
88
|
"rollup": "^3",
|
|
88
89
|
"vite": ">=3",
|
|
89
90
|
"webpack": "^4 || ^5"
|
|
@@ -148,7 +149,7 @@
|
|
|
148
149
|
"tsup": "^7.3.0",
|
|
149
150
|
"typescript": "^5.3.3",
|
|
150
151
|
"vite": "^4.5.2",
|
|
151
|
-
"vitest": "^0.
|
|
152
|
+
"vitest": "^2.0.5",
|
|
152
153
|
"webpack": "^5.90.3"
|
|
153
154
|
},
|
|
154
155
|
"scripts": {
|
|
@@ -164,6 +165,6 @@
|
|
|
164
165
|
"play:vuecli4": "npm -C examples/vuecli4 run serve",
|
|
165
166
|
"release": "bumpp",
|
|
166
167
|
"start": "tsx src/index.ts",
|
|
167
|
-
"test": "vitest"
|
|
168
|
+
"test": "UHRP_CADDY_PATH='./test/.uhrp' vitest"
|
|
168
169
|
}
|
|
169
170
|
}
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -55,6 +55,7 @@ var import_got_cjs = require("got-cjs");
|
|
|
55
55
|
var import_http_proxy_agent = require("http-proxy-agent");
|
|
56
56
|
var import_https_proxy_agent = require("https-proxy-agent");
|
|
57
57
|
var import_kill_port = __toESM(require("kill-port"), 1);
|
|
58
|
+
var lockfile = __toESM(require("proper-lockfile"), 1);
|
|
58
59
|
|
|
59
60
|
// src/host/index.ts
|
|
60
61
|
var import_node_process2 = __toESM(require("process"), 1);
|
package/src/caddy/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { got } from 'got-cjs'
|
|
|
7
7
|
import { HttpProxyAgent } from 'http-proxy-agent'
|
|
8
8
|
import { HttpsProxyAgent } from 'https-proxy-agent'
|
|
9
9
|
import kill from 'kill-port'
|
|
10
|
+
import * as lockfile from 'proper-lockfile'
|
|
10
11
|
import { chmodRecursive, consola, once } from '../utils'
|
|
11
12
|
import { addHost, removeHost } from '../host'
|
|
12
13
|
import { TEMP_DIR, caddyFilePath, caddyLockFilePath, caddyPath, supportList } from './constants'
|
|
@@ -108,8 +109,6 @@ export class CaddyInstant {
|
|
|
108
109
|
private locked = false
|
|
109
110
|
private caddyfile: string | undefined
|
|
110
111
|
|
|
111
|
-
private lockfile: typeof import('proper-lockfile')
|
|
112
|
-
|
|
113
112
|
constructor() {
|
|
114
113
|
testCaddy().then(async () => {
|
|
115
114
|
await this.getCaddyfile()
|
|
@@ -117,16 +116,13 @@ export class CaddyInstant {
|
|
|
117
116
|
this.inited = true
|
|
118
117
|
})
|
|
119
118
|
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
121
|
-
this.lockfile = require('proper-lockfile')
|
|
122
|
-
|
|
123
119
|
this.locked = this.checkLock()
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
checkLock() {
|
|
127
123
|
if (!existsSync(caddyLockFilePath))
|
|
128
124
|
writeFileSync(caddyLockFilePath, '')
|
|
129
|
-
return
|
|
125
|
+
return lockfile.checkSync(caddyLockFilePath)
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
async getCaddyfile() {
|
|
@@ -134,6 +130,7 @@ export class CaddyInstant {
|
|
|
134
130
|
await this.initCaddyfile()
|
|
135
131
|
|
|
136
132
|
this.caddyfile = await readFile(caddyFilePath, 'utf-8')
|
|
133
|
+
return this.caddyfile
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
async initCaddyfile() {
|
|
@@ -199,7 +196,7 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
199
196
|
writeFileSync(caddyLockFilePath, '')
|
|
200
197
|
|
|
201
198
|
if (!this.locked) {
|
|
202
|
-
if (
|
|
199
|
+
if (await tryPort(443))
|
|
203
200
|
await kill(443, 'tcp')
|
|
204
201
|
if ((process.platform === 'win32' || !https) && await tryPort(80))
|
|
205
202
|
await kill(80, 'tcp')
|
|
@@ -211,16 +208,7 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
211
208
|
if (!restore || this.stoped)
|
|
212
209
|
return
|
|
213
210
|
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
await this.lockfile.unlock(caddyLockFilePath)
|
|
217
|
-
await unlink(caddyFilePath)
|
|
218
|
-
await unlink(caddyLockFilePath)
|
|
219
|
-
}
|
|
220
|
-
catch (e) {
|
|
221
|
-
// consola.error(e)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
211
|
+
await this.baseCleanup()
|
|
224
212
|
|
|
225
213
|
try {
|
|
226
214
|
if (await removeHost(source.split(':')[0], target.split(':')[0]))
|
|
@@ -264,16 +252,7 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
264
252
|
if (!restore || this.stoped)
|
|
265
253
|
return originalExit(code)
|
|
266
254
|
|
|
267
|
-
|
|
268
|
-
try {
|
|
269
|
-
await this.lockfile.unlock(caddyLockFilePath)
|
|
270
|
-
await unlink(caddyFilePath)
|
|
271
|
-
await unlink(caddyLockFilePath)
|
|
272
|
-
}
|
|
273
|
-
catch (e) {
|
|
274
|
-
// consola.error(e)
|
|
275
|
-
}
|
|
276
|
-
}
|
|
255
|
+
await this.baseCleanup()
|
|
277
256
|
|
|
278
257
|
try {
|
|
279
258
|
if (await removeHost(source.split(':')[0], target.split(':')[0]))
|
|
@@ -300,7 +279,7 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
300
279
|
? spawn('sudo', ['-E', caddyPath, 'run', '--config', caddyFilePath, '--watch'])
|
|
301
280
|
: spawn(caddyPath, ['run', '--config', caddyFilePath, '--watch'])
|
|
302
281
|
|
|
303
|
-
|
|
282
|
+
lockfile.lockSync(caddyLockFilePath)
|
|
304
283
|
|
|
305
284
|
child.on('error', (err) => {
|
|
306
285
|
return reject(err)
|
|
@@ -341,4 +320,17 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
|
|
|
341
320
|
}
|
|
342
321
|
})
|
|
343
322
|
}
|
|
323
|
+
|
|
324
|
+
async baseCleanup() {
|
|
325
|
+
if (!this.locked) {
|
|
326
|
+
try {
|
|
327
|
+
await lockfile.unlock(caddyLockFilePath)
|
|
328
|
+
await unlink(caddyFilePath)
|
|
329
|
+
await unlink(caddyLockFilePath)
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
// consola.error(e)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
344
336
|
}
|