fix(release): preserve updates from npm-based services (#11732)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-09-14 05:02:04 -07:00
1 parent 6f00d3881a
commit 9375c77970
7 files changed
+227 -9

No files matched your search

+45 -7
View File
@@ -1,3 +1,4 @@
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
@@ -151,7 +152,7 @@ it.layer(NodeServices.layer)("build-npm-platform-packages", (it) => {
assert.equal(launcherManifest.name, "t3");
assert.equal(launcherManifest.version, VERSION);
assert.deepStrictEqual(launcherManifest.bin, { t3: "./bin/t3.js" });
assert.deepStrictEqual(launcherManifest.files, ["bin"]);
assert.deepStrictEqual(launcherManifest.files, ["bin", "dist"]);
assert.deepStrictEqual(launcherManifest.optionalDependencies, {
"@t3code/t3-darwin-arm64": VERSION,
"@t3code/t3-linux-x64": VERSION,
@@ -182,13 +183,50 @@ it.layer(NodeServices.layer)("build-npm-platform-packages", (it) => {
// NODE_PATH stands in for node_modules: require.resolve finds the
// platform package there exactly as it would after `npm install`.
const hostPlatform = yield* HostProcessPlatform;
const hostArch = yield* HostProcessArchitecture;
const env = { ...process.env, NODE_PATH: fixture.outputDir } as Record<string, string>;
const passthrough = yield* run(process.execPath, ["bin/t3.js", "serve", "--port", "1234"], {
cwd: launcherDir,
env,
});
assert.equal(passthrough.stdout.trim(), "stub linux-x64 serve --port 1234");
assert.equal(passthrough.exitCode, 7);
if (KEYS.some((key) => key === `${hostPlatform}-${hostArch}`)) {
const passthrough = yield* run(process.execPath, ["bin/t3.js", "serve", "--port", "1234"], {
cwd: launcherDir,
env,
});
assert.equal(
passthrough.stdout.trim(),
`stub ${hostPlatform}-${hostArch} serve --port 1234`,
);
assert.equal(passthrough.exitCode, 7);
// Run the entry point used by already-installed service updaters from
// the published tarball, including their preflight arguments.
const installedLauncher = path.join(fixture.root, "installed-launcher");
yield* fs.makeDirectory(installedLauncher);
const unpack = yield* run(
"tar",
["-xf", path.join(fixture.outputDir, "t3.tgz"), "-C", installedLauncher],
{
cwd: fixture.root,
},
);
assert.equal(unpack.exitCode, 0, unpack.stderr);
const legacy = yield* run(
process.execPath,
[
"dist/bin.mjs",
"__service-preflight",
"--database-path",
"a database.sqlite",
"--launcher-protocol",
"2",
],
{ cwd: path.join(installedLauncher, "package"), env },
);
assert.equal(
legacy.stdout.trim(),
`stub ${hostPlatform}-${hostArch} __service-preflight --database-path a database.sqlite --launcher-protocol 2`,
);
assert.equal(legacy.exitCode, 7);
}
const unsupported = yield* run(process.execPath, ["bin/t3.js", "--version"], {
cwd: launcherDir,
+6 -1
View File
@@ -19,6 +19,7 @@
* bundleDependencies needs an arborist tree these flattened installs are
* not), whereas `npm publish <tarball>` uploads the bytes as given.
*/
import { legacyCliLauncherScript } from "@t3tools/shared/legacyCliLauncher";
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as Effect from "effect/Effect";
@@ -137,7 +138,7 @@ export function npmLauncherPackageManifest(
license: serverPackageJson.license,
repository: serverPackageJson.repository,
bin: { t3: "./bin/t3.js" },
files: ["bin"],
files: ["bin", "dist"],
optionalDependencies: Object.fromEntries(
platformKeys.map((key) => [npmPlatformPackageName(key), version]),
),
@@ -342,6 +343,10 @@ const stageLauncherPackage = Effect.fn("stageLauncherPackage")(function* (input:
const launcherScript = path.join(stageDir, "bin/t3.js");
yield* fs.writeFileString(launcherScript, NPM_LAUNCHER_SCRIPT);
yield* fs.chmod(launcherScript, 0o755);
// Older service updaters and launchers run this exact path with Node.
// Keep it in the package so they can preflight and start the new executable.
yield* fs.makeDirectory(path.join(stageDir, "dist"));
yield* fs.writeFileString(path.join(stageDir, "dist/bin.mjs"), legacyCliLauncherScript("npm"));
const readme = yield* path.fromFileUrl(new URL("../apps/server/README.md", import.meta.url));
if (yield* fs.exists(readme)) {
yield* fs.copyFile(readme, path.join(stageDir, "README.md"));