|
| 1 | +import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess"; |
1 | 2 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
2 | 3 | import { assert, it } from "@effect/vitest"; |
3 | 4 | import * as Effect from "effect/Effect"; |
@@ -151,7 +152,7 @@ it.layer(NodeServices.layer)("build-npm-platform-packages", (it) => { |
151 | 152 | assert.equal(launcherManifest.name, "t3"); |
152 | 153 | assert.equal(launcherManifest.version, VERSION); |
153 | 154 | assert.deepStrictEqual(launcherManifest.bin, { t3: "./bin/t3.js" }); |
154 | | - assert.deepStrictEqual(launcherManifest.files, ["bin"]); |
| 155 | + assert.deepStrictEqual(launcherManifest.files, ["bin", "dist"]); |
155 | 156 | assert.deepStrictEqual(launcherManifest.optionalDependencies, { |
156 | 157 | "@t3code/t3-darwin-arm64": VERSION, |
157 | 158 | "@t3code/t3-linux-x64": VERSION, |
@@ -182,14 +183,46 @@ it.layer(NodeServices.layer)("build-npm-platform-packages", (it) => { |
182 | 183 |
|
183 | 184 | // NODE_PATH stands in for node_modules: require.resolve finds the |
184 | 185 | // platform package there exactly as it would after `npm install`. |
| 186 | + const hostPlatform = yield* HostProcessPlatform; |
| 187 | + const hostArch = yield* HostProcessArchitecture; |
185 | 188 | const env = { ...process.env, NODE_PATH: fixture.outputDir } as Record<string, string>; |
186 | 189 | const passthrough = yield* run(process.execPath, ["bin/t3.js", "serve", "--port", "1234"], { |
187 | 190 | cwd: launcherDir, |
188 | 191 | env, |
189 | 192 | }); |
190 | | - assert.equal(passthrough.stdout.trim(), "stub linux-x64 serve --port 1234"); |
| 193 | + assert.equal(passthrough.stdout.trim(), `stub ${hostPlatform}-${hostArch} serve --port 1234`); |
191 | 194 | assert.equal(passthrough.exitCode, 7); |
192 | 195 |
|
| 196 | + // Run the entry point used by already-installed service updaters from |
| 197 | + // the published tarball, including their preflight arguments. |
| 198 | + const installedLauncher = path.join(fixture.root, "installed-launcher"); |
| 199 | + yield* fs.makeDirectory(installedLauncher); |
| 200 | + const unpack = yield* run( |
| 201 | + "tar", |
| 202 | + ["-xf", path.join(fixture.outputDir, "t3.tgz"), "-C", installedLauncher], |
| 203 | + { |
| 204 | + cwd: fixture.root, |
| 205 | + }, |
| 206 | + ); |
| 207 | + assert.equal(unpack.exitCode, 0, unpack.stderr); |
| 208 | + const legacy = yield* run( |
| 209 | + process.execPath, |
| 210 | + [ |
| 211 | + "dist/bin.mjs", |
| 212 | + "__service-preflight", |
| 213 | + "--database-path", |
| 214 | + "a database.sqlite", |
| 215 | + "--launcher-protocol", |
| 216 | + "2", |
| 217 | + ], |
| 218 | + { cwd: path.join(installedLauncher, "package"), env }, |
| 219 | + ); |
| 220 | + assert.equal( |
| 221 | + legacy.stdout.trim(), |
| 222 | + `stub ${hostPlatform}-${hostArch} __service-preflight --database-path a database.sqlite --launcher-protocol 2`, |
| 223 | + ); |
| 224 | + assert.equal(legacy.exitCode, 7); |
| 225 | + |
193 | 226 | const unsupported = yield* run(process.execPath, ["bin/t3.js", "--version"], { |
194 | 227 | cwd: launcherDir, |
195 | 228 | env: { ...env, NODE_PATH: path.join(fixture.root, "nowhere") }, |
|
0 commit comments