feat(cli): add squad update-check --json for tooling/CI#1440
feat(cli): add squad update-check --json for tooling/CI#1440omercangumus wants to merge 1 commit into
Conversation
🏗️ Architectural Review
Automated architectural review — informational only. |
🟡 Impact Analysis — PR #1440Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (1 file)
root (2 files)
squad-cli (5 files)
tests (2 files)
|
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ✅ | CI passing | All checks passing |
Files Changed (10 files, +477 −4)
| File | +/− |
|---|---|
.changeset/feat-1170-update-check-json.md |
+12 −0 |
README.md |
+1 −0 |
docs/src/content/docs/features/self-upgrade.md |
+39 −0 |
packages/squad-cli/package.json |
+4 −0 |
packages/squad-cli/src/cli-entry.ts |
+8 −0 |
packages/squad-cli/src/cli/commands/update-check.ts |
+166 −0 |
packages/squad-cli/src/cli/core/command-help.ts |
+12 −0 |
packages/squad-cli/src/cli/self-update.ts |
+5 −4 |
test/cli/command-help.test.ts |
+1 −0 |
test/cli/update-check.test.ts |
+229 −0 |
Total: +477 −4
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
| console.log(` --global (personal squad dir)`); | ||
| console.log(` --no-workflows (skip CI setup)`); | ||
| console.log(` --preset <name> (apply a preset after init)`); | ||
| console.log(` --roles (use base roles)`); |
There was a problem hiding this comment.
Seems like the change is in hidden chars or something. Please fix. There are a bunch of other files with same whitespace changes
Adds a squad update-check command that reads the existing update-check.json cache (already maintained by self-update.ts) and reports current/latest version, release channel, and update availability, instead of requiring every consumer (editor extensions, coordinator instructions, CI scripts) to replicate OS-specific cache path resolution and TTL-freshness checks themselves. - --json emits structured output matching the schema proposed in bradygaster#1170 - --refresh bypasses the cache and re-fetches from the npm registry - Exit codes: 0 (up to date / no cache yet), 1 (update available), 2 (transport failure during --refresh) - Honors SQUAD_NO_UPDATE_CHECK=1 (no network call, silent exit 0) Release channel is derived from the running version's prerelease tag (stable/preview/insider) via the existing ReleaseChannel type in upgrade.ts. cacheAge is formatted as an ISO 8601 duration (e.g. "PT2H15M"). Exported getCachePath/fetchLatestVersion/writeCache from self-update.ts for reuse instead of duplicating cache I/O. Closes bradygaster#1170 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2579618 to
98769ef
Compare
|
yeah, windows autocrlf snuck in there and flipped a bunch of untouched lines in cli-entry.ts to CRLF. reset the file to upstream and reapplied just the real hunks, diff is down to the actual 10 files now (477 insertions, 4 deletions), no more phantom removes/adds. |
What
Adds
squad update-check [--json] [--refresh], a new CLI command that reports the CLI's cached update status.Why
self-update.tsalready maintains an OS-specific cache (update-check.json) for the background startup update check, but anything outside the CLI process that wants this information (editor extensions, coordinator instructions, CI scripts) currently has to replicate the OS-specific cache path logic, parse the JSON, check TTL freshness, and handle the no-cache-yet case. A dedicated command gives them a single, stable interface.Closes #1170
How
packages/squad-cli/src/cli/commands/update-check.ts:detectChannel(version)derives the release channel (stable/preview/insider) from the version's prerelease tag, reusing theReleaseChanneltype andparseVersionfromupgrade.ts.formatCacheAge(ms)formats a millisecond duration as an ISO 8601 duration string (e.g.PT2H15M), matching the schema in the issue.runUpdateCheck(currentVersion, { refresh })— withoutrefresh, only reads the existing cache (no network call, per the acceptance criteria); withrefresh, always re-fetches from npm and updates the cache.runUpdateCheckCommand(args)— CLI entry point; handles--json/--refresh, theSQUAD_NO_UPDATE_CHECK=1opt-out, and returns the process exit code.getCachePath,fetchLatestVersion, andwriteCachefromself-update.ts(previously private) so the new command reuses the same cache I/O instead of duplicating it.cli-entry.tsrouting, the top-levelsquad helplisting, and a dedicatedsquad update-check --helpblock incommand-help.ts../commands/update-checksubpath export topackages/squad-cli/package.json, following the existing convention for CLI command modules (e.g../commands/doctor).README.md's command table and added a new section todocs/src/content/docs/features/self-upgrade.md.Judgment calls where the issue was ambiguous (flagging for review):
--refresh: reportslatest: null,updateAvailable: false, exit code0, with a human-readable hint to run--refresh. Chosen because the acceptance criteria explicitly says "No new network calls without--refresh", ruling out a fallback fetch.--refresh: returns{ ..., error: "Failed to reach the npm registry" }(an additive field beyond the issue's schema) and exit code2.Testing
test/cli/update-check.test.ts(21 tests):detectChannelbranches,formatCacheAgeformatting,runUpdateCheckcache-read/refresh/error paths (mockingself-update.js's network/cache functions — no real HTTP calls or shared-cache-path writes), andrunUpdateCheckCommandexit codes /--jsonoutput /SQUAD_NO_UPDATE_CHECKopt-out.test/cli/command-help.test.ts's hardcoded command list to includeupdate-check(was failing before this fix).npx vitest run test/cli/update-check.test.ts test/cli/command-help.test.ts— 35 passed.npm run build— passes.npm run lint(tsc --noEmit) — passes.npm run lint:eslint— 0 errors (pre-existing warnings only, unrelated to this change).npm run lint:docs(markdownlint + cspell) — passes, since README.md and a docs page changed.npm test(full suite) andnpx vitest run test/cli/— no regressions from this change. Verifiedtest/cli/rc.test.ts,test/cli/start.test.ts,test/cli/watch.test.tstime out identically on a cleanupstream/devcheckout before my changes (pre-existing local Windows-environment flakiness, not something this PR introduces)..changeset/feat-1170-update-check-json.md(minor bump,@bradygaster/squad-cli), since this adds a new CLI command (packages/squad-cli/src/)PR Readiness Checklist
Branch & Commit
devdevgit diff --cached --stat)Build & Test
npm run buildpassesnpm testpasses (see testing notes above for pre-existing unrelated local failures)npm run lintpasses (type check clean)npm run lint:eslintpasses (0 errors)Changeset
@bradygaster/squad-cli)Docs
docs/src/content/docs/features/self-upgrade.md) — new capability documented under the existing self-upgrade feature, not a new pageExports
package.jsonsubpath export added (./commands/update-check), matching the convention for other CLI command modulesBreaking Changes
None.
Waivers
None.