runwork 0.15.1 → 0.15.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.js +19272 -116
- package/package.json +4 -4
- package/dist/__tests__/curl-parser.test.d.ts +0 -1
- package/dist/__tests__/curl-parser.test.js +0 -250
- package/dist/__tests__/install-scripts.test.d.ts +0 -1
- package/dist/__tests__/install-scripts.test.js +0 -280
- package/dist/__tests__/types-manager.test.d.ts +0 -1
- package/dist/__tests__/types-manager.test.js +0 -89
- package/dist/agents/__tests__/chatgpt-registry.test.d.ts +0 -1
- package/dist/agents/__tests__/chatgpt-registry.test.js +0 -61
- package/dist/agents/__tests__/claude-code-managed-block.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-managed-block.test.js +0 -105
- package/dist/agents/__tests__/claude-code-plugin.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-plugin.test.js +0 -47
- package/dist/agents/__tests__/claude-code-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-stats.test.js +0 -390
- package/dist/agents/__tests__/claude-desktop-memory.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-memory.test.js +0 -154
- package/dist/agents/__tests__/claude-desktop-plugin-tree.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-plugin-tree.test.js +0 -161
- package/dist/agents/__tests__/claude-desktop-plugin.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-plugin.test.js +0 -117
- package/dist/agents/__tests__/claude-desktop-rpm.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-rpm.test.js +0 -126
- package/dist/agents/__tests__/claude-desktop-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-stats.test.js +0 -280
- package/dist/agents/__tests__/codex-instructions.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-instructions.test.js +0 -57
- package/dist/agents/__tests__/codex-minimum-permissions.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-minimum-permissions.test.js +0 -82
- package/dist/agents/__tests__/codex-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-stats.test.js +0 -370
- package/dist/agents/__tests__/cursor-merge.test.d.ts +0 -1
- package/dist/agents/__tests__/cursor-merge.test.js +0 -66
- package/dist/agents/__tests__/cursor-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/cursor-stats.test.js +0 -183
- package/dist/agents/__tests__/defaults-merge.test.d.ts +0 -1
- package/dist/agents/__tests__/defaults-merge.test.js +0 -268
- package/dist/agents/__tests__/detection.test.d.ts +0 -1
- package/dist/agents/__tests__/detection.test.js +0 -89
- package/dist/agents/__tests__/graceful-degradation.test.d.ts +0 -1
- package/dist/agents/__tests__/graceful-degradation.test.js +0 -129
- package/dist/agents/__tests__/instruction-hint.test.d.ts +0 -1
- package/dist/agents/__tests__/instruction-hint.test.js +0 -69
- package/dist/agents/__tests__/intro-skill.test.d.ts +0 -1
- package/dist/agents/__tests__/intro-skill.test.js +0 -193
- package/dist/agents/__tests__/schema-validation.test.d.ts +0 -1
- package/dist/agents/__tests__/schema-validation.test.js +0 -212
- package/dist/agents/__tests__/skill-slug.test.d.ts +0 -1
- package/dist/agents/__tests__/skill-slug.test.js +0 -77
- package/dist/agents/claude-code.d.ts +0 -59
- package/dist/agents/claude-code.js +0 -753
- package/dist/agents/claude-desktop-plugin-tree.d.ts +0 -59
- package/dist/agents/claude-desktop-plugin-tree.js +0 -143
- package/dist/agents/claude-desktop.d.ts +0 -47
- package/dist/agents/claude-desktop.js +0 -684
- package/dist/agents/cline.d.ts +0 -15
- package/dist/agents/cline.js +0 -130
- package/dist/agents/codex.d.ts +0 -44
- package/dist/agents/codex.js +0 -453
- package/dist/agents/conversation-skills.d.ts +0 -18
- package/dist/agents/conversation-skills.js +0 -229
- package/dist/agents/cursor.d.ts +0 -35
- package/dist/agents/cursor.js +0 -294
- package/dist/agents/default-config.d.ts +0 -30
- package/dist/agents/default-config.js +0 -67
- package/dist/agents/defaults-merge.d.ts +0 -87
- package/dist/agents/defaults-merge.js +0 -150
- package/dist/agents/detect.d.ts +0 -4
- package/dist/agents/detect.js +0 -67
- package/dist/agents/detection.d.ts +0 -18
- package/dist/agents/detection.js +0 -94
- package/dist/agents/gemini.d.ts +0 -15
- package/dist/agents/gemini.js +0 -122
- package/dist/agents/generic-adapter.d.ts +0 -25
- package/dist/agents/generic-adapter.js +0 -151
- package/dist/agents/intro-skill.d.ts +0 -45
- package/dist/agents/intro-skill.js +0 -447
- package/dist/agents/registry-data.d.ts +0 -192
- package/dist/agents/registry-data.js +0 -669
- package/dist/agents/registry.d.ts +0 -13
- package/dist/agents/registry.js +0 -36
- package/dist/agents/runtime-detection.d.ts +0 -82
- package/dist/agents/runtime-detection.js +0 -271
- package/dist/agents/session-start-hook.d.ts +0 -37
- package/dist/agents/session-start-hook.js +0 -159
- package/dist/agents/types.d.ts +0 -171
- package/dist/agents/types.js +0 -75
- package/dist/agents/utils/instruction-hint.d.ts +0 -21
- package/dist/agents/utils/instruction-hint.js +0 -108
- package/dist/agents/utils/json-config.d.ts +0 -19
- package/dist/agents/utils/json-config.js +0 -69
- package/dist/agents/utils/toml-config.d.ts +0 -8
- package/dist/agents/utils/toml-config.js +0 -27
- package/dist/agents/windsurf.d.ts +0 -14
- package/dist/agents/windsurf.js +0 -102
- package/dist/api/__tests__/client.test.d.ts +0 -1
- package/dist/api/__tests__/client.test.js +0 -272
- package/dist/api/client.d.ts +0 -326
- package/dist/api/client.js +0 -427
- package/dist/auth/__tests__/login-flow.test.d.ts +0 -1
- package/dist/auth/__tests__/login-flow.test.js +0 -101
- package/dist/auth/__tests__/store.test.d.ts +0 -1
- package/dist/auth/__tests__/store.test.js +0 -132
- package/dist/auth/login-flow.d.ts +0 -26
- package/dist/auth/login-flow.js +0 -137
- package/dist/auth/store.d.ts +0 -5
- package/dist/auth/store.js +0 -62
- package/dist/commands/__tests__/clone-args.test.d.ts +0 -1
- package/dist/commands/__tests__/clone-args.test.js +0 -51
- package/dist/commands/__tests__/clone-source-result.test.d.ts +0 -1
- package/dist/commands/__tests__/clone-source-result.test.js +0 -45
- package/dist/commands/__tests__/info-merge.test.d.ts +0 -1
- package/dist/commands/__tests__/info-merge.test.js +0 -55
- package/dist/commands/__tests__/mcp-entries.test.d.ts +0 -1
- package/dist/commands/__tests__/mcp-entries.test.js +0 -48
- package/dist/commands/__tests__/setup-persona.test.d.ts +0 -1
- package/dist/commands/__tests__/setup-persona.test.js +0 -31
- package/dist/commands/__tests__/setup.test.d.ts +0 -1
- package/dist/commands/__tests__/setup.test.js +0 -81
- package/dist/commands/__tests__/sync-redetect.test.d.ts +0 -1
- package/dist/commands/__tests__/sync-redetect.test.js +0 -96
- package/dist/commands/__tests__/sync-telemetry.test.d.ts +0 -1
- package/dist/commands/__tests__/sync-telemetry.test.js +0 -281
- package/dist/commands/__tests__/upgrade.test.d.ts +0 -1
- package/dist/commands/__tests__/upgrade.test.js +0 -157
- package/dist/commands/agents.d.ts +0 -2
- package/dist/commands/agents.js +0 -160
- package/dist/commands/api-keys.d.ts +0 -2
- package/dist/commands/api-keys.js +0 -95
- package/dist/commands/apps.d.ts +0 -2
- package/dist/commands/apps.js +0 -82
- package/dist/commands/build-plugin.d.ts +0 -2
- package/dist/commands/build-plugin.js +0 -135
- package/dist/commands/clone.d.ts +0 -60
- package/dist/commands/clone.js +0 -271
- package/dist/commands/components.d.ts +0 -2
- package/dist/commands/components.js +0 -43
- package/dist/commands/deploy.d.ts +0 -2
- package/dist/commands/deploy.js +0 -279
- package/dist/commands/dev.d.ts +0 -11
- package/dist/commands/dev.js +0 -1011
- package/dist/commands/doctor.d.ts +0 -2
- package/dist/commands/doctor.js +0 -230
- package/dist/commands/endpoints.d.ts +0 -2
- package/dist/commands/endpoints.js +0 -189
- package/dist/commands/entities.d.ts +0 -2
- package/dist/commands/entities.js +0 -198
- package/dist/commands/files.d.ts +0 -2
- package/dist/commands/files.js +0 -193
- package/dist/commands/inbox.d.ts +0 -11
- package/dist/commands/inbox.js +0 -60
- package/dist/commands/info.d.ts +0 -178
- package/dist/commands/info.js +0 -455
- package/dist/commands/init.d.ts +0 -21
- package/dist/commands/init.js +0 -185
- package/dist/commands/integrations.d.ts +0 -2
- package/dist/commands/integrations.js +0 -233
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -44
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.js +0 -13
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -232
- package/dist/commands/mcp-entries.d.ts +0 -13
- package/dist/commands/mcp-entries.js +0 -26
- package/dist/commands/mcp.d.ts +0 -2
- package/dist/commands/mcp.js +0 -245
- package/dist/commands/open.d.ts +0 -2
- package/dist/commands/open.js +0 -53
- package/dist/commands/resume.d.ts +0 -2
- package/dist/commands/resume.js +0 -289
- package/dist/commands/save-convo.d.ts +0 -8
- package/dist/commands/save-convo.js +0 -20
- package/dist/commands/schedules.d.ts +0 -2
- package/dist/commands/schedules.js +0 -221
- package/dist/commands/setup.d.ts +0 -27
- package/dist/commands/setup.js +0 -177
- package/dist/commands/share-convo.d.ts +0 -24
- package/dist/commands/share-convo.js +0 -167
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -352
- package/dist/commands/sync-telemetry.d.ts +0 -33
- package/dist/commands/sync-telemetry.js +0 -186
- package/dist/commands/sync.d.ts +0 -37
- package/dist/commands/sync.js +0 -702
- package/dist/commands/uninstall.d.ts +0 -2
- package/dist/commands/uninstall.js +0 -145
- package/dist/commands/upgrade.d.ts +0 -14
- package/dist/commands/upgrade.js +0 -217
- package/dist/commands/validate.d.ts +0 -2
- package/dist/commands/validate.js +0 -89
- package/dist/commands/welcome.d.ts +0 -1
- package/dist/commands/welcome.js +0 -86
- package/dist/commands/workflows.d.ts +0 -2
- package/dist/commands/workflows.js +0 -187
- package/dist/deploy/__tests__/deploy-state.test.d.ts +0 -1
- package/dist/deploy/__tests__/deploy-state.test.js +0 -80
- package/dist/deploy/__tests__/deploy-status.test.d.ts +0 -1
- package/dist/deploy/__tests__/deploy-status.test.js +0 -41
- package/dist/deploy/__tests__/detach-args.test.d.ts +0 -1
- package/dist/deploy/__tests__/detach-args.test.js +0 -30
- package/dist/deploy/deploy-state.d.ts +0 -36
- package/dist/deploy/deploy-state.js +0 -63
- package/dist/deploy/deploy-status.d.ts +0 -21
- package/dist/deploy/deploy-status.js +0 -36
- package/dist/deploy/detach.d.ts +0 -32
- package/dist/deploy/detach.js +0 -71
- package/dist/dev/__tests__/attach.test.d.ts +0 -1
- package/dist/dev/__tests__/attach.test.js +0 -296
- package/dist/dev/__tests__/detach.test.d.ts +0 -1
- package/dist/dev/__tests__/detach.test.js +0 -404
- package/dist/dev/__tests__/preview-url-poller.test.d.ts +0 -1
- package/dist/dev/__tests__/preview-url-poller.test.js +0 -149
- package/dist/dev/__tests__/session.test.d.ts +0 -1
- package/dist/dev/__tests__/session.test.js +0 -446
- package/dist/dev/__tests__/startup-sync.test.d.ts +0 -1
- package/dist/dev/__tests__/startup-sync.test.js +0 -32
- package/dist/dev/__tests__/stop.test.d.ts +0 -1
- package/dist/dev/__tests__/stop.test.js +0 -172
- package/dist/dev/attach.d.ts +0 -120
- package/dist/dev/attach.js +0 -269
- package/dist/dev/detach.d.ts +0 -187
- package/dist/dev/detach.js +0 -292
- package/dist/dev/preview-url-poller.d.ts +0 -35
- package/dist/dev/preview-url-poller.js +0 -50
- package/dist/dev/session.d.ts +0 -175
- package/dist/dev/session.js +0 -258
- package/dist/dev/startup-sync.d.ts +0 -23
- package/dist/dev/startup-sync.js +0 -14
- package/dist/dev/stop.d.ts +0 -52
- package/dist/dev/stop.js +0 -101
- package/dist/devtools/registry-data.d.ts +0 -46
- package/dist/devtools/registry-data.js +0 -40
- package/dist/generated/bundled-types.d.ts +0 -1
- package/dist/generated/bundled-types.js +0 -46
- package/dist/generated/version.d.ts +0 -1
- package/dist/generated/version.js +0 -2
- package/dist/git/__tests__/auto-commit.test.d.ts +0 -1
- package/dist/git/__tests__/auto-commit.test.js +0 -431
- package/dist/git/__tests__/classify-sync-error.test.d.ts +0 -1
- package/dist/git/__tests__/classify-sync-error.test.js +0 -57
- package/dist/git/__tests__/credential-helper-e2e.test.d.ts +0 -21
- package/dist/git/__tests__/credential-helper-e2e.test.js +0 -195
- package/dist/git/__tests__/credentials.test.d.ts +0 -1
- package/dist/git/__tests__/credentials.test.js +0 -141
- package/dist/git/__tests__/deploy-guard.test.d.ts +0 -1
- package/dist/git/__tests__/deploy-guard.test.js +0 -61
- package/dist/git/__tests__/ensure-git-credential-helper.test.d.ts +0 -1
- package/dist/git/__tests__/ensure-git-credential-helper.test.js +0 -133
- package/dist/git/__tests__/ensure-runwork-remote.test.d.ts +0 -1
- package/dist/git/__tests__/ensure-runwork-remote.test.js +0 -109
- package/dist/git/__tests__/identity.test.d.ts +0 -1
- package/dist/git/__tests__/identity.test.js +0 -146
- package/dist/git/__tests__/manifest.test.d.ts +0 -1
- package/dist/git/__tests__/manifest.test.js +0 -446
- package/dist/git/__tests__/preflight-resolution.test.d.ts +0 -1
- package/dist/git/__tests__/preflight-resolution.test.js +0 -366
- package/dist/git/__tests__/preflight.test.d.ts +0 -1
- package/dist/git/__tests__/preflight.test.js +0 -36
- package/dist/git/__tests__/repo-config.test.d.ts +0 -1
- package/dist/git/__tests__/repo-config.test.js +0 -26
- package/dist/git/__tests__/sync.test.d.ts +0 -1
- package/dist/git/__tests__/sync.test.js +0 -405
- package/dist/git/auto-commit.d.ts +0 -35
- package/dist/git/auto-commit.js +0 -293
- package/dist/git/classify-sync-error.d.ts +0 -21
- package/dist/git/classify-sync-error.js +0 -111
- package/dist/git/credentials.d.ts +0 -75
- package/dist/git/credentials.js +0 -164
- package/dist/git/critical-files.d.ts +0 -20
- package/dist/git/critical-files.js +0 -68
- package/dist/git/deploy-guard.d.ts +0 -53
- package/dist/git/deploy-guard.js +0 -78
- package/dist/git/identity.d.ts +0 -44
- package/dist/git/identity.js +0 -133
- package/dist/git/preflight.d.ts +0 -57
- package/dist/git/preflight.js +0 -276
- package/dist/git/remote.d.ts +0 -37
- package/dist/git/remote.js +0 -75
- package/dist/git/repo-config.d.ts +0 -8
- package/dist/git/repo-config.js +0 -29
- package/dist/git/sync.d.ts +0 -15
- package/dist/git/sync.js +0 -159
- package/dist/health/__tests__/checks.test.d.ts +0 -1
- package/dist/health/__tests__/checks.test.js +0 -357
- package/dist/health/__tests__/cli-distribution-checks.test.d.ts +0 -1
- package/dist/health/__tests__/cli-distribution-checks.test.js +0 -196
- package/dist/health/__tests__/fix.test.d.ts +0 -1
- package/dist/health/__tests__/fix.test.js +0 -72
- package/dist/health/__tests__/runner-filter.test.d.ts +0 -1
- package/dist/health/__tests__/runner-filter.test.js +0 -61
- package/dist/health/checks.d.ts +0 -42
- package/dist/health/checks.js +0 -636
- package/dist/health/fix.d.ts +0 -22
- package/dist/health/fix.js +0 -62
- package/dist/health/runner.d.ts +0 -8
- package/dist/health/runner.js +0 -47
- package/dist/health/types.d.ts +0 -12
- package/dist/health/types.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/logs/__tests__/tailer-format.test.d.ts +0 -1
- package/dist/logs/__tests__/tailer-format.test.js +0 -43
- package/dist/logs/tailer.d.ts +0 -17
- package/dist/logs/tailer.js +0 -217
- package/dist/sync/__tests__/change-detect.test.d.ts +0 -1
- package/dist/sync/__tests__/change-detect.test.js +0 -123
- package/dist/sync/__tests__/hash.test.d.ts +0 -1
- package/dist/sync/__tests__/hash.test.js +0 -18
- package/dist/sync/change-detect.d.ts +0 -19
- package/dist/sync/change-detect.js +0 -136
- package/dist/sync/conflict-ui.d.ts +0 -5
- package/dist/sync/conflict-ui.js +0 -78
- package/dist/sync/executor.d.ts +0 -23
- package/dist/sync/executor.js +0 -102
- package/dist/sync/hash.d.ts +0 -1
- package/dist/sync/hash.js +0 -4
- package/dist/sync/types.d.ts +0 -24
- package/dist/sync/types.js +0 -1
- package/dist/template/manifest.d.ts +0 -17
- package/dist/template/manifest.js +0 -145
- package/dist/tools/types.d.ts +0 -52
- package/dist/tools/types.js +0 -8
- package/dist/types-manager.d.ts +0 -1
- package/dist/types-manager.js +0 -35
- package/dist/types.d.ts +0 -349
- package/dist/types.js +0 -1
- package/dist/ui/__tests__/banner.test.d.ts +0 -1
- package/dist/ui/__tests__/banner.test.js +0 -98
- package/dist/ui/__tests__/colors.test.d.ts +0 -1
- package/dist/ui/__tests__/colors.test.js +0 -22
- package/dist/ui/__tests__/keyboard.test.d.ts +0 -1
- package/dist/ui/__tests__/keyboard.test.js +0 -34
- package/dist/ui/__tests__/status-line.test.d.ts +0 -1
- package/dist/ui/__tests__/status-line.test.js +0 -54
- package/dist/ui/banner.d.ts +0 -29
- package/dist/ui/banner.js +0 -153
- package/dist/ui/colors.d.ts +0 -4
- package/dist/ui/colors.js +0 -7
- package/dist/ui/keyboard.d.ts +0 -12
- package/dist/ui/keyboard.js +0 -61
- package/dist/ui/status-line.d.ts +0 -6
- package/dist/ui/status-line.js +0 -53
- package/dist/utils/__tests__/format-error.test.d.ts +0 -1
- package/dist/utils/__tests__/format-error.test.js +0 -43
- package/dist/utils/__tests__/help-json.test.d.ts +0 -1
- package/dist/utils/__tests__/help-json.test.js +0 -39
- package/dist/utils/__tests__/http.test.d.ts +0 -1
- package/dist/utils/__tests__/http.test.js +0 -381
- package/dist/utils/__tests__/ignore-matcher.test.d.ts +0 -1
- package/dist/utils/__tests__/ignore-matcher.test.js +0 -205
- package/dist/utils/__tests__/output.test.d.ts +0 -1
- package/dist/utils/__tests__/output.test.js +0 -38
- package/dist/utils/__tests__/prompt.test.d.ts +0 -1
- package/dist/utils/__tests__/prompt.test.js +0 -27
- package/dist/utils/__tests__/resolve.test.d.ts +0 -1
- package/dist/utils/__tests__/resolve.test.js +0 -95
- package/dist/utils/__tests__/sqlite.test.d.ts +0 -1
- package/dist/utils/__tests__/sqlite.test.js +0 -89
- package/dist/utils/agent-guidance.d.ts +0 -47
- package/dist/utils/agent-guidance.js +0 -128
- package/dist/utils/app-info.d.ts +0 -70
- package/dist/utils/app-info.js +0 -167
- package/dist/utils/curl-parser.d.ts +0 -12
- package/dist/utils/curl-parser.js +0 -162
- package/dist/utils/data-input.d.ts +0 -1
- package/dist/utils/data-input.js +0 -38
- package/dist/utils/format-error.d.ts +0 -10
- package/dist/utils/format-error.js +0 -38
- package/dist/utils/fs.d.ts +0 -5
- package/dist/utils/fs.js +0 -23
- package/dist/utils/help-json.d.ts +0 -70
- package/dist/utils/help-json.js +0 -88
- package/dist/utils/http.d.ts +0 -46
- package/dist/utils/http.js +0 -421
- package/dist/utils/ignore-matcher.d.ts +0 -47
- package/dist/utils/ignore-matcher.js +0 -132
- package/dist/utils/output.d.ts +0 -17
- package/dist/utils/output.js +0 -27
- package/dist/utils/prompt.d.ts +0 -5
- package/dist/utils/prompt.js +0 -42
- package/dist/utils/resolve.d.ts +0 -12
- package/dist/utils/resolve.js +0 -52
- package/dist/utils/setup-state.d.ts +0 -3
- package/dist/utils/setup-state.js +0 -19
- package/dist/utils/sqlite-adapter.d.ts +0 -48
- package/dist/utils/sqlite-adapter.js +0 -147
- package/dist/utils/sqlite.d.ts +0 -14
- package/dist/utils/sqlite.js +0 -14
- package/dist/utils/subprocess.d.ts +0 -19
- package/dist/utils/subprocess.js +0 -27
- package/dist/utils/which.d.ts +0 -14
- package/dist/utils/which.js +0 -47
- package/dist/utils/zip.d.ts +0 -7
- package/dist/utils/zip.js +0 -42
- package/dist/validate/__tests__/validate.test.d.ts +0 -1
- package/dist/validate/__tests__/validate.test.js +0 -42
- package/dist/validate/freshness.d.ts +0 -28
- package/dist/validate/freshness.js +0 -48
- package/dist/validate/preview.d.ts +0 -21
- package/dist/validate/preview.js +0 -39
- package/dist/workspace/resolve.d.ts +0 -19
- package/dist/workspace/resolve.js +0 -100
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { execFileSync } from 'child_process';
|
|
3
|
-
import { mkdtempSync, writeFileSync, readFileSync, rmSync, existsSync, mkdirSync, } from 'fs';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { tmpdir } from 'os';
|
|
6
|
-
import { isIgnored, commitWorkingTree } from '../auto-commit.js';
|
|
7
|
-
const tempDirs = [];
|
|
8
|
-
function makeTempDir(prefix) {
|
|
9
|
-
const dir = mkdtempSync(join(tmpdir(), `runwork-autocommit-test-${prefix}-`));
|
|
10
|
-
tempDirs.push(dir);
|
|
11
|
-
return dir;
|
|
12
|
-
}
|
|
13
|
-
function initGitRepo(dir) {
|
|
14
|
-
execFileSync('git', ['init', dir]);
|
|
15
|
-
execFileSync('git', ['config', 'user.email', 'test@test.com'], { cwd: dir });
|
|
16
|
-
execFileSync('git', ['config', 'user.name', 'Test'], { cwd: dir });
|
|
17
|
-
}
|
|
18
|
-
function createTestRepo() {
|
|
19
|
-
const remote = makeTempDir('remote');
|
|
20
|
-
execFileSync('git', ['init', '--bare', remote]);
|
|
21
|
-
const local = makeTempDir('local');
|
|
22
|
-
execFileSync('git', ['init', local]);
|
|
23
|
-
execFileSync('git', ['remote', 'add', 'runwork', remote], { cwd: local });
|
|
24
|
-
execFileSync('git', ['config', 'user.email', 'test@test.com'], { cwd: local });
|
|
25
|
-
execFileSync('git', ['config', 'user.name', 'Test'], { cwd: local });
|
|
26
|
-
return { local, remote };
|
|
27
|
-
}
|
|
28
|
-
function commitFile(repoDir, filename, content, message) {
|
|
29
|
-
const fullPath = join(repoDir, filename);
|
|
30
|
-
const dir = fullPath.substring(0, fullPath.lastIndexOf('/'));
|
|
31
|
-
if (dir !== repoDir && !existsSync(dir)) {
|
|
32
|
-
mkdirSync(dir, { recursive: true });
|
|
33
|
-
}
|
|
34
|
-
writeFileSync(fullPath, content);
|
|
35
|
-
execFileSync('git', ['add', filename], { cwd: repoDir });
|
|
36
|
-
execFileSync('git', ['commit', '-m', message], { cwd: repoDir });
|
|
37
|
-
}
|
|
38
|
-
afterEach(() => {
|
|
39
|
-
for (const dir of tempDirs) {
|
|
40
|
-
try {
|
|
41
|
-
rmSync(dir, { recursive: true, force: true });
|
|
42
|
-
}
|
|
43
|
-
catch { /* best effort */ }
|
|
44
|
-
}
|
|
45
|
-
tempDirs.length = 0;
|
|
46
|
-
});
|
|
47
|
-
// ============================================================
|
|
48
|
-
// isIgnored() unit tests
|
|
49
|
-
// ============================================================
|
|
50
|
-
describe('isIgnored()', () => {
|
|
51
|
-
it('ignores .git directory', () => {
|
|
52
|
-
expect(isIgnored('.git')).toBe(true);
|
|
53
|
-
expect(isIgnored('/path/to/.git')).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
it('ignores node_modules directory', () => {
|
|
56
|
-
expect(isIgnored('node_modules')).toBe(true);
|
|
57
|
-
expect(isIgnored('/path/to/node_modules')).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
it('ignores .runwork directory', () => {
|
|
60
|
-
expect(isIgnored('.runwork')).toBe(true);
|
|
61
|
-
expect(isIgnored('/project/.runwork')).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
it('ignores .dev.vars file', () => {
|
|
64
|
-
expect(isIgnored('.dev.vars')).toBe(true);
|
|
65
|
-
expect(isIgnored('/project/.dev.vars')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('ignores .env file (BUG FIX: was missing before)', () => {
|
|
68
|
-
expect(isIgnored('.env')).toBe(true);
|
|
69
|
-
expect(isIgnored('/project/.env')).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
it('ignores .log extension', () => {
|
|
72
|
-
expect(isIgnored('app.log')).toBe(true);
|
|
73
|
-
expect(isIgnored('/var/log/debug.log')).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
it('does not ignore normal files', () => {
|
|
76
|
-
expect(isIgnored('index.ts')).toBe(false);
|
|
77
|
-
expect(isIgnored('package.json')).toBe(false);
|
|
78
|
-
expect(isIgnored('vite.config.ts')).toBe(false);
|
|
79
|
-
expect(isIgnored('/project/src/app.tsx')).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
it('does not ignore files that contain skip names as substrings', () => {
|
|
82
|
-
// ".env.example" has basename ".env.example", not ".env"
|
|
83
|
-
expect(isIgnored('.env.example')).toBe(false);
|
|
84
|
-
expect(isIgnored('.env.local')).toBe(false);
|
|
85
|
-
// ".gitignore" has basename ".gitignore", not ".git"
|
|
86
|
-
expect(isIgnored('.gitignore')).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
it('BUG PROBE: does not ignore files INSIDE node_modules when given full path', () => {
|
|
89
|
-
// isIgnored uses basename(), so "node_modules/foo/bar.js" -> basename = "bar.js"
|
|
90
|
-
// This is fine because chokidar calls isIgnored on the directory entry first,
|
|
91
|
-
// so it never descends into node_modules. But if isIgnored is called with a
|
|
92
|
-
// full path directly, it would NOT catch files inside node_modules.
|
|
93
|
-
const fullPath = '/project/node_modules/some-package/index.js';
|
|
94
|
-
// basename is "index.js" - NOT in SKIP_DIRS
|
|
95
|
-
expect(isIgnored(fullPath)).toBe(false);
|
|
96
|
-
// This is acceptable because chokidar checks the directory first.
|
|
97
|
-
// But it means isIgnored is NOT safe for general-purpose use outside chokidar.
|
|
98
|
-
});
|
|
99
|
-
it('does not ignore files without extensions', () => {
|
|
100
|
-
expect(isIgnored('Makefile')).toBe(false);
|
|
101
|
-
expect(isIgnored('Dockerfile')).toBe(false);
|
|
102
|
-
expect(isIgnored('LICENSE')).toBe(false);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
// ============================================================
|
|
106
|
-
// Bug fix verification: .env file protection
|
|
107
|
-
// ============================================================
|
|
108
|
-
describe('.env file protection (BUG FIX)', () => {
|
|
109
|
-
it('.env file should NOT be staged by auto-commit git add -u', () => {
|
|
110
|
-
// Scenario: user has .env tracked in git (mistake), modifies it.
|
|
111
|
-
// auto-commit does `git add -u` which would stage it.
|
|
112
|
-
// The chokidar watcher should never fire for .env files.
|
|
113
|
-
const { local } = createTestRepo();
|
|
114
|
-
// Commit a .env file (simulating an initial mistake)
|
|
115
|
-
commitFile(local, '.env', 'SECRET=old', 'init with env');
|
|
116
|
-
// Modify it
|
|
117
|
-
writeFileSync(join(local, '.env'), 'SECRET=new_value_leaked');
|
|
118
|
-
// The isIgnored function should prevent chokidar from watching .env
|
|
119
|
-
expect(isIgnored('.env')).toBe(true);
|
|
120
|
-
// But even if chokidar somehow fired, the file should be ignored.
|
|
121
|
-
// The real protection is that isIgnored('.env') returns true,
|
|
122
|
-
// so changedFiles never includes it, so it won't be in filesToAdd.
|
|
123
|
-
// However, `git add -u` (line 152) stages ALL modified tracked files,
|
|
124
|
-
// including .env if it's tracked. This is a secondary concern —
|
|
125
|
-
// the primary fix is preventing chokidar from triggering.
|
|
126
|
-
});
|
|
127
|
-
it('.dev.vars file is also protected', () => {
|
|
128
|
-
expect(isIgnored('.dev.vars')).toBe(true);
|
|
129
|
-
});
|
|
130
|
-
it('REMAINING RISK: git add -u stages tracked .env even if chokidar ignores it', () => {
|
|
131
|
-
// This test documents a remaining risk: if .env is already tracked in git
|
|
132
|
-
// and gets modified outside the watcher, `git add -u` in commitAndPush()
|
|
133
|
-
// will still stage it. The isIgnored fix only prevents chokidar from
|
|
134
|
-
// firing events, but git add -u is unconditional.
|
|
135
|
-
const { local } = createTestRepo();
|
|
136
|
-
commitFile(local, 'index.ts', 'export {}', 'init');
|
|
137
|
-
commitFile(local, '.env', 'SECRET=123', 'add env (mistake)');
|
|
138
|
-
// Modify both files
|
|
139
|
-
writeFileSync(join(local, 'index.ts'), 'export { hello }');
|
|
140
|
-
writeFileSync(join(local, '.env'), 'SECRET=leaked_value');
|
|
141
|
-
// Simulate what commitAndPush does: git add -u
|
|
142
|
-
execFileSync('git', ['add', '-u'], { cwd: local, stdio: 'pipe' });
|
|
143
|
-
const staged = execFileSync('git', ['diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
144
|
-
// BUG: git add -u stages .env if it's tracked, even though isIgnored
|
|
145
|
-
// prevents chokidar from watching it. The user's .env modification
|
|
146
|
-
// from another editor would still be committed on the next auto-commit
|
|
147
|
-
// cycle triggered by any other file change.
|
|
148
|
-
expect(staged.split('\n')).toContain('.env');
|
|
149
|
-
// This is a known risk - the fix prevents most .env commits (via chokidar),
|
|
150
|
-
// but doesn't prevent `git add -u` from staging tracked .env files.
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
// ============================================================
|
|
154
|
-
// Bug fix verification: unicode filenames in git diff --cached
|
|
155
|
-
// ============================================================
|
|
156
|
-
describe('unicode filename handling in commitAndPush (BUG FIX)', () => {
|
|
157
|
-
it('git diff --cached with core.quotePath=false returns real filenames', () => {
|
|
158
|
-
const { local } = createTestRepo();
|
|
159
|
-
// Create and commit a unicode filename
|
|
160
|
-
const filename = 'caf\u00e9.txt';
|
|
161
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
162
|
-
// Stage a unicode file
|
|
163
|
-
writeFileSync(join(local, filename), 'content');
|
|
164
|
-
execFileSync('git', ['add', filename], { cwd: local });
|
|
165
|
-
// WITHOUT fix: git diff --cached --name-only returns octal-escaped
|
|
166
|
-
const withoutFix = execFileSync('git', ['diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
167
|
-
// WITH fix: git -c core.quotePath=false diff --cached --name-only returns real name
|
|
168
|
-
const withFix = execFileSync('git', ['-c', 'core.quotePath=false', 'diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
169
|
-
// The fixed version should contain the actual unicode character
|
|
170
|
-
expect(withFix).toContain('caf\u00e9.txt');
|
|
171
|
-
// The unfixed version may contain octal escaping (depends on git config)
|
|
172
|
-
// On most systems, git.quotePath defaults to true for non-ASCII
|
|
173
|
-
if (withoutFix.includes('\\')) {
|
|
174
|
-
// Confirms the bug existed: without the fix, git returns escaped names
|
|
175
|
-
expect(withoutFix).not.toContain('caf\u00e9');
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
it('staged file count is correct with unicode filenames', () => {
|
|
179
|
-
const { local } = createTestRepo();
|
|
180
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
181
|
-
// Stage multiple files including unicode names
|
|
182
|
-
const files = ['normal.txt', 'caf\u00e9.txt', '\u00fcber.ts', 'na\u00efve.md'];
|
|
183
|
-
for (const f of files) {
|
|
184
|
-
writeFileSync(join(local, f), `content of ${f}`);
|
|
185
|
-
execFileSync('git', ['add', f], { cwd: local });
|
|
186
|
-
}
|
|
187
|
-
const staged = execFileSync('git', ['-c', 'core.quotePath=false', 'diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
188
|
-
const stagedFiles = staged.split('\n').filter(Boolean);
|
|
189
|
-
expect(stagedFiles).toHaveLength(files.length);
|
|
190
|
-
for (const f of files) {
|
|
191
|
-
expect(stagedFiles).toContain(f);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
// ============================================================
|
|
196
|
-
// Real-life scenario tests
|
|
197
|
-
// ============================================================
|
|
198
|
-
describe('real-life auto-commit scenarios', () => {
|
|
199
|
-
it('handles rapid file writes without losing changes', () => {
|
|
200
|
-
// Scenario: IDE save-all writes 10 files in quick succession.
|
|
201
|
-
// All should be captured for staging.
|
|
202
|
-
const { local } = createTestRepo();
|
|
203
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
204
|
-
// Rapidly create files (simulating what changedFiles set would collect)
|
|
205
|
-
const files = Array.from({ length: 10 }, (_, i) => `file-${i}.ts`);
|
|
206
|
-
for (const f of files) {
|
|
207
|
-
writeFileSync(join(local, f), `export const x${f.replace(/\W/g, '')} = true;`);
|
|
208
|
-
}
|
|
209
|
-
// Stage them all (simulating what commitAndPush does)
|
|
210
|
-
execFileSync('git', ['add', '--', ...files], { cwd: local, stdio: 'pipe' });
|
|
211
|
-
const staged = execFileSync('git', ['-c', 'core.quotePath=false', 'diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim().split('\n').filter(Boolean);
|
|
212
|
-
expect(staged).toHaveLength(10);
|
|
213
|
-
});
|
|
214
|
-
it('handles files deleted between detection and staging', () => {
|
|
215
|
-
// Scenario: chokidar fires for a temp file that gets deleted
|
|
216
|
-
// before git add runs. git add throws for non-existent files,
|
|
217
|
-
// but commitAndPush wraps it in try/catch so it's handled gracefully.
|
|
218
|
-
const { local } = createTestRepo();
|
|
219
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
220
|
-
const tempFile = join(local, 'temp.txt');
|
|
221
|
-
writeFileSync(tempFile, 'temporary');
|
|
222
|
-
// Delete before staging
|
|
223
|
-
rmSync(tempFile);
|
|
224
|
-
// git add -- temp.txt DOES throw for non-existent files
|
|
225
|
-
let threw = false;
|
|
226
|
-
try {
|
|
227
|
-
execFileSync('git', ['add', '--', 'temp.txt'], { cwd: local, stdio: 'pipe' });
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
threw = true;
|
|
231
|
-
}
|
|
232
|
-
// Confirmed: git add throws. commitAndPush catches this per batch.
|
|
233
|
-
expect(threw).toBe(true);
|
|
234
|
-
});
|
|
235
|
-
it('batch staging handles more than 50 files correctly', () => {
|
|
236
|
-
// commitAndPush batches git add into groups of 50.
|
|
237
|
-
// Verify nothing gets lost at batch boundaries.
|
|
238
|
-
const { local } = createTestRepo();
|
|
239
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
240
|
-
const fileCount = 120; // 50 + 50 + 20
|
|
241
|
-
const files = [];
|
|
242
|
-
for (let i = 0; i < fileCount; i++) {
|
|
243
|
-
const name = `batch-${String(i).padStart(3, '0')}.ts`;
|
|
244
|
-
writeFileSync(join(local, name), `export const x = ${i};`);
|
|
245
|
-
files.push(name);
|
|
246
|
-
}
|
|
247
|
-
// Simulate batch staging from commitAndPush
|
|
248
|
-
const BATCH_SIZE = 50;
|
|
249
|
-
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
250
|
-
const batch = files.slice(i, i + BATCH_SIZE);
|
|
251
|
-
execFileSync('git', ['add', '--', ...batch], { cwd: local, stdio: 'pipe' });
|
|
252
|
-
}
|
|
253
|
-
const staged = execFileSync('git', ['-c', 'core.quotePath=false', 'diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim().split('\n').filter(Boolean);
|
|
254
|
-
expect(staged).toHaveLength(fileCount);
|
|
255
|
-
});
|
|
256
|
-
it('commit message includes ISO timestamp', () => {
|
|
257
|
-
const { local } = createTestRepo();
|
|
258
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
259
|
-
writeFileSync(join(local, 'new.ts'), 'export {}');
|
|
260
|
-
execFileSync('git', ['add', 'new.ts'], { cwd: local, stdio: 'pipe' });
|
|
261
|
-
const timestamp = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
262
|
-
execFileSync('git', ['commit', '-m', `dev: updated ${timestamp}`], { cwd: local, stdio: 'pipe' });
|
|
263
|
-
const log = execFileSync('git', ['log', '-1', '--format=%s'], {
|
|
264
|
-
cwd: local, encoding: 'utf-8',
|
|
265
|
-
}).trim();
|
|
266
|
-
expect(log).toMatch(/^dev: updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
|
|
267
|
-
});
|
|
268
|
-
it('pull --rebase then push works after remote has new commits', () => {
|
|
269
|
-
const { local, remote } = createTestRepo();
|
|
270
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
271
|
-
execFileSync('git', ['push', 'runwork', 'main'], { cwd: local, stdio: 'pipe' });
|
|
272
|
-
// Simulate remote commit (e.g. DO onStart creating files)
|
|
273
|
-
const secondary = makeTempDir('secondary');
|
|
274
|
-
execFileSync('git', ['clone', remote, secondary]);
|
|
275
|
-
execFileSync('git', ['config', 'user.email', 'server@test.com'], { cwd: secondary });
|
|
276
|
-
execFileSync('git', ['config', 'user.name', 'Server'], { cwd: secondary });
|
|
277
|
-
commitFile(secondary, 'server-file.txt', 'from server', 'server: init');
|
|
278
|
-
execFileSync('git', ['push', 'origin', 'main'], { cwd: secondary, stdio: 'pipe' });
|
|
279
|
-
// Local commit (user edit)
|
|
280
|
-
commitFile(local, 'user-file.ts', 'export {}', 'dev: user edit');
|
|
281
|
-
// Simulate commitAndPush: pull --rebase then push
|
|
282
|
-
execFileSync('git', ['pull', '--rebase', 'runwork', 'main'], { cwd: local, stdio: 'pipe' });
|
|
283
|
-
execFileSync('git', ['push', 'runwork', 'main'], { cwd: local, stdio: 'pipe' });
|
|
284
|
-
// Both files should exist
|
|
285
|
-
expect(existsSync(join(local, 'server-file.txt'))).toBe(true);
|
|
286
|
-
expect(existsSync(join(local, 'user-file.ts'))).toBe(true);
|
|
287
|
-
});
|
|
288
|
-
it('merge with --allow-unrelated-histories combines diverged trees', () => {
|
|
289
|
-
// Scenario: template update on web UI rewrites history.
|
|
290
|
-
// The merge fallback (used when rebase fails) should combine both trees.
|
|
291
|
-
const { local, remote } = createTestRepo();
|
|
292
|
-
commitFile(local, 'local-file.txt', 'local content', 'local init');
|
|
293
|
-
// Create a completely separate history on the remote
|
|
294
|
-
const other = makeTempDir('template-update');
|
|
295
|
-
execFileSync('git', ['init', other]);
|
|
296
|
-
execFileSync('git', ['config', 'user.email', 'server@test.com'], { cwd: other });
|
|
297
|
-
execFileSync('git', ['config', 'user.name', 'Server'], { cwd: other });
|
|
298
|
-
commitFile(other, 'template-file.txt', 'new template', 'template: v2');
|
|
299
|
-
execFileSync('git', ['remote', 'add', 'origin', remote], { cwd: other });
|
|
300
|
-
execFileSync('git', ['push', 'origin', 'main'], { cwd: other, stdio: 'pipe' });
|
|
301
|
-
// Fetch remote
|
|
302
|
-
execFileSync('git', ['fetch', 'runwork', 'main'], { cwd: local, stdio: 'pipe' });
|
|
303
|
-
// Merge with unrelated histories
|
|
304
|
-
execFileSync('git', ['merge', 'runwork/main', '--allow-unrelated-histories', '--no-edit'], { cwd: local, stdio: 'pipe' });
|
|
305
|
-
// Both files should exist after merge
|
|
306
|
-
expect(existsSync(join(local, 'local-file.txt'))).toBe(true);
|
|
307
|
-
expect(existsSync(join(local, 'template-file.txt'))).toBe(true);
|
|
308
|
-
});
|
|
309
|
-
it('binary files are excluded from fast sync but included in git', () => {
|
|
310
|
-
// Scenario: user adds an image file. Fast sync should skip it,
|
|
311
|
-
// but git should still commit and push it.
|
|
312
|
-
const { local } = createTestRepo();
|
|
313
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
314
|
-
const binaryExtensions = ['.png', '.jpg', '.woff2', '.pdf', '.wasm'];
|
|
315
|
-
for (const ext of binaryExtensions) {
|
|
316
|
-
writeFileSync(join(local, `file${ext}`), Buffer.from([0x00, 0xFF, 0x89, 0x50]));
|
|
317
|
-
}
|
|
318
|
-
// All binary files should be stageable by git
|
|
319
|
-
execFileSync('git', ['add', '.'], { cwd: local, stdio: 'pipe' });
|
|
320
|
-
const staged = execFileSync('git', ['-c', 'core.quotePath=false', 'diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim().split('\n').filter(Boolean);
|
|
321
|
-
for (const ext of binaryExtensions) {
|
|
322
|
-
expect(staged).toContain(`file${ext}`);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
it('handles .gitignore interaction: ignored files not staged by git add -u', () => {
|
|
326
|
-
// Scenario: user has .gitignore. Modified ignored files should NOT
|
|
327
|
-
// be staged by git add -u.
|
|
328
|
-
const { local } = createTestRepo();
|
|
329
|
-
writeFileSync(join(local, '.gitignore'), 'dist/\n*.tmp\n');
|
|
330
|
-
commitFile(local, '.gitignore', readFileSync(join(local, '.gitignore'), 'utf-8'), 'add gitignore');
|
|
331
|
-
commitFile(local, 'src/app.ts', 'export {}', 'init');
|
|
332
|
-
// Create ignored files
|
|
333
|
-
mkdirSync(join(local, 'dist'));
|
|
334
|
-
writeFileSync(join(local, 'dist', 'bundle.js'), 'compiled');
|
|
335
|
-
writeFileSync(join(local, 'temp.tmp'), 'temporary');
|
|
336
|
-
// git add -u should NOT stage ignored files
|
|
337
|
-
execFileSync('git', ['add', '-u'], { cwd: local, stdio: 'pipe' });
|
|
338
|
-
const staged = execFileSync('git', ['diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
339
|
-
// Nothing should be staged (only gitignored files were modified)
|
|
340
|
-
expect(staged).toBe('');
|
|
341
|
-
});
|
|
342
|
-
it('handles empty working directory after initial commit', () => {
|
|
343
|
-
// Edge case: all files deleted, nothing to stage
|
|
344
|
-
const { local } = createTestRepo();
|
|
345
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
346
|
-
execFileSync('git', ['rm', 'init.txt'], { cwd: local, stdio: 'pipe' });
|
|
347
|
-
execFileSync('git', ['commit', '-m', 'delete all'], { cwd: local, stdio: 'pipe' });
|
|
348
|
-
// git add -u with nothing to add
|
|
349
|
-
execFileSync('git', ['add', '-u'], { cwd: local, stdio: 'pipe' });
|
|
350
|
-
const staged = execFileSync('git', ['diff', '--cached', '--name-only'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
351
|
-
expect(staged).toBe('');
|
|
352
|
-
});
|
|
353
|
-
it('commitWorkingTree stages and commits new untracked files (deploy path)', () => {
|
|
354
|
-
// Deploy must commit pending working-tree changes even when no dev
|
|
355
|
-
// session ever ran -- including brand-new untracked files.
|
|
356
|
-
const { local } = createTestRepo();
|
|
357
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
358
|
-
writeFileSync(join(local, 'new-feature.ts'), 'export const feature = true;');
|
|
359
|
-
mkdirSync(join(local, 'src'));
|
|
360
|
-
writeFileSync(join(local, 'src', 'page.tsx'), 'export default () => null;');
|
|
361
|
-
const result = commitWorkingTree(local, 'deploy: test');
|
|
362
|
-
expect(result.committed).toBe(true);
|
|
363
|
-
expect(result.fileCount).toBe(2);
|
|
364
|
-
const log = execFileSync('git', ['log', '-1', '--format=%s'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
365
|
-
expect(log).toBe('deploy: test');
|
|
366
|
-
const status = execFileSync('git', ['status', '--porcelain'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
367
|
-
expect(status).toBe('');
|
|
368
|
-
});
|
|
369
|
-
it('commitWorkingTree stages tracked modifications and deletions', () => {
|
|
370
|
-
const { local } = createTestRepo();
|
|
371
|
-
commitFile(local, 'keep.ts', 'export const a = 1;', 'init');
|
|
372
|
-
commitFile(local, 'remove.ts', 'export const b = 2;', 'add remove');
|
|
373
|
-
writeFileSync(join(local, 'keep.ts'), 'export const a = 99;');
|
|
374
|
-
rmSync(join(local, 'remove.ts'));
|
|
375
|
-
const result = commitWorkingTree(local, 'deploy: edits');
|
|
376
|
-
expect(result.committed).toBe(true);
|
|
377
|
-
expect(result.fileCount).toBe(2);
|
|
378
|
-
expect(existsSync(join(local, 'remove.ts'))).toBe(false);
|
|
379
|
-
});
|
|
380
|
-
it('commitWorkingTree returns committed=false on a clean tree', () => {
|
|
381
|
-
const { local } = createTestRepo();
|
|
382
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
383
|
-
const result = commitWorkingTree(local, 'deploy: noop');
|
|
384
|
-
expect(result.committed).toBe(false);
|
|
385
|
-
expect(result.fileCount).toBe(0);
|
|
386
|
-
const count = execFileSync('git', ['rev-list', '--count', 'HEAD'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
387
|
-
expect(count).toBe('1');
|
|
388
|
-
});
|
|
389
|
-
it('commitWorkingTree does NOT stage untracked secrets / ignored dirs (matches dev, not git add -A)', () => {
|
|
390
|
-
// SECURITY: a bare `.env` is not in the runwork-app .gitignore, so a
|
|
391
|
-
// blanket `git add -A` would commit and push it. commitWorkingTree must
|
|
392
|
-
// filter untracked files through the CLI ignore matcher, exactly like
|
|
393
|
-
// the dev watcher, so local secrets never reach the remote.
|
|
394
|
-
const { local } = createTestRepo();
|
|
395
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
396
|
-
// Real source that SHOULD be committed.
|
|
397
|
-
writeFileSync(join(local, 'app.ts'), 'export const x = 1;');
|
|
398
|
-
// Secrets / caches that MUST NOT be committed.
|
|
399
|
-
writeFileSync(join(local, '.env'), 'SECRET=do_not_leak');
|
|
400
|
-
writeFileSync(join(local, '.dev.vars'), 'WORKSPACE_API_KEY=do_not_leak');
|
|
401
|
-
mkdirSync(join(local, '.bun-cache'));
|
|
402
|
-
writeFileSync(join(local, '.bun-cache', 'pkg.json'), '{}');
|
|
403
|
-
const result = commitWorkingTree(local, 'deploy: test');
|
|
404
|
-
expect(result.committed).toBe(true);
|
|
405
|
-
const tracked = execFileSync('git', ['ls-files'], { cwd: local, encoding: 'utf-8' }).trim().split('\n');
|
|
406
|
-
expect(tracked).toContain('app.ts');
|
|
407
|
-
expect(tracked).not.toContain('.env');
|
|
408
|
-
expect(tracked).not.toContain('.dev.vars');
|
|
409
|
-
expect(tracked.some((f) => f.startsWith('.bun-cache/'))).toBe(false);
|
|
410
|
-
});
|
|
411
|
-
it('push -u sets upstream on first push', () => {
|
|
412
|
-
// commitAndPush tries `git rev-parse --abbrev-ref @{u}` to check
|
|
413
|
-
// for upstream. If it fails, it uses `push -u` to set upstream.
|
|
414
|
-
const { local, remote } = createTestRepo();
|
|
415
|
-
commitFile(local, 'init.txt', 'hello', 'init');
|
|
416
|
-
// No upstream configured yet
|
|
417
|
-
let hasUpstream = true;
|
|
418
|
-
try {
|
|
419
|
-
execFileSync('git', ['rev-parse', '--abbrev-ref', '@{u}'], { cwd: local, stdio: 'pipe' });
|
|
420
|
-
}
|
|
421
|
-
catch {
|
|
422
|
-
hasUpstream = false;
|
|
423
|
-
}
|
|
424
|
-
expect(hasUpstream).toBe(false);
|
|
425
|
-
// Push with -u to set upstream
|
|
426
|
-
execFileSync('git', ['push', '-u', 'runwork', 'main'], { cwd: local, stdio: 'pipe' });
|
|
427
|
-
// Now upstream should be set
|
|
428
|
-
const upstream = execFileSync('git', ['rev-parse', '--abbrev-ref', '@{u}'], { cwd: local, encoding: 'utf-8' }).trim();
|
|
429
|
-
expect(upstream).toBe('runwork/main');
|
|
430
|
-
});
|
|
431
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { classifySyncError, diagnoseSyncError } from '../classify-sync-error.js';
|
|
3
|
-
describe('git/classify-sync-error', () => {
|
|
4
|
-
describe('classifySyncError()', () => {
|
|
5
|
-
it('detects a missing/misnamed runwork remote', () => {
|
|
6
|
-
expect(classifySyncError("fatal: 'runwork' does not appear to be a git repository")).toBe('no-remote');
|
|
7
|
-
expect(classifySyncError('fatal: No such remote: runwork')).toBe('no-remote');
|
|
8
|
-
});
|
|
9
|
-
it('detects authentication failures', () => {
|
|
10
|
-
expect(classifySyncError('fatal: Authentication failed for https://runwork.ai/...')).toBe('auth');
|
|
11
|
-
expect(classifySyncError('fatal: could not read Username for https://runwork.ai: terminal prompts disabled')).toBe('auth');
|
|
12
|
-
expect(classifySyncError("fatal: unable to access '...': The requested URL returned error: 403")).toBe('auth');
|
|
13
|
-
});
|
|
14
|
-
it('detects network failures', () => {
|
|
15
|
-
expect(classifySyncError("fatal: unable to access '...': Could not resolve host: runwork.ai")).toBe('network');
|
|
16
|
-
expect(classifySyncError('fatal: unable to access: Failed to connect to runwork.ai port 443: Connection timed out')).toBe('network');
|
|
17
|
-
});
|
|
18
|
-
it('detects merge/rebase conflicts and the stash-conflict sentinel', () => {
|
|
19
|
-
expect(classifySyncError('CONFLICT (content): Merge conflict in src/App.tsx')).toBe('conflict');
|
|
20
|
-
expect(classifySyncError('error: Automatic merge failed')).toBe('conflict');
|
|
21
|
-
expect(classifySyncError('stash-conflict')).toBe('conflict');
|
|
22
|
-
});
|
|
23
|
-
it('falls back to unknown for unrecognized errors and empty input', () => {
|
|
24
|
-
expect(classifySyncError('some unexpected git failure')).toBe('unknown');
|
|
25
|
-
expect(classifySyncError(undefined)).toBe('unknown');
|
|
26
|
-
expect(classifySyncError('')).toBe('unknown');
|
|
27
|
-
});
|
|
28
|
-
it('is case-insensitive', () => {
|
|
29
|
-
expect(classifySyncError('AUTHENTICATION FAILED')).toBe('auth');
|
|
30
|
-
expect(classifySyncError('could not resolve HOST')).toBe('network');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('diagnoseSyncError()', () => {
|
|
34
|
-
it('points a no-remote failure at doctor --fix, not network/session', () => {
|
|
35
|
-
const d = diagnoseSyncError("fatal: 'runwork' does not appear to be a git repository");
|
|
36
|
-
expect(d.reason).toBe('no-remote');
|
|
37
|
-
expect(d.suggestions.join(' ')).toContain('runwork doctor --fix');
|
|
38
|
-
// Must NOT regress to the old misleading "session expired / network" advice.
|
|
39
|
-
expect(d.diagnosis.toLowerCase()).not.toContain('session expired');
|
|
40
|
-
});
|
|
41
|
-
it('points an auth failure at credential-helper remediation', () => {
|
|
42
|
-
const d = diagnoseSyncError('fatal: Authentication failed');
|
|
43
|
-
expect(d.reason).toBe('auth');
|
|
44
|
-
expect(d.suggestions.join(' ')).toContain('runwork doctor --fix');
|
|
45
|
-
});
|
|
46
|
-
it('gives stash-conflict a restore-specific message', () => {
|
|
47
|
-
const d = diagnoseSyncError('stash-conflict');
|
|
48
|
-
expect(d.reason).toBe('conflict');
|
|
49
|
-
expect(d.message).toContain('restoring local changes');
|
|
50
|
-
});
|
|
51
|
-
it('preserves the raw error in the unknown-case message', () => {
|
|
52
|
-
const d = diagnoseSyncError('weird git explosion');
|
|
53
|
-
expect(d.reason).toBe('unknown');
|
|
54
|
-
expect(d.message).toBe('weird git explosion');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* End-to-end auth test.
|
|
3
|
-
*
|
|
4
|
-
* Spins up a tiny HTTP server that mimics the runwork.ai git endpoint's
|
|
5
|
-
* auth contract (HTTP Basic, any username, password = API key) and runs a
|
|
6
|
-
* real `git ls-remote` against it through a credential-helper script. This
|
|
7
|
-
* verifies the entire chain we depend on:
|
|
8
|
-
*
|
|
9
|
-
* git -> credential.<origin>.helper -> our helper script -> our helper's
|
|
10
|
-
* protocol output -> git constructs Basic auth -> server accepts it.
|
|
11
|
-
*
|
|
12
|
-
* Catches the class of bugs we've burned hours on (Pass 1's PATH issues,
|
|
13
|
-
* Pass 2's "logged in but no helper registered") *before* a user hits them.
|
|
14
|
-
*
|
|
15
|
-
* Note: this test exercises the contract our credential helper depends on,
|
|
16
|
-
* not the helper function itself -- credentials.test.ts already covers
|
|
17
|
-
* `handleGitCredentialRequest()` in isolation. Together they prove that
|
|
18
|
-
* (a) the helper produces the right protocol output and (b) git+server
|
|
19
|
-
* accept that output as Basic auth.
|
|
20
|
-
*/
|
|
21
|
-
export {};
|