Repository navigation
Description
Problem
The npm tarball for @togo-framework/cli@0.2.33 has CRLF line endings in bin/togo.js and install.js. Earlier versions (0.2.29–0.2.31) were LF. The repository index is LF, so this is a packaging artifact, not a source change.
Reproduction
d=$(mktemp -d) && cd "$d"
for v in 0.2.31 0.2.33; do
npm pack @togo-framework/cli@$v --silent >/dev/null
mkdir $v && tar -xzf togo-framework-cli-$v.tgz -C $v
for f in bin/togo.js install.js package.json; do
printf '%s %-14s CR bytes: %s\n' $v $f "$(tr -cd '\r' < $v/package/$f | wc -c)"
done
done
# 0.2.31: 0 / 0 / 0
# 0.2.33: bin/togo.js 13, install.js 65, package.json 0(Count with tr -cd '\r' | wc -c. In Git Bash, grep -c $'\r' miscounts.)
Cause
0.2.33 was packed with npm pack/npm publish from a Windows checkout where Git's system config sets core.autocrlf=true (Git for Windows default, in C:/Program Files/Git/etc/gitconfig). The repo has no .gitattributes, so text files under npm/ were checked out as CRLF (git ls-files --eol npm/ shows i/lf w/crlf) and npm packed them as-is. package.json stayed LF because npm rewrites it. The release workflow builds only goreleaser assets; the npm publish is a manual step.
Why 0.2.33 still works
bin/togo.js: on install, npm (bin-links) rewrites a CRLF shebang to LF in the installed bin, so#!/usr/bin/env node\rnever reaches the kernel. Verified: the installed file's first line ends in\n, andtogo versionruns after a cleannpm i -gon Debian (node:24-bookworm-slim), Alpine (node:24-alpine) and Windows 11.install.jsruns asnode install.js(the postinstall script), and Node accepts CRLF source.
It still needs fixing: the result depends on npm's shebang fix-up, npx/other package managers, or direct execution of the file from the tarball, may not apply it. Builds also differ from LF releases depending on who packs them.
Recommendation
- Enforce LF in the repo: add
.gitattributeswith* text=auto eol=lf(or at leastnpm/** text eol=lf), so every checkout ofnpm/is LF whatevercore.autocrlfsays. - Pack and publish from Linux: preferably publish npm in the tag-triggered release workflow after goreleaser (
ubuntu-latest, provenance, version taken from the tag), instead of from a developer machine. - Guard: a CI step that runs
npm packand fails if any packed file contains\r.
These are complementary: (1) fixes local checkouts, (2) removes the developer-machine dependency, and (3) catches regressions either way.
Acceptance criteria
- A fresh checkout on Windows with
core.autocrlf=trueproduces LF files undernpm/(git ls-files --eol npm/showsw/lf). -
npm packfrom that checkout produces a tarball with 0 CR bytes in every file. - CI fails if the packed tarball contains CR bytes, and passes on LF (shown with a deliberately CRLF file).
- The next npm release (0.2.34+) is verified with the reproduction above: 0 CR bytes.
- If npm publishing moves to CI: the release docs/workflow describe the publish step, its token/provenance, and who approves it.
- 0.2.33 is not republished (npm doesn't allow it). This issue only changes the next release.
Activity
fadymondy commentedon Oct 14, 2026
Fixed in #19, released in v0.2.37.
.gitattributes(* text=auto eol=lf) makesnpm/LF on every checkout regardless ofcore.autocrlf(item 1).npm/pack.test.jspacks the package, extracts the tarball and fails on any CR byte; it runs in the npm CI job on ubuntu and windows (item 3). Confirmed it fails with a CRLFbin/togo.jsand passes with LF.Not done: moving
npm publishinto the tag workflow (item 2). It needs an npm token and a provenance/approval decision, so publishing remains a maintainer step. Nothing was published to npm from here, so@togo-framework/cli@0.2.37still needs publishing (from a Linux or LF checkout). Once it is out, run the reproduction above against 0.2.37 to tick the last acceptance item; reopen this issue if any CR bytes show up.