@sushanglewis/lincoln 1.5.0 → 1.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/main.d.ts +3 -0
- package/dist/main.js +1286 -916
- package/dist/main.js.map +1 -1
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.js +18 -0
- package/dist/postinstall.js.map +1 -0
- package/framework/.claude/agents/_contract.md +79 -0
- package/framework/.claude/agents/architect.md +31 -0
- package/framework/.claude/agents/default.md +151 -0
- package/framework/.claude/agents/designer.md +33 -0
- package/framework/.claude/agents/engineer.md +42 -0
- package/framework/.claude/agents/external/NOTICES.md +12 -0
- package/framework/.claude/agents/external/everything-claude-code.manifest.yaml +23 -0
- package/framework/.claude/agents/external/oh-my-claudecode.manifest.yaml +26 -0
- package/framework/.claude/agents/external/wshobson-agents.manifest.yaml +23 -0
- package/framework/.claude/agents/frontend-engineer.md +32 -0
- package/framework/.claude/agents/knowledge-curator.md +28 -0
- package/framework/.claude/agents/pm.md +38 -0
- package/framework/.claude/agents/qa.md +28 -0
- package/framework/.claude/agents/release-coordinator.md +25 -0
- package/framework/.claude/agents/researcher.md +41 -0
- package/framework/.claude/harnesses/claude-code.yaml +15 -0
- package/framework/.claude/harnesses/codex.yaml +40 -0
- package/framework/.claude/harnesses/command-map.yaml +255 -0
- package/framework/.claude/harnesses/opencode.yaml +32 -0
- package/framework/.claude/harnesses/scenarios.yaml +45 -0
- package/framework/.claude/hooks/on-pr-event.sh +69 -0
- package/framework/.claude/hooks/on-session-start.sh +427 -0
- package/framework/.claude/hooks/on-stop.sh +104 -0
- package/framework/.claude/hooks/post-tool-use.sh +161 -0
- package/framework/.claude/hooks/pre-tool-use.sh +246 -0
- package/framework/.claude/schemas/agent-definition.schema.json +35 -0
- package/framework/.claude/schemas/benchmark-report.schema.json +148 -0
- package/framework/.claude/schemas/pm-to-ux-handoff.schema.yaml +128 -0
- package/framework/.claude/schemas/stage-definition.schema.json +233 -0
- package/framework/.claude/schemas/workflow-stage.schema.json +86 -0
- package/framework/.claude/schemas/workflow-template.schema.json +88 -0
- package/framework/.claude/settings.json +14 -0
- package/framework/.claude/skills/build-product-prototype/SKILL.md +35 -0
- package/framework/.claude/skills/build-product-prototype/prompts/main.md +78 -0
- package/framework/.claude/skills/clarify-requirements/SKILL.md +32 -0
- package/framework/.claude/skills/clarify-requirements/prompts/main.md +81 -0
- package/framework/.claude/skills/dependencies.yaml +139 -0
- package/framework/.claude/skills/draft-product-design/SKILL.md +40 -0
- package/framework/.claude/skills/draft-product-design/prompts/main.md +47 -0
- package/framework/.claude/skills/lc-analyze-frameworks/SKILL.md +43 -0
- package/framework/.claude/skills/lc-analyze-frameworks/prompts/main.md +95 -0
- package/framework/.claude/skills/lc-benchmark/SKILL.md +61 -0
- package/framework/.claude/skills/lc-build-codebase-knowledge/SKILL.md +38 -0
- package/framework/.claude/skills/lc-build-codebase-knowledge/prompts/build-codebase-knowledge.md +61 -0
- package/framework/.claude/skills/lc-collect-intelligence/SKILL.md +43 -0
- package/framework/.claude/skills/lc-collect-intelligence/prompts/main.md +72 -0
- package/framework/.claude/skills/lc-competitive-analysis/SKILL.md +43 -0
- package/framework/.claude/skills/lc-competitive-analysis/prompts/main.md +70 -0
- package/framework/.claude/skills/lc-explore-opensource/SKILL.md +36 -0
- package/framework/.claude/skills/lc-explore-opensource/prompts/explore-opensource.md +77 -0
- package/framework/.claude/skills/lc-first-principles/SKILL.md +43 -0
- package/framework/.claude/skills/lc-first-principles/prompts/main.md +73 -0
- package/framework/.claude/skills/lc-handoff/SKILL.md +34 -0
- package/framework/.claude/skills/lc-init-branch/SKILL.md +52 -0
- package/framework/.claude/skills/lc-market-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-market-research/prompts/main.md +79 -0
- package/framework/.claude/skills/lc-product-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-product-research/prompts/main.md +80 -0
- package/framework/.claude/skills/lc-research-report/SKILL.md +43 -0
- package/framework/.claude/skills/lc-research-report/prompts/main.md +90 -0
- package/framework/.claude/skills/lc-research-scope/SKILL.md +43 -0
- package/framework/.claude/skills/lc-research-scope/prompts/main.md +82 -0
- package/framework/.claude/skills/lc-setup/SKILL.md +68 -0
- package/framework/.claude/skills/lc-setup/prompts/main.md +88 -0
- package/framework/.claude/skills/lc-stage/SKILL.md +45 -0
- package/framework/.claude/skills/lc-stakeholder-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-stakeholder-research/prompts/main.md +65 -0
- package/framework/.claude/skills/lc-status/SKILL.md +25 -0
- package/framework/.claude/skills/lc-storytelling/SKILL.md +43 -0
- package/framework/.claude/skills/lc-storytelling/prompts/main.md +77 -0
- package/framework/.claude/skills/lc-wf/SKILL.md +54 -0
- package/framework/.claude/skills/lc-workflow/SKILL.md +48 -0
- package/framework/.claude/skills/lc-workflow/validators/validate.py +755 -0
- package/framework/.claude/skills/lc-workflow-router/SKILL.md +41 -0
- package/framework/.claude/skills/lc-workflow-router/prompts/intake-prompt.md +91 -0
- package/framework/.claude/skills/lc-workflow-router/prompts/router-prompt.md +44 -0
- package/framework/.claude/skills/plan-tdd-development/SKILL.md +31 -0
- package/framework/.claude/skills/plan-tdd-development/prompts/main.md +44 -0
- package/framework/.claude/skills/process-interview/SKILL.md +32 -0
- package/framework/.claude/skills/process-interview/prompts/main.md +47 -0
- package/framework/.claude/skills/propose-with-openspec/SKILL.md +37 -0
- package/framework/.claude/skills/propose-with-openspec/prompts/main.md +53 -0
- package/framework/.claude/skills/split-to-github/SKILL.md +32 -0
- package/framework/.claude/skills/split-to-github/prompts/main.md +42 -0
- package/framework/.claude/skills/sync-to-knowledge/SKILL.md +35 -0
- package/framework/.claude/skills/sync-to-knowledge/prompts/main.md +54 -0
- package/framework/.claude/skills/workflow-continue/SKILL.md +24 -0
- package/framework/.claude/skills/workflow-continue/prompts/main.md +25 -0
- package/framework/.claude/stages/build-codebase-knowledge.yaml +42 -0
- package/framework/.claude/stages/clarify.yaml +59 -0
- package/framework/.claude/stages/explore-opensource.yaml +40 -0
- package/framework/.claude/stages/implement.yaml +60 -0
- package/framework/.claude/stages/ingest.yaml +40 -0
- package/framework/.claude/stages/lc-analyze-frameworks.yaml +37 -0
- package/framework/.claude/stages/lc-collect-intelligence.yaml +37 -0
- package/framework/.claude/stages/lc-competitive-analysis.yaml +37 -0
- package/framework/.claude/stages/lc-first-principles.yaml +37 -0
- package/framework/.claude/stages/lc-market-research.yaml +37 -0
- package/framework/.claude/stages/lc-product-research.yaml +37 -0
- package/framework/.claude/stages/lc-research-report.yaml +38 -0
- package/framework/.claude/stages/lc-research-scope.yaml +38 -0
- package/framework/.claude/stages/lc-stakeholder-research.yaml +37 -0
- package/framework/.claude/stages/lc-storytelling.yaml +37 -0
- package/framework/.claude/stages/product-design-docs.yaml +66 -0
- package/framework/.claude/stages/product-prototype.yaml +53 -0
- package/framework/.claude/stages/propose.yaml +45 -0
- package/framework/.claude/stages/split.yaml +41 -0
- package/framework/.claude/stages/sync-knowledge.yaml +49 -0
- package/framework/.claude/stages/tdd-development-plan.yaml +43 -0
- package/framework/.claude/stages/workflow-router.yaml +45 -0
- package/framework/.claude/templates/solo-workflow-context.yaml +23 -0
- package/framework/.claude/workflows/README.md +93 -0
- package/framework/.claude/workflows/bug-fix.yaml +81 -0
- package/framework/.claude/workflows/design-spike.yaml +55 -0
- package/framework/.claude/workflows/existing-project-iteration.yaml +106 -0
- package/framework/.claude/workflows/interview-to-knowledge.yaml +189 -0
- package/framework/.claude/workflows/oss-first-design.yaml +100 -0
- package/framework/.claude/workflows/pm-research.yaml +115 -0
- package/framework/.claude-plugin/hooks.json +6 -0
- package/framework/.claude-plugin/marketplace.json +32 -0
- package/framework/.claude-plugin/plugin.json +57 -0
- package/framework/.version-bump.json +43 -0
- package/framework/CLAUDE.md +140 -0
- package/framework/CONTRIBUTING.md +219 -0
- package/framework/LICENSE +21 -0
- package/framework/README.en.md +139 -0
- package/framework/README.md +139 -0
- package/framework/RELEASE.md +334 -0
- package/framework/SKILL.md +24 -0
- package/framework/USAGE.md +356 -0
- package/framework/manifest.json +1214 -0
- package/framework/requirements.txt +4 -0
- package/framework/scripts/__init__.py +0 -0
- package/framework/scripts/build_codebase_knowledge.py +76 -0
- package/framework/scripts/bump_version.py +181 -0
- package/framework/scripts/check-dependency-drift.py +69 -0
- package/framework/scripts/check-harness-drift.sh +57 -0
- package/framework/scripts/check-main-merge-hygiene.py +128 -0
- package/framework/scripts/check-skill-dependencies.sh +124 -0
- package/framework/scripts/init-lincoln-branch.sh +300 -0
- package/framework/scripts/init-project.sh +184 -0
- package/framework/scripts/lc-benchmark-cli.py +66 -0
- package/framework/scripts/lincoln-audit.py +288 -0
- package/framework/scripts/lincoln-setup.py +651 -0
- package/framework/scripts/lincoln-status.py +448 -0
- package/framework/scripts/lincoln_benchmark.py +224 -0
- package/framework/scripts/lincoln_benchmark_eval.py +104 -0
- package/framework/scripts/lincoln_benchmark_metrics.py +818 -0
- package/framework/scripts/lincoln_benchmark_report.py +141 -0
- package/framework/scripts/lincoln_command_map.py +289 -0
- package/framework/scripts/lincoln_dependency_manager.py +335 -0
- package/framework/scripts/lincoln_documents.py +175 -0
- package/framework/scripts/lincoln_harness_adapter.py +319 -0
- package/framework/scripts/lincoln_index.py +255 -0
- package/framework/scripts/lincoln_paths.py +198 -0
- package/framework/scripts/lincoln_prd.py +227 -0
- package/framework/scripts/lincoln_role.py +46 -0
- package/framework/scripts/lincoln_scenario.py +59 -0
- package/framework/scripts/lincoln_session_start_metrics.py +71 -0
- package/framework/scripts/lincoln_skill_prompt.py +48 -0
- package/framework/scripts/lincoln_trace.py +335 -0
- package/framework/scripts/lincoln_workflow.py +199 -0
- package/framework/scripts/list-active-lincoln-branches.sh +87 -0
- package/framework/scripts/package-lincoln-plugin.py +340 -0
- package/framework/scripts/run-infrastructure-tests.py +84 -0
- package/framework/scripts/stage_loader.py +1071 -0
- package/framework/scripts/static-check.sh +356 -0
- package/framework/scripts/sync-external-agents.sh +210 -0
- package/framework/scripts/sync-framework-package.mjs +218 -0
- package/framework/scripts/task_tool_guard.py +213 -0
- package/framework/scripts/track-artifacts.py +140 -0
- package/framework/scripts/validate_stage.py +350 -0
- package/{README.md → framework/tools/lincoln/README.md} +4 -4
- package/framework/tools/lincoln/package-lock.json +3349 -0
- package/framework/tools/lincoln/package.json +48 -0
- package/framework/tools/lincoln/src/cli.tsx +60 -0
- package/framework/tools/lincoln/src/components/AudioMeter.tsx +34 -0
- package/framework/tools/lincoln/src/components/CancelledScreen.tsx +11 -0
- package/framework/tools/lincoln/src/components/DevicesMenu.tsx +79 -0
- package/framework/tools/lincoln/src/components/HintBar.tsx +25 -0
- package/framework/tools/lincoln/src/components/LogView.tsx +36 -0
- package/framework/tools/lincoln/src/components/ModelMenu.tsx +122 -0
- package/framework/tools/lincoln/src/components/ReadyScreen.tsx +54 -0
- package/framework/tools/lincoln/src/components/RecordingApp.tsx +211 -0
- package/framework/tools/lincoln/src/components/RecordingScreen.tsx +41 -0
- package/framework/tools/lincoln/src/components/SelectMenu.tsx +53 -0
- package/framework/tools/lincoln/src/components/StatusPanel.tsx +52 -0
- package/framework/tools/lincoln/src/components/StopConfirmation.tsx +32 -0
- package/framework/tools/lincoln/src/config/args.ts +35 -0
- package/framework/tools/lincoln/src/config/loadConfig.ts +81 -0
- package/framework/tools/lincoln/src/config/resolveConfig.ts +85 -0
- package/framework/tools/lincoln/src/devices/listDevices.ts +11 -0
- package/framework/tools/lincoln/src/devices/parseDevices.ts +25 -0
- package/framework/tools/lincoln/src/hooks/useKeyHandler.ts +63 -0
- package/framework/tools/lincoln/src/main.tsx +4 -0
- package/framework/tools/lincoln/src/models/models.ts +34 -0
- package/framework/tools/lincoln/src/models/runWarmup.ts +46 -0
- package/framework/tools/lincoln/src/models/warmupProgress.ts +30 -0
- package/framework/tools/lincoln/src/recording/spawnRecorder.ts +127 -0
- package/framework/tools/lincoln/src/recording/useRecorder.ts +146 -0
- package/framework/tools/lincoln/src/utils/amplitudeToMeter.ts +4 -0
- package/framework/tools/lincoln/src/utils/formatDuration.ts +6 -0
- package/framework/tools/lincoln/src/utils/sessionId.ts +25 -0
- package/framework/tools/lincoln/tests/cli.test.tsx +52 -0
- package/framework/tools/lincoln/tests/components/AudioMeter.test.tsx +31 -0
- package/framework/tools/lincoln/tests/components/CancelledScreen.test.tsx +12 -0
- package/framework/tools/lincoln/tests/components/ReadyScreen.test.tsx +68 -0
- package/framework/tools/lincoln/tests/components/RecordingApp.menus.test.tsx +158 -0
- package/framework/tools/lincoln/tests/components/RecordingApp.test.tsx +248 -0
- package/framework/tools/lincoln/tests/components/RecordingScreen.test.tsx +37 -0
- package/framework/tools/lincoln/tests/components/SelectMenu.test.tsx +59 -0
- package/framework/tools/lincoln/tests/components/StopConfirmation.test.tsx +38 -0
- package/framework/tools/lincoln/tests/config/args.test.ts +49 -0
- package/framework/tools/lincoln/tests/config/loadConfig.test.ts +59 -0
- package/framework/tools/lincoln/tests/config/resolveConfig.test.ts +72 -0
- package/framework/tools/lincoln/tests/devices/parseDevices.test.ts +21 -0
- package/framework/tools/lincoln/tests/hooks/useKeyHandler.enabled.test.tsx +44 -0
- package/framework/tools/lincoln/tests/hooks/useKeyHandler.test.tsx +130 -0
- package/framework/tools/lincoln/tests/models/models.test.ts +27 -0
- package/framework/tools/lincoln/tests/models/warmupProgress.test.ts +25 -0
- package/framework/tools/lincoln/tests/recording/spawnRecorder.test.ts +85 -0
- package/framework/tools/lincoln/tests/recording/useRecorder.test.tsx +172 -0
- package/framework/tools/lincoln/tests/utils/amplitudeToMeter.test.ts +22 -0
- package/framework/tools/lincoln/tests/utils/formatDuration.test.ts +11 -0
- package/framework/tools/lincoln/tests/utils/sessionId.test.ts +30 -0
- package/framework/tools/lincoln/tsconfig.json +22 -0
- package/framework/tools/lincoln/tsconfig.tests.json +10 -0
- package/framework/tools/lincoln/tsup.config.ts +17 -0
- package/framework/tools/lincoln/vitest.config.ts +20 -0
- package/framework/tools/lincoln-installer/package-lock.json +3611 -0
- package/framework/tools/lincoln-installer/package.json +53 -0
- package/framework/tools/lincoln-installer/src/cli.tsx +63 -0
- package/framework/tools/lincoln-installer/src/components/HarnessSelectScreen.tsx +43 -0
- package/framework/tools/lincoln-installer/src/components/InstallerApp.tsx +98 -0
- package/framework/tools/lincoln-installer/src/components/OptionsScreen.tsx +56 -0
- package/framework/tools/lincoln-installer/src/components/ProgressScreen.tsx +25 -0
- package/framework/tools/lincoln-installer/src/components/ResultScreen.tsx +40 -0
- package/framework/tools/lincoln-installer/src/components/SelectMenu.tsx +73 -0
- package/framework/tools/lincoln-installer/src/components/SummaryScreen.tsx +49 -0
- package/framework/tools/lincoln-installer/src/components/UpdateApp.tsx +135 -0
- package/framework/tools/lincoln-installer/src/components/WelcomeScreen.tsx +22 -0
- package/framework/tools/lincoln-installer/src/config/args.ts +76 -0
- package/framework/tools/lincoln-installer/src/config/resolveConfig.ts +33 -0
- package/framework/tools/lincoln-installer/src/config/updateArgs.ts +67 -0
- package/framework/tools/lincoln-installer/src/hooks/useSetup.ts +149 -0
- package/framework/tools/lincoln-installer/src/main.tsx +11 -0
- package/framework/tools/lincoln-installer/src/types.ts +19 -0
- package/framework/tools/lincoln-installer/src/update-main.tsx +11 -0
- package/framework/tools/lincoln-installer/src/update.tsx +90 -0
- package/framework/tools/lincoln-installer/src/utils/detectHarness.ts +51 -0
- package/framework/tools/lincoln-installer/src/utils/runSetup.ts +62 -0
- package/framework/tools/lincoln-installer/src/utils/updateRelease.ts +454 -0
- package/framework/tools/lincoln-installer/tests/components/InstallerApp.test.tsx +88 -0
- package/framework/tools/lincoln-installer/tests/components/SelectMenu.test.tsx +26 -0
- package/framework/tools/lincoln-installer/tests/components/UpdateApp.test.tsx +170 -0
- package/framework/tools/lincoln-installer/tests/components/screens.test.tsx +310 -0
- package/framework/tools/lincoln-installer/tests/config/args.test.ts +66 -0
- package/framework/tools/lincoln-installer/tests/config/resolveConfig.test.ts +75 -0
- package/framework/tools/lincoln-installer/tests/config/updateArgs.test.ts +52 -0
- package/framework/tools/lincoln-installer/tests/hooks/useSetup.test.tsx +213 -0
- package/framework/tools/lincoln-installer/tests/update.test.tsx +108 -0
- package/framework/tools/lincoln-installer/tests/utils/detectHarness.test.ts +40 -0
- package/framework/tools/lincoln-installer/tests/utils/runSetup.test.ts +45 -0
- package/framework/tools/lincoln-installer/tests/utils/updateRelease.test.ts +559 -0
- package/framework/tools/lincoln-installer/tsconfig.json +22 -0
- package/framework/tools/lincoln-installer/tsconfig.tests.json +8 -0
- package/framework/tools/lincoln-installer/tsup.config.ts +17 -0
- package/framework/tools/lincoln-installer/vitest.config.ts +20 -0
- package/framework/tools/lincoln-record/Cargo.lock +1896 -0
- package/framework/tools/lincoln-record/Cargo.toml +24 -0
- package/framework/tools/lincoln-record/diarize/diarize.py +117 -0
- package/framework/tools/lincoln-record/diarize/merge.py +55 -0
- package/framework/tools/lincoln-record/src/audio/capture/microphone.rs +194 -0
- package/framework/tools/lincoln-record/src/audio/capture/mod.rs +1 -0
- package/framework/tools/lincoln-record/src/audio/devices.rs +20 -0
- package/framework/tools/lincoln-record/src/audio/mod.rs +5 -0
- package/framework/tools/lincoln-record/src/audio/resampler.rs +44 -0
- package/framework/tools/lincoln-record/src/audio/saver.rs +87 -0
- package/framework/tools/lincoln-record/src/audio/source.rs +104 -0
- package/framework/tools/lincoln-record/src/cli.rs +96 -0
- package/framework/tools/lincoln-record/src/config.rs +135 -0
- package/framework/tools/lincoln-record/src/lib.rs +6 -0
- package/framework/tools/lincoln-record/src/main.rs +242 -0
- package/framework/tools/lincoln-record/src/model/mod.rs +248 -0
- package/framework/tools/lincoln-record/src/output/metadata.rs +30 -0
- package/framework/tools/lincoln-record/src/output/mod.rs +2 -0
- package/framework/tools/lincoln-record/src/output/transcript.rs +42 -0
- package/framework/tools/lincoln-record/src/transcription/diarization.rs +64 -0
- package/framework/tools/lincoln-record/src/transcription/mod.rs +3 -0
- package/framework/tools/lincoln-record/src/transcription/provider.rs +43 -0
- package/framework/tools/lincoln-record/src/transcription/whisper.rs +176 -0
- package/framework/tools/lincoln-record/tests/cli_args.rs +103 -0
- package/framework/tools/lincoln-record/tests/config_test.rs +70 -0
- package/framework/tools/lincoln-record/tests/devices_test.rs +23 -0
- package/framework/tools/lincoln-record/tests/diarization_tests.rs +101 -0
- package/framework/tools/lincoln-record/tests/integration_tests.rs +44 -0
- package/framework/tools/lincoln-record/tests/model_test.rs +68 -0
- package/framework/tools/lincoln-record/tests/transcription_tests.rs +73 -0
- package/package.json +19 -13
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { describe, expect, test, vi, afterEach } from 'vitest'
|
|
3
|
+
import {
|
|
4
|
+
mkdtempSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
existsSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
} from 'node:fs'
|
|
11
|
+
import { tmpdir } from 'node:os'
|
|
12
|
+
import { join, resolve } from 'node:path'
|
|
13
|
+
import { create } from 'tar'
|
|
14
|
+
import {
|
|
15
|
+
getCurrentVersion,
|
|
16
|
+
fetchLatestRelease,
|
|
17
|
+
isUpdateNeeded,
|
|
18
|
+
isPreserved,
|
|
19
|
+
downloadAsset,
|
|
20
|
+
extractArchive,
|
|
21
|
+
mergeRelease,
|
|
22
|
+
updateRelease,
|
|
23
|
+
PRESERVE_PATHS,
|
|
24
|
+
type ReleaseInfo,
|
|
25
|
+
} from '../../src/utils/updateRelease'
|
|
26
|
+
|
|
27
|
+
function makeStreamFromBuffer(buffer: Buffer): ReadableStream<Uint8Array> {
|
|
28
|
+
return new ReadableStream<Uint8Array>({
|
|
29
|
+
start(controller) {
|
|
30
|
+
controller.enqueue(new Uint8Array(buffer))
|
|
31
|
+
controller.close()
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function makeTempDir(): string {
|
|
37
|
+
return mkdtempSync(join(tmpdir(), 'lincoln-update-'))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cleanup(dirs: string[]) {
|
|
41
|
+
for (const dir of dirs) {
|
|
42
|
+
rmSync(dir, { recursive: true, force: true })
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('getCurrentVersion', () => {
|
|
47
|
+
const dirs: string[] = []
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
cleanup(dirs)
|
|
51
|
+
dirs.length = 0
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('reads version from .version-bump.json', () => {
|
|
55
|
+
const root = makeTempDir()
|
|
56
|
+
dirs.push(root)
|
|
57
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.2.0' }))
|
|
58
|
+
expect(getCurrentVersion(root)).toBe('1.2.0')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('returns undefined when .version-bump.json is missing', () => {
|
|
62
|
+
const root = makeTempDir()
|
|
63
|
+
dirs.push(root)
|
|
64
|
+
expect(getCurrentVersion(root)).toBeUndefined()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('returns undefined when .version-bump.json lacks version', () => {
|
|
68
|
+
const root = makeTempDir()
|
|
69
|
+
dirs.push(root)
|
|
70
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ manifests: [] }))
|
|
71
|
+
expect(getCurrentVersion(root)).toBeUndefined()
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe('isUpdateNeeded', () => {
|
|
76
|
+
test('returns true when latest is greater', () => {
|
|
77
|
+
expect(isUpdateNeeded('1.2.0', '1.3.0')).toBe(true)
|
|
78
|
+
expect(isUpdateNeeded('1.2.0', '2.0.0')).toBe(true)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('returns false when versions are equal', () => {
|
|
82
|
+
expect(isUpdateNeeded('1.3.0', '1.3.0')).toBe(false)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('returns false when current is newer', () => {
|
|
86
|
+
expect(isUpdateNeeded('1.3.0', '1.2.0')).toBe(false)
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('fetchLatestRelease', () => {
|
|
91
|
+
afterEach(() => {
|
|
92
|
+
vi.restoreAllMocks()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('returns asset URL for tar.gz asset', async () => {
|
|
96
|
+
const release = {
|
|
97
|
+
tag_name: 'v1.3.0',
|
|
98
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
99
|
+
assets: [
|
|
100
|
+
{ name: 'lincoln-1.3.0.tar.gz', browser_download_url: 'https://example.com/lincoln-1.3.0.tar.gz' },
|
|
101
|
+
{ name: 'lincoln-1.3.0.zip', browser_download_url: 'https://example.com/lincoln-1.3.0.zip' },
|
|
102
|
+
],
|
|
103
|
+
}
|
|
104
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
105
|
+
ok: true,
|
|
106
|
+
json: async () => release,
|
|
107
|
+
} as Response)
|
|
108
|
+
|
|
109
|
+
const result = await fetchLatestRelease('sushanglewis/Lincoln')
|
|
110
|
+
expect(result.version).toBe('1.3.0')
|
|
111
|
+
expect(result.assetUrl).toBe('https://example.com/lincoln-1.3.0.tar.gz')
|
|
112
|
+
expect(result.publishedAt).toBe('2026-07-27T00:00:00Z')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('throws when GitHub API fails', async () => {
|
|
116
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
117
|
+
ok: false,
|
|
118
|
+
status: 403,
|
|
119
|
+
statusText: 'Forbidden',
|
|
120
|
+
} as Response)
|
|
121
|
+
|
|
122
|
+
await expect(fetchLatestRelease('sushanglewis/Lincoln')).rejects.toThrow('GitHub API error')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test('throws when no tar.gz asset exists', async () => {
|
|
126
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
127
|
+
ok: true,
|
|
128
|
+
json: async () => ({
|
|
129
|
+
tag_name: 'v1.3.0',
|
|
130
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
131
|
+
assets: [{ name: 'lincoln-1.3.0.zip', browser_download_url: 'https://example.com/lincoln-1.3.0.zip' }],
|
|
132
|
+
}),
|
|
133
|
+
} as Response)
|
|
134
|
+
|
|
135
|
+
await expect(fetchLatestRelease('sushanglewis/Lincoln')).rejects.toThrow('No tar.gz asset')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('downloadAsset', () => {
|
|
140
|
+
const dirs: string[] = []
|
|
141
|
+
|
|
142
|
+
afterEach(() => {
|
|
143
|
+
vi.restoreAllMocks()
|
|
144
|
+
cleanup(dirs)
|
|
145
|
+
dirs.length = 0
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
test('writes downloaded stream to destination', async () => {
|
|
149
|
+
const destDir = makeTempDir()
|
|
150
|
+
dirs.push(destDir)
|
|
151
|
+
const destPath = join(destDir, 'lincoln.tgz')
|
|
152
|
+
|
|
153
|
+
const content = Buffer.from('fake archive bytes')
|
|
154
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
155
|
+
ok: true,
|
|
156
|
+
body: makeStreamFromBuffer(content),
|
|
157
|
+
} as Response)
|
|
158
|
+
|
|
159
|
+
await downloadAsset('https://github.com/lincoln.tgz', destPath)
|
|
160
|
+
|
|
161
|
+
expect(existsSync(destPath)).toBe(true)
|
|
162
|
+
expect(readFileSync(destPath)).toEqual(content)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('throws when download fails', async () => {
|
|
166
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
167
|
+
ok: false,
|
|
168
|
+
status: 404,
|
|
169
|
+
statusText: 'Not Found',
|
|
170
|
+
} as Response)
|
|
171
|
+
|
|
172
|
+
const destDir = makeTempDir()
|
|
173
|
+
dirs.push(destDir)
|
|
174
|
+
await expect(downloadAsset('https://github.com/lincoln.tgz', join(destDir, 'lincoln.tgz'))).rejects.toThrow(
|
|
175
|
+
'Download failed'
|
|
176
|
+
)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
test('rejects unexpected download host', async () => {
|
|
180
|
+
const destDir = makeTempDir()
|
|
181
|
+
dirs.push(destDir)
|
|
182
|
+
await expect(downloadAsset('https://example.com/lincoln.tgz', join(destDir, 'lincoln.tgz'))).rejects.toThrow(
|
|
183
|
+
'Unexpected download host'
|
|
184
|
+
)
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
describe('extractArchive', () => {
|
|
189
|
+
const dirs: string[] = []
|
|
190
|
+
|
|
191
|
+
afterEach(() => {
|
|
192
|
+
cleanup(dirs)
|
|
193
|
+
dirs.length = 0
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
test('extracts tar.gz archive', async () => {
|
|
197
|
+
const sourceDir = makeTempDir()
|
|
198
|
+
const archiveDir = makeTempDir()
|
|
199
|
+
const extractDir = makeTempDir()
|
|
200
|
+
dirs.push(sourceDir, archiveDir, extractDir)
|
|
201
|
+
|
|
202
|
+
mkdirSync(join(sourceDir, 'scripts'))
|
|
203
|
+
writeFileSync(join(sourceDir, 'scripts', 'lincoln-setup.py'), 'setup')
|
|
204
|
+
writeFileSync(join(sourceDir, 'README.md'), 'hello')
|
|
205
|
+
|
|
206
|
+
const archivePath = join(archiveDir, 'lincoln.tgz')
|
|
207
|
+
await create(
|
|
208
|
+
{
|
|
209
|
+
gzip: true,
|
|
210
|
+
file: archivePath,
|
|
211
|
+
cwd: sourceDir,
|
|
212
|
+
},
|
|
213
|
+
['.']
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
await extractArchive(archivePath, extractDir)
|
|
217
|
+
|
|
218
|
+
expect(existsSync(join(extractDir, 'scripts', 'lincoln-setup.py'))).toBe(true)
|
|
219
|
+
expect(readFileSync(join(extractDir, 'README.md'), 'utf-8')).toBe('hello')
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
describe('mergeRelease', () => {
|
|
224
|
+
const dirs: string[] = []
|
|
225
|
+
|
|
226
|
+
afterEach(() => {
|
|
227
|
+
cleanup(dirs)
|
|
228
|
+
dirs.length = 0
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test('copies allowlisted files and preserves user data', async () => {
|
|
232
|
+
const staging = makeTempDir()
|
|
233
|
+
const project = makeTempDir()
|
|
234
|
+
dirs.push(staging, project)
|
|
235
|
+
|
|
236
|
+
mkdirSync(join(staging, '.claude'))
|
|
237
|
+
writeFileSync(join(staging, '.claude', 'skills.yaml'), 'new skills')
|
|
238
|
+
writeFileSync(join(staging, 'README.md'), 'new readme')
|
|
239
|
+
|
|
240
|
+
mkdirSync(join(project, '.claude'))
|
|
241
|
+
writeFileSync(join(project, '.claude', 'skills.yaml'), 'old skills')
|
|
242
|
+
mkdirSync(join(project, '.context'))
|
|
243
|
+
writeFileSync(join(project, '.context', 'lc-setup-state.yaml'), 'user state')
|
|
244
|
+
writeFileSync(join(project, 'README.md'), 'old readme')
|
|
245
|
+
|
|
246
|
+
const result = await mergeRelease(staging, project)
|
|
247
|
+
|
|
248
|
+
expect(readFileSync(join(project, '.claude', 'skills.yaml'), 'utf-8')).toBe('new skills')
|
|
249
|
+
expect(readFileSync(join(project, 'README.md'), 'utf-8')).toBe('new readme')
|
|
250
|
+
expect(readFileSync(join(project, '.context', 'lc-setup-state.yaml'), 'utf-8')).toBe('user state')
|
|
251
|
+
expect(result.updated).toContain('README.md')
|
|
252
|
+
expect(result.updated).toContain('.claude/skills.yaml')
|
|
253
|
+
expect(result.preserved).toContain('.context')
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test('creates backup before overwriting', async () => {
|
|
257
|
+
const staging = makeTempDir()
|
|
258
|
+
const project = makeTempDir()
|
|
259
|
+
dirs.push(staging, project)
|
|
260
|
+
|
|
261
|
+
writeFileSync(join(staging, 'README.md'), 'new')
|
|
262
|
+
writeFileSync(join(project, 'README.md'), 'old')
|
|
263
|
+
|
|
264
|
+
await mergeRelease(staging, project)
|
|
265
|
+
|
|
266
|
+
const backupDir = resolve(project, '.context', 'lincoln-update-backup')
|
|
267
|
+
expect(existsSync(backupDir)).toBe(true)
|
|
268
|
+
expect(existsSync(join(backupDir, 'README.md'))).toBe(true)
|
|
269
|
+
expect(readFileSync(join(backupDir, 'README.md'), 'utf-8')).toBe('old')
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
test('restores backups when merge fails', async () => {
|
|
273
|
+
const staging = makeTempDir()
|
|
274
|
+
const project = makeTempDir()
|
|
275
|
+
dirs.push(staging, project)
|
|
276
|
+
|
|
277
|
+
writeFileSync(join(staging, 'README.md'), 'new')
|
|
278
|
+
mkdirSync(join(project, 'README.md'))
|
|
279
|
+
writeFileSync(join(project, 'README.md', 'nested'), 'existing')
|
|
280
|
+
|
|
281
|
+
await expect(mergeRelease(staging, project)).rejects.toThrow()
|
|
282
|
+
expect(readFileSync(join(project, 'README.md', 'nested'), 'utf-8')).toBe('existing')
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
describe('PRESERVE_PATHS', () => {
|
|
287
|
+
test('includes user data directories and config files', () => {
|
|
288
|
+
expect(PRESERVE_PATHS).toContain('.context')
|
|
289
|
+
expect(PRESERVE_PATHS).toContain('.github/openspec-config.yml')
|
|
290
|
+
expect(PRESERVE_PATHS).toContain('recordings')
|
|
291
|
+
expect(PRESERVE_PATHS).toContain('issue-')
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
describe('getCurrentVersion edge cases', () => {
|
|
296
|
+
const dirs: string[] = []
|
|
297
|
+
|
|
298
|
+
afterEach(() => {
|
|
299
|
+
cleanup(dirs)
|
|
300
|
+
dirs.length = 0
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
test('returns undefined when .version-bump.json is malformed', () => {
|
|
304
|
+
const root = makeTempDir()
|
|
305
|
+
dirs.push(root)
|
|
306
|
+
writeFileSync(join(root, '.version-bump.json'), 'not json')
|
|
307
|
+
expect(getCurrentVersion(root)).toBeUndefined()
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
describe('isUpdateNeeded edge cases', () => {
|
|
312
|
+
test('handles versions with different lengths', () => {
|
|
313
|
+
expect(isUpdateNeeded('1.2', '1.2.0')).toBe(false)
|
|
314
|
+
expect(isUpdateNeeded('1.2', '1.3.0')).toBe(true)
|
|
315
|
+
expect(isUpdateNeeded('1.2.0', '1.2')).toBe(false)
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
test('treats non-numeric parts as zero', () => {
|
|
319
|
+
expect(isUpdateNeeded('1.x.0', '1.0.0')).toBe(false)
|
|
320
|
+
expect(isUpdateNeeded('1.0.0', '1.x.0')).toBe(false)
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
describe('mergeRelease edge cases', () => {
|
|
325
|
+
const dirs: string[] = []
|
|
326
|
+
|
|
327
|
+
afterEach(() => {
|
|
328
|
+
cleanup(dirs)
|
|
329
|
+
dirs.length = 0
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
test('resolves single top-level directory in staging', async () => {
|
|
333
|
+
const staging = makeTempDir()
|
|
334
|
+
const project = makeTempDir()
|
|
335
|
+
dirs.push(staging, project)
|
|
336
|
+
|
|
337
|
+
const inner = join(staging, 'lincoln-1.3.0')
|
|
338
|
+
mkdirSync(inner)
|
|
339
|
+
mkdirSync(join(inner, '.claude'))
|
|
340
|
+
writeFileSync(join(inner, '.claude', 'skills.yaml'), 'new skills')
|
|
341
|
+
|
|
342
|
+
const result = await mergeRelease(staging, project)
|
|
343
|
+
|
|
344
|
+
expect(result.updated).toContain('.claude/skills.yaml')
|
|
345
|
+
expect(readFileSync(join(project, '.claude', 'skills.yaml'), 'utf-8')).toBe('new skills')
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
test('skips missing allowlist directories and files', async () => {
|
|
349
|
+
const staging = makeTempDir()
|
|
350
|
+
const project = makeTempDir()
|
|
351
|
+
dirs.push(staging, project)
|
|
352
|
+
|
|
353
|
+
writeFileSync(join(staging, 'README.md'), 'new readme')
|
|
354
|
+
|
|
355
|
+
const result = await mergeRelease(staging, project)
|
|
356
|
+
|
|
357
|
+
expect(result.updated).toContain('README.md')
|
|
358
|
+
expect(result.updated).not.toContain('.version-bump.json')
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
test('does not list preserved paths that do not exist in project', async () => {
|
|
362
|
+
const staging = makeTempDir()
|
|
363
|
+
const project = makeTempDir()
|
|
364
|
+
dirs.push(staging, project)
|
|
365
|
+
|
|
366
|
+
mkdirSync(join(staging, '.context'))
|
|
367
|
+
writeFileSync(join(staging, '.context', 'lc-setup-state.yaml'), 'new state')
|
|
368
|
+
|
|
369
|
+
const result = await mergeRelease(staging, project)
|
|
370
|
+
|
|
371
|
+
expect(result.preserved).not.toContain('.context')
|
|
372
|
+
expect(existsSync(join(project, '.context', 'lc-setup-state.yaml'))).toBe(false)
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
test('detects issue- prefixed preserved paths', () => {
|
|
376
|
+
expect(isPreserved('issue-123/notes.md')).toBe(true)
|
|
377
|
+
expect(isPreserved('issue-123')).toBe(true)
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
test('detects exact preserved paths', () => {
|
|
381
|
+
expect(isPreserved('.context/lc-setup-state.yaml')).toBe(true)
|
|
382
|
+
expect(isPreserved('.context')).toBe(true)
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
test('returns false for non-preserved paths', () => {
|
|
386
|
+
expect(isPreserved('README.md')).toBe(false)
|
|
387
|
+
expect(isPreserved('.claude/skills.yaml')).toBe(false)
|
|
388
|
+
})
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
describe('updateRelease orchestrator', () => {
|
|
392
|
+
const dirs: string[] = []
|
|
393
|
+
|
|
394
|
+
afterEach(() => {
|
|
395
|
+
vi.restoreAllMocks()
|
|
396
|
+
cleanup(dirs)
|
|
397
|
+
dirs.length = 0
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
test('returns error when current version cannot be detected', async () => {
|
|
401
|
+
const root = makeTempDir()
|
|
402
|
+
dirs.push(root)
|
|
403
|
+
|
|
404
|
+
const result = await updateRelease({ root })
|
|
405
|
+
|
|
406
|
+
expect(result.success).toBe(false)
|
|
407
|
+
expect(result.error).toContain('Could not detect current Lincoln version')
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
test('returns up-to-date result when latest is not newer', async () => {
|
|
411
|
+
const root = makeTempDir()
|
|
412
|
+
dirs.push(root)
|
|
413
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.3.0' }))
|
|
414
|
+
|
|
415
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
416
|
+
ok: true,
|
|
417
|
+
json: async () => ({
|
|
418
|
+
tag_name: 'v1.3.0',
|
|
419
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
420
|
+
assets: [{ name: 'lincoln-1.3.0.tar.gz', browser_download_url: 'https://example.com/lincoln-1.3.0.tar.gz' }],
|
|
421
|
+
}),
|
|
422
|
+
} as Response)
|
|
423
|
+
|
|
424
|
+
const result = await updateRelease({ root })
|
|
425
|
+
|
|
426
|
+
expect(result.success).toBe(true)
|
|
427
|
+
expect(result.fromVersion).toBe('1.3.0')
|
|
428
|
+
expect(result.toVersion).toBe('1.3.0')
|
|
429
|
+
expect(result.updated).toEqual([])
|
|
430
|
+
expect(result.preserved).toEqual([])
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
test('returns dry-run result without downloading', async () => {
|
|
434
|
+
const root = makeTempDir()
|
|
435
|
+
dirs.push(root)
|
|
436
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.2.0' }))
|
|
437
|
+
|
|
438
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
439
|
+
ok: true,
|
|
440
|
+
json: async () => ({
|
|
441
|
+
tag_name: 'v1.3.0',
|
|
442
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
443
|
+
assets: [{ name: 'lincoln-1.3.0.tar.gz', browser_download_url: 'https://example.com/lincoln-1.3.0.tar.gz' }],
|
|
444
|
+
}),
|
|
445
|
+
} as Response)
|
|
446
|
+
|
|
447
|
+
const result = await updateRelease({ root, dryRun: true })
|
|
448
|
+
|
|
449
|
+
expect(result.success).toBe(true)
|
|
450
|
+
expect(result.fromVersion).toBe('1.2.0')
|
|
451
|
+
expect(result.toVersion).toBe('1.3.0')
|
|
452
|
+
expect(global.fetch).toHaveBeenCalledTimes(1)
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
test('downloads and merges release when update is available', async () => {
|
|
456
|
+
const root = makeTempDir()
|
|
457
|
+
const archiveDir = makeTempDir()
|
|
458
|
+
dirs.push(root, archiveDir)
|
|
459
|
+
|
|
460
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.2.0' }))
|
|
461
|
+
|
|
462
|
+
mkdirSync(join(archiveDir, 'source', '.claude'), { recursive: true })
|
|
463
|
+
writeFileSync(join(archiveDir, 'source', '.claude', 'skills.yaml'), 'new skills')
|
|
464
|
+
writeFileSync(join(archiveDir, 'source', 'README.md'), 'new readme')
|
|
465
|
+
|
|
466
|
+
const archivePath = join(archiveDir, 'lincoln-1.3.0.tar.gz')
|
|
467
|
+
await create({ gzip: true, file: archivePath, cwd: join(archiveDir, 'source') }, ['.'])
|
|
468
|
+
const archiveBuffer = Buffer.from(readFileSync(archivePath))
|
|
469
|
+
|
|
470
|
+
global.fetch = vi.fn().mockImplementation(async (url: string | URL | Request) => {
|
|
471
|
+
const urlString = String(url)
|
|
472
|
+
if (urlString.includes('api.github.com')) {
|
|
473
|
+
return {
|
|
474
|
+
ok: true,
|
|
475
|
+
json: async () => ({
|
|
476
|
+
tag_name: 'v1.3.0',
|
|
477
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
478
|
+
assets: [{ name: 'lincoln-1.3.0.tar.gz', browser_download_url: 'https://github.com/lincoln-1.3.0.tar.gz' }],
|
|
479
|
+
}),
|
|
480
|
+
} as Response
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
ok: true,
|
|
484
|
+
body: makeStreamFromBuffer(archiveBuffer),
|
|
485
|
+
} as Response
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
const result = await updateRelease({ root })
|
|
489
|
+
|
|
490
|
+
expect(result.success).toBe(true)
|
|
491
|
+
expect(result.fromVersion).toBe('1.2.0')
|
|
492
|
+
expect(result.toVersion).toBe('1.3.0')
|
|
493
|
+
expect(result.updated).toContain('README.md')
|
|
494
|
+
expect(result.updated).toContain('.claude/skills.yaml')
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
test('verifies checksum when sha256 asset is present', async () => {
|
|
498
|
+
const root = makeTempDir()
|
|
499
|
+
const archiveDir = makeTempDir()
|
|
500
|
+
dirs.push(root, archiveDir)
|
|
501
|
+
|
|
502
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.2.0' }))
|
|
503
|
+
|
|
504
|
+
mkdirSync(join(archiveDir, 'source', '.claude'), { recursive: true })
|
|
505
|
+
writeFileSync(join(archiveDir, 'source', '.claude', 'skills.yaml'), 'new skills')
|
|
506
|
+
writeFileSync(join(archiveDir, 'source', 'README.md'), 'new readme')
|
|
507
|
+
|
|
508
|
+
const archivePath = join(archiveDir, 'lincoln-1.3.0.tar.gz')
|
|
509
|
+
await create({ gzip: true, file: archivePath, cwd: join(archiveDir, 'source') }, ['.'])
|
|
510
|
+
const archiveBuffer = Buffer.from(readFileSync(archivePath))
|
|
511
|
+
const checksum = createHash('sha256').update(archiveBuffer).digest('hex')
|
|
512
|
+
|
|
513
|
+
global.fetch = vi.fn().mockImplementation(async (url: string | URL | Request) => {
|
|
514
|
+
const urlString = String(url)
|
|
515
|
+
if (urlString.includes('api.github.com')) {
|
|
516
|
+
return {
|
|
517
|
+
ok: true,
|
|
518
|
+
json: async () => ({
|
|
519
|
+
tag_name: 'v1.3.0',
|
|
520
|
+
published_at: '2026-07-27T00:00:00Z',
|
|
521
|
+
assets: [
|
|
522
|
+
{ name: 'lincoln-1.3.0.tar.gz', browser_download_url: 'https://github.com/lincoln-1.3.0.tar.gz' },
|
|
523
|
+
{ name: 'lincoln-1.3.0.tar.gz.sha256', browser_download_url: 'https://github.com/lincoln-1.3.0.tar.gz.sha256' },
|
|
524
|
+
],
|
|
525
|
+
}),
|
|
526
|
+
} as Response
|
|
527
|
+
}
|
|
528
|
+
if (urlString.endsWith('.sha256')) {
|
|
529
|
+
return {
|
|
530
|
+
ok: true,
|
|
531
|
+
text: async () => `${checksum} lincoln-1.3.0.tar.gz`,
|
|
532
|
+
} as Response
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
ok: true,
|
|
536
|
+
body: makeStreamFromBuffer(archiveBuffer),
|
|
537
|
+
} as Response
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
const result = await updateRelease({ root })
|
|
541
|
+
|
|
542
|
+
expect(result.success).toBe(true)
|
|
543
|
+
expect(result.toVersion).toBe('1.3.0')
|
|
544
|
+
expect(result.updated).toContain('.claude/skills.yaml')
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
test('returns error when fetchLatestRelease fails', async () => {
|
|
548
|
+
const root = makeTempDir()
|
|
549
|
+
dirs.push(root)
|
|
550
|
+
writeFileSync(join(root, '.version-bump.json'), JSON.stringify({ version: '1.2.0' }))
|
|
551
|
+
|
|
552
|
+
global.fetch = vi.fn().mockRejectedValue(new Error('network error'))
|
|
553
|
+
|
|
554
|
+
const result = await updateRelease({ root })
|
|
555
|
+
|
|
556
|
+
expect(result.success).toBe(false)
|
|
557
|
+
expect(result.error).toContain('network error')
|
|
558
|
+
})
|
|
559
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"outDir": "./dist",
|
|
17
|
+
"rootDir": "./src",
|
|
18
|
+
"types": ["node", "vitest/globals"]
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*"],
|
|
21
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/main.tsx', 'src/update-main.tsx'],
|
|
5
|
+
outDir: 'dist',
|
|
6
|
+
format: ['esm'],
|
|
7
|
+
target: 'node20',
|
|
8
|
+
platform: 'node',
|
|
9
|
+
bundle: true,
|
|
10
|
+
splitting: false,
|
|
11
|
+
sourcemap: true,
|
|
12
|
+
clean: true,
|
|
13
|
+
dts: true,
|
|
14
|
+
esbuildOptions(options) {
|
|
15
|
+
options.jsx = 'automatic'
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
resolve: {
|
|
5
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
6
|
+
},
|
|
7
|
+
test: {
|
|
8
|
+
globals: true,
|
|
9
|
+
environment: 'node',
|
|
10
|
+
coverage: {
|
|
11
|
+
provider: 'v8',
|
|
12
|
+
thresholds: {
|
|
13
|
+
lines: 80,
|
|
14
|
+
functions: 80,
|
|
15
|
+
branches: 80,
|
|
16
|
+
statements: 80,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
})
|