@riddledc/riddle-proof 0.5.4 → 0.5.5
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/lib/workspace-core.mjs +3 -0
- package/package.json +1 -1
- package/runtime/lib/setup.py +49 -5
package/lib/workspace-core.mjs
CHANGED
|
@@ -385,6 +385,9 @@ async function main() {
|
|
|
385
385
|
case "ensure-deps":
|
|
386
386
|
ok({ status: ensureDeps(payload) });
|
|
387
387
|
return;
|
|
388
|
+
case "dependency-fingerprint":
|
|
389
|
+
ok({ fingerprint: computeDependencyFingerprint(payload.projectDir) });
|
|
390
|
+
return;
|
|
388
391
|
default:
|
|
389
392
|
throw new Error(`Unsupported command: ${command}`);
|
|
390
393
|
}
|
package/package.json
CHANGED
package/runtime/lib/setup.py
CHANGED
|
@@ -77,6 +77,13 @@ def ensure_deps(project_dir, reuse_from=''):
|
|
|
77
77
|
return result.get('status', '')
|
|
78
78
|
|
|
79
79
|
|
|
80
|
+
def dependency_fingerprint(project_dir):
|
|
81
|
+
if not project_dir:
|
|
82
|
+
return ''
|
|
83
|
+
result = workspace_core('dependency-fingerprint', {'projectDir': project_dir}, timeout=30)
|
|
84
|
+
return result.get('fingerprint', '') or ''
|
|
85
|
+
|
|
86
|
+
|
|
80
87
|
def record_setup_phase(phase, status='running', summary=''):
|
|
81
88
|
global s
|
|
82
89
|
ts = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
|
|
@@ -131,6 +138,24 @@ def ensure_deps_phase(phase, project_dir, reuse_from='', summary=''):
|
|
|
131
138
|
return status
|
|
132
139
|
|
|
133
140
|
|
|
141
|
+
def dependencies_match(left_dir, right_dir):
|
|
142
|
+
left = dependency_fingerprint(left_dir)
|
|
143
|
+
right = dependency_fingerprint(right_dir)
|
|
144
|
+
return bool(left and right and left == right)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def compatible_reuse_source(source_dir, target_dirs):
|
|
148
|
+
if not source_dir:
|
|
149
|
+
return ''
|
|
150
|
+
source = dependency_fingerprint(source_dir)
|
|
151
|
+
if not source:
|
|
152
|
+
return ''
|
|
153
|
+
for target_dir in target_dirs:
|
|
154
|
+
if target_dir and dependency_fingerprint(target_dir) == source:
|
|
155
|
+
return source_dir
|
|
156
|
+
return ''
|
|
157
|
+
|
|
158
|
+
|
|
134
159
|
def resolve_worktree_root(repo_dir):
|
|
135
160
|
configured = (s.get('worktree_root') or os.environ.get('RIDDLE_PROOF_WORKTREE_ROOT') or '').strip()
|
|
136
161
|
if configured:
|
|
@@ -401,17 +426,36 @@ print('After worktree: ' + AFTER_DIR + ' (' + AFTER_WORKTREE_BRANCH + ' -> ' + b
|
|
|
401
426
|
apply_repo_profile(AFTER_DIR)
|
|
402
427
|
save_state(s)
|
|
403
428
|
|
|
429
|
+
target_dependency_dirs = [AFTER_DIR]
|
|
430
|
+
if reference in ('before', 'both'):
|
|
431
|
+
target_dependency_dirs.append(BEFORE_DIR)
|
|
432
|
+
|
|
404
433
|
reuse_source = repo_dir if os.path.exists(os.path.join(repo_dir, 'package.json')) else ''
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
434
|
+
shared_reuse_source = compatible_reuse_source(reuse_source, target_dependency_dirs)
|
|
435
|
+
shared_status = ''
|
|
436
|
+
if shared_reuse_source:
|
|
437
|
+
shared_status = ensure_deps_phase('shared_deps', shared_reuse_source, summary='Ensuring shared repository dependencies.')
|
|
438
|
+
if shared_status:
|
|
439
|
+
print('Shared deps status: ' + shared_status)
|
|
440
|
+
elif reuse_source:
|
|
441
|
+
record_setup_phase(
|
|
442
|
+
'shared_deps',
|
|
443
|
+
'completed',
|
|
444
|
+
'skipped: active workspace dependencies differ from proof worktrees',
|
|
445
|
+
)
|
|
446
|
+
print('Shared deps skipped: active workspace dependencies differ from proof worktrees')
|
|
408
447
|
|
|
409
448
|
before_dep_status = ''
|
|
410
449
|
if reference in ('before', 'both'):
|
|
411
|
-
before_dep_status = ensure_deps_phase('before_deps', BEFORE_DIR, reuse_from=
|
|
450
|
+
before_dep_status = ensure_deps_phase('before_deps', BEFORE_DIR, reuse_from=shared_reuse_source, summary='Ensuring before-worktree dependencies.')
|
|
412
451
|
print('Before deps status: ' + before_dep_status)
|
|
413
452
|
|
|
414
|
-
|
|
453
|
+
after_reuse_source = ''
|
|
454
|
+
if before_dep_status and dependencies_match(BEFORE_DIR, AFTER_DIR):
|
|
455
|
+
after_reuse_source = BEFORE_DIR
|
|
456
|
+
elif shared_reuse_source:
|
|
457
|
+
after_reuse_source = shared_reuse_source
|
|
458
|
+
after_dep_status = ensure_deps_phase('after_deps', AFTER_DIR, reuse_from=after_reuse_source, summary='Ensuring after-worktree dependencies.')
|
|
415
459
|
print('After deps status: ' + after_dep_status)
|
|
416
460
|
|
|
417
461
|
# Patch Next.js config in after worktree if needed
|