mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
Merge PR #4776
This commit is contained in:
commit
3c1ff71204
2 files changed
+20
-7
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* `npx @claude-flow/cli@latest <subcommand>` in Claude settings has the same
|
||||
* cold-process cost, not only the historical `hooks` form.
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
@@ -15,7 +15,6 @@ type HealthCheck = { name: string; status: 'pass' | 'warn' | 'fail'; message: st
|
||||
type DoctorData = { results: HealthCheck[] };
|
||||
|
||||
const ORIGINAL_CWD = process.cwd();
|
||||
const ORIGINAL_HOME = process.env.HOME;
|
||||
let workdir: string;
|
||||
|
||||
async function runStaleSettingsCheck(): Promise<HealthCheck> {
|
||||
@@ -38,13 +37,13 @@ describe('doctor #2677 — stale npx detection covers every subcommand', () => {
|
||||
workdir = mkdtempSync(join(tmpdir(), 'doctor-2677-settings-'));
|
||||
process.chdir(workdir);
|
||||
// Keep the test isolated from a developer's real ~/.claude/settings.json.
|
||||
process.env.HOME = join(workdir, 'home');
|
||||
vi.stubEnv('HOME', join(workdir, 'home'));
|
||||
vi.stubEnv('USERPROFILE', join(workdir, 'home'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.chdir(ORIGINAL_CWD);
|
||||
if (ORIGINAL_HOME === undefined) delete process.env.HOME;
|
||||
else process.env.HOME = ORIGINAL_HOME;
|
||||
vi.unstubAllEnvs();
|
||||
rmSync(workdir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
@@ -69,6 +68,19 @@ describe('doctor #2677 — stale npx detection covers every subcommand', () => {
|
||||
expect((await runStaleSettingsCheck()).status).toBe('pass');
|
||||
});
|
||||
|
||||
it.runIf(process.platform === 'win32')('checks user settings with HOME unset', async () => {
|
||||
vi.stubEnv('HOME', undefined);
|
||||
const homeSettings = join(workdir, 'home', '.claude');
|
||||
mkdirSync(homeSettings, { recursive: true });
|
||||
writeFileSync(join(homeSettings, 'settings.json'), JSON.stringify({
|
||||
statusLine: { command: 'npx @claude-flow/cli@latest hooks statusline' },
|
||||
}));
|
||||
|
||||
const check = await runStaleSettingsCheck();
|
||||
expect(check.status).toBe('fail');
|
||||
expect(check.message).toContain(join(homeSettings, 'settings.json'));
|
||||
});
|
||||
|
||||
it('upgrade removes sibling npx hooks and regenerates the statusline', async () => {
|
||||
writeSettings({
|
||||
statusLine: { command: 'npx @claude-flow/cli@latest memory retrieve --key status' },
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { Command, CommandContext, CommandResult } from '../types.js';
|
||||
import { output } from '../output.js';
|
||||
import { existsSync, readFileSync, statSync, openSync, readSync, closeSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import { homedir } from 'node:os';
|
||||
import { fileURLToPath, pathToFileURL } from 'url';
|
||||
import { createHash } from 'crypto';
|
||||
import { ownInstallAncestors } from '../plugins/own-install.js';
|
||||
@@ -206,7 +207,7 @@ async function checkStaleSettingsNpx(): Promise<HealthCheck> {
|
||||
// Look in both project-local and home-dir settings.
|
||||
const candidates = [
|
||||
join(process.cwd(), '.claude', 'settings.json'),
|
||||
join(process.env.HOME ?? '', '.claude', 'settings.json'),
|
||||
join(homedir(), '.claude', 'settings.json'),
|
||||
].filter((p, i, a) => p && a.indexOf(p) === i);
|
||||
|
||||
const offenders: Array<{ path: string; where: string }> = [];
|
||||
@@ -280,7 +281,7 @@ export async function checkHelperIntegrity(opts: {
|
||||
const { verifyInstalledCriticalHelpers } = await import('../init/helper-integrity.js');
|
||||
const { CRITICAL_HELPERS, findPackageHelpersDir } = await import('../init/helper-refresh.js');
|
||||
const envLocked = /^(1|true|on|yes)$/i.test(String(process.env.RUFLO_HELPERS_LOCKED || ''));
|
||||
const home = opts.homeDir ?? process.env.HOME ?? '';
|
||||
const home = opts.homeDir ?? homedir();
|
||||
const dirs = [
|
||||
join(opts.cwd ?? process.cwd(), '.claude', 'helpers'),
|
||||
...(home ? [join(home, '.claude', 'helpers')] : []),
|
||||
|
||||
Reference in new issue
Block a user