Skip to content

Commit 2b51bd7

Browse files
committed
fix: update paths for CLI binary and package directory in integration tests
1 parent 9a32ddf commit 2b51bd7

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

cli-integration-test/src/artifacts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const REPO_ROOT = fileURLToPath(new URL("../../", import.meta.url));
88
const CLI_DIR = path.join(REPO_ROOT, "cli");
99
const CLI_LINUX_PACKAGE_DIR = path.join(CLI_DIR, "npm", "linux-x64-gnu");
1010
const RUST_BINARY_PATH = path.join(REPO_ROOT, "target", "release", "tnmsc");
11-
const LINUX_PACKAGE_BINARY = "tnmsc";
11+
const LINUX_PACKAGE_BINARY = path.join("bin", "tnmsc");
1212
const MAX_BUFFER = 16 * 1024 * 1024;
1313

1414
export interface CliIntegrationArtifacts {
@@ -88,6 +88,7 @@ function ensureLinuxBinaryInPlatformPackage(): void {
8888
}
8989

9090
ensureDirectory(CLI_LINUX_PACKAGE_DIR);
91+
ensureDirectory(path.dirname(targetBinary));
9192

9293
copyFileSync(RUST_BINARY_PATH, targetBinary);
9394
}
@@ -108,7 +109,7 @@ export function prepareCliIntegrationArtifacts(): CliIntegrationArtifacts {
108109

109110
const tempDir = mkdtempSync(path.join(tmpdir(), "tnmsc-cli-integration-artifacts-"));
110111
const cliTarballPath = packWorkspacePackage(CLI_DIR, path.join(tempDir, "cli"));
111-
const linuxTarballPath = packWorkspacePackage(CLI_LINUX_PACKAGE_DIR, path.join(tempDir, "cli-linux-x64"));
112+
const linuxTarballPath = packWorkspacePackage(CLI_LINUX_PACKAGE_DIR, path.join(tempDir, "cli-linux-x64-gnu"));
112113
const latestPnpmVersion = resolveLatestPackageVersion("pnpm");
113114

114115
cachedArtifacts = {

cli-integration-test/src/container.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,10 @@ function shellScript(command: string, cwd: string): string {
112112

113113
function buildPinnedGlobalCliPlatformLinkScript(): string {
114114
return [
115-
'GLOBAL_ROOT="$(pnpm root -g)"',
116-
'MAIN_PACKAGE_DIR="$GLOBAL_ROOT/@truenine/memory-sync-cli"',
117-
'PLATFORM_PACKAGE_DIR="$GLOBAL_ROOT/@truenine/memory-sync-cli-linux-x64-gnu"',
118-
'test -d "$MAIN_PACKAGE_DIR"',
119-
'test -d "$PLATFORM_PACKAGE_DIR"',
120-
'mkdir -p "$MAIN_PACKAGE_DIR/node_modules/@truenine"',
121-
'rm -rf "$MAIN_PACKAGE_DIR/node_modules/@truenine/memory-sync-cli-linux-x64-gnu"',
122-
'ln -s "$PLATFORM_PACKAGE_DIR" "$MAIN_PACKAGE_DIR/node_modules/@truenine/memory-sync-cli-linux-x64-gnu"',
115+
'MAIN_PACKAGE_JSON="$(find -L /pnpm/global -path \'*/@truenine/memory-sync-cli/package.json\' -print -quit)"',
116+
'PLATFORM_PACKAGE_JSON="$(find -L /pnpm/global -path \'*/@truenine/memory-sync-cli-linux-x64-gnu/package.json\' -print -quit)"',
117+
'test -n "$MAIN_PACKAGE_JSON"',
118+
'test -n "$PLATFORM_PACKAGE_JSON"',
123119
].join("\n");
124120
}
125121

@@ -160,14 +156,13 @@ export class PreparedCliIntegrationContainer {
160156

161157
inspectInstalledCliResolution(): InstalledCliResolution {
162158
const script = [
163-
'const { createRequire } = require("node:module");',
164159
'const fs = require("node:fs");',
165160
'const path = require("node:path");',
166-
"const mainDir = process.argv[1];",
167-
'const requireFromMain = createRequire(path.join(mainDir, "dist", "index.mjs"));',
168-
'const resolvedPackageJson = requireFromMain.resolve("@truenine/memory-sync-cli-linux-x64-gnu/package.json");',
169-
"const platformDir = path.dirname(resolvedPackageJson);",
170-
'const binaryPath = path.join(platformDir, "tnmsc");',
161+
"const mainPackageJson = process.argv[1];",
162+
"const platformPackageJson = process.argv[2];",
163+
"const mainDir = path.dirname(mainPackageJson);",
164+
"const platformDir = path.dirname(platformPackageJson);",
165+
'const binaryPath = path.join(platformDir, "bin", "tnmsc");',
171166
"const binaryExists = fs.existsSync(binaryPath);",
172167
"process.stdout.write(JSON.stringify({",
173168
" mainPackageDir: mainDir,",
@@ -177,15 +172,19 @@ export class PreparedCliIntegrationContainer {
177172
].join(" ");
178173

179174
const result = this.assertExecSuccess(
180-
['GLOBAL_ROOT="$(pnpm root -g)"', 'MAIN_PACKAGE_DIR="$GLOBAL_ROOT/@truenine/memory-sync-cli"', `node -e ${quoteShell(script)} "$MAIN_PACKAGE_DIR"`].join(
181-
" && ",
182-
),
175+
[
176+
'MAIN_PACKAGE_JSON="$(find -L /pnpm/global -path \'*/@truenine/memory-sync-cli/package.json\' -print -quit)"',
177+
'PLATFORM_PACKAGE_JSON="$(find -L /pnpm/global -path \'*/@truenine/memory-sync-cli-linux-x64-gnu/package.json\' -print -quit)"',
178+
'test -n "$MAIN_PACKAGE_JSON"',
179+
'test -n "$PLATFORM_PACKAGE_JSON"',
180+
`node -e ${quoteShell(script)} "$MAIN_PACKAGE_JSON" "$PLATFORM_PACKAGE_JSON"`,
181+
].join(" && "),
183182
);
184183

185184
const parsed = JSON.parse(result.stdout);
186185

187186
if (!parsed.binaryExists) {
188-
throw new Error(`Expected tnmsc binary at "${parsed.platformPackageDir}/tnmsc" but it does not exist.`);
187+
throw new Error(`Expected tnmsc binary at "${parsed.platformPackageDir}/bin/tnmsc" but it does not exist.`);
189188
}
190189

191190
return {

0 commit comments

Comments
 (0)