Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bruno-build-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@usebruno/api-docs": patch
---

Expose the build's commit, branch, version and environment as `Bruno.build` in the browser console
1 change: 1 addition & 0 deletions packages/bruno-api-docs/src/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ if (typeof window !== 'undefined') {
globals.OpenCollection = OpenCollectionRenderer;
globals.Bruno = {
...globals.Bruno,
build: __BRUNO_BUILD__,
apiDocs: (target: HTMLElement, { content, repositoryUrl, gitCollectionUrl, ...options }: ApiDocsOptions) =>
new OpenCollectionRenderer({
target,
Expand Down
2 changes: 2 additions & 0 deletions packages/bruno-api-docs/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference types="vite/client" />

declare const __BRUNO_BUILD__: Record<'sha' | 'ref' | 'version' | 'env' | 'run' | 'built_at', string | null>;

declare module 'atob/node-atob' {
const atob: (input: string) => string;
export default atob;
Expand Down
12 changes: 11 additions & 1 deletion packages/bruno-api-docs/vite.config.standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { fileURLToPath } from 'node:url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

const build = {
sha: process.env.BUILD_SHA ?? null,
ref: process.env.BUILD_REF ?? null,
version: process.env.BUILD_VERSION ?? null,
env: process.env.BUILD_ENV ?? null,
run: process.env.BUILD_RUN ?? null,
built_at: process.env.BUILD_TIME ?? null
};

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
Expand All @@ -17,7 +26,8 @@ export default defineConfig({
react()
],
define: {
'process.env.NODE_ENV': '"production"'
'process.env.NODE_ENV': '"production"',
'__BRUNO_BUILD__': JSON.stringify(build)
},
build: {
lib: {
Expand Down
Loading