A NestJS module for SVN (Subversion) that provides read/write operations to interact with SVN repositories.
This module requires SVN (Subversion) to be installed on your system. Make sure SVN is installed and available in your PATH before using this module.
You can verify SVN installation by running:
svn --versionThis module supports Windows, macOS, and Linux. The module automatically handles platform-specific differences in shell command execution and environment variables.
- Windows: Uses double quotes for argument escaping (compatible with
cmd.exe) - Unix/Linux/macOS: Uses single quotes for argument escaping (compatible with
sh/bash)
Windows environment has not been fully tested in real-world scenarios.
Current Windows compatibility implementation status:
- Windows platform detection and path handling logic implemented
- Windows shell escaping (double quotes) implemented
- Logic validation completed through unit tests
However, the following have not been verified in actual Windows environments:
- Actual SVN command execution on Windows
- Various Windows shell environments (PowerShell, Git Bash, etc.)
- Real Windows path handling and UNC paths
- Windows environment variable configuration behavior
Recommendations:
- Please report issues if you encounter problems when using this module on Windows
- We welcome feedback from testing in actual Windows environments
npm install nestjs-svn
# or
pnpm add nestjs-svn
# or
yarn add nestjs-svnimport { Module } from '@nestjs/common';
import { SvnModule } from 'nestjs-svn';
@Module({
imports: [
SvnModule.forRoot({
username: 'your-username',
password: 'your-password',
repositoryUrl: 'https://svn.example.com/repo',
trustServerCert: true,
nonInteractive: true,
}),
],
})
export class AppModule {}import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { SvnModule } from 'nestjs-svn';
@Module({
imports: [
SvnModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
username: configService.get('SVN_USERNAME'),
password: configService.get('SVN_PASSWORD'),
repositoryUrl: configService.get('SVN_REPO_URL'),
trustServerCert: true,
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}import { Injectable } from '@nestjs/common';
import { SvnService } from 'nestjs-svn';
@Injectable()
export class MyService {
constructor(private readonly svnService: SvnService) {}
async doSomething() {
// Perform SVN operations
}
}Operations that only query information or read files from the repository. These operations do not modify the repository or working copy.
- info - Get repository information (returns
SvnInfoResult | null) - status - Get working copy status (returns
SvnStatusResult[]) - log - Get commit logs (returns
SvnLogEntry[]) - list - List directory contents (returns
string[]) - cat - Read file contents (returns
string) - diff - Get differences (returns
string) - export - Export from repository (without creating working copy) (returns
SvnCommandResult)
Operations that modify the repository or working copy, or create a local working copy.
- checkout - Checkout repository (creates working copy) (returns
SvnCommandResult) - update - Update working copy (returns
SvnCommandResult) - add - Add files/directories (returns
SvnCommandResult) - remove - Remove files/directories (returns
SvnCommandResult) - commit - Commit changes (returns
SvnCommandResult) - copy - Copy files/directories (returns
SvnCommandResult) - move - Move/rename files/directories (returns
SvnCommandResult) - mkdir - Create directory (returns
SvnCommandResult)
interface SvnOptions {
username?: string; // SVN username
password?: string; // SVN password
repositoryUrl?: string; // Repository URL (used for resolving relative paths)
nonInteractive?: boolean; // Non-interactive mode (default: true)
trustServerCert?: boolean; // Trust server certificate
noAuthCache?: boolean; // Disable authentication cache
}When using the repositoryUrl option, all paths are interpreted as relative paths within that repository URL. This allows you to use relative paths instead of absolute URLs.
MIT