pulumi-package-docs 0.1.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/LICENSE +21 -0
- package/README.md +60 -0
- package/bin/cli.js +80 -0
- package/dist/client/assets/MemberDetail-CX9jiyic.js +1 -0
- package/dist/client/assets/index-CZRUHwIq.js +13 -0
- package/dist/client/assets/providers._name-DpU324kz.js +1 -0
- package/dist/client/assets/providers._name.functions._token-DXrP4mSE.js +1 -0
- package/dist/client/assets/providers._name.functions._token-bvc3vrG2.js +1 -0
- package/dist/client/assets/providers._name.index-CtKE1x7S.js +1 -0
- package/dist/client/assets/providers._name.index-tTXQzRr7.js +1 -0
- package/dist/client/assets/providers._name.resources._token--BZM8RBv.js +1 -0
- package/dist/client/assets/providers._name.resources._token-CbZkRkaE.js +1 -0
- package/dist/client/assets/routes-GAgiQcBX.js +1 -0
- package/dist/client/assets/styles-CWDprFhI.css +1 -0
- package/dist/client/assets/token-oQmZfAP3.js +1 -0
- package/dist/client/assets/useSelector-BIt42tGI.js +1 -0
- package/dist/server/assets/MemberDetail-BiBAI1vw.js +96 -0
- package/dist/server/assets/_tanstack-start-manifest_v-Cl1i6HDY.js +62 -0
- package/dist/server/assets/api-BV6lykkP.js +20 -0
- package/dist/server/assets/api-C55bS4R6.js +64 -0
- package/dist/server/assets/empty-plugin-adapters-D9UWiqvJ.js +5 -0
- package/dist/server/assets/providers._name-DF6sA3DG.js +6 -0
- package/dist/server/assets/providers._name.functions._token-C0A7Y90t.js +21 -0
- package/dist/server/assets/providers._name.functions._token-D8LsoIum.js +13 -0
- package/dist/server/assets/providers._name.index-BEwt-7U0.js +13 -0
- package/dist/server/assets/providers._name.index-BK_ZRd5l.js +97 -0
- package/dist/server/assets/providers._name.resources._token-CbvRkms4.js +22 -0
- package/dist/server/assets/providers._name.resources._token-DJPF8nMg.js +13 -0
- package/dist/server/assets/router-DZSocx9m.js +562 -0
- package/dist/server/assets/routes-B-G_iLTo.js +82 -0
- package/dist/server/assets/schema.server-B-VvU1qb.js +122 -0
- package/dist/server/assets/start-5Z2QO8AU.js +4 -0
- package/dist/server/server.js +2003 -0
- package/package.json +67 -0
- package/src/components/CodeExample.tsx +14 -0
- package/src/components/MemberDetail.tsx +89 -0
- package/src/components/PropertyTable.tsx +49 -0
- package/src/components/PulumiLogo.tsx +86 -0
- package/src/lib/pulumi/api.ts +77 -0
- package/src/lib/pulumi/description.test.ts +54 -0
- package/src/lib/pulumi/description.ts +35 -0
- package/src/lib/pulumi/discovery.server.test.ts +117 -0
- package/src/lib/pulumi/discovery.server.ts +77 -0
- package/src/lib/pulumi/examples.test.ts +97 -0
- package/src/lib/pulumi/examples.ts +55 -0
- package/src/lib/pulumi/format.test.ts +51 -0
- package/src/lib/pulumi/format.ts +11 -0
- package/src/lib/pulumi/mcp.server.ts +343 -0
- package/src/lib/pulumi/naming.test.ts +27 -0
- package/src/lib/pulumi/naming.ts +31 -0
- package/src/lib/pulumi/schema.server.ts +78 -0
- package/src/lib/pulumi/token.test.ts +21 -0
- package/src/lib/pulumi/token.ts +10 -0
- package/src/lib/pulumi/types.ts +62 -0
- package/src/routeTree.gen.ts +187 -0
- package/src/router.tsx +19 -0
- package/src/routes/__root.tsx +59 -0
- package/src/routes/index.tsx +78 -0
- package/src/routes/mcp.ts +30 -0
- package/src/routes/providers.$name.functions.$token.tsx +47 -0
- package/src/routes/providers.$name.index.tsx +129 -0
- package/src/routes/providers.$name.resources.$token.tsx +48 -0
- package/src/routes/providers.$name.tsx +5 -0
- package/src/styles.css +478 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
//#region src/lib/pulumi/discovery.server.ts
|
|
9
|
+
var PROJECT_FILE_NAMES = ["Pulumi.yaml", "Pulumi.yml"];
|
|
10
|
+
/**
|
|
11
|
+
* The directory of the Pulumi program to inspect. `bin/cli.js` sets this to the
|
|
12
|
+
* directory the user ran `npx pulumi-package-docs` from, since the dev/preview
|
|
13
|
+
* server itself runs with this package's own directory as its cwd.
|
|
14
|
+
*/
|
|
15
|
+
function getTargetDir() {
|
|
16
|
+
return process.env.PULUMI_LOCAL_DOCS_DIR || process.cwd();
|
|
17
|
+
}
|
|
18
|
+
function findProjectFile(startDir) {
|
|
19
|
+
let dir = startDir;
|
|
20
|
+
for (;;) {
|
|
21
|
+
for (const fileName of PROJECT_FILE_NAMES) {
|
|
22
|
+
const candidate = join(dir, fileName);
|
|
23
|
+
if (existsSync(candidate)) return candidate;
|
|
24
|
+
}
|
|
25
|
+
const parent = dirname(dir);
|
|
26
|
+
if (parent === dir) return null;
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function toLocalPackageRefs(packages) {
|
|
31
|
+
if (!packages || typeof packages !== "object") return [];
|
|
32
|
+
return Object.entries(packages).map(([name, value]) => {
|
|
33
|
+
const entry = value ?? {};
|
|
34
|
+
const parameters = Array.isArray(entry.parameters) ? entry.parameters.filter((p) => typeof p === "string") : void 0;
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
source: typeof entry.source === "string" ? entry.source : name,
|
|
38
|
+
version: typeof entry.version === "string" ? entry.version : void 0,
|
|
39
|
+
parameters
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Walks up from `startDir` looking for a Pulumi.yaml/Pulumi.yml, then reads its
|
|
45
|
+
* `packages` section to find the local/parameterized providers used by the project.
|
|
46
|
+
*/
|
|
47
|
+
function loadPulumiProject(startDir = getTargetDir()) {
|
|
48
|
+
const projectFile = findProjectFile(startDir);
|
|
49
|
+
if (!projectFile) return null;
|
|
50
|
+
const raw = readFileSync(projectFile, "utf-8");
|
|
51
|
+
const doc = parse(raw);
|
|
52
|
+
return {
|
|
53
|
+
root: dirname(projectFile),
|
|
54
|
+
name: typeof doc?.name === "string" ? doc.name : void 0,
|
|
55
|
+
runtime: typeof doc?.runtime === "string" ? doc.runtime : typeof (doc?.runtime)?.name === "string" ? doc.runtime.name : void 0,
|
|
56
|
+
packages: toLocalPackageRefs(doc?.packages)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/lib/pulumi/schema.server.ts
|
|
61
|
+
var execFileAsync = promisify(execFile);
|
|
62
|
+
var CLI_TIMEOUT_MS = 6e4;
|
|
63
|
+
var MAX_BUFFER_BYTES = 67108864;
|
|
64
|
+
function cacheFilePath(projectRoot, ref) {
|
|
65
|
+
const projectHash = createHash("sha256").update(projectRoot).digest("hex").slice(0, 16);
|
|
66
|
+
const dir = join(tmpdir(), "pulumi-package-docs", projectHash);
|
|
67
|
+
mkdirSync(dir, { recursive: true });
|
|
68
|
+
return join(dir, `${ref.name}.json`);
|
|
69
|
+
}
|
|
70
|
+
function readCache(path) {
|
|
71
|
+
if (!existsSync(path)) return null;
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function fetchViaCli(projectRoot, ref) {
|
|
79
|
+
const { stdout } = await execFileAsync("pulumi", [
|
|
80
|
+
"package",
|
|
81
|
+
"get-schema",
|
|
82
|
+
ref.source,
|
|
83
|
+
...ref.parameters ?? []
|
|
84
|
+
], {
|
|
85
|
+
cwd: projectRoot,
|
|
86
|
+
timeout: CLI_TIMEOUT_MS,
|
|
87
|
+
maxBuffer: MAX_BUFFER_BYTES
|
|
88
|
+
});
|
|
89
|
+
return JSON.parse(stdout);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Resolves the schema for a local package: try the `pulumi` CLI first (it's the
|
|
93
|
+
* source of truth and works for parameterized providers), and fall back to the
|
|
94
|
+
* last schema we successfully cached for this project if the CLI call fails.
|
|
95
|
+
*/
|
|
96
|
+
async function resolveProviderSchema(projectRoot, ref) {
|
|
97
|
+
const cachePath = cacheFilePath(projectRoot, ref);
|
|
98
|
+
try {
|
|
99
|
+
const schema = await fetchViaCli(projectRoot, ref);
|
|
100
|
+
writeFileSync(cachePath, JSON.stringify(schema));
|
|
101
|
+
return {
|
|
102
|
+
ref,
|
|
103
|
+
schema,
|
|
104
|
+
origin: "cli"
|
|
105
|
+
};
|
|
106
|
+
} catch (cliError) {
|
|
107
|
+
const cached = readCache(cachePath);
|
|
108
|
+
if (cached) return {
|
|
109
|
+
ref,
|
|
110
|
+
schema: cached,
|
|
111
|
+
origin: "cache"
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
ref,
|
|
115
|
+
schema: null,
|
|
116
|
+
origin: "error",
|
|
117
|
+
error: cliError instanceof Error ? cliError.message : String(cliError)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { getTargetDir as n, loadPulumiProject as r, resolveProviderSchema as t };
|