-
Notifications
You must be signed in to change notification settings - Fork 7
feat: update libs #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: update libs #276
Changes from all commits
a910d2b
eb7d39e
cbe4562
a13f3f1
719bf26
6dcf95e
986502b
a1044ec
2f1aa32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,3 @@ enableGlobalCache: false | |
| httpTimeout: 100000 | ||
|
|
||
| nodeLinker: node-modules | ||
|
|
||
| yarnPath: .yarn/releases/yarn-4.1.1.cjs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "lerna": "^6.6.1", | ||
| "rimraf": "^5.0.5" | ||
| "lerna": "^9.0.7", | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,6 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "rimraf": "^5.0.5" | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "lerna": "^6.6.1", | ||
| "rimraf": "^5.0.5" | ||
| "lerna": "^9.0.7", | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,6 @@ | |
| "@sofie-package-manager/api": "1.53.0" | ||
| }, | ||
| "devDependencies": { | ||
| "rimraf": "^5.0.5" | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,8 @@ | ||||||||||||||||||||||||||||
| import Koa from 'koa' | ||||||||||||||||||||||||||||
| import Router from 'koa-router' | ||||||||||||||||||||||||||||
| import type { RouterContext } from '@koa/router' | ||||||||||||||||||||||||||||
| import { Readable, Writable } from 'stream' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export type CTX = Koa.ParameterizedContext<any, Router.IRouterParamContext<any, any>> | ||||||||||||||||||||||||||||
| export type CTXPost = Koa.ParameterizedContext<any, Router.IRouterParamContext<any, any>> | ||||||||||||||||||||||||||||
| export type CTX = RouterContext<any, any> | ||||||||||||||||||||||||||||
| export type CTXPost = RouterContext<any, any> | ||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In @koa/router 15.x (koajs/router) the exported RouterContext<StateT = DefaultState, ContextT = DefaultContext, BodyT = unknown>and route params are not generic—they’re typed as Recommended typing (avoid import Router, { type RouterContext } from '@koa/router';
type AppState = { user?: { id: string } };
type AppContext = { requestId: string }; // whatever you add via declaration merging, etc.
const router = new Router<AppState, AppContext>();
router.get('/users/:id', async (ctx: RouterContext<AppState, AppContext>) => {
// ctx.state is AppState
// ctx is AppContext & router additions
// ctx.params.id is string (Record<string, string>)
const id = ctx.params.id;
});If you need strongly-typed param keys (e.g. Sources: Citations: 🏁 Script executed: # First, check the package.json for version info
find . -name "package.json" -path "*/http-server/*" | head -5Repository: Sofie-Automation/sofie-package-manager Length of output: 166 🏁 Script executed: # Search for usage of CTX and CTXPost in the codebase
rg "CTX|CTXPost" --type ts --type tsx -B 2 -A 2Repository: Sofie-Automation/sofie-package-manager Length of output: 109 🏁 Script executed: # Look for any custom context or state type definitions
rg "type.*Context|type.*State" --type ts --type tsx | head -20Repository: Sofie-Automation/sofie-package-manager Length of output: 109 🏁 Script executed: # Check package.json for koa and `@koa/router` versions
cat apps/http-server/packages/generic/package.json | grep -A 2 -B 2 "koa\|router"Repository: Sofie-Automation/sofie-package-manager Length of output: 529 🏁 Script executed: # Search for CTX and CTXPost usage without file type
rg "CTX|CTXPost" -B 2 -A 2Repository: Sofie-Automation/sofie-package-manager Length of output: 4014 🏁 Script executed: # Check the lib.ts file itself
cat -n apps/http-server/packages/generic/src/lib.tsRepository: Sofie-Automation/sofie-package-manager Length of output: 838 🏁 Script executed: # Verify that DefaultState and DefaultContext are available from 'koa' types
cat apps/http-server/packages/generic/package.json | grep -A 5 "@types/koa"Repository: Sofie-Automation/sofie-package-manager Length of output: 318 🏁 Script executed: # Quick check of `@types/koa` to confirm DefaultState/DefaultContext exports
find . -name "*.json" -path "*@types/koa*" 2>/dev/null | head -3Repository: Sofie-Automation/sofie-package-manager Length of output: 64 🏁 Script executed: # Check what's imported from 'koa' or '@koa/router' in the broader codebase to see patterns
rg "from ['\"](koa|@koa)" --type ts | head -15Repository: Sofie-Automation/sofie-package-manager Length of output: 983 🏁 Script executed: # Check if there are any custom context/state type definitions in the http-server packages
rg "interface|type.*Context|type.*State" apps/http-server/packages/generic/src --type ts -A 1 | head -25Repository: Sofie-Automation/sofie-package-manager Length of output: 822 Avoid exporting Lines 4–5 currently erase handler context typing across the package. Use Koa's standard ♻️ Proposed typing fix import type { RouterContext } from '@koa/router'
+import type { DefaultContext, DefaultState } from 'koa'
import { Readable, Writable } from 'stream'
-export type CTX = RouterContext<any, any>
-export type CTXPost = RouterContext<any, any>
+export type CTX = RouterContext<DefaultState, DefaultContext>
+export type CTXPost = RouterContext<DefaultState, DefaultContext>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export async function asyncPipe(readable: Readable, writable: Writable): Promise<void> { | ||||||||||||||||||||||||||||
| return new Promise((resolve) => { | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { promisify } from 'util' | |
| import fs from 'fs' | ||
| import Koa from 'koa' | ||
| import path from 'path' | ||
| import Router from 'koa-router' | ||
| import Router from '@koa/router' | ||
| import cors from '@koa/cors' | ||
| import { bodyParser } from '@koa/bodyparser' | ||
|
|
||
|
|
@@ -61,7 +61,7 @@ export class PackageProxyServer { | |
| await this._setUpRoutes() | ||
| } | ||
| private async _setUpRoutes(): Promise<void> { | ||
| this.router.all('(.*)', async (ctx, next) => { | ||
| this.router.all('{/*path}', async (ctx, next) => { | ||
| // Intercept and authenticate: | ||
|
|
||
| const apiKey: string | undefined = | ||
|
|
@@ -95,13 +95,13 @@ export class PackageProxyServer { | |
| this.router.get('/list', async (ctx) => { | ||
| await this.handleStorageHTMLList(ctx, async () => this.storage.listPackages()) | ||
| }) | ||
| this.router.get('/package/:path+', async (ctx) => { | ||
| this.router.get('/package/*path', async (ctx) => { | ||
| await this.handleStorage(ctx, async () => this.storage.getPackage(ctx.params.path)) | ||
| }) | ||
| this.router.head('/package/:path+', async (ctx) => { | ||
| this.router.head('/package/*path', async (ctx) => { | ||
| await this.handleStorage(ctx, async () => this.storage.headPackage(ctx.params.path)) | ||
| }) | ||
| this.router.post('/package/:path+', async (ctx) => { | ||
| this.router.post('/package/*path', async (ctx) => { | ||
| this.logger.debug(`POST ${ctx.request.URL}`) | ||
|
Comment on lines
+98
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In @koa/router v15+, a named wildcard (“splat”) parameter must be wrapped in braces:
The README’s example is 🏁 Script executed: # Check `@koa/router` version and related dependencies
find . -name "package.json" -type f | head -5 | xargs grep -l "@koa/router\|koa.*router" 2>/dev/nullRepository: Sofie-Automation/sofie-package-manager Length of output: 66 🏁 Script executed: # Locate the server.ts file
find . -path "*/apps/http-server/packages/generic/src/server.ts" -type fRepository: Sofie-Automation/sofie-package-manager Length of output: 131 🏁 Script executed: # Find package.json in the http-server package directory
find ./apps/http-server -name "package.json" -type fRepository: Sofie-Automation/sofie-package-manager Length of output: 166 🏁 Script executed: # Read the server.ts file at the relevant lines
sed -n '95,110p; 123,128p; 137,142p' ./apps/http-server/packages/generic/src/server.tsRepository: Sofie-Automation/sofie-package-manager Length of output: 1159 🏁 Script executed: # Check `@koa/router` version in the package.json
grep -A2 -B2 "@koa/router" ./apps/http-server/packages/generic/package.jsonRepository: Sofie-Automation/sofie-package-manager Length of output: 226 Update wildcard route patterns to Routes at lines 98, 101, 104, 126, and 140 use 🔧 Proposed route-pattern fix- this.router.get('/package/*path', async (ctx) => {
+ this.router.get('/package/{/*path}', async (ctx) => {
await this.handleStorage(ctx, async () => this.storage.getPackage(ctx.params.path))
})
- this.router.head('/package/*path', async (ctx) => {
+ this.router.head('/package/{/*path}', async (ctx) => {
await this.handleStorage(ctx, async () => this.storage.headPackage(ctx.params.path))
})
- this.router.post('/package/*path', async (ctx) => {
+ this.router.post('/package/{/*path}', async (ctx) => {
this.logger.debug(`POST ${ctx.request.URL}`)
const { files, fields } = await parseFormData(ctx.req, {
maxFileByteLength: MAX_UPLOAD_FILE_SIZE,
@@
- this.router.delete('/package/*path', async (ctx) => {
+ this.router.delete('/package/{/*path}', async (ctx) => {
this.logger.debug(`DELETE ${ctx.request.URL}`)
await this.handleStorage(ctx, async () => this.storage.deletePackage(ctx.params.path))
})
@@
- this.router.get('/uploadForm/*path', async (ctx) => {
+ this.router.get('/uploadForm/{/*path}', async (ctx) => {
// ctx.response.status = result.code
ctx.type = 'text/html'
ctx.body = (await fsReadFile(path.resolve('../static/uploadForm.html'), 'utf-8'))🤖 Prompt for AI Agents |
||
| const { files, fields } = await parseFormData(ctx.req, { | ||
| maxFileByteLength: MAX_UPLOAD_FILE_SIZE, | ||
|
|
@@ -123,7 +123,7 @@ export class PackageProxyServer { | |
| } | ||
| } | ||
| }) | ||
| this.router.delete('/package/:path+', async (ctx) => { | ||
| this.router.delete('/package/*path', async (ctx) => { | ||
| this.logger.debug(`DELETE ${ctx.request.URL}`) | ||
| await this.handleStorage(ctx, async () => this.storage.deletePackage(ctx.params.path)) | ||
| }) | ||
|
|
@@ -137,7 +137,7 @@ export class PackageProxyServer { | |
| info: this.storage.getInfo(), | ||
| } | ||
| }) | ||
| this.router.get('/uploadForm/:path+', async (ctx) => { | ||
| this.router.get('/uploadForm/*path', async (ctx) => { | ||
| // ctx.response.status = result.code | ||
| ctx.type = 'text/html' | ||
| ctx.body = (await fsReadFile(path.resolve('../static/uploadForm.html'), 'utf-8')) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "lerna": "^6.6.1", | ||
| "rimraf": "^5.0.5" | ||
| "lerna": "^9.0.7", | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "lerna": "^6.6.1", | ||
| "rimraf": "^5.0.5" | ||
| "lerna": "^9.0.7", | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import Koa from 'koa' | ||
| import Router from 'koa-router' | ||
| import Router from '@koa/router' | ||
| import cors from '@koa/cors' | ||
| import range from 'koa-range' | ||
| import ratelimit from 'koa-ratelimit' | ||
|
|
@@ -69,7 +69,7 @@ export class QuantelHTTPTransformerProxy { | |
| }) | ||
|
|
||
| // Proxy | ||
| this.router.get('/(quantel|gv)/(.*)', async (ctx) => { | ||
| this.router.get(['/quantel{/*rest}', '/gv{/*rest}'], async (ctx) => { | ||
| try { | ||
| // this.logger.debug(`Pass-through requests to transformer: ${ctx.path}`) | ||
| if (!this.transformerURL) { | ||
|
|
@@ -120,7 +120,7 @@ export class QuantelHTTPTransformerProxy { | |
| } | ||
| } | ||
| }) | ||
| this.router.get('/(.*)', async (ctx, next) => { | ||
| this.router.get('{/*path}', async (ctx, next) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for similar route patterns in other files to ensure consistency
echo "=== Checking route patterns in http-server and similar apps ==="
rg -n --type ts '@koa/router|{/\*' apps/Repository: Sofie-Automation/sofie-package-manager Length of output: 266 🏁 Script executed: #!/bin/bash
# First, find the server.ts file and examine the routes around line 123
echo "=== Locating server.ts ==="
fd -n "server.ts" apps/quantel-http-transformer-proxy/
echo "=== Examining routes in server.ts ==="
cat -n apps/quantel-http-transformer-proxy/packages/generic/src/server.ts | sed -n '110,135p'
echo "=== Checking package.json for dependencies ==="
cat apps/quantel-http-transformer-proxy/package.json | grep -A5 -B5 "path-to-regexp\|@koa"Repository: Sofie-Automation/sofie-package-manager Length of output: 1527 🏁 Script executed: #!/bin/bash
# Search for similar route patterns more carefully
echo "=== Checking for router.get patterns with catch-all routes ==="
rg -n "router\.(get|post|put|delete)" apps/quantel-http-transformer-proxy/ -A1 -t ts | head -50
echo "=== Checking for Koa router usage patterns ==="
rg -n "@koa/router|new Router" apps/ -t ts | head -20Repository: Sofie-Automation/sofie-package-manager Length of output: 1425 🏁 Script executed: #!/bin/bash
# Check for package.json files in the quantel-http-transformer-proxy
echo "=== Finding package.json files ==="
find apps/quantel-http-transformer-proxy -name "package.json" -type f
# Check the root package.json for dependencies
echo "=== Root package.json dependencies ==="
rg -A2 -B2 "@koa/router|path-to-regexp" package.json
# Check if there are any test files that demonstrate route patterns
echo "=== Looking for test files with router patterns ==="
find apps/quantel-http-transformer-proxy -name "*.test.ts" -o -name "*.spec.ts" | head -10Repository: Sofie-Automation/sofie-package-manager Length of output: 393 🏁 Script executed: #!/bin/bash
# Look at the full context of the server.ts file to understand the router setup
echo "=== Full route definitions in server.ts ==="
rg -n "router\.(get|post|put|delete)" apps/quantel-http-transformer-proxy/packages/generic/src/server.ts -B1 -A3
# Check if there's documentation or comments about the route pattern
echo "=== Search for any comments about route patterns ==="
rg -n "catch.all|{/\*|path\}" apps/quantel-http-transformer-proxy/ -t ts -B2 -A2Repository: Sofie-Automation/sofie-package-manager Length of output: 950 🏁 Script executed: #!/bin/bash
# Check package versions
echo "=== Checking `@koa/router` and dependencies in packages/generic/package.json ==="
cat apps/quantel-http-transformer-proxy/packages/generic/package.json | grep -A50 "dependencies"
echo "=== Checking `@koa/router` and dependencies in app/package.json ==="
cat apps/quantel-http-transformer-proxy/app/package.json | grep -A50 "dependencies"Repository: Sofie-Automation/sofie-package-manager Length of output: 1633 🏁 Script executed: #!/bin/bash
# Check the test file to see how routes are tested
echo "=== Examining test file ==="
cat -n apps/quantel-http-transformer-proxy/app/src/__tests__/test.spec.ts | head -100Repository: Sofie-Automation/sofie-package-manager Length of output: 344 🌐 Web query:
💡 Result: In @koa/router v15 (uses path-to-regexp v8), the catch-all is a named wildcard (you can’t use a bare
Why Sources [1] Citations:
🌐 Web query:
💡 Result: In current path-to-regexp (v6+), the old Zero or more path segments (the “ /files{/*path}This matches:
and For comparison, one or more segments is just a wildcard: /*path(which does not match Citations:
🌐 Web query:
💡 Result: In @koa/router v15 (uses path-to-regexp v8), the So:
Citations:
🏁 Script executed: #!/bin/bash
# Check if there are similar catch-all patterns in the codebase
echo "=== Searching for catch-all route patterns ==="
rg -n "router\.(get|post|all)" apps/ -t ts | rg "{/\*|/\*" | head -20
# Check http-server app for comparison
echo "=== Checking http-server for route patterns ==="
rg -n "router\.(get|post|all)" apps/http-server/ -t ts -A1 | head -40Repository: Sofie-Automation/sofie-package-manager Length of output: 1923 Change catch-all route pattern from The pattern Note: The http-server app also uses this same incorrect pattern on line 64 and should be corrected as well. 🤖 Prompt for AI Agents |
||
| const url = `${this.transformerURL}${ctx.path}` + (ctx.querystring ? `?${ctx.querystring}` : '') | ||
| try { | ||
| const initReq = await got(url, { responseType: 'buffer' }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ | |
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "lerna": "^6.6.1", | ||
| "rimraf": "^5.0.5" | ||
| "lerna": "^9.0.7", | ||
| "rimraf": "^6.1.3" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Sofie-Automation/sofie-package-manager
Length of output: 389
🏁 Script executed:
cat -n apps/http-server/app/package.json | head -40Repository: Sofie-Automation/sofie-package-manager
Length of output: 1201
🏁 Script executed:
Repository: Sofie-Automation/sofie-package-manager
Length of output: 828
Move
rimraffromdependenciestodevDependencies.Line 15 places
rimrafindependencies, but it is used only in the build script (line 7:"build": "yarn rimraf dist ..."), not at runtime. The sibling package (packages/generic) correctly places the same tool indevDependencies. This unnecessarily addsrimrafto the production install surface.Adjustment
"dependencies": { - "@http-server/generic": "1.53.0", - "rimraf": "^6.1.3" + "@http-server/generic": "1.53.0" }, @@ "devDependencies": { - "lerna": "^9.0.7" + "lerna": "^9.0.7", + "rimraf": "^6.1.3" }Also applies to: 30-30
🤖 Prompt for AI Agents