@rudderhq/cli 0.3.3-canary.6 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3975,6 +3975,48 @@ async function touchRuntimeInstallMetadata(cacheDir) {
3975
3975
  } catch {
3976
3976
  }
3977
3977
  }
3978
+ function resolveEmbeddedPostgresPlatformPackage(platform = process.platform, arch = process.arch) {
3979
+ if (platform === "darwin" && arch === "arm64") return "@embedded-postgres/darwin-arm64";
3980
+ if (platform === "darwin" && arch === "x64") return "@embedded-postgres/darwin-x64";
3981
+ if (platform === "linux" && arch === "arm64") return "@embedded-postgres/linux-arm64";
3982
+ if (platform === "linux" && arch === "arm") return "@embedded-postgres/linux-arm";
3983
+ if (platform === "linux" && arch === "ia32") return "@embedded-postgres/linux-ia32";
3984
+ if (platform === "linux" && arch === "ppc64") return "@embedded-postgres/linux-ppc64";
3985
+ if (platform === "linux" && arch === "x64") return "@embedded-postgres/linux-x64";
3986
+ if (platform === "win32" && arch === "x64") return "@embedded-postgres/windows-x64";
3987
+ return null;
3988
+ }
3989
+ async function canResolveRuntimePackage(cacheDir, packageName) {
3990
+ try {
3991
+ await readFile(path6.join(cacheDir, "node_modules", ...packageName.split("/"), "package.json"), "utf8");
3992
+ return true;
3993
+ } catch {
3994
+ return false;
3995
+ }
3996
+ }
3997
+ async function hasRequiredRuntimePlatformDependencies(cacheDir) {
3998
+ if (!await canResolveRuntimePackage(cacheDir, EMBEDDED_POSTGRES_PACKAGE_NAME)) return true;
3999
+ const platformPackage = resolveEmbeddedPostgresPlatformPackage();
4000
+ if (!platformPackage) return true;
4001
+ return await canResolveRuntimePackage(cacheDir, platformPackage);
4002
+ }
4003
+ async function assertRequiredRuntimePlatformDependencies(cacheDir, command, output) {
4004
+ if (!await canResolveRuntimePackage(cacheDir, EMBEDDED_POSTGRES_PACKAGE_NAME)) return;
4005
+ const platformPackage = resolveEmbeddedPostgresPlatformPackage();
4006
+ if (!platformPackage || await canResolveRuntimePackage(cacheDir, platformPackage)) return;
4007
+ throw new RuntimeInstallError(
4008
+ `Rudder runtime installation is missing required platform package ${platformPackage}. Re-run manually: ${command}`,
4009
+ {
4010
+ cacheDir,
4011
+ command,
4012
+ output: [
4013
+ output,
4014
+ `Missing required optional dependency: ${platformPackage}`,
4015
+ "Your npm registry, mirror, proxy, or cache may have skipped the embedded PostgreSQL platform package."
4016
+ ].filter((line) => line.trim().length > 0).join("\n")
4017
+ }
4018
+ );
4019
+ }
3978
4020
  async function isRuntimeCacheHit(options) {
3979
4021
  const packageName = options.packageName ?? RUNTIME_NPM_PACKAGE_NAME;
3980
4022
  const packageVersion = resolveRuntimePackageVersion(options.version);
@@ -3985,7 +4027,8 @@ async function isRuntimeCacheHit(options) {
3985
4027
  try {
3986
4028
  const packageJsonPath = path6.join(options.cacheDir, "node_modules", ...packageName.split("/"), "package.json");
3987
4029
  const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));
3988
- return packageVersion === "latest" || packageJson.version === packageVersion;
4030
+ const packageVersionMatches = packageVersion === "latest" || packageJson.version === packageVersion;
4031
+ return packageVersionMatches && await hasRequiredRuntimePlatformDependencies(options.cacheDir);
3989
4032
  } catch {
3990
4033
  return false;
3991
4034
  }
@@ -4006,6 +4049,7 @@ async function ensureRuntimeInstalled(options) {
4006
4049
  });
4007
4050
  return { status: "hit", cacheDir, packageSpec, command, output: "", ...prune2 ? { prune: prune2 } : {} };
4008
4051
  }
4052
+ await rm(cacheDir, { recursive: true, force: true });
4009
4053
  await mkdir(cacheDir, { recursive: true });
4010
4054
  await writeFile(path6.join(cacheDir, "package.json"), `${JSON.stringify({ private: true, type: "module" }, null, 2)}
4011
4055
  `, "utf8");
@@ -4026,12 +4070,14 @@ async function ensureRuntimeInstalled(options) {
4026
4070
  output: ""
4027
4071
  };
4028
4072
  }
4073
+ await rm(fallbackCacheDir, { recursive: true, force: true });
4029
4074
  await mkdir(fallbackCacheDir, { recursive: true });
4030
4075
  await writeFile(path6.join(fallbackCacheDir, "package.json"), `${JSON.stringify({ private: true, type: "module" }, null, 2)}
4031
4076
  `, "utf8");
4032
4077
  const fallbackResult = runNpmRuntimeInstall(spawnSyncImpl, fallbackCacheDir, fallbackSpec);
4033
4078
  const fallbackOutput = collectSpawnOutput(fallbackResult);
4034
4079
  if (fallbackResult.status === 0) {
4080
+ await assertRequiredRuntimePlatformDependencies(fallbackCacheDir, formatRuntimeInstallCommand(fallbackCacheDir, fallbackSpec), fallbackOutput);
4035
4081
  const fallbackMetadata = {
4036
4082
  version: 1,
4037
4083
  packageName,
@@ -4055,6 +4101,7 @@ async function ensureRuntimeInstalled(options) {
4055
4101
  { cacheDir, command, output }
4056
4102
  );
4057
4103
  }
4104
+ await assertRequiredRuntimePlatformDependencies(cacheDir, command, output);
4058
4105
  const metadata = {
4059
4106
  version: 1,
4060
4107
  packageName,
@@ -4320,7 +4367,7 @@ function parseRuntimeVersion(version) {
4320
4367
  canaryNumber: canaryMatch ? Number(canaryMatch[1]) : null
4321
4368
  };
4322
4369
  }
4323
- var RUNTIME_NPM_PACKAGE_NAME, RUNTIME_METADATA_FILE, DEFAULT_RUNTIME_CACHE_MAX_ENTRIES, DEFAULT_RUNTIME_CACHE_MAX_AGE_MS, DEFAULT_RUNTIME_CACHE_MAX_BYTES, DEFAULT_RUNTIME_CACHE_KEEP_PREVIOUS, RUNTIME_NPM_INSTALL_FLAGS, RuntimeInstallError;
4370
+ var RUNTIME_NPM_PACKAGE_NAME, RUNTIME_METADATA_FILE, DEFAULT_RUNTIME_CACHE_MAX_ENTRIES, DEFAULT_RUNTIME_CACHE_MAX_AGE_MS, DEFAULT_RUNTIME_CACHE_MAX_BYTES, DEFAULT_RUNTIME_CACHE_KEEP_PREVIOUS, RUNTIME_NPM_INSTALL_FLAGS, EMBEDDED_POSTGRES_PACKAGE_NAME, RuntimeInstallError;
4324
4371
  var init_install = __esm({
4325
4372
  "src/runtime/install.ts"() {
4326
4373
  "use strict";
@@ -4332,6 +4379,7 @@ var init_install = __esm({
4332
4379
  DEFAULT_RUNTIME_CACHE_MAX_BYTES = 2 * 1024 * 1024 * 1024;
4333
4380
  DEFAULT_RUNTIME_CACHE_KEEP_PREVIOUS = 0;
4334
4381
  RUNTIME_NPM_INSTALL_FLAGS = ["--omit=dev", "--include=optional", "--no-audit", "--no-fund"];
4382
+ EMBEDDED_POSTGRES_PACKAGE_NAME = "embedded-postgres";
4335
4383
  RuntimeInstallError = class extends Error {
4336
4384
  cacheDir;
4337
4385
  command;