mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-28 04:32:35 -07:00
fix(workspaces): clean up distractors and fix ESM runtime errors
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import { spawnSync } from 'child_process';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { ProviderFactory } from './providers/ProviderFactory.ts';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
||||
|
||||
export async function runChecker(args: string[], env: NodeJS.ProcessEnv = process.env) {
|
||||
export async function runChecker(
|
||||
args: string[],
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
) {
|
||||
const prNumber = args[0];
|
||||
if (!prNumber) {
|
||||
console.error('Usage: npm run review:check <PR_NUMBER>');
|
||||
@@ -16,7 +24,7 @@ export async function runChecker(args: string[], env: NodeJS.ProcessEnv = proces
|
||||
|
||||
const settingsPath = path.join(REPO_ROOT, '.gemini/workspaces/settings.json');
|
||||
if (!fs.existsSync(settingsPath)) {
|
||||
console.error('❌ Settings not found. Run "npm run workspace:setup" first.');
|
||||
console.error('❌ Settings not found. Run "workspace setup" first.');
|
||||
return 1;
|
||||
}
|
||||
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
@@ -27,11 +35,21 @@ export async function runChecker(args: string[], env: NodeJS.ProcessEnv = proces
|
||||
}
|
||||
const { projectId, zone, remoteWorkDir } = config;
|
||||
const targetVM = `gcli-workspace-${env.USER || 'mattkorwel'}`;
|
||||
const provider = ProviderFactory.getProvider({ projectId, zone, instanceName: targetVM });
|
||||
const provider = ProviderFactory.getProvider({
|
||||
projectId,
|
||||
zone,
|
||||
instanceName: targetVM,
|
||||
});
|
||||
|
||||
console.log(`🔍 Checking remote status for PR #${prNumber} on ${targetVM}...`);
|
||||
console.log(
|
||||
`🔍 Checking remote status for PR #${prNumber} on ${targetVM}...`,
|
||||
);
|
||||
|
||||
const branchView = spawnSync('gh', ['pr', 'view', prNumber, '--json', 'headRefName', '-q', '.headRefName'], { shell: true });
|
||||
const branchView = spawnSync(
|
||||
'gh',
|
||||
['pr', 'view', prNumber, '--json', 'headRefName', '-q', '.headRefName'],
|
||||
{ shell: true },
|
||||
);
|
||||
const branchName = branchView.stdout.toString().trim();
|
||||
const logDir = `${remoteWorkDir}/${branchName}/.gemini/logs/review-${prNumber}`;
|
||||
|
||||
@@ -41,13 +59,20 @@ export async function runChecker(args: string[], env: NodeJS.ProcessEnv = proces
|
||||
console.log('\n--- Task Status ---');
|
||||
for (const task of tasks) {
|
||||
const exitFile = `${logDir}/${task}.exit`;
|
||||
const checkExit = await provider.getExecOutput(`[ -f ${exitFile} ] && cat ${exitFile}`, { wrapContainer: 'maintainer-worker' });
|
||||
|
||||
const checkExit = await provider.getExecOutput(
|
||||
`[ -f ${exitFile} ] && cat ${exitFile}`,
|
||||
{ wrapContainer: 'maintainer-worker' },
|
||||
);
|
||||
|
||||
if (checkExit.status === 0 && checkExit.stdout.trim()) {
|
||||
const code = checkExit.stdout.trim();
|
||||
console.log(` ${code === '0' ? '✅' : '❌'} ${task.padEnd(10)}: ${code === '0' ? 'SUCCESS' : `FAILED (exit ${code})`}`);
|
||||
console.log(
|
||||
` ${code === '0' ? '✅' : '❌'} ${task.padEnd(10)}: ${code === '0' ? 'SUCCESS' : `FAILED (exit ${code})`}`,
|
||||
);
|
||||
} else {
|
||||
const checkRunning = await provider.exec(`[ -f ${logDir}/${task}.log ]`, { wrapContainer: 'maintainer-worker' });
|
||||
const checkRunning = await provider.exec(`[ -f ${logDir}/${task}.log ]`, {
|
||||
wrapContainer: 'maintainer-worker',
|
||||
});
|
||||
if (checkRunning === 0) {
|
||||
console.log(` ⏳ ${task.padEnd(10)}: RUNNING`);
|
||||
} else {
|
||||
@@ -58,9 +83,13 @@ export async function runChecker(args: string[], env: NodeJS.ProcessEnv = proces
|
||||
}
|
||||
|
||||
if (allDone) {
|
||||
console.log('\n✨ All remote tasks complete. You can now synthesize the results.');
|
||||
console.log(
|
||||
'\n✨ All remote tasks complete. You can now synthesize the results.',
|
||||
);
|
||||
} else {
|
||||
console.log('\n⏳ Some tasks are still in progress. Check again in a few minutes.');
|
||||
console.log(
|
||||
'\n⏳ Some tasks are still in progress. Check again in a few minutes.',
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user