Skip to content

Commit e1d183e

Browse files
committed
Agent Evals: Copy Firebase CLI configs in dev mode
1 parent a8c5f58 commit e1d183e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

scripts/agent-evals/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "tsc",
88
"test": "npm run build && mocha 'lib/**/*.spec.js' --reporter spec",
9-
"test:dev": "SKIP_REBUILD=true npm run test"
9+
"test:dev": "SKIP_REBUILD=true COPY_FIREBASE_CLI_CONFIG=true npm run test"
1010
},
1111
"keywords": [],
1212
"author": "",

scripts/agent-evals/src/runner/index.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from "node:path";
22
import { randomBytes } from "node:crypto";
3-
import { mkdirSync } from "node:fs";
3+
import { mkdirSync, copyFileSync } from "node:fs";
44
import { AgentTestRunner } from "./agent-test-runner.js";
55
import { GeminiCliRunner } from "./gemini-cli-runner.js";
66
import { buildFirebaseCli } from "./setup.js";
@@ -13,6 +13,10 @@ export * from "./agent-test-runner.js";
1313

1414
const dateName = new Date().toISOString().replace("T", "_").replace(/:/g, "-").replace(".", "-");
1515

16+
const FIREBASE_CONFIG_FILENAME = "firebase-tools.json";
17+
const CONFIGSTORE_DIR = ".config/configstore";
18+
const HOME_CONFIGSTORE_DIR = path.resolve(path.join(process.env.HOME || "", CONFIGSTORE_DIR));
19+
1620
export async function setupEnvironment(): Promise<void> {
1721
await buildFirebaseCli();
1822
await buildTemplates();
@@ -40,6 +44,13 @@ export async function startAgentTest(
4044
if (options?.templateName) {
4145
copyTemplate(options.templateName, dirs.runDir);
4246
}
47+
if (process.env.COPY_FIREBASE_CLI_CONFIG) {
48+
const toDir = path.resolve(dirs.userDir, CONFIGSTORE_DIR);
49+
console.log(
50+
`Copying Firebase CLI configs from ${HOME_CONFIGSTORE_DIR} to \n${toDir} so the test can use your auth credentials`,
51+
);
52+
copyFirebaseCliConfigstore(HOME_CONFIGSTORE_DIR, toDir);
53+
}
4354

4455
const run = new GeminiCliRunner(testName, dirs, options?.toolMocks || []);
4556
await run.waitForReadyPrompt();
@@ -65,3 +76,13 @@ function createRunDirectory(testName: string): RunDirectories {
6576

6677
return { testDir, runDir, userDir };
6778
}
79+
80+
function copyFirebaseCliConfigstore(fromDir: string, toDir: string) {
81+
const toDirResolved = path.resolve(toDir);
82+
mkdirSync(toDirResolved, { recursive: true });
83+
84+
copyFileSync(
85+
path.join(fromDir, FIREBASE_CONFIG_FILENAME),
86+
path.join(toDirResolved, FIREBASE_CONFIG_FILENAME),
87+
);
88+
}

0 commit comments

Comments
 (0)