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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -0
  3. package/bin/cli.js +80 -0
  4. package/dist/client/assets/MemberDetail-CX9jiyic.js +1 -0
  5. package/dist/client/assets/index-CZRUHwIq.js +13 -0
  6. package/dist/client/assets/providers._name-DpU324kz.js +1 -0
  7. package/dist/client/assets/providers._name.functions._token-DXrP4mSE.js +1 -0
  8. package/dist/client/assets/providers._name.functions._token-bvc3vrG2.js +1 -0
  9. package/dist/client/assets/providers._name.index-CtKE1x7S.js +1 -0
  10. package/dist/client/assets/providers._name.index-tTXQzRr7.js +1 -0
  11. package/dist/client/assets/providers._name.resources._token--BZM8RBv.js +1 -0
  12. package/dist/client/assets/providers._name.resources._token-CbZkRkaE.js +1 -0
  13. package/dist/client/assets/routes-GAgiQcBX.js +1 -0
  14. package/dist/client/assets/styles-CWDprFhI.css +1 -0
  15. package/dist/client/assets/token-oQmZfAP3.js +1 -0
  16. package/dist/client/assets/useSelector-BIt42tGI.js +1 -0
  17. package/dist/server/assets/MemberDetail-BiBAI1vw.js +96 -0
  18. package/dist/server/assets/_tanstack-start-manifest_v-Cl1i6HDY.js +62 -0
  19. package/dist/server/assets/api-BV6lykkP.js +20 -0
  20. package/dist/server/assets/api-C55bS4R6.js +64 -0
  21. package/dist/server/assets/empty-plugin-adapters-D9UWiqvJ.js +5 -0
  22. package/dist/server/assets/providers._name-DF6sA3DG.js +6 -0
  23. package/dist/server/assets/providers._name.functions._token-C0A7Y90t.js +21 -0
  24. package/dist/server/assets/providers._name.functions._token-D8LsoIum.js +13 -0
  25. package/dist/server/assets/providers._name.index-BEwt-7U0.js +13 -0
  26. package/dist/server/assets/providers._name.index-BK_ZRd5l.js +97 -0
  27. package/dist/server/assets/providers._name.resources._token-CbvRkms4.js +22 -0
  28. package/dist/server/assets/providers._name.resources._token-DJPF8nMg.js +13 -0
  29. package/dist/server/assets/router-DZSocx9m.js +562 -0
  30. package/dist/server/assets/routes-B-G_iLTo.js +82 -0
  31. package/dist/server/assets/schema.server-B-VvU1qb.js +122 -0
  32. package/dist/server/assets/start-5Z2QO8AU.js +4 -0
  33. package/dist/server/server.js +2003 -0
  34. package/package.json +67 -0
  35. package/src/components/CodeExample.tsx +14 -0
  36. package/src/components/MemberDetail.tsx +89 -0
  37. package/src/components/PropertyTable.tsx +49 -0
  38. package/src/components/PulumiLogo.tsx +86 -0
  39. package/src/lib/pulumi/api.ts +77 -0
  40. package/src/lib/pulumi/description.test.ts +54 -0
  41. package/src/lib/pulumi/description.ts +35 -0
  42. package/src/lib/pulumi/discovery.server.test.ts +117 -0
  43. package/src/lib/pulumi/discovery.server.ts +77 -0
  44. package/src/lib/pulumi/examples.test.ts +97 -0
  45. package/src/lib/pulumi/examples.ts +55 -0
  46. package/src/lib/pulumi/format.test.ts +51 -0
  47. package/src/lib/pulumi/format.ts +11 -0
  48. package/src/lib/pulumi/mcp.server.ts +343 -0
  49. package/src/lib/pulumi/naming.test.ts +27 -0
  50. package/src/lib/pulumi/naming.ts +31 -0
  51. package/src/lib/pulumi/schema.server.ts +78 -0
  52. package/src/lib/pulumi/token.test.ts +21 -0
  53. package/src/lib/pulumi/token.ts +10 -0
  54. package/src/lib/pulumi/types.ts +62 -0
  55. package/src/routeTree.gen.ts +187 -0
  56. package/src/router.tsx +19 -0
  57. package/src/routes/__root.tsx +59 -0
  58. package/src/routes/index.tsx +78 -0
  59. package/src/routes/mcp.ts +30 -0
  60. package/src/routes/providers.$name.functions.$token.tsx +47 -0
  61. package/src/routes/providers.$name.index.tsx +129 -0
  62. package/src/routes/providers.$name.resources.$token.tsx +48 -0
  63. package/src/routes/providers.$name.tsx +5 -0
  64. package/src/styles.css +478 -0
  65. 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 };
@@ -0,0 +1,4 @@
1
+ //#region node_modules/@tanstack/react-start/dist/plugin/default-entry/start.ts
2
+ var startInstance = void 0;
3
+ //#endregion
4
+ export { startInstance };