unplugin-https-reverse-proxy 1.0.0-beta.1 → 1.0.0-beta.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 +94 -1
- package/dist/{chunk-NNO3ZUSU.js → chunk-RUJE3YFB.js} +11 -0
- package/dist/{chunk-DUCXH7CX.js → chunk-XLSIGDFU.js} +121 -68
- package/dist/esbuild.cjs +141 -71
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +141 -71
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +86 -145
- package/dist/nuxt.js +24 -22
- package/dist/rollup.cjs +141 -71
- package/dist/rollup.js +2 -2
- 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/types.cjs +1 -1
- package/dist/utils.cjs +13 -1
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +3 -1
- package/dist/vite.cjs +141 -71
- package/dist/vite.d.cts +1 -2
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +7 -4
- package/dist/webpack.cjs +141 -71
- package/dist/webpack.js +7 -4
- package/package.json +42 -25
- package/scripts/postinstall.cjs +310 -0
- package/src/caddy/constants.ts +13 -1
- package/src/caddy/index.ts +32 -5
- package/src/index.ts +111 -79
- package/src/nuxt.ts +26 -19
- package/src/rspack.ts +5 -0
- package/src/utils.ts +11 -0
- package/dist/chunk-QIKJQBZH.js +0 -11
- package/dist/chunk-Y5ZVZOMP.js +0 -11
- package/scripts/postinstall.ts +0 -19
package/src/nuxt.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import vite from './vite'
|
|
4
|
-
import webpack from './webpack'
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { defineNuxtModule } from '@nuxt/kit'
|
|
5
3
|
import type { Options } from './types'
|
|
6
4
|
import '@nuxt/schema'
|
|
7
|
-
import { consola,
|
|
5
|
+
import { consola, isAdmin } from './utils'
|
|
8
6
|
import { vitePrintUrls } from '.'
|
|
9
7
|
|
|
10
8
|
export interface ModuleOptions extends Options {
|
|
@@ -17,26 +15,35 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
17
15
|
configKey: 'unpluginHttpsReverseProxy',
|
|
18
16
|
},
|
|
19
17
|
setup(options, _nuxt) {
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (process.env.NODE_ENV !== 'development')
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
enable = true,
|
|
23
|
+
target = '',
|
|
24
|
+
} = options
|
|
25
|
+
|
|
26
|
+
if (!enable)
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
if (!isAdmin()) {
|
|
30
|
+
consola.warn('please run as administrator')
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!target) {
|
|
35
|
+
consola.fail('please provide target')
|
|
36
|
+
return
|
|
37
|
+
}
|
|
22
38
|
|
|
23
39
|
// https://github.com/nuxt/cli/issues/220#issuecomment-1735394141
|
|
24
|
-
let url = ''
|
|
25
40
|
_nuxt.hook('listen', (_, listener) => {
|
|
26
|
-
url = listener.url
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
_nuxt.hook('vite:serverCreated', once((server: ViteDevServer) => {
|
|
41
|
+
const url = listener.url
|
|
30
42
|
const source = new URL(url).host
|
|
31
43
|
|
|
32
|
-
if (!options.target) {
|
|
33
|
-
consola.fail('please provide target')
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
44
|
const base = _nuxt.options.app.baseURL || '/'
|
|
38
45
|
|
|
39
|
-
vitePrintUrls(
|
|
40
|
-
})
|
|
46
|
+
vitePrintUrls(options, source, options.target, base)
|
|
47
|
+
})
|
|
41
48
|
},
|
|
42
49
|
})
|
package/src/rspack.ts
ADDED
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { chmod, readdir, stat } from 'node:fs/promises'
|
|
2
4
|
import { execSync } from 'node:child_process'
|
|
3
5
|
import { createConsola } from 'consola'
|
|
4
6
|
|
|
@@ -6,6 +8,15 @@ export const consola = createConsola({
|
|
|
6
8
|
level: 3,
|
|
7
9
|
}).withTag('reverse-proxy')
|
|
8
10
|
|
|
11
|
+
export async function chmodRecursive(_path: string, mode: number) {
|
|
12
|
+
await chmod(_path, mode)
|
|
13
|
+
if ((await stat(_path)).isDirectory()) {
|
|
14
|
+
const children = await readdir(_path)
|
|
15
|
+
for (const child of children)
|
|
16
|
+
await chmodRecursive(path.join(_path, child), mode)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
export function once<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T> {
|
|
10
21
|
let called = false
|
|
11
22
|
return (...args: any[]) => {
|
package/dist/chunk-QIKJQBZH.js
DELETED
package/dist/chunk-Y5ZVZOMP.js
DELETED
package/scripts/postinstall.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { existsSync, unlinkSync } from 'node:fs'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { consola } from '../src/utils'
|
|
4
|
-
import { download } from '../src/caddy'
|
|
5
|
-
import { caddyPath } from '../src/caddy/constants'
|
|
6
|
-
|
|
7
|
-
async function run() {
|
|
8
|
-
try {
|
|
9
|
-
if (process.env.UHRP_AUTO_INSTALL_CADDY) {
|
|
10
|
-
existsSync(caddyPath) && unlinkSync(caddyPath)
|
|
11
|
-
await download()
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch (e: any) {
|
|
15
|
-
consola.error(e.code)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
run()
|