polen 0.10.0-next.3 → 0.10.0-next.4

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 (268) hide show
  1. package/README.md +49 -376
  2. package/build/api/api.d.ts +1 -0
  3. package/build/api/api.d.ts.map +1 -1
  4. package/build/api/api.js +1 -0
  5. package/build/api/api.js.map +1 -1
  6. package/build/api/static/index.d.ts +2 -0
  7. package/build/api/static/index.d.ts.map +1 -0
  8. package/build/api/static/index.js +2 -0
  9. package/build/api/static/index.js.map +1 -0
  10. package/build/api/static/manifest.d.ts +18 -0
  11. package/build/api/static/manifest.d.ts.map +1 -0
  12. package/build/api/static/manifest.js +13 -0
  13. package/build/api/static/manifest.js.map +1 -0
  14. package/build/api/static/rebase.d.ts +14 -0
  15. package/build/api/static/rebase.d.ts.map +1 -0
  16. package/build/api/static/rebase.js +110 -0
  17. package/build/api/static/rebase.js.map +1 -0
  18. package/build/api/static/static.d.ts +3 -0
  19. package/build/api/static/static.d.ts.map +1 -0
  20. package/build/api/static/static.js +3 -0
  21. package/build/api/static/static.js.map +1 -0
  22. package/build/api/vite/plugins/build.d.ts.map +1 -1
  23. package/build/api/vite/plugins/build.js +22 -1
  24. package/build/api/vite/plugins/build.js.map +1 -1
  25. package/build/cli/commands/static/$default.d.ts +3 -0
  26. package/build/cli/commands/static/$default.d.ts.map +1 -0
  27. package/build/cli/commands/static/$default.js +38 -0
  28. package/build/cli/commands/static/$default.js.map +1 -0
  29. package/build/cli/commands/static/rebase.d.ts +2 -0
  30. package/build/cli/commands/static/rebase.d.ts.map +1 -0
  31. package/build/cli/commands/static/rebase.js +26 -0
  32. package/build/cli/commands/static/rebase.js.map +1 -0
  33. package/build/cli/commands/static.d.ts +3 -0
  34. package/build/cli/commands/static.d.ts.map +1 -0
  35. package/build/cli/commands/static.js +5 -0
  36. package/build/cli/commands/static.js.map +1 -0
  37. package/build/lib/demos/builder.d.ts +83 -0
  38. package/build/lib/demos/builder.d.ts.map +1 -0
  39. package/build/lib/demos/builder.js +237 -0
  40. package/build/lib/demos/builder.js.map +1 -0
  41. package/build/lib/demos/config-schema.d.ts +243 -0
  42. package/build/lib/demos/config-schema.d.ts.map +1 -0
  43. package/build/lib/demos/config-schema.js +52 -0
  44. package/build/lib/demos/config-schema.js.map +1 -0
  45. package/build/lib/demos/config.d.ts +40 -0
  46. package/build/lib/demos/config.d.ts.map +1 -0
  47. package/build/lib/demos/config.js +180 -0
  48. package/build/lib/demos/config.js.map +1 -0
  49. package/build/lib/demos/index.d.ts +9 -0
  50. package/build/lib/demos/index.d.ts.map +1 -0
  51. package/build/lib/demos/index.js +8 -0
  52. package/build/lib/demos/index.js.map +1 -0
  53. package/build/lib/demos/ui/components.d.ts +33 -0
  54. package/build/lib/demos/ui/components.d.ts.map +1 -0
  55. package/build/lib/demos/ui/components.js +699 -0
  56. package/build/lib/demos/ui/components.js.map +1 -0
  57. package/build/lib/demos/ui/data-collector.d.ts +88 -0
  58. package/build/lib/demos/ui/data-collector.d.ts.map +1 -0
  59. package/build/lib/demos/ui/data-collector.js +174 -0
  60. package/build/lib/demos/ui/data-collector.js.map +1 -0
  61. package/build/lib/demos/ui/landing-page-cli.d.ts +3 -0
  62. package/build/lib/demos/ui/landing-page-cli.d.ts.map +1 -0
  63. package/build/lib/demos/ui/landing-page-cli.js +21 -0
  64. package/build/lib/demos/ui/landing-page-cli.js.map +1 -0
  65. package/build/lib/demos/ui/landing-page.d.ts +32 -0
  66. package/build/lib/demos/ui/landing-page.d.ts.map +1 -0
  67. package/build/lib/demos/ui/landing-page.js +83 -0
  68. package/build/lib/demos/ui/landing-page.js.map +1 -0
  69. package/build/lib/demos/ui/page-renderer.d.ts +26 -0
  70. package/build/lib/demos/ui/page-renderer.d.ts.map +1 -0
  71. package/build/lib/demos/ui/page-renderer.js +104 -0
  72. package/build/lib/demos/ui/page-renderer.js.map +1 -0
  73. package/build/lib/demos/utils.d.ts +14 -0
  74. package/build/lib/demos/utils.d.ts.map +1 -0
  75. package/build/lib/demos/utils.js +37 -0
  76. package/build/lib/demos/utils.js.map +1 -0
  77. package/build/lib/deployment/$$.d.ts +3 -0
  78. package/build/lib/deployment/$$.d.ts.map +1 -0
  79. package/build/lib/deployment/$$.js +3 -0
  80. package/build/lib/deployment/$$.js.map +1 -0
  81. package/build/lib/deployment/$.d.ts +2 -0
  82. package/build/lib/deployment/$.d.ts.map +1 -0
  83. package/build/lib/deployment/$.js +2 -0
  84. package/build/lib/deployment/$.js.map +1 -0
  85. package/build/lib/deployment/metadata.d.ts +32 -0
  86. package/build/lib/deployment/metadata.d.ts.map +1 -0
  87. package/build/lib/deployment/metadata.js +37 -0
  88. package/build/lib/deployment/metadata.js.map +1 -0
  89. package/build/lib/deployment/path-manager.d.ts +41 -0
  90. package/build/lib/deployment/path-manager.d.ts.map +1 -0
  91. package/build/lib/deployment/path-manager.js +157 -0
  92. package/build/lib/deployment/path-manager.js.map +1 -0
  93. package/build/lib/github-actions/git-controller.d.ts +50 -0
  94. package/build/lib/github-actions/git-controller.d.ts.map +1 -0
  95. package/build/lib/github-actions/git-controller.js +90 -0
  96. package/build/lib/github-actions/git-controller.js.map +1 -0
  97. package/build/lib/github-actions/github-actions.d.ts +7 -0
  98. package/build/lib/github-actions/github-actions.d.ts.map +1 -0
  99. package/build/lib/github-actions/github-actions.js +7 -0
  100. package/build/lib/github-actions/github-actions.js.map +1 -0
  101. package/build/lib/github-actions/index.d.ts +2 -0
  102. package/build/lib/github-actions/index.d.ts.map +1 -0
  103. package/build/lib/github-actions/index.js +2 -0
  104. package/build/lib/github-actions/index.js.map +1 -0
  105. package/build/lib/github-actions/lib/get-pr-deployments.d.ts +12 -0
  106. package/build/lib/github-actions/lib/get-pr-deployments.d.ts.map +1 -0
  107. package/build/lib/github-actions/lib/get-pr-deployments.js +51 -0
  108. package/build/lib/github-actions/lib/get-pr-deployments.js.map +1 -0
  109. package/build/lib/github-actions/pr-controller.d.ts +39 -0
  110. package/build/lib/github-actions/pr-controller.d.ts.map +1 -0
  111. package/build/lib/github-actions/pr-controller.js +122 -0
  112. package/build/lib/github-actions/pr-controller.js.map +1 -0
  113. package/build/lib/github-actions/run-step-cli.d.ts +9 -0
  114. package/build/lib/github-actions/run-step-cli.d.ts.map +1 -0
  115. package/build/lib/github-actions/run-step-cli.js +71 -0
  116. package/build/lib/github-actions/run-step-cli.js.map +1 -0
  117. package/build/lib/github-actions/runner.d.ts +17 -0
  118. package/build/lib/github-actions/runner.d.ts.map +1 -0
  119. package/build/lib/github-actions/runner.js +195 -0
  120. package/build/lib/github-actions/runner.js.map +1 -0
  121. package/build/lib/github-actions/schemas/context.d.ts +933 -0
  122. package/build/lib/github-actions/schemas/context.d.ts.map +1 -0
  123. package/build/lib/github-actions/schemas/context.js +407 -0
  124. package/build/lib/github-actions/schemas/context.js.map +1 -0
  125. package/build/lib/github-actions/schemas/index.d.ts +5 -0
  126. package/build/lib/github-actions/schemas/index.d.ts.map +1 -0
  127. package/build/lib/github-actions/schemas/index.js +5 -0
  128. package/build/lib/github-actions/schemas/index.js.map +1 -0
  129. package/build/lib/github-actions/search-module.d.ts +38 -0
  130. package/build/lib/github-actions/search-module.d.ts.map +1 -0
  131. package/build/lib/github-actions/search-module.js +40 -0
  132. package/build/lib/github-actions/search-module.js.map +1 -0
  133. package/build/lib/github-actions/step.d.ts +163 -0
  134. package/build/lib/github-actions/step.d.ts.map +1 -0
  135. package/build/lib/github-actions/step.js +121 -0
  136. package/build/lib/github-actions/step.js.map +1 -0
  137. package/build/lib/helpers.d.ts.map +1 -1
  138. package/build/lib/helpers.js +5 -3
  139. package/build/lib/helpers.js.map +1 -1
  140. package/build/lib/kit-temp.d.ts +54 -0
  141. package/build/lib/kit-temp.d.ts.map +1 -1
  142. package/build/lib/kit-temp.js +80 -14
  143. package/build/lib/kit-temp.js.map +1 -1
  144. package/build/lib/kit-temp.test-d.d.ts +2 -0
  145. package/build/lib/kit-temp.test-d.d.ts.map +1 -0
  146. package/build/lib/kit-temp.test-d.js +75 -0
  147. package/build/lib/kit-temp.test-d.js.map +1 -0
  148. package/build/lib/mask/$$.d.ts +3 -0
  149. package/build/lib/mask/$$.d.ts.map +1 -0
  150. package/build/lib/mask/$$.js +3 -0
  151. package/build/lib/mask/$$.js.map +1 -0
  152. package/build/lib/mask/$.d.ts +2 -0
  153. package/build/lib/mask/$.d.ts.map +1 -0
  154. package/build/lib/mask/$.js +2 -0
  155. package/build/lib/mask/$.js.map +1 -0
  156. package/build/lib/mask/apply.d.ts +86 -0
  157. package/build/lib/mask/apply.d.ts.map +1 -0
  158. package/build/lib/mask/apply.js +86 -0
  159. package/build/lib/mask/apply.js.map +1 -0
  160. package/build/lib/mask/mask.d.ts +124 -0
  161. package/build/lib/mask/mask.d.ts.map +1 -0
  162. package/build/lib/mask/mask.js +137 -0
  163. package/build/lib/mask/mask.js.map +1 -0
  164. package/build/lib/mask/mask.test-d.d.ts +2 -0
  165. package/build/lib/mask/mask.test-d.d.ts.map +1 -0
  166. package/build/lib/mask/mask.test-d.js +102 -0
  167. package/build/lib/mask/mask.test-d.js.map +1 -0
  168. package/build/lib/task/$$.d.ts +3 -0
  169. package/build/lib/task/$$.d.ts.map +1 -0
  170. package/build/lib/task/$$.js +3 -0
  171. package/build/lib/task/$$.js.map +1 -0
  172. package/build/lib/task/$.d.ts +2 -0
  173. package/build/lib/task/$.d.ts.map +1 -0
  174. package/build/lib/task/$.js +2 -0
  175. package/build/lib/task/$.js.map +1 -0
  176. package/build/lib/task/report.d.ts +28 -0
  177. package/build/lib/task/report.d.ts.map +1 -0
  178. package/build/lib/task/report.js +33 -0
  179. package/build/lib/task/report.js.map +1 -0
  180. package/build/lib/task/task.d.ts +44 -0
  181. package/build/lib/task/task.d.ts.map +1 -0
  182. package/build/lib/task/task.js +63 -0
  183. package/build/lib/task/task.js.map +1 -0
  184. package/build/lib/version-history/index.d.ts +3 -0
  185. package/build/lib/version-history/index.d.ts.map +1 -0
  186. package/build/lib/version-history/index.js +2 -0
  187. package/build/lib/version-history/index.js.map +1 -0
  188. package/build/lib/version-history/types.d.ts +64 -0
  189. package/build/lib/version-history/types.d.ts.map +1 -0
  190. package/build/lib/version-history/types.js +5 -0
  191. package/build/lib/version-history/types.js.map +1 -0
  192. package/build/lib/version-history/version-history.d.ts +85 -0
  193. package/build/lib/version-history/version-history.d.ts.map +1 -0
  194. package/build/lib/version-history/version-history.js +248 -0
  195. package/build/lib/version-history/version-history.js.map +1 -0
  196. package/build/sandbox.d.ts +2 -0
  197. package/build/sandbox.d.ts.map +1 -0
  198. package/build/sandbox.js +3 -0
  199. package/build/sandbox.js.map +1 -0
  200. package/build/template/components/Link.jsx +1 -1
  201. package/package.json +16 -9
  202. package/src/api/api.ts +1 -0
  203. package/src/api/singletons/markdown/markdown.test.ts +1 -1
  204. package/src/api/static/index.ts +1 -0
  205. package/src/api/static/manifest.test.ts +106 -0
  206. package/src/api/static/manifest.ts +16 -0
  207. package/src/api/static/rebase.test.ts +229 -0
  208. package/src/api/static/rebase.ts +140 -0
  209. package/src/api/static/static.ts +2 -0
  210. package/src/api/utils/asset-url/asset-url.test.ts +4 -4
  211. package/src/api/vite/plugins/build.ts +25 -1
  212. package/src/api/vite/plugins/core.ts +1 -1
  213. package/src/cli/commands/static/$default.ts +43 -0
  214. package/src/cli/commands/static/rebase.ts +37 -0
  215. package/src/cli/commands/static.ts +6 -0
  216. package/src/lib/demos/builder.ts +298 -0
  217. package/src/lib/demos/config-schema.ts +56 -0
  218. package/src/lib/demos/config.test.ts +193 -0
  219. package/src/lib/demos/config.ts +205 -0
  220. package/src/lib/demos/index.ts +9 -0
  221. package/src/lib/demos/ui/components.ts +739 -0
  222. package/src/lib/demos/ui/data-collector.ts +246 -0
  223. package/src/lib/demos/ui/landing-page-cli.ts +23 -0
  224. package/src/lib/demos/ui/landing-page.ts +126 -0
  225. package/src/lib/demos/ui/page-renderer.ts +124 -0
  226. package/src/lib/demos/utils.ts +43 -0
  227. package/src/lib/deployment/$$.ts +2 -0
  228. package/src/lib/deployment/$.test.ts +53 -0
  229. package/src/lib/deployment/$.ts +1 -0
  230. package/src/lib/deployment/metadata.ts +40 -0
  231. package/src/lib/deployment/path-manager.ts +186 -0
  232. package/src/lib/github-actions/git-controller.ts +151 -0
  233. package/src/lib/github-actions/github-actions.ts +6 -0
  234. package/src/lib/github-actions/index.ts +1 -0
  235. package/src/lib/github-actions/lib/get-pr-deployments.ts +76 -0
  236. package/src/lib/github-actions/pr-controller.test.ts +172 -0
  237. package/src/lib/github-actions/pr-controller.ts +183 -0
  238. package/src/lib/github-actions/run-step-cli.ts +84 -0
  239. package/src/lib/github-actions/runner.test.ts +192 -0
  240. package/src/lib/github-actions/runner.ts +226 -0
  241. package/src/lib/github-actions/schemas/context.ts +424 -0
  242. package/src/lib/github-actions/schemas/index.ts +5 -0
  243. package/src/lib/github-actions/search-module.test.ts +110 -0
  244. package/src/lib/github-actions/search-module.ts +76 -0
  245. package/src/lib/github-actions/step.test.ts +149 -0
  246. package/src/lib/github-actions/step.ts +232 -0
  247. package/src/lib/helpers.ts +4 -3
  248. package/src/lib/kit-temp.test-d.ts +115 -0
  249. package/src/lib/kit-temp.test.ts +127 -0
  250. package/src/lib/kit-temp.ts +126 -14
  251. package/src/lib/mask/$$.ts +2 -0
  252. package/src/lib/mask/$.test.ts +248 -0
  253. package/src/lib/mask/$.ts +1 -0
  254. package/src/lib/mask/apply.ts +134 -0
  255. package/src/lib/mask/mask.test-d.ts +144 -0
  256. package/src/lib/mask/mask.ts +244 -0
  257. package/src/lib/shiki/shiki.test.ts +1 -1
  258. package/src/lib/task/$$.ts +2 -0
  259. package/src/lib/task/$.test.ts +209 -0
  260. package/src/lib/task/$.ts +1 -0
  261. package/src/lib/task/report.ts +72 -0
  262. package/src/lib/task/task.ts +112 -0
  263. package/src/lib/version-history/index.test.ts +188 -0
  264. package/src/lib/version-history/index.ts +4 -0
  265. package/src/lib/version-history/types.ts +68 -0
  266. package/src/lib/version-history/version-history.ts +293 -0
  267. package/src/sandbox.ts +1 -0
  268. package/src/template/components/Link.tsx +1 -1
package/README.md CHANGED
@@ -2,34 +2,33 @@
2
2
 
3
3
  A framework for delightful GraphQL developer portals
4
4
 
5
- ## Installation
5
+ ## What is Polen?
6
6
 
7
- ```sh
8
- npm add polen
9
- ```
7
+ Polen transforms your GraphQL schema into a beautiful, interactive developer portal with zero configuration. It automatically generates:
10
8
 
11
- ## Quickstart
9
+ - 📖 **Schema Reference** - Interactive documentation for all types, fields, and operations
10
+ - 📝 **Changelog** - Track schema evolution over time
11
+ - 📄 **Custom Pages** - Add guides, tutorials, and API documentation with Markdown/MDX
12
+ - 🎨 **Beautiful UI** - Modern, responsive design out of the box
13
+ - 🚀 **Instant Deploy** - Static site generation for easy hosting anywhere
12
14
 
13
- 1. Have a `schema.graphql` GraphQL schema file in your project directory.
15
+ ## Quick Start
14
16
 
15
- ```graphql
16
- type Query {
17
- hello: String
18
- }
19
- ```
17
+ ```sh
18
+ # Install Polen
19
+ npm add polen
20
20
 
21
- 2. Build your developer portal.
21
+ # Create a GraphQL schema file
22
+ echo "type Query { hello: String }" > schema.graphql
22
23
 
23
- ```sh
24
- npx polen build
25
- ```
24
+ # Build your developer portal
25
+ npx polen build
26
26
 
27
- 3. You now have a deployable developer portal. Try it locally
28
- (http://localhost:3001):
27
+ # Preview locally
28
+ node build/app.js
29
+ ```
29
30
 
30
- ```sh
31
- node build/app.js
32
- ```
31
+ Visit http://localhost:3001 to see your developer portal!
33
32
 
34
33
  ## Live Demos
35
34
 
@@ -38,378 +37,52 @@ Experience Polen in action with our live documentation sites:
38
37
  ### 🌐 [View All Demos](https://the-guild-org.github.io/polen/)
39
38
 
40
39
  Featured examples:
41
-
42
40
  - **[Pokemon GraphQL API](https://the-guild-org.github.io/polen/latest/pokemon/)** - Explore a fun GraphQL API with rich schema documentation
43
41
  - **GitHub GraphQL API** (Coming soon) - Browse GitHub's extensive GraphQL API documentation
44
42
 
45
- ### Demo Versions
46
-
47
- Our demos are available at different stability levels, matching npm's dist tags:
43
+ ## Documentation
48
44
 
49
- - **Stable Release** (`latest`): [/polen/latest/pokemon](https://the-guild-org.github.io/polen/latest/pokemon/)
50
- - The most recent stable version (e.g., `1.0.0`)
51
- - Same as `npm install polen`
45
+ - **[Getting Started](./docs/getting-started.md)** - Installation and quick start guide
46
+ - **[Schema Configuration](./docs/guide/schema.md)** - Configure your GraphQL schema
47
+ - **[Custom Pages](./docs/guide/pages.md)** - Add documentation with Markdown and MDX
48
+ - **[Build & Deploy](./docs/guide/build.md)** - Build configuration and deployment options
49
+ - **[CLI Reference](./docs/cli/index.md)** - All available commands
50
+ - **[Package API](./docs/api/package.md)** - Programmatic usage
52
51
 
53
- - **Pre-release** (`next`): [/polen/next/pokemon](https://the-guild-org.github.io/polen/next/pokemon/)
54
- - The latest pre-release version (e.g., `1.1.0-beta.1`)
55
- - Same as `npm install polen@next`
52
+ ### Features
56
53
 
57
- - **Tagged Versions**: Access any specific release
58
- - e.g., [/polen/1.0.0/pokemon](https://the-guild-org.github.io/polen/1.0.0/pokemon/)
59
- - Same as `npm install polen@1.0.0`
60
-
61
- > [!TIP]
62
- > The correspondence between demo URLs and npm versions makes it easy to test features before upgrading. If you're using `polen@1.0.0`, visit `/polen/1.0.0/pokemon` to see exactly how your docs will look!
54
+ - **[Static Rebase](./docs/features/static-rebase.md)** - Update base paths without rebuilding
55
+ - **[Syntax Highlighting](./docs/features/syntax-highlighting.md)** - Beautiful code blocks with language support
63
56
 
64
57
  ## Examples
65
58
 
66
- Find the source code for these demos and more in the [examples](./examples) directory.
67
-
68
- ## Guide
69
-
70
- ### Schema Reference
71
-
72
- If you [provide Polen with a schema](#providing-a-schema), Polen will
73
- automatically render reference documentation for it.
74
-
75
- If you provide multiple versions of your schema then the reference is based on
76
- the schema with the latest date.
77
-
78
- ### Schema Changelog
79
-
80
- Polen can render a changelog for your schema.
81
-
82
- This feature is automatically enabled when you provide multiple versions of your
83
- schema. Refer to [Provide a Schema](#providing-a-schema) for details on how to
84
- do that.
85
-
86
- ### Schema Augmentations
87
-
88
- #### Descriptions
89
-
90
- You can append/prepend/replace descriptions of types and fields in your schema.
91
-
92
- Any Markdown syntax in your content will be automatically rendered.
93
-
94
- ```ts
95
- import { Polen } from 'polen'
96
-
97
- export default Polen.defineConfig({
98
- templateVariables: {
99
- title: `Pokemon Developer Portal`,
100
- },
101
- schemaAugmentations: [
102
- {
103
- type: `description`,
104
- on: {
105
- type: `TargetType`,
106
- name: `Query`,
107
- },
108
- placement: `over`,
109
- content:
110
- `**Content from [Polen](https://github.com/the-guild-org/polen)**.`,
111
- },
112
- ],
113
- })
114
- ```
115
-
116
- ### Providing a Schema
117
-
118
- You can provide a GraphQL schema to Polen in various ways.
119
-
120
- #### File
121
-
122
- Have a single `schema.graphql` SDL file in your project directory. Example:
123
-
124
- ```
125
- schema.graphql
126
- ```
127
-
128
- #### Directory
129
-
130
- Have a `schema` directory in your project directory with multiple versions of
131
- your schema as SDL files named using format: `YYYY-MM-DD.graphql`. Example:
132
-
133
- ```
134
- schema/
135
- 2023-01-13.graphql
136
- 2020-09-26.graphql
137
- ```
138
-
139
- This approach allows Polen to render a changelog for your schema. Refer to
140
- [Changelog](#changelog).
141
-
142
- #### Memory
143
-
144
- You can provide a schema to Polen in memory via configuration.
145
-
146
- You have control to provide one or multiple schemas, with or without dates.
147
-
148
- If no dates are given then the current time is assumed.
149
-
150
- If you provide multiple versions then Polen can render a changelog for you.
151
- Refer to [Changelog](#changelog).
152
-
153
- Basic example:
154
-
155
- ```ts
156
- // polen.config.ts
157
- import { Polen } from 'polen'
158
-
159
- export default Polen.defineConfig({
160
- schema: {
161
- useDataSources: `memory`,
162
- dataSources: {
163
- memory: {
164
- versions: [
165
- {
166
- date: new Date('2023-01-13'),
167
- value: `type Query { hello: String }`,
168
- },
169
- ],
170
- },
171
- },
172
- },
173
- })
174
- ```
175
-
176
- ### Pages
177
-
178
- You can add pages to your developer portal by adding markdown (`.md`) or MDX (`.mdx`) files to a
179
- `pages` directory.
180
-
181
- #### Routing
182
-
183
- - A file becomes a page.
184
- - The relative (to `pages` directory) file path becomes the web path.
185
- - _Navigation Bar_
186
- - Top level pages are listed in the navigation bar.
187
- - _Index Pages_
188
- - A file named `index` is an index page.
189
- - The file name is elided in the route. For example `foo/index.md` becomes
190
- route `/foo` .
191
- - Details:
192
- - If both `foo/index.md` and `foo.md` exist, then the former is used, latter
193
- ignored, and a warning is raised.
194
-
195
- Example:
196
-
197
- | File | Route | Navigation Bar Title |
198
- | --------------------- | ---------- | -------------------- |
199
- | `pages/foo.md` | `/foo` | `Foo` |
200
- | `pages/foo.mdx` | `/foo` | `Foo` |
201
- | `pages/foo/index.md` | `/foo` | `Foo` |
202
- | `pages/foo/index.mdx` | `/foo` | `Foo` |
203
- | `pages/foo/bar.md` | `/foo/bar` | `Foo` |
204
- | `pages/foo/bar.mdx` | `/foo/bar` | `Foo` |
205
-
206
- #### Page Ordering
207
-
208
- You can control the order of pages in the sidebar by prefixing file names with numbers followed by `_` or `-`. The numeric prefix affects only the sidebar ordering - it does not appear in the page URL or title.
209
-
210
- - _Syntax_
211
- - Format: `<number>_<name>.md` or `<number>-<name>.md`
212
- - Examples: `01_intro.md`, `10_getting-started.md`, `20-configuration.md`
213
- - _Ordering_
214
- - Pages with numeric prefixes appear before pages without prefixes
215
- - Pages are sorted by their numeric value (not alphabetically)
216
- - Pages without prefixes are sorted alphabetically after numbered pages
217
- - _Collisions_
218
- - If multiple files have the same name after removing the prefix (e.g., `10_about.md` and `20_about.md`), the file with the higher number is used
219
- - A warning is shown for collision conflicts
220
-
221
- Example:
222
-
223
- | File | Route | Sidebar Title | Order |
224
- | ----------------------------- | ------------------ | ----------------- | ----- |
225
- | `pages/10_getting-started.md` | `/getting-started` | `Getting Started` | 1st |
226
- | `pages/20_configuration.md` | `/configuration` | `Configuration` | 2nd |
227
- | `pages/30_advanced.md` | `/advanced` | `Advanced` | 3rd |
228
- | `pages/api-reference.md` | `/api-reference` | `Api Reference` | 4th |
229
- | `pages/troubleshooting.md` | `/troubleshooting` | `Troubleshooting` | 5th |
230
-
231
- #### Markdown
232
-
233
- Markdown files (`.md`) are supported using [remark](https://remark.js.org/). This is the same underlying engine as [MDX](https://mdxjs.com/) thus you can rely on consistent behavior between your `.md` and `.mdx` files.
234
-
235
- Polen supports:
236
-
237
- - [CommonMark](https://commonmark.org/).
238
- - [GitHub Flavored Markdown](https://github.github.com/gfm/).
239
-
240
- In the future you will be able to extend Polen in your project with additional [Remark plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins). Track this feature in [#64](https://github.com/the-guild-org/polen/issues/64).
59
+ Find complete example projects in the [examples](./examples) directory:
241
60
 
242
- If you're new to Markdown, here are some great resources to get started:
61
+ - `pokemon` - Fun Pokemon API documentation
62
+ - `github` - GitHub GraphQL API (coming soon)
63
+ - `minimal` - Minimal setup example
243
64
 
244
- - **[CommonMark Tutorial](https://commonmark.org/help/)** - Interactive 10-minute tutorial
245
- - **[Markdown Guide](https://www.markdownguide.org/)** - Comprehensive reference and cheat sheets
246
- - **[GitHub's Markdown Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)** - Practical guide with examples
65
+ ## Why Polen?
247
66
 
248
- Syntax features available to you include:
67
+ - **Zero Configuration** - Works out of the box with just a GraphQL schema
68
+ - **Developer Focused** - Built specifically for GraphQL API documentation
69
+ - **Modern Stack** - React, TypeScript, and Vite for fast builds
70
+ - **Flexible** - Customize everything from branding to page structure
71
+ - **Static or Server** - Deploy as static files or run as a Node.js server
249
72
 
250
- **Via CommonMark:**
73
+ ## Contributing
251
74
 
252
- - Headers, paragraphs, and line breaks
253
- - Bold, italic, and code formatting
254
- - Lists (ordered and unordered)
255
- - Links and images
256
- - Code blocks with syntax highlighting
257
- - Blockquotes
258
- - Horizontal rules
259
-
260
- **Via GitHub Flavored Markdown:**
261
-
262
- - Tables
263
- - Task lists
264
- - Strikethrough text
265
- - Autolinks
266
-
267
- #### MDX
268
-
269
- MDX begins where [Markdown](#markdown) ends. So everything stated there such as regarding supported Markdown flavours applies here too.
270
-
271
- MDX files (`.mdx`) allow you to use JSX/React components within your markdown content. This enables
272
- interactive documentation with live examples, custom components, and more.
273
-
274
- Example MDX page:
275
-
276
- ```mdx
277
- # Interactive Documentation
278
-
279
- import { Button } from "@radix-ui/themes";
280
-
281
- This page demonstrates MDX features.
282
-
283
- <Button onClick={() => alert("Hello from MDX!")}>Click me!</Button>
284
-
285
- ## Code Examples
286
-
287
- You can mix markdown with React components for powerful documentation:
288
-
289
- export const CodeExample = ({ language, code }) => (
290
- <pre>
291
- <code className={`language-${language}`}>{code}</code>
292
- </pre>
293
- );
294
-
295
- <CodeExample
296
- language="graphql"
297
- code={`
298
- query GetUser($id: ID!) {
299
- user(id: $id) {
300
- name
301
- email
302
- }
303
- }
304
- `}
305
- />
306
- ```
307
-
308
- ### Build
309
-
310
- When you build you may choose between SSG and SSR. The default is SSG.
311
-
312
- #### SSG
313
-
314
- ```sh
315
- npx polen build --type ssg
316
- ```
317
-
318
- Deploy the contents of the `./build` directory on your favourite static site provider.
319
-
320
- #### SSR
321
-
322
- In the future Polen will have features that motivate using a server, but for now there is no particular benefit. Use `SSG` instead.
323
-
324
- #### Base Path Configuration
325
-
326
- Polen supports deploying to subdirectories through the `build.base` configuration option. This is useful for:
327
-
328
- - GitHub Pages project sites (e.g., `/my-project/`)
329
- - PR preview deployments (e.g., `/pr-123/`)
330
- - Hosting multiple Polen sites on one domain
331
-
332
- ```ts
333
- // polen.config.ts
334
- import { Polen } from 'polen'
335
-
336
- export default Polen.defineConfig({
337
- build: {
338
- base: '/my-project/', // Must start and end with /
339
- },
340
- })
341
- ```
342
-
343
- When configured, Polen will output differently:
344
-
345
- - For SSG architecture:
346
- - Generate static files that work in the subdirectory
347
- - For SSR architecture:
348
- - A server that serves static assets from the correct path
349
-
350
- You can also set the base path via CLI:
351
-
352
- ```bash
353
- npx polen build --base /my-project/
354
- npx polen dev --base /my-project/
355
- ```
356
-
357
- The CLI flag takes precedence over the config file setting.
358
-
359
- #### Custom Logo
360
-
361
- You can provide a custom logo for your developer portal by placing a `logo.svg` file in your project's `public` directory:
362
-
363
- ```
364
- public/
365
- logo.svg
366
- ```
367
-
368
- Polen will automatically use this logo in the navigation bar instead of the default Polen logo.
369
-
370
- ### Package
371
-
372
- #### ESM
373
-
374
- Polen is an ESM only package. If you are using CJS, then you need
375
- [NodeJS version `>=22.0.0` to `require` it](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require).
376
-
377
- #### Exports
378
-
379
- You can import a `Polen` namespace from `polen`. You can import its bare exports
380
- from `polen/polen`.
381
-
382
- ```ts
383
- import { Polen } from 'polen'
384
- import { defineConfig } from 'polen/polen'
385
-
386
- console.log(Polen.defineConfig === defineConfig) // true
387
- ```
388
-
389
- ### Instant Schema Explorer
390
-
391
- Polen comes with a light-weight command to instantly view any GraphQL schema.
392
-
393
- Example:
394
-
395
- ```sh
396
- npx polen open --name github
397
- ```
398
-
399
- See docs for more details
400
-
401
- ```sh
402
- npx polen open --help
403
- ```
75
+ We welcome contributions! See [DEVELOPMENT.md](./DEVELOPMENT.md) for:
404
76
 
405
- ## Other
77
+ - Development setup
78
+ - Architecture overview
79
+ - Testing guidelines
80
+ - Contribution process
406
81
 
407
- ### Changelog
82
+ ## Changelog
408
83
 
409
- Refer to
410
- [releases on this repo](https://github.com/the-guild-org/polen/releases).
84
+ See [releases](https://github.com/the-guild-org/polen/releases) for a detailed changelog.
411
85
 
412
- ### Development
86
+ ## License
413
87
 
414
- If you are working on Polen itself, then refer to
415
- [DEVELOPMENT.md](./DEVELOPMENT.md) for details about workflow, testing, etc.
88
+ MIT © [The Guild](https://the-guild.dev)
@@ -1,4 +1,5 @@
1
1
  export * from './builder/index.ts';
2
2
  export * from './config-resolver/index.ts';
3
3
  export * from './config/index.ts';
4
+ export * from './static/index.ts';
4
5
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
package/build/api/api.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./builder/index.js";
2
2
  export * from "./config-resolver/index.js";
3
3
  export * from "./config/index.js";
4
+ export * from "./static/index.js";
4
5
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * as Static from './static.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/static/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * as Static from "./static.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/static/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { Resource } from '@wollybeard/kit';
2
+ import { z } from 'zod/v4';
3
+ export declare const PolenBuildManifestSchema: z.ZodObject<{
4
+ type: z.ZodEnum<{
5
+ ssr: "ssr";
6
+ ssg: "ssg";
7
+ }>;
8
+ version: z.ZodString;
9
+ basePath: z.ZodString;
10
+ }, z.core.$loose>;
11
+ export type PolenBuildManifest = z.infer<typeof PolenBuildManifestSchema>;
12
+ export declare const buildManifest: Resource.Resource<"polen-build-manifest", {
13
+ [x: string]: unknown;
14
+ type: "ssr" | "ssg";
15
+ version: string;
16
+ basePath: string;
17
+ }>;
18
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/api/static/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,eAAO,MAAM,wBAAwB;;;;;;;iBAI3B,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,eAAO,MAAM,aAAa;;;;;EAIxB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Codec, Resource } from '@wollybeard/kit';
2
+ import { z } from 'zod/v4';
3
+ export const PolenBuildManifestSchema = z.object({
4
+ type: z.enum(['ssg', 'ssr']),
5
+ version: z.string(),
6
+ basePath: z.string(),
7
+ }).loose();
8
+ export const buildManifest = Resource.create({
9
+ name: 'polen-build-manifest',
10
+ path: '.polen/build.json',
11
+ codec: Codec.fromZod(PolenBuildManifestSchema),
12
+ });
13
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/api/static/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC,KAAK,EAAE,CAAA;AAIV,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC;CAC/C,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ export type RebasePlan = RebaseOverwritePlan | RebaseCopyPlan;
2
+ export interface RebaseOverwritePlan {
3
+ changeMode: 'mutate';
4
+ newBasePath: string;
5
+ sourcePath: string;
6
+ }
7
+ export interface RebaseCopyPlan {
8
+ changeMode: 'copy';
9
+ newBasePath: string;
10
+ sourcePath: string;
11
+ targetPath: string;
12
+ }
13
+ export declare const rebase: (plan: RebasePlan) => Promise<void>;
14
+ //# sourceMappingURL=rebase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebase.d.ts","sourceRoot":"","sources":["../../../src/api/static/rebase.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,cAAc,CAAA;AAE7D,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,QAAQ,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,MAAM,GAAU,MAAM,UAAU,KAAG,OAAO,CAAC,IAAI,CAiC3D,CAAA"}
@@ -0,0 +1,110 @@
1
+ import { TinyGlobby } from '#dep/tiny-globby/index';
2
+ import { Fs, Path } from '@wollybeard/kit';
3
+ import { Err } from '@wollybeard/kit';
4
+ import { buildManifest } from "./manifest.js";
5
+ export const rebase = async (plan) => {
6
+ // 1. Validate source is a Polen build
7
+ const manifestResult = await buildManifest.read(plan.sourcePath);
8
+ if (Err.is(manifestResult)) {
9
+ throw new Error(`Polen build manifest not found at: ${Path.join(plan.sourcePath, '.polen', 'build.json')}`);
10
+ }
11
+ const manifest = manifestResult;
12
+ // 2. Validate newBasePath is valid URL path
13
+ if (!isValidUrlPath(plan.newBasePath)) {
14
+ throw new Error(`Invalid base path: ${plan.newBasePath}`);
15
+ }
16
+ // 3. Handle copy vs mutate
17
+ let workingPath;
18
+ if (plan.changeMode === 'copy') {
19
+ if (await Fs.exists(plan.targetPath)) {
20
+ const isEmpty = await Fs.isEmptyDir(plan.targetPath);
21
+ if (!isEmpty) {
22
+ throw new Error(`Target path already exists and is not empty: ${plan.targetPath}`);
23
+ }
24
+ }
25
+ await Fs.copyDir({ from: plan.sourcePath, to: plan.targetPath });
26
+ workingPath = plan.targetPath;
27
+ }
28
+ else {
29
+ workingPath = plan.sourcePath;
30
+ }
31
+ // 4. Update HTML files with new base path
32
+ await updateHtmlFiles(workingPath, manifest.basePath, plan.newBasePath);
33
+ // 5. Update manifest
34
+ await updateManifest(workingPath, { basePath: plan.newBasePath });
35
+ };
36
+ //
37
+ //
38
+ //
39
+ //
40
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Local Helpers
41
+ //
42
+ //
43
+ // TODO: this is very generic, factor out to kit-temp
44
+ const isValidUrlPath = (path) => {
45
+ // URL path should start with / and not contain invalid characters
46
+ if (!path.startsWith('/'))
47
+ return false;
48
+ if (!path.endsWith('/'))
49
+ return false;
50
+ // Basic validation - no spaces, proper URL characters
51
+ const urlPathRegex = /^\/[a-zA-Z0-9\-._~:/?#[\]@!$&'()*+,;=%]*\/$/;
52
+ return urlPathRegex.test(path);
53
+ };
54
+ const updateHtmlFiles = async (buildPath, oldBasePath, newBasePath) => {
55
+ // Find all HTML files recursively
56
+ const htmlFiles = await findHtmlFiles(buildPath);
57
+ for (const htmlFile of htmlFiles) {
58
+ await updateHtmlFile(htmlFile, oldBasePath, newBasePath);
59
+ }
60
+ };
61
+ const findHtmlFiles = async (dir) => {
62
+ return await TinyGlobby.glob('**/*.html', {
63
+ absolute: true,
64
+ cwd: dir,
65
+ onlyFiles: true,
66
+ });
67
+ };
68
+ const updateHtmlFile = async (filePath, oldBasePath, newBasePath) => {
69
+ const content = await Fs.read(filePath);
70
+ if (content === null) {
71
+ throw new Error(`Could not read HTML file: ${filePath}`);
72
+ }
73
+ // Simple regex-based approach to update base tag
74
+ // Look for existing base tag first
75
+ const baseTagRegex = /<base\s+href\s*=\s*["']([^"']*)["'][^>]*>/i;
76
+ let updatedContent;
77
+ if (baseTagRegex.test(content)) {
78
+ // Update existing base tag
79
+ updatedContent = content.replace(baseTagRegex, `<base href="${newBasePath}">`);
80
+ }
81
+ else {
82
+ // Insert new base tag in head
83
+ const headRegex = /<head[^>]*>/i;
84
+ const headMatch = content.match(headRegex);
85
+ if (headMatch) {
86
+ const insertPosition = headMatch.index + headMatch[0].length;
87
+ updatedContent = content.slice(0, insertPosition)
88
+ + `\n <base href="${newBasePath}">`
89
+ + content.slice(insertPosition);
90
+ }
91
+ else {
92
+ throw new Error(`Could not find <head> tag in HTML file: ${filePath}`);
93
+ }
94
+ }
95
+ await Fs.write({ path: filePath, content: updatedContent });
96
+ };
97
+ const updateManifest = async (buildPath, updates) => {
98
+ const manifestPath = Path.join(buildPath, '.polen', 'build.json');
99
+ const manifestResult = await buildManifest.read(buildPath);
100
+ if (Err.is(manifestResult)) {
101
+ throw new Error(`Polen build manifest not found at: ${manifestPath}`);
102
+ }
103
+ const currentManifest = manifestResult;
104
+ const updatedManifest = { ...currentManifest, ...updates };
105
+ await Fs.write({
106
+ path: manifestPath,
107
+ content: JSON.stringify(updatedManifest, null, 2),
108
+ });
109
+ };
110
+ //# sourceMappingURL=rebase.js.map