fy-convertor
Version:
Convert excel/xml/json/bin/protocl/ts/as ...
55 lines • 1.8 kB
JavaScript
import fs from 'fs-extra';
import { SVNClient } from '@taiyosen/easy-svn';
import { toolchain } from '../tools/toolchain.js';
export class SvnHolder {
svnClient = new SVNClient();
static ins;
static get Instance() {
if (!SvnHolder.ins)
SvnHolder.ins = new SvnHolder();
return SvnHolder.ins;
}
commitOutput = '';
constructor() {
const env = process.env;
if (env.SVN_USERNAME && env.SVN_PASSWORD) {
this.svnClient.setConfig({
username: env.SVN_USERNAME,
password: env.SVN_PASSWORD,
globalParams: ['--non-interactive', '--trust-server-cert', '--no-auth-cache']
});
}
}
async checkSVN(revert, localPath, svnPath) {
if (fs.existsSync(localPath)) {
await this.svnClient.cleanup(true, localPath);
if (revert) {
await this.svnClient.revert(localPath);
}
await this.svnClient.update(localPath);
}
else {
await fs.mkdirp(localPath);
await this.svnClient.checkout(svnPath, localPath);
}
}
async commitSVN(msg, ...paths) {
await this.svnClient.addUnversioned(...paths);
this.commitOutput = await this.svnClient.commit(msg, ...paths);
}
getLastCommitFiles() {
const files = [];
const mchs = this.commitOutput.matchAll(/Sending\s+(\S+)/g);
for (const mch of mchs) {
files.push(mch[1]);
}
return files;
}
}
export function adjustSVN(raw) {
if (toolchain.options.publish) {
raw = raw.replace('trunk', 'branches/publish');
}
return raw;
}
//# sourceMappingURL=SvnHolder.js.map