pulumi-package-docs 0.3.0 → 0.5.0
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 +1 -0
- package/bin/cli.js +5 -2
- package/package.json +1 -1
- package/vite.config.ts +35 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ pulumi-package-docs [options]
|
|
|
16
16
|
-d, --dir <path> Pulumi project directory to inspect (default: current directory)
|
|
17
17
|
-p, --port <port> Port to serve on (default: 3000)
|
|
18
18
|
--host Expose the server on your network
|
|
19
|
+
--open Open the docs in your default browser once ready
|
|
19
20
|
-h, --help Show this help message
|
|
20
21
|
```
|
|
21
22
|
|
package/bin/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
|
9
9
|
const require = createRequire(import.meta.url)
|
|
10
10
|
|
|
11
11
|
function parseArgs(argv) {
|
|
12
|
-
const options = { dir: process.cwd(), port: '3000', host: false }
|
|
12
|
+
const options = { dir: process.cwd(), port: '3000', host: false, open: false }
|
|
13
13
|
for (let i = 0; i < argv.length; i++) {
|
|
14
14
|
const arg = argv[i]
|
|
15
15
|
if (arg === '--dir' || arg === '-d') {
|
|
@@ -18,6 +18,8 @@ function parseArgs(argv) {
|
|
|
18
18
|
options.port = argv[++i]
|
|
19
19
|
} else if (arg === '--host') {
|
|
20
20
|
options.host = true
|
|
21
|
+
} else if (arg === '--open') {
|
|
22
|
+
options.open = true
|
|
21
23
|
} else if (arg === '--help' || arg === '-h') {
|
|
22
24
|
options.help = true
|
|
23
25
|
}
|
|
@@ -35,6 +37,7 @@ Options:
|
|
|
35
37
|
-d, --dir <path> Pulumi project directory to inspect (default: current directory)
|
|
36
38
|
-p, --port <port> Port to serve on (default: 3000)
|
|
37
39
|
--host Expose the server on your network
|
|
40
|
+
--open Open the docs in your default browser once ready
|
|
38
41
|
-h, --help Show this help message
|
|
39
42
|
`)
|
|
40
43
|
}
|
|
@@ -58,6 +61,7 @@ const viteArgs = [
|
|
|
58
61
|
options.port,
|
|
59
62
|
]
|
|
60
63
|
if (options.host) viteArgs.push('--host')
|
|
64
|
+
if (options.open) viteArgs.push('--open')
|
|
61
65
|
|
|
62
66
|
if (!hasProductionBuild) {
|
|
63
67
|
console.log(
|
|
@@ -65,7 +69,6 @@ if (!hasProductionBuild) {
|
|
|
65
69
|
)
|
|
66
70
|
}
|
|
67
71
|
console.log(`Serving provider docs for: ${options.dir}`)
|
|
68
|
-
console.log(`MCP endpoint: http://localhost:${options.port}/mcp`)
|
|
69
72
|
|
|
70
73
|
const child = spawn(process.execPath, [viteBin, ...viteArgs], {
|
|
71
74
|
cwd: packageRoot,
|
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
|
+
import type { Plugin, PreviewServer, ViteDevServer } from 'vite'
|
|
2
3
|
|
|
3
4
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
|
|
4
5
|
|
|
5
6
|
import viteReact from '@vitejs/plugin-react'
|
|
6
7
|
|
|
8
|
+
// Matches the ANSI styling Vite's own CLI uses for its "Local"/"Network"
|
|
9
|
+
// bullets (picocolors' green/bold/cyan), so this reads as one more item in
|
|
10
|
+
// that same list rather than a separately-styled line.
|
|
11
|
+
const green = (s: string) => `\x1b[32m${s}\x1b[39m`
|
|
12
|
+
const bold = (s: string) => `\x1b[1m${s}\x1b[22m`
|
|
13
|
+
const cyan = (s: string) => `\x1b[36m${s}\x1b[39m`
|
|
14
|
+
const colorUrl = (url: string) =>
|
|
15
|
+
cyan(url.replace(/:(\d+)\//, (_, port) => `:${bold(port)}/`))
|
|
16
|
+
|
|
17
|
+
/** Prints the MCP endpoint alongside Vite's own "Local"/"Network" bullets. */
|
|
18
|
+
function printMcpUrl(): Plugin {
|
|
19
|
+
function withMcpUrl(server: ViteDevServer | PreviewServer) {
|
|
20
|
+
const printUrls = server.printUrls.bind(server)
|
|
21
|
+
server.printUrls = () => {
|
|
22
|
+
printUrls()
|
|
23
|
+
const base = server.resolvedUrls?.local[0]
|
|
24
|
+
if (!base) return
|
|
25
|
+
const url = new URL('mcp', base).toString()
|
|
26
|
+
// Padded to the same 9-column label width Vite uses ("Local: " /
|
|
27
|
+
// "Network: " are both 9 characters before the URL).
|
|
28
|
+
server.config.logger.info(
|
|
29
|
+
` ${green('➜')} ${bold('MCP')}: ${colorUrl(url)}`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: 'print-mcp-url',
|
|
36
|
+
configureServer: withMcpUrl,
|
|
37
|
+
configurePreviewServer: withMcpUrl,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
7
41
|
const config = defineConfig({
|
|
8
42
|
resolve: { tsconfigPaths: true },
|
|
9
|
-
plugins: [tanstackStart(), viteReact()],
|
|
43
|
+
plugins: [tanstackStart(), viteReact(), printMcpUrl()],
|
|
10
44
|
})
|
|
11
45
|
|
|
12
46
|
export default config
|