MCPcopy Create free account
hub / github.com/TanStack/cli / sync

Method sync

packages/cli/src/file-syncer.ts:26–62  ·  view source on GitHub ↗
(
    sourceDir: string,
    targetDir: string,
    options?: SyncOptions,
  )

Source from the content-addressed store, hash-verified

24
25export class FileSyncer {
26 async sync(
27 sourceDir: string,
28 targetDir: string,
29 options?: SyncOptions,
30 ): Promise<SyncResult> {
31 const result: SyncResult = {
32 updated: [],
33 skipped: [],
34 created: [],
35 deleted: [],
36 sourceFiles: [],
37 errors: [],
38 }
39
40 // Ensure directories exist
41 if (!fs.existsSync(sourceDir)) {
42 throw new Error(`Source directory does not exist: ${sourceDir}`)
43 }
44 if (!fs.existsSync(targetDir)) {
45 throw new Error(`Target directory does not exist: ${targetDir}`)
46 }
47
48 // Walk through source directory and sync files
49 await this.syncDirectory(sourceDir, targetDir, sourceDir, result)
50
51 if (options?.deleteRemoved && options.previousSourceFiles) {
52 const currentSourceFileSet = new Set(result.sourceFiles)
53 await this.deleteRemovedFiles(
54 targetDir,
55 options.previousSourceFiles,
56 currentSourceFileSet,
57 result,
58 )
59 }
60
61 return result
62 }
63
64 private async syncDirectory(
65 currentPath: string,

Callers

nothing calls this directly

Calls 2

syncDirectoryMethod · 0.95
deleteRemovedFilesMethod · 0.95

Tested by

no test coverage detected