Skip to content

Commit 7acbaa1

Browse files
refactor: delegate ol update to @doist/cli-core/commands (#68)
## Summary Mirrors [twist-cli #214](Doist/twist-cli#214). cli-core 0.9.0 owns the registry fetch, package-manager detection, install spawn, channel switch, and `--json`/`--ndjson` envelopes. outline provides the package name, version, config path, changelog hint, and spinner runner. PR 3 of a 3-PR stack — **stacked on #67**: 1. ✅ #66 — cli-core wiring (errors, config, spinner, output, markdown) 2. ✅ #67 — global-args + ViewOptions + empty-output test helper 3. **This PR** — delegate `ol update` to cli-core/commands ## Changes - `src/commands/update/index.ts` now forwards to cli-core's `registerUpdateCommand` with `{ packageName, currentVersion, configPath, changelogCommandName: 'ol changelog', withSpinner }`. - Delete `src/commands/update/action.ts` (203 lines) and `src/commands/update/switch.ts` (37 lines) — cli-core owns both. - Delete `src/lib/update-config.ts` (12 lines) — cli-core reads/writes `update_channel` directly via the config path we hand it. - `src/__tests__/update.test.ts` slims to a wrapper test (option forwarding). ~400 lines of behaviour tests removed — covered upstream by cli-core's update suite. - `src/lib/skills/content.ts` documents the new `--json` flag on `ol update --check`; `skills/outline-cli/SKILL.md` regenerated. Net: **37 insertions / 710 deletions across 7 files.** ## Behaviour changes (mirroring twist-cli #214) - Invalid `update_channel` on disk surfaces as `INVALID_UPDATE_CHANNEL` from `ol update` (was silently coerced to stable). - Errors emit canonical cli-core codes (`INVALID_FLAGS`, `UPDATE_CHECK_FAILED`, `UPDATE_INSTALL_FAILED`). - Both subcommands accept `--json` / `--ndjson` envelopes. ## Test plan - [x] `npm run type-check` - [x] `npm run lint:check` — 0 warnings, 0 errors - [x] `npm test` — 103 tests pass - [x] `npm run build && npm run sync:skill && npm run check:skill-sync` — SKILL.md in sync - [ ] Smoke `ol update --channel` — reports `stable` - [ ] Smoke `ol update --check` — reports current vs latest with channel line - [ ] Smoke `ol update --check --json` — single-record JSON envelope - [ ] Manual `ol update switch --pre-release` then `ol update switch --stable` — flips on-disk `update_channel` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d1cf0b1 commit 7acbaa1

8 files changed

Lines changed: 82 additions & 710 deletions

File tree

skills/outline-cli/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ ol auth logout # Clear saved credentials
8282
```bash
8383
ol update # Update CLI to latest version
8484
ol update --check # Check for updates without installing, show channel
85+
ol update --check --json # Check for updates as a JSON envelope
86+
ol update --check --ndjson # Check for updates as NDJSON output
8587
ol update --channel # Show current update channel
8688
ol update switch --stable # Switch to stable release channel
8789
ol update switch --pre-release # Switch to pre-release (next) channel
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Command } from 'commander'
2+
import { describe, expect, it, vi } from 'vitest'
3+
import { registerUpdateCommand } from '../commands/update/index.js'
4+
5+
// Stub out config + spinner — this test only cares about the command surface
6+
// (subcommand names + flags) wired up via the real cli-core, so a bump to
7+
// cli-core can't silently change `ol update`'s public CLI shape.
8+
vi.mock('../lib/config.js', () => ({
9+
getConfigPath: () => '/tmp/outline-cli-test/config.json',
10+
}))
11+
12+
vi.mock('../lib/spinner.js', () => ({
13+
withSpinner: vi.fn((_opts: unknown, fn: () => Promise<unknown>) => fn()),
14+
}))
15+
16+
describe('ol update command surface (integration with real cli-core)', () => {
17+
it('exposes `update` with --check and --channel flags', () => {
18+
const program = new Command()
19+
registerUpdateCommand(program)
20+
21+
const update = program.commands.find((c) => c.name() === 'update')
22+
expect(update).toBeDefined()
23+
24+
const longs = update?.options.map((o) => o.long) ?? []
25+
expect(longs).toContain('--check')
26+
expect(longs).toContain('--channel')
27+
})
28+
29+
it('exposes `update switch` with --stable and --pre-release flags', () => {
30+
const program = new Command()
31+
registerUpdateCommand(program)
32+
33+
const update = program.commands.find((c) => c.name() === 'update')
34+
const switchCmd = update?.commands.find((c) => c.name() === 'switch')
35+
expect(switchCmd).toBeDefined()
36+
37+
const longs = switchCmd?.options.map((o) => o.long) ?? []
38+
expect(longs).toContain('--stable')
39+
expect(longs).toContain('--pre-release')
40+
})
41+
})

0 commit comments

Comments
 (0)