@cbnventures/nova 0.38.0 → 0.40.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 (214) hide show
  1. package/build/package.json +1 -1
  2. package/build/scaffold-versions.json +10 -9
  3. package/build/src/api/app-store-connect.d.ts +17 -2
  4. package/build/src/api/app-store-connect.d.ts.map +1 -1
  5. package/build/src/api/app-store-connect.js +654 -171
  6. package/build/src/api/app-store-connect.js.map +1 -1
  7. package/build/src/api/docker-hub.d.ts +14 -0
  8. package/build/src/api/docker-hub.d.ts.map +1 -0
  9. package/build/src/api/docker-hub.js +275 -0
  10. package/build/src/api/docker-hub.js.map +1 -0
  11. package/build/src/api/github-runner-images.d.ts +13 -0
  12. package/build/src/api/github-runner-images.d.ts.map +1 -0
  13. package/build/src/api/github-runner-images.js +238 -0
  14. package/build/src/api/github-runner-images.js.map +1 -0
  15. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +2 -2
  16. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -1
  17. package/build/src/cli/generate/github/workflows-blueprint-validate.js +260 -50
  18. package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -1
  19. package/build/src/cli/generate/github/workflows-blueprint.d.ts +6 -4
  20. package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
  21. package/build/src/cli/generate/github/workflows-blueprint.js +632 -74
  22. package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
  23. package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
  24. package/build/src/cli/generate/must-haves/agent-conventions.js +1 -0
  25. package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
  26. package/build/src/cli/index.js +41 -1
  27. package/build/src/cli/index.js.map +1 -1
  28. package/build/src/cli/integration/app-store-connect.d.ts +10 -0
  29. package/build/src/cli/integration/app-store-connect.d.ts.map +1 -1
  30. package/build/src/cli/integration/app-store-connect.js +701 -80
  31. package/build/src/cli/integration/app-store-connect.js.map +1 -1
  32. package/build/src/cli/recipe/docker-hub/docker-hub-precheck.d.ts +3 -0
  33. package/build/src/cli/recipe/docker-hub/docker-hub-precheck.d.ts.map +1 -0
  34. package/build/src/cli/recipe/docker-hub/docker-hub-precheck.js +72 -0
  35. package/build/src/cli/recipe/docker-hub/docker-hub-precheck.js.map +1 -0
  36. package/build/src/cli/recipe/docker-hub/sync-identity.d.ts +5 -0
  37. package/build/src/cli/recipe/docker-hub/sync-identity.d.ts.map +1 -0
  38. package/build/src/cli/recipe/docker-hub/sync-identity.js +124 -0
  39. package/build/src/cli/recipe/docker-hub/sync-identity.js.map +1 -0
  40. package/build/src/cli/recipe/docker-hub/sync-policies.d.ts +5 -0
  41. package/build/src/cli/recipe/docker-hub/sync-policies.d.ts.map +1 -0
  42. package/build/src/cli/recipe/docker-hub/sync-policies.js +63 -0
  43. package/build/src/cli/recipe/docker-hub/sync-policies.js.map +1 -0
  44. package/build/src/cli/recipe/index.d.ts.map +1 -1
  45. package/build/src/cli/recipe/index.js +12 -0
  46. package/build/src/cli/recipe/index.js.map +1 -1
  47. package/build/src/cli/recipe/nova-config/normalize-order.js +3 -3
  48. package/build/src/cli/recipe/nova-config/normalize-order.js.map +1 -1
  49. package/build/src/cli/scaffold/package/pfsense.d.ts +3 -0
  50. package/build/src/cli/scaffold/package/pfsense.d.ts.map +1 -1
  51. package/build/src/cli/scaffold/package/pfsense.js +140 -6
  52. package/build/src/cli/scaffold/package/pfsense.js.map +1 -1
  53. package/build/src/cli/scaffold/tool/serverless.d.ts +2 -0
  54. package/build/src/cli/scaffold/tool/serverless.d.ts.map +1 -1
  55. package/build/src/cli/scaffold/tool/serverless.js +35 -1
  56. package/build/src/cli/scaffold/tool/serverless.js.map +1 -1
  57. package/build/src/cli/utility/changelog.d.ts +7 -0
  58. package/build/src/cli/utility/changelog.d.ts.map +1 -1
  59. package/build/src/cli/utility/changelog.js +800 -7
  60. package/build/src/cli/utility/changelog.js.map +1 -1
  61. package/build/src/cli/utility/configure.d.ts +4 -1
  62. package/build/src/cli/utility/configure.d.ts.map +1 -1
  63. package/build/src/cli/utility/configure.js +396 -24
  64. package/build/src/cli/utility/configure.js.map +1 -1
  65. package/build/src/lib/docker-packaging.d.ts +1 -0
  66. package/build/src/lib/docker-packaging.d.ts.map +1 -1
  67. package/build/src/lib/docker-packaging.js +39 -2
  68. package/build/src/lib/docker-packaging.js.map +1 -1
  69. package/build/src/lib/env-namespace.d.ts.map +1 -1
  70. package/build/src/lib/env-namespace.js +2 -1
  71. package/build/src/lib/env-namespace.js.map +1 -1
  72. package/build/src/lib/item.d.ts +2 -1
  73. package/build/src/lib/item.d.ts.map +1 -1
  74. package/build/src/lib/item.js +23 -0
  75. package/build/src/lib/item.js.map +1 -1
  76. package/build/src/lib/nova-config-order.d.ts.map +1 -1
  77. package/build/src/lib/nova-config-order.js +35 -1
  78. package/build/src/lib/nova-config-order.js.map +1 -1
  79. package/build/src/lib/nova-config.d.ts +1 -0
  80. package/build/src/lib/nova-config.d.ts.map +1 -1
  81. package/build/src/lib/nova-config.js +178 -3
  82. package/build/src/lib/nova-config.js.map +1 -1
  83. package/build/src/lib/regex.d.ts +16 -0
  84. package/build/src/lib/regex.d.ts.map +1 -1
  85. package/build/src/lib/regex.js +16 -0
  86. package/build/src/lib/regex.js.map +1 -1
  87. package/build/src/lib/scaffold.d.ts +3 -3
  88. package/build/src/lib/scaffold.d.ts.map +1 -1
  89. package/build/src/lib/scaffold.js +111 -8
  90. package/build/src/lib/scaffold.js.map +1 -1
  91. package/build/src/lib/schema.d.ts +34 -0
  92. package/build/src/lib/schema.d.ts.map +1 -1
  93. package/build/src/lib/schema.js +31 -0
  94. package/build/src/lib/schema.js.map +1 -1
  95. package/build/src/lib/workflow-templates.d.ts +4 -1
  96. package/build/src/lib/workflow-templates.d.ts.map +1 -1
  97. package/build/src/lib/workflow-templates.js +46 -16
  98. package/build/src/lib/workflow-templates.js.map +1 -1
  99. package/build/src/types/api/app-store-connect.d.ts +476 -33
  100. package/build/src/types/api/docker-hub.d.ts +237 -0
  101. package/build/src/types/api/github-runner-images.d.ts +199 -0
  102. package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +79 -17
  103. package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +131 -9
  104. package/build/src/types/cli/index.d.ts +2 -0
  105. package/build/src/types/cli/integration/app-store-connect.d.ts +470 -6
  106. package/build/src/types/cli/recipe/docker-hub/docker-hub-precheck.d.ts +78 -0
  107. package/build/src/types/cli/recipe/docker-hub/sync-identity.d.ts +80 -0
  108. package/build/src/types/cli/recipe/docker-hub/sync-policies.d.ts +57 -0
  109. package/build/src/types/cli/recipe/index.d.ts +3 -1
  110. package/build/src/types/cli/scaffold/package/pfsense.d.ts +83 -0
  111. package/build/src/types/cli/scaffold/tool/serverless.d.ts +30 -0
  112. package/build/src/types/cli/utility/changelog.d.ts +327 -1
  113. package/build/src/types/cli/utility/configure.d.ts +199 -4
  114. package/build/src/types/lib/docker-packaging.d.ts +25 -1
  115. package/build/src/types/lib/env-namespace.d.ts +4 -1
  116. package/build/src/types/lib/item.d.ts +11 -0
  117. package/build/src/types/lib/nova-config-order.d.ts +34 -1
  118. package/build/src/types/lib/nova-config.d.ts +100 -0
  119. package/build/src/types/lib/regex.d.ts +91 -0
  120. package/build/src/types/lib/scaffold.d.ts +48 -4
  121. package/build/src/types/lib/workflow-templates.d.ts +26 -0
  122. package/build/src/types/shared.d.ts +353 -3
  123. package/build/src/types/tests/api/app-store-connect.test.d.ts +162 -0
  124. package/build/src/types/tests/api/docker-hub.test.d.ts +84 -0
  125. package/build/src/types/tests/api/github-runner-images.test.d.ts +113 -0
  126. package/build/src/types/tests/cli/generate/github/workflows-blueprint-generate.test.d.ts +19 -0
  127. package/build/src/types/tests/cli/generate/github/workflows-blueprint-parity.test.d.ts +0 -9
  128. package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +108 -25
  129. package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +139 -30
  130. package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +45 -0
  131. package/build/src/types/tests/cli/generate/github/workflows-version-contract.test.d.ts +2 -2
  132. package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +2 -0
  133. package/build/src/types/tests/cli/integration/app-store-connect.test.d.ts +876 -0
  134. package/build/src/types/tests/cli/recipe/nova-config/normalize-order.test.d.ts +4 -0
  135. package/build/src/types/tests/cli/scaffold/tool/serverless.test.d.ts +21 -0
  136. package/build/src/types/tests/cli/utility/changelog-android.test.d.ts +14 -0
  137. package/build/src/types/tests/cli/utility/changelog-apple.test.d.ts +21 -0
  138. package/build/src/types/tests/cli/utility/changelog-fold.test.d.ts +350 -0
  139. package/build/src/types/tests/cli/utility/changelog.test.d.ts +50 -0
  140. package/build/src/types/tests/cli/utility/configure.test.d.ts +90 -0
  141. package/build/src/types/tests/lib/nova-config.test.d.ts +29 -1
  142. package/build/src/types/tests/lib/scaffold.test.d.ts +59 -2
  143. package/build/src/types/tests/scaffold-output-contract.test.d.ts +136 -0
  144. package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +1 -0
  145. package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +1 -0
  146. package/build/templates/generators/must-haves/agent-conventions/conventions/nova.md +6 -0
  147. package/build/templates/generators/must-haves/agent-conventions/conventions/pfsense.md +311 -0
  148. package/build/templates/scaffold/app/android/package.json +1 -1
  149. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-1024.png +0 -0
  150. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128.png +0 -0
  151. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128@2x.png +0 -0
  152. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16.png +0 -0
  153. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16@2x.png +0 -0
  154. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256.png +0 -0
  155. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256@2x.png +0 -0
  156. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32.png +0 -0
  157. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32@2x.png +0 -0
  158. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512.png +0 -0
  159. package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512@2x.png +0 -0
  160. package/build/templates/scaffold/app/apple/package.json +1 -1
  161. package/build/templates/scaffold/app/astro/package.json +1 -1
  162. package/build/templates/scaffold/app/discord-bot/package.json +1 -1
  163. package/build/templates/scaffold/app/express/package.json +1 -1
  164. package/build/templates/scaffold/app/nextjs/package.json +1 -1
  165. package/build/templates/scaffold/app/vite/package.json +1 -1
  166. package/build/templates/scaffold/docs/docusaurus/package.json +2 -2
  167. package/build/templates/scaffold/package/github-action/package.json +1 -1
  168. package/build/templates/scaffold/package/homebridge/package.json +1 -1
  169. package/build/templates/scaffold/package/pfsense/package.json +2 -2
  170. package/build/templates/scaffold/package/pfsense/port/Makefile.template +16 -1
  171. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/FileLock.php +93 -0
  172. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/PackagePaths.php +40 -0
  173. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/UpdateManager.php +1667 -0
  174. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].inc +161 -13
  175. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].xml +37 -0
  176. package/build/templates/scaffold/package/pfsense/port/files/usr/local/sbin/[__WORKSPACE_NAME__] +203 -8
  177. package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/logo.svg +12 -0
  178. package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/release-signing.pub +9 -0
  179. package/build/templates/scaffold/package/pfsense/port/files/usr/local/www/[__WORKSPACE_NAME__]-about.php +437 -0
  180. package/build/templates/scaffold/package/pfsense/port/pkg-plist +6 -0
  181. package/build/templates/scaffold/package/pfsense/scripts/build-package.sh +61 -0
  182. package/build/templates/scaffold/package/pfsense/scripts/check-package.mjs +114 -1
  183. package/build/templates/scaffold/package/pfsense/scripts/regex.mjs +10 -0
  184. package/build/templates/scaffold/package/pfsense/scripts/stage-package.mjs +48 -2
  185. package/build/templates/scaffold/package/pfsense/tests/updates.php +695 -0
  186. package/build/templates/scaffold-options/app/android-native/app/src/main/res/drawable/ic_launcher_background.xml +1 -1
  187. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  188. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  189. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  190. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  191. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  192. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  193. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  194. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  195. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  196. package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  197. package/build/templates/scaffold-options/docker-image/common/Dockerfile +7 -0
  198. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +1 -1
  199. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.test.d.ts +40 -2
  200. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/landing-page.d.ts +23 -0
  201. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.test.ts +119 -4
  202. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.ts +25 -3
  203. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/landing-page.ts +278 -0
  204. package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.test.ts +121 -6
  205. package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.ts +49 -12
  206. package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +3 -1
  207. package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/function/landing-page.ts +278 -0
  208. package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.d.ts +17 -2
  209. package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.test.d.ts +40 -2
  210. package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/function/landing-page.d.ts +23 -0
  211. package/build/templates/scaffold-options/tool/serverless/vercel-functions/tsconfig.functions.json +3 -1
  212. package/build/templates/scaffold-options/tool/serverless/vercel-functions/vercel.json +7 -1
  213. package/package.json +1 -1
  214. package/build/templates/scaffold/package/pfsense-root/.github/workflows/pfsense-[__WORKSPACE_NAME__].yml +0 -62
@@ -4,17 +4,132 @@ import {
4
4
  it,
5
5
  } from 'vitest';
6
6
 
7
- import { GET } from './index.js';
7
+ import { landingPage } from '../src/function/landing-page.js';
8
+ import handler from './index.js';
8
9
 
9
- import type { Api_IndexTest_Get_ReturnsTheStarterResponse_Response } from '../src/types/api/index.test.d.ts';
10
+ import type {
11
+ Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Html,
12
+ Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Response,
13
+ Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Html,
14
+ Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Response,
15
+ Api_IndexTest_FunctionHandler_ReturnsHeadersForHEADRequests_Response,
16
+ Api_IndexTest_FunctionHandler_ReturnsJsonForUnknownPaths_Response,
17
+ Api_IndexTest_FunctionHandler_ReturnsJsonForUnsupportedRootMethods_Response,
18
+ Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Html,
19
+ Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Response,
20
+ } from '../src/types/api/index.test.d.ts';
10
21
 
11
- describe('GET', () => {
12
- it('returns the starter response', async () => {
13
- const response: Api_IndexTest_Get_ReturnsTheStarterResponse_Response = GET(new Request('https://example.com/api'));
22
+ describe('Function handler', () => {
23
+ it('returns the homepage', async () => {
24
+ const response: Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Response = handler.fetch(new Request('https://example.com/api?path='));
25
+ const html: Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Html = await response.text();
14
26
 
15
27
  expect(response.status).toBe(200);
16
28
 
17
- expect(await response.json()).toEqual({ message: 'Welcome to [__PROJECT_SLUG__]' });
29
+ expect(response.headers.get('Content-Type')).toBe('text/html; charset=utf-8');
30
+
31
+ expect(response.headers.get('Content-Security-Policy')).toContain('frame-ancestors \'none\'');
32
+
33
+ expect(response.headers.get('Permissions-Policy')).toBe('camera=(), geolocation=(), microphone=()');
34
+
35
+ expect(response.headers.get('Referrer-Policy')).toBe('no-referrer');
36
+
37
+ expect(response.headers.get('X-Content-Type-Options')).toBe('nosniff');
38
+
39
+ expect(response.headers.get('X-Frame-Options')).toBe('DENY');
40
+
41
+ expect(html).toContain('<title>[__PROJECT_SLUG__]</title>');
42
+
43
+ expect(html).toContain('Your Worker is running. Edit src/worker/index.ts to make it yours.');
44
+
45
+ expect(html).toContain('>Running</span>');
46
+
47
+ expect(html).toContain('https://nova.cbnventures.io/docs/quickstart/');
48
+
49
+ expect(html).toContain('class="button ghost" href="[__PROJECT_REPOSITORY__]" target="_blank" rel="noopener noreferrer"');
50
+
51
+ expect(html).toContain('aria-hidden="true"');
52
+
53
+ expect(html).toContain('>GitHub</a>');
54
+
55
+ expect(html).toContain('A CBN Ventures project');
56
+
57
+ return;
58
+ });
59
+
60
+ it('returns headers for HEAD requests', async () => {
61
+ const response: Api_IndexTest_FunctionHandler_ReturnsHeadersForHEADRequests_Response = handler.fetch(new Request('https://example.com/api', {
62
+ method: 'HEAD',
63
+ }));
64
+
65
+ expect(response.status).toBe(200);
66
+
67
+ expect(response.headers.get('Content-Type')).toBe('text/html; charset=utf-8');
68
+
69
+ expect(await response.text()).toBe('');
70
+
71
+ return;
72
+ });
73
+
74
+ it('returns JSON for unsupported root methods', async () => {
75
+ const response: Api_IndexTest_FunctionHandler_ReturnsJsonForUnsupportedRootMethods_Response = handler.fetch(new Request('https://example.com/', {
76
+ method: 'POST',
77
+ }));
78
+
79
+ expect(response.status).toBe(405);
80
+
81
+ expect(response.headers.get('Allow')).toBe('GET, HEAD');
82
+
83
+ expect(response.headers.get('Content-Type')).toContain('application/json');
84
+
85
+ expect(await response.json()).toEqual({
86
+ status: 'error',
87
+ message: 'Method not allowed',
88
+ });
89
+
90
+ return;
91
+ });
92
+
93
+ it('returns JSON for unknown paths', async () => {
94
+ const response: Api_IndexTest_FunctionHandler_ReturnsJsonForUnknownPaths_Response = handler.fetch(new Request('https://example.com/api?path=missing'));
95
+
96
+ expect(response.status).toBe(404);
97
+
98
+ expect(response.headers.get('Content-Type')).toContain('application/json');
99
+
100
+ expect(await response.json()).toEqual({
101
+ status: 'error',
102
+ message: 'Not found',
103
+ });
104
+
105
+ return;
106
+ });
107
+
108
+ it('escapes project names before rendering', async () => {
109
+ const response: Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Response = landingPage(
110
+ '<script>alert("unsafe")</script>',
111
+ 'https://example.com/?query="<unsafe>"',
112
+ );
113
+ const html: Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Html = await response.text();
114
+
115
+ expect(html).toContain('&lt;script&gt;alert(&quot;unsafe&quot;)&lt;/script&gt;');
116
+
117
+ expect(html).not.toContain('<script>alert("unsafe")</script>');
118
+
119
+ expect(html).toContain('href="https://example.com/?query=&quot;&lt;unsafe&gt;&quot;"');
120
+
121
+ expect(html).not.toContain('href="https://example.com/?query="<unsafe>""');
122
+
123
+ return;
124
+ });
125
+
126
+ it('omits the repository button without a repository', async () => {
127
+ const response: Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Response = landingPage('example');
128
+ const html: Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Html = await response.text();
129
+
130
+ expect(html).toContain('>Documentation</a>');
131
+
132
+ expect(html).not.toContain('>GitHub</a>');
18
133
 
19
134
  return;
20
135
  });
@@ -1,20 +1,57 @@
1
+ import { landingPage } from '../src/function/landing-page.js';
2
+
1
3
  import type {
2
- Api_Index_Get_Request,
3
- Api_Index_Get_Returns,
4
+ Api_Index_Handler,
5
+ Api_Index_Handler_Fetch_Pathname,
6
+ Api_Index_Handler_Fetch_Request,
7
+ Api_Index_Handler_Fetch_RewrittenPath,
8
+ Api_Index_Handler_Fetch_Url,
4
9
  } from '../src/types/api/index.d.ts';
5
10
 
6
11
  /**
7
- * Index - Get.
8
- *
9
- * Handles the starter Vercel Function route through the web-standard Request
10
- * and Response APIs. Add product routes beside this file as the tool grows.
12
+ * Index - Handler.
11
13
  *
12
- * @param {Api_Index_Get_Request} _request - Request.
13
- *
14
- * @returns {Api_Index_Get_Returns}
14
+ * Handles incoming requests for the tool-owned Vercel Function. Add product
15
+ * routes here while the sibling CLI owns local management and deployment.
15
16
  *
16
17
  * @since 0.0.0
17
18
  */
18
- export function GET(_request: Api_Index_Get_Request): Api_Index_Get_Returns {
19
- return Response.json({ message: 'Welcome to [__PROJECT_SLUG__]' });
20
- }
19
+ const handler: Api_Index_Handler = {
20
+ fetch(request: Api_Index_Handler_Fetch_Request) {
21
+ const url: Api_Index_Handler_Fetch_Url = new URL(request.url);
22
+ const rewrittenPath: Api_Index_Handler_Fetch_RewrittenPath = url.searchParams.get('path');
23
+ const pathname: Api_Index_Handler_Fetch_Pathname = (rewrittenPath === null) ? url.pathname : `/${rewrittenPath}`;
24
+
25
+ if (
26
+ pathname !== '/'
27
+ && pathname !== '/api'
28
+ && pathname !== '/api/'
29
+ ) {
30
+ return Response.json({
31
+ status: 'error',
32
+ message: 'Not found',
33
+ }, {
34
+ status: 404,
35
+ });
36
+ }
37
+
38
+ if (
39
+ request.method !== 'GET'
40
+ && request.method !== 'HEAD'
41
+ ) {
42
+ return Response.json({
43
+ status: 'error',
44
+ message: 'Method not allowed',
45
+ }, {
46
+ status: 405,
47
+ headers: {
48
+ Allow: 'GET, HEAD',
49
+ },
50
+ });
51
+ }
52
+
53
+ return landingPage('[__PROJECT_SLUG__]', '[__PROJECT_REPOSITORY__]', request.method === 'HEAD');
54
+ },
55
+ };
56
+
57
+ export default handler;
@@ -13,7 +13,9 @@
13
13
  "api/index.ts",
14
14
  "bin",
15
15
  "build",
16
+ "src/function",
16
17
  "src/types/api",
18
+ "src/types/function",
17
19
  "vercel.json"
18
20
  ],
19
21
  "bin": {
@@ -49,7 +51,7 @@
49
51
  "node": "[__SCAFFOLD_VERSION_NODE_ENGINE__]"
50
52
  },
51
53
  "dependencies": {
52
- "@cbnventures/nova": "0.38.0",
54
+ "@cbnventures/nova": "0.40.0",
53
55
  "chalk": "[__SCAFFOLD_VERSION_CHALK__]",
54
56
  "commander": "[__SCAFFOLD_VERSION_COMMANDER__]",
55
57
  "vercel": "[__SCAFFOLD_VERSION_VERCEL__]"
@@ -0,0 +1,278 @@
1
+ import type {
2
+ Function_LandingPage_EscapeHtml_Returns,
3
+ Function_LandingPage_EscapeHtml_Value,
4
+ Function_LandingPage_LandingPage_Body,
5
+ Function_LandingPage_LandingPage_EscapedProjectInitial,
6
+ Function_LandingPage_LandingPage_EscapedProjectName,
7
+ Function_LandingPage_LandingPage_EscapedProjectRepository,
8
+ Function_LandingPage_LandingPage_Html,
9
+ Function_LandingPage_LandingPage_IsHead,
10
+ Function_LandingPage_LandingPage_ProjectName,
11
+ Function_LandingPage_LandingPage_ProjectRepository,
12
+ Function_LandingPage_LandingPage_RepositoryButton,
13
+ Function_LandingPage_LandingPage_Returns,
14
+ } from '../types/function/landing-page.d.ts';
15
+
16
+ /**
17
+ * Landing Page - Escape HTML.
18
+ *
19
+ * Encodes project-owned text before it enters the starter homepage markup.
20
+ * Generated projects can safely reuse the renderer with customized names.
21
+ *
22
+ * @param {Function_LandingPage_EscapeHtml_Value} value - Value.
23
+ *
24
+ * @returns {Function_LandingPage_EscapeHtml_Returns}
25
+ *
26
+ * @since 0.0.0
27
+ */
28
+ function escapeHtml(value: Function_LandingPage_EscapeHtml_Value): Function_LandingPage_EscapeHtml_Returns {
29
+ return value
30
+ .replaceAll('&', '&amp;')
31
+ .replaceAll('<', '&lt;')
32
+ .replaceAll('>', '&gt;')
33
+ .replaceAll('"', '&quot;')
34
+ .replaceAll('\'', '&#39;');
35
+ }
36
+
37
+ /**
38
+ * Landing Page - Landing Page.
39
+ *
40
+ * Renders the self-contained service card shown at the deployment root route.
41
+ * The isolated module gives generated projects one place to restyle it.
42
+ *
43
+ * @param {Function_LandingPage_LandingPage_ProjectName} projectName - Project name.
44
+ * @param {Function_LandingPage_LandingPage_ProjectRepository} [projectRepository] - Project repository.
45
+ * @param {Function_LandingPage_LandingPage_IsHead} [isHead] - Is head.
46
+ *
47
+ * @returns {Function_LandingPage_LandingPage_Returns}
48
+ *
49
+ * @since 0.0.0
50
+ */
51
+ function landingPage(projectName: Function_LandingPage_LandingPage_ProjectName, projectRepository: Function_LandingPage_LandingPage_ProjectRepository = '', isHead: Function_LandingPage_LandingPage_IsHead = false): Function_LandingPage_LandingPage_Returns {
52
+ const escapedProjectName: Function_LandingPage_LandingPage_EscapedProjectName = escapeHtml(projectName);
53
+ const escapedProjectInitial: Function_LandingPage_LandingPage_EscapedProjectInitial = escapeHtml(projectName.charAt(0).toUpperCase());
54
+ const escapedProjectRepository: Function_LandingPage_LandingPage_EscapedProjectRepository = escapeHtml(projectRepository);
55
+ const repositoryButton: Function_LandingPage_LandingPage_RepositoryButton = (projectRepository === '') ? '' : ` <a class="button ghost" href="${escapedProjectRepository}" target="_blank" rel="noopener noreferrer"><svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38v-1.33c-2.23.48-2.7-1.07-2.7-1.07-.36-.92-.89-1.17-.89-1.17-.73-.5.06-.49.06-.49.8.06 1.23.83 1.23.83.72 1.22 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48v2.19c0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"></path></svg>GitHub</a>`;
56
+ const html: Function_LandingPage_LandingPage_Html = [
57
+ '<!DOCTYPE html>',
58
+ '<html lang="en">',
59
+ '<head>',
60
+ ' <meta charset="utf-8">',
61
+ ' <meta name="viewport" content="width=device-width, initial-scale=1">',
62
+ ` <title>${escapedProjectName}</title>`,
63
+ ' <style>',
64
+ ' :root {',
65
+ ' --background: #111318;',
66
+ ' --accent: #a78bfa;',
67
+ ' --accent-text: #1e1037;',
68
+ ' --focus: #60a5fa;',
69
+ ' --text: #f6f3ff;',
70
+ ' --text-muted: #cfc9e6;',
71
+ ' --text-subtle: #9a93b8;',
72
+ ' }',
73
+ '',
74
+ ' *, *::before, *::after {',
75
+ ' box-sizing: border-box;',
76
+ ' }',
77
+ '',
78
+ ' body {',
79
+ ' display: grid;',
80
+ ' grid-template-columns: minmax(0, 1fr);',
81
+ ' place-items: center;',
82
+ ' min-height: 100vh;',
83
+ ' min-height: 100dvh;',
84
+ ' margin: 0;',
85
+ ' padding: 1rem;',
86
+ '',
87
+ ' color: var(--text);',
88
+ ' font-family: system-ui, -apple-system, \'Segoe UI\', sans-serif;',
89
+ ' -webkit-font-smoothing: antialiased;',
90
+ '',
91
+ ' background:',
92
+ ' radial-gradient(circle at 15% 10%, rgba(124, 58, 237, 0.3), transparent 45%),',
93
+ ' radial-gradient(circle at 85% 90%, rgba(59, 130, 246, 0.22), transparent 40%),',
94
+ ' var(--background);',
95
+ ' }',
96
+ '',
97
+ ' .card {',
98
+ ' display: flex;',
99
+ ' flex-direction: column;',
100
+ ' align-items: center;',
101
+ ' width: 100%;',
102
+ ' min-width: 0;',
103
+ ' max-width: 28rem;',
104
+ ' padding: 2.25rem 1rem 1.25rem;',
105
+ '',
106
+ ' text-align: center;',
107
+ '',
108
+ ' background: rgba(255, 255, 255, 0.05);',
109
+ ' border: 1px solid rgba(255, 255, 255, 0.12);',
110
+ ' border-radius: 24px;',
111
+ ' box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);',
112
+ ' }',
113
+ '',
114
+ ' .logo {',
115
+ ' display: grid;',
116
+ ' flex: none;',
117
+ ' place-items: center;',
118
+ ' width: 80px;',
119
+ ' height: 80px;',
120
+ ' margin-bottom: 1.25rem;',
121
+ '',
122
+ ' color: var(--accent-text);',
123
+ ' font-size: 34px;',
124
+ ' font-weight: 800;',
125
+ '',
126
+ ' background: var(--accent);',
127
+ ' border-radius: 20px;',
128
+ ' box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);',
129
+ ' }',
130
+ '',
131
+ ' h1 {',
132
+ ' max-width: 100%;',
133
+ ' margin: 0;',
134
+ '',
135
+ ' font-size: 1.75rem;',
136
+ ' line-height: 1.2;',
137
+ ' letter-spacing: -0.4px;',
138
+ ' overflow-wrap: anywhere;',
139
+ ' }',
140
+ '',
141
+ ' .description {',
142
+ ' max-width: 100%;',
143
+ ' margin: 0.6rem 0 0;',
144
+ '',
145
+ ' color: var(--text-muted);',
146
+ ' font-size: 1rem;',
147
+ ' line-height: 1.5;',
148
+ ' overflow-wrap: anywhere;',
149
+ ' }',
150
+ '',
151
+ ' .status {',
152
+ ' display: inline-flex;',
153
+ ' align-items: center;',
154
+ ' gap: 8px;',
155
+ ' margin-top: 1.1rem;',
156
+ ' padding: 5px 12px;',
157
+ '',
158
+ ' font-size: 13px;',
159
+ ' font-weight: 600;',
160
+ '',
161
+ ' background: rgba(255, 255, 255, 0.08);',
162
+ ' border: 1px solid rgba(255, 255, 255, 0.14);',
163
+ ' border-radius: 999px;',
164
+ ' }',
165
+ '',
166
+ ' .status-dot {',
167
+ ' width: 8px;',
168
+ ' height: 8px;',
169
+ '',
170
+ ' background: #34d399;',
171
+ ' border-radius: 50%;',
172
+ ' box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);',
173
+ ' }',
174
+ '',
175
+ ' .actions {',
176
+ ' display: flex;',
177
+ ' flex-wrap: wrap;',
178
+ ' justify-content: center;',
179
+ ' gap: 10px;',
180
+ ' width: 100%;',
181
+ ' margin-top: 1.4rem;',
182
+ ' }',
183
+ '',
184
+ ' .button {',
185
+ ' display: inline-flex;',
186
+ ' align-items: center;',
187
+ ' justify-content: center;',
188
+ ' gap: 8px;',
189
+ ' width: 100%;',
190
+ ' max-width: 100%;',
191
+ ' padding: 0.65rem 1.25rem;',
192
+ '',
193
+ ' font: 600 15px system-ui, -apple-system, sans-serif;',
194
+ ' text-align: center;',
195
+ ' text-decoration: none;',
196
+ ' overflow-wrap: anywhere;',
197
+ '',
198
+ ' border: 1px solid transparent;',
199
+ ' border-radius: 999px;',
200
+ ' }',
201
+ '',
202
+ ' .button.primary {',
203
+ ' color: var(--accent-text);',
204
+ ' background: var(--accent);',
205
+ ' }',
206
+ '',
207
+ ' .button.ghost {',
208
+ ' color: var(--text);',
209
+ ' background: transparent;',
210
+ ' border-color: rgba(255, 255, 255, 0.22);',
211
+ ' }',
212
+ '',
213
+ ' .button svg {',
214
+ ' width: 16px;',
215
+ ' height: 16px;',
216
+ ' }',
217
+ '',
218
+ ' .button:hover {',
219
+ ' filter: brightness(1.08);',
220
+ ' }',
221
+ '',
222
+ ' .button:focus-visible {',
223
+ ' outline: 3px solid var(--focus);',
224
+ ' outline-offset: 3px;',
225
+ ' }',
226
+ '',
227
+ ' .footer {',
228
+ ' margin-top: 1.6rem;',
229
+ '',
230
+ ' color: var(--text-subtle);',
231
+ ' font-size: 12px;',
232
+ ' letter-spacing: 0.2px;',
233
+ ' }',
234
+ '',
235
+ ' @media (min-width: 361px) {',
236
+ ' .card {',
237
+ ' padding-inline: 1.5rem;',
238
+ ' }',
239
+ '',
240
+ ' .actions, .button {',
241
+ ' width: auto;',
242
+ ' }',
243
+ ' }',
244
+ ' </style>',
245
+ '</head>',
246
+ '<body>',
247
+ ' <main class="card">',
248
+ ` <div class="logo" role="img" aria-label="${escapedProjectName} logo">${escapedProjectInitial}</div>`,
249
+ ` <h1>${escapedProjectName}</h1>`,
250
+ ' <p class="description">Your Worker is running. Edit src/worker/index.ts to make it yours.</p>',
251
+ ' <span class="status"><span class="status-dot" aria-hidden="true"></span>Running</span>',
252
+ ' <div class="actions">',
253
+ ' <a class="button primary" href="https://nova.cbnventures.io/docs/quickstart/" target="_blank" rel="noopener noreferrer">Documentation</a>',
254
+ repositoryButton,
255
+ ' </div>',
256
+ ' <footer class="footer">A CBN Ventures project</footer>',
257
+ ' </main>',
258
+ '</body>',
259
+ '</html>',
260
+ ].join('\n');
261
+ const body: Function_LandingPage_LandingPage_Body = (isHead === true) ? null : html;
262
+
263
+ return new Response(body, {
264
+ status: 200,
265
+ headers: {
266
+ 'Content-Security-Policy': 'default-src \'none\'; base-uri \'none\'; form-action \'none\'; frame-ancestors \'none\'; style-src \'unsafe-inline\'',
267
+ 'Content-Type': 'text/html; charset=utf-8',
268
+ 'Permissions-Policy': 'camera=(), geolocation=(), microphone=()',
269
+ 'Referrer-Policy': 'no-referrer',
270
+ 'X-Content-Type-Options': 'nosniff',
271
+ 'X-Frame-Options': 'DENY',
272
+ },
273
+ });
274
+ }
275
+
276
+ export {
277
+ landingPage,
278
+ };
@@ -3,6 +3,21 @@
3
3
  *
4
4
  * @since 0.0.0
5
5
  */
6
- export type Api_Index_Get_Request = Request;
6
+ export type Api_Index_Handler_Fetch_Request = Request;
7
7
 
8
- export type Api_Index_Get_Returns = Response;
8
+ export type Api_Index_Handler_Fetch_Returns = Response;
9
+
10
+ export type Api_Index_Handler_Fetch_Url = URL;
11
+
12
+ export type Api_Index_Handler_Fetch_RewrittenPath = string | null;
13
+
14
+ export type Api_Index_Handler_Fetch_Pathname = string;
15
+
16
+ /**
17
+ * Index.
18
+ *
19
+ * @since 0.0.0
20
+ */
21
+ export type Api_Index_Handler = {
22
+ fetch(request: Api_Index_Handler_Fetch_Request): Api_Index_Handler_Fetch_Returns;
23
+ };
@@ -1,6 +1,44 @@
1
1
  /**
2
- * Index.
2
+ * Index Test - Function handler - Escapes project names before rendering.
3
3
  *
4
4
  * @since 0.0.0
5
5
  */
6
- export type Api_IndexTest_Get_ReturnsTheStarterResponse_Response = Response;
6
+ export type Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Response = Response;
7
+ export type Api_IndexTest_FunctionHandler_EscapesProjectNamesBeforeRendering_Html = string;
8
+
9
+ /**
10
+ * Index Test - Function handler - Omits the repository button without a repository.
11
+ *
12
+ * @since UNRELEASED
13
+ */
14
+ export type Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Response = Response;
15
+ export type Api_IndexTest_FunctionHandler_OmitsTheRepositoryButtonWithoutARepository_Html = string;
16
+
17
+ /**
18
+ * Index Test - Function handler - Returns headers for HEAD requests.
19
+ *
20
+ * @since 0.0.0
21
+ */
22
+ export type Api_IndexTest_FunctionHandler_ReturnsHeadersForHEADRequests_Response = Response;
23
+
24
+ /**
25
+ * Index Test - Function handler - Returns JSON for unknown paths.
26
+ *
27
+ * @since 0.0.0
28
+ */
29
+ export type Api_IndexTest_FunctionHandler_ReturnsJsonForUnknownPaths_Response = Response;
30
+
31
+ /**
32
+ * Index Test - Function handler - Returns JSON for unsupported root methods.
33
+ *
34
+ * @since 0.0.0
35
+ */
36
+ export type Api_IndexTest_FunctionHandler_ReturnsJsonForUnsupportedRootMethods_Response = Response;
37
+
38
+ /**
39
+ * Index Test - Function handler - Returns the homepage.
40
+ *
41
+ * @since 0.0.0
42
+ */
43
+ export type Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Response = Response;
44
+ export type Api_IndexTest_FunctionHandler_ReturnsTheHomepage_Html = string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Landing Page.
3
+ *
4
+ * @since 0.0.0
5
+ */
6
+ export type Function_LandingPage_EscapeHtml_Value = string;
7
+ export type Function_LandingPage_EscapeHtml_Returns = string;
8
+
9
+ /**
10
+ * Landing Page.
11
+ *
12
+ * @since 0.0.0
13
+ */
14
+ export type Function_LandingPage_LandingPage_ProjectName = string;
15
+ export type Function_LandingPage_LandingPage_ProjectRepository = string;
16
+ export type Function_LandingPage_LandingPage_IsHead = boolean;
17
+ export type Function_LandingPage_LandingPage_Returns = Response;
18
+ export type Function_LandingPage_LandingPage_EscapedProjectName = string;
19
+ export type Function_LandingPage_LandingPage_EscapedProjectInitial = string;
20
+ export type Function_LandingPage_LandingPage_EscapedProjectRepository = string;
21
+ export type Function_LandingPage_LandingPage_RepositoryButton = string;
22
+ export type Function_LandingPage_LandingPage_Html = string;
23
+ export type Function_LandingPage_LandingPage_Body = string | null;
@@ -15,7 +15,9 @@
15
15
  },
16
16
  "include": [
17
17
  "./api/**/*.ts",
18
- "./src/types/api/**/*.d.ts"
18
+ "./src/function/**/*.ts",
19
+ "./src/types/api/**/*.d.ts",
20
+ "./src/types/function/**/*.d.ts"
19
21
  ],
20
22
  "exclude": [
21
23
  "./api/**/*.test.ts",
@@ -1,3 +1,9 @@
1
1
  {
2
- "$schema": "https://openapi.vercel.sh/vercel.json"
2
+ "$schema": "https://openapi.vercel.sh/vercel.json",
3
+ "rewrites": [
4
+ {
5
+ "source": "/:path*",
6
+ "destination": "/api?path=:path*"
7
+ }
8
+ ]
3
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbnventures/nova",
3
- "version": "0.38.0",
3
+ "version": "0.40.0",
4
4
  "description": "Scripts, templates, and project configuration for the common JavaScript and TypeScript developer",
5
5
  "keywords": [
6
6
  "eslint",