Skip to content

roadhong/nestjs-svn

Repository files navigation

NestJS SVN Module

A NestJS module for SVN (Subversion) that provides read/write operations to interact with SVN repositories.

⚠️ Warning

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 --version

Platform Support

This 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 Compatibility Notice

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

Installation

npm install nestjs-svn
# or
pnpm add nestjs-svn
# or
yarn add nestjs-svn

Module Configuration

Basic Configuration (forRoot)

import { 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 {}

Async Configuration (forRootAsync)

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 {}

Usage

Service Injection

import { Injectable } from '@nestjs/common';
import { SvnService } from 'nestjs-svn';

@Injectable()
export class MyService {
  constructor(private readonly svnService: SvnService) {}

  async doSomething() {
    // Perform SVN operations
  }
}

Available Features

Read 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)

Write Operations

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)

Options

Common Options (SvnOptions)

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
}

Using repositoryUrl Option

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.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published