Skip to content

feat(targets): add pkg-chocolatey target (Chocolatey Community Repository)#475

Open
Alexander-Sorrell-IT wants to merge 2 commits into
profullstack:masterfrom
Alexander-Sorrell-IT:feat/target-pkg-chocolatey
Open

feat(targets): add pkg-chocolatey target (Chocolatey Community Repository)#475
Alexander-Sorrell-IT wants to merge 2 commits into
profullstack:masterfrom
Alexander-Sorrell-IT:feat/target-pkg-chocolatey

Conversation

@Alexander-Sorrell-IT
Copy link
Copy Markdown

Add pkg-chocolatey target — Chocolatey Community Repository

Implements the pkg-chocolatey distribution target (Windows), filling the README "Package managers → Chocolatey" entry. Mirrors the existing pkg-winget adapter convention.

What's included

  • packages/targets/pkg-chocolatey/ — adapter, tests, package.json, tsconfig, README.
  • build() generates a real .nuspec + tools/chocolateyinstall.ps1 (exe/msi/zip installer types), with XML escaping and checksum-verified install scripts.
  • ship() is dry-run-safe (no network/secrets in dryRun) and surfaces the exact choco pack / choco apikey / choco push commands; live path requires CHOCOLATEY_API_KEY + the choco CLI on Windows.
  • Registered pkg-chocolatey in packages/cli/src/adapter-registry.ts; TARGETS.md row added (✅).
  • manualSetup notes the community moderation + VirusTotal review gate.

Tests

  • smokeTest + nuspec/install-script generation (exe + zip), XML escaping, and dry-run command surfacing.
  • pnpm --filter @profullstack/sh1pt-target-pkg-chocolatey typecheck and the package tests pass; pnpm install --frozen-lockfile is green.

No external CLI or secrets needed for build/test (dry-run only).

…tory)

Adds the Chocolatey distribution target for Windows.
- build() generates a real .nuspec + tools/chocolateyinstall.ps1 (exe/msi/zip),
  with XML escaping and checksum-verified install scripts.
- ship() is dry-run-safe and surfaces the exact choco pack/apikey/push commands;
  live path requires CHOCOLATEY_API_KEY + the choco CLI on Windows.
- Register pkg-chocolatey in cli adapter-registry; TARGETS.md row added.
- manualSetup notes the community moderation/VirusTotal review gate.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 29, 2026

Greptile Summary

This PR adds a pkg-chocolatey target adapter for publishing packages to the Chocolatey Community Repository, following the existing pkg-winget adapter pattern. All three issues from the prior review round (false-success live ship(), unused version parameter in renderInstallScript, and missing PowerShell single-quote escaping) have been addressed with the psEscape helper, an explicit throw, and corresponding tests.

  • packages/targets/pkg-chocolatey/src/index.ts — generates .nuspec (with xmlEscape) and chocolateyinstall.ps1 (with psEscape), supports exe/msi/zip installer types, and throws clearly for the unimplemented live-publish path.
  • Five targeted tests cover exe generation, zip generation, XML escaping, PS quote escaping, and the live-throw guard, alongside the standard smokeTest.
  • adapter-registry.ts and TARGETS.md are updated to register the new target.

Confidence Score: 5/5

Safe to merge — the adapter is a well-scoped addition with no side effects outside its own package directory; the live publish path is intentionally unimplemented and guarded by an explicit throw.

The three issues flagged in the prior review round have all been resolved: the false-success live-ship path now throws, the unused parameter has been removed, and PowerShell single-quote escaping is implemented and tested. XML escaping for the nuspec is correct. No pre-existing code paths are modified beyond the single-line adapter registry update.

No files require special attention. The status() stub always returning 'in-review' is a known limitation consistent with the unimplemented live-publish path.

Important Files Changed

Filename Overview
packages/targets/pkg-chocolatey/src/index.ts Core adapter: nuspec + PS script generation with correct XML and PS escaping; ship() now throws for live path; status() is a known stub returning 'in-review'.
packages/targets/pkg-chocolatey/src/index.test.ts Comprehensive tests covering exe/zip build, XML escape, PS quote escape, dry-run surfacing, and live-throw guard; all previous review issues are now test-covered.
packages/cli/src/adapter-registry.ts Added 'pkg-chocolatey' in alphabetical order to the targets adapter list; no other changes.
packages/targets/pkg-chocolatey/package.json Standard package manifest matching workspace conventions; 'main' points to src/index.ts and 'files' covers dist.
TARGETS.md Row added for pkg-chocolatey with ✅ status; correctly positioned between pkg-scoop and pkg-apt.

Sequence Diagram

sequenceDiagram
    participant CLI
    participant Adapter as pkg-chocolatey adapter
    participant FS as Filesystem
    participant Choco as choco CLI (Windows)

    CLI->>Adapter: build(ctx, config)
    Adapter->>FS: "mkdir outDir/chocolatey/{packageId}/tools"
    Adapter->>FS: "writeFile {packageId}.nuspec (xmlEscape)"
    Adapter->>FS: writeFile tools/chocolateyinstall.ps1 (psEscape)
    Adapter-->>CLI: "{ artifact, meta: { nuspec, installScript, commands[] } }"

    CLI->>Adapter: "ship(ctx, config) [dryRun=true]"
    Adapter-->>CLI: "{ id: 'dry-run', meta: { commands[] } }"

    CLI->>Adapter: "ship(ctx, config) [dryRun=false]"
    Adapter-->>CLI: throws Error('not implemented yet')

    Note over Choco: Future live path
    Note over Choco: choco pack + choco push
    Note over Choco: requires CHOCOLATEY_API_KEY
Loading

Reviews (2): Last reviewed commit: "fix(pkg-chocolatey): address Greptile re..." | Re-trigger Greptile

Comment thread packages/targets/pkg-chocolatey/src/index.ts Outdated
Comment thread packages/targets/pkg-chocolatey/src/index.ts Outdated
Comment thread packages/targets/pkg-chocolatey/src/index.ts
- Live ship() now throws 'not implemented' instead of returning a false
  success after the secret check (P1).
- Escape single quotes in interpolated PowerShell fields via psEscape() so a
  quote in installerUrl/silentArgs/packageId can't break the .ps1 (P2).
- Drop the unused 'version' param from renderInstallScript (P2).
- Add tests for quote-escaping and the live not-implemented throw.
@Alexander-Sorrell-IT
Copy link
Copy Markdown
Author

Thanks — all three addressed in the latest commit:

  • P1 (live ship false success): live-mode ship() now throws not implemented instead of returning a synthetic {id,url} after the secret check. dry-run still surfaces the choco pack/push commands.
  • P2 (PowerShell quoting): added psEscape() (doubles ''') applied to packageId/installerUrl/checksum/silentArgs; added a test with a quote in silentArgs + installerUrl.
  • P2 (unused param): dropped the unused version param from renderInstallScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant