@rudderhq/cli 0.2.6-canary.3 → 0.2.6-canary.5
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 +41 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3797,6 +3797,43 @@ async function ensureRuntimeInstalled(options) {
|
|
|
3797
3797
|
const spawnSyncImpl = options.spawnSyncImpl ?? spawnSync;
|
|
3798
3798
|
const result = runNpmRuntimeInstall(spawnSyncImpl, cacheDir, packageSpec);
|
|
3799
3799
|
const output = collectSpawnOutput(result);
|
|
3800
|
+
if (result.status !== 0 && packageVersion !== "latest" && isVersionNotFoundError(output)) {
|
|
3801
|
+
const fallbackVersion = "latest";
|
|
3802
|
+
const fallbackCacheDir = resolveRuntimeCacheDir(fallbackVersion, options.homeDir);
|
|
3803
|
+
const fallbackSpec = resolveRuntimePackageSpec(fallbackVersion, packageName);
|
|
3804
|
+
if (await isRuntimeCacheHit({ cacheDir: fallbackCacheDir, version: fallbackVersion, packageName })) {
|
|
3805
|
+
await touchRuntimeInstallMetadata(fallbackCacheDir);
|
|
3806
|
+
return {
|
|
3807
|
+
status: "hit",
|
|
3808
|
+
cacheDir: fallbackCacheDir,
|
|
3809
|
+
packageSpec: fallbackSpec,
|
|
3810
|
+
command: `npm install --prefix ${fallbackCacheDir} --omit=dev --no-audit --no-fund ${fallbackSpec}`,
|
|
3811
|
+
output: ""
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
await mkdir(fallbackCacheDir, { recursive: true });
|
|
3815
|
+
await writeFile(path6.join(fallbackCacheDir, "package.json"), `${JSON.stringify({ private: true, type: "module" }, null, 2)}
|
|
3816
|
+
`, "utf8");
|
|
3817
|
+
const fallbackResult = runNpmRuntimeInstall(spawnSyncImpl, fallbackCacheDir, fallbackSpec);
|
|
3818
|
+
const fallbackOutput = collectSpawnOutput(fallbackResult);
|
|
3819
|
+
if (fallbackResult.status === 0) {
|
|
3820
|
+
const fallbackMetadata = {
|
|
3821
|
+
version: 1,
|
|
3822
|
+
packageName,
|
|
3823
|
+
packageVersion: fallbackVersion,
|
|
3824
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3825
|
+
lastUsedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3826
|
+
};
|
|
3827
|
+
await writeRuntimeInstallMetadata(fallbackCacheDir, fallbackMetadata);
|
|
3828
|
+
return {
|
|
3829
|
+
status: "installed",
|
|
3830
|
+
cacheDir: fallbackCacheDir,
|
|
3831
|
+
packageSpec: fallbackSpec,
|
|
3832
|
+
command: `npm install --prefix ${fallbackCacheDir} --omit=dev --no-audit --no-fund ${fallbackSpec}`,
|
|
3833
|
+
output: fallbackOutput
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3800
3837
|
if (result.status !== 0) {
|
|
3801
3838
|
throw new RuntimeInstallError(
|
|
3802
3839
|
`Rudder runtime installation failed. Re-run manually: ${command}`,
|
|
@@ -3840,6 +3877,10 @@ function runNpmRuntimeInstall(spawnSyncImpl, cacheDir, packageSpec) {
|
|
|
3840
3877
|
function collectSpawnOutput(result) {
|
|
3841
3878
|
return [result.stdout, result.stderr, result.error instanceof Error ? result.error.message : null].filter((value) => typeof value === "string" && value.trim().length > 0).join("\n").trim();
|
|
3842
3879
|
}
|
|
3880
|
+
function isVersionNotFoundError(output) {
|
|
3881
|
+
const normalized = output.toLowerCase();
|
|
3882
|
+
return normalized.includes("enoent") || normalized.includes("etarget") || normalized.includes("no matching version found");
|
|
3883
|
+
}
|
|
3843
3884
|
async function maybePruneRuntimeCache(options) {
|
|
3844
3885
|
if (!options.enabled) return null;
|
|
3845
3886
|
return pruneRuntimeCache({
|