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
28 changes: 28 additions & 0 deletions src/firebase_studio/migrate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

describe("extractMetadata", () => {
beforeEach(() => {
sandbox.stub(fs, "readFile").callsFake(async (p: any) => {

Check warning on line 26 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const pStr = p.toString();

Check warning on line 27 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 27 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .toString on an `any` value

Check warning on line 27 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
if (pStr.endsWith("metadata.json")) {

Check warning on line 28 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 28 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .endsWith on an `any` value
return JSON.stringify({ projectId: "original-project" });
}
if (pStr.endsWith("blueprint.md")) {

Check warning on line 31 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 31 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .endsWith on an `any` value
return "# **App Name**: Test App";
}
return "";
Expand All @@ -54,13 +54,14 @@

let listBackendsStub: sinon.SinonStub;
let commandStub: sinon.SinonStub;
let selectStub: sinon.SinonStub;
let trackStub: sinon.SinonStub;
let confirmStub: sinon.SinonStub;
let unlinkStub: sinon.SinonStub;
let spawnStub: sinon.SinonStub;

beforeEach(() => {
sandbox.stub(fs, "stat").resolves({ isDirectory: () => true } as any);

Check warning on line 64 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 64 in src/firebase_studio/migrate.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Stats | BigIntStats | undefined`
const cp = require("child_process");
sandbox.stub(cp, "spawnSync").returns({ status: 0 });
sandbox.stub(process, "platform").value("darwin");
Expand Down Expand Up @@ -115,6 +116,7 @@
commandStub = sandbox.stub(utils, "commandExistsSync").returns(false);
trackStub = sandbox.stub(track, "trackGA4").resolves();
confirmStub = sandbox.stub(prompt, "confirm").resolves(true);
selectStub = sandbox.stub(prompt, "select").resolves("local");

const childProcess = require("child_process");
spawnStub = sandbox.stub(childProcess, "spawn").returns({
Expand Down Expand Up @@ -474,6 +476,32 @@
expect(launchJsonCall).to.be.undefined;
});

it("should install skills globally if the user chooses global", async () => {
selectStub.resolves("global");

await migrate(testRoot);

const cp = require("child_process");
expect(
(cp.spawnSync as sinon.SinonStub).calledWith(
"npx",
[
"-y",
"skills",
"add",
"firebase/agent-skills",
"-a",
"gemini-cli",
"--skill",
"*",
"-y",
"-g",
],
sinon.match.any,
),
).to.be.true;
});

it("should detect antigravity command if agy is missing", async () => {
commandStub.withArgs("agy").returns(false);
commandStub.withArgs("antigravity").returns(true);
Expand Down
41 changes: 30 additions & 11 deletions src/firebase_studio/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,38 @@ async function injectAntigravityContext(
await fs.mkdir(skillsDir, { recursive: true });

// Add Skills using npx
const installLocation = await prompt.select({
message: "Where would you like to install Firebase project skills?",
choices: [
{ name: "Locally in the project", value: "local" },
{ name: "Globally for all projects", value: "global" },
],
default: "local",
nonInteractive: process.env.NODE_ENV === "test",
});

logger.info("⏳ Adding Antigravity skills...");
try {
const result = spawnSync(
"npx",
// gemini-CLI is chosen as a workaround for the .agents subfolder (instead of .agent)
// which is current for antigravity's location from vercel.
["-y", "skills", "add", "firebase/agent-skills", "-a", "gemini-cli", "--skill", "*", "-y"],
{
cwd: rootPath,
stdio: "ignore",
shell: process.platform === "win32",
},
);
const args = [
"-y",
"skills",
"add",
"firebase/agent-skills",
"-a",
"gemini-cli",
"--skill",
"*",
"-y",
];
if (installLocation === "global") {
args.push("-g");
}

const result = spawnSync("npx", args, {
cwd: rootPath,
stdio: "ignore",
shell: process.platform === "win32",
});
if (result.error) {
throw result.error;
}
Expand Down
Loading