style: fix prettier formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-03-05 14:08:56 +00:00
parent f06f99b3e5
commit 3976b7cedd
6 changed files with 56 additions and 150 deletions

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -107,10 +107,7 @@ describe('LocalCacheService', () => {
const result = await LocalCacheService.restoreLibraryCache('/project', '/cache', 'key1');
expect(result).toBe(true);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('lib-2000.tar'),
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('lib-2000.tar'), true);
});
it('should return false and log warning on error', async () => {
@@ -154,10 +151,7 @@ describe('LocalCacheService', () => {
await LocalCacheService.saveLibraryCache('/project', '/cache', 'key1');
expect(mockFs.mkdirSync).toHaveBeenCalledWith(path.join('/cache', 'key1', 'Library'), { recursive: true });
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('tar -cf'),
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('tar -cf'), true);
});
});
@@ -187,10 +181,7 @@ describe('LocalCacheService', () => {
const result = await LocalCacheService.restoreLfsCache('/repo', '/cache', 'key1');
expect(result).toBe(true);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('lfs-200.tar'),
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('lfs-200.tar'), true);
});
});
@@ -224,10 +215,7 @@ describe('LocalCacheService', () => {
await LocalCacheService.saveLfsCache('/repo', '/cache', 'key1');
expect(mockFs.mkdirSync).toHaveBeenCalledWith(path.join('/cache', 'key1', 'lfs'), { recursive: true });
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('tar -cf'),
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('tar -cf'), true);
});
it('should handle save errors gracefully', async () => {
@@ -263,10 +251,7 @@ describe('LocalCacheService', () => {
await LocalCacheService.garbageCollect('/cache', 7);
expect(mockFs.rmSync).toHaveBeenCalledTimes(1);
expect(mockFs.rmSync).toHaveBeenCalledWith(
path.join('/cache', 'old-cache'),
{ recursive: true, force: true },
);
expect(mockFs.rmSync).toHaveBeenCalledWith(path.join('/cache', 'old-cache'), { recursive: true, force: true });
});
it('should not remove directories newer than maxAgeDays', async () => {

View File

@@ -64,22 +64,26 @@ describe('GitHooksService', () => {
describe('detectUnityGitHooks', () => {
it('should return true when package is in manifest.json', () => {
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readFileSync as jest.Mock).mockReturnValue(JSON.stringify({
dependencies: {
'com.frostebite.unitygithooks': 'https://github.com/frostebite/UnityGitHooks.git#1.0.5',
},
}));
(mockFs.readFileSync as jest.Mock).mockReturnValue(
JSON.stringify({
dependencies: {
'com.frostebite.unitygithooks': 'https://github.com/frostebite/UnityGitHooks.git#1.0.5',
},
}),
);
expect(GitHooksService.detectUnityGitHooks('/repo')).toBe(true);
});
it('should return false when package is not in manifest.json', () => {
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readFileSync as jest.Mock).mockReturnValue(JSON.stringify({
dependencies: {
'com.unity.textmeshpro': '3.0.6',
},
}));
(mockFs.readFileSync as jest.Mock).mockReturnValue(
JSON.stringify({
dependencies: {
'com.unity.textmeshpro': '3.0.6',
},
}),
);
expect(GitHooksService.detectUnityGitHooks('/repo')).toBe(false);
});
@@ -115,9 +119,7 @@ describe('GitHooksService', () => {
it('should return empty string when package not in cache', () => {
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.unity.textmeshpro@3.0.6',
]);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.unity.textmeshpro@3.0.6']);
const result = GitHooksService.findUnityGitHooksPackagePath('/repo');
expect(result).toBe('');
@@ -136,16 +138,11 @@ describe('GitHooksService', () => {
const { OrchestratorSystem } = require('../core/orchestrator-system');
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.frostebite.unitygithooks@1.0.5',
]);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.frostebite.unitygithooks@1.0.5']);
await GitHooksService.initUnityGitHooks('/repo');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('init-unity-lefthook.js'),
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('init-unity-lefthook.js'), true);
});
it('should skip when package not found in cache', async () => {
@@ -165,15 +162,11 @@ describe('GitHooksService', () => {
// PackageCache dir exists, but init script doesn't
return !String(p).includes('init-unity-lefthook');
});
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.frostebite.unitygithooks@1.0.5',
]);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.frostebite.unitygithooks@1.0.5']);
await GitHooksService.initUnityGitHooks('/repo');
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('init script not found'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('init script not found'));
});
it('should log warning on init failure', async () => {
@@ -181,16 +174,12 @@ describe('GitHooksService', () => {
const OrchestratorLogger = require('../core/orchestrator-logger').default;
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.frostebite.unitygithooks@1.0.5',
]);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.frostebite.unitygithooks@1.0.5']);
OrchestratorSystem.Run.mockRejectedValue(new Error('node not found'));
await GitHooksService.initUnityGitHooks('/repo');
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('init failed'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('init failed'));
});
});
@@ -228,9 +217,7 @@ describe('GitHooksService', () => {
(mockFs.readFileSync as jest.Mock).mockReturnValue(
`{"dependencies":{"com.frostebite.unitygithooks":"https://github.com/frostebite/UnityGitHooks.git"}}`,
);
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.frostebite.unitygithooks@1.0.5',
]);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.frostebite.unitygithooks@1.0.5']);
OrchestratorSystem.Run.mockImplementation((cmd: string) => {
if (cmd.includes('init-unity-lefthook')) {
@@ -246,19 +233,13 @@ describe('GitHooksService', () => {
// Init should happen before install
expect(callOrder).toEqual(['init', 'install']);
expect(OrchestratorLogger.log).toHaveBeenCalledWith(
expect.stringContaining('Unity Git Hooks (UPM) detected'),
);
expect(OrchestratorLogger.log).toHaveBeenCalledWith(expect.stringContaining('Unity Git Hooks (UPM) detected'));
});
it('should set CI env vars when Unity Git Hooks detected', async () => {
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
(mockFs.readFileSync as jest.Mock).mockReturnValue(
`{"dependencies":{"com.frostebite.unitygithooks":"1.0.5"}}`,
);
(mockFs.readdirSync as jest.Mock).mockReturnValue([
'com.frostebite.unitygithooks@1.0.5',
]);
(mockFs.readFileSync as jest.Mock).mockReturnValue(`{"dependencies":{"com.frostebite.unitygithooks":"1.0.5"}}`);
(mockFs.readdirSync as jest.Mock).mockReturnValue(['com.frostebite.unitygithooks@1.0.5']);
await GitHooksService.installHooks('/repo');
@@ -300,9 +281,7 @@ describe('GitHooksService', () => {
await GitHooksService.installHooks('/repo');
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('Hook installation failed'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('Hook installation failed'));
});
});
@@ -316,14 +295,8 @@ describe('GitHooksService', () => {
const results = await GitHooksService.runHookGroups('/repo', ['pre-commit', 'pre-push']);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
`cd "/repo" && npx lefthook run pre-commit`,
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
`cd "/repo" && npx lefthook run pre-push`,
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(`cd "/repo" && npx lefthook run pre-commit`, true);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(`cd "/repo" && npx lefthook run pre-push`, true);
expect(results['pre-commit']).toBe(true);
expect(results['pre-push']).toBe(true);
});
@@ -340,9 +313,7 @@ describe('GitHooksService', () => {
const results = await GitHooksService.runHookGroups('/repo', ['pre-commit']);
expect(results).toEqual({});
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('requires lefthook'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('requires lefthook'));
});
it('should mark failed groups as false', async () => {
@@ -351,8 +322,7 @@ describe('GitHooksService', () => {
return String(filePath).includes('lefthook.yml') && !String(filePath).startsWith('.');
});
OrchestratorSystem.Run
.mockResolvedValueOnce('') // pre-commit passes
OrchestratorSystem.Run.mockResolvedValueOnce('') // pre-commit passes
.mockRejectedValueOnce(new Error('tests failed')); // pre-push fails
const results = await GitHooksService.runHookGroups('/repo', ['pre-commit', 'pre-push']);
@@ -368,18 +338,12 @@ describe('GitHooksService', () => {
return String(filePath).includes('lefthook.yml') && !String(filePath).startsWith('.');
});
OrchestratorSystem.Run
.mockResolvedValueOnce('')
.mockRejectedValueOnce(new Error('check failed'));
OrchestratorSystem.Run.mockResolvedValueOnce('').mockRejectedValueOnce(new Error('check failed'));
await GitHooksService.runHookGroups('/repo', ['pre-commit', 'commit-msg']);
expect(OrchestratorLogger.log).toHaveBeenCalledWith(
expect.stringContaining("'pre-commit' passed"),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining("'commit-msg' failed"),
);
expect(OrchestratorLogger.log).toHaveBeenCalledWith(expect.stringContaining("'pre-commit' passed"));
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining("'commit-msg' failed"));
});
});
@@ -429,9 +393,7 @@ describe('GitHooksService', () => {
await GitHooksService.disableHooks('/repo');
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('Failed to disable hooks'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('Failed to disable hooks'));
});
});

View File

@@ -169,9 +169,7 @@ export class GitHooksService {
const framework = GitHooksService.detectHookFramework(repoPath);
if (framework !== 'lefthook') {
OrchestratorLogger.logWarning(
`[GitHooks] runHookGroups requires lefthook, but detected: ${framework}`,
);
OrchestratorLogger.logWarning(`[GitHooks] runHookGroups requires lefthook, but detected: ${framework}`);
return results;
}

View File

@@ -132,11 +132,7 @@ describe('ElasticGitStorageService', () => {
const result = await ElasticGitStorageService.findInstalled();
expect(result).toBe('C:\\tools\\elastic-git-storage.exe');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('where'),
false,
true,
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('where'), false, true);
});
it('should check common install locations when not on PATH', async () => {
@@ -195,12 +191,8 @@ describe('ElasticGitStorageService', () => {
const result = await ElasticGitStorageService.install('latest');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('elastic-git-storage_linux_amd64'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('chmod +x'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('elastic-git-storage_linux_amd64'));
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('chmod +x'));
expect(result).toContain('elastic-git-storage');
});
@@ -213,12 +205,8 @@ describe('ElasticGitStorageService', () => {
await ElasticGitStorageService.install('v1.2.0');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('elastic-git-storage_darwin_arm64'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('v1.2.0'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('elastic-git-storage_darwin_arm64'));
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('v1.2.0'));
});
it('should download .exe for windows', async () => {
@@ -234,9 +222,7 @@ describe('ElasticGitStorageService', () => {
expect.stringContaining('elastic-git-storage_windows_amd64.exe'),
);
// Should NOT chmod on windows
expect(OrchestratorSystem.Run).not.toHaveBeenCalledWith(
expect.stringContaining('chmod'),
);
expect(OrchestratorSystem.Run).not.toHaveBeenCalledWith(expect.stringContaining('chmod'));
});
it('should use RUNNER_TOOL_CACHE for install dir when available', async () => {
@@ -269,9 +255,7 @@ describe('ElasticGitStorageService', () => {
await ElasticGitStorageService.install('latest');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('/releases/latest/download/'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('/releases/latest/download/'));
});
it('should use tagged release URL when version is specified', async () => {
@@ -283,9 +267,7 @@ describe('ElasticGitStorageService', () => {
await ElasticGitStorageService.install('v2.0.0');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('/releases/download/v2.0.0/'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('/releases/download/v2.0.0/'));
});
it('should return empty string on download failure', async () => {
@@ -321,12 +303,7 @@ describe('ElasticGitStorageService', () => {
OrchestratorSystem.Run.mockResolvedValue('/usr/local/bin/elastic-git-storage\n');
(mockFs.existsSync as jest.Mock).mockReturnValue(true);
const result = await ElasticGitStorageService.ensureAndConfigure(
'latest',
'--verbose',
['/mnt/lfs'],
'/repo',
);
const result = await ElasticGitStorageService.ensureAndConfigure('latest', '--verbose', ['/mnt/lfs'], '/repo');
expect(result).toBe('/usr/local/bin/elastic-git-storage');
expect(LfsAgentService.configure).toHaveBeenCalledWith(
@@ -346,8 +323,7 @@ describe('ElasticGitStorageService', () => {
mockOs.tmpdir.mockReturnValue('/tmp');
// findInstalled finds nothing
OrchestratorSystem.Run
.mockRejectedValueOnce(new Error('not found')) // which
OrchestratorSystem.Run.mockRejectedValueOnce(new Error('not found')) // which
.mockResolvedValueOnce('') // curl download
.mockResolvedValueOnce(''); // chmod
@@ -357,12 +333,7 @@ describe('ElasticGitStorageService', () => {
.mockReturnValueOnce(false) // ~/.local/bin
.mockReturnValueOnce(true); // after install
const result = await ElasticGitStorageService.ensureAndConfigure(
'v1.0.0',
'',
[],
'/repo',
);
const result = await ElasticGitStorageService.ensureAndConfigure('v1.0.0', '', [], '/repo');
expect(result).toContain('elastic-git-storage');
expect(LfsAgentService.configure).toHaveBeenCalled();
@@ -379,12 +350,7 @@ describe('ElasticGitStorageService', () => {
OrchestratorSystem.Run.mockRejectedValue(new Error('not found'));
(mockFs.existsSync as jest.Mock).mockReturnValue(false);
const result = await ElasticGitStorageService.ensureAndConfigure(
'latest',
'',
[],
'/repo',
);
const result = await ElasticGitStorageService.ensureAndConfigure('latest', '', [], '/repo');
expect(result).toBe('');
});
@@ -397,8 +363,7 @@ describe('ElasticGitStorageService', () => {
mockOs.tmpdir.mockReturnValue('/tmp');
// findInstalled finds nothing
OrchestratorSystem.Run
.mockRejectedValueOnce(new Error('not found'))
OrchestratorSystem.Run.mockRejectedValueOnce(new Error('not found'))
.mockResolvedValueOnce('')
.mockResolvedValueOnce('');
@@ -410,9 +375,7 @@ describe('ElasticGitStorageService', () => {
await ElasticGitStorageService.ensureAndConfigure('', '', [], '/repo');
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(
expect.stringContaining('/releases/latest/download/'),
);
expect(OrchestratorSystem.Run).toHaveBeenCalledWith(expect.stringContaining('/releases/latest/download/'));
});
});

View File

@@ -116,9 +116,7 @@ describe('LfsAgentService', () => {
await LfsAgentService.validate('/nonexistent/agent');
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(
expect.stringContaining('Agent executable not found'),
);
expect(OrchestratorLogger.logWarning).toHaveBeenCalledWith(expect.stringContaining('Agent executable not found'));
});
});
});