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
6 changes: 6 additions & 0 deletions apps/website/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
]
},
"e2e": {
"executor": "nx:run-commands",
"options": {
"command": "npx tsx apps/website/scripts/run-e2e-with-next-env-restore.ts -- npx nx run website:e2e-playwright --skip-nx-cache"
}
},
"e2e-playwright": {
"executor": "@nx/playwright:playwright",
"options": {
"config": "apps/website/playwright.config.ts"
Expand Down
48 changes: 48 additions & 0 deletions apps/website/scripts/run-e2e-with-next-env-restore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { spawn } from 'node:child_process';
import { writeFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';

const CANONICAL_NEXT_ENV = `/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./../../dist/apps/website/.next/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
`;

async function restoreNextEnv(): Promise<void> {
await writeFile(new URL('../next-env.d.ts', import.meta.url), CANONICAL_NEXT_ENV);
Comment on lines +5 to +14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded constant works today, but will silently restore stale content if next-env.d.ts is legitimately updated (e.g., a Next.js upgrade regenerates the routes import path). A snapshot-then-restore pattern is more resilient:

Suggested change
const CANONICAL_NEXT_ENV = `/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./../../dist/apps/website/.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
`;
async function restoreNextEnv(): Promise<void> {
await writeFile(new URL('../next-env.d.ts', import.meta.url), CANONICAL_NEXT_ENV);
async function restoreNextEnv(): Promise<void> {
await writeFile(new URL('../next-env.d.ts', import.meta.url), CANONICAL_NEXT_ENV);
}

Suggested alternative for the full file — read then restore:

import { readFile, writeFile } from 'node:fs/promises';

async function main(): Promise<void> {
  const nextEnvUrl = new URL('../next-env.d.ts', import.meta.url);
  const originalContent = await readFile(nextEnvUrl, 'utf8');
  // ... run ...
  try {
    exitCode = await run(command, args);
  } finally {
    await writeFile(nextEnvUrl, originalContent);
  }
}

This would automatically track whatever git-committed content the file had at test start. Minor maintainability note, not a blocker.

}

function run(command: string, args: string[]): Promise<number | null> {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { stdio: 'inherit' });
child.on('error', reject);
child.on('close', (code) => resolve(code));
});
}

async function main(): Promise<void> {
const separator = process.argv.indexOf('--');
const commandLine = separator === -1 ? process.argv.slice(2) : process.argv.slice(separator + 1);
const [command, ...args] = commandLine;

if (!command) {
throw new Error('Expected a command after --');
}

let exitCode: number | null = 1;
try {
exitCode = await run(command, args);
} finally {
await restoreNextEnv();
}
process.exitCode = exitCode ?? 1;
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
}
3 changes: 2 additions & 1 deletion libs/middleware/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class FakeModel {
bound: unknown[] = [];
private turn = 0;
bindTools(tools: unknown[]) { this.bound = tools; return this; }
async invoke(_messages: unknown[]) {
async invoke(messages: unknown[]) {
void messages;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unconventional suppression: void messages evaluates the expression and discards the result to satisfy the linter, but it's surprising to readers. The idiomatic TypeScript convention is the _ prefix:

Suggested change
void messages;
async invoke(_messages: unknown[]) {

If the project's ESLint rule triggers on _-prefixed params specifically, adding // eslint-disable-next-line @typescript-eslint/no-unused-vars would be more explicit. Using void as a statement may also conflict with a no-void rule in other files. Nit only.

this.turn += 1;
if (this.turn === 1) {
return new AIMessage({ content: '', tool_calls: [{ name: 'get_weather', args: { city: 'SF' }, id: 'call_1' }] });
Expand Down
8 changes: 4 additions & 4 deletions libs/telemetry/src/node/postinstall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('postinstall script', () => {
await expect(
capturePostinstallScript({
readPackageJson: () => { throw new Error('not found'); },
write: (_s: string) => undefined,
write: () => undefined,
env: { ...process.env },
cwd: () => '/tmp/project/node_modules/@threadplane/telemetry',
}),
Expand All @@ -103,7 +103,7 @@ describe('postinstall script', () => {
test('skips local top-level installs by default', async () => {
await capturePostinstallScript({
readPackageJson: () => ({ name: '@threadplane/chat', version: '0.0.31' }),
write: (_s: string) => undefined,
write: () => undefined,
env: { ...process.env, INIT_CWD: '/repo/libs/chat' },
cwd: () => '/repo/libs/chat',
});
Expand All @@ -118,7 +118,7 @@ describe('postinstall script', () => {
symlinkSync(root, link, 'dir');
await capturePostinstallScript({
readPackageJson: () => ({ name: '@threadplane/chat', version: '0.0.31' }),
write: (_s: string) => undefined,
write: () => undefined,
env: { ...process.env, INIT_CWD: join(link, 'pkg') },
cwd: () => join(root, 'pkg'),
});
Expand All @@ -132,7 +132,7 @@ describe('postinstall script', () => {
test('allows global installs even when INIT_CWD matches cwd', async () => {
await capturePostinstallScript({
readPackageJson: () => ({ name: '@threadplane/chat', version: '0.0.31' }),
write: (_s: string) => undefined,
write: () => undefined,
env: { ...process.env, INIT_CWD: '/repo/libs/chat', npm_config_global: 'true' },
cwd: () => '/repo/libs/chat',
});
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@angular/elements": "~21.1.0",
"@angular/language-service": "~21.1.0",
"@anthropic-ai/sdk": "^0.79.0",
"@copilotkit/aimock": "^1.23.0",
"@copilotkit/aimock": "^1.35.1",
"@eslint/js": "^9.8.0",
"@json-render/core": "^0.16.0",
"@langchain/langgraph": "^1.4.2",
Expand Down
Loading