From 5a18653c6911dcb9bbe48f9b5e1148c0dd9cf1af Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Wed, 13 May 2026 13:29:25 -0500 Subject: [PATCH] Changed the framework so that apps out of the box come with the Bridgeman Accessible Web Components library (which if not used introduces little latency but if used provide large value) --- .forgejo/workflows/publish.yml | 9 +++++---- package.json | 1 + src/App.ts | 12 +++++++++--- src/oauth/OAuthApp.ts | 7 +++---- yarn.lock | 18 ++++++++++++++++++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml index febfa5f..c7dac70 100644 --- a/.forgejo/workflows/publish.yml +++ b/.forgejo/workflows/publish.yml @@ -9,7 +9,8 @@ on: jobs: publish: runs-on: default - #runs-on: self-hosted + env: + PRIVATE_NPM_REGISTRY: 'https://npm.pkg.bridgemanaccessible.ca' steps: # Checkout the repository @@ -36,7 +37,7 @@ jobs: # > Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, # > and set up auth to read in from env.NODE_AUTH_TOKEN. # > Default: '' - registry-url: 'https://npm.pkg.bridgemanaccessible.ca' + registry-url: ${{ env.PRIVATE_NPM_REGISTRY }} # Taken from [Repo README](https://github.com/actions/setup-node#readme) # @@ -68,7 +69,7 @@ jobs: echo "Version: $VERSION" NAME=$(node -p "require('./package.json').name") - LATEST_VERSION=$(npm show $NAME version --registry https://npm.pkg.bridgemanaccessible.ca) + LATEST_VERSION=$(npm show $NAME version --registry ${{ env.PRIVATE_NPM_REGISTRY }} 2>/dev/null || echo "0.0.0") echo "Latest version: $LATEST_VERSION" if [ "$LATEST_VERSION" != "$VERSION" ]; then @@ -109,4 +110,4 @@ jobs: cd dist # Publish the package to the private NPM registry - npm publish --registry http://npm.pkg.bridgemanaccessible.ca/ \ No newline at end of file + npm publish --registry ${{ env.PRIVATE_NPM_REGISTRY }} \ No newline at end of file diff --git a/package.json b/package.json index b327858..56e8bbd 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "dependencies": { "@BridgemanAccessible/ba-auth": "^1.0.52", "@BridgemanAccessible/ba-logging": "^1.0.2", + "@BridgemanAccessible/ba-web-components": "^1.0.0", "express": "^4.19.2", "fs-extra": "^11.2.0", "jsdom": "^24.1.0", diff --git a/src/App.ts b/src/App.ts index 2b0db1f..ff03a7a 100644 --- a/src/App.ts +++ b/src/App.ts @@ -1,6 +1,7 @@ import 'reflect-metadata'; -import type { Application } from 'express'; +import type { RequestHandler } from 'express'; +import useComponentsLibrary from '@BridgemanAccessible/ba-web-components'; import { logMessage, LogLevel } from '@BridgemanAccessible/ba-logging'; import { Initializer } from './Initializer.js'; @@ -30,7 +31,7 @@ export class App { * The main entry point for the web app * This is mostly required because of async/await */ - async run(initializer?: T, callback?: (app: App) => void | Promise, onErrorCallback?: (error: any) => void | Promise) { + async run(initializer?: T, callback?: (app: App) => void | Promise, onErrorCallback?: (error: any) => void | Promise, includeComponentLibrary: boolean = true): Promise { // Do the initial setup of the app if(typeof initializer !== 'undefined') { this.initializer = initializer; @@ -41,11 +42,16 @@ export class App { await this.initializer.init(); + if(includeComponentLibrary) { + const componentsLibraryMiddleware = await useComponentsLibrary({ expressApp: this.getExpressApp() }) as RequestHandler; + this.getExpressApp().use(componentsLibraryMiddleware); + } + // Start the server const port = process.env.PORT || this.DEFAULT_PORT; this.getExpressApp().listen(port, async () => { logMessage(`Server is running on port ${port}`, LogLevel.DEBUG); - + // Run the callback if one is provided if(typeof callback !== 'undefined') { await callback.bind(this)(this); diff --git a/src/oauth/OAuthApp.ts b/src/oauth/OAuthApp.ts index dcd613f..dba39f4 100644 --- a/src/oauth/OAuthApp.ts +++ b/src/oauth/OAuthApp.ts @@ -1,5 +1,3 @@ -import axios from 'axios'; - import { Scopes } from '@BridgemanAccessible/ba-auth'; import Client from '@BridgemanAccessible/ba-auth/client'; import type { OnAuthCallback } from '@BridgemanAccessible/ba-auth/client'; @@ -321,6 +319,7 @@ export class OAuthApp) => void | Promise) { try { @@ -370,7 +369,7 @@ export class OAuthApp(initializer?: T, callback?: (app: OAuthApp) => void | Promise) { - await super.run(initializer, async (app: App) => this.onStart(app, callback)); + async run(initializer?: T, callback?: (app: OAuthApp) => void | Promise, onErrorCallback?: (error: any) => void | Promise, includeComponentLibrary: boolean = true): Promise { + await super.run(initializer, async (app: App) => this.onStart(app, callback), onErrorCallback, includeComponentLibrary); } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 5f7893c..42c5ef5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,6 +44,14 @@ axios "^1.8.4" express "^4.21.2" +"@BridgemanAccessible/ba-web-components@^1.0.0": + version "1.0.0" + resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-web-components/-/ba-web-components-1.0.0.tgz#66d7f2ff68983bbdc2ed7d2252c232d768d6c928" + integrity sha512-wJ/nEh0J+wDQsYZkZFM58D74tmsJ5AYvaqVX4V6hBBPSbPu8mmkLH2fdb2Qn6mQi8lAV1xmuc/olSg0S82tujQ== + dependencies: + ejs "^5.0.2" + open-props "2.0.0-beta.5" + "@asamuzakjp/css-color@^3.2.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@asamuzakjp/css-color/-/css-color-3.2.0.tgz#cc42f5b85c593f79f1fa4f25d2b9b321e61d1794" @@ -506,6 +514,11 @@ ejs@^3.1.9: dependencies: jake "^10.8.5" +ejs@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-5.0.2.tgz#cb8a7922ec1e71193b2507942250e230e200de79" + integrity sha512-IpbUaI/CAW86l3f+T8zN0iggSc0LmMZLcIW5eRVStLVNCoTXkE0YlncbbH50fp8Cl6zHIky0sW2uUbhBqGw0Jw== + encodeurl@^2.0.0, encodeurl@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-2.0.0.tgz#7b8ea898077d7e409d3ac45474ea38eaf0857a58" @@ -1039,6 +1052,11 @@ once@^1.4.0: dependencies: wrappy "1" +open-props@2.0.0-beta.5: + version "2.0.0-beta.5" + resolved "https://registry.yarnpkg.com/open-props/-/open-props-2.0.0-beta.5.tgz#9885e32640ba342fa500e78aa9f7fc1d92d9b5b0" + integrity sha512-Ahq2/q6T+0kzI9Lwt3f8CX6l0IQxqKYkeMi4u09gdFkFmxB1gYuSwqg2xd5nVN1zEYtUN93V0DbQRoDsP3OSmw== + pako@^2.0.4: version "2.1.0" resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"