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
9 changes: 6 additions & 3 deletions src/cli/actions/remoteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RepomixError } from '../../shared/errorHandle.js';
import { logger } from '../../shared/logger.js';
import type { CliOptions } from '../cliRun.js';
import Spinner from '../cliSpinner.js';
import { runDefaultAction } from './defaultAction.js';
import { type DefaultActionRunnerResult, runDefaultAction } from './defaultAction.js';

export const runRemoteAction = async (
repoUrl: string,
Expand All @@ -16,14 +16,15 @@ export const runRemoteAction = async (
isGitInstalled,
execGitShallowClone,
},
): Promise<void> => {
): Promise<DefaultActionRunnerResult> => {
if (!(await deps.isGitInstalled())) {
throw new RepomixError('Git is not installed or not in the system PATH.');
}

const spinner = new Spinner('Cloning repository...');

const tempDirPath = await createTempDirectory();
let result: DefaultActionRunnerResult;

try {
spinner.start();
Expand All @@ -37,7 +38,7 @@ export const runRemoteAction = async (
logger.log('');

// Run the default action on the cloned repository
const result = await runDefaultAction(tempDirPath, tempDirPath, options);
result = await runDefaultAction(tempDirPath, tempDirPath, options);
await copyOutputToCurrentDirectory(tempDirPath, process.cwd(), result.config.output.filePath);
} catch (error) {
spinner.fail('Error during repository cloning. cleanup...');
Expand All @@ -46,6 +47,8 @@ export const runRemoteAction = async (
// Cleanup the temporary directory
await cleanupTempDirectory(tempDirPath);
}

return result;
};

export const formatGitUrl = (url: string): string => {
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export { pack } from './core/packager.js';
export type { RepomixConfigFile as RepomixConfig } from './config/configSchema.js';
export { run as cli } from './cli/cliRun.js';
export { runInitAction } from './cli/actions/initAction.js';
export { runRemoteAction } from './cli/actions/remoteAction.js';
export { runDefaultAction } from './cli/actions/defaultAction.js';
34 changes: 33 additions & 1 deletion tests/cli/cliRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,39 @@ describe('cliRun', () => {
} satisfies PackResult,
});
vi.mocked(initAction.runInitAction).mockResolvedValue();
vi.mocked(remoteAction.runRemoteAction).mockResolvedValue();
vi.mocked(remoteAction.runRemoteAction).mockResolvedValue({
config: {
cwd: process.cwd(),
output: {
filePath: 'repomix-output.txt',
style: 'plain',
fileSummary: true,
directoryStructure: true,
topFilesLength: 5,
showLineNumbers: false,
removeComments: false,
removeEmptyLines: false,
copyToClipboard: false,
},
include: [],
ignore: {
useGitignore: true,
useDefaultPatterns: true,
customPatterns: [],
},
security: {
enableSecurityCheck: true,
},
} satisfies RepomixConfigMerged,
packResult: {
totalFiles: 0,
totalCharacters: 0,
totalTokens: 0,
fileCharCounts: {},
fileTokenCounts: {},
suspiciousFilesResults: [],
} satisfies PackResult,
});
vi.mocked(versionAction.runVersionAction).mockResolvedValue();
});

Expand Down