@ebay-dt/bonfire-next 0.2.1 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -179,7 +179,11 @@ themes are enabled, so the host does not scan metadata or rebuild a
|
|
|
179
179
|
```tsx
|
|
180
180
|
// src/app/(prototypes)/layout.tsx
|
|
181
181
|
import { notFound } from "next/navigation";
|
|
182
|
-
import {
|
|
182
|
+
import {
|
|
183
|
+
AppHeader,
|
|
184
|
+
PrototypeControlsShell,
|
|
185
|
+
PrototypeEnvironment,
|
|
186
|
+
} from "@ebay-dt/bonfire-react";
|
|
183
187
|
import { openInClaudeCode, openInCursor } from "@/actions/agents";
|
|
184
188
|
import { bonfire } from "@/bonfire";
|
|
185
189
|
|
|
@@ -192,13 +196,12 @@ export default async function PrototypeLayout({ children }: LayoutProps<"/">) {
|
|
|
192
196
|
|
|
193
197
|
const agentActions = { openInClaudeCode, openInCursor };
|
|
194
198
|
const header = <AppHeader {...headerProps} agentActions={agentActions} />;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
);
|
|
199
|
+
const shell = (
|
|
200
|
+
<PrototypeControlsShell header={header}>{children}</PrototypeControlsShell>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (prototype.theme === undefined) return shell;
|
|
204
|
+
|
|
202
205
|
return (
|
|
203
206
|
<PrototypeEnvironment
|
|
204
207
|
prototypeUrl={prototype.url}
|
|
@@ -206,19 +209,29 @@ export default async function PrototypeLayout({ children }: LayoutProps<"/">) {
|
|
|
206
209
|
themeRegistry={prototype.themeRegistry}
|
|
207
210
|
agentActions={agentActions}
|
|
208
211
|
>
|
|
209
|
-
{
|
|
210
|
-
{children}
|
|
212
|
+
{shell}
|
|
211
213
|
</PrototypeEnvironment>
|
|
212
214
|
);
|
|
213
215
|
}
|
|
214
216
|
```
|
|
215
217
|
|
|
218
|
+
`PrototypeControlsShell` is shared host composition, not a requirement to adopt
|
|
219
|
+
controls. A prototype that opts in places its client
|
|
220
|
+
`PrototypeControlsProvider` in its own prototype-local layout/provider wrapper;
|
|
221
|
+
that provider and its consumers stay below this boundary. Theme-less hosts use
|
|
222
|
+
the same shell and receive no synthetic theme controls. Keep application-lifetime
|
|
223
|
+
providers, including lifecycle providers, higher in the application layout; an
|
|
224
|
+
item-data `QueryProvider` remains an optional prototype-local composition and
|
|
225
|
+
must not be shadowed by an inner provider.
|
|
226
|
+
|
|
216
227
|
Keep this layout scoped to prototype routes. Dashboard, login, and other
|
|
217
|
-
application-level pages should remain outside it.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
application-level pages should remain outside it. The shared shell does not
|
|
229
|
+
remove the known limitation that a route-group layout may not remount for soft
|
|
230
|
+
navigation between prototypes; if an application supports that navigation, move
|
|
231
|
+
the environment/provider boundary to the route segment that identifies one
|
|
232
|
+
prototype (for example `[login]/[slug]/layout.tsx`) and use
|
|
233
|
+
`getRouteModel({ login, slug })` there. Regardless, controls must follow the
|
|
234
|
+
current provider and must not leave stale sidebar content.
|
|
222
235
|
|
|
223
236
|
## Prototype lifecycle composition
|
|
224
237
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-bonfire-next.d.ts","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,OAAO,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,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CAAC;CACH,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAkJvB,OAAO,CAAC,cAAc,CAAC;2CA0BhD,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA2DhE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n resolvePrimaryBranch,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: {\n url: string;\n prototypeDirectory: string;\n primaryBranch: string;\n };\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const primaryBranch = resolvePrimaryBranch(options.primaryBranch);\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\n }\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch,\n remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n primaryBranch,\n });\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n ...(sourceRepository === undefined ? {} : { sourceRepository }),\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-bonfire-next.d.ts","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,OAAO,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAW/B,MAAM,MAAM,wBAAwB,GAAG,k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BAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA2DhE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n resolvePrimaryBranch,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: {\n url: string;\n prototypeDirectory: string;\n primaryBranch: string;\n };\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"0px\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const primaryBranch = resolvePrimaryBranch(options.primaryBranch);\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\n }\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch,\n remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n primaryBranch,\n });\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n ...(sourceRepository === undefined ? {} : { sourceRepository }),\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
@@ -15,7 +15,7 @@ import { createRepositoryActions } from "./repository-actions.js";
|
|
|
15
15
|
import { createRepositoryRoutes } from "./repository-routes.js";
|
|
16
16
|
import { getPrototypeSourceRepository } from "./prototype-source-link.js";
|
|
17
17
|
const APP_HEADER_BLOCK_SIZE_PROPERTY = "--app-header-block-size";
|
|
18
|
-
const APP_HEADER_PRESENT_BLOCK_SIZE = "
|
|
18
|
+
const APP_HEADER_PRESENT_BLOCK_SIZE = "0px";
|
|
19
19
|
export function createBonfireNext(options) {
|
|
20
20
|
const primaryBranch = resolvePrimaryBranch(options.primaryBranch);
|
|
21
21
|
const config = defineConfig({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-bonfire-next.js","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,GAKrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,g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AqB;YAC7B,MAAM,EAAE,EAAE,GAAG,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE;SAC7D;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n resolvePrimaryBranch,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: {\n url: string;\n prototypeDirectory: string;\n primaryBranch: string;\n };\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const primaryBranch = resolvePrimaryBranch(options.primaryBranch);\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\n }\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch,\n remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n primaryBranch,\n });\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n ...(sourceRepository === undefined ? {} : { sourceRepository }),\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-bonfire-next.js","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,GAKrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,GAO7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,E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CAAC,CAAC;QAC5D,OAAO,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,KAAK,GAAG,eAAe,CAAC;QAC5B,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,UAAU;KACX,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,UAAU;QACV,SAAS;QACT,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;IACH,OAAO;QACL,UAAU,EAAE;YACV,iBAAiB;YACjB,aAAa;YACb,oBAAoB;YACpB,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC9D,YAAY,EAAE;gBACZ,UAAU,EAAE,mBAAmB;gBAC/B,GAAG,EAAE;oBACH,GAAG,4BAA4B,CAAC,OAAO,CAAC;oBACxC,GAAG,CAAC,UAAU;wBACZ,CAAC,CAAC;4BACE,mBAAmB,EAAE,KAAK;4BAC1B,cAAc,EAAE,KAAK;4BACrB,IAAI,EAAE,KAAK;4BACX,OAAO,EAAE,KAAK;4BACd,UAAU,EAAE,KAAK;4BACjB,MAAM,EAAE,KAAK;yBACd;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR;aAC8B;YACjC,SAAS;YACT,OAAO,EAAE,gBAAgB;YACzB,UAAU,EAAE,iBAAiB;YAC7B,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,EAAE,GAAG,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE;SAC7D;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n resolvePrimaryBranch,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: {\n url: string;\n prototypeDirectory: string;\n primaryBranch: string;\n };\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"0px\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const primaryBranch = resolvePrimaryBranch(options.primaryBranch);\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\n }\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch,\n remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n primaryBranch,\n });\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n ...(sourceRepository === undefined ? {} : { sourceRepository }),\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebay-dt/bonfire-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.0",
|
|
4
4
|
"description": "Next.js server integration for Bonfire.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ebay-dt/bonfire-core": "0.
|
|
35
|
-
"@ebay-dt/bonfire-node": "0.
|
|
34
|
+
"@ebay-dt/bonfire-core": "0.3.0-alpha.0",
|
|
35
|
+
"@ebay-dt/bonfire-node": "0.3.0-alpha.0",
|
|
36
36
|
"jose": "^6.1.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@ebay-dt/bonfire-react": "0.
|
|
39
|
+
"@ebay-dt/bonfire-react": "0.3.0-alpha.0",
|
|
40
40
|
"next": ">=16.2 <17",
|
|
41
41
|
"react": ">=19.2 <20",
|
|
42
42
|
"react-dom": ">=19.2 <20"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@ebay-dt/bonfire-react": "0.
|
|
45
|
+
"@ebay-dt/bonfire-react": "0.3.0-alpha.0",
|
|
46
46
|
"@repo/eslint-config": "0.0.0",
|
|
47
47
|
"@repo/typescript-config": "0.0.0",
|
|
48
48
|
"@types/node": "20.19.43",
|