@fractary/codex 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +30 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3106,16 +3106,19 @@ var SyncManager = class {
|
|
|
3106
3106
|
};
|
|
3107
3107
|
const plan = createSyncPlan(sourceFiles, targetFiles, planOptions, this.config);
|
|
3108
3108
|
plan.estimatedTime = estimateSyncTime(plan);
|
|
3109
|
+
plan.source = codexDir;
|
|
3110
|
+
plan.target = ".fractary/codex/cache";
|
|
3109
3111
|
return {
|
|
3110
3112
|
...plan,
|
|
3111
3113
|
routingScan
|
|
3112
3114
|
};
|
|
3113
3115
|
}
|
|
3114
3116
|
/**
|
|
3115
|
-
* Execute a sync plan
|
|
3117
|
+
* Execute a sync plan
|
|
3116
3118
|
*
|
|
3117
|
-
*
|
|
3118
|
-
* For
|
|
3119
|
+
* Copies files from source to target based on the plan.
|
|
3120
|
+
* For from-codex syncs, files are copied to .fractary/codex/cache/ preserving full paths.
|
|
3121
|
+
* For to-codex syncs, files are copied to the codex repository.
|
|
3119
3122
|
*/
|
|
3120
3123
|
async executePlan(plan, options) {
|
|
3121
3124
|
const startTime = Date.now();
|
|
@@ -3141,7 +3144,30 @@ var SyncManager = class {
|
|
|
3141
3144
|
if (options?.onProgress) {
|
|
3142
3145
|
options.onProgress(i + 1, plan.totalFiles, file.path);
|
|
3143
3146
|
}
|
|
3144
|
-
|
|
3147
|
+
if (file.operation === "create" || file.operation === "update") {
|
|
3148
|
+
const sourcePath = `${plan.source}/${file.path}`;
|
|
3149
|
+
const targetPath = `${plan.target}/${file.path}`;
|
|
3150
|
+
const fs4 = await import('fs/promises');
|
|
3151
|
+
const path6 = await import('path');
|
|
3152
|
+
const targetDir = path6.dirname(targetPath);
|
|
3153
|
+
await fs4.mkdir(targetDir, { recursive: true });
|
|
3154
|
+
await fs4.copyFile(sourcePath, targetPath);
|
|
3155
|
+
synced++;
|
|
3156
|
+
} else if (file.operation === "delete") {
|
|
3157
|
+
const targetPath = `${plan.target}/${file.path}`;
|
|
3158
|
+
const fs4 = await import('fs/promises');
|
|
3159
|
+
try {
|
|
3160
|
+
await fs4.unlink(targetPath);
|
|
3161
|
+
synced++;
|
|
3162
|
+
} catch (error) {
|
|
3163
|
+
if (error.code !== "ENOENT") {
|
|
3164
|
+
throw error;
|
|
3165
|
+
}
|
|
3166
|
+
synced++;
|
|
3167
|
+
}
|
|
3168
|
+
} else {
|
|
3169
|
+
synced++;
|
|
3170
|
+
}
|
|
3145
3171
|
} catch (error) {
|
|
3146
3172
|
failed++;
|
|
3147
3173
|
errors.push({
|