Skip to content

Commit e3d7dd5

Browse files
fix(release): give each npm platform package its own README
npm displays the first README in a tarball when the root has none, which for these packages was ffi-rs's from the bundled node_modules. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent d85bfb1 commit e3d7dd5

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎scripts/build-npm-platform-packages.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ it.layer(NodeServices.layer)("build-npm-platform-packages", (it) => {
128128
assert.isUndefined(linuxManifest.bin);
129129
// Archive contents sit at the package root, not under the archive stem.
130130
assert.isTrue(yield* fs.exists(path.join(linuxDir, "client/index.html")));
131+
// A root README, or npm would display a bundled dependency's.
132+
assert.include(
133+
yield* fs.readFileString(path.join(linuxDir, "README.md")),
134+
"# @t3code/t3-linux-x64",
135+
);
131136
assert.isTrue(yield* fs.exists(path.join(linuxDir, "node_modules/node-pty")));
132137
assert.equal(Number((yield* fs.stat(path.join(linuxDir, "t3"))).mode) & 0o111, 0o111);
133138

‎scripts/build-npm-platform-packages.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,28 @@ export function npmPlatformPackageManifest(platformKey: CliArchivePlatformKey, v
103103
};
104104
}
105105

106+
/**
107+
* README for one platform package. Without one at the package root, npm
108+
* shows the first README it finds in the tarball, which is a bundled
109+
* dependency's (ffi-rs).
110+
*/
111+
export function npmPlatformPackageReadme(platformKey: CliArchivePlatformKey): string {
112+
return [
113+
`# ${npmPlatformPackageName(platformKey)}`,
114+
"",
115+
`The T3 Code CLI executable for ${platformKey}. Do not install this package directly:`,
116+
`it is an optional dependency of \`${NPM_LAUNCHER_PACKAGE_NAME}\`, which picks the package for the`,
117+
"current platform and runs the executable inside it.",
118+
"",
119+
"```sh",
120+
`npx ${NPM_LAUNCHER_PACKAGE_NAME}@latest`,
121+
"```",
122+
"",
123+
"Source and documentation: https://github.com/pingdotgg/t3code",
124+
"",
125+
].join("\n");
126+
}
127+
106128
/** package.json for the `t3` launcher. No engines: bin/t3.js is trivial CJS. */
107129
export function npmLauncherPackageManifest(
108130
version: string,
@@ -283,6 +305,10 @@ const stagePlatformPackage = Effect.fn("stagePlatformPackage")(function* (input:
283305
path.join(contentDir, "package.json"),
284306
`${yield* encodePackageJson(npmPlatformPackageManifest(input.key, input.version))}\n`,
285307
);
308+
yield* fs.writeFileString(
309+
path.join(contentDir, "README.md"),
310+
npmPlatformPackageReadme(input.key),
311+
);
286312
// npm tarballs root everything under `package/`.
287313
yield* fs.rename(contentDir, path.join(scratch, "package"));
288314
const name = npmPlatformPackageName(input.key);

0 commit comments

Comments
 (0)